mautrix / telegram

A Matrix-Telegram hybrid puppeting/relaybot bridge
https://matrix.to/#/#telegram:maunium.net
GNU Affero General Public License v3.0
1.3k stars 172 forks source link

Ghost missing in portaled room and messages dropped T->M #516

Open pacien opened 4 years ago

pacien commented 4 years ago

Some user present in a Telegram chat is missing on the Matrix side of a portaled room. The messages that they send are simply missing from the Matrix side of the conversation.

Even restarting the bridge doesn't seem to create the missing ghost. Running !tg sync-state in the room results in Synchronization complete but doesn't create the missing ghost.

This issue has first been observed on mautrix-telegram 0.7.2 and seems to persist after upgrading to 0.8.2.

There is no error showing up in the log while restarting the bridge or running the sync-state command. There is however some stacktrace appearing when the user for whom the corresponding ghost is missing is sending a message (log entry from 0.7.2):

Aug 11 09:53:48 hp2 mautrix-telegram[1582]: [ERROR@mau.user.[BRIDGE_PORTAL_USER]] Failed to handle Telegram update UpdateNewChannelMessage(message=Message([MESSAGE REDACTED]), pts=36890, pts_count=1)
Aug 11 09:53:48 hp2 mautrix-telegram[1582]: Traceback (most recent call last):
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:   File "/nix/store/iqvll6zg4ds0hb0xkgvdxs3ana43dk6p-python3.7-mautrix-telegram-0.7.2/lib/python3.7/site-packages/mautrix_telegram/abstract_user.py", line 194, in _update_catch
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:     await self._update(update)
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:   File "/nix/store/iqvll6zg4ds0hb0xkgvdxs3ana43dk6p-python3.7-mautrix-telegram-0.7.2/lib/python3.7/site-packages/mautrix_telegram/abstract_user.py", line 241, in _update
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:     await self.update_message(update)
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:   File "/nix/store/iqvll6zg4ds0hb0xkgvdxs3ana43dk6p-python3.7-mautrix-telegram-0.7.2/lib/python3.7/site-packages/mautrix_telegram/abstract_user.py", line 441, in update_message
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:     return await portal.handle_telegram_message(self, sender, update)
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:   File "/nix/store/iqvll6zg4ds0hb0xkgvdxs3ana43dk6p-python3.7-mautrix-telegram-0.7.2/lib/python3.7/site-packages/mautrix_telegram/portal/telegram.py", line 418, in handle_telegram_message
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:     relates_to=formatter.telegram_reply_to_matrix(evt, source))
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:   File "/nix/store/iqvll6zg4ds0hb0xkgvdxs3ana43dk6p-python3.7-mautrix-telegram-0.7.2/lib/python3.7/site-packages/mautrix_telegram/portal/telegram.py", line 198, in handle_telegram_document
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:     return await intent.send_message_event(self.mxid, event_type, content, timestamp=evt.date)
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:   File "/nix/store/m535qwvj8bqsb52idl6lf6fh00wyx4h4-python3.7-mautrix-0.4.2/lib/python3.7/site-packages/mautrix/appservice/api/intent.py", line 87, in wrapper
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:     return await __method(*args, **kwargs)
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:   File "/nix/store/m535qwvj8bqsb52idl6lf6fh00wyx4h4-python3.7-mautrix-0.4.2/lib/python3.7/site-packages/mautrix/appservice/api/intent.py", line 289, in send_message_event
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:     return await super().send_message_event(room_id, event_type, content, **kwargs)
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:   File "/nix/store/m535qwvj8bqsb52idl6lf6fh00wyx4h4-python3.7-mautrix-0.4.2/lib/python3.7/site-packages/mautrix/client/api/events.py", line 294, in send_message_event
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:     resp = await self.api.request(Method.PUT, url, content, **kwargs)
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:   File "/nix/store/m535qwvj8bqsb52idl6lf6fh00wyx4h4-python3.7-mautrix-0.4.2/lib/python3.7/site-packages/mautrix/api/http.py", line 205, in request
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:     return await self._send(method, endpoint, content, query_params, headers or {})
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:   File "/nix/store/m535qwvj8bqsb52idl6lf6fh00wyx4h4-python3.7-mautrix-0.4.2/lib/python3.7/site-packages/mautrix/api/http.py", line 146, in _send
Aug 11 09:53:48 hp2 mautrix-telegram[1582]:     errcode=errcode, message=message)
Aug 11 09:53:48 hp2 mautrix-telegram[1582]: mautrix.errors.request.MForbidden: User @telegram_[MISSING_USER]:[HS] not in room ![ROOM_ID]:[HS] (<FrozenEventV3 event_id='$[EVENT_ID]', type='m.room.member', state_key='@telegram_[MISSING_USER]:[HS]'>)
pacien commented 4 years ago

