summaryrefslogtreecommitdiffstats
path: root/api/channel.go
diff options
context:
space:
mode:
authorDavid Lu <david.lu97@outlook.com>2016-08-19 08:08:31 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-08-19 08:08:31 -0400
commit8c2ea22892079cb7f72be96ae6ddff165cda6e43 (patch)
tree8b7cc90ec3ca8d3cdb2437dcf726174e74a9903e /api/channel.go
parent9ad50d4d7562c1b029c888e892dd7cfc203f938a (diff)
downloadchat-8c2ea22892079cb7f72be96ae6ddff165cda6e43.tar.gz
chat-8c2ea22892079cb7f72be96ae6ddff165cda6e43.tar.bz2
chat-8c2ea22892079cb7f72be96ae6ddff165cda6e43.zip
Refactored CreatePost to not use context (#3813)
Diffstat (limited to 'api/channel.go')
-rw-r--r--api/channel.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/api/channel.go b/api/channel.go
index 5d3021cee..a07f45d7a 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -352,8 +352,9 @@ func PostUpdateChannelHeaderMessage(c *Context, channelId string, oldChannelHead
ChannelId: channelId,
Message: message,
Type: model.POST_HEADER_CHANGE,
+ UserId: c.Session.UserId,
}
- if _, err := CreatePost(c, post, false); err != nil {
+ if _, err := CreatePost(c.TeamId, post, false); err != nil {
l4g.Error(utils.T("api.channel.post_update_channel_header_message_and_forget.join_leave.error"), err)
}
}
@@ -543,8 +544,9 @@ func PostUserAddRemoveMessage(c *Context, channelId string, message, postType st
ChannelId: channelId,
Message: message,
Type: postType,
+ UserId: c.Session.UserId,
}
- if _, err := CreatePost(c, post, false); err != nil {
+ if _, err := CreatePost(c.TeamId, post, false); err != nil {
l4g.Error(utils.T("api.channel.post_user_add_remove_message_and_forget.error"), err)
}
}
@@ -609,6 +611,16 @@ func JoinDefaultChannels(teamId string, user *model.User, channelRole string) *m
if cmResult := <-Srv.Store.Channel().SaveMember(cm); cmResult.Err != nil {
err = cmResult.Err
}
+
+ post := &model.Post{
+ ChannelId: result.Data.(*model.Channel).Id,
+ Message: fmt.Sprintf(utils.T("api.channel.join_channel.post_and_forget"), user.Username),
+ Type: model.POST_JOIN_LEAVE,
+ UserId: user.Id,
+ }
+ if _, err := CreatePost(teamId, post, false); err != nil {
+ l4g.Error(utils.T("api.channel.post_user_add_remove_message_and_forget.error"), err)
+ }
}
if result := <-Srv.Store.Channel().GetByName(teamId, "off-topic"); result.Err != nil {
@@ -780,8 +792,9 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
ChannelId: channel.Id,
Message: fmt.Sprintf(c.T("api.channel.delete_channel.archived"), user.Username),
Type: model.POST_CHANNEL_DELETED,
+ UserId: c.Session.UserId,
}
- if _, err := CreatePost(c, post, false); err != nil {
+ if _, err := CreatePost(c.TeamId, post, false); err != nil {
l4g.Error(utils.T("api.channel.delete_channel.failed_post.error"), err)
}
}()