mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Split Directory store
This commit is contained in:
parent
42174946f8
commit
2e223163ff
@ -14,10 +14,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from ._base import BaseSlavedStore
|
from ._base import BaseSlavedStore
|
||||||
from synapse.storage.directory import DirectoryStore
|
from synapse.storage.directory import DirectoryWorkerStore
|
||||||
|
|
||||||
|
|
||||||
class DirectoryStore(BaseSlavedStore):
|
class DirectoryStore(DirectoryWorkerStore, BaseSlavedStore):
|
||||||
get_aliases_for_room = DirectoryStore.__dict__[
|
pass
|
||||||
"get_aliases_for_room"
|
|
||||||
]
|
|
||||||
|
@ -29,8 +29,7 @@ RoomAliasMapping = namedtuple(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class DirectoryStore(SQLBaseStore):
|
class DirectoryWorkerStore(SQLBaseStore):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_association_from_room_alias(self, room_alias):
|
def get_association_from_room_alias(self, room_alias):
|
||||||
""" Get's the room_id and server list for a given room_alias
|
""" Get's the room_id and server list for a given room_alias
|
||||||
@ -69,6 +68,28 @@ class DirectoryStore(SQLBaseStore):
|
|||||||
RoomAliasMapping(room_id, room_alias.to_string(), servers)
|
RoomAliasMapping(room_id, room_alias.to_string(), servers)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_room_alias_creator(self, room_alias):
|
||||||
|
return self._simple_select_one_onecol(
|
||||||
|
table="room_aliases",
|
||||||
|
keyvalues={
|
||||||
|
"room_alias": room_alias,
|
||||||
|
},
|
||||||
|
retcol="creator",
|
||||||
|
desc="get_room_alias_creator",
|
||||||
|
allow_none=True
|
||||||
|
)
|
||||||
|
|
||||||
|
@cached(max_entries=5000)
|
||||||
|
def get_aliases_for_room(self, room_id):
|
||||||
|
return self._simple_select_onecol(
|
||||||
|
"room_aliases",
|
||||||
|
{"room_id": room_id},
|
||||||
|
"room_alias",
|
||||||
|
desc="get_aliases_for_room",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class DirectoryStore(DirectoryWorkerStore):
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def create_room_alias_association(self, room_alias, room_id, servers, creator=None):
|
def create_room_alias_association(self, room_alias, room_id, servers, creator=None):
|
||||||
""" Creates an associatin between a room alias and room_id/servers
|
""" Creates an associatin between a room alias and room_id/servers
|
||||||
@ -116,17 +137,6 @@ class DirectoryStore(SQLBaseStore):
|
|||||||
)
|
)
|
||||||
defer.returnValue(ret)
|
defer.returnValue(ret)
|
||||||
|
|
||||||
def get_room_alias_creator(self, room_alias):
|
|
||||||
return self._simple_select_one_onecol(
|
|
||||||
table="room_aliases",
|
|
||||||
keyvalues={
|
|
||||||
"room_alias": room_alias,
|
|
||||||
},
|
|
||||||
retcol="creator",
|
|
||||||
desc="get_room_alias_creator",
|
|
||||||
allow_none=True
|
|
||||||
)
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def delete_room_alias(self, room_alias):
|
def delete_room_alias(self, room_alias):
|
||||||
room_id = yield self.runInteraction(
|
room_id = yield self.runInteraction(
|
||||||
@ -162,15 +172,6 @@ class DirectoryStore(SQLBaseStore):
|
|||||||
|
|
||||||
return room_id
|
return room_id
|
||||||
|
|
||||||
@cached(max_entries=5000)
|
|
||||||
def get_aliases_for_room(self, room_id):
|
|
||||||
return self._simple_select_onecol(
|
|
||||||
"room_aliases",
|
|
||||||
{"room_id": room_id},
|
|
||||||
"room_alias",
|
|
||||||
desc="get_aliases_for_room",
|
|
||||||
)
|
|
||||||
|
|
||||||
def update_aliases_for_room(self, old_room_id, new_room_id, creator):
|
def update_aliases_for_room(self, old_room_id, new_room_id, creator):
|
||||||
def _update_aliases_for_room_txn(txn):
|
def _update_aliases_for_room_txn(txn):
|
||||||
sql = "UPDATE room_aliases SET room_id = ?, creator = ? WHERE room_id = ?"
|
sql = "UPDATE room_aliases SET room_id = ?, creator = ? WHERE room_id = ?"
|
||||||
|
Loading…
Reference in New Issue
Block a user