Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
3693ea61
Unverified
Commit
3693ea61
authored
3 years ago
by
Andrew Morgan
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix iteration in _remove_deleted_email_pushers background job. (#10734)
parent
78e590d4
No related branches found
Branches containing commit
Tags
v0.5.3c
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/10734.bugfix
+1
-0
1 addition, 0 deletions
changelog.d/10734.bugfix
synapse/storage/databases/main/pusher.py
+2
-1
2 additions, 1 deletion
synapse/storage/databases/main/pusher.py
tests/push/test_email.py
+44
-0
44 additions, 0 deletions
tests/push/test_email.py
with
47 additions
and
1 deletion
changelog.d/10734.bugfix
0 → 100644
+
1
−
0
View file @
3693ea61
Remove pushers when deleting a 3pid from an account. Pushers for old unlinked emails will also be deleted.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
synapse/storage/databases/main/pusher.py
+
2
−
1
View file @
3693ea61
...
@@ -430,10 +430,11 @@ class PusherWorkerStore(SQLBaseStore):
...
@@ -430,10 +430,11 @@ class PusherWorkerStore(SQLBaseStore):
"""
"""
txn
.
execute
(
sql
,
(
last_pusher
,
batch_size
))
txn
.
execute
(
sql
,
(
last_pusher
,
batch_size
))
rows
=
txn
.
fetchall
()
last
=
None
last
=
None
num_deleted
=
0
num_deleted
=
0
for
row
in
txn
:
for
row
in
rows
:
last
=
row
[
0
]
last
=
row
[
0
]
num_deleted
+=
1
num_deleted
+=
1
self
.
db_pool
.
simple_delete_txn
(
self
.
db_pool
.
simple_delete_txn
(
...
...
This diff is collapsed.
Click to expand it.
tests/push/test_email.py
+
44
−
0
View file @
3693ea61
...
@@ -344,6 +344,50 @@ class EmailPusherTests(HomeserverTestCase):
...
@@ -344,6 +344,50 @@ class EmailPusherTests(HomeserverTestCase):
pushers
=
list
(
pushers
)
pushers
=
list
(
pushers
)
self
.
assertEqual
(
len
(
pushers
),
0
)
self
.
assertEqual
(
len
(
pushers
),
0
)
def
test_remove_unlinked_pushers_background_job
(
self
):
"""
Checks that all existing pushers associated with unlinked email addresses are removed
upon running the remove_deleted_email_pushers background update.
"""
# disassociate the user's email address manually (without deleting the pusher).
# This resembles the old behaviour, which the background update below is intended
# to clean up.
self
.
get_success
(
self
.
hs
.
get_datastore
().
user_delete_threepid
(
self
.
user_id
,
"
email
"
,
"
a@example.com
"
)
)
# Run the "remove_deleted_email_pushers" background job
self
.
get_success
(
self
.
hs
.
get_datastore
().
db_pool
.
simple_insert
(
table
=
"
background_updates
"
,
values
=
{
"
update_name
"
:
"
remove_deleted_email_pushers
"
,
"
progress_json
"
:
"
{}
"
,
"
depends_on
"
:
None
,
},
)
)
# ... and tell the DataStore that it hasn't finished all updates yet
self
.
hs
.
get_datastore
().
db_pool
.
updates
.
_all_done
=
False
# Now let's actually drive the updates to completion
while
not
self
.
get_success
(
self
.
hs
.
get_datastore
().
db_pool
.
updates
.
has_completed_background_updates
()
):
self
.
get_success
(
self
.
hs
.
get_datastore
().
db_pool
.
updates
.
do_next_background_update
(
100
),
by
=
0.1
,
)
# Check that all pushers with unlinked addresses were 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
):
def
_check_for_mail
(
self
):
"""
Check that the user receives an email notification
"""
"""
Check that the user receives an email notification
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment