summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-20 11:31:52 -0500
committerenahum <nahumhbl@gmail.com>2017-02-20 13:31:52 -0300
commitdd4d8440eac2e4b64bfb6b449cc0668b78ecba50 (patch)
tree2529e2561e0fd7216c85f7ea68bee390474c7426 /app
parentbecbe935c2c411745aa1d940d32ddfe6c04b7252 (diff)
downloadchat-dd4d8440eac2e4b64bfb6b449cc0668b78ecba50.tar.gz
chat-dd4d8440eac2e4b64bfb6b449cc0668b78ecba50.tar.bz2
chat-dd4d8440eac2e4b64bfb6b449cc0668b78ecba50.zip
Implement a few channel member endpoints for APIv4 (#5444)
* Implement POST /channels/members/{user_id}/view endpoint for APIv4 * Implement PUT /channels/{channel_id}/members/{user_id}/roles endpoint for APIv4 * Implement DELETE /channels/{channel_id}/members/{user_id} endpoint for APIv4
Diffstat (limited to 'app')
-rw-r--r--app/channel.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/app/channel.go b/app/channel.go
index 347c106a8..db007dd3b 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -700,7 +700,7 @@ func LeaveChannel(channelId string, userId string) *model.AppError {
return err
}
- if err := RemoveUserFromChannel(userId, userId, channel); err != nil {
+ if err := removeUserFromChannel(userId, userId, channel); err != nil {
return err
}
@@ -765,7 +765,7 @@ func PostRemoveFromChannelMessage(removerUserId string, removedUser *model.User,
return nil
}
-func RemoveUserFromChannel(userIdToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
+func removeUserFromChannel(userIdToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
if channel.DeleteAt > 0 {
err := model.NewLocAppError("RemoveUserFromChannel", "api.channel.remove_user_from_channel.deleted.app_error", nil, "")
err.StatusCode = http.StatusBadRequest
@@ -797,6 +797,22 @@ func RemoveUserFromChannel(userIdToRemove string, removerUserId string, channel
return nil
}
+func RemoveUserFromChannel(userIdToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
+ var err *model.AppError
+ if err = removeUserFromChannel(userIdToRemove, removerUserId, channel); err != nil {
+ return err
+ }
+
+ var user *model.User
+ if user, err = GetUser(userIdToRemove); err != nil {
+ return err
+ }
+
+ go PostRemoveFromChannelMessage(removerUserId, user, channel)
+
+ return nil
+}
+
func GetNumberOfChannelsOnTeam(teamId string) (int, *model.AppError) {
// Get total number of channels on current team
if result := <-Srv.Store.Channel().GetTeamChannels(teamId); result.Err != nil {
@@ -847,7 +863,7 @@ func SearchChannelsUserNotIn(teamId string, userId string, term string) (*model.
}
}
-func ViewChannel(view *model.ChannelView, teamId string, userId string, clearPushNotifications bool) *model.AppError {
+func ViewChannel(view *model.ChannelView, userId string, clearPushNotifications bool) *model.AppError {
if err := SetActiveChannel(userId, view.ChannelId); err != nil {
return err
}