alik0211 / mtproto-core

Telegram API JS (MTProto) client library for Node.js and browser
https://mtproto-core.js.org
GNU General Public License v3.0
630 stars 113 forks source link

messageMediaUnsupported #233

Closed Raptor5 closed 2 years ago

Raptor5 commented 2 years ago

Describe the bug The owner of a channel disbled forwarding to protect messages.

When I request messages using "messages.getHistory" or get then on updates.on('updates', ...) I get messages with .message property empty and .media: { _:"messageMediaUnsupported"}

This started to happen a few days ago.

Context:

joeberetta commented 2 years ago

@Raptor5 it's ok. Cuz Telegram added new type of "empty media" which indices that this message is not supported by your client not empty (cuz is deleted)

Raptor5 commented 2 years ago

@joeberetta So how can I make client to support these new messages? Is it MTProto/core issue or is it Telegram API core issue or my client issue?

joeberetta commented 2 years ago

@Raptor5 you need to implement view for such kind of messages. E.g. Telegram's official client when get this kind of message shows to user message with prefilled text like "This message is not supported by your version. Please update your app"

Raptor5 commented 2 years ago

@joeberetta What do you mean by update your app? I wrote a Telegram client application prom scratch on NodeJS using MTProto/core. The application has to get messages from a predefined channel and output them to console. Which part should I update to be able to receive/decode such messages?

joeberetta commented 2 years ago

@joeberetta What do you mean by update your app? I wrote a Telegram client application prom scratch on NodeJS using MTProto/core. The application has to get messages from a predefined channel and output them to console. Which part should I update to be able to receive/decode such messages?

Oh, sorry. Forgot that client is u with this library🥲

Yes. It's part of @alik0211 to update tl layer)

UPD: By the way, if your client is not browser app, you need to handle this case on your side too. Cuz in this situation you need to publish new version and till this moment older versions of your app can't handle this messages

Raptor5 commented 2 years ago

@alik0211 Please, update the layer :)

Messages look like this:

{_:'message' date:1641932874 edit_hide:false flags:17920 forwards:0 from_scheduled:false id:4185 legacy:false media:{_: 'messageMediaUnsupported'} media_unread:false mentioned:false message:'' noforwards:false out:false peer_id:{_: 'peerChannel', channel_id: '1113513181'} pinned:false post:true silent:false views:882}

Raptor5 commented 2 years ago

@joeberetta updated builder and parser using

npm run generate-builder npm run generate-parser

and fresh API.json from Telegram site but no way. Is there something else @alik0211 can do?

Seems like messageMediaUnsupported is coming from the backend. How does the backend determine that this type of message is unsupported by client?

joeberetta commented 2 years ago

@joeberetta updated builder and parser using

npm run generate-builder npm run generate-parser

and fresh API.json from Telegram site but no way. Is there something else @alik0211 can do?

Seems like messageMediaUnsupported is coming from the backend. How does the backend determine that this type of message is unsupported by client?

It's useless for u. First u need to retrieve latest schema.tl from telegram and after generate it.

Yes, telegram's backend knows it, cuz ur client sends lower layer (think as api version on it) to the backend on connection. Hope it was clear)

Raptor5 commented 2 years ago

@joeberetta I have already downloaded the latest schema.json from here and it is identical to the one from TMProto distribution.

joeberetta commented 2 years ago

@joeberetta I have already downloaded the latest schema.json from here and it is identical to the one from TMProto distribution.

Hmm, if so, IDK how to resolve this issue, by the way check the apiVersion field which sending to the server. If it differs from latest, it would solve the problem

Raptor5 commented 2 years ago

@joeberetta > check the apiVersion field which sending to the server

It would be great if you tell me which file to look at and what function sends this info :)

joeberetta commented 2 years ago

@joeberetta > check the apiVersion field which sending to the server

It would be great if you tell me which file to look at and what function sends this info :)

Sorry, I can't tell u right now. I have to learn code for finding option which can fix it. It must be somewhere with "initConnectionParams".

It would be great to add some typings @alik0211 How do u think?)

Raptor5 commented 2 years ago

It must be somewhere with "initConnectionParams"

The only place I found is this in RPC.call method: const initConnectionParams = { api_id, device_model: '@mtproto/core', system_version: '6.1.1', app_version: '1.0.0', system_lang_code: 'en', lang_code: 'en', ...this.context.initConnectionParams, }; But it doesn't contain anything specific. this.context.initConnectionParams is {}

joeberetta commented 2 years ago

It must be somewhere with "initConnectionParams"

The only place I found is this in RPC.call method: const initConnectionParams = { api_id, device_model: '@mtproto/core', system_version: '6.1.1', app_version: '1.0.0', system_lang_code: 'en', lang_code: 'en', ...this.context.initConnectionParams, }; But it doesn't contain anything specific. this.context.initConnectionParams is {}

As I found from README current supported layer is 133 and it's hardcoded see: https://github.com/alik0211/mtproto-core/blob/d77ba52c6a68f62f137b56dfccf0b6efa40b8bba/src/rpc/index.js#L592

U have to change this value to higher version, but it's temporary solution. As I see, better way is feature request for ability to control API Layer and schema from your code. It should be same as bootstrapping project with gulp (in similar php client madelineproto.xyz here's option to override internal tl schemas with another one).

But I can't guarantee is it ok for project's current logic

Raptor5 commented 2 years ago

@joeberetta Thank you! The actual layer is 137 not 133. So I downloaded tl schema of 137 layer, rebuilt, set layer: 137 and that's it! Problem resolved.

alexsanderluisdev commented 2 years ago

@Raptor5 how did you download tl schema of 137 layer?

Raptor5 commented 2 years ago

@Raptor5 how did you download tl schema of 137 layer?

@alexsanderluisdev Stange, but I can't find it on the Telegram API any more. You can try mine. api.zip

darkblazeGG commented 2 years ago

@Raptor5 Hi, a got the same problem, but im not so high at node.js, can u tell me where i should post this schema or tell some steps to solve this problem now?

Endytech commented 1 year ago

Hi ! 10 months ago, problem was solved by update layer to 139. But 23.01.23 Again empty message, and media: { : 'messageMediaUnsupported' }, item { : 'message', flags: 50688, out: false, mentioned: false, media_unread: false, silent: false, post: true, from_scheduled: false, legacy: false, edit_hide: false, pinned: false, noforwards: false, id: 347, peerid: { : 'peerChannel', channelid: '1681209320' }, date: 1674457581, message: '', media: { : 'messageMediaUnsupported' }, views: 143, forwards: 3, edit_date: 1674457692 }