HistoryMessage::HistoryMessage( not_null<History*> history, MsgId id, MTPDmessage::Flags flags, TimeId date, UserId from, const QString &postAuthor, not_null<HistoryMessage*> original) : HistoryItem( history, id, NewForwardedFlags(history->peer, from, original) | flags, date, from) { CreateConfig config; if (original->Has<HistoryMessageForwarded>() || !original->history()->peer->isSelf()) { // Server doesn't add "fwd_from" to non-forwarded messages from chat with yourself. config.originalDate = original->dateOriginal(); auto senderOriginal = original->senderOriginal(); config.senderOriginal = senderOriginal->id; config.authorOriginal = original->authorOriginal(); if (senderOriginal->isChannel()) { config.originalId = original->idOriginal(); } } if (history->peer->isSelf()) { // // iOS app sends you to the original post if we forward a forward from channel. // But server returns not the original post but the forward in saved_from_... // //if (config.originalId) { // config.savedFromPeer = config.senderOriginal; // config.savedFromMsgId = config.originalId; //} else { config.savedFromPeer = original->history()->peer->id; config.savedFromMsgId = original->id; //} } if (flags & MTPDmessage::Flag::f_post_author) { config.author = postAuthor; } auto fwdViaBot = original->viaBot(); if (fwdViaBot) config.viaBotId = peerToUser(fwdViaBot->id); int fwdViewsCount = original->viewsCount(); if (fwdViewsCount > 0) { config.viewsCount = fwdViewsCount; } else if (isPost()) { config.viewsCount = 1; } // Copy inline keyboard when forwarding messages with a game. auto mediaOriginal = original->media(); if (mediaOriginal && mediaOriginal->game()) { config.inlineMarkup = original->inlineReplyMarkup(); } createComponents(config); auto ignoreMedia = [&] { if (mediaOriginal && mediaOriginal->webpage()) { if (const auto channel = history->peer->asChannel()) { if (channel->restricted(ChannelRestriction::f_embed_links)) { return true; } } } return false; }; if (mediaOriginal && !ignoreMedia()) { _media = mediaOriginal->clone(this); } setText(original->originalText()); }