mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Implement disabling/enabling sharing.
This commit is contained in:
@@ -858,6 +858,8 @@ PRIVATE
|
||||
history/view/media/history_view_media_spoiler.h
|
||||
history/view/media/history_view_media_unwrapped.cpp
|
||||
history/view/media/history_view_media_unwrapped.h
|
||||
history/view/media/history_view_no_forwards_request.cpp
|
||||
history/view/media/history_view_no_forwards_request.h
|
||||
history/view/media/history_view_photo.cpp
|
||||
history/view/media/history_view_photo.h
|
||||
history/view/media/history_view_poll.cpp
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="72px" height="72px" viewBox="0 0 72 72" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>General / menu_download_off</title>
|
||||
<g id="General-/-menu_download_off" stroke="none" fill="none" fill-rule="nonzero">
|
||||
<path d="M9.47389883,17.6528876 L12.7944831,20.7769886 C9.92145398,25.1476842 8.25,30.3786476 8.25,36 C8.25,51.3259018 20.6740982,63.75 36,63.75 C42.2291078,63.75 47.9788491,61.6975883 52.6098705,58.2321183 L55.930069,61.3563149 C50.444238,65.674153 43.5229296,68.25 36,68.25 C18.1888168,68.25 3.75,53.8111832 3.75,36 C3.75,29.1836121 5.86472873,22.8611455 9.47389883,17.6528876 Z M10.5466159,7.36583985 L66.5466159,60.3658399 C67.4491376,61.2200122 67.4883325,62.6440941 66.6341601,63.5466159 C65.7799878,64.4491376 64.3559059,64.4883325 63.4533841,63.6341601 L7.45338414,10.6341601 C6.55086241,9.7799878 6.5116675,8.35590587 7.36583985,7.45338414 C8.2200122,6.55086241 9.64409413,6.5116675 10.5466159,7.36583985 Z M23.5706043,35.8888817 L33.2499989,45.324 L33.2499989,40.02 L37.7499989,44.253 L37.7499989,46.299 L38.818,45.258 L42.099,48.344 L37.7102136,52.6229689 C36.7587254,53.5505305 35.2412746,53.5505305 34.2897864,52.6229689 L20.4293957,39.1111183 C19.5395996,38.2436975 19.5214609,36.8191917 20.3888817,35.9293957 C21.2563025,35.0395996 22.6808083,35.0214609 23.5706043,35.8888817 Z M36,3.75 C53.8111832,3.75 68.25,18.1888168 68.25,36 C68.25,42.0362889 66.5916122,47.6852405 63.7056013,52.5160902 L60.3364031,49.3450226 C62.512335,45.3853526 63.75,40.8372124 63.75,36 C63.75,20.6740982 51.3259018,8.25 36,8.25 C30.5567647,8.25 25.4795707,9.81720938 21.1950318,12.5250144 L17.8250746,9.35540043 C23.0002277,5.81848433 29.2585536,3.75 36,3.75 Z M51.6111183,35.9293957 C52.4785391,36.8191917 52.4604004,38.2436975 51.5706043,39.1111183 L50.532,40.123 L47.251,37.036 L48.4293957,35.8888817 C49.3191917,35.0214609 50.7436975,35.0395996 51.6111183,35.9293957 Z M35.5,17.75 C36.7426407,17.75 37.75,18.7573593 37.75,20 L37.75,28.099 L33.25,23.865 L33.25,20 C33.25,18.7573593 34.2573593,17.75 35.5,17.75 Z" id="Shape" fill="#FFFFFF"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="72px" height="72px" viewBox="0 0 72 72" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>General / menu_share_off</title>
|
||||
<g id="General-/-menu_share_off" stroke="none" fill="none" fill-rule="evenodd" stroke-width="1">
|
||||
<g id="Group-Copy" fill="#FFFFFF">
|
||||
<path d="M13.5410475,10.3605877 L63.5410475,57.3605877 C64.4464699,58.2116848 64.4905093,59.6356251 63.6394123,60.5410475 C62.7883152,61.4464699 61.3643749,61.4905093 60.4589525,60.6394123 L10.4589525,13.6394123 C9.55353009,12.7883152 9.5094907,11.3643749 10.3605877,10.4589525 C11.2116848,9.55353009 12.6356251,9.5094907 13.5410475,10.3605877 Z M20.8697864,27.9167669 L24.2120013,31.0494419 C22.5720741,32.209287 20.97837,33.5705168 19.4634089,35.1234281 C14.9053119,39.7957062 11.9408626,45.1740812 10.5605883,51.3047505 L11.5051987,50.6015513 C16.0028436,47.2792607 19.5161459,45.0657707 22.0998368,43.9379122 C25.3941073,42.4998643 29.8873875,41.7830384 35.6139217,41.7402273 L39.7497201,45.6169821 L39.75,52.8610336 L43.6427201,49.2669821 L46.9337201,52.3519821 L41.5435504,57.3295353 C40.8508419,57.9689585 39.9427126,58.3240224 39,58.3240224 C36.9289322,58.3240224 35.25,56.6450902 35.25,54.5740224 L35.25,46.2445368 C30.2823664,46.3118224 26.4887541,46.9320902 23.9001632,48.0620878 C21.1038403,49.2827666 16.6790868,52.217586 10.7334856,56.8296594 C10.0454974,57.3626476 9.17248701,57.5974385 8.30996087,57.4814518 C6.53104748,57.2422354 5.28287643,55.606218 5.5220928,53.8273046 L5.82195865,51.5973762 L5.91112003,51.609366 C7.32643988,44.1287015 10.7867131,37.5733134 16.2423132,31.9810496 C17.7180145,30.4683817 19.2679346,29.1105456 20.8697864,27.9167669 Z M41.574499,10.6994311 L63.4340398,30.8770703 C63.5173005,30.9539264 63.5974393,31.0340651 63.6742803,31.1173096 C65.2663463,32.8420477 65.1587942,35.5308487 63.4340561,37.1229146 L55.0377201,44.8719821 L51.7467201,41.7869821 L60.1827844,34.0000018 L39.7914686,15.1776163 L39.8121759,19.4395349 L39.81008,21.9362814 C39.8076961,22.3780357 39.8040398,22.7522447 39.7990732,23.0599114 L39.7825303,23.7289937 C39.7787867,23.8265061 39.7745714,23.9114264 39.7697493,23.9851995 C39.7624707,24.096554 39.7535986,24.1918121 39.7385791,24.2928873 L39.661515,24.796446 C39.4402142,26.1576904 39.2505293,26.2209711 37.5424339,26.2531907 C36.8212,26.2667952 36.0924969,26.3233582 35.3590026,26.4220805 L31.3609553,22.6738894 C32.6774415,22.3146094 33.997132,22.0625163 35.3100594,21.9217361 L35.3094753,18.5338121 C35.304347,17.1233929 35.2942592,15.4381587 35.2792041,13.4782339 C35.2728525,12.5247482 35.6299537,11.6046499 36.2778705,10.9050936 C37.6851807,9.38561997 40.0578077,9.29469349 41.574499,10.6994311 Z" id="Shape" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="72px" height="72px" viewBox="0 0 72 72" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>General / menu_share_on</title>
|
||||
<g id="General-/-menu_share_on" stroke="none" fill="none" fill-rule="nonzero">
|
||||
<path d="M70.5418968,45.3555412 C71.4743766,46.1769042 71.5644546,47.5986747 70.7430916,48.5311546 L57.3925886,63.6877603 C57.3238151,63.7641971 57.3238151,63.7641971 57.2518797,63.8376661 C55.9826757,65.1068701 53.9248896,65.1068701 52.6556856,63.8376661 L46.4090097,57.5909903 C45.5303301,56.7123106 45.5303301,55.2876894 46.4090097,54.4090097 C47.2876894,53.5303301 48.7123106,53.5303301 49.5909903,54.4090097 L54.896011,59.7140304 L67.3662834,45.556736 C68.1876464,44.6242562 69.6094169,44.5341782 70.5418968,45.3555412 Z M40.574499,6.69943107 L62.4340398,26.8770703 C62.5173005,26.9539264 62.5974393,27.0340651 62.6742803,27.1173096 C64.2663463,28.8420477 64.1587942,31.5308487 62.4340561,33.1229146 L40.5435504,53.3295353 C39.8508419,53.9689585 38.9427126,54.3240224 38,54.3240224 C35.9289322,54.3240224 34.25,52.6450902 34.25,50.5740224 L34.25,42.2445368 C29.2823664,42.3118224 25.4887541,42.9320902 22.9001632,44.0620878 C20.1038403,45.2827666 15.6790868,48.217586 9.73348561,52.8296594 C9.04549739,53.3626476 8.17248701,53.5974385 7.30996087,53.4814518 C5.53104748,53.2422354 4.28287643,51.606218 4.5220928,49.8273046 L4.82195865,47.5973762 L4.91112003,47.609366 C6.32643988,40.1287015 9.78671313,33.5733134 15.2423132,27.9810496 C20.9223073,22.1587705 27.7018464,18.6303097 34.3100594,17.9217361 C34.311043,17.7474678 34.3117992,17.5601548 34.3123494,17.3612422 L34.312932,17.1056401 L34.3131028,15.9634276 C34.3110268,14.3126951 34.2997338,12.1508586 34.2792041,9.47823391 C34.2728525,8.52474824 34.6299537,7.60464986 35.2778705,6.90509359 C36.6851807,5.38561997 39.0578077,5.29469349 40.574499,6.69943107 Z M38.7914686,11.1776163 C38.8038479,13.0150348 38.8109783,14.5636507 38.8129119,15.8271389 L38.8129621,17.0925577 C38.8127949,17.188613 38.812585,17.2823229 38.8123322,17.3736902 C38.8098628,18.2664023 38.8033194,18.9389672 38.7924819,19.3972354 C38.7866103,19.6455183 38.7793935,19.8376533 38.7697493,19.9851995 C38.7624707,20.096554 38.7535986,20.1918121 38.7385791,20.2928873 C38.4636206,22.1432446 38.4403177,22.2173911 36.5424339,22.2531907 C30.5168733,22.3668501 23.9699768,25.4789196 18.4634089,31.1234281 C13.9053119,35.7957062 10.9408626,41.1740812 9.56058826,47.3047505 C14.5138287,43.5897332 18.3379603,41.1435541 21.0998368,39.9379122 C24.7547558,38.3424304 29.8855842,37.6347299 36.5390895,37.7503396 L38.75,37.7887558 L38.75,48.8610336 L59.1827844,30.0000018 L38.7914686,11.1776163 Z" id="Combined-Shape" fill="#FFFFFF"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
@@ -1898,6 +1898,31 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_manage_peer_no_forwards_about" = "Members won't be able to copy, save or forward content from this group.";
|
||||
"lng_manage_peer_no_forwards_about_channel" = "Subscribers won't be able to copy, save or forward content from this channel.";
|
||||
|
||||
"lng_disable_sharing" = "Disable Sharing";
|
||||
"lng_enable_sharing" = "Enable Sharing";
|
||||
"lng_disable_sharing_title" = "Disable Sharing";
|
||||
"lng_disable_sharing_no_forwarding" = "No Forwarding";
|
||||
"lng_disable_sharing_no_forwarding_about" = "Disable message forwarding to other chats.";
|
||||
"lng_disable_sharing_no_saving" = "No Saving";
|
||||
"lng_disable_sharing_no_saving_about" = "Disable copying texts and saving photos and videos to gallery.";
|
||||
"lng_disable_sharing_unlock" = "Unlock with Telegram Premium";
|
||||
"lng_disable_sharing_button" = "Disable Sharing";
|
||||
"lng_disable_sharing_toast" = "Sharing disabled for this chat.";
|
||||
"lng_enable_sharing_toast" = "Sharing enabled for this chat.";
|
||||
|
||||
"lng_action_no_forwards_you_disabled" = "You disabled sharing in this chat.";
|
||||
"lng_action_no_forwards_you_enabled" = "You enabled sharing in this chat.";
|
||||
"lng_action_no_forwards_disabled" = "{from} disabled sharing in this chat.";
|
||||
"lng_action_no_forwards_enabled" = "{from} enabled sharing in this chat.";
|
||||
"lng_action_no_forwards_still_disabled" = "Sharing in this chat is still disabled.";
|
||||
"lng_action_no_forwards_request" = "{from} would like to enable sharing in this chat, which includes:";
|
||||
"lng_action_no_forwards_request_you" = "You requested to enable sharing in this chat, which includes:";
|
||||
"lng_action_no_forwards_feature_forwarding" = "Forwarding messages";
|
||||
"lng_action_no_forwards_feature_saving" = "Saving photos and videos";
|
||||
"lng_action_no_forwards_feature_copying" = "Copying messages";
|
||||
"lng_action_no_forwards_accept" = "Accept";
|
||||
"lng_action_no_forwards_reject" = "Reject";
|
||||
|
||||
"lng_manage_peer_bot_public_link" = "Public Link";
|
||||
"lng_manage_peer_bot_public_links" = "Public Links";
|
||||
"lng_manage_peer_bot_balance" = "Balance";
|
||||
@@ -5005,7 +5030,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_context_noforwards_info_channel" = "Copying and forwarding is not allowed in this channel.";
|
||||
"lng_context_noforwards_info_group" = "Copying and forwarding is not allowed in this group.";
|
||||
"lng_context_noforwards_info_bot" = "Copying and forwarding is not allowed from this bot.";
|
||||
"lng_context_noforwards_info_user" = "Copying and forwarding is not allowed in this chat.";
|
||||
"lng_context_noforwards_info_his" = "{user} disabled copying and forwarding in this chat.";
|
||||
"lng_context_noforwards_info_mine" = "You disabled copying and forwarding in this chat.";
|
||||
|
||||
"lng_context_spoiler_effect" = "Hide with Spoiler";
|
||||
"lng_context_disable_spoiler" = "Remove Spoiler";
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
<file alias="ban.tgs">../../animations/ban.tgs</file>
|
||||
<file alias="cocoon.tgs">../../animations/cocoon.tgs</file>
|
||||
<file alias="craft_failed.tgs">../../animations/craft_failed.tgs</file>
|
||||
<file alias="stop.tgs">../../animations/stop.tgs</file>
|
||||
|
||||
<file alias="profile_muting.tgs">../../animations/profile/profile_muting.tgs</file>
|
||||
<file alias="profile_unmuting.tgs">../../animations/profile/profile_unmuting.tgs</file>
|
||||
|
||||
@@ -520,6 +520,40 @@ void ConfirmGiftSaleDecline(
|
||||
ShowGiftSaleRejectBox(window, item, suggestion);
|
||||
}
|
||||
|
||||
void RespondToNoForwardsRequest(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item,
|
||||
not_null<HistoryServiceNoForwardsRequest*> request,
|
||||
bool accept) {
|
||||
if (request->requestId) {
|
||||
return;
|
||||
}
|
||||
const auto id = item->fullId();
|
||||
const auto session = &item->history()->session();
|
||||
const auto peer = item->history()->peer;
|
||||
const auto msgId = item->id;
|
||||
const auto finish = [=] {
|
||||
if (const auto item = session->data().message(id)) {
|
||||
if (const auto r = item->Get<HistoryServiceNoForwardsRequest>()) {
|
||||
r->requestId = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
using Flag = MTPmessages_ToggleNoForwards::Flag;
|
||||
request->requestId = session->api().request(MTPmessages_ToggleNoForwards(
|
||||
MTP_flags(Flag::f_request_msg_id),
|
||||
peer->input(),
|
||||
MTP_bool(!accept),
|
||||
MTP_int(msgId)
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
session->api().applyUpdates(result);
|
||||
finish();
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
controller->showToast(error.type());
|
||||
finish();
|
||||
}).send();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::shared_ptr<ClickHandler> AcceptClickHandler(
|
||||
@@ -538,7 +572,11 @@ std::shared_ptr<ClickHandler> AcceptClickHandler(
|
||||
}
|
||||
const auto show = controller->uiShow();
|
||||
const auto suggestion = item->Get<HistoryMessageSuggestion>();
|
||||
if (!suggestion) {
|
||||
const auto nfRequest = item->Get<HistoryServiceNoForwardsRequest>();
|
||||
if (!suggestion && !nfRequest) {
|
||||
return;
|
||||
} else if (nfRequest) {
|
||||
RespondToNoForwardsRequest(controller, item, nfRequest, true);
|
||||
return;
|
||||
} else if (suggestion->gift) {
|
||||
ConfirmGiftSaleAccept(controller, item, suggestion);
|
||||
@@ -564,6 +602,11 @@ std::shared_ptr<ClickHandler> DeclineClickHandler(
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
const auto nfRequest = item->Get<HistoryServiceNoForwardsRequest>();
|
||||
if (nfRequest) {
|
||||
RespondToNoForwardsRequest(controller, item, nfRequest, false);
|
||||
return;
|
||||
}
|
||||
const auto suggestion = item->Get<HistoryMessageSuggestion>();
|
||||
if (suggestion && suggestion->gift) {
|
||||
ConfirmGiftSaleDecline(controller, item, suggestion);
|
||||
|
||||
@@ -2692,17 +2692,6 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||
_session->diceStickersPacks().apply(data);
|
||||
} break;
|
||||
|
||||
case mtpc_updatePeerHistoryNoForwards: {
|
||||
const auto &d = update.c_updatePeerHistoryNoForwards();
|
||||
const auto peerId = peerFromMTP(d.vpeer());
|
||||
if (const auto peer = session().data().peerLoaded(peerId)) {
|
||||
if (const auto user = peer->asUser()) {
|
||||
user->setNoForwardsFlags(
|
||||
d.is_my_enabled(),
|
||||
d.is_peer_enabled());
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1200,3 +1200,9 @@ futureOwnerBox: Box(defaultBox) {
|
||||
buttonHeight: 0px;
|
||||
}
|
||||
futureOwnerBoxSelect: collectibleBox;
|
||||
|
||||
disableSharingIconPadding: margins(12px, 12px, 12px, 8px);
|
||||
disableSharingButtonLock: IconEmoji {
|
||||
icon: icon {{ "emoji/premium_lock", activeButtonFg }};
|
||||
padding: margins(-2px, 1px, 0px, 0px);
|
||||
}
|
||||
|
||||
@@ -2745,9 +2745,12 @@ void Controller::saveForwards() {
|
||||
|| *_savingData.noForwards != _peer->allowsForwarding()) {
|
||||
return continueSave();
|
||||
}
|
||||
using Flag = MTPmessages_ToggleNoForwards::Flag;
|
||||
_api.request(MTPmessages_ToggleNoForwards(
|
||||
MTP_flags(Flag()),
|
||||
_peer->input(),
|
||||
MTP_bool(*_savingData.noForwards)
|
||||
MTP_bool(*_savingData.noForwards),
|
||||
MTPint()
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
_peer->session().api().applyUpdates(result);
|
||||
continueSave();
|
||||
|
||||
@@ -1858,6 +1858,15 @@ ServiceAction ParseServiceAction(
|
||||
auto content = ActionChangeCreator();
|
||||
content.newCreatorId = data.vnew_creator_id().v;
|
||||
result.content = content;
|
||||
}, [&](const MTPDmessageActionNoForwardsToggle &data) {
|
||||
auto content = ActionNoForwardsToggle();
|
||||
content.newValue = (data.vnew_value().type() == mtpc_boolTrue);
|
||||
result.content = content;
|
||||
}, [&](const MTPDmessageActionNoForwardsRequest &data) {
|
||||
auto content = ActionNoForwardsRequest();
|
||||
content.expired = data.is_expired();
|
||||
content.newValue = (data.vnew_value().type() == mtpc_boolTrue);
|
||||
result.content = content;
|
||||
}, [](const MTPDmessageActionEmpty &data) {});
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -738,6 +738,15 @@ struct ActionSuggestBirthday {
|
||||
Birthday birthday;
|
||||
};
|
||||
|
||||
struct ActionNoForwardsToggle {
|
||||
bool newValue = false;
|
||||
};
|
||||
|
||||
struct ActionNoForwardsRequest {
|
||||
bool expired = false;
|
||||
bool newValue = false;
|
||||
};
|
||||
|
||||
struct ActionNewCreatorPending {
|
||||
UserId newCreatorId = 0;
|
||||
};
|
||||
@@ -800,6 +809,8 @@ struct ServiceAction {
|
||||
ActionSuggestedPostSuccess,
|
||||
ActionSuggestedPostRefund,
|
||||
ActionSuggestBirthday,
|
||||
ActionNoForwardsToggle,
|
||||
ActionNoForwardsRequest,
|
||||
ActionNewCreatorPending,
|
||||
ActionChangeCreator> content;
|
||||
};
|
||||
|
||||
@@ -1553,6 +1553,14 @@ auto HtmlWriter::Wrap::pushMessage(
|
||||
}() + (data.birthday.year()
|
||||
? (' ' + QByteArray::number(data.birthday.year()))
|
||||
: QByteArray());
|
||||
}, [&](const ActionNoForwardsToggle &data) {
|
||||
return serviceFrom
|
||||
+ (data.newValue
|
||||
? " disabled sharing in this chat"
|
||||
: " enabled sharing in this chat");
|
||||
}, [&](const ActionNoForwardsRequest &data) {
|
||||
return serviceFrom
|
||||
+ " requested to enable sharing in this chat";
|
||||
}, [&](const ActionNewCreatorPending &data) {
|
||||
return peers.wrapUserName(data.newCreatorId)
|
||||
+ " will become the new main admin in 7 days if "
|
||||
|
||||
@@ -743,6 +743,15 @@ QByteArray SerializeMessage(
|
||||
if (const auto year = data.birthday.year()) {
|
||||
push("year", year);
|
||||
}
|
||||
}, [&](const ActionNoForwardsToggle &data) {
|
||||
pushActor();
|
||||
pushAction("no_forwards_toggle");
|
||||
push("new_value", data.newValue);
|
||||
}, [&](const ActionNoForwardsRequest &data) {
|
||||
pushActor();
|
||||
pushAction("no_forwards_request");
|
||||
push("expired", data.expired);
|
||||
push("new_value", data.newValue);
|
||||
}, [&](const ActionNewCreatorPending &data) {
|
||||
pushActor();
|
||||
pushAction("new_creator_pending");
|
||||
|
||||
@@ -1382,6 +1382,13 @@ void History::applyServiceChanges(
|
||||
peer->owner().notifyGiftAuctionGot({ data.vid().v, to });
|
||||
}, [](const auto &) {});
|
||||
}
|
||||
}, [&](const MTPDmessageActionNoForwardsToggle &data) {
|
||||
if (const auto user = peer->asUser()) {
|
||||
const auto enabled = mtpIsTrue(data.vnew_value());
|
||||
user->setNoForwardsFlags(
|
||||
enabled && item->out(),
|
||||
enabled && !item->out());
|
||||
}
|
||||
}, [](const auto &) {
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "storage/file_upload.h"
|
||||
#include "storage/storage_shared_media.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "menu/menu_ttl_validator.h"
|
||||
#include "apiwrap.h"
|
||||
@@ -4946,6 +4947,29 @@ void HistoryItem::createServiceFromMtp(const MTPDmessageService &message) {
|
||||
? SuggestRefundType::Expired
|
||||
: SuggestRefundType::User;
|
||||
finish->price = CreditsAmountFromTL(data.vprice());
|
||||
} else if (type == mtpc_messageActionNoForwardsRequest) {
|
||||
const auto &data = action.c_messageActionNoForwardsRequest();
|
||||
const auto expired = data.is_expired();
|
||||
const auto period = _history->session().appConfig()
|
||||
.noForwardsRequestExpirePeriod();
|
||||
const auto expiresAt = TimeId(_date + period);
|
||||
const auto isExpired = expired
|
||||
|| (expiresAt <= base::unixtime::now());
|
||||
auto mask = HistoryServiceNoForwardsRequest::Bit();
|
||||
const auto actions = (!isExpired && !out())
|
||||
? SuggestionActions::NoForwardsRequest
|
||||
: SuggestionActions::None;
|
||||
if (actions != SuggestionActions::None) {
|
||||
mask |= HistoryMessageReplyMarkup::Bit();
|
||||
}
|
||||
UpdateComponents(mask);
|
||||
const auto request = Get<HistoryServiceNoForwardsRequest>();
|
||||
request->expired = isExpired;
|
||||
request->expiresAt = expiresAt;
|
||||
if (actions != SuggestionActions::None) {
|
||||
const auto markup = Get<HistoryMessageReplyMarkup>();
|
||||
markup->updateSuggestControls(actions);
|
||||
}
|
||||
}
|
||||
if (const auto replyTo = message.vreply_to()) {
|
||||
replyTo->match([&](const MTPDmessageReplyHeader &data) {
|
||||
@@ -6654,6 +6678,50 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
||||
return result;
|
||||
};
|
||||
|
||||
auto prepareNoForwardsToggle = [this](const MTPDmessageActionNoForwardsToggle &action) {
|
||||
auto result = PreparedServiceText();
|
||||
const auto enabled = mtpIsTrue(action.vnew_value());
|
||||
const auto prevEnabled = mtpIsTrue(action.vprev_value());
|
||||
if (enabled == prevEnabled) {
|
||||
result.text = tr::lng_action_no_forwards_still_disabled(
|
||||
tr::now,
|
||||
tr::marked);
|
||||
} else if (out()) {
|
||||
result.text = (enabled
|
||||
? tr::lng_action_no_forwards_you_disabled
|
||||
: tr::lng_action_no_forwards_you_enabled)(
|
||||
tr::now,
|
||||
tr::marked);
|
||||
} else {
|
||||
result.links.push_back(fromLink());
|
||||
result.text = (enabled
|
||||
? tr::lng_action_no_forwards_disabled
|
||||
: tr::lng_action_no_forwards_enabled)(
|
||||
tr::now,
|
||||
lt_from,
|
||||
fromLinkText(),
|
||||
tr::marked);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
auto prepareNoForwardsRequest = [this](const MTPDmessageActionNoForwardsRequest &action) {
|
||||
auto result = PreparedServiceText();
|
||||
if (_from->isSelf()) {
|
||||
result.text = tr::lng_action_no_forwards_request_you(
|
||||
tr::now,
|
||||
tr::marked);
|
||||
} else {
|
||||
result.links.push_back(fromLink());
|
||||
result.text = tr::lng_action_no_forwards_request(
|
||||
tr::now,
|
||||
lt_from,
|
||||
fromLinkText(),
|
||||
tr::marked);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
setServiceText(action.match(
|
||||
prepareChatAddUserText,
|
||||
prepareChatJoinedByLink,
|
||||
@@ -6715,14 +6783,15 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
||||
prepareStarGiftPurchaseOfferDeclined,
|
||||
prepareNewCreatorPending,
|
||||
prepareChangeCreator,
|
||||
prepareNoForwardsToggle,
|
||||
prepareNoForwardsRequest,
|
||||
PrepareEmptyText<MTPDmessageActionRequestedPeerSentMe>,
|
||||
PrepareErrorText<MTPDmessageActionEmpty>));
|
||||
|
||||
// Additional information.
|
||||
applyAction(action);
|
||||
processAction(action);
|
||||
}
|
||||
|
||||
void HistoryItem::applyAction(const MTPMessageAction &action) {
|
||||
void HistoryItem::processAction(const MTPMessageAction &action) {
|
||||
action.match([&](const MTPDmessageActionChatAddUser &data) {
|
||||
if (const auto channel = _history->peer->asMegagroup()) {
|
||||
const auto selfUserId = _history->session().userId();
|
||||
|
||||
@@ -683,7 +683,7 @@ private:
|
||||
void setReactions(const MTPMessageReactions *reactions);
|
||||
[[nodiscard]] bool changeReactions(const MTPMessageReactions *reactions);
|
||||
void setServiceMessageByAction(const MTPmessageAction &action);
|
||||
void applyAction(const MTPMessageAction &action);
|
||||
void processAction(const MTPMessageAction &action);
|
||||
void refreshMedia(const MTPMessageMedia *media);
|
||||
void refreshSentMedia(const MTPMessageMedia *media);
|
||||
void createServiceFromMtp(const MTPDmessage &message);
|
||||
|
||||
@@ -1284,7 +1284,8 @@ bool HistoryMessageReplyMarkup::hiddenBy(Data::Media *media) const {
|
||||
void HistoryMessageReplyMarkup::updateSuggestControls(
|
||||
SuggestionActions actions) {
|
||||
if (actions == SuggestionActions::AcceptAndDecline
|
||||
|| actions == SuggestionActions::GiftOfferActions) {
|
||||
|| actions == SuggestionActions::GiftOfferActions
|
||||
|| actions == SuggestionActions::NoForwardsRequest) {
|
||||
data.flags |= ReplyMarkupFlag::SuggestionAccept;
|
||||
} else {
|
||||
data.flags &= ~ReplyMarkupFlag::SuggestionAccept;
|
||||
@@ -1320,6 +1321,19 @@ void HistoryMessageReplyMarkup::updateSuggestControls(
|
||||
Visual(),
|
||||
},
|
||||
});
|
||||
} else if (actions == SuggestionActions::NoForwardsRequest) {
|
||||
data.rows.push_back({
|
||||
{
|
||||
Type::SuggestDecline,
|
||||
tr::lng_action_no_forwards_reject(tr::now),
|
||||
Visual(),
|
||||
},
|
||||
{
|
||||
Type::SuggestAccept,
|
||||
tr::lng_action_no_forwards_accept(tr::now),
|
||||
Visual(),
|
||||
},
|
||||
});
|
||||
} else if (actions == SuggestionActions::AcceptAndDecline) {
|
||||
// ... rows ...
|
||||
// [decline] | [accept]
|
||||
|
||||
@@ -63,6 +63,7 @@ enum class SuggestionActions : uchar {
|
||||
Decline,
|
||||
AcceptAndDecline,
|
||||
GiftOfferActions,
|
||||
NoForwardsRequest,
|
||||
};
|
||||
|
||||
struct HistoryMessageVia : RuntimeComponent<HistoryMessageVia, HistoryItem> {
|
||||
@@ -738,6 +739,13 @@ struct HistoryServiceSuggestFinish
|
||||
SuggestRefundType refundType = SuggestRefundType::None;
|
||||
};
|
||||
|
||||
struct HistoryServiceNoForwardsRequest
|
||||
: RuntimeComponent<HistoryServiceNoForwardsRequest, HistoryItem> {
|
||||
TimeId expiresAt = 0;
|
||||
mtpRequestId requestId = 0;
|
||||
bool expired = false;
|
||||
};
|
||||
|
||||
struct HistoryServiceGameScore
|
||||
: RuntimeComponent<HistoryServiceGameScore, HistoryItem>
|
||||
, HistoryServiceDependentData {
|
||||
|
||||
@@ -2048,25 +2048,30 @@ void AddSelectRestrictionAction(
|
||||
if (addIcon && !menu->empty()) {
|
||||
menu->addSeparator();
|
||||
}
|
||||
const auto user = peer->asUser();
|
||||
auto button = base::make_unique_q<Ui::Menu::MultilineAction>(
|
||||
menu->menu(),
|
||||
menu->st().menu,
|
||||
st::historyHasCustomEmoji,
|
||||
addIcon
|
||||
((addIcon && !user)
|
||||
? st::historySponsoredAboutMenuLabelPosition
|
||||
: st::historyHasCustomEmojiPosition,
|
||||
: st::historyHasCustomEmojiPosition),
|
||||
(peer->isMegagroup()
|
||||
? tr::lng_context_noforwards_info_group
|
||||
? tr::lng_context_noforwards_info_group(tr::now, tr::rich)
|
||||
: (peer->isChannel())
|
||||
? tr::lng_context_noforwards_info_channel
|
||||
: (peer->isUser() && peer->asUser()->isBot())
|
||||
? tr::lng_context_noforwards_info_bot
|
||||
: peer->isUser()
|
||||
? tr::lng_context_noforwards_info_user
|
||||
: tr::lng_context_noforwards_info_channel)(
|
||||
tr::now,
|
||||
tr::rich),
|
||||
addIcon ? &st::menuIconCopyright : nullptr);
|
||||
? tr::lng_context_noforwards_info_channel(tr::now, tr::rich)
|
||||
: (user && user->isBot())
|
||||
? tr::lng_context_noforwards_info_bot(tr::now, tr::rich)
|
||||
: user
|
||||
? ((user->flags() & UserDataFlag::NoForwardsMyEnabled)
|
||||
? tr::lng_context_noforwards_info_mine(tr::now, tr::rich)
|
||||
: tr::lng_context_noforwards_info_his(
|
||||
tr::now,
|
||||
lt_user,
|
||||
tr::bold(user->shortName()),
|
||||
tr::rich))
|
||||
: tr::lng_context_noforwards_info_channel(tr::now, tr::rich)),
|
||||
(addIcon && !user) ? &st::menuIconCopyright : nullptr);
|
||||
button->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
menu->addAction(std::move(button));
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/view/media/history_view_sticker.h"
|
||||
#include "history/view/media/history_view_large_emoji.h"
|
||||
#include "history/view/media/history_view_custom_emoji.h"
|
||||
#include "history/view/media/history_view_no_forwards_request.h"
|
||||
#include "history/view/media/history_view_suggest_decision.h"
|
||||
#include "history/view/reactions/history_view_reactions_button.h"
|
||||
#include "history/view/reactions/history_view_reactions.h"
|
||||
@@ -1508,6 +1509,15 @@ void Element::refreshMedia(Element *replacing) {
|
||||
this,
|
||||
std::make_unique<LargeEmoji>(this, emoji));
|
||||
}
|
||||
} else if (const auto nfr = item->Get<HistoryServiceNoForwardsRequest>()) {
|
||||
_media = std::make_unique<MediaGeneric>(
|
||||
this,
|
||||
GenerateNoForwardsRequestMedia(this, nfr),
|
||||
MediaGenericDescriptor{
|
||||
.maxWidth = st::chatSuggestInfoWidth,
|
||||
.service = true,
|
||||
.hideServiceText = true,
|
||||
});
|
||||
} else if (const auto decision = item->Get<HistoryServiceSuggestDecision>()) {
|
||||
_media = std::make_unique<MediaGeneric>(
|
||||
this,
|
||||
|
||||
@@ -123,11 +123,17 @@ void MediaGeneric::draw(Painter &p, const PaintContext &context) const {
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(context.st->msgServiceBg());
|
||||
const auto rect = QRect(0, 0, width(), height());
|
||||
p.drawRoundedRect(rect, radius, radius);
|
||||
//if (context.selected()) {
|
||||
// p.setBrush(context.st->serviceTextPalette().selectBg);
|
||||
// p.drawRoundedRect(rect, radius, radius);
|
||||
//}
|
||||
if (parent()->data()->inlineReplyKeyboard()) {
|
||||
const auto half = rect.height() / 2;
|
||||
p.setClipRect(rect - QMargins(0, 0, 0, half));
|
||||
p.drawRoundedRect(rect, radius, radius);
|
||||
p.setClipRect(rect - QMargins(0, rect.height() - half, 0, 0));
|
||||
const auto small = Ui::BubbleRadiusSmall();
|
||||
p.drawRoundedRect(rect, small, small);
|
||||
p.setClipping(false);
|
||||
} else {
|
||||
p.drawRoundedRect(rect, radius, radius);
|
||||
}
|
||||
}
|
||||
|
||||
auto translated = 0;
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "history/view/media/history_view_no_forwards_request.h"
|
||||
|
||||
#include "data/data_peer.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "history/view/media/history_view_media_generic.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "styles/style_chat.h"
|
||||
|
||||
namespace HistoryView {
|
||||
namespace {
|
||||
|
||||
class BulletPointPart final : public MediaGenericTextPart {
|
||||
public:
|
||||
BulletPointPart(
|
||||
TextWithEntities text,
|
||||
QMargins margins);
|
||||
|
||||
void draw(
|
||||
Painter &p,
|
||||
not_null<const MediaGeneric*> owner,
|
||||
const PaintContext &context,
|
||||
int outerWidth) const override;
|
||||
|
||||
private:
|
||||
int _bulletLeft = 0;
|
||||
int _bulletTop = 0;
|
||||
|
||||
};
|
||||
|
||||
BulletPointPart::BulletPointPart(
|
||||
TextWithEntities text,
|
||||
QMargins margins)
|
||||
: MediaGenericTextPart(
|
||||
std::move(text),
|
||||
QMargins(
|
||||
margins.left() + st::chatSuggestBulletLeftExtra + st::historyGroupAboutBulletSkip,
|
||||
margins.top(),
|
||||
margins.right(),
|
||||
margins.bottom()),
|
||||
st::serviceTextStyle,
|
||||
{},
|
||||
{},
|
||||
style::al_left)
|
||||
, _bulletLeft(margins.left() + st::chatSuggestBulletLeftExtra)
|
||||
, _bulletTop(margins.top()) {
|
||||
}
|
||||
|
||||
void BulletPointPart::draw(
|
||||
Painter &p,
|
||||
not_null<const MediaGeneric*> owner,
|
||||
const PaintContext &context,
|
||||
int outerWidth) const {
|
||||
MediaGenericTextPart::draw(p, owner, context, outerWidth);
|
||||
|
||||
const auto &font = st::serviceTextStyle.font;
|
||||
const auto size = st::mediaUnreadSize;
|
||||
const auto top = _bulletTop + (font->height - size) / 2;
|
||||
|
||||
p.setBrush(context.st->msgServiceFg());
|
||||
|
||||
PainterHighQualityEnabler hq(p);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawEllipse(_bulletLeft, top, size, size);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
auto GenerateNoForwardsRequestMedia(
|
||||
not_null<Element*> parent,
|
||||
not_null<const HistoryServiceNoForwardsRequest*> request)
|
||||
-> Fn<void(
|
||||
not_null<MediaGeneric*>,
|
||||
Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
||||
return [=](
|
||||
not_null<MediaGeneric*> media,
|
||||
Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
||||
const auto item = parent->data();
|
||||
const auto from = item->from();
|
||||
|
||||
auto pushText = [&](
|
||||
TextWithEntities text,
|
||||
QMargins margins,
|
||||
style::align align = style::al_left) {
|
||||
push(std::make_unique<MediaGenericTextPart>(
|
||||
std::move(text),
|
||||
margins,
|
||||
st::serviceTextStyle,
|
||||
base::flat_map<uint16, ClickHandlerPtr>(),
|
||||
Ui::Text::MarkedContext(),
|
||||
align));
|
||||
};
|
||||
|
||||
pushText(
|
||||
(from->isSelf()
|
||||
? tr::lng_action_no_forwards_request_you(
|
||||
tr::now,
|
||||
tr::marked)
|
||||
: tr::lng_action_no_forwards_request(
|
||||
tr::now,
|
||||
lt_from,
|
||||
tr::bold(from->shortName()),
|
||||
tr::marked)),
|
||||
st::chatSuggestInfoTitleMargin,
|
||||
style::al_top);
|
||||
|
||||
const auto features = {
|
||||
tr::lng_action_no_forwards_feature_forwarding(tr::now),
|
||||
tr::lng_action_no_forwards_feature_saving(tr::now),
|
||||
tr::lng_action_no_forwards_feature_copying(tr::now),
|
||||
};
|
||||
auto isLast = false;
|
||||
auto index = 0;
|
||||
const auto count = int(features.size());
|
||||
for (const auto &feature : features) {
|
||||
isLast = (++index == count);
|
||||
push(std::make_unique<BulletPointPart>(
|
||||
TextWithEntities{ feature },
|
||||
isLast
|
||||
? st::chatSuggestInfoLastMargin
|
||||
: st::chatSuggestInfoMiddleMargin));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
struct HistoryServiceNoForwardsRequest;
|
||||
|
||||
namespace HistoryView {
|
||||
|
||||
class Element;
|
||||
class MediaGeneric;
|
||||
class MediaGenericPart;
|
||||
|
||||
auto GenerateNoForwardsRequestMedia(
|
||||
not_null<Element*> parent,
|
||||
not_null<const HistoryServiceNoForwardsRequest*> request
|
||||
) -> Fn<void(
|
||||
not_null<MediaGeneric*>,
|
||||
Fn<void(std::unique_ptr<MediaGenericPart>)>)>;
|
||||
|
||||
} // namespace HistoryView
|
||||
@@ -66,6 +66,12 @@ int AppConfig::stargiftConvertPeriodMax() const {
|
||||
_account->mtp().isTestMode() ? 300 : (90 * 86400));
|
||||
}
|
||||
|
||||
int AppConfig::noForwardsRequestExpirePeriod() const {
|
||||
return get<int>(
|
||||
u"no_forwards_request_expire_period"_q,
|
||||
_account->mtp().isTestMode() ? 300 : 86400);
|
||||
}
|
||||
|
||||
const std::vector<QString> &AppConfig::startRefPrefixes() {
|
||||
if (_startRefPrefixes.empty()) {
|
||||
_startRefPrefixes = get<std::vector<QString>>(
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
|
||||
[[nodiscard]] int quoteLengthMax() const;
|
||||
[[nodiscard]] int stargiftConvertPeriodMax() const;
|
||||
[[nodiscard]] int noForwardsRequestExpirePeriod() const;
|
||||
|
||||
[[nodiscard]] const std::vector<QString> &startRefPrefixes();
|
||||
[[nodiscard]] bool starrefSetupAllowed() const;
|
||||
|
||||
@@ -68,6 +68,7 @@ QByteArray SessionSettings::serialize() const {
|
||||
size += sizeof(qint32); // _setupEmailState
|
||||
size += sizeof(qint32) // _moderateCommonGroups size
|
||||
+ (_moderateCommonGroups.size() * sizeof(qint32));
|
||||
size += sizeof(qint32);
|
||||
|
||||
auto result = QByteArray();
|
||||
result.reserve(size);
|
||||
@@ -153,6 +154,7 @@ QByteArray SessionSettings::serialize() const {
|
||||
for (const auto &filterId : _moderateCommonGroups) {
|
||||
stream << qint32(filterId);
|
||||
}
|
||||
stream << qint32(_disableSharingBoxShowsCount);
|
||||
}
|
||||
|
||||
Ensures(result.size() == size);
|
||||
@@ -226,6 +228,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||
std::vector<Data::UnreviewedAuth> unreviewed;
|
||||
qint32 setupEmailState = 0;
|
||||
std::vector<int32> moderateCommonGroups;
|
||||
qint32 disableSharingBoxShowsCount = 0;
|
||||
|
||||
stream >> versionTag;
|
||||
if (versionTag == kVersionTag) {
|
||||
@@ -659,6 +662,9 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> disableSharingBoxShowsCount;
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for SessionSettings::addFromSerialized()"));
|
||||
@@ -723,6 +729,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||
}
|
||||
|
||||
_moderateCommonGroups = std::move(moderateCommonGroups);
|
||||
_disableSharingBoxShowsCount = disableSharingBoxShowsCount;
|
||||
|
||||
if (version < 2) {
|
||||
app.setLastSeenWarningSeen(appLastSeenWarningSeen == 1);
|
||||
@@ -881,6 +888,20 @@ void SessionSettings::incrementPhotoEditorHintShown() {
|
||||
}
|
||||
}
|
||||
|
||||
bool SessionSettings::shouldShowDisableSharingBox() const {
|
||||
return _disableSharingBoxShowsCount < kDisableSharingBoxMaxShowsCount;
|
||||
}
|
||||
|
||||
void SessionSettings::incrementDisableSharingBoxShown() {
|
||||
if (shouldShowDisableSharingBox()) {
|
||||
_disableSharingBoxShowsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
void SessionSettings::resetDisableSharingBoxShown() {
|
||||
_disableSharingBoxShowsCount = 0;
|
||||
}
|
||||
|
||||
std::vector<TimeId> SessionSettings::mutePeriods() const {
|
||||
return _mutePeriods;
|
||||
}
|
||||
|
||||
@@ -137,6 +137,10 @@ public:
|
||||
[[nodiscard]] bool photoEditorHintShown() const;
|
||||
void incrementPhotoEditorHintShown();
|
||||
|
||||
[[nodiscard]] bool shouldShowDisableSharingBox() const;
|
||||
void incrementDisableSharingBoxShown();
|
||||
void resetDisableSharingBoxShown();
|
||||
|
||||
[[nodiscard]] std::vector<TimeId> mutePeriods() const;
|
||||
void addMutePeriod(TimeId period);
|
||||
|
||||
@@ -186,6 +190,7 @@ public:
|
||||
private:
|
||||
static constexpr auto kDefaultSupportChatsLimitSlice = 7 * 24 * 60 * 60;
|
||||
static constexpr auto kPhotoEditorHintMaxShowsCount = 5;
|
||||
static constexpr auto kDisableSharingBoxMaxShowsCount = 3;
|
||||
|
||||
struct ThreadId {
|
||||
PeerId peerId;
|
||||
@@ -211,6 +216,7 @@ private:
|
||||
base::flat_map<ThreadId, ushort> _ringtoneVolumes;
|
||||
bool _dialogsFiltersEnabled = false;
|
||||
int _photoEditorHintShowsCount = 0;
|
||||
int _disableSharingBoxShowsCount = 0;
|
||||
std::vector<TimeId> _mutePeriods;
|
||||
TimeId _lastNonPremiumLimitDownload = 0;
|
||||
TimeId _lastNonPremiumLimitUpload = 0;
|
||||
|
||||
@@ -33,7 +33,7 @@ inputMediaUploadedPhoto#1e287d04 flags:# spoiler:flags.2?true file:InputFile sti
|
||||
inputMediaPhoto#b3ba0635 flags:# spoiler:flags.1?true id:InputPhoto ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia;
|
||||
inputMediaContact#f8ab7dfb phone_number:string first_name:string last_name:string vcard:string = InputMedia;
|
||||
inputMediaUploadedDocument#37c9330 flags:# nosound_video:flags.3?true force_file:flags.4?true spoiler:flags.5?true live_photo:flags.8?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector<DocumentAttribute> stickers:flags.0?Vector<InputDocument> video_cover:flags.6?InputPhoto video_timestamp:flags.7?int ttl_seconds:flags.1?int = InputMedia;
|
||||
inputMediaUploadedDocument#37c9330 flags:# nosound_video:flags.3?true force_file:flags.4?true spoiler:flags.5?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector<DocumentAttribute> stickers:flags.0?Vector<InputDocument> video_cover:flags.6?InputPhoto video_timestamp:flags.7?int ttl_seconds:flags.1?int = InputMedia;
|
||||
inputMediaDocument#a8763ab5 flags:# spoiler:flags.2?true id:InputDocument video_cover:flags.3?InputPhoto video_timestamp:flags.4?int ttl_seconds:flags.0?int query:flags.1?string = InputMedia;
|
||||
inputMediaVenue#c13d1c11 geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string = InputMedia;
|
||||
inputMediaPhotoExternal#e5bbfe1a flags:# spoiler:flags.1?true url:string ttl_seconds:flags.0?int = InputMedia;
|
||||
@@ -126,7 +126,7 @@ messageMediaPhoto#695150d7 flags:# spoiler:flags.3?true photo:flags.0?Photo ttl_
|
||||
messageMediaGeo#56e0d474 geo:GeoPoint = MessageMedia;
|
||||
messageMediaContact#70322949 phone_number:string first_name:string last_name:string vcard:string user_id:long = MessageMedia;
|
||||
messageMediaUnsupported#9f84f49e = MessageMedia;
|
||||
messageMediaDocument#52d8ccd9 flags:# nopremium:flags.3?true spoiler:flags.4?true video:flags.6?true round:flags.7?true voice:flags.8?true live_photo:flags.11?true document:flags.0?Document alt_documents:flags.5?Vector<Document> video_cover:flags.9?Photo video_timestamp:flags.10?int ttl_seconds:flags.2?int = MessageMedia;
|
||||
messageMediaDocument#52d8ccd9 flags:# nopremium:flags.3?true spoiler:flags.4?true video:flags.6?true round:flags.7?true voice:flags.8?true document:flags.0?Document alt_documents:flags.5?Vector<Document> video_cover:flags.9?Photo video_timestamp:flags.10?int ttl_seconds:flags.2?int = MessageMedia;
|
||||
messageMediaWebPage#ddf10c3b flags:# force_large_media:flags.0?true force_small_media:flags.1?true manual:flags.3?true safe:flags.4?true webpage:WebPage = MessageMedia;
|
||||
messageMediaVenue#2ec0533f geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string = MessageMedia;
|
||||
messageMediaGame#fdb19008 game:Game = MessageMedia;
|
||||
@@ -203,6 +203,8 @@ messageActionStarGiftPurchaseOffer#774278d4 flags:# accepted:flags.0?true declin
|
||||
messageActionStarGiftPurchaseOfferDeclined#73ada76b flags:# expired:flags.0?true gift:StarGift price:StarsAmount = MessageAction;
|
||||
messageActionNewCreatorPending#b07ed085 new_creator_id:long = MessageAction;
|
||||
messageActionChangeCreator#e188503b new_creator_id:long = MessageAction;
|
||||
messageActionNoForwardsToggle#bf7d6572 prev_value:Bool new_value:Bool = MessageAction;
|
||||
messageActionNoForwardsRequest#3e2793ba flags:# expired:flags.0?true prev_value:Bool new_value:Bool = MessageAction;
|
||||
|
||||
dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog;
|
||||
dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog;
|
||||
@@ -457,7 +459,6 @@ updateStarGiftAuctionState#48e246c2 gift_id:long state:StarGiftAuctionState = Up
|
||||
updateStarGiftAuctionUserState#dc58f31e gift_id:long user_state:StarGiftAuctionUserState = Update;
|
||||
updateEmojiGameInfo#fb9c547a info:messages.EmojiGameInfo = Update;
|
||||
updateStarGiftCraftFail#ac072444 = Update;
|
||||
updatePeerHistoryNoForwards#5736b39a flags:# my_enabled:flags.0?true peer_enabled:flags.1?true peer:Peer = Update;
|
||||
updateChatParticipantRank#bd8367b9 chat_id:long user_id:long rank:string version:int = Update;
|
||||
|
||||
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
|
||||
@@ -2475,7 +2476,7 @@ messages.getSearchResultsCalendar#6aa3f6bd flags:# peer:InputPeer saved_peer_id:
|
||||
messages.getSearchResultsPositions#9c7f2f10 flags:# peer:InputPeer saved_peer_id:flags.2?InputPeer filter:MessagesFilter offset_id:int limit:int = messages.SearchResultsPositions;
|
||||
messages.hideChatJoinRequest#7fe7e815 flags:# approved:flags.0?true peer:InputPeer user_id:InputUser = Updates;
|
||||
messages.hideAllChatJoinRequests#e085f4ea flags:# approved:flags.0?true peer:InputPeer link:flags.1?string = Updates;
|
||||
messages.toggleNoForwards#b11eafa2 peer:InputPeer enabled:Bool = Updates;
|
||||
messages.toggleNoForwards#b2081a35 flags:# peer:InputPeer enabled:Bool request_msg_id:flags.0?int = Updates;
|
||||
messages.saveDefaultSendAs#ccfddf96 peer:InputPeer send_as:InputPeer = Bool;
|
||||
messages.sendReaction#d30d78d4 flags:# big:flags.1?true add_to_recent:flags.2?true peer:InputPeer msg_id:int reaction:flags.0?Vector<Reaction> = Updates;
|
||||
messages.getMessagesReactions#8bba90e6 peer:InputPeer id:Vector<int> = Updates;
|
||||
|
||||
@@ -1100,6 +1100,7 @@ chatSuggestInfoWidth: 272px;
|
||||
chatSuggestInfoTitleMargin: margins(16px, 16px, 16px, 6px);
|
||||
chatSuggestInfoMiddleMargin: margins(16px, 4px, 16px, 4px);
|
||||
chatSuggestInfoLastMargin: margins(16px, 4px, 16px, 16px);
|
||||
chatSuggestBulletLeftExtra: 16px;
|
||||
chatSuggestTableMiddleMargin: margins(8px, 4px, 8px, 4px);
|
||||
chatSuggestTableLastMargin: margins(8px, 4px, 8px, 16px);
|
||||
chatSuggestInfoFullMargin: margins(16px, 16px, 16px, 16px);
|
||||
|
||||
@@ -204,6 +204,9 @@ menuIconCraftChance: icon{{ "menu/craft_chance-24x24", menuIconColor }};
|
||||
menuIconCraft: icon{{ "menu/craft_start-24x24", menuIconColor }};
|
||||
menuIconTagAdd: icon{{ "menu/tag_add-24x24", menuIconColor }};
|
||||
menuIconTagEdit: icon{{ "menu/tag_edit-24x24", menuIconColor }};
|
||||
menuIconDownloadOff: icon {{ "menu/download_off-24x24", menuIconColor }};
|
||||
menuIconShareOff: icon {{ "menu/share_off-24x24", menuIconColor }};
|
||||
menuIconShareOn: icon {{ "menu/share_on-24x24", menuIconColor }};
|
||||
|
||||
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
||||
menuIconTTLAnyTextPosition: point(11px, 22px);
|
||||
|
||||
@@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "api/api_chat_participants.h"
|
||||
#include "api/api_global_privacy.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "lottie/lottie_icon.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "base/random.h"
|
||||
#include "base/options.h"
|
||||
@@ -57,6 +58,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/delayed_activation.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "ui/controls/feature_list.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "main/main_session.h"
|
||||
@@ -79,6 +81,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "settings/sections/settings_advanced.h"
|
||||
#include "settings/sections/settings_premium.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "support/support_helper.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "info/info_memento.h"
|
||||
@@ -105,6 +109,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_saved_sublist.h"
|
||||
#include "data/data_histories.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "dialogs/dialogs_key.h"
|
||||
#include "core/application.h"
|
||||
#include "core/ui_integration.h"
|
||||
@@ -118,6 +123,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_window.h" // st::windowMinWidth
|
||||
#include "styles/style_menu_icons.h"
|
||||
#include "styles/style_premium.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QtWidgets/QApplication>
|
||||
@@ -304,6 +311,7 @@ private:
|
||||
void addCreatePoll();
|
||||
void addCreateTodoList();
|
||||
void addThemeEdit();
|
||||
void addToggleNoForwards();
|
||||
void addBlockUser();
|
||||
void addViewDiscussion();
|
||||
void addDirectMessages();
|
||||
@@ -1340,6 +1348,141 @@ void Filler::addThemeEdit() {
|
||||
&st::menuIconChangeColors);
|
||||
}
|
||||
|
||||
void ShowDisableSharingBox(
|
||||
not_null<SessionController*> controller,
|
||||
not_null<PeerData*> peer,
|
||||
Fn<void(bool)> toggleNoForwards) {
|
||||
controller->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
box->setStyle(st::showOrBox);
|
||||
box->setWidth(st::boxWideWidth);
|
||||
box->addTopButton(st::boxTitleClose, [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
|
||||
const auto buttonPadding = QMargins(
|
||||
st::showOrBox.buttonPadding.left(),
|
||||
0,
|
||||
st::showOrBox.buttonPadding.right(),
|
||||
0);
|
||||
|
||||
auto icon = Settings::CreateLottieIcon(
|
||||
box,
|
||||
{
|
||||
.name = u"stop"_q,
|
||||
.sizeOverride = st::normalBoxLottieSize,
|
||||
},
|
||||
{});
|
||||
box->verticalLayout()->add(
|
||||
std::move(icon.widget),
|
||||
st::disableSharingIconPadding,
|
||||
style::al_top);
|
||||
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
tr::lng_disable_sharing_title(),
|
||||
st::boostCenteredTitle),
|
||||
QMargins(0, 0, 0, st::showOrTitleIconMargin) + buttonPadding,
|
||||
style::al_top);
|
||||
|
||||
const auto features = std::vector<Ui::FeatureListEntry>{
|
||||
{
|
||||
st::menuIconShareOff,
|
||||
tr::lng_disable_sharing_no_forwarding(tr::now),
|
||||
{ tr::lng_disable_sharing_no_forwarding_about(tr::now) },
|
||||
},
|
||||
{
|
||||
st::menuIconDownloadOff,
|
||||
tr::lng_disable_sharing_no_saving(tr::now),
|
||||
{ tr::lng_disable_sharing_no_saving_about(tr::now) },
|
||||
},
|
||||
};
|
||||
for (const auto &feature : features) {
|
||||
box->addRow(
|
||||
Ui::MakeFeatureListEntry(box, feature),
|
||||
st::boxRowPadding);
|
||||
}
|
||||
|
||||
const auto button = box->addButton(rpl::single(QString()), [=] {
|
||||
if (peer->session().premium()) {
|
||||
toggleNoForwards(true);
|
||||
box->closeBox();
|
||||
} else {
|
||||
Settings::ShowPremium(controller, u"no_forwards"_q);
|
||||
}
|
||||
});
|
||||
button->setText(
|
||||
Data::AmPremiumValue(&peer->session())
|
||||
| rpl::map([](bool premium) {
|
||||
if (premium) {
|
||||
return TextWithEntities{
|
||||
tr::lng_disable_sharing_button(tr::now) };
|
||||
}
|
||||
return Ui::Text::IconEmoji(
|
||||
&st::disableSharingButtonLock
|
||||
).append(
|
||||
' ' + tr::lng_disable_sharing_unlock(tr::now));
|
||||
}));
|
||||
|
||||
box->setShowFinishedCallback([animate = std::move(icon.animate)] {
|
||||
animate(anim::repeat::once);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
void Filler::addToggleNoForwards() {
|
||||
const auto user = _peer->asUser();
|
||||
if (!user || user->isInaccessible() || user->isBot() || user->isSelf()) {
|
||||
return;
|
||||
}
|
||||
const auto controller = _controller;
|
||||
const auto peer = _peer;
|
||||
const auto toggleNoForwards = [=](bool enabled) {
|
||||
using Flag = MTPmessages_ToggleNoForwards::Flag;
|
||||
peer->session().api().request(MTPmessages_ToggleNoForwards(
|
||||
MTP_flags(Flag()),
|
||||
peer->input(),
|
||||
MTP_bool(enabled),
|
||||
MTPint()
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
peer->session().api().applyUpdates(result);
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
if (error.type() != u"CHAT_NOT_MODIFIED"_q) {
|
||||
controller->showToast(error.type());
|
||||
}
|
||||
}).send();
|
||||
};
|
||||
const auto disabledNow = !user->allowsForwarding();
|
||||
_addAction(disabledNow
|
||||
? tr::lng_enable_sharing(tr::now)
|
||||
: tr::lng_disable_sharing(tr::now), [=] {
|
||||
if (controller->showFrozenError()) {
|
||||
return;
|
||||
} else if (disabledNow) {
|
||||
toggleNoForwards(false);
|
||||
return;
|
||||
}
|
||||
auto &settings = peer->session().settings();
|
||||
if (!settings.shouldShowDisableSharingBox()) {
|
||||
#ifdef _DEBUG
|
||||
settings.resetDisableSharingBoxShown();
|
||||
peer->session().saveSettingsDelayed();
|
||||
#endif
|
||||
if (peer->session().premium()) {
|
||||
toggleNoForwards(true);
|
||||
} else {
|
||||
Settings::ShowPremium(controller, u"no_forwards"_q);
|
||||
}
|
||||
return;
|
||||
}
|
||||
settings.incrementDisableSharingBoxShown();
|
||||
peer->session().saveSettingsDelayed();
|
||||
ShowDisableSharingBox(controller, peer, toggleNoForwards);
|
||||
}, disabledNow ? &st::menuIconShareOn : &st::menuIconShareOff);
|
||||
}
|
||||
|
||||
void Filler::addTTLSubmenu(bool addSeparator) {
|
||||
if (_thread->asTopic() || !_peer || _peer->isMonoforum()) {
|
||||
return; // #TODO later forum
|
||||
@@ -1596,6 +1739,7 @@ void Filler::fillHistoryActions() {
|
||||
addCreatePoll();
|
||||
addCreateTodoList();
|
||||
addThemeEdit();
|
||||
addToggleNoForwards();
|
||||
addViewDiscussion();
|
||||
addDirectMessages();
|
||||
addExportChat();
|
||||
@@ -1625,6 +1769,7 @@ void Filler::fillProfileActions() {
|
||||
addViewDiscussion();
|
||||
addDirectMessages();
|
||||
addExportChat();
|
||||
addToggleNoForwards();
|
||||
addToggleFolder();
|
||||
addBlockUser();
|
||||
addReport();
|
||||
|
||||
Reference in New Issue
Block a user