summaryrefslogtreecommitdiffstats
path: root/app/channel.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2018-03-27 21:14:42 +0800
committerGitHub <noreply@github.com>2018-03-27 21:14:42 +0800
commit07b14c370a6c911c89e1812bc796a445e5223604 (patch)
treed8ad9a5373db49c10d347bd8e2ea06b9cd5c8fed /app/channel.go
parent9e6db178b09387e21ac19ce85369cf1ca7a443e8 (diff)
downloadchat-07b14c370a6c911c89e1812bc796a445e5223604.tar.gz
chat-07b14c370a6c911c89e1812bc796a445e5223604.tar.bz2
chat-07b14c370a6c911c89e1812bc796a445e5223604.zip
post a system message after a channel is converted from public to private (#8501)
Diffstat (limited to 'app/channel.go')
-rw-r--r--app/channel.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/channel.go b/app/channel.go
index 4e294abbb..49a797f15 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -805,6 +805,34 @@ func (a *App) PostUpdateChannelDisplayNameMessage(userId string, channel *model.
return nil
}
+func (a *App) PostConvertChannelToPrivate(userId string, channel *model.Channel) *model.AppError {
+ uc := a.Srv.Store.User().Get(userId)
+
+ if uresult := <-uc; uresult.Err != nil {
+ return model.NewAppError("PostConvertChannelToPrivate", "api.channel.post_convert_channel_to_private.retrieve_user.error", nil, uresult.Err.Error(), http.StatusBadRequest)
+ } else {
+ user := uresult.Data.(*model.User)
+
+ message := fmt.Sprintf(utils.T("api.channel.post_convert_channel_to_private.updated_from"), user.Username)
+
+ post := &model.Post{
+ ChannelId: channel.Id,
+ Message: message,
+ Type: model.POST_CONVERT_CHANNEL,
+ UserId: userId,
+ Props: model.StringInterface{
+ "username": user.Username,
+ },
+ }
+
+ if _, err := a.CreatePost(post, channel, false); err != nil {
+ return model.NewAppError("PostConvertChannelToPrivate", "api.channel.post_convert_channel_to_private.create_post.error", nil, err.Error(), http.StatusInternalServerError)
+ }
+ }
+
+ return nil
+}
+
func (a *App) GetChannel(channelId string) (*model.Channel, *model.AppError) {
if result := <-a.Srv.Store.Channel().Get(channelId, true); result.Err != nil && result.Err.Id == "store.sql_channel.get.existing.app_error" {
result.Err.StatusCode = http.StatusNotFound