mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 12:06:08 -04:00
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)
This commit is contained in:
parent
1aa0dad021
commit
ad17fbd20e
7 changed files with 143 additions and 1 deletions
|
@ -125,6 +125,8 @@ class EmailPusherTests(HomeserverTestCase):
|
|||
)
|
||||
)
|
||||
|
||||
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 @@ class EmailPusherTests(HomeserverTestCase):
|
|||
# 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="a@example.com",
|
||||
)
|
||||
)
|
||||
|
||||
# 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"""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue