From 65817e13c7900ea81947e40e177459cfea8acee4 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 2 Aug 2017 01:36:54 -0700 Subject: 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 --- app/channel.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/channel.go') 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 +} -- cgit v1.2.3-1-g7c22