PLT-2408 Adds here mention for online users (#3619)

* Added @here mention that notifies online users

* Fixed existing race condition that would sometime cause clients to miss mention count changes

* Added missing localization strings

* Prevent @here from mentioning the user who posted it
Этот коммит содержится в:
Joram Wilander
2016-07-21 10:00:09 -04:00
коммит произвёл GitHub
родитель f0e9ec2dd1
Коммит bfa04c0ab0
10 изменённых файлов: 96 добавлений и 13 удалений

Просмотреть файл

@@ -98,7 +98,27 @@ func (s SqlStatusStore) GetOnlineAway() StoreChannel {
var statuses []*model.Status
if _, err := s.GetReplica().Select(&statuses, "SELECT * FROM Status WHERE Status = :Online OR Status = :Away", map[string]interface{}{"Online": model.STATUS_ONLINE, "Away": model.STATUS_AWAY}); err != nil {
result.Err = model.NewLocAppError("SqlStatusStore.GetOnline", "store.sql_status.get_online_away.app_error", nil, err.Error())
result.Err = model.NewLocAppError("SqlStatusStore.GetOnlineAway", "store.sql_status.get_online_away.app_error", nil, err.Error())
} else {
result.Data = statuses
}
storeChannel <- result
close(storeChannel)
}()
return storeChannel
}
func (s SqlStatusStore) GetOnline() StoreChannel {
storeChannel := make(StoreChannel)
go func() {
result := StoreResult{}
var statuses []*model.Status
if _, err := s.GetReplica().Select(&statuses, "SELECT * FROM Status WHERE Status = :Online", map[string]interface{}{"Online": model.STATUS_ONLINE}); err != nil {
result.Err = model.NewLocAppError("SqlStatusStore.GetOnline", "store.sql_status.get_online.app_error", nil, err.Error())
} else {
result.Data = statuses
}

Просмотреть файл

@@ -48,6 +48,17 @@ func TestSqlStatusStore(t *testing.T) {
}
}
if result := <-store.Status().GetOnline(); result.Err != nil {
t.Fatal(result.Err)
} else {
statuses := result.Data.([]*model.Status)
for _, status := range statuses {
if status.Status != model.STATUS_ONLINE {
t.Fatal("should not have returned offline statuses")
}
}
}
if err := (<-store.Status().ResetAll()).Err; err != nil {
t.Fatal(err)
}

Просмотреть файл

@@ -266,6 +266,7 @@ type StatusStore interface {
SaveOrUpdate(status *model.Status) StoreChannel
Get(userId string) StoreChannel
GetOnlineAway() StoreChannel
GetOnline() StoreChannel
ResetAll() StoreChannel
GetTotalActiveUsersCount() StoreChannel
UpdateLastActivityAt(userId string, lastActivityAt int64) StoreChannel