Update API scheme on layer 158.

This commit is contained in:
John Preston 2023-03-31 13:06:13 +04:00
parent 7a9961b0e9
commit 4444844443
12 changed files with 75 additions and 10 deletions

View File

@ -1521,6 +1521,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_action_suggested_video" = "{user} suggests you to use this profile video.";
"lng_action_suggested_video_button" = "View Video";
"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_topic_created_inside" = "Topic created";
"lng_action_topic_closed_inside" = "Topic closed";
"lng_action_topic_reopened_inside" = "Topic reopened";
@ -1580,6 +1582,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_group_invite_no_joined" = "No one joined yet";
"lng_group_invite_joined#one" = "{count} joined";
"lng_group_invite_joined#other" = "{count} joined";
"lng_group_invite_joined_via_filter" = "joined via a folder invite link";
"lng_group_invite_remaining#one" = "{count} remaining";
"lng_group_invite_remaining#other" = "{count} remaining";
"lng_group_invite_requested#one" = "{count} requested";
@ -3095,6 +3098,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_admin_log_participant_joined_channel" = "{from} joined the channel";
"lng_admin_log_participant_joined_by_link" = "{from} joined the group via {link}";
"lng_admin_log_participant_joined_by_link_channel" = "{from} joined the channel via {link}";
"lng_admin_log_participant_joined_by_filter_link" = "{from} joined the group via {link} from a folder";
"lng_admin_log_participant_joined_by_filter_link_channel" = "{from} joined the channel via {link} from a folder";
"lng_admin_log_participant_approved_by_link" = "{from} was approved to join the group via {link} by {user}";
"lng_admin_log_participant_approved_by_link_channel" = "{from} was approved to join the channel via {link} by {user}";
"lng_admin_log_participant_approved_by_request" = "{from} joined to the group via public request, approved by {user}";

View File

@ -196,6 +196,7 @@ messageActionTopicCreate#d999256 flags:# title:string icon_color:int icon_emoji_
messageActionTopicEdit#c0944820 flags:# title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool hidden:flags.3?Bool = MessageAction;
messageActionSuggestProfilePhoto#57de635e photo:Photo = MessageAction;
messageActionRequestedPeer#fe77345d button_id:int peer:Peer = MessageAction;
messageActionSetChatWallPaper#bc44a927 wallpaper:WallPaper = 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;
@ -247,7 +248,7 @@ inputReportReasonFake#f5ddd6e7 = ReportReason;
inputReportReasonIllegalDrugs#a8eb2be = ReportReason;
inputReportReasonPersonalDetails#9ec7863d = ReportReason;
userFull#f8d32aed flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector<PremiumGiftOption> = UserFull;
userFull#93eadb53 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector<PremiumGiftOption> wallpaper:flags.24?WallPaper = UserFull;
contact#145ade0b user_id:long mutual:Bool = Contact;
@ -385,7 +386,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:# 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_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;
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;
@ -959,7 +960,7 @@ channelAdminLogEventActionDiscardGroupCall#db9f9140 call:InputGroupCall = Channe
channelAdminLogEventActionParticipantMute#f92424d2 participant:GroupCallParticipant = ChannelAdminLogEventAction;
channelAdminLogEventActionParticipantUnmute#e64429c0 participant:GroupCallParticipant = ChannelAdminLogEventAction;
channelAdminLogEventActionToggleGroupCallSetting#56d6a247 join_muted:Bool = ChannelAdminLogEventAction;
channelAdminLogEventActionParticipantJoinByInvite#5cdada77 invite:ExportedChatInvite = ChannelAdminLogEventAction;
channelAdminLogEventActionParticipantJoinByInvite#fe9fc158 flags:# via_community: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;
@ -1306,7 +1307,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 user_id:long date:int about:flags.2?string approved_by:flags.1?long = ChatInviteImporter;
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;
messages.exportedChatInvites#bdc62dcc count:int invites:Vector<ExportedChatInvite> users:Vector<User> = messages.ExportedChatInvites;
@ -1876,6 +1877,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;
updates.getState#edd4882a = updates.State;
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
@ -2068,6 +2070,7 @@ communities.joinCommunityInvite#4eff927 slug:string peers:Vector<InputPeer> = Up
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;
// LAYER 158

View File

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

View File

