diff --git a/userapi/internal/api.go b/userapi/internal/api.go index ae4a69739..e22081a2f 100644 --- a/userapi/internal/api.go +++ b/userapi/internal/api.go @@ -553,10 +553,11 @@ func (a *UserInternalAPI) PerformAccountDeactivation(ctx context.Context, req *a if err != nil { return err } - - err = a.DB.RemoveThreePIDAssociation(ctx, threepids[0].Address, threepids[0].Medium) - if err != nil { - return err + for i := 0; i < len(threepids); i++ { + err = a.DB.RemoveThreePIDAssociation(ctx, threepids[i].Address, threepids[i].Medium) + if err != nil { + return err + } } pusherReq := &api.PerformPusherDeletionRequest{ diff --git a/userapi/storage/storage_test.go b/userapi/storage/storage_test.go index 42e35d1ab..53c51416b 100644 --- a/userapi/storage/storage_test.go +++ b/userapi/storage/storage_test.go @@ -128,6 +128,11 @@ func Test_Accounts(t *testing.T) { _, err = db.GetAccountByPassword(ctx, aliceLocalpart, "newPassword") assert.Error(t, err, "expected an error, got none") + // This should return an empty slice, as the account is deactivated and the 3pid is unbound + threepids, err := db.GetThreePIDsForLocalpart(ctx, aliceLocalpart) + assert.NoError(t, err, "failed to get 3pid for account") + assert.Equal(t, len(threepids), 0) + _, err = db.GetAccountByLocalpart(ctx, "unusename") assert.Error(t, err, "expected an error for non existent localpart")