This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove pushers when deleting 3pid from account (#10581)
When a user deletes an email from their account it will now also remove all pushers for that email and that user (even if these pushers were created by a different client)
- Loading branch information
Showing
7 changed files
with
143 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Remove pushers when deleting a 3pid from an account. Pushers for old unlinked emails will also be deleted. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
synapse/storage/schema/main/delta/63/02delete_unlinked_email_pushers.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* Copyright 2021 The Matrix.org Foundation C.I.C | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
-- We may not have deleted all pushers for emails that are no longer linked | ||
-- to an account, so we set up a background job to delete them. | ||
INSERT INTO background_updates (ordering, update_name, progress_json) VALUES | ||
(6302, 'remove_deleted_email_pushers', '{}'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,6 +125,8 @@ def prepare(self, reactor, clock, hs): | |
) | ||
) | ||
|
||
self.auth_handler = hs.get_auth_handler() | ||
|
||
def test_need_validated_email(self): | ||
"""Test that we can only add an email pusher if the user has validated | ||
their email. | ||
|
@@ -305,6 +307,43 @@ def test_encrypted_message(self): | |
# We should get emailed about that message | ||
self._check_for_mail() | ||
|
||
def test_no_email_sent_after_removed(self): | ||
# Create a simple room with two users | ||
room = self.helper.create_room_as(self.user_id, tok=self.access_token) | ||
self.helper.invite( | ||
room=room, | ||
src=self.user_id, | ||
tok=self.access_token, | ||
targ=self.others[0].id, | ||
) | ||
self.helper.join( | ||
room=room, | ||
user=self.others[0].id, | ||
tok=self.others[0].token, | ||
) | ||
|
||
# The other user sends a single message. | ||
self.helper.send(room, body="Hi!", tok=self.others[0].token) | ||
|
||
# We should get emailed about that message | ||
self._check_for_mail() | ||
|
||
# disassociate the user's email address | ||
self.get_success( | ||
self.auth_handler.delete_threepid( | ||
user_id=self.user_id, | ||
medium="email", | ||
address="[email protected]", | ||
) | ||
) | ||
|
||
# check that the pusher for that email address has been deleted | ||
pushers = self.get_success( | ||
self.hs.get_datastore().get_pushers_by({"user_name": self.user_id}) | ||
) | ||
pushers = list(pushers) | ||
self.assertEqual(len(pushers), 0) | ||
|
||
def _check_for_mail(self): | ||
"""Check that the user receives an email notification""" | ||
|
||
|