Skip to content

Commit

Permalink
Add a config option to disable deleting tokens on bind
Browse files Browse the repository at this point in the history
  • Loading branch information
babolivier committed May 19, 2020
1 parent 6837ad7 commit 0fcbe86
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/293.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a config option to disable deleting invite tokens on bind.
5 changes: 5 additions & 0 deletions sydent/sydent.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@

# Whether clients and homeservers can register an association using v1 endpoints.
'enable_v1_associations': 'true',
'delete_tokens_on_bind': 'true',
},
'db': {
'db.file': 'sydent.db',
Expand Down Expand Up @@ -176,6 +177,10 @@ def __init__(self, cfg, reactor=twisted.internet.reactor):
self.cfg.get("general", "enable_v1_associations")
)

self.delete_tokens_on_bind = parse_cfg_bool(
self.cfg.get("general", "delete_tokens_on_bind")
)

# See if a pepper already exists in the database
# Note: This MUST be run before we start serving requests, otherwise lookups for
# 3PID hashes may come in before we've completed generating them
Expand Down
4 changes: 4 additions & 0 deletions sydent/threepid/bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ def _notify(self, assoc, attempt):
else:
logger.info("Successfully notified on bind for %s" % (mxid,))

# Skip the deletion step if instructed so by the config.
if not self.sydent.delete_tokens_on_bind:
return

# Only remove sent tokens when they've been successfully sent.
try:
joinTokenStore = JoinTokenStore(self.sydent)
Expand Down

0 comments on commit 0fcbe86

Please sign in to comment.