MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / FastShareMessage

Function FastShareMessage

Telegram/SourceFiles/boxes/share_box.cpp:1977–2065  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1975}
1976
1977void FastShareMessage(
1978 std::shared_ptr<Main::SessionShow> show,
1979 not_null<HistoryItem*> item,
1980 ShareBoxStyleOverrides st) {
1981 const auto history = item->history();
1982 const auto owner = &history->owner();
1983 const auto session = &history->session();
1984 const auto msgIds = owner->itemOrItsGroup(item);
1985 const auto isGame = item->getMessageBot()
1986 && item->media()
1987 && (item->media()->game() != nullptr);
1988 const auto canCopyLink = item->hasDirectLink() || isGame;
1989
1990 const auto items = owner->idsToItems(msgIds);
1991 const auto hasCaptions = ranges::any_of(items, [](auto item) {
1992 return item->media()
1993 && !item->originalText().text.isEmpty()
1994 && item->media()->allowsEditCaption();
1995 });
1996 const auto hasOnlyForcedForwardedInfo = hasCaptions
1997 ? false
1998 : ranges::all_of(items, [](auto item) {
1999 return item->media() && item->media()->forceForwardedInfo();
2000 });
2001 const auto canShowRichForwardOptions
2002 = !HistoryView::Controls::HasRichPage(items)
2003 || HistoryView::Controls::CanHideForwardAuthor(session, items);
2004
2005 auto copyCallback = [=] {
2006 const auto item = owner->message(msgIds[0]);
2007 if (!item) {
2008 return;
2009 }
2010 if (item->hasDirectLink()) {
2011 using namespace HistoryView;
2012 CopyPostLink(show, item->fullId(), Context::History);
2013 } else if (const auto bot = item->getMessageBot()) {
2014 if (const auto media = item->media()) {
2015 if (const auto game = media->game()) {
2016 const auto link = session->createInternalLinkFull(
2017 bot->username() + u"?game="_q + game->shortName);
2018
2019 QGuiApplication::clipboard()->setText(link);
2020
2021 show->showToast(
2022 tr::lng_share_game_link_copied(tr::now));
2023 }
2024 }
2025 }
2026 };
2027
2028 const auto requiredRight = item->requiredSendRight();
2029 const auto requiresInline = item->requiresSendInlineRight();
2030 auto filterCallback = [=](not_null<Data::Thread*> thread) {
2031 if (const auto user = thread->peer()->asUser()) {
2032 if (user->canSendIgnoreMoneyRestrictions()) {
2033 return true;
2034 }

Callers 4

botHandleMenuButtonMethod · 0.85
showRichMessageMethod · 0.85

Calls 15

HasRichPageFunction · 0.85
CanHideForwardAuthorFunction · 0.85
CopyPostLinkFunction · 0.85
CanSendFunction · 0.85
ItemsForwardSendersCountFunction · 0.85
itemOrItsGroupMethod · 0.80
getMessageBotMethod · 0.80
idsToItemsMethod · 0.80
allowsEditCaptionMethod · 0.80
forceForwardedInfoMethod · 0.80

Tested by

no test coverage detected