diff options
author | Jesse Hallam <jesse.hallam@gmail.com> | 2018-04-06 17:08:57 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-04-06 17:08:57 -0400 |
commit | 116849842be59bc6960df415f23155ec8e767f06 (patch) | |
tree | 582794ce6efc92f4564118cbb0a1841699f16a19 /app/channel.go | |
parent | ff077c6761bd4b6d170831f7f2ba474c2a9bd5e0 (diff) | |
download | chat-116849842be59bc6960df415f23155ec8e767f06.tar.gz chat-116849842be59bc6960df415f23155ec8e767f06.tar.bz2 chat-116849842be59bc6960df415f23155ec8e767f06.zip |
MM-8678: add CUD support for channel members via plugins (#8565)
* add CUD support for channel members via plugins
This effectively exposes AddChannelMember, UpdateChannelMemberRoles,
UpdateChannelMemberNotifyProps and LeaveChannel via the plugin API.
It also modifies the semantics of AddChannelMember to explicitly allow
for an empty user requestor, left as such for now via the plugin API.
* change the signature of AddChannelMember to accept a channel id instead of a channel
Diffstat (limited to 'app/channel.go')
-rw-r--r-- | app/channel.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/channel.go b/app/channel.go index 6e11d4e5d..40f21c3a9 100644 --- a/app/channel.go +++ b/app/channel.go @@ -652,8 +652,10 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques } var userRequestor *model.User - if userRequestor, err = a.GetUser(userRequestorId); err != nil { - return nil, err + if userRequestorId != "" { + if userRequestor, err = a.GetUser(userRequestorId); err != nil { + return nil, err + } } cm, err := a.AddUserToChannel(user, channel) @@ -661,7 +663,7 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques return nil, err } - if userId == userRequestorId { + if userRequestorId == "" || userId == userRequestorId { a.postJoinChannelMessage(user, channel) } else { a.Go(func() { @@ -669,7 +671,9 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques }) } - a.UpdateChannelLastViewedAt([]string{channel.Id}, userRequestor.Id) + if userRequestor != nil { + a.UpdateChannelLastViewedAt([]string{channel.Id}, userRequestor.Id) + } return cm, nil } |