Same error with mautrix-telegram 0.8.2:

Aug 11 20:10:57 hp2 mautrix-telegram[16109]: [ERROR@mau.user.[BRIDGE_PORTAL_USER]] Failed to handle Telegram update UpdateNewChannelMessage([MESSAGE REDACTED]), pts=36917, pts_count=1)
Aug 11 20:10:57 hp2 mautrix-telegram[16109]: Traceback (most recent call last):
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:   File "/nix/store/m88k0igk6d95pnvxs5rf71falym0gdgl-python3.8-mautrix-telegram-0.8.2/lib/python3.8/site-packages/mautrix_telegram/abstract_user.py", line 195, in _update_catch
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:     await self._update(update)
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:   File "/nix/store/m88k0igk6d95pnvxs5rf71falym0gdgl-python3.8-mautrix-telegram-0.8.2/lib/python3.8/site-packages/mautrix_telegram/abstract_user.py", line 242, in _update
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:     await self.update_message(update)
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:   File "/nix/store/m88k0igk6d95pnvxs5rf71falym0gdgl-python3.8-mautrix-telegram-0.8.2/lib/python3.8/site-packages/mautrix_telegram/abstract_user.py", line 440, in update_message
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:     return await portal.handle_telegram_message(self, sender, update)
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:   File "/nix/store/m88k0igk6d95pnvxs5rf71falym0gdgl-python3.8-mautrix-telegram-0.8.2/lib/python3.8/site-packages/mautrix_telegram/portal/telegram.py", line 493, in handle_telegram_message
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:     event_id = await self.handle_telegram_text(source, intent, is_bot, evt)
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:   File "/nix/store/m88k0igk6d95pnvxs5rf71falym0gdgl-python3.8-mautrix-telegram-0.8.2/lib/python3.8/site-packages/mautrix_telegram/portal/telegram.py", line 249, in handle_telegram_text
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:     return await self._send_message(intent, content, timestamp=evt.date)
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:   File "/nix/store/m88k0igk6d95pnvxs5rf71falym0gdgl-python3.8-mautrix-telegram-0.8.2/lib/python3.8/site-packages/mautrix_telegram/portal/base.py", line 471, in _send_message
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:     return await intent.send_message_event(self.mxid, event_type, content, **kwargs)
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:   File "/nix/store/812dhbdz88vxm283zdvjw61xzaagkvrh-python3.8-mautrix-0.5.8/lib/python3.8/site-packages/mautrix/appservice/api/intent.py", line 87, in wrapper
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:     return await __method(*args, **kwargs)
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:   File "/nix/store/812dhbdz88vxm283zdvjw61xzaagkvrh-python3.8-mautrix-0.5.8/lib/python3.8/site-packages/mautrix/appservice/api/intent.py", line 289, in send_message_event
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:     return await super().send_message_event(room_id, event_type, content, **kwargs)
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:   File "/nix/store/812dhbdz88vxm283zdvjw61xzaagkvrh-python3.8-mautrix-0.5.8/lib/python3.8/site-packages/mautrix/client/api/events.py", line 294, in send_message_event
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:     resp = await self.api.request(Method.PUT, url, content, **kwargs)
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:   File "/nix/store/812dhbdz88vxm283zdvjw61xzaagkvrh-python3.8-mautrix-0.5.8/lib/python3.8/site-packages/mautrix/api/http.py", line 203, in request
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:     return await self._send(method, endpoint, content, query_params, headers or {})
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:   File "/nix/store/812dhbdz88vxm283zdvjw61xzaagkvrh-python3.8-mautrix-0.5.8/lib/python3.8/site-packages/mautrix/api/http.py", line 143, in _send
Aug 11 20:10:57 hp2 mautrix-telegram[16109]:     raise make_request_error(http_status=response.status,
Aug 11 20:10:57 hp2 mautrix-telegram[16109]: mautrix.errors.request.MForbidden: User @telegram_[MISSING_USER]:[HS] not in room ![ROOM_ID]:[HS] (<FrozenEventV3 event_id='$[EVENT_ID]', type='m.room.member', state_key='@telegram_[MISSING_USER]:[HS]'>)
LuckyTurtleDev commented 3 years ago

I have the same issues. The users does not join the group and their message get lost. If I enter !tg sync the users join the group.

wucke13 commented 3 years ago

I have a variation of this issue: I get the

mautrix.errors.request.MForbidden: User @telegram_[MISSING_USER]:[HS] not in room ![ROOM_ID]:[HS] (<FrozenEventV3 event_id='$[EVENT_ID]', type='m.room.member', state_key='@telegram_[MISSING_USER]:[HS]'>)

Despite a user with that very ID being the room. I'm on mautrix 0.9.0.

NickCao commented 2 years ago

Still reproducible.