Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 04897c9

Browse files
authored
Merge pull request #2622 from matrix-org/rav/db_access_for_auth_providers
Let auth providers get to the database
2 parents 846a94f + 3e0aaad commit 04897c9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

synapse/handlers/auth.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ def __init__(self, hs, check_user_exists):
826826
self.hs = hs
827827

828828
self._check_user_exists = check_user_exists
829+
self._store = hs.get_datastore()
829830

830831
def get_qualified_user_id(self, username):
831832
"""Qualify a user id, if necessary
@@ -863,3 +864,18 @@ def register(self, localpart):
863864
"""
864865
reg = self.hs.get_handlers().registration_handler
865866
return reg.register(localpart=localpart)
867+
868+
def run_db_interaction(self, desc, func, *args, **kwargs):
869+
"""Run a function with a database connection
870+
871+
Args:
872+
desc (str): description for the transaction, for metrics etc
873+
func (func): function to be run. Passed a database cursor object
874+
as well as *args and **kwargs
875+
*args: positional args to be passed to func
876+
**kwargs: named args to be passed to func
877+
878+
Returns:
879+
Deferred[object]: result of func
880+
"""
881+
return self._store.runInteraction(desc, func, *args, **kwargs)

0 commit comments

Comments
 (0)