mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 07:16:31 +03:00
deltachat_rpc_client: make get_{chat,message}_by_id non-async
This commit is contained in:
@@ -212,7 +212,7 @@ class Account:
|
|||||||
"""
|
"""
|
||||||
return Chat(self, await self._rpc.create_group_chat(self.id, name, protect))
|
return Chat(self, await self._rpc.create_group_chat(self.id, name, protect))
|
||||||
|
|
||||||
async def get_chat_by_id(self, chat_id: int) -> Chat:
|
def get_chat_by_id(self, chat_id: int) -> Chat:
|
||||||
"""Return the Chat instance with the given ID."""
|
"""Return the Chat instance with the given ID."""
|
||||||
return Chat(self, chat_id)
|
return Chat(self, chat_id)
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ class Account:
|
|||||||
"""
|
"""
|
||||||
return await self._rpc.get_chat_securejoin_qr_code_svg(self.id, None)
|
return await self._rpc.get_chat_securejoin_qr_code_svg(self.id, None)
|
||||||
|
|
||||||
async def get_message_by_id(self, msg_id: int) -> Message:
|
def get_message_by_id(self, msg_id: int) -> Message:
|
||||||
"""Return the Message instance with the given ID."""
|
"""Return the Message instance with the given ID."""
|
||||||
return Message(self, msg_id)
|
return Message(self, msg_id)
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ async def test_account(acfactory) -> None:
|
|||||||
msg_id = event.msg_id
|
msg_id = event.msg_id
|
||||||
break
|
break
|
||||||
|
|
||||||
message = await bob.get_message_by_id(msg_id)
|
message = bob.get_message_by_id(msg_id)
|
||||||
snapshot = await message.get_snapshot()
|
snapshot = await message.get_snapshot()
|
||||||
assert snapshot.chat_id == chat_id
|
assert snapshot.chat_id == chat_id
|
||||||
assert snapshot.text == "Hello!"
|
assert snapshot.text == "Hello!"
|
||||||
@@ -82,8 +82,8 @@ async def test_account(acfactory) -> None:
|
|||||||
group = await alice.create_group("test group")
|
group = await alice.create_group("test group")
|
||||||
await group.add_contact(alice_contact_bob)
|
await group.add_contact(alice_contact_bob)
|
||||||
group_msg = await group.send_message(text="hello")
|
group_msg = await group.send_message(text="hello")
|
||||||
assert group_msg == await alice.get_message_by_id(group_msg.id)
|
assert group_msg == alice.get_message_by_id(group_msg.id)
|
||||||
assert group == await alice.get_chat_by_id(group.id)
|
assert group == alice.get_chat_by_id(group.id)
|
||||||
await alice.delete_messages([group_msg])
|
await alice.delete_messages([group_msg])
|
||||||
|
|
||||||
await alice.set_config("selfstatus", "test")
|
await alice.set_config("selfstatus", "test")
|
||||||
@@ -116,11 +116,11 @@ async def test_chat(acfactory) -> None:
|
|||||||
chat_id = event.chat_id
|
chat_id = event.chat_id
|
||||||
msg_id = event.msg_id
|
msg_id = event.msg_id
|
||||||
break
|
break
|
||||||
message = await bob.get_message_by_id(msg_id)
|
message = bob.get_message_by_id(msg_id)
|
||||||
snapshot = await message.get_snapshot()
|
snapshot = await message.get_snapshot()
|
||||||
assert snapshot.chat_id == chat_id
|
assert snapshot.chat_id == chat_id
|
||||||
assert snapshot.text == "Hello!"
|
assert snapshot.text == "Hello!"
|
||||||
bob_chat_alice = await bob.get_chat_by_id(chat_id)
|
bob_chat_alice = bob.get_chat_by_id(chat_id)
|
||||||
|
|
||||||
assert alice_chat_bob != bob_chat_alice
|
assert alice_chat_bob != bob_chat_alice
|
||||||
assert repr(alice_chat_bob)
|
assert repr(alice_chat_bob)
|
||||||
@@ -201,7 +201,7 @@ async def test_message(acfactory) -> None:
|
|||||||
msg_id = event.msg_id
|
msg_id = event.msg_id
|
||||||
break
|
break
|
||||||
|
|
||||||
message = await bob.get_message_by_id(msg_id)
|
message = bob.get_message_by_id(msg_id)
|
||||||
snapshot = await message.get_snapshot()
|
snapshot = await message.get_snapshot()
|
||||||
assert snapshot.chat_id == chat_id
|
assert snapshot.chat_id == chat_id
|
||||||
assert snapshot.text == "Hello!"
|
assert snapshot.text == "Hello!"
|
||||||
|
|||||||
Reference in New Issue
Block a user