diff options
author | Alexander Smaga <smagaan@gmail.com> | 2016-10-17 15:12:56 +0300 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-10-17 08:12:56 -0400 |
commit | e7b25f4cd8b7d87b99153fd4a901d3f9f92d7b0d (patch) | |
tree | 9dfad731f8a4320e72e287732b50f46946ce76fe /store/sql_channel_store.go | |
parent | b1e2b23b882ec062cfd7209abeed417eb07e121e (diff) | |
download | chat-e7b25f4cd8b7d87b99153fd4a901d3f9f92d7b0d.tar.gz chat-e7b25f4cd8b7d87b99153fd4a901d3f9f92d7b0d.tar.bz2 chat-e7b25f4cd8b7d87b99153fd4a901d3f9f92d7b0d.zip |
GH-4187 Create direct channel during incoming webhook if not exists (#4206)
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r-- | store/sql_channel_store.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index 07c037075..eb150a63c 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -83,6 +83,29 @@ func (s SqlChannelStore) Save(channel *model.Channel) StoreChannel { return storeChannel } +func (s SqlChannelStore) CreateDirectChannel(userId string, otherUserId string) StoreChannel { + channel := new(model.Channel) + + channel.DisplayName = "" + channel.Name = model.GetDMNameFromIds(otherUserId, userId) + + channel.Header = "" + channel.Type = model.CHANNEL_DIRECT + + cm1 := &model.ChannelMember{ + UserId: userId, + NotifyProps: model.GetDefaultChannelNotifyProps(), + Roles: model.ROLE_CHANNEL_USER.Id, + } + cm2 := &model.ChannelMember{ + UserId: otherUserId, + NotifyProps: model.GetDefaultChannelNotifyProps(), + Roles: model.ROLE_CHANNEL_USER.Id, + } + + return s.SaveDirectChannel(channel, cm1, cm2) +} + func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) StoreChannel { storeChannel := make(StoreChannel, 1) |