mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-11272 Added initial post metadata (#9175)
* MM-11272 Added app.PreparePostForClient * MM-11272 Added app.PreparePostListForClient * MM-11272 Added EmojiStore.GetMultipleByName * MM-11272 Added emojis to PreparePostForClient * MM-11272 Added unit tests for getting reaction counts * MM-11272 Added unit tests for TestPreparePostForClient * MM-11272 Added emojis from reactions to Post.Emojis * MM-11272 Always update post.UpdateAt when reactions change to bust cache * Fixed merge conflicts * Moved post metadata-related code into its own file * Update store mocks * Fixed typo * Add missing license headers * Updated post metadata tests when custom emojis are disabled * Fix unreliable unit tests * Fix inconsistent casing in SQL statements * Fix blank line * Invalidate store cache after making changes * Clear post cache synchronously with reactions
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
func (s *RedisSupplier) RoleSave(ctx context.Context, role *model.Role, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
key := buildRedisKeyForRoleName(role.Name)
|
||||
result := s.Next().RoleSave(ctx, role, hints...)
|
||||
|
||||
defer func() {
|
||||
if err := s.client.Del(key).Err(); err != nil {
|
||||
@@ -20,7 +21,7 @@ func (s *RedisSupplier) RoleSave(ctx context.Context, role *model.Role, hints ..
|
||||
}
|
||||
}()
|
||||
|
||||
return s.Next().RoleSave(ctx, role, hints...)
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *RedisSupplier) RoleGet(ctx context.Context, roleId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
@@ -86,6 +87,7 @@ func (s *RedisSupplier) RoleGetByNames(ctx context.Context, roleNames []string,
|
||||
}
|
||||
|
||||
func (s *RedisSupplier) RoleDelete(ctx context.Context, roleId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
// XXXXXX Shouldn't this call Role
|
||||
result := s.Next().RoleGet(ctx, roleId, hints...)
|
||||
|
||||
if result.Err == nil {
|
||||
@@ -103,17 +105,17 @@ func (s *RedisSupplier) RoleDelete(ctx context.Context, roleId string, hints ...
|
||||
}
|
||||
|
||||
func (s *RedisSupplier) RolePermanentDeleteAll(ctx context.Context, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
defer func() {
|
||||
if keys, err := s.client.Keys("roles:*").Result(); err != nil {
|
||||
mlog.Error("Redis encountered an error on read: " + err.Error())
|
||||
} else {
|
||||
if err := s.client.Del(keys...).Err(); err != nil {
|
||||
mlog.Error("Redis encountered an error on delete: " + err.Error())
|
||||
}
|
||||
}
|
||||
}()
|
||||
result := s.Next().RolePermanentDeleteAll(ctx, hints...)
|
||||
|
||||
return s.Next().RolePermanentDeleteAll(ctx, hints...)
|
||||
if keys, err := s.client.Keys("roles:*").Result(); err != nil {
|
||||
mlog.Error("Redis encountered an error on read: " + err.Error())
|
||||
} else {
|
||||
if err := s.client.Del(keys...).Err(); err != nil {
|
||||
mlog.Error("Redis encountered an error on delete: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func buildRedisKeyForRoleName(roleName string) string {
|
||||
|
||||
Reference in New Issue
Block a user