summaryrefslogtreecommitdiffstats
path: root/store/redis_supplier_reactions.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2018-03-27 22:36:55 +0100
committerGeorge Goldberg <george@gberg.me>2018-03-27 22:36:55 +0100
commit71c9dff7662868770f66ab876ad66b354133c2c1 (patch)
treee2d5d8c5ad203b42af868ee18399c42a9ab08385 /store/redis_supplier_reactions.go
parent2af4c7e6496d4c5192fedf5001817f6f1eb3664b (diff)
parente13e64711f7a7e8ceadb8cbc6af72c4022c95b36 (diff)
downloadchat-71c9dff7662868770f66ab876ad66b354133c2c1.tar.gz
chat-71c9dff7662868770f66ab876ad66b354133c2c1.tar.bz2
chat-71c9dff7662868770f66ab876ad66b354133c2c1.zip
Merge branch 'advanced-permissions-phase-1'
Diffstat (limited to 'store/redis_supplier_reactions.go')
-rw-r--r--store/redis_supplier_reactions.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/store/redis_supplier_reactions.go b/store/redis_supplier_reactions.go
new file mode 100644
index 000000000..cece8113d
--- /dev/null
+++ b/store/redis_supplier_reactions.go
@@ -0,0 +1,57 @@
+// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package store
+
+import (
+ "context"
+
+ l4g "github.com/alecthomas/log4go"
+
+ "github.com/mattermost/mattermost-server/model"
+)
+
+func (s *RedisSupplier) ReactionSave(ctx context.Context, reaction *model.Reaction, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
+ if err := s.client.Del("reactions:" + reaction.PostId).Err(); err != nil {
+ l4g.Error("Redis failed to remove key reactions:" + reaction.PostId + " Error: " + err.Error())
+ }
+ return s.Next().ReactionSave(ctx, reaction, hints...)
+}
+
+func (s *RedisSupplier) ReactionDelete(ctx context.Context, reaction *model.Reaction, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
+ if err := s.client.Del("reactions:" + reaction.PostId).Err(); err != nil {
+ l4g.Error("Redis failed to remove key reactions:" + reaction.PostId + " Error: " + err.Error())
+ }
+ return s.Next().ReactionDelete(ctx, reaction, hints...)
+}
+
+func (s *RedisSupplier) ReactionGetForPost(ctx context.Context, postId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
+ var resultdata []*model.Reaction
+ found, err := s.load("reactions:"+postId, &resultdata)
+ if found {
+ result := NewSupplierResult()
+ result.Data = resultdata
+ return result
+ }
+ if err != nil {
+ l4g.Error("Redis encountered an error on read: " + err.Error())
+ }
+
+ result := s.Next().ReactionGetForPost(ctx, postId, hints...)
+
+ if err := s.save("reactions:"+postId, result.Data, REDIS_EXPIRY_TIME); err != nil {
+ l4g.Error("Redis encountered and error on write: " + err.Error())
+ }
+
+ return result
+}
+
+func (s *RedisSupplier) ReactionDeleteAllWithEmojiName(ctx context.Context, emojiName string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
+ // Ignoring this. It's probably OK to have the emoji slowly expire from Redis.
+ return s.Next().ReactionDeleteAllWithEmojiName(ctx, emojiName, hints...)
+}
+
+func (s *RedisSupplier) ReactionPermanentDeleteBatch(ctx context.Context, endTime int64, limit int64, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
+ // Ignoring this. It's probably OK to have the emoji slowly expire from Redis.
+ return s.Next().ReactionPermanentDeleteBatch(ctx, endTime, limit, hints...)
+}