PLT-3560 blocking adding to channel once user is removed (#3537)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
ab831b88de
Коммит
dd99252278
@@ -562,6 +562,11 @@ func AddUserToChannel(user *model.User, channel *model.Channel) (*model.ChannelM
|
|||||||
|
|
||||||
if result := <-tmchan; result.Err != nil {
|
if result := <-tmchan; result.Err != nil {
|
||||||
return nil, result.Err
|
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 {
|
if result := <-cmchan; result.Err != nil {
|
||||||
|
|||||||
@@ -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) {
|
func TestLeaveChannel(t *testing.T) {
|
||||||
th := Setup().InitBasic()
|
th := Setup().InitBasic()
|
||||||
Client := th.BasicClient
|
Client := th.BasicClient
|
||||||
|
|||||||
@@ -163,6 +163,10 @@
|
|||||||
"id": "api.channel.add_user.to.channel.failed.app_error",
|
"id": "api.channel.add_user.to.channel.failed.app_error",
|
||||||
"translation": "Failed to add user to channel"
|
"translation": "Failed to add user to channel"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "api.channel.add_user.to.channel.failed.deleted.app_error",
|
||||||
|
"translation": "Failed to add user to channel because they have been removed from the team."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "api.channel.add_user_to_channel.deleted.app_error",
|
"id": "api.channel.add_user_to_channel.deleted.app_error",
|
||||||
"translation": "The channel has been archived or deleted"
|
"translation": "The channel has been archived or deleted"
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user