mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-11-13 18:20:37 -05:00
Add an EventValidator. Fix bugs in auth ++ storage
This commit is contained in:
parent
ec824927c1
commit
a8e565eca8
9 changed files with 64 additions and 90 deletions
|
|
@ -212,7 +212,7 @@ class SQLBaseStore(object):
|
|||
retcol : string giving the name of the column to return
|
||||
"""
|
||||
return self.runInteraction(
|
||||
"_simple_select_one_onecol_txn",
|
||||
"_simple_select_one_onecol",
|
||||
self._simple_select_one_onecol_txn,
|
||||
table, keyvalues, retcol, allow_none=allow_none,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -107,13 +107,17 @@ class RegistrationStore(SQLBaseStore):
|
|||
token
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def is_server_admin(self, user):
|
||||
return self._simple_select_one_onecol(
|
||||
res = yield self._simple_select_one_onecol(
|
||||
table="users",
|
||||
keyvalues={"name": user.to_string()},
|
||||
retcol="admin",
|
||||
allow_none=True,
|
||||
)
|
||||
|
||||
defer.returnValue(res if res else False)
|
||||
|
||||
def _query_for_auth(self, txn, token):
|
||||
sql = (
|
||||
"SELECT users.name, users.admin, access_tokens.device_id "
|
||||
|
|
|
|||
|
|
@ -133,26 +133,28 @@ class RoomStore(SQLBaseStore):
|
|||
defer.returnValue(ret)
|
||||
|
||||
def _store_room_topic_txn(self, txn, event):
|
||||
self._simple_insert_txn(
|
||||
txn,
|
||||
"topics",
|
||||
{
|
||||
"event_id": event.event_id,
|
||||
"room_id": event.room_id,
|
||||
"topic": event.topic,
|
||||
}
|
||||
)
|
||||
if hasattr(event, "topic"):
|
||||
self._simple_insert_txn(
|
||||
txn,
|
||||
"topics",
|
||||
{
|
||||
"event_id": event.event_id,
|
||||
"room_id": event.room_id,
|
||||
"topic": event.topic,
|
||||
}
|
||||
)
|
||||
|
||||
def _store_room_name_txn(self, txn, event):
|
||||
self._simple_insert_txn(
|
||||
txn,
|
||||
"room_names",
|
||||
{
|
||||
"event_id": event.event_id,
|
||||
"room_id": event.room_id,
|
||||
"name": event.name,
|
||||
}
|
||||
)
|
||||
if hasattr(event, "name"):
|
||||
self._simple_insert_txn(
|
||||
txn,
|
||||
"room_names",
|
||||
{
|
||||
"event_id": event.event_id,
|
||||
"room_id": event.room_id,
|
||||
"name": event.name,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class RoomsTable(Table):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue