summaryrefslogtreecommitdiffstats
path: root/app/channel.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-21 14:00:14 -0500
committerGitHub <noreply@github.com>2017-09-21 14:00:14 -0500
commite525383c52b0c65ad3b3f6cdbee73f56e1e3f67d (patch)
treee46d2dcd0dcad346da8641f4bd62f9134bc80699 /app/channel.go
parent266ff8670244da288aec937320d9eecc7996af35 (diff)
downloadchat-e525383c52b0c65ad3b3f6cdbee73f56e1e3f67d.tar.gz
chat-e525383c52b0c65ad3b3f6cdbee73f56e1e3f67d.tar.bz2
chat-e525383c52b0c65ad3b3f6cdbee73f56e1e3f67d.zip
plugin CRUD operations for users, posts, channels, and teams (#7479)
Diffstat (limited to 'app/channel.go')
-rw-r--r--app/channel.go44
1 files changed, 26 insertions, 18 deletions
diff --git a/app/channel.go b/app/channel.go
index 8ca3a563a..436d429c9 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -413,18 +413,24 @@ func (a *App) UpdateChannelMemberNotifyProps(data map[string]string, channelId s
}
func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppError {
- uc := a.Srv.Store.User().Get(userId)
ihc := a.Srv.Store.Webhook().GetIncomingByChannel(channel.Id)
ohc := a.Srv.Store.Webhook().GetOutgoingByChannel(channel.Id, -1, -1)
- if uresult := <-uc; uresult.Err != nil {
- return uresult.Err
- } else if ihcresult := <-ihc; ihcresult.Err != nil {
+ var user *model.User
+ if userId != "" {
+ uc := a.Srv.Store.User().Get(userId)
+ uresult := <-uc
+ if uresult.Err != nil {
+ return uresult.Err
+ }
+ user = uresult.Data.(*model.User)
+ }
+
+ if ihcresult := <-ihc; ihcresult.Err != nil {
return ihcresult.Err
} else if ohcresult := <-ohc; ohcresult.Err != nil {
return ohcresult.Err
} else {
- user := uresult.Data.(*model.User)
incomingHooks := ihcresult.Data.([]*model.IncomingWebhook)
outgoingHooks := ohcresult.Data.([]*model.OutgoingWebhook)
@@ -438,20 +444,22 @@ func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppErr
return err
}
- T := utils.GetUserTranslations(user.Locale)
-
- post := &model.Post{
- ChannelId: channel.Id,
- Message: fmt.Sprintf(T("api.channel.delete_channel.archived"), user.Username),
- Type: model.POST_CHANNEL_DELETED,
- UserId: userId,
- Props: model.StringInterface{
- "username": user.Username,
- },
- }
+ if user != nil {
+ T := utils.GetUserTranslations(user.Locale)
+
+ post := &model.Post{
+ ChannelId: channel.Id,
+ Message: fmt.Sprintf(T("api.channel.delete_channel.archived"), user.Username),
+ Type: model.POST_CHANNEL_DELETED,
+ UserId: userId,
+ Props: model.StringInterface{
+ "username": user.Username,
+ },
+ }
- if _, err := a.CreatePost(post, channel, false); err != nil {
- l4g.Error(utils.T("api.channel.delete_channel.failed_post.error"), err)
+ if _, err := a.CreatePost(post, channel, false); err != nil {
+ l4g.Error(utils.T("api.channel.delete_channel.failed_post.error"), err)
+ }
}
now := model.GetMillis()