@ -34,6 +34,7 @@ struct PeerInviteLinks {
struct JoinedByLinkUser {
not_null<UserData*> user;
TimeId date = 0;
bool viaFilterLink = false;
};
struct JoinedByLinkSlice {

View File

@ -731,9 +731,14 @@ void Controller::loadMoreRows() {
void Controller::appendSlice(const Api::JoinedByLinkSlice &slice) {
for (const auto &user : slice.users) {
_lastUser = user;
delegate()->peerListAppendRow((_role == Role::Requested)
auto row = (_role == Role::Requested)
? std::make_unique<RequestedRow>(user.user, user.date)
: std::make_unique<PeerListRow>(user.user));
: std::make_unique<PeerListRow>(user.user);
if (_role != Role::Requested && user.viaFilterLink) {
row->setCustomStatus(
tr::lng_group_invite_joined_via_filter(tr::now));
}
delegate()->peerListAppendRow(std::move(row));
}
delegate()->peerListRefreshRows();
if (delegate()->peerListFullRowsCount() > 0) {

View File

@ -97,6 +97,8 @@ struct FileReferenceAccumulator {
push(data.vphoto());
}, [&](const MTPDmessageActionSuggestProfilePhoto &data) {
push(data.vphoto());
}, [&](const MTPDmessageActionSetChatWallPaper &data) {
push(data.vwallpaper());
}, [](const auto &data) {
});
}, [](const MTPDmessageEmpty &data) {

View File

@ -1182,6 +1182,10 @@ ServiceAction ParseServiceAction(
+ "photos/"
+ PreparePhotoFileName(++context.photos, date));
result.content = content;
}, [&](const MTPDmessageActionSetChatWallPaper &data) {
auto content = ActionSetChatWallPaper();
// #TODO wallpapers
result.content = content;
}, [&](const MTPDmessageActionRequestedPeer &data) {
auto content = ActionRequestedPeer();
content.peerId = ParsePeerId(data.vpeer());
@ -1198,6 +1202,9 @@ File &Message::file() {
} else if (const auto photo = std::get_if<ActionSuggestProfilePhoto>(
content)) {
return photo->photo.image.file;
} else if (const auto wallpaper = std::get_if<ActionSetChatWallPaper>(
content)) {
// #TODO wallpapers
}
return media.file();
}
@ -1209,6 +1216,9 @@ const File &Message::file() const {
} else if (const auto photo = std::get_if<ActionSuggestProfilePhoto>(
content)) {
return photo->photo.image.file;
} else if (const auto wallpaper = std::get_if<ActionSetChatWallPaper>(
content)) {
// #TODO wallpapers
}
return media.file();
}

View File

@ -515,6 +515,10 @@ struct ActionSuggestProfilePhoto {
Photo photo;
};
struct ActionSetChatWallPaper {
// #TODO wallpapers
};
struct ActionRequestedPeer {
PeerId peerId = 0;
int buttonId = 0;
@ -556,7 +560,8 @@ struct ServiceAction {
ActionTopicCreate,
ActionTopicEdit,
ActionSuggestProfilePhoto,
ActionRequestedPeer> content;
ActionRequestedPeer,
ActionSetChatWallPaper> content;
};
ServiceAction ParseServiceAction(

View File

@ -1173,6 +1173,8 @@ auto HtmlWriter::Wrap::pushMessage(
return serviceFrom + " suggests to use this photo";
}, [&](const ActionRequestedPeer &data) {
return "requested: "_q/* + data.peerId*/;
}, [&](const ActionSetChatWallPaper &data) {
return serviceFrom + " set a new background for this chat";
}, [](v::null_t) { return QByteArray(); });
if (!serviceText.isEmpty()) {

View File

@ -590,6 +590,9 @@ QByteArray SerializeMessage(
pushAction("requested_peer");
push("button_id", data.buttonId);
push("peer_id", data.peerId.value);
}, [&](const ActionSetChatWallPaper &data) {
pushActor();
pushAction("set_chat_wallpaper");
}, [](v::null_t) {});
if (v::is_null(message.action.content)) {

View File

@ -1392,9 +1392,13 @@ void GenerateItems(
const auto createParticipantJoinByInvite = [&](
const LogJoinByInvite &data) {
const auto text = (channel->isMegagroup()
? tr::lng_admin_log_participant_joined_by_link
: tr::lng_admin_log_participant_joined_by_link_channel);
const auto text = data.is_via_community()
? (channel->isMegagroup()
? tr::lng_admin_log_participant_joined_by_filter_link
: tr::lng_admin_log_participant_joined_by_filter_link_channel)
: (channel->isMegagroup()
? tr::lng_admin_log_participant_joined_by_link
: tr::lng_admin_log_participant_joined_by_link_channel);
addInviteLinkServiceMessage(
text(
tr::now,

View File

@ -4157,6 +4157,26 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
return result;
};
auto prepareSetChatWallPaper = [&](
const MTPDmessageActionSetChatWallPaper &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{};
result.links.push_back(peer->createOpenLink());
result.text = isSelf
? tr::lng_action_set_wallpaper(
tr::now,
lt_user,
Ui::Text::Link(name, 1), // Link 1.
Ui::Text::WithEntities)
: tr::lng_action_set_wallpaper_me(tr::now, Ui::Text::WithEntities);
return result;
};
setServiceText(action.match([&](
const MTPDmessageActionChatAddUser &data) {
return prepareChatAddUserText(data);
@ -4233,6 +4253,8 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
return prepareSuggestProfilePhoto(data);
}, [&](const MTPDmessageActionRequestedPeer &data) {
return prepareRequestedPeer(data);
}, [&](const MTPDmessageActionSetChatWallPaper &data) {
return prepareSetChatWallPaper(data);
}, [](const MTPDmessageActionEmpty &) {
return PreparedServiceText{ { tr::lng_message_empty(tr::now) } };
}));
@ -4296,6 +4318,8 @@ void HistoryItem::applyAction(const MTPMessageAction &action) {
history()->owner().processPhoto(photo));
}, [](const MTPDphotoEmpty &) {
});
}, [&](const MTPDmessageActionSetChatWallPaper &data) {
//_media = std::make_unique.. #TODO wallpapers
}, [](const auto &) {
});
}