summaryrefslogtreecommitdiffstats
path: root/app/channel.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-08-02 01:36:54 -0700
committerGitHub <noreply@github.com>2017-08-02 01:36:54 -0700
commit65817e13c7900ea81947e40e177459cfea8acee4 (patch)
tree8dfc88db36844e4186b4110753be8de976da6371 /app/channel.go
parentc6bf235ec2a8613d8ef35607e2aeb8c0cb629f45 (diff)
downloadchat-65817e13c7900ea81947e40e177459cfea8acee4.tar.gz
chat-65817e13c7900ea81947e40e177459cfea8acee4.tar.bz2
chat-65817e13c7900ea81947e40e177459cfea8acee4.zip
PLT-6965 jira integration (plus plugin scaffolding) (#6918)
* plugin scaffolding / jira integration * add vendored testify packages * webhook fix * don't change i18n ids * support configuration watching * add basic jira plugin configuration to admin console * fix eslint errors * fix another eslint warning * polish * undo unintentional config.json commit >:( * test fix * add jira plugin diagnostics, remove dm support, add bot tag, generate web-safe secrets * rebase, implement requested changes * requested changes * remove tests and minimize makefile change * add missing license headers * add missing comma * remove bad line from Makefile
Diffstat (limited to 'app/channel.go')
-rw-r--r--app/channel.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/channel.go b/app/channel.go
index 03df0e800..4a0f94b42 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -1206,3 +1206,19 @@ func GetPinnedPosts(channelId string) (*model.PostList, *model.AppError) {
return result.Data.(*model.PostList), nil
}
}
+
+func GetDirectChannel(userId1, userId2 string) (*model.Channel, *model.AppError) {
+ result := <-Srv.Store.Channel().GetByName("", model.GetDMNameFromIds(userId1, userId2), true)
+ if result.Err != nil && result.Err.Id == store.MISSING_CHANNEL_ERROR {
+ result := <-Srv.Store.Channel().CreateDirectChannel(userId1, userId2)
+ if result.Err != nil {
+ return nil, model.NewAppError("GetOrCreateDMChannel", "web.incoming_webhook.channel.app_error", nil, "err="+result.Err.Message, http.StatusBadRequest)
+ }
+ InvalidateCacheForUser(userId1)
+ InvalidateCacheForUser(userId2)
+ return result.Data.(*model.Channel), nil
+ } else if result.Err != nil {
+ return nil, model.NewAppError("GetOrCreateDMChannel", "web.incoming_webhook.channel.app_error", nil, "err="+result.Err.Message, result.Err.StatusCode)
+ }
+ return result.Data.(*model.Channel), nil
+}