<metaproperty="description"content="In some situations user and channel constructors have reduced set of fields present (although id is always there) and min flag set. ">
<metaproperty="og:description"content="In some situations user and channel constructors have reduced set of fields present (although id is always there) and min flag set. ">
<divid="dev_page_content"><p>In some situations <ahref="/constructor/user">user</a> and <ahref="/constructor/channel">channel</a> constructors have reduced set of fields present (although <code>id</code> is always there) and <code>min</code> flag set. This is done for performance and privacy reasons. </p>
<p>When receiving said constructors, the client must first check if user or chat object without <code>min</code> flag is already present in local cache. If it is present, then the client should just ignore constructors with <code>min</code> flag and use local one instead.</p>
<p><strong>The rest of article assumes the client receives min-constructor without full object in local cache.</strong></p>
<p>The client must store the context (similar to <ahref="/api/file_reference">file references</a>) in which the user/channel was seen. Later, when the client needs to pass the user/channel as input argument (e.g. fetch profile, mute, ban etc), the context is used to generate the <code>input*FromMessage</code> constructor, instead of normal <code>inputUser</code>, <code>inputChannel</code> or <code>inputPeer</code>.</p>
<p>The <code>access_hash</code> value, if present, is only suitable to use in <ahref="/constructor/inputPeerPhotoFileLocation"><code>inputPeerPhotoFileLocation</code></a>, to directly <ahref="/api/files">download the profile pictures</a> of channels and users <strong>without</strong> having to generate an <code>inputPeer*FromMessage</code>, simply using <code>inputPeer*</code> with the specified access hash. </p>
<p>Usually <code>min</code> constructors are encountered in messages inside of groups or channels.
When a message mentioning (sender, forwarder or forwardee, et cetera) such a user or channel is found, the constuctor must be associated with the message ID of the message and with the chat where the message was seen.</p>
<p>Assume a <ahref="/constructor/message">message</a> with id <code>34</code> is received from supergroup (<ahref="/api/channel">actually channel</a>) <code>123456789</code>.
Said message was sent by <code>from_id</code><code>102424212</code>.
The <ahref="/api/updates">updates</a> container that contained the message has a user with ID <code>102424212</code> in the <code>users</code> field, but it has the <code>min</code> flag set, and the provided <code>access_hash</code> may be absent, or otherwise can't be used to generate a typical <ahref="/constructor/inputPeerUser">inputPeerUser</a> constructor to send messages or do other actions.</p>
<p>What the client does is associate <code>102424212</code> with the channel <code>123456789</code> and message ID <code>34</code>.
When and if the client will need to interact with user <code>102424212</code>, it will generate one of the <code>*FromMessage</code> constructors mentioned above, setting:</p>
<ul>
<li><code>msg_id</code> to <code>34</code></li>
<li><code>peer</code> to the <ahref="/type/InputPeer">InputPeer</a> associated with channel <code>123456789</code></li>
<li><code>user_id</code> to <code>102424212</code></li>
</ul>
<p><code>user_id</code> can also be set to the IDs of users met in the <code>fwd_header</code> (messages forwarded from a user can be used to interact with the original sender, if they don't have privacy settings for forwards enabled).
Users mentioned via <ahref="/constructor/messageEntityMentionName">messageEntityMentionName</a> in a message can also be used.</p>
<p>The same can be done with <code>min</code><ahref="/api/channel">channels</a>.</p>
<p>Example implementations: <ahref="https://github.com/peter-iakovlev/Telegram-iOS">Telegram for iOS</a>, <ahref="https://github.com/tdlib/td">tdlib</a>.</p></div>
</div>
</div>
</div>
<divclass="footer_wrap">
<divclass="footer_columns_wrap footer_desktop">
<divclass="footer_column footer_column_telegram">
<h5>Telegram</h5>
<divclass="footer_telegram_description"></div>
Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.