mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-09-18 20:24:39 -04:00
Additional constants for EDU types. (#12884)
Instead of hard-coding strings in many places.
This commit is contained in:
parent
d9f092285b
commit
c52abc1cfd
35 changed files with 146 additions and 96 deletions
|
@ -19,6 +19,7 @@ from unittest.mock import Mock
|
|||
from twisted.test.proto_helpers import MemoryReactor
|
||||
|
||||
import synapse.rest.admin
|
||||
from synapse.api.constants import EduTypes
|
||||
from synapse.rest.client import events, login, room
|
||||
from synapse.server import HomeServer
|
||||
from synapse.util import Clock
|
||||
|
@ -103,7 +104,7 @@ class EventStreamPermissionsTestCase(unittest.HomeserverTestCase):
|
|||
c
|
||||
for c in channel.json_body["chunk"]
|
||||
if not (
|
||||
c.get("type") == "m.presence"
|
||||
c.get("type") == EduTypes.PRESENCE
|
||||
and c["content"].get("user_id") == self.user_id
|
||||
)
|
||||
]
|
||||
|
|
|
@ -26,6 +26,7 @@ from twisted.test.proto_helpers import MemoryReactor
|
|||
|
||||
import synapse.rest.admin
|
||||
from synapse.api.constants import (
|
||||
EduTypes,
|
||||
EventContentFields,
|
||||
EventTypes,
|
||||
Membership,
|
||||
|
@ -1412,7 +1413,7 @@ class RoomInitialSyncTestCase(RoomBase):
|
|||
e["content"]["user_id"]: e for e in channel.json_body["presence"]
|
||||
}
|
||||
self.assertTrue(self.user_id in presence_by_user)
|
||||
self.assertEqual("m.presence", presence_by_user[self.user_id]["type"])
|
||||
self.assertEqual(EduTypes.PRESENCE, presence_by_user[self.user_id]["type"])
|
||||
|
||||
|
||||
class RoomMessageListTestCase(RoomBase):
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from synapse.api.constants import EduTypes
|
||||
from synapse.rest import admin
|
||||
from synapse.rest.client import login, sendtodevice, sync
|
||||
|
||||
|
@ -139,7 +140,7 @@ class SendToDeviceTestCase(HomeserverTestCase):
|
|||
for i in range(3):
|
||||
self.get_success(
|
||||
federation_registry.on_edu(
|
||||
"m.direct_to_device",
|
||||
EduTypes.DIRECT_TO_DEVICE,
|
||||
"remote_server",
|
||||
{
|
||||
"sender": "@user:remote_server",
|
||||
|
@ -172,7 +173,7 @@ class SendToDeviceTestCase(HomeserverTestCase):
|
|||
# and we can send more messages
|
||||
self.get_success(
|
||||
federation_registry.on_edu(
|
||||
"m.direct_to_device",
|
||||
EduTypes.DIRECT_TO_DEVICE,
|
||||
"remote_server",
|
||||
{
|
||||
"sender": "@user:remote_server",
|
||||
|
|
|
@ -17,7 +17,7 @@ from unittest.mock import Mock, patch
|
|||
from twisted.test.proto_helpers import MemoryReactor
|
||||
|
||||
import synapse.rest.admin
|
||||
from synapse.api.constants import EventTypes
|
||||
from synapse.api.constants import EduTypes, EventTypes
|
||||
from synapse.rest.client import (
|
||||
directory,
|
||||
login,
|
||||
|
@ -226,7 +226,7 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
events[0],
|
||||
[
|
||||
{
|
||||
"type": "m.typing",
|
||||
"type": EduTypes.TYPING,
|
||||
"room_id": room_id,
|
||||
"content": {"user_ids": [self.other_user_id]},
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ from twisted.test.proto_helpers import MemoryReactor
|
|||
|
||||
import synapse.rest.admin
|
||||
from synapse.api.constants import (
|
||||
EduTypes,
|
||||
EventContentFields,
|
||||
EventTypes,
|
||||
ReceiptTypes,
|
||||
|
@ -504,7 +505,7 @@ class ReadReceiptsTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# Checks if event is a read receipt
|
||||
def is_read_receipt(event: JsonDict) -> bool:
|
||||
return event["type"] == "m.receipt"
|
||||
return event["type"] == EduTypes.RECEIPT
|
||||
|
||||
# Sync
|
||||
channel = self.make_request(
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
from twisted.test.proto_helpers import MemoryReactor
|
||||
|
||||
from synapse.api.constants import EduTypes
|
||||
from synapse.rest.client import room
|
||||
from synapse.server import HomeServer
|
||||
from synapse.types import UserID
|
||||
|
@ -67,7 +68,7 @@ class RoomTypingTestCase(unittest.HomeserverTestCase):
|
|||
events[0],
|
||||
[
|
||||
{
|
||||
"type": "m.typing",
|
||||
"type": EduTypes.TYPING,
|
||||
"room_id": self.room_id,
|
||||
"content": {"user_ids": [self.user_id]},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue