summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-07-11 04:37:20 -0800
committerHarrison Healey <harrisonmhealey@gmail.com>2016-07-11 08:37:20 -0400
commitdd9925227870525339eb5c6ae7ab3be2a21ab923 (patch)
treec0a157292443c554c23f04342be45d6cc7b70cdc /api
parentab831b88de3b9e8dafb39bebda43faa29ffc8475 (diff)
downloadchat-dd9925227870525339eb5c6ae7ab3be2a21ab923.tar.gz
chat-dd9925227870525339eb5c6ae7ab3be2a21ab923.tar.bz2
chat-dd9925227870525339eb5c6ae7ab3be2a21ab923.zip
PLT-3560 blocking adding to channel once user is removed (#3537)
Diffstat (limited to 'api')
-rw-r--r--api/channel.go5
-rw-r--r--api/channel_test.go19
2 files changed, 24 insertions, 0 deletions
diff --git a/api/channel.go b/api/channel.go
index 038a4286a..2e4eb2bb5 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -562,6 +562,11 @@ func AddUserToChannel(user *model.User, channel *model.Channel) (*model.ChannelM
if result := <-tmchan; result.Err != nil {
return nil, result.Err
+ } else {
+ teamMember := result.Data.(model.TeamMember)
+ if teamMember.DeleteAt > 0 {
+ return nil, model.NewLocAppError("AddUserToChannel", "api.channel.add_user.to.channel.failed.deleted.app_error", nil, "")
+ }
}
if result := <-cmchan; result.Err != nil {
diff --git a/api/channel_test.go b/api/channel_test.go
index 93d097261..450aac877 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -833,6 +833,25 @@ func TestJoinChannelByName(t *testing.T) {
}
}
+func TestJoinChannelByNameDisabledUser(t *testing.T) {
+ th := Setup().InitBasic()
+ Client := th.BasicClient
+ team := th.BasicTeam
+
+ channel1 := &model.Channel{DisplayName: "A Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
+ channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
+
+ Client.Must(th.BasicClient.RemoveUserFromTeam(th.BasicTeam.Id, th.BasicUser.Id))
+
+ if _, err := AddUserToChannel(th.BasicUser, channel1); err == nil {
+ t.Fatal("shoudn't be able to join channel")
+ } else {
+ if err.Id != "api.channel.add_user.to.channel.failed.deleted.app_error" {
+ t.Fatal("wrong error")
+ }
+ }
+}
+
func TestLeaveChannel(t *testing.T) {
th := Setup().InitBasic()
Client := th.BasicClient