diff options
author | Corey Hulen <corey@hulen.com> | 2016-07-14 04:18:18 -0800 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-07-14 08:18:18 -0400 |
commit | 294981d4a3a36d48c983a3a92cf423910347b4c4 (patch) | |
tree | 1f72d3e951af15d5d8a6197358bdb554cd3f4272 /store | |
parent | 0858c34314487c6c81075c531c88cd3b56d665a4 (diff) | |
download | chat-294981d4a3a36d48c983a3a92cf423910347b4c4.tar.gz chat-294981d4a3a36d48c983a3a92cf423910347b4c4.tar.bz2 chat-294981d4a3a36d48c983a3a92cf423910347b4c4.zip |
PLT-3547 fixing caching issue with direct profiles (#3567)
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_user_store.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go index df132ab42..d4b65d04d 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -4,6 +4,7 @@ package store import ( + "crypto/md5" "database/sql" "fmt" "strconv" @@ -480,9 +481,10 @@ func (s SqlUserStore) GetEtagForDirectProfiles(userId string) StoreChannel { go func() { result := StoreResult{} - updateAt, err := s.GetReplica().SelectInt(` + var ids []string + _, err := s.GetReplica().Select(ids, ` SELECT - UpdateAt + Id FROM Users WHERE @@ -508,12 +510,14 @@ func (s SqlUserStore) GetEtagForDirectProfiles(userId string) StoreChannel { WHERE UserId = :UserId AND Category = 'direct_channel_show') - ORDER BY UpdateAt DESC LIMIT 1 + ORDER BY UpdateAt DESC `, map[string]interface{}{"UserId": userId}) - if err != nil { - result.Data = fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.GetMillis(), utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress) + + if err != nil || len(ids) == 0 { + result.Data = fmt.Sprintf("%v.%v.0.%v.%v", model.CurrentVersion, model.GetMillis(), utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress) } else { - result.Data = fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, updateAt, utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress) + allIds := strings.Join(ids, "") + result.Data = fmt.Sprintf("%v.%v.%v.%v.%v", model.CurrentVersion, md5.Sum([]byte(allIds)), len(ids), utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress) } storeChannel <- result |