summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/command_statuses_test.go2
-rw-r--r--api/context.go1
-rw-r--r--api/post.go10
-rw-r--r--api/slackimport.go2
-rw-r--r--api/web_hub.go20
5 files changed, 32 insertions, 3 deletions
diff --git a/api/command_statuses_test.go b/api/command_statuses_test.go
index 47628de3f..063d76062 100644
--- a/api/command_statuses_test.go
+++ b/api/command_statuses_test.go
@@ -27,7 +27,7 @@ func commandAndTest(t *testing.T, th *TestHelper, status string) {
t.Fatal("Command failed to execute")
}
- time.Sleep(500 * time.Millisecond)
+ time.Sleep(1000 * time.Millisecond)
statuses := Client.Must(Client.GetStatuses()).Data.(map[string]string)
diff --git a/api/context.go b/api/context.go
index 1e82acb68..91f17dada 100644
--- a/api/context.go
+++ b/api/context.go
@@ -564,4 +564,5 @@ func InvalidateAllCaches() {
ClearStatusCache()
store.ClearChannelCaches()
store.ClearUserCaches()
+ store.ClearPostCaches()
}
diff --git a/api/post.go b/api/post.go
index 143dbf7e1..a4a493060 100644
--- a/api/post.go
+++ b/api/post.go
@@ -166,6 +166,8 @@ func CreatePost(c *Context, post *model.Post, triggerWebhooks bool) (*model.Post
}
}
+ InvalidateCacheForChannelPosts(rpost.ChannelId)
+
handlePostEvents(c, rpost, triggerWebhooks)
return rpost, nil
@@ -1226,6 +1228,8 @@ func updatePost(c *Context, w http.ResponseWriter, r *http.Request) {
go Publish(message)
+ InvalidateCacheForChannelPosts(rpost.ChannelId)
+
w.Write([]byte(rpost.ToJson()))
}
}
@@ -1278,7 +1282,7 @@ func getPosts(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- etagChan := Srv.Store.Post().GetEtag(id)
+ etagChan := Srv.Store.Post().GetEtag(id, true)
if !HasPermissionToChannelContext(c, id, model.PERMISSION_CREATE_POST) {
return
@@ -1508,6 +1512,8 @@ func deletePost(c *Context, w http.ResponseWriter, r *http.Request) {
go DeletePostFiles(post)
go DeleteFlaggedPost(c.Session.UserId, post)
+ InvalidateCacheForChannelPosts(post.ChannelId)
+
result := make(map[string]string)
result["id"] = postId
w.Write([]byte(model.MapToJson(result)))
@@ -1567,7 +1573,7 @@ func getPostsBeforeOrAfter(c *Context, w http.ResponseWriter, r *http.Request, b
}
// We can do better than this etag in this situation
- etagChan := Srv.Store.Post().GetEtag(id)
+ etagChan := Srv.Store.Post().GetEtag(id, true)
if !HasPermissionToChannelContext(c, id, model.PERMISSION_READ_CHANNEL) {
return
diff --git a/api/slackimport.go b/api/slackimport.go
index 1225e7833..3fd0ec3f6 100644
--- a/api/slackimport.go
+++ b/api/slackimport.go
@@ -560,6 +560,8 @@ func SlackImport(fileData multipart.File, fileSize int64, teamID string) (*model
deactivateSlackBotUser(botUser)
}
+ InvalidateAllCaches()
+
log.WriteString(utils.T("api.slackimport.slack_import.notes"))
log.WriteString("=======\r\n\r\n")
diff --git a/api/web_hub.go b/api/web_hub.go
index ce11d26b0..da40bf1c7 100644
--- a/api/web_hub.go
+++ b/api/web_hub.go
@@ -103,10 +103,30 @@ func PublishSkipClusterSend(message *model.WebSocketEvent) {
}
func InvalidateCacheForChannel(channelId string) {
+ InvalidateCacheForChannelSkipClusterSend(channelId)
+
+ if cluster := einterfaces.GetClusterInterface(); cluster != nil {
+ cluster.InvalidateCacheForChannel(channelId)
+ }
+}
+
+func InvalidateCacheForChannelSkipClusterSend(channelId string) {
Srv.Store.User().InvalidateProfilesInChannelCache(channelId)
Srv.Store.Channel().InvalidateMemberCount(channelId)
}
+func InvalidateCacheForChannelPosts(channelId string) {
+ InvalidateCacheForChannelPostsSkipClusterSend(channelId)
+
+ if cluster := einterfaces.GetClusterInterface(); cluster != nil {
+ cluster.InvalidateCacheForChannelPosts(channelId)
+ }
+}
+
+func InvalidateCacheForChannelPostsSkipClusterSend(channelId string) {
+ Srv.Store.Post().InvalidatePostEtagCache(channelId)
+}
+
func InvalidateCacheForUser(userId string) {
InvalidateCacheForUserSkipClusterSend(userId)