Fix most private messages being outgoing since 56ddaae

56ddaae checked to_id and from_id to compare if they were equal,
and if they were, mark the event as outgoing for convenience in
your private chat (saved messages).

However when reconstructing the Message from UpdateShortMessage
to_id didn't mimic 100% Telegram's behaviour (the chat to which
the message is sent is "different" depending on who sent the
messages). This bug is what actually caused most messages to
be outgoing, even though 56ddaae's logic is correct.
This commit is contained in:
Lonami Exo 2018-06-22 10:21:32 +02:00
parent 8d98c04932
commit 1a1d9d346c

View File

@ -88,7 +88,11 @@ class NewMessage(EventBuilder):
media_unread=update.media_unread,
silent=update.silent,
id=update.id,
to_id=types.PeerUser(update.user_id),
# Note that to_id/from_id complement each other in private
# messages, depending on whether the message was outgoing.
to_id=types.PeerUser(
update.user_id if update.out else self._self_id
),
from_id=self._self_id if update.out else update.user_id,
message=update.message,
date=update.date,