From d1f3bf502e3fce9d01d46330f140a4e28da8e146 Mon Sep 17 00:00:00 2001 From: danielaloni Date: Mon, 31 Oct 2022 13:17:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Remove=20all=203pids=20and=20not?= =?UTF-8?q?=20just=20the=20first=20one.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- userapi/internal/api.go | 9 +++++---- userapi/storage/storage_test.go | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) 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")