[MM-49989] Pass a context.Context to Client4 methods (#22922)
* Migrate all method in model/client4.go to accept a context.Context * Fix th.*Client * Fix remaining issues * Empty commit to triger CI * Fix test * Add cancellation test * Test that returned error is context.Canceled * Fix bad merge * Update mmctl code --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7116e9267a
Коммит
6c82605df0
@@ -4,6 +4,7 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
@@ -72,7 +73,7 @@ func removeUserFromTeam(c client.Client, team *model.Team, user *model.User, use
|
||||
}
|
||||
|
||||
var err error
|
||||
if _, err = c.RemoveTeamMember(team.Id, user.Id); err != nil {
|
||||
if _, err = c.RemoveTeamMember(context.TODO(), team.Id, user.Id); err != nil {
|
||||
err = fmt.Errorf("unable to remove '%s' from %s. Error: %w", userArg, team.Name, err)
|
||||
printer.PrintError(err.Error())
|
||||
}
|
||||
@@ -102,7 +103,7 @@ func teamUsersAddCmdF(c client.Client, cmd *cobra.Command, args []string) error
|
||||
}
|
||||
|
||||
func addUserToTeam(c client.Client, team *model.Team, user *model.User, userArg string) {
|
||||
if _, _, err := c.AddTeamMember(team.Id, user.Id); err != nil {
|
||||
if _, _, err := c.AddTeamMember(context.TODO(), team.Id, user.Id); err != nil {
|
||||
printer.PrintError("Unable to add '" + userArg + "' to " + team.Name + ". Error: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user