Skip to content

Commit

Permalink
MM-57906 Update platform preference when disconnecting (#603) (#609)
Browse files Browse the repository at this point in the history
* reset to MM primary platform on disconnect

* revert file changes

* Fix linter

---------

Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
(cherry picked from commit a96acd1)
  • Loading branch information
sbishel authored Apr 18, 2024
1 parent e7114c3 commit 0abd31d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions server/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
}

Expand Down

0 comments on commit 0abd31d

Please sign in to comment.