def sync_response(self): timeline = Timeline([ RoomMemberEvent( { "event_id": "event_id_1", "sender": ALICE_ID, "origin_server_ts": 1516809890615 }, ALICE_ID, "join", None, {"membership": "join"}), RoomMemberEvent( { "event_id": "event_id_2", "sender": ALICE_ID, "origin_server_ts": 1516809890615 }, CAROL_ID, "invite", None, {"membership": "invite"}, ), RoomEncryptionEvent({ "event_id": "event_id_3", "sender": ALICE_ID, "origin_server_ts": 1516809890615 }) ], False, "prev_batch_token") test_room_info = RoomInfo( timeline, [], [ TypingNoticeEvent([ALICE_ID]), ReceiptEvent([ Receipt(event_id="event_id_3", receipt_type="m.read", user_id=ALICE_ID, timestamp=1516809890615) ]) ], [], RoomSummary(invited_member_count=1, joined_member_count=2), ) rooms = Rooms({}, {TEST_ROOM_ID: test_room_info}, {}) return SyncResponse("token123", rooms, DeviceOneTimeKeyCount( 49, 50), DeviceList([ALICE_ID], []), [ RoomEncryptionEvent({ "event_id": "event_id_2", "sender": ALICE_ID, "origin_server_ts": 1516809890615 }) ])
def sync_response(self): timeline = Timeline([ RoomMemberEvent( { "event_id": "event_id_1", "sender": ALICE_ID, "origin_server_ts": 1516809890615 }, ALICE_ID, "join", None, {"membership": "join"}), RoomEncryptionEvent({ "event_id": "event_id_2", "sender": ALICE_ID, "origin_server_ts": 1516809890615 }) ], False, "prev_batch_token") test_room_info = RoomInfo(timeline, [], [TypingNoticeEvent([ALICE_ID])], [], RoomSummary(1, 2, [])) rooms = Rooms({}, {TEST_ROOM_ID: test_room_info}, {}) return SyncResponse("token123", rooms, DeviceOneTimeKeyCount( 49, 50), DeviceList([ALICE_ID], []), [ RoomEncryptionEvent({ "event_id": "event_id_2", "sender": ALICE_ID, "origin_server_ts": 1516809890615 }) ])
def downgrade_sync(self): timeline = Timeline([ RoomMemberEvent("event_id_1", ALICE_ID, 1516809890615, ALICE_ID, {"membership": "join"}), ], False, "prev_batch_token") test_room_info = RoomInfo(timeline, [], [], [], RoomSummary(1, 2, [])) rooms = Rooms({}, {TEST_ROOM_ID: test_room_info}, {}) return SyncResponse("token123", rooms, DeviceOneTimeKeyCount(49, 50), DeviceList([ALICE_ID], []), [])
async def handle_room_membership(self, evt: StateEvent) -> None: if self._ignore_user(evt.state_key): return try: room = self.client.rooms[evt.room_id] except KeyError: room = self.client.rooms[evt.room_id] = NioRoom(evt.room_id, self.bot_mxid, encrypted=True) await self.client.joined_members(evt.room_id) nio_evt = NioMemberEvent.from_dict(evt.serialize()) try: if room.handle_membership(nio_evt): self.client._invalidate_session_for_member_event(evt.room_id) except Exception: self.log.exception("matrix-nio failed to handle membership event")
def sync_response(self): timeline = Timeline([ RoomMemberEvent( { "event_id": "event_id_1", "sender": ALICE_ID, "origin_server_ts": 1516809890615 }, ALICE_ID, "join", None, {"membership": "join"}), RoomMemberEvent( { "event_id": "event_id_2", "sender": ALICE_ID, "origin_server_ts": 1516809890615 }, CAROL_ID, "invite", None, {"membership": "invite"}, ), RoomEncryptionEvent({ "event_id": "event_id_3", "sender": ALICE_ID, "origin_server_ts": 1516809890615 }) ], False, "prev_batch_token") test_room_info = RoomInfo( timeline=timeline, state=[], ephemeral=[ TypingNoticeEvent([ALICE_ID]), ReceiptEvent([ Receipt(event_id="event_id_3", receipt_type="m.read", user_id=ALICE_ID, timestamp=1516809890615) ]) ], account_data=[ FullyReadEvent(event_id="event_id_2"), TagEvent(tags={"u.test": { "order": 1 }}), ], summary=RoomSummary( invited_member_count=1, joined_member_count=2, ), ) rooms = Rooms(invite={}, join={TEST_ROOM_ID: test_room_info}, leave={}) return SyncResponse(next_batch="token123", rooms=rooms, device_key_count=DeviceOneTimeKeyCount(49, 50), device_list=DeviceList([ALICE_ID], []), to_device_events=[ RoomEncryptionEvent({ "event_id": "event_id_2", "sender": ALICE_ID, "origin_server_ts": 1516809890615 }) ], presence_events=[ PresenceEvent(ALICE_ID, "online", 1337, True, "I am here.") ])