Deduplicate outgoing avatar/title changes
This commit is contained in:
@@ -603,10 +603,11 @@ class Portal:
|
|||||||
return
|
return
|
||||||
|
|
||||||
if self.peer_type == "chat":
|
if self.peer_type == "chat":
|
||||||
await sender.client(EditChatTitleRequest(chat_id=self.tgid, title=title))
|
response = await sender.client(EditChatTitleRequest(chat_id=self.tgid, title=title))
|
||||||
else:
|
else:
|
||||||
channel = await self.get_input_entity(sender)
|
channel = await self.get_input_entity(sender)
|
||||||
await sender.client(EditTitleRequest(channel=channel, title=title))
|
response = await sender.client(EditTitleRequest(channel=channel, title=title))
|
||||||
|
self._register_outgoing_actions_for_dedup(response)
|
||||||
self.title = title
|
self.title = title
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
@@ -622,11 +623,12 @@ class Portal:
|
|||||||
photo = InputChatUploadedPhoto(file=uploaded)
|
photo = InputChatUploadedPhoto(file=uploaded)
|
||||||
|
|
||||||
if self.peer_type == "chat":
|
if self.peer_type == "chat":
|
||||||
updates = await sender.client(EditChatPhotoRequest(chat_id=self.tgid, photo=photo))
|
response = await sender.client(EditChatPhotoRequest(chat_id=self.tgid, photo=photo))
|
||||||
else:
|
else:
|
||||||
channel = await self.get_input_entity(sender)
|
channel = await self.get_input_entity(sender)
|
||||||
updates = await sender.client(EditPhotoRequest(channel=channel, photo=photo))
|
response = await sender.client(EditPhotoRequest(channel=channel, photo=photo))
|
||||||
for update in updates.updates:
|
self._register_outgoing_actions_for_dedup(response)
|
||||||
|
for update in response.updates:
|
||||||
is_photo_update = (isinstance(update, UpdateNewMessage)
|
is_photo_update = (isinstance(update, UpdateNewMessage)
|
||||||
and isinstance(update.message, MessageService)
|
and isinstance(update.message, MessageService)
|
||||||
and isinstance(update.message.action, MessageActionChatEditPhoto))
|
and isinstance(update.message.action, MessageActionChatEditPhoto))
|
||||||
@@ -636,6 +638,13 @@ class Portal:
|
|||||||
self.save()
|
self.save()
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def _register_outgoing_actions_for_dedup(self, response):
|
||||||
|
for update in response.updates:
|
||||||
|
check_dedup = (isinstance(update, (UpdateNewMessage, UpdateNewChannelMessage))
|
||||||
|
and isinstance(update.message, MessageService))
|
||||||
|
if check_dedup:
|
||||||
|
self.is_duplicate_action(update)
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
# region Telegram chat info updating
|
# region Telegram chat info updating
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user