MM-34002: Improve AddUserToChannel (#17174)

* MM-34002: Improve AddUserToChannel

When we would add a user to a channel, we would
check whether the user is removed from that team or not.

During LDAP sync, this check is not required because the
team member would have just been created. Hence, we
pass a boolean flag to bypass the check.

And with that done, we can freely query the replica.

https://mattermost.atlassian.net/browse/MM-34002

```release-note
NONE
```

* Refactor code

* Rename a struct field

* fix double negative
Этот коммит содержится в:
Agniva De Sarker
2021-04-02 14:33:23 +05:30
коммит произвёл GitHub
родитель 4f0cfbe329
Коммит db01f2a91b
30 изменённых файлов: 169 добавлений и 152 удалений

Просмотреть файл

@@ -311,7 +311,7 @@ func addUserToChannel(a *app.App, channel *model.Channel, user *model.User, user
CommandPrintErrorln("Can't find user '" + userArg + "'")
return
}
if _, err := a.AddUserToChannel(user, channel); err != nil {
if _, err := a.AddUserToChannel(user, channel, false); err != nil {
CommandPrintErrorln("Unable to add '" + userArg + "' from " + channel.Name + ". Error: " + err.Error())
return
}