From 0abd31d702b34405ac8fc1d56cbe7648e7bbb6cf Mon Sep 17 00:00:00 2001 From: Scott Bishel Date: Wed, 17 Apr 2024 18:04:46 -0600 Subject: [PATCH] MM-57906 Update platform preference when disconnecting (#603) (#609) * reset to MM primary platform on disconnect * revert file changes * Fix linter --------- Co-authored-by: Miguel de la Cruz (cherry picked from commit a96acd178bdf650b2325da0bd966f7ce912b6bbf) --- server/command.go | 4 ++++ server/command_test.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/server/command.go b/server/command.go index 38601537b..bd1a31304 100644 --- a/server/command.go +++ b/server/command.go @@ -527,6 +527,10 @@ func (p *Plugin) executeDisconnectCommand(args *model.CommandArgs) (*model.Comma if err != nil { return p.cmdSuccess(args, fmt.Sprintf("Error: unable to disconnect your account, %s", err.Error())) } + err = p.setPrimaryPlatform(args.UserId, PreferenceValuePlatformMM) + if err != nil { + return p.cmdSuccess(args, fmt.Sprintf("Error: unable to reset your primary platform, %s", err.Error())) + } _, _ = p.updateAutomutingOnUserDisconnect(args.UserId) diff --git a/server/command_test.go b/server/command_test.go index 2582ca072..bda78ecca 100644 --- a/server/command_test.go +++ b/server/command_test.go @@ -446,11 +446,15 @@ func TestExecuteDisconnectCommand(t *testing.T) { err := th.p.store.SetUserInfo(user1.Id, "team_user_id", &oauth2.Token{AccessToken: "token", Expiry: time.Now().Add(10 * time.Minute)}) require.NoError(t, err) + err = th.p.setPrimaryPlatform(user1.Id, PreferenceValuePlatformMSTeams) + require.NoError(t, err) commandResponse, appErr := th.p.executeDisconnectCommand(args) require.Nil(t, appErr) assertNoCommandResponse(t, commandResponse) assertEphemeralResponse(th, t, args, "Your account has been disconnected.") + + require.Equal(t, PreferenceValuePlatformMM, th.p.getPrimaryPlatform(user1.Id)) }) }