summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMukul Rawat <mukulsrawat@gmail.com>2018-10-14 20:54:06 +0530
committerGeorge Goldberg <george@gberg.me>2018-10-14 16:24:06 +0100
commit481d83a1e76415c7e64f2314a7d288ec1ae7aa4f (patch)
tree7e27663098125231297df6dd3db135b1e9c11959 /app
parent38f117ed99e057a915f8f00c96e0dadef0e81cfc (diff)
downloadchat-481d83a1e76415c7e64f2314a7d288ec1ae7aa4f.tar.gz
chat-481d83a1e76415c7e64f2314a7d288ec1ae7aa4f.tar.bz2
chat-481d83a1e76415c7e64f2314a7d288ec1ae7aa4f.zip
[MM-12537] Migrate to idiomatic error handling the file `app/status.go` in the mattermost-server (#9574) (#9589)
* Perform idiomatic error handling * Golint gives warning when using the variable name 'userId' so change it to 'userID' * Change all ID back to Id
Diffstat (limited to 'app')
-rw-r--r--app/status.go46
1 files changed, 23 insertions, 23 deletions
diff --git a/app/status.go b/app/status.go
index bfeb5c77e..bda20b22f 100644
--- a/app/status.go
+++ b/app/status.go
@@ -44,9 +44,7 @@ func (a *App) GetAllStatuses() map[string]*model.Status {
statusMap := map[string]*model.Status{}
for _, userId := range userIds {
- if id, ok := userId.(string); !ok {
- continue
- } else {
+ if id, ok := userId.(string); ok {
status := GetStatusFromCache(id)
if status != nil {
statusMap[id] = status
@@ -81,16 +79,17 @@ func (a *App) GetStatusesByIds(userIds []string) (map[string]interface{}, *model
}
if len(missingUserIds) > 0 {
- if result := <-a.Srv.Store.Status().GetByIds(missingUserIds); result.Err != nil {
+ result := <-a.Srv.Store.Status().GetByIds(missingUserIds)
+ if result.Err != nil {
return nil, result.Err
- } else {
- statuses := result.Data.([]*model.Status)
+ }
+ statuses := result.Data.([]*model.Status)
- for _, s := range statuses {
- a.AddStatusCacheSkipClusterSend(s)
- statusMap[s.UserId] = s.Status
- }
+ for _, s := range statuses {
+ a.AddStatusCacheSkipClusterSend(s)
+ statusMap[s.UserId] = s.Status
}
+
}
// For the case where the user does not have a row in the Status table and cache
@@ -128,17 +127,18 @@ func (a *App) GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.Ap
}
if len(missingUserIds) > 0 {
- if result := <-a.Srv.Store.Status().GetByIds(missingUserIds); result.Err != nil {
+ result := <-a.Srv.Store.Status().GetByIds(missingUserIds)
+ if result.Err != nil {
return nil, result.Err
- } else {
- statuses := result.Data.([]*model.Status)
-
- for _, s := range statuses {
- a.AddStatusCacheSkipClusterSend(s)
- }
+ }
+ statuses := result.Data.([]*model.Status)
- statusMap = append(statusMap, statuses...)
+ for _, s := range statuses {
+ a.AddStatusCacheSkipClusterSend(s)
}
+
+ statusMap = append(statusMap, statuses...)
+
}
// For the case where the user does not have a row in the Status table and cache
@@ -185,8 +185,8 @@ func (a *App) SetStatusOnline(userId string, manual bool) {
broadcast := false
var oldStatus string = model.STATUS_OFFLINE
- var oldTime int64 = 0
- var oldManual bool = false
+ var oldTime int64
+ var oldManual bool
var status *model.Status
var err *model.AppError
@@ -353,11 +353,11 @@ func (a *App) GetStatus(userId string) (*model.Status, *model.AppError) {
return status, nil
}
- if result := <-a.Srv.Store.Status().Get(userId); result.Err != nil {
+ result := <-a.Srv.Store.Status().Get(userId)
+ if result.Err != nil {
return nil, result.Err
- } else {
- return result.Data.(*model.Status), nil
}
+ return result.Data.(*model.Status), nil
}
func (a *App) IsUserAway(lastActivityAt int64) bool {