summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api4/channel_test.go12
-rw-r--r--app/channel.go10
-rw-r--r--app/notification.go5
-rw-r--r--app/notification_test.go5
4 files changed, 22 insertions, 10 deletions
diff --git a/api4/channel_test.go b/api4/channel_test.go
index 4645a0ab6..c2a0131cf 100644
--- a/api4/channel_test.go
+++ b/api4/channel_test.go
@@ -1974,6 +1974,18 @@ func TestRemoveChannelMember(t *testing.T) {
_, resp = th.SystemAdminClient.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser.Id)
CheckNoError(t, resp)
+ // Leave deleted channel
+ th.LoginBasic()
+ deletedChannel := th.CreatePublicChannel()
+ th.App.AddUserToChannel(th.BasicUser, deletedChannel)
+ th.App.AddUserToChannel(th.BasicUser2, deletedChannel)
+
+ deletedChannel.DeleteAt = 1
+ th.App.UpdateChannel(deletedChannel)
+
+ _, resp = Client.RemoveUserFromChannel(deletedChannel.Id, th.BasicUser.Id)
+ CheckNoError(t, resp)
+
th.LoginBasic()
private := th.CreatePrivateChannel()
th.App.AddUserToChannel(th.BasicUser2, private)
diff --git a/app/channel.go b/app/channel.go
index 830dbb8b7..0a89574ac 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -1380,11 +1380,6 @@ func (a *App) postRemoveFromChannelMessage(removerUserId string, removedUser *mo
}
func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
- if channel.DeleteAt > 0 {
- err := model.NewAppError("RemoveUserFromChannel", "api.channel.remove_user_from_channel.deleted.app_error", nil, "", http.StatusBadRequest)
- return err
- }
-
if channel.Name == model.DEFAULT_CHANNEL {
return model.NewAppError("RemoveUserFromChannel", "api.channel.remove.default.app_error", map[string]interface{}{"Channel": model.DEFAULT_CHANNEL}, "", http.StatusBadRequest)
}
@@ -1449,11 +1444,6 @@ func (a *App) RemoveUserFromChannel(userIdToRemove string, removerUserId string,
if userIdToRemove == removerUserId {
a.postLeaveChannelMessage(user, channel)
} else {
-
- if err != nil {
- return err
- }
-
a.Go(func() {
a.postRemoveFromChannelMessage(removerUserId, user, channel)
})
diff --git a/app/notification.go b/app/notification.go
index 5d31c2739..70f60dd42 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -22,6 +22,11 @@ const (
)
func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *model.Channel, sender *model.User, parentPostList *model.PostList) ([]string, *model.AppError) {
+ // Do not send notifications in archived channels
+ if channel.DeleteAt > 0 {
+ return []string{}, nil
+ }
+
pchan := a.Srv.Store.User().GetAllProfilesInChannel(channel.Id, true)
cmnchan := a.Srv.Store.Channel().GetAllChannelMembersNotifyPropsForChannel(channel.Id, true)
var fchan store.StoreChannel
diff --git a/app/notification_test.go b/app/notification_test.go
index d9f81dccb..bdc38e455 100644
--- a/app/notification_test.go
+++ b/app/notification_test.go
@@ -78,6 +78,11 @@ func TestSendNotifications(t *testing.T) {
if err != nil {
t.Fatal(err)
}
+
+ th.BasicChannel.DeleteAt = 1
+ mentions, err = th.App.SendNotifications(post1, th.BasicTeam, th.BasicChannel, th.BasicUser, nil)
+ assert.Nil(t, err)
+ assert.Len(t, mentions, 0)
}
func TestGetExplicitMentions(t *testing.T) {