mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-06 12:15:02 -04:00
Test room alias deletion (#11327)
* Prefer `HTTPStatus` over plain `int` This is an Opinion that no-one has seemed to object to yet. * `--disallow-untyped-defs` for `tests.rest.client.test_directory` * Improve synapse's annotations for deleting aliases * Test case for deleting a room alias * Changelog
This commit is contained in:
parent
0bcae8ad56
commit
bea815cec8
5 changed files with 91 additions and 31 deletions
|
@ -17,6 +17,7 @@ from typing import Iterable, List, Optional
|
|||
|
||||
from synapse.api.errors import SynapseError
|
||||
from synapse.storage._base import SQLBaseStore
|
||||
from synapse.storage.database import LoggingTransaction
|
||||
from synapse.types import RoomAlias
|
||||
from synapse.util.caches.descriptors import cached
|
||||
|
||||
|
@ -126,14 +127,16 @@ class DirectoryWorkerStore(SQLBaseStore):
|
|||
|
||||
|
||||
class DirectoryStore(DirectoryWorkerStore):
|
||||
async def delete_room_alias(self, room_alias: RoomAlias) -> str:
|
||||
async def delete_room_alias(self, room_alias: RoomAlias) -> Optional[str]:
|
||||
room_id = await self.db_pool.runInteraction(
|
||||
"delete_room_alias", self._delete_room_alias_txn, room_alias
|
||||
)
|
||||
|
||||
return room_id
|
||||
|
||||
def _delete_room_alias_txn(self, txn, room_alias: RoomAlias) -> str:
|
||||
def _delete_room_alias_txn(
|
||||
self, txn: LoggingTransaction, room_alias: RoomAlias
|
||||
) -> Optional[str]:
|
||||
txn.execute(
|
||||
"SELECT room_id FROM room_aliases WHERE room_alias = ?",
|
||||
(room_alias.to_string(),),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue