[MM-16751] golint model (#17896)
Этот коммит содержится в:
коммит произвёл
Claudio Costa
родитель
953eebdef4
Коммит
97ccf0bdf6
@@ -22,8 +22,8 @@ func (a *App) AddStatusCache(status *model.Status) {
|
||||
|
||||
if a.Cluster() != nil {
|
||||
msg := &model.ClusterMessage{
|
||||
Event: model.CLUSTER_EVENT_UPDATE_STATUS,
|
||||
SendType: model.CLUSTER_SEND_BEST_EFFORT,
|
||||
Event: model.ClusterEventUpdateStatus,
|
||||
SendType: model.ClusterSendBestEffort,
|
||||
Data: status.ToClusterJson(),
|
||||
}
|
||||
a.Cluster().SendClusterMessage(msg)
|
||||
@@ -87,7 +87,7 @@ func (a *App) GetStatusesByIds(userIDs []string) (map[string]interface{}, *model
|
||||
// For the case where the user does not have a row in the Status table and cache
|
||||
for _, userID := range missingUserIds {
|
||||
if _, ok := statusMap[userID]; !ok {
|
||||
statusMap[userID] = model.STATUS_OFFLINE
|
||||
statusMap[userID] = model.StatusOffline
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,21 +176,21 @@ func (a *App) SetStatusOnline(userID string, manual bool) {
|
||||
|
||||
broadcast := false
|
||||
|
||||
var oldStatus string = model.STATUS_OFFLINE
|
||||
var oldStatus string = model.StatusOffline
|
||||
var oldTime int64
|
||||
var oldManual bool
|
||||
var status *model.Status
|
||||
var err *model.AppError
|
||||
|
||||
if status, err = a.GetStatus(userID); err != nil {
|
||||
status = &model.Status{UserId: userID, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
status = &model.Status{UserId: userID, Status: model.StatusOnline, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
broadcast = true
|
||||
} else {
|
||||
if status.Manual && !manual {
|
||||
return // manually set status always overrides non-manual one
|
||||
}
|
||||
|
||||
if status.Status != model.STATUS_ONLINE {
|
||||
if status.Status != model.StatusOnline {
|
||||
broadcast = true
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ func (a *App) SetStatusOnline(userID string, manual bool) {
|
||||
oldTime = status.LastActivityAt
|
||||
oldManual = status.Manual
|
||||
|
||||
status.Status = model.STATUS_ONLINE
|
||||
status.Status = model.StatusOnline
|
||||
status.Manual = false // for "online" there's no manual setting
|
||||
status.LastActivityAt = model.GetMillis()
|
||||
}
|
||||
@@ -207,7 +207,7 @@ func (a *App) SetStatusOnline(userID string, manual bool) {
|
||||
|
||||
// Only update the database if the status has changed, the status has been manually set,
|
||||
// or enough time has passed since the previous action
|
||||
if status.Status != oldStatus || status.Manual != oldManual || status.LastActivityAt-oldTime > model.STATUS_MIN_UPDATE_TIME {
|
||||
if status.Status != oldStatus || status.Manual != oldManual || status.LastActivityAt-oldTime > model.StatusMinUpdateTime {
|
||||
if broadcast {
|
||||
if err := a.Srv().Store.Status().SaveOrUpdate(status); err != nil {
|
||||
mlog.Warn("Failed to save status", mlog.String("user_id", userID), mlog.Err(err), mlog.String("user_id", userID))
|
||||
@@ -229,7 +229,7 @@ func (a *App) BroadcastStatus(status *model.Status) {
|
||||
// this is considered a non-critical service and will be disabled when server busy.
|
||||
return
|
||||
}
|
||||
event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_STATUS_CHANGE, "", "", status.UserId, nil)
|
||||
event := model.NewWebSocketEvent(model.WebsocketEventStatusChange, "", "", status.UserId, nil)
|
||||
event.Add("status", status.Status)
|
||||
event.Add("user_id", status.UserId)
|
||||
a.Publish(event)
|
||||
@@ -245,7 +245,7 @@ func (a *App) SetStatusOffline(userID string, manual bool) {
|
||||
return // manually set status always overrides non-manual one
|
||||
}
|
||||
|
||||
status = &model.Status{UserId: userID, Status: model.STATUS_OFFLINE, Manual: manual, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
status = &model.Status{UserId: userID, Status: model.StatusOffline, Manual: manual, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||
|
||||
a.SaveAndBroadcastStatus(status)
|
||||
}
|
||||
@@ -258,7 +258,7 @@ func (a *App) SetStatusAwayIfNeeded(userID string, manual bool) {
|
||||
status, err := a.GetStatus(userID)
|
||||
|
||||
if err != nil {
|
||||
status = &model.Status{UserId: userID, Status: model.STATUS_OFFLINE, Manual: manual, LastActivityAt: 0, ActiveChannel: ""}
|
||||
status = &model.Status{UserId: userID, Status: model.StatusOffline, Manual: manual, LastActivityAt: 0, ActiveChannel: ""}
|
||||
}
|
||||
|
||||
if !manual && status.Manual {
|
||||
@@ -266,7 +266,7 @@ func (a *App) SetStatusAwayIfNeeded(userID string, manual bool) {
|
||||
}
|
||||
|
||||
if !manual {
|
||||
if status.Status == model.STATUS_AWAY {
|
||||
if status.Status == model.StatusAway {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ func (a *App) SetStatusAwayIfNeeded(userID string, manual bool) {
|
||||
}
|
||||
}
|
||||
|
||||
status.Status = model.STATUS_AWAY
|
||||
status.Status = model.StatusAway
|
||||
status.Manual = manual
|
||||
status.ActiveChannel = ""
|
||||
|
||||
@@ -292,11 +292,11 @@ func (a *App) SetStatusDoNotDisturbTimed(userId string, endtime int64) {
|
||||
status, err := a.GetStatus(userId)
|
||||
|
||||
if err != nil {
|
||||
status = &model.Status{UserId: userId, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
status = &model.Status{UserId: userId, Status: model.StatusOffline, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
}
|
||||
|
||||
status.PrevStatus = status.Status
|
||||
status.Status = model.STATUS_DND
|
||||
status.Status = model.StatusDnd
|
||||
status.Manual = true
|
||||
|
||||
status.DNDEndTime = endtime
|
||||
@@ -312,10 +312,10 @@ func (a *App) SetStatusDoNotDisturb(userID string) {
|
||||
status, err := a.GetStatus(userID)
|
||||
|
||||
if err != nil {
|
||||
status = &model.Status{UserId: userID, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
status = &model.Status{UserId: userID, Status: model.StatusOffline, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
}
|
||||
|
||||
status.Status = model.STATUS_DND
|
||||
status.Status = model.StatusDnd
|
||||
status.Manual = true
|
||||
|
||||
a.SaveAndBroadcastStatus(status)
|
||||
@@ -339,10 +339,10 @@ func (a *App) SetStatusOutOfOffice(userID string) {
|
||||
status, err := a.GetStatus(userID)
|
||||
|
||||
if err != nil {
|
||||
status = &model.Status{UserId: userID, Status: model.STATUS_OUT_OF_OFFICE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
status = &model.Status{UserId: userID, Status: model.StatusOutOfOffice, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
}
|
||||
|
||||
status.Status = model.STATUS_OUT_OF_OFFICE
|
||||
status.Status = model.StatusOutOfOffice
|
||||
status.Manual = true
|
||||
|
||||
a.SaveAndBroadcastStatus(status)
|
||||
@@ -439,7 +439,7 @@ func (a *App) RemoveCustomStatus(userID string) *model.AppError {
|
||||
func (a *App) addRecentCustomStatus(userID string, status *model.CustomStatus) *model.AppError {
|
||||
var newRCS *model.RecentCustomStatuses
|
||||
|
||||
pref, err := a.GetPreferenceByCategoryAndNameForUser(userID, model.PREFERENCE_CATEGORY_CUSTOM_STATUS, model.PREFERENCE_NAME_RECENT_CUSTOM_STATUSES)
|
||||
pref, err := a.GetPreferenceByCategoryAndNameForUser(userID, model.PreferenceCategoryCustomStatus, model.PreferenceNameRecentCustomStatuses)
|
||||
if err != nil || pref.Value == "" {
|
||||
newRCS = &model.RecentCustomStatuses{*status}
|
||||
} else {
|
||||
@@ -449,8 +449,8 @@ func (a *App) addRecentCustomStatus(userID string, status *model.CustomStatus) *
|
||||
|
||||
pref = &model.Preference{
|
||||
UserId: userID,
|
||||
Category: model.PREFERENCE_CATEGORY_CUSTOM_STATUS,
|
||||
Name: model.PREFERENCE_NAME_RECENT_CUSTOM_STATUSES,
|
||||
Category: model.PreferenceCategoryCustomStatus,
|
||||
Name: model.PreferenceNameRecentCustomStatuses,
|
||||
Value: newRCS.ToJson(),
|
||||
}
|
||||
if err := a.UpdatePreferences(userID, model.Preferences{*pref}); err != nil {
|
||||
@@ -461,7 +461,7 @@ func (a *App) addRecentCustomStatus(userID string, status *model.CustomStatus) *
|
||||
}
|
||||
|
||||
func (a *App) RemoveRecentCustomStatus(userID string, status *model.CustomStatus) *model.AppError {
|
||||
pref, err := a.GetPreferenceByCategoryAndNameForUser(userID, model.PREFERENCE_CATEGORY_CUSTOM_STATUS, model.PREFERENCE_NAME_RECENT_CUSTOM_STATUSES)
|
||||
pref, err := a.GetPreferenceByCategoryAndNameForUser(userID, model.PreferenceCategoryCustomStatus, model.PreferenceNameRecentCustomStatuses)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user