summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-11-14 07:09:41 -0500
committerChristopher Speller <crspeller@gmail.com>2016-11-14 07:09:41 -0500
commit323ce8b203c570ed6a1dd57b44d6637ad8207616 (patch)
treeefc3c61b905244bdb0e1ace0ce9f5ae4876644ad /api
parentd1207d34c1d99eba9ebf85c98d267ee7e955ea7d (diff)
parentb55ec6148caa93d54b660afe55408c643d217108 (diff)
downloadchat-323ce8b203c570ed6a1dd57b44d6637ad8207616.tar.gz
chat-323ce8b203c570ed6a1dd57b44d6637ad8207616.tar.bz2
chat-323ce8b203c570ed6a1dd57b44d6637ad8207616.zip
Merge branch 'release-3.5'
Diffstat (limited to 'api')
-rw-r--r--api/channel.go4
-rw-r--r--api/channel_test.go2
-rw-r--r--api/user.go3
-rw-r--r--api/web_conn.go8
-rw-r--r--api/web_hub.go7
-rw-r--r--api/webhook.go2
-rw-r--r--api/websocket_router.go1
7 files changed, 23 insertions, 4 deletions
diff --git a/api/channel.go b/api/channel.go
index 2232786fd..ea39ee398 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -77,7 +77,7 @@ func createChannel(c *Context, w http.ResponseWriter, r *http.Request) {
if channel.TeamId == c.TeamId {
// Get total number of channels on current team
- if result := <-Srv.Store.Channel().GetChannels(channel.TeamId, c.Session.UserId); result.Err != nil {
+ if result := <-Srv.Store.Channel().GetTeamChannels(channel.TeamId); result.Err != nil {
c.Err = model.NewLocAppError("createChannel", "api.channel.get_channels.error", nil, result.Err.Message)
return
} else {
@@ -1176,6 +1176,8 @@ func updateNotifyProps(c *Context, w http.ResponseWriter, r *http.Request) {
c.Err = result.Err
return
} else {
+ InvalidateCacheForUser(userId)
+
// return the updated notify properties including any unchanged ones
w.Write([]byte(model.MapToJson(member.NotifyProps)))
}
diff --git a/api/channel_test.go b/api/channel_test.go
index d05cd495b..4b0ce9509 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -378,6 +378,8 @@ func TestUpdateChannelHeader(t *testing.T) {
upChannel1 = result.Data.(*model.Channel)
}
+ time.Sleep(100 * time.Millisecond)
+
r1 := Client.Must(Client.GetPosts(channel1.Id, 0, 1, "")).Data.(*model.PostList)
if len(r1.Order) != 1 {
t.Fatal("Header update system message was not found")
diff --git a/api/user.go b/api/user.go
index b961aa609..e78b5be03 100644
--- a/api/user.go
+++ b/api/user.go
@@ -1398,6 +1398,8 @@ func updateUser(c *Context, w http.ResponseWriter, r *http.Request) {
go sendEmailChangeUsername(c, rusers[1].Username, rusers[0].Username, rusers[0].Email, c.GetSiteURL())
}
+ InvalidateCacheForUser(user.Id)
+
updatedUser := rusers[0]
updatedUser = sanitizeProfile(c, updatedUser)
@@ -1955,6 +1957,7 @@ func updateUserNotify(c *Context, w http.ResponseWriter, r *http.Request) {
return
} else {
c.LogAuditWithUserId(user.Id, "")
+ InvalidateCacheForUser(user.Id)
ruser := result.Data.([2]*model.User)[0]
options := utils.Cfg.GetSanitizeOptions()
diff --git a/api/web_conn.go b/api/web_conn.go
index 52b5ba9de..c906b7c95 100644
--- a/api/web_conn.go
+++ b/api/web_conn.go
@@ -8,6 +8,7 @@ import (
"time"
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/websocket"
@@ -142,6 +143,13 @@ func (webCon *WebConn) isAuthenticated() bool {
return webCon.SessionToken != ""
}
+func (webCon *WebConn) SendHello() {
+ msg := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_HELLO, "", "", webCon.UserId, nil)
+ msg.Add("server_version", fmt.Sprintf("%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.CfgHash))
+ msg.DoPreComputeJson()
+ webCon.Send <- msg
+}
+
func (webCon *WebConn) ShouldSendEvent(msg *model.WebSocketEvent) bool {
// IMPORTANT: Do not send event if WebConn does not have a session
if !webCon.isAuthenticated() {
diff --git a/api/web_hub.go b/api/web_hub.go
index e59521879..b607703f2 100644
--- a/api/web_hub.go
+++ b/api/web_hub.go
@@ -112,6 +112,7 @@ func InvalidateCacheForUser(userId string) {
func InvalidateCacheForUserSkipClusterSend(userId string) {
Srv.Store.Channel().InvalidateAllChannelMembersForUser(userId)
+ Srv.Store.User().InvalidateProfilesInChannelCacheByUser(userId)
GetHubForUserId(userId).InvalidateUser(userId)
}
@@ -119,9 +120,9 @@ func InvalidateCacheForUserSkipClusterSend(userId string) {
func (h *Hub) Register(webConn *WebConn) {
h.register <- webConn
- msg := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_HELLO, "", "", webConn.UserId, nil)
- msg.Add("server_version", fmt.Sprintf("%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.CfgHash))
- go Publish(msg)
+ if webConn.isAuthenticated() {
+ webConn.SendHello()
+ }
}
func (h *Hub) Unregister(webConn *WebConn) {
diff --git a/api/webhook.go b/api/webhook.go
index 2daac03f2..dce739239 100644
--- a/api/webhook.go
+++ b/api/webhook.go
@@ -443,6 +443,8 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
return
} else {
channel = newChanResult.Data.(*model.Channel)
+ InvalidateCacheForUser(directUserId)
+ InvalidateCacheForUser(hook.UserId)
}
} else if result.Err != nil {
c.Err = model.NewLocAppError("incomingWebhook", "web.incoming_webhook.channel.app_error", nil, "err="+result.Err.Message)
diff --git a/api/websocket_router.go b/api/websocket_router.go
index bdbd9f4d9..504e434b7 100644
--- a/api/websocket_router.go
+++ b/api/websocket_router.go
@@ -57,6 +57,7 @@ func (wr *WebSocketRouter) ServeWebSocket(conn *WebConn, r *model.WebSocketReque
resp := model.NewWebSocketResponse(model.STATUS_OK, r.Seq, nil)
resp.DoPreComputeJson()
conn.Send <- resp
+ conn.SendHello()
}
return