mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
Fix ruff warnings
This commit is contained in:
@@ -182,19 +182,23 @@ class Chat:
|
|||||||
"""Add contacts to this group."""
|
"""Add contacts to this group."""
|
||||||
for cnt in contact:
|
for cnt in contact:
|
||||||
if isinstance(cnt, str):
|
if isinstance(cnt, str):
|
||||||
cnt = (await self.account.create_contact(cnt)).id
|
contact_id = (await self.account.create_contact(cnt)).id
|
||||||
elif not isinstance(cnt, int):
|
elif not isinstance(cnt, int):
|
||||||
cnt = cnt.id
|
contact_id = cnt.id
|
||||||
await self._rpc.add_contact_to_chat(self.account.id, self.id, cnt)
|
else:
|
||||||
|
contact_id = cnt
|
||||||
|
await self._rpc.add_contact_to_chat(self.account.id, self.id, contact_id)
|
||||||
|
|
||||||
async def remove_contact(self, *contact: Union[int, str, Contact]) -> None:
|
async def remove_contact(self, *contact: Union[int, str, Contact]) -> None:
|
||||||
"""Remove members from this group."""
|
"""Remove members from this group."""
|
||||||
for cnt in contact:
|
for cnt in contact:
|
||||||
if isinstance(cnt, str):
|
if isinstance(cnt, str):
|
||||||
cnt = (await self.account.create_contact(cnt)).id
|
contact_id = (await self.account.create_contact(cnt)).id
|
||||||
elif not isinstance(cnt, int):
|
elif not isinstance(cnt, int):
|
||||||
cnt = cnt.id
|
contact_id = cnt.id
|
||||||
await self._rpc.remove_contact_from_chat(self.account.id, self.id, cnt)
|
else:
|
||||||
|
contact_id = cnt
|
||||||
|
await self._rpc.remove_contact_from_chat(self.account.id, self.id, contact_id)
|
||||||
|
|
||||||
async def get_contacts(self) -> List[Contact]:
|
async def get_contacts(self) -> List[Contact]:
|
||||||
"""Get the contacts belonging to this chat.
|
"""Get the contacts belonging to this chat.
|
||||||
@@ -230,9 +234,9 @@ class Chat:
|
|||||||
locations = []
|
locations = []
|
||||||
contacts: Dict[int, Contact] = {}
|
contacts: Dict[int, Contact] = {}
|
||||||
for loc in result:
|
for loc in result:
|
||||||
loc = AttrDict(loc)
|
location = AttrDict(loc)
|
||||||
loc["chat"] = self
|
location["chat"] = self
|
||||||
loc["contact"] = contacts.setdefault(loc.contact_id, Contact(self.account, loc.contact_id))
|
location["contact"] = contacts.setdefault(location.contact_id, Contact(self.account, location.contact_id))
|
||||||
loc["message"] = Message(self.account, loc.msg_id)
|
location["message"] = Message(self.account, location.msg_id)
|
||||||
locations.append(loc)
|
locations.append(location)
|
||||||
return locations
|
return locations
|
||||||
|
|||||||
Reference in New Issue
Block a user