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

exportChatInvite does not support some parameters #214

Open matthiasobergasser opened 2 years ago

matthiasobergasser commented 2 years ago

Describe the bug messages.exportChatInvite does not accept legacy_revoke_permanent, expire_date and usage_limit as parameter. Tried all possible combinations. Also on wrong values there is no feedback or error message. It just returns the invitation link with endless usages and endless time

USAGE_LIMIT_INVALIDand EXPIRE_DATE_INVALID never gets thrown

Code example

async function fetchInvitationLink(channel) {
  return await api.call("messages.exportChatInvite",{
    peer: {
      _: "inputPeerChannel",
      channel_id: channel.id,
      access_hash: channel.access_hash,
    },
    legacy_revoke_permanent: false,
    expire_date: 1635497605,
    usage_limit: 2
  })
}

Expected behavior It should return a link with an expire date and a certain usage limit

Screenshots this is what it returns. Also in the real telegram client the links are permanent and without usage limit

{_: 'chatInviteExported', link: 'https://t.me/joinchat/zFgNaq----------'}

Context:

Additional context Until this method everything worked fine and all parameters were accepted right away

Edit:

Through #106 i came to the idea to check the builder and for me it seems that there are no other parameters / flags respected:

'messages.exportChatInvite': function(params) {
    this.int32(234312524);
    this.predicate(params.peer);
  },

i tried to fix it by adding flags:

'messages.exportChatInvite': function(params) {
    this.int32(234312524);
    const flags = (this.has(params.legacy_revoke_permanent) << 2) | (this.has(params.expire_date) << 0) | (this.has(params.usage_limit) << 1);
    this.int32(flags);
    this.predicate(params.peer);
    this.flag(this.int, params.expire_date)
    this.flag(this.int, params.usage_limit)
  },

but i am missing something or doing something wrong, because I always get INPUT_CONSTRUCTOR_INVALID_0X

{
    "_": "mt_rpc_error",
    "error_code": 400,
    "error_message": "INPUT_CONSTRUCTOR_INVALID_03"
}

can someone tell me what i am doing wrong?

alik0211 commented 2 years ago

I think the reason is that there are no flags in layer 121 (it is used in the library version 6.0.1) yet. Flags appeared in the following layers. I will try to update the layer within a few months.