[MM-41573] - Remove FF for MM-39060 Resend Invite Interval (#19652)
* [MM-41573] - Remove FF for MM-39060 Resend Invite Interval * feedback impl
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
20a0178dcb
Коммит
d543db6186
39
api4/team.go
39
api4/team.go
@@ -1311,28 +1311,6 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// we get the emailList after it has finished checks like the emails over the list
|
||||
|
||||
scheduledAt := model.GetMillis()
|
||||
jobData := map[string]string{
|
||||
"emailList": model.ArrayToJSON(emailList),
|
||||
"teamID": c.Params.TeamId,
|
||||
"senderID": c.AppContext.Session().UserId,
|
||||
"scheduledAt": strconv.FormatInt(scheduledAt, 10),
|
||||
}
|
||||
|
||||
// we then manually schedule the job
|
||||
j, e := c.App.Srv().Jobs.CreateJob(model.JobTypeResendInvitationEmail, jobData)
|
||||
if e != nil {
|
||||
c.Err = model.NewAppError("Api4.inviteUsersToTeam", e.Id, nil, e.Error(), e.StatusCode)
|
||||
return
|
||||
}
|
||||
|
||||
sysVar := &model.System{Name: j.Id, Value: "0"}
|
||||
if sysValErr := c.App.Srv().Store.System().SaveOrUpdate(sysVar); sysValErr != nil {
|
||||
mlog.Warn("Error while saving system value", mlog.Err(sysValErr))
|
||||
}
|
||||
|
||||
var invitesWithError []*model.EmailInviteWithError
|
||||
var err *model.AppError
|
||||
if emailList != nil {
|
||||
@@ -1356,6 +1334,23 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
// we get the emailList after it has finished checks like the emails over the list
|
||||
scheduledAt := model.GetMillis()
|
||||
jobData := map[string]string{
|
||||
"emailList": model.ArrayToJSON(emailList),
|
||||
"teamID": c.Params.TeamId,
|
||||
"senderID": c.AppContext.Session().UserId,
|
||||
"scheduledAt": strconv.FormatInt(scheduledAt, 10),
|
||||
}
|
||||
|
||||
// we then manually schedule the job to send another invite after 48 hours
|
||||
_, e := c.App.Srv().Jobs.CreateJob(model.JobTypeResendInvitationEmail, jobData)
|
||||
if e != nil {
|
||||
c.Err = model.NewAppError("Api4.inviteUsersToTeam", e.Id, nil, e.Error(), e.StatusCode)
|
||||
return
|
||||
}
|
||||
|
||||
// in graceful mode we return both the successful ones and the failed ones
|
||||
js, jsonErr := json.Marshal(invitesWithError)
|
||||
if jsonErr != nil {
|
||||
|
||||
@@ -16,9 +16,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v6/store"
|
||||
)
|
||||
|
||||
const TwentyFourHoursInMillis int64 = 86400000
|
||||
const FourtyEightHoursInMillis int64 = 172800000
|
||||
const SeventyTwoHoursInMillis int64 = 259200000
|
||||
|
||||
type AppIface interface {
|
||||
configservice.ConfigService
|
||||
@@ -87,52 +85,9 @@ func (rseworker *ResendInvitationEmailWorker) JobChannel() chan<- model.Job {
|
||||
}
|
||||
|
||||
func (rseworker *ResendInvitationEmailWorker) DoJob(job *model.Job) {
|
||||
resendInviteEmailIntervalFlag := rseworker.app.Config().FeatureFlags.ResendInviteEmailInterval
|
||||
|
||||
switch resendInviteEmailIntervalFlag {
|
||||
case "48":
|
||||
rseworker.DoJob_24_48(job)
|
||||
case "72":
|
||||
rseworker.DoJob_24_72(job)
|
||||
default:
|
||||
rseworker.DoJob_24(job)
|
||||
}
|
||||
}
|
||||
|
||||
func (rseworker *ResendInvitationEmailWorker) DoJob_24(job *model.Job) {
|
||||
elapsedTimeSinceSchedule, DurationInMillis_24, _, _ := rseworker.GetDurations(job)
|
||||
if elapsedTimeSinceSchedule > DurationInMillis_24 {
|
||||
rseworker.ResendEmails(job, "24")
|
||||
rseworker.TearDown(job)
|
||||
}
|
||||
}
|
||||
|
||||
func (rseworker *ResendInvitationEmailWorker) DoJob_24_48(job *model.Job) {
|
||||
elapsedTimeSinceSchedule, DurationInMillis_24, DurationInMillis_48, _ := rseworker.GetDurations(job)
|
||||
rseworker.Execute(job, elapsedTimeSinceSchedule, DurationInMillis_24, DurationInMillis_48, "24", "48")
|
||||
}
|
||||
|
||||
func (rseworker *ResendInvitationEmailWorker) DoJob_24_72(job *model.Job) {
|
||||
elapsedTimeSinceSchedule, DurationInMillis_24, _, DurationInMillis_72 := rseworker.GetDurations(job)
|
||||
rseworker.Execute(job, elapsedTimeSinceSchedule, DurationInMillis_24, DurationInMillis_72, "24", "72")
|
||||
}
|
||||
|
||||
func (rseworker *ResendInvitationEmailWorker) Execute(job *model.Job, elapsedTimeSinceSchedule, firstDuration, secondDuration int64, firstDurationTelemetryValue, secondDurationTelemetryValue string) {
|
||||
systemValue, sysValErr := rseworker.store.System().GetByName(job.Id)
|
||||
if sysValErr != nil {
|
||||
if _, ok := sysValErr.(*store.ErrNotFound); !ok {
|
||||
mlog.Error("An error occurred while getting NUMBER_OF_INVITE_EMAILS_SENT from system store", mlog.String("worker", rseworker.name), mlog.Err(sysValErr))
|
||||
// system value information is critical and if it was not set for this job at creation, we want to cancel the job all together.
|
||||
rseworker.setJobCancelled(job)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (elapsedTimeSinceSchedule > firstDuration) && (systemValue == nil || systemValue.Value == "0") {
|
||||
rseworker.ResendEmails(job, firstDurationTelemetryValue)
|
||||
rseworker.setNumResendEmailSent(job, "1")
|
||||
} else if elapsedTimeSinceSchedule > secondDuration {
|
||||
rseworker.ResendEmails(job, secondDurationTelemetryValue)
|
||||
elapsedTimeSinceSchedule, DurationInMillis := rseworker.GetDurations(job)
|
||||
if elapsedTimeSinceSchedule > DurationInMillis {
|
||||
rseworker.ResendEmails(job, "48")
|
||||
rseworker.TearDown(job)
|
||||
}
|
||||
}
|
||||
@@ -144,13 +99,6 @@ func (rseworker *ResendInvitationEmailWorker) setJobSuccess(job *model.Job) {
|
||||
}
|
||||
}
|
||||
|
||||
func (rseworker *ResendInvitationEmailWorker) setJobCancelled(job *model.Job) {
|
||||
if err := rseworker.jobServer.SetJobCanceled(job); err != nil {
|
||||
mlog.Error("Worker: Failed to cancel job", mlog.String("worker", rseworker.name), mlog.String("job_id", job.Id), mlog.String("error", err.Error()))
|
||||
rseworker.setJobError(job, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (rseworker *ResendInvitationEmailWorker) setJobError(job *model.Job, appError *model.AppError) {
|
||||
if err := rseworker.jobServer.SetJobError(job, appError); err != nil {
|
||||
mlog.Error("Worker: Failed to set job error", mlog.String("worker", rseworker.name), mlog.String("job_id", job.Id), mlog.String("error", err.Error()))
|
||||
@@ -188,41 +136,20 @@ func (rseworker *ResendInvitationEmailWorker) removeAlreadyJoined(teamID string,
|
||||
return notJoinedYet
|
||||
}
|
||||
|
||||
func (rseworker *ResendInvitationEmailWorker) setNumResendEmailSent(job *model.Job, num string) {
|
||||
sysVar := &model.System{Name: job.Id, Value: num}
|
||||
if err := rseworker.store.System().SaveOrUpdate(sysVar); err != nil {
|
||||
mlog.Error("Unable to save NUMBER_OF_INVITE_EMAIL_SENT", mlog.String("worker", rseworker.name), mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
func (rseworker *ResendInvitationEmailWorker) GetDurations(job *model.Job) (int64, int64, int64, int64) {
|
||||
func (rseworker *ResendInvitationEmailWorker) GetDurations(job *model.Job) (int64, int64) {
|
||||
scheduledAt, _ := strconv.ParseInt(job.Data["scheduledAt"], 10, 64)
|
||||
now := model.GetMillis()
|
||||
|
||||
elapsedTimeSinceSchedule := now - scheduledAt
|
||||
|
||||
duration_24 := os.Getenv("MM_RESEND_INVITATION_EMAIL_JOB_DURATION")
|
||||
DurationInMillis_24, parseError := strconv.ParseInt(duration_24, 10, 64)
|
||||
if parseError != nil {
|
||||
// default to 24 hours
|
||||
DurationInMillis_24 = TwentyFourHoursInMillis
|
||||
}
|
||||
|
||||
duration_48 := os.Getenv("MM_RESEND_INVITATION_EMAIL_JOB_DURATION_48")
|
||||
DurationInMillis_48, parseError := strconv.ParseInt(duration_48, 10, 64)
|
||||
duration := os.Getenv("MM_RESEND_INVITATION_EMAIL_JOB_DURATION")
|
||||
DurationInMillis, parseError := strconv.ParseInt(duration, 10, 64)
|
||||
if parseError != nil {
|
||||
// default to 48 hours
|
||||
DurationInMillis_48 = FourtyEightHoursInMillis
|
||||
DurationInMillis = FourtyEightHoursInMillis
|
||||
}
|
||||
|
||||
duration_72 := os.Getenv("MM_RESEND_INVITATION_EMAIL_JOB_DURATION_72")
|
||||
DurationInMillis_72, parseError := strconv.ParseInt(duration_72, 10, 64)
|
||||
if parseError != nil {
|
||||
// default to 72 hours
|
||||
DurationInMillis_72 = SeventyTwoHoursInMillis
|
||||
}
|
||||
|
||||
return elapsedTimeSinceSchedule, DurationInMillis_24, DurationInMillis_48, DurationInMillis_72
|
||||
return elapsedTimeSinceSchedule, DurationInMillis
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ type FeatureFlags struct {
|
||||
// A/B test for the add members to channel button, possible values = ("top", "bottom")
|
||||
AddMembersToChannel string
|
||||
|
||||
// Determine after which duration in hours to send a second invitation to someone that didn't join after the initial invite, possible values = ("48", "72")
|
||||
ResendInviteEmailInterval string
|
||||
// Enable Create First Channel
|
||||
GuidedChannelCreation bool
|
||||
|
||||
// A/B test for whether radio buttons or toggle button is more effective in in-screen invite to team modal ("none", "toggle")
|
||||
InviteToTeam string
|
||||
@@ -97,7 +97,7 @@ func (f *FeatureFlags) SetDefaults() {
|
||||
f.CallsMobile = false
|
||||
f.BoardsFeatureFlags = ""
|
||||
f.AddMembersToChannel = "top"
|
||||
f.ResendInviteEmailInterval = ""
|
||||
f.GuidedChannelCreation = false
|
||||
f.InviteToTeam = "none"
|
||||
f.CustomGroups = true
|
||||
f.InlinePostEditing = false
|
||||
|
||||
Ссылка в новой задаче
Block a user