Update API scheme on layer 158.

This commit is contained in:
John Preston 2023-04-03 11:58:30 +04:00
parent 6be2fb9790
commit 312aa4b130
24 changed files with 198 additions and 127 deletions

View File

@ -1523,6 +1523,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_action_attach_menu_bot_allowed" = "You allowed this bot to message you when you added it in the attachment menu.";
"lng_action_set_wallpaper_me" = "You set a new background for this chat.";
"lng_action_set_wallpaper" = "{user} set a new background for this chat.";
"lng_action_set_same_wallpaper_me" = "You set {background} for this chat.";
"lng_action_set_same_wallpaper" = "{user} set {background} for this chat.";
"lng_action_set_same_background" = "the same background";
"lng_action_topic_created_inside" = "Topic created";
"lng_action_topic_closed_inside" = "Topic closed";
"lng_action_topic_reopened_inside" = "Topic reopened";
@ -3577,8 +3580,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_filters_link_private_status" = "you can't share private chats";
"lng_filters_link_private_error" = "Private chats can't be shared.";
"lng_filters_link_noadmin_status" = "you can't invite others here";
"lng_filters_link_noadmin_group_error" = "You don't have the admin rights to share invite links to this group chat.";
"lng_filters_link_noadmin_channel_error" = "You don't have the admin rights to share invite links to this channel.";
"lng_filters_link_noadmin_group_error" = "You don't have the admin rights to share invite links to this private group chat.";
"lng_filters_link_noadmin_channel_error" = "You don't have the admin rights to share invite links to this private channel.";
"lng_filters_link_already_group" = "you are already a member";
"lng_filters_link_already_channel" = "you are already subscribed";
"lng_filters_link_chats_about" = "Select groups and channels that you want everyone who adds the folder via invite link to join.";
@ -3587,6 +3590,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_filters_link_chats_no_about" = "You can only share groups and channels in which you are allowed to create invite links.";
"lng_filters_link_name_it" = "Name Link";
"lng_filters_link_delete_sure" = "Are you sure you want to delete this link?";
"lng_filters_link_qr_about" = "Everyone on Telegram can scan this code to add this folder and join the chats included in this invite link.";
"lng_filters_by_link_title" = "Add Folder";
"lng_filters_by_link_sure" = "Do you want to add a new chat folder {folder} and join its groups and channels?";
"lng_filters_by_link_join#one" = "{count} chat to join";
@ -3603,7 +3607,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_filters_by_link_in#one" = "{count} chat in this folder";
"lng_filters_by_link_in#other" = "{count} chats in this folder";
"lng_filters_by_link_remove" = "Remove Folder";
"lng_filters_by_link_remove_sure" = "Do you want to quit the chats you joined when added the folder {folder}?";
"lng_filters_by_link_remove_sure" = "Do you also want to quit the chats included in the folder {folder}?";
"lng_filters_by_link_quit#one" = "{count} chat to quit";
"lng_filters_by_link_quit#other" = "{count} chats to quit";
"lng_filters_by_link_select" = "Select All";
@ -3619,7 +3623,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_filters_updated_also#other" = "You have joined {count} new chats.";
"lng_filters_bar_you_can#one" = "You can join {count} new chat";
"lng_filters_bar_you_can#other" = "You can join {count} new chats";
"lng_filters_bar_view" = "Click here to view them";
"lng_filters_bar_view#one" = "Click here to view it";
"lng_filters_bar_view#other" = "Click here to view them";
"lng_chat_theme_change" = "Change colors";
"lng_chat_theme_none" = "No\nTheme";

View File

@ -197,6 +197,7 @@ messageActionTopicEdit#c0944820 flags:# title:flags.0?string icon_emoji_id:flags
messageActionSuggestProfilePhoto#57de635e photo:Photo = MessageAction;
messageActionRequestedPeer#fe77345d button_id:int peer:Peer = MessageAction;
messageActionSetChatWallPaper#bc44a927 wallpaper:WallPaper = MessageAction;
messageActionSetSameChatWallPaper#da54583a = MessageAction;
dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?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;
@ -386,7 +387,7 @@ updateGroupCallParticipants#f2ebdb4e call:InputGroupCall participants:Vector<Gro
updateGroupCall#14b24500 chat_id:long call:GroupCall = Update;
updatePeerHistoryTTL#bb9bb9a5 flags:# peer:Peer ttl_period:flags.0?int = Update;
updateChatParticipant#d087663a flags:# chat_id:long date:int actor_id:long user_id:long prev_participant:flags.0?ChatParticipant new_participant:flags.1?ChatParticipant invite:flags.2?ExportedChatInvite qts:int = Update;
updateChannelParticipant#985d3abb flags:# via_community:flags.3?true channel_id:long date:int actor_id:long user_id:long prev_participant:flags.0?ChannelParticipant new_participant:flags.1?ChannelParticipant invite:flags.2?ExportedChatInvite qts:int = Update;
updateChannelParticipant#985d3abb flags:# via_chatlist:flags.3?true channel_id:long date:int actor_id:long user_id:long prev_participant:flags.0?ChannelParticipant new_participant:flags.1?ChannelParticipant invite:flags.2?ExportedChatInvite qts:int = Update;
updateBotStopped#c4870a49 user_id:long date:int stopped:Bool qts:int = Update;
updateGroupCallConnection#b783982 flags:# presentation:flags.0?true params:DataJSON = Update;
updateBotCommands#4d712f2e peer:Peer bot_id:long commands:Vector<BotCommand> = Update;
@ -960,7 +961,7 @@ channelAdminLogEventActionDiscardGroupCall#db9f9140 call:InputGroupCall = Channe
channelAdminLogEventActionParticipantMute#f92424d2 participant:GroupCallParticipant = ChannelAdminLogEventAction;
channelAdminLogEventActionParticipantUnmute#e64429c0 participant:GroupCallParticipant = ChannelAdminLogEventAction;
channelAdminLogEventActionToggleGroupCallSetting#56d6a247 join_muted:Bool = ChannelAdminLogEventAction;
channelAdminLogEventActionParticipantJoinByInvite#fe9fc158 flags:# via_community:flags.0?true invite:ExportedChatInvite = ChannelAdminLogEventAction;
channelAdminLogEventActionParticipantJoinByInvite#fe9fc158 flags:# via_chatlist:flags.0?true invite:ExportedChatInvite = ChannelAdminLogEventAction;
channelAdminLogEventActionExportedInviteDelete#5a50fca4 invite:ExportedChatInvite = ChannelAdminLogEventAction;
channelAdminLogEventActionExportedInviteRevoke#410a134e invite:ExportedChatInvite = ChannelAdminLogEventAction;
channelAdminLogEventActionExportedInviteEdit#e90ebb59 prev_invite:ExportedChatInvite new_invite:ExportedChatInvite = ChannelAdminLogEventAction;
@ -1228,7 +1229,7 @@ payments.bankCardData#3e24e573 title:string open_urls:Vector<BankCardOpenUrl> =
dialogFilter#7438f7e8 flags:# contacts:flags.0?true non_contacts:flags.1?true groups:flags.2?true broadcasts:flags.3?true bots:flags.4?true exclude_muted:flags.11?true exclude_read:flags.12?true exclude_archived:flags.13?true id:int title:string emoticon:flags.25?string pinned_peers:Vector<InputPeer> include_peers:Vector<InputPeer> exclude_peers:Vector<InputPeer> = DialogFilter;
dialogFilterDefault#363293ae = DialogFilter;
dialogFilterCommunity#d8565037 flags:# id:int title:string emoticon:flags.25?string pinned_peers:Vector<InputPeer> include_peers:Vector<InputPeer> = DialogFilter;
dialogFilterChatlist#d64a04a8 flags:# has_my_invites:flags.26?true id:int title:string emoticon:flags.25?string pinned_peers:Vector<InputPeer> include_peers:Vector<InputPeer> = DialogFilter;
dialogFilterSuggested#77744d4a filter:DialogFilter description:string = DialogFilterSuggested;
@ -1307,7 +1308,7 @@ messages.historyImportParsed#5e0fb7b9 flags:# pm:flags.0?true group:flags.1?true
messages.affectedFoundMessages#ef8d3e6c pts:int pts_count:int offset:int messages:Vector<int> = messages.AffectedFoundMessages;
chatInviteImporter#8c5adfd9 flags:# requested:flags.0?true via_community:flags.3?true user_id:long date:int about:flags.2?string approved_by:flags.1?long = ChatInviteImporter;
chatInviteImporter#8c5adfd9 flags:# requested:flags.0?true via_chatlist:flags.3?true user_id:long date:int about:flags.2?string approved_by:flags.1?long = ChatInviteImporter;
messages.exportedChatInvites#bdc62dcc count:int invites:Vector<ExportedChatInvite> users:Vector<User> = messages.ExportedChatInvites;
@ -1526,18 +1527,18 @@ inlineBotWebView#b57295d5 text:string url:string = InlineBotWebView;
readParticipantDate#4a4ff172 user_id:long date:int = ReadParticipantDate;
inputCommunityDialogFilter#1ae107a1 filter_id:int = InputCommunity;
inputChatlistDialogFilter#f3e0da33 filter_id:int = InputChatlist;
exportedCommunityInvite#ebddc1aa flags:# title:string url:string peers:Vector<Peer> = ExportedCommunityInvite;
exportedChatlistInvite#c5181ac flags:# title:string url:string peers:Vector<Peer> = ExportedChatlistInvite;
communities.exportedCommunityInvite#6b97a8ea filter:DialogFilter invite:ExportedCommunityInvite = communities.ExportedCommunityInvite;
chatlists.exportedChatlistInvite#10e6e3a6 filter:DialogFilter invite:ExportedChatlistInvite = chatlists.ExportedChatlistInvite;
communities.exportedInvites#ffd75fa7 invites:Vector<ExportedCommunityInvite> chats:Vector<Chat> users:Vector<User> = communities.ExportedInvites;
chatlists.exportedInvites#10ab6dc7 invites:Vector<ExportedChatlistInvite> chats:Vector<Chat> users:Vector<User> = chatlists.ExportedInvites;
communities.communityInviteAlready#c745ee07 filter_id:int missing_peers:Vector<Peer> already_peers:Vector<Peer> chats:Vector<Chat> users:Vector<User> = communities.CommunityInvite;
communities.communityInvite#3857da1 flags:# title:string emoticon:flags.0?string peers:Vector<Peer> chats:Vector<Chat> users:Vector<User> = communities.CommunityInvite;
chatlists.chatlistInviteAlready#fa87f659 filter_id:int missing_peers:Vector<Peer> already_peers:Vector<Peer> chats:Vector<Chat> users:Vector<User> = chatlists.ChatlistInvite;
chatlists.chatlistInvite#1dcd839d flags:# title:string emoticon:flags.0?string peers:Vector<Peer> chats:Vector<Chat> users:Vector<User> = chatlists.ChatlistInvite;
communities.communityUpdates#e74660b3 missing_peers:Vector<Peer> chats:Vector<Chat> users:Vector<User> = communities.CommunityUpdates;
chatlists.chatlistUpdates#93bd878d missing_peers:Vector<Peer> chats:Vector<Chat> users:Vector<User> = chatlists.ChatlistUpdates;
bots.botInfo#e8a775b0 name:string about:string description:string = bots.BotInfo;
@ -1623,7 +1624,7 @@ account.getContactSignUpNotification#9f07c728 = Bool;
account.setContactSignUpNotification#cff43f61 silent:Bool = Bool;
account.getNotifyExceptions#53577479 flags:# compare_sound:flags.1?true peer:flags.0?InputNotifyPeer = Updates;
account.getWallPaper#fc8ddbea wallpaper:InputWallPaper = WallPaper;
account.uploadWallPaper#dd853661 file:InputFile mime_type:string settings:WallPaperSettings = WallPaper;
account.uploadWallPaper#e39a8f03 flags:# for_chat:flags.0?true file:InputFile mime_type:string settings:WallPaperSettings = WallPaper;
account.saveWallPaper#6c5a5b37 wallpaper:InputWallPaper unsave:Bool settings:WallPaperSettings = Bool;
account.installWallPaper#feed5769 wallpaper:InputWallPaper settings:WallPaperSettings = Bool;
account.resetWallPapers#bb3b9804 = Bool;
@ -1877,7 +1878,7 @@ messages.searchCustomEmoji#2c11c0d7 emoticon:string hash:long = EmojiList;
messages.togglePeerTranslations#e47cb579 flags:# disabled:flags.0?true peer:InputPeer = Bool;
messages.getBotApp#34fdc5c3 app:InputBotApp hash:long = messages.BotApp;
messages.requestAppWebView#8c5a3b3c flags:# write_allowed:flags.0?true peer:InputPeer app:InputBotApp start_param:flags.1?string theme_params:flags.2?DataJSON platform:string = AppWebViewResult;
messages.setChatWallPaper#bddd7eaa peer:InputPeer wallpaper:InputWallPaper settings:WallPaperSettings = Updates;
messages.setChatWallPaper#dbaaba25 flags:# peer:InputPeer wallpaper:flags.0?InputWallPaper settings:flags.0?WallPaperSettings id:flags.1?int = Updates;
updates.getState#edd4882a = updates.State;
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
@ -2061,16 +2062,16 @@ stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel
stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats;
communities.exportCommunityInvite#41fe69d9 community:InputCommunity title:string peers:Vector<InputPeer> = communities.ExportedCommunityInvite;
communities.deleteExportedInvite#f96e4616 community:InputCommunity slug:string = Bool;
communities.editExportedInvite#27140512 flags:# community:InputCommunity slug:string title:flags.1?string peers:flags.2?Vector<InputPeer> = ExportedCommunityInvite;
communities.getExportedInvites#4688a39d community:InputCommunity = communities.ExportedInvites;
communities.checkCommunityInvite#99ba9e5 slug:string = communities.CommunityInvite;
communities.joinCommunityInvite#4eff927 slug:string peers:Vector<InputPeer> = Updates;
communities.getCommunityUpdates#2956d635 community:InputCommunity = communities.CommunityUpdates;
communities.joinCommunityUpdates#51d42216 community:InputCommunity peers:Vector<InputPeer> = Updates;
communities.hideCommunityUpdates#d678baf community:InputCommunity = Bool;
communities.getLeaveCommunitySuggestions#ee4e9ae2 community:InputCommunity = Vector<Peer>;
communities.leaveCommunity#35d9755f community:InputCommunity peers:Vector<InputPeer> = Updates;
chatlists.exportChatlistInvite#8472478e chatlist:InputChatlist title:string peers:Vector<InputPeer> = chatlists.ExportedChatlistInvite;
chatlists.deleteExportedInvite#719c5c5e chatlist:InputChatlist slug:string = Bool;
chatlists.editExportedInvite#653db63d flags:# chatlist:InputChatlist slug:string title:flags.1?string peers:flags.2?Vector<InputPeer> = ExportedChatlistInvite;
chatlists.getExportedInvites#ce03da83 chatlist:InputChatlist = chatlists.ExportedInvites;
chatlists.checkChatlistInvite#41c10fff slug:string = chatlists.ChatlistInvite;
chatlists.joinChatlistInvite#a6b1e39a slug:string peers:Vector<InputPeer> = Updates;
chatlists.getChatlistUpdates#89419521 chatlist:InputChatlist = chatlists.ChatlistUpdates;
chatlists.joinChatlistUpdates#e089f8f5 chatlist:InputChatlist peers:Vector<InputPeer> = Updates;
chatlists.hideChatlistUpdates#66e486fb chatlist:InputChatlist = Bool;
chatlists.getLeaveChatlistSuggestions#fdbcd714 chatlist:InputChatlist = Vector<Peer>;
chatlists.leaveChatlist#74fae13a chatlist:InputChatlist peers:Vector<InputPeer> = Updates;
// LAYER 158

View File

@ -216,7 +216,7 @@ void ImportInvite(
auto inputs = peers | ranges::views::transform([](auto peer) {
return MTPInputPeer(peer->input);
}) | ranges::to<QVector>();
api->request(MTPcommunities_JoinCommunityInvite(
api->request(MTPchatlists_JoinChatlistInvite(
MTP_string(slug),
MTP_vector<MTPInputPeer>(std::move(inputs))
)).done(callback).fail(error).send();
@ -527,7 +527,7 @@ void CheckFilterInvite(
const auto session = &controller->session();
const auto weak = base::make_weak(controller);
session->api().checkFilterInvite(slug, [=](
const MTPcommunities_CommunityInvite &result) {
const MTPchatlists_ChatlistInvite &result) {
const auto strong = weak.get();
if (!strong) {
return;
@ -550,11 +550,11 @@ void CheckFilterInvite(
}
return result;
};
result.match([&](const MTPDcommunities_communityInvite &data) {
result.match([&](const MTPDchatlists_chatlistInvite &data) {
title = qs(data.vtitle());
iconEmoji = data.vemoticon().value_or_empty();
peers = parseList(data.vpeers());
}, [&](const MTPDcommunities_communityInviteAlready &data) {
}, [&](const MTPDchatlists_chatlistInviteAlready &data) {
filterId = data.vfilter_id().v;
peers = parseList(data.vmissing_peers());
already = parseList(data.valready_peers());

View File

@ -58,7 +58,7 @@ JoinedByLinkSlice ParseJoinedByLinkSlice(
result.users.push_back({
.user = owner.user(data.vuser_id()),
.date = data.vdate().v,
.viaFilterLink = data.is_via_community(),
.viaFilterLink = data.is_via_chatlist(),
});
});
}

View File

@ -382,11 +382,11 @@ void ApiWrap::checkChatInvite(
void ApiWrap::checkFilterInvite(
const QString &slug,
FnMut<void(const MTPcommunities_CommunityInvite &)> done,
FnMut<void(const MTPchatlists_ChatlistInvite &)> done,
Fn<void(const MTP::Error &)> fail) {
request(base::take(_checkFilterInviteRequestId)).cancel();
_checkFilterInviteRequestId = request(
MTPcommunities_CheckCommunityInvite(MTP_string(slug))
MTPchatlists_CheckChatlistInvite(MTP_string(slug))
).done(std::move(done)).fail(std::move(fail)).send();
}

View File

@ -204,7 +204,7 @@ public:
Fn<void(const MTP::Error &)> fail);
void checkFilterInvite(
const QString &slug,
FnMut<void(const MTPcommunities_CommunityInvite &)> done,
FnMut<void(const MTPchatlists_ChatlistInvite &)> done,
Fn<void(const MTP::Error &)> fail);
void processFullPeer(

View File

@ -554,19 +554,19 @@ void EditFilterBox(
rpl::variable<Data::ChatFilter> rules;
rpl::variable<std::vector<Data::ChatFilterLink>> links;
rpl::variable<bool> hasLinks;
rpl::variable<bool> community;
rpl::variable<bool> chatlist;
};
const auto owner = &window->session().data();
const auto state = box->lifetime().make_state<State>(State{
.rules = filter,
.community = filter.community(),
.chatlist = filter.chatlist(),
});
state->links = owner->chatsFilters().communityLinks(filter.id()),
state->links = owner->chatsFilters().chatlistLinks(filter.id()),
state->hasLinks = state->links.value() | rpl::map([=](const auto &v) {
return !v.empty();
});
if (!state->community.current()) {
state->community = state->hasLinks.value() | rpl::filter(
if (!state->chatlist.current()) {
state->chatlist = state->hasLinks.value() | rpl::filter(
_1
) | rpl::take(1);
}
@ -657,7 +657,7 @@ void EditFilterBox(
content,
object_ptr<Ui::VerticalLayout>(content))
)->setDuration(0);
excludeWrap->toggleOn(state->community.value() | rpl::map(!_1));
excludeWrap->toggleOn(state->chatlist.value() | rpl::map(!_1));
const auto excludeInner = excludeWrap->entity();
AddSubsectionTitle(excludeInner, tr::lng_filters_exclude());
@ -717,8 +717,8 @@ void EditFilterBox(
content->resizeToWidth(content->widthNoMargins());
}, content->lifetime());
if (filter.community()) {
window->session().data().chatsFilters().reloadCommunityLinks(
if (filter.chatlist()) {
window->session().data().chatsFilters().reloadChatlistLinks(
filter.id());
}
@ -763,13 +763,13 @@ void EditFilterBox(
// Comparison of ChatFilter-s don't take id into account!
data->force_assign(updated);
const auto id = updated.id();
state->links = owner->chatsFilters().communityLinks(id);
state->links = owner->chatsFilters().chatlistLinks(id);
ExportFilterLink(id, shared, [=](Data::ChatFilterLink link) {
Expects(link.id == id);
window->show(ShowLinkBox(window, updated, link));
}, [=](QString error) {
if (error == "COMMUNITIES_TOO_MUCH") {
if (error == "CHATLISTS_TOO_MUCH") {
// #TODO filters
} else {
window->show(ShowLinkBox(window, updated, { .id = id }));
@ -799,7 +799,7 @@ void EditFilterBox(
EditExceptions(
window,
box,
kTypes | (state->community.current() ? Flag::Community : Flag()),
kTypes | (state->chatlist.current() ? Flag::Chatlist : Flag()),
data,
updateDefaultTitle,
refreshPreviews);

View File

@ -343,10 +343,10 @@ EditFilterChatsListController::EditFilterChatsListController(
, _session(session)
, _title(std::move(title))
, _peers(peers)
, _options(options & ~Flag::Community)
, _options(options & ~Flag::Chatlist)
, _selected(selected)
, _limit(Limit(session))
, _community(options & Flag::Community) {
, _chatlist(options & Flag::Chatlist) {
}
Main::Session &EditFilterChatsListController::session() const {
@ -354,9 +354,9 @@ Main::Session &EditFilterChatsListController::session() const {
}
int EditFilterChatsListController::selectedTypesCount() const {
Expects(_community || _typesDelegate != nullptr);
Expects(_chatlist || _typesDelegate != nullptr);
if (_community) {
if (_chatlist) {
return 0;
}
auto result = 0;
@ -400,7 +400,7 @@ bool EditFilterChatsListController::handleDeselectForeignRow(
void EditFilterChatsListController::prepareViewHook() {
delegate()->peerListSetTitle(std::move(_title));
if (!_community) {
if (!_chatlist) {
delegate()->peerListSetAboveWidget(prepareTypesList());
}

View File

@ -75,7 +75,7 @@ private:
Flags _options;
Flags _selected;
int _limit = 0;
bool _community = false;
bool _chatlist = false;
Fn<void(PeerListRowId)> _deselectOption;

View File

@ -606,7 +606,7 @@ void LinkController::addLinkBlock(not_null<Ui::VerticalLayout*> container) {
});
const auto getLinkQr = crl::guard(weak, [=] {
delegate()->peerListShowBox(
InviteLinkQrBox(link),
InviteLinkQrBox(link, tr::lng_filters_link_qr_about()),
Ui::LayerOption::KeepOther);
});
const auto editLink = crl::guard(weak, [=] {
@ -885,7 +885,7 @@ base::unique_qptr<Ui::PopupMenu> LinksController::createRowContextMenu(
};
const auto getLinkQr = [=] {
delegate()->peerListShowBox(
InviteLinkQrBox(link),
InviteLinkQrBox(link, tr::lng_filters_link_qr_about()),
Ui::LayerOption::KeepOther);
};
const auto editLink = [=] {
@ -1040,7 +1040,7 @@ bool GoodForExportFilterLink(
not_null<Window::SessionController*> window,
const Data::ChatFilter &filter) {
using Flag = Data::ChatFilter::Flag;
if (!filter.never().empty() || (filter.flags() & ~Flag::Community)) {
if (!filter.never().empty() || (filter.flags() & ~Flag::Chatlist)) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(window).toastParent(),
.text = { tr::lng_filters_link_cant(tr::now) },
@ -1062,11 +1062,11 @@ void ExportFilterLink(
auto mtpPeers = peers | ranges::views::transform(
[](not_null<PeerData*> peer) { return MTPInputPeer(peer->input); }
) | ranges::to<QVector>();
session->api().request(MTPcommunities_ExportCommunityInvite(
MTP_inputCommunityDialogFilter(MTP_int(id)),
session->api().request(MTPchatlists_ExportChatlistInvite(
MTP_inputChatlistDialogFilter(MTP_int(id)),
MTP_string(), // title
MTP_vector<MTPInputPeer>(std::move(mtpPeers))
)).done([=](const MTPcommunities_ExportedCommunityInvite &result) {
)).done([=](const MTPchatlists_ExportedChatlistInvite &result) {
const auto &data = result.data();
session->data().chatsFilters().apply(MTP_updateDialogFilter(
MTP_flags(MTPDupdateDialogFilter::Flag::f_filter),
@ -1094,13 +1094,13 @@ void EditLinkChats(
auto mtpPeers = peers | ranges::views::transform(
[](not_null<PeerData*> peer) { return MTPInputPeer(peer->input); }
) | ranges::to<QVector>();
session->api().request(MTPcommunities_EditExportedInvite(
MTP_flags(MTPcommunities_EditExportedInvite::Flag::f_peers),
MTP_inputCommunityDialogFilter(MTP_int(link.id)),
session->api().request(MTPchatlists_EditExportedInvite(
MTP_flags(MTPchatlists_EditExportedInvite::Flag::f_peers),
MTP_inputChatlistDialogFilter(MTP_int(link.id)),
MTP_string(link.url),
MTPstring(), // title
MTP_vector<MTPInputPeer>(std::move(mtpPeers))
)).done([=](const MTPExportedCommunityInvite &result) {
)).done([=](const MTPExportedChatlistInvite &result) {
const auto &data = result.data();
const auto link = session->data().chatsFilters().add(id, result);
//done(link);

View File

@ -274,6 +274,7 @@ QImage QrForShare(const QString &text) {
void QrBox(
not_null<Ui::GenericBox*> box,
const QString &link,
rpl::producer<QString> about,
Fn<void(QImage, std::shared_ptr<Ui::BoxShow>)> share) {
box->setTitle(tr::lng_group_invite_qr_title());
@ -307,7 +308,7 @@ void QrBox(
box->addRow(
object_ptr<Ui::FlatLabel>(
box,
tr::lng_group_invite_qr_about(),
std::move(about),
st::boxLabel),
st::inviteLinkQrValuePadding);
@ -354,7 +355,7 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
});
const auto getLinkQr = crl::guard(weak, [=] {
delegate()->peerListShowBox(
InviteLinkQrBox(link),
InviteLinkQrBox(link, tr::lng_group_invite_qr_about()),
Ui::LayerOption::KeepOther);
});
const auto revokeLink = crl::guard(weak, [=] {
@ -973,7 +974,9 @@ void AddPermanentLinkBlock(
const auto getLinkQr = crl::guard(weak, [=] {
if (const auto current = value->current(); !current.link.isEmpty()) {
show->showBox(
InviteLinkQrBox(current.link),
InviteLinkQrBox(
current.link,
tr::lng_group_invite_qr_about()),
Ui::LayerOption::KeepOther);
}
});
@ -1224,8 +1227,10 @@ object_ptr<Ui::BoxContent> ShareInviteLinkBox(
return object;
}
object_ptr<Ui::BoxContent> InviteLinkQrBox(const QString &link) {
return Box(QrBox, link, [=](
object_ptr<Ui::BoxContent> InviteLinkQrBox(
const QString &link,
rpl::producer<QString> about) {
return Box(QrBox, link, std::move(about), [=](
const QImage &image,
std::shared_ptr<Ui::BoxShow> show) {
auto mime = std::make_unique<QMimeData>();

View File

@ -45,7 +45,9 @@ void CopyInviteLink(not_null<QWidget*> toastParent, const QString &link);
[[nodiscard]] object_ptr<Ui::BoxContent> ShareInviteLinkBox(
not_null<Main::Session*> session,
const QString &link);
[[nodiscard]] object_ptr<Ui::BoxContent> InviteLinkQrBox(const QString &link);
[[nodiscard]] object_ptr<Ui::BoxContent> InviteLinkQrBox(
const QString &link,
rpl::producer<QString> about);
[[nodiscard]] object_ptr<Ui::BoxContent> RevokeLinkBox(
not_null<PeerData*> peer,
not_null<UserData*> admin,

View File

@ -594,7 +594,7 @@ base::unique_qptr<Ui::PopupMenu> LinksController::createRowContextMenu(
}, &st::menuIconShare);
result->addAction(tr::lng_group_invite_context_qr(tr::now), [=] {
delegate()->peerListShowBox(
InviteLinkQrBox(link),
InviteLinkQrBox(link, tr::lng_group_invite_qr_about()),
Ui::LayerOption::KeepOther);
}, &st::menuIconQrCode);
result->addAction(tr::lng_group_invite_context_edit(tr::now), [=] {

View File

@ -109,7 +109,7 @@ ChatFilter ChatFilter::FromTL(
{ never.begin(), never.end() });
}, [](const MTPDdialogFilterDefault &d) {
return ChatFilter();
}, [&](const MTPDdialogFilterCommunity &data) {
}, [&](const MTPDdialogFilterChatlist &data) {
auto &&to_histories = ranges::views::transform([&](
const MTPInputPeer &data) {
const auto peer = data.match([&](const MTPDinputPeerUser &data) {
@ -148,7 +148,7 @@ ChatFilter ChatFilter::FromTL(
data.vid().v,
qs(data.vtitle()),
qs(data.vemoticon().value_or_empty()),
Flag::Community,
Flag::Chatlist,
std::move(list),
std::move(pinned),
{});
@ -174,10 +174,10 @@ MTPDialogFilter ChatFilter::tl(FilterId replaceId) const {
for (const auto &history : always) {
include.push_back(history->peer->input);
}
if (_flags & Flag::Community) {
using TLFlag = MTPDdialogFilterCommunity::Flag;
if (_flags & Flag::Chatlist) {
using TLFlag = MTPDdialogFilterChatlist::Flag;
const auto flags = TLFlag::f_emoticon;
return MTP_dialogFilterCommunity(
return MTP_dialogFilterChatlist(
MTP_flags(flags),
MTP_int(replaceId ? replaceId : _id),
MTP_string(_title),
@ -228,8 +228,8 @@ ChatFilter::Flags ChatFilter::flags() const {
return _flags;
}
bool ChatFilter::community() const {
return _flags & Flag::Community;
bool ChatFilter::chatlist() const {
return _flags & Flag::Chatlist;
}
const base::flat_set<not_null<History*>> &ChatFilter::always() const {
@ -410,15 +410,15 @@ void ChatFilters::apply(const MTPUpdate &update) {
ChatFilterLink ChatFilters::add(
FilterId id,
const MTPExportedCommunityInvite &update) {
const MTPExportedChatlistInvite &update) {
const auto i = ranges::find(_list, id, &ChatFilter::id);
if (i == end(_list) || !i->community()) {
if (i == end(_list) || !i->chatlist()) {
LOG(("Api Error: "
"Attempt to add community link to a non-community filter: %1"
"Attempt to add chatlist link to a non-chatlist filter: %1"
).arg(id));
return {};
}
auto &links = _communityLinks[id];
auto &links = _chatlistLinks[id];
const auto &data = update.data();
const auto url = qs(data.vurl());
const auto title = qs(data.vtitle());
@ -431,7 +431,7 @@ ChatFilterLink ChatFilters::add(
if (j->title != title || j->chats != chats) {
j->title = title;
j->chats = std::move(chats);
_communityLinksUpdated.fire_copy(id);
_chatlistLinksUpdated.fire_copy(id);
}
return *j;
}
@ -441,7 +441,7 @@ ChatFilterLink ChatFilters::add(
.title = title,
.chats = std::move(chats),
});
_communityLinksUpdated.fire_copy(id);
_chatlistLinksUpdated.fire_copy(id);
return links.back();
}
@ -449,19 +449,19 @@ void ChatFilters::edit(
FilterId id,
const QString &url,
const QString &title) {
auto &links = _communityLinks[id];
auto &links = _chatlistLinks[id];
const auto i = ranges::find(links, url, &ChatFilterLink::url);
if (i != end(links)) {
i->title = title;
_communityLinksUpdated.fire_copy(id);
_chatlistLinksUpdated.fire_copy(id);
_owner->session().api().request(MTPcommunities_EditExportedInvite(
MTP_flags(MTPcommunities_EditExportedInvite::Flag::f_title),
MTP_inputCommunityDialogFilter(MTP_int(id)),
_owner->session().api().request(MTPchatlists_EditExportedInvite(
MTP_flags(MTPchatlists_EditExportedInvite::Flag::f_title),
MTP_inputChatlistDialogFilter(MTP_int(id)),
MTP_string(url),
MTP_string(title),
MTPVector<MTPInputPeer>() // peers
)).done([=](const MTPExportedCommunityInvite &result) {
)).done([=](const MTPExportedChatlistInvite &result) {
//const auto &data = result.data();
//const auto link = _owner->chatsFilters().add(id, result);
//done(link);
@ -472,47 +472,47 @@ void ChatFilters::edit(
}
void ChatFilters::destroy(FilterId id, const QString &url) {
auto &links = _communityLinks[id];
auto &links = _chatlistLinks[id];
const auto i = ranges::find(links, url, &ChatFilterLink::url);
if (i != end(links)) {
links.erase(i);
_communityLinksUpdated.fire_copy(id);
_chatlistLinksUpdated.fire_copy(id);
const auto api = &_owner->session().api();
api->request(_linksRequestId).cancel();
_linksRequestId = api->request(MTPcommunities_DeleteExportedInvite(
MTP_inputCommunityDialogFilter(MTP_int(id)),
_linksRequestId = api->request(MTPchatlists_DeleteExportedInvite(
MTP_inputChatlistDialogFilter(MTP_int(id)),
MTP_string(url)
)).send();
}
}
rpl::producer<std::vector<ChatFilterLink>> ChatFilters::communityLinks(
rpl::producer<std::vector<ChatFilterLink>> ChatFilters::chatlistLinks(
FilterId id) const {
return _communityLinksUpdated.events_starting_with_copy(
return _chatlistLinksUpdated.events_starting_with_copy(
id
) | rpl::filter(rpl::mappers::_1 == id) | rpl::map([=] {
const auto i = _communityLinks.find(id);
return (i != end(_communityLinks))
const auto i = _chatlistLinks.find(id);
return (i != end(_chatlistLinks))
? i->second
: std::vector<ChatFilterLink>();
});
}
void ChatFilters::reloadCommunityLinks(FilterId id) {
void ChatFilters::reloadChatlistLinks(FilterId id) {
const auto api = &_owner->session().api();
api->request(_linksRequestId).cancel();
_linksRequestId = api->request(MTPcommunities_GetExportedInvites(
MTP_inputCommunityDialogFilter(MTP_int(id))
)).done([=](const MTPcommunities_ExportedInvites &result) {
_linksRequestId = api->request(MTPchatlists_GetExportedInvites(
MTP_inputChatlistDialogFilter(MTP_int(id))
)).done([=](const MTPchatlists_ExportedInvites &result) {
const auto &data = result.data();
_owner->processUsers(data.vusers());
_owner->processChats(data.vchats());
_communityLinks[id].clear();
_chatlistLinks[id].clear();
for (const auto &link : data.vinvites().v) {
add(id, link);
}
_communityLinksUpdated.fire_copy(id);
_chatlistLinksUpdated.fire_copy(id);
}).send();
}

View File

@ -32,7 +32,7 @@ public:
NoRead = (1 << 6),
NoArchived = (1 << 7),
Community = (1 << 8),
Chatlist = (1 << 8),
};
friend constexpr inline bool is_flag_type(Flag) { return true; };
using Flags = base::flags<Flag>;
@ -58,7 +58,7 @@ public:
[[nodiscard]] QString title() const;
[[nodiscard]] QString iconEmoji() const;
[[nodiscard]] Flags flags() const;
[[nodiscard]] bool community() const;
[[nodiscard]] bool chatlist() const;
[[nodiscard]] const base::flat_set<not_null<History*>> &always() const;
[[nodiscard]] const std::vector<not_null<History*>> &pinned() const;
[[nodiscard]] const base::flat_set<not_null<History*>> &never() const;
@ -149,15 +149,15 @@ public:
ChatFilterLink add(
FilterId id,
const MTPExportedCommunityInvite &update);
const MTPExportedChatlistInvite &update);
void edit(
FilterId id,
const QString &url,
const QString &title);
void destroy(FilterId id, const QString &url);
rpl::producer<std::vector<ChatFilterLink>> communityLinks(
rpl::producer<std::vector<ChatFilterLink>> chatlistLinks(
FilterId id) const;
void reloadCommunityLinks(FilterId id);
void reloadChatlistLinks(FilterId id);
private:
void load(bool force);
@ -186,8 +186,8 @@ private:
std::deque<FilterId> _exceptionsToLoad;
mtpRequestId _exceptionsLoadRequestId = 0;
base::flat_map<FilterId, std::vector<ChatFilterLink>> _communityLinks;
rpl::event_stream<FilterId> _communityLinksUpdated;
base::flat_map<FilterId, std::vector<ChatFilterLink>> _chatlistLinks;
rpl::event_stream<FilterId> _chatlistLinksUpdated;
mtpRequestId _linksRequestId = 0;
};

View File

@ -1186,6 +1186,8 @@ ServiceAction ParseServiceAction(
auto content = ActionSetChatWallPaper();
// #TODO wallpapers
result.content = content;
}, [&](const MTPDmessageActionSetSameChatWallPaper &data) {
result.content = ActionSetSameChatWallPaper();
}, [&](const MTPDmessageActionRequestedPeer &data) {
auto content = ActionRequestedPeer();
content.peerId = ParsePeerId(data.vpeer());

View File

@ -519,6 +519,9 @@ struct ActionSetChatWallPaper {
// #TODO wallpapers
};
struct ActionSetSameChatWallPaper {
};
struct ActionRequestedPeer {
PeerId peerId = 0;
int buttonId = 0;
@ -561,7 +564,8 @@ struct ServiceAction {
ActionTopicEdit,
ActionSuggestProfilePhoto,
ActionRequestedPeer,
ActionSetChatWallPaper> content;
ActionSetChatWallPaper,
ActionSetSameChatWallPaper> content;
};
ServiceAction ParseServiceAction(

View File

@ -1175,6 +1175,11 @@ auto HtmlWriter::Wrap::pushMessage(
return "requested: "_q/* + data.peerId*/;
}, [&](const ActionSetChatWallPaper &data) {
return serviceFrom + " set a new background for this chat";
}, [&](const ActionSetSameChatWallPaper &data) {
return serviceFrom
+ " set "
+ wrapReplyToLink("the same background")
+ " for this chat";
}, [](v::null_t) { return QByteArray(); });
if (!serviceText.isEmpty()) {

View File

@ -593,6 +593,10 @@ QByteArray SerializeMessage(
}, [&](const ActionSetChatWallPaper &data) {
pushActor();
pushAction("set_chat_wallpaper");
}, [&](const ActionSetSameChatWallPaper &data) {
pushActor();
pushAction("set_same_chat_wallpaper");
pushReplyToMsgId("message_id");
}, [](v::null_t) {});
if (v::is_null(message.action.content)) {

View File

@ -1392,7 +1392,7 @@ void GenerateItems(
const auto createParticipantJoinByInvite = [&](
const LogJoinByInvite &data) {
const auto text = data.is_via_community()
const auto text = data.is_via_chatlist()
? (channel->isMegagroup()
? tr::lng_admin_log_participant_joined_by_filter_link
: tr::lng_admin_log_participant_joined_by_filter_link_channel)

View File

@ -672,6 +672,8 @@ HistoryServiceDependentData *HistoryItem::GetServiceDependentData() {
return payment;
} else if (const auto info = Get<HistoryServiceTopicInfo>()) {
return info;
} else if (const auto same = Get<HistoryServiceSameBackground>()) {
return same;
}
return nullptr;
}
@ -3426,6 +3428,8 @@ void HistoryItem::createServiceFromMtp(const MTPDmessageService &message) {
}
}, call->lifetime);
}
} else if (type == mtpc_messageActionSetSameChatWallPaper) {
UpdateComponents(HistoryServiceSameBackground::Bit());
}
if (const auto replyTo = message.vreply_to()) {
replyTo->match([&](const MTPDmessageReplyHeader &data) {
@ -4177,6 +4181,37 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
return result;
};
auto prepareSetSameChatWallPaper = [&](
const MTPDmessageActionSetSameChatWallPaper &action) {
const auto isSelf = (_from->id == _from->session().userPeerId());
const auto peer = isSelf ? history()->peer : _from;
const auto user = peer->asUser();
const auto name = (user && !user->firstName.isEmpty())
? user->firstName
: peer->name();
auto result = PreparedServiceText{};
if (!isSelf) {
result.links.push_back(peer->createOpenLink());
}
if (const auto dependent = GetServiceDependentData()) {
result.links.push_back(dependent->lnk);
}
result.text = isSelf
? tr::lng_action_set_same_wallpaper(
tr::now,
lt_user,
Ui::Text::Link(name, 1), // Link 1.
lt_background,
Ui::Text::Link(tr::lng_action_set_same_background(tr::now), 2),
Ui::Text::WithEntities)
: tr::lng_action_set_same_wallpaper_me(
tr::now,
lt_background,
Ui::Text::Link(tr::lng_action_set_same_background(tr::now), 1),
Ui::Text::WithEntities);
return result;
};
setServiceText(action.match([&](
const MTPDmessageActionChatAddUser &data) {
return prepareChatAddUserText(data);
@ -4255,6 +4290,8 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
return prepareRequestedPeer(data);
}, [&](const MTPDmessageActionSetChatWallPaper &data) {
return prepareSetChatWallPaper(data);
}, [&](const MTPDmessageActionSetSameChatWallPaper &data) {
return prepareSetSameChatWallPaper(data);
}, [](const MTPDmessageActionEmpty &) {
return PreparedServiceText{ { tr::lng_message_empty(tr::now) } };
}));

View File

@ -530,6 +530,11 @@ struct HistoryServicePayment
bool recurringUsed = false;
};
struct HistoryServiceSameBackground
: public RuntimeComponent<HistoryServiceSameBackground, HistoryItem>
, public HistoryServiceDependentData {
};
enum class HistorySelfDestructType {
Photo,
Video,

View File

@ -159,7 +159,7 @@ struct FilterRow {
const auto result = count
? tr::lng_filters_chats_count(tr::now, lt_count_short, count)
: tr::lng_filters_no_chats(tr::now);
return filter.community()
return filter.chatlist()
? result + QString::fromUtf8(" \xE2\x80\xA2 shareable folder")
: result;
}
@ -371,7 +371,7 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
const auto row = find(button);
if (row->removed || row->removePeersRequestId > 0) {
return;
} else if (row->filter.community()
} else if (row->filter.chatlist()
&& !row->filter.always().empty()) {
const auto chosen = crl::guard(button, [=](
std::vector<not_null<PeerData*>> peers) {
@ -399,7 +399,7 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
const auto row = find(button);
if (row->removed || row->removePeersRequestId > 0) {
return;
} else if (row->filter.community() && row->removeHasLinks) {
} else if (row->filter.chatlist() && row->removeHasLinks) {
controller->show(Ui::MakeConfirmBox({
.text = { tr::lng_filters_delete_sure(tr::now) },
.confirmed = crl::guard(button, [=](Fn<void()> close) {
@ -417,10 +417,10 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
const auto row = find(button);
if (row->removed || row->removePeersRequestId > 0) {
return;
} else if (row->filter.community() && !row->removePeersRequestId) {
} else if (row->filter.chatlist() && !row->removePeersRequestId) {
row->removePeersRequestId = session->api().request(
MTPcommunities_GetLeaveCommunitySuggestions(
MTP_inputCommunityDialogFilter(
MTPchatlists_GetLeaveChatlistSuggestions(
MTP_inputChatlistDialogFilter(
MTP_int(row->filter.id())))
).done(crl::guard(button, [=](const MTPVector<MTPPeer> &result) {
const auto row = find(button);
@ -642,7 +642,7 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
auto updates = std::vector<MTPUpdate>();
auto addRequests = std::vector<MTPmessages_UpdateDialogFilter>();
auto removeRequests = std::vector<MTPmessages_UpdateDialogFilter>();
auto removeCommunityRequests = std::vector<MTPcommunities_LeaveCommunity>();
auto removeChatlistRequests = std::vector<MTPchatlists_LeaveChatlist>();
auto &realFilters = session->data().chatsFilters();
const auto &list = realFilters.list();
@ -671,18 +671,18 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
const auto tl = removed
? MTPDialogFilter()
: row.filter.tl(newId);
const auto removeCommunityWithChats = removed
&& row.filter.community()
const auto removeChatlistWithChats = removed
&& row.filter.chatlist()
&& !row.removePeers.empty();
if (removeCommunityWithChats) {
if (removeChatlistWithChats) {
auto inputs = ranges::views::all(
row.removePeers
) | ranges::views::transform([](not_null<PeerData*> peer) {
return MTPInputPeer(peer->input);
}) | ranges::to<QVector>();
removeCommunityRequests.push_back(
MTPcommunities_LeaveCommunity(
MTP_inputCommunityDialogFilter(MTP_int(newId)),
removeChatlistRequests.push_back(
MTPchatlists_LeaveChatlist(
MTP_inputChatlistDialogFilter(MTP_int(newId)),
MTP_vector<MTPInputPeer>(std::move(inputs))));
} else {
const auto request = MTPmessages_UpdateDialogFilter(
@ -726,7 +726,7 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
updates = std::move(updates),
addRequests = std::move(addRequests),
removeRequests = std::move(removeRequests),
removeCommunityRequests = std::move(removeCommunityRequests)
removeChatlistRequests = std::move(removeChatlistRequests)
] {
const auto api = &session->api();
const auto filters = &session->data().chatsFilters();
@ -760,7 +760,7 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
}
};
sendRequests(removeRequests);
sendRequests(removeCommunityRequests);
sendRequests(removeChatlistRequests);
sendRequests(addRequests);
if (!order.empty() && !addRequests.empty()) {
filters->saveOrder(order, previousId);

View File

@ -644,6 +644,7 @@ void ChatBackground::checkUploadWallPaper() {
_wallPaperUploadId = FullMsgId();
_wallPaperRequestId = _session->api().request(
MTPaccount_UploadWallPaper(
MTP_flags(0),
data.info.file,
MTP_string("image/jpeg"),
_paper.mtpSettings()