mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 09:14:58 -04:00
Move storage classes into a main "data store".
This is in preparation for having multiple data stores that offer different functionality, e.g. splitting out state or event storage.
This commit is contained in:
parent
1ee97cbd01
commit
c66a06ac6b
266 changed files with 4509 additions and 4331 deletions
31
synapse/storage/data_stores/main/openid.py
Normal file
31
synapse/storage/data_stores/main/openid.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from synapse.storage._base import SQLBaseStore
|
||||
|
||||
|
||||
class OpenIdStore(SQLBaseStore):
|
||||
def insert_open_id_token(self, token, ts_valid_until_ms, user_id):
|
||||
return self._simple_insert(
|
||||
table="open_id_tokens",
|
||||
values={
|
||||
"token": token,
|
||||
"ts_valid_until_ms": ts_valid_until_ms,
|
||||
"user_id": user_id,
|
||||
},
|
||||
desc="insert_open_id_token",
|
||||
)
|
||||
|
||||
def get_user_id_for_open_id_token(self, token, ts_now_ms):
|
||||
def get_user_id_for_token_txn(txn):
|
||||
sql = (
|
||||
"SELECT user_id FROM open_id_tokens"
|
||||
" WHERE token = ? AND ? <= ts_valid_until_ms"
|
||||
)
|
||||
|
||||
txn.execute(sql, (token, ts_now_ms))
|
||||
|
||||
rows = txn.fetchall()
|
||||
if not rows:
|
||||
return None
|
||||
else:
|
||||
return rows[0][0]
|
||||
|
||||
return self.runInteraction("get_user_id_for_token", get_user_id_for_token_txn)
|
Loading…
Add table
Add a link
Reference in a new issue