mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Update API scheme, simplify auto-delete.
This commit is contained in:
parent
05488022c7
commit
781e7a2e79
13 changed files with 95 additions and 192 deletions
|
@ -977,23 +977,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_manage_history_visibility_hidden_legacy" = "New members won't see more than 100 previous messages.";
|
"lng_manage_history_visibility_hidden_legacy" = "New members won't see more than 100 previous messages.";
|
||||||
|
|
||||||
"lng_manage_messages_ttl_title" = "Auto-delete messages";
|
"lng_manage_messages_ttl_title" = "Auto-delete messages";
|
||||||
"lng_manage_messages_ttl_never" = "Never";
|
"lng_manage_messages_ttl_never" = "Off";
|
||||||
"lng_manage_messages_ttl_after1" = "After 24 hours";
|
"lng_manage_messages_ttl_after1" = "24 hours";
|
||||||
"lng_manage_messages_ttl_after2" = "After 7 days";
|
"lng_manage_messages_ttl_after2" = "7 days";
|
||||||
"lng_manage_messages_ttl_about" = "Turning on this setting will make auto-delete messages from this group after the selected period.";
|
|
||||||
"lng_manage_messages_ttl_about_channel" = "Turning on this setting will make auto-delete messages from this channel after the selected period.";
|
|
||||||
|
|
||||||
"lng_ttl_edit_title" = "Auto-delete messages in this chat";
|
"lng_ttl_edit_title" = "Auto-delete messages in this chat";
|
||||||
"lng_ttl_edit_about" = "Automatically delete new messages sent in this chat after a certain period of time.";
|
"lng_ttl_edit_about" = "Automatically delete new messages after a certain period of time for you and {user}.";
|
||||||
"lng_ttl_edit_about_other" = "{user} has set messages to auto-delete in {duration} for both of you.";
|
"lng_ttl_edit_about_group" = "Automatically delete new messages sent in this chat after a certain period of time.";
|
||||||
"lng_ttl_edit_about_you" = "You have set messages to auto-delete in {duration} for both you and {user}.";
|
"lng_ttl_edit_about_channel" = "Automatically delete new messages sent in this channel after a certain period of time.";
|
||||||
"lng_ttl_edit_about_you_only" = "You have set messages to auto-delete in {duration} only for yourself.";
|
"lng_ttl_edit_save" = "Confirm";
|
||||||
"lng_ttl_also_checkbox" = "Also delete for {user}";
|
"lng_ttl_about_tooltip" = "New messages in this chat will be automatically deleted in {duration}.";
|
||||||
"lng_ttl_about_tooltip_on_title" = "Auto-delete On – {duration}";
|
"lng_ttl_about_tooltip_channel" = "New messages in this chat will be automatically deleted in {duration}.";
|
||||||
"lng_ttl_about_tooltip" = "Messages in this chat will auto-delete in {duration}.";
|
"lng_ttl_about_tooltip_off" = "Auto-delete is now disabled.";
|
||||||
"lng_ttl_about_tooltip_no_longer" = "{user} has set messages to auto-delete in {duration}. You can't make this interval longer.";
|
|
||||||
"lng_ttl_about_tooltip_no_cancel" = "{user} has set messages to auto-delete in {duration}. You can't cancel this.";
|
|
||||||
"lng_ttl_about_tooltip_off" = "Auto-delete is now Off.";
|
|
||||||
"lng_ttl_about_duration1" = "24 hours";
|
"lng_ttl_about_duration1" = "24 hours";
|
||||||
"lng_ttl_about_duration2" = "7 days";
|
"lng_ttl_about_duration2" = "7 days";
|
||||||
|
|
||||||
|
@ -1117,6 +1112,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_action_changed_title" = "{from} changed group name to «{title}»";
|
"lng_action_changed_title" = "{from} changed group name to «{title}»";
|
||||||
"lng_action_changed_title_channel" = "Channel name was changed to «{title}»";
|
"lng_action_changed_title_channel" = "Channel name was changed to «{title}»";
|
||||||
"lng_action_created_chat" = "{from} created group «{title}»";
|
"lng_action_created_chat" = "{from} created group «{title}»";
|
||||||
|
"lng_action_ttl_changed" = "{from} has set messages to auto-delete in {duration}";
|
||||||
|
"lng_action_ttl_changed_channel" = "New messages will auto-delete in {duration}";
|
||||||
|
"lng_action_ttl_removed" = "{from} has set messages not to auto-delete";
|
||||||
|
"lng_action_ttl_removed_channel" = "New messages will not auto-delete";
|
||||||
"lng_action_created_channel" = "Channel created";
|
"lng_action_created_channel" = "Channel created";
|
||||||
"lng_action_pinned_message" = "{from} pinned «{text}»";
|
"lng_action_pinned_message" = "{from} pinned «{text}»";
|
||||||
"lng_action_pinned_media" = "{from} pinned {media}";
|
"lng_action_pinned_media" = "{from} pinned {media}";
|
||||||
|
|
|
@ -127,8 +127,8 @@ chatForbidden#7328bdb id:int title:string = Chat;
|
||||||
channel#d31a961e flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?Vector<RestrictionReason> admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat;
|
channel#d31a961e flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?Vector<RestrictionReason> admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat;
|
||||||
channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat;
|
channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat;
|
||||||
|
|
||||||
chatFull#e22542a0 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl:flags.14?PeerHistoryTTL = ChatFull;
|
chatFull#f06c4018 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int = ChatFull;
|
||||||
channelFull#7c62b528 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?int location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl:flags.24?PeerHistoryTTL pending_suggestions:flags.25?Vector<string> = ChatFull;
|
channelFull#2548c037 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?int location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector<string> = ChatFull;
|
||||||
|
|
||||||
chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant;
|
chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant;
|
||||||
chatParticipantCreator#da13538a user_id:int = ChatParticipant;
|
chatParticipantCreator#da13538a user_id:int = ChatParticipant;
|
||||||
|
@ -184,6 +184,7 @@ messageActionContactSignUp#f3f25f76 = MessageAction;
|
||||||
messageActionGeoProximityReached#98e0d697 from_id:Peer to_id:Peer distance:int = MessageAction;
|
messageActionGeoProximityReached#98e0d697 from_id:Peer to_id:Peer distance:int = MessageAction;
|
||||||
messageActionGroupCall#7a0d7f42 flags:# call:InputGroupCall duration:flags.0?int = MessageAction;
|
messageActionGroupCall#7a0d7f42 flags:# call:InputGroupCall duration:flags.0?int = MessageAction;
|
||||||
messageActionInviteToGroupCall#76b9f11a call:InputGroupCall users:Vector<int> = MessageAction;
|
messageActionInviteToGroupCall#76b9f11a call:InputGroupCall users:Vector<int> = MessageAction;
|
||||||
|
messageActionSetMessagesTTL#aa1afbfd period:int = MessageAction;
|
||||||
|
|
||||||
dialog#2c171f72 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 notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog;
|
dialog#2c171f72 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 notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?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;
|
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;
|
||||||
|
@ -231,7 +232,7 @@ inputReportReasonCopyright#9b89f93a = ReportReason;
|
||||||
inputReportReasonGeoIrrelevant#dbd4feed = ReportReason;
|
inputReportReasonGeoIrrelevant#dbd4feed = ReportReason;
|
||||||
inputReportReasonFake#f5ddd6e7 = ReportReason;
|
inputReportReasonFake#f5ddd6e7 = ReportReason;
|
||||||
|
|
||||||
userFull#a54475a7 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 user:User about:flags.1?string settings:PeerSettings profile_photo:flags.2?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:flags.14?PeerHistoryTTL = UserFull;
|
userFull#139a9a77 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 user:User about:flags.1?string settings:PeerSettings profile_photo:flags.2?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 = UserFull;
|
||||||
|
|
||||||
contact#f911c994 user_id:int mutual:Bool = Contact;
|
contact#f911c994 user_id:int mutual:Bool = Contact;
|
||||||
|
|
||||||
|
@ -358,7 +359,6 @@ updateDialogFilter#26ffde7d flags:# id:int filter:flags.0?DialogFilter = Update;
|
||||||
updateDialogFilterOrder#a5d72105 order:Vector<int> = Update;
|
updateDialogFilterOrder#a5d72105 order:Vector<int> = Update;
|
||||||
updateDialogFilters#3504914f = Update;
|
updateDialogFilters#3504914f = Update;
|
||||||
updatePhoneCallSignalingData#2661bf09 phone_call_id:long data:bytes = Update;
|
updatePhoneCallSignalingData#2661bf09 phone_call_id:long data:bytes = Update;
|
||||||
updateChannelParticipant#65d2b464 flags:# channel_id:int date:int user_id:int prev_participant:flags.0?ChannelParticipant new_participant:flags.1?ChannelParticipant qts:int = Update;
|
|
||||||
updateChannelMessageForwards#6e8a84df channel_id:int id:int forwards:int = Update;
|
updateChannelMessageForwards#6e8a84df channel_id:int id:int forwards:int = Update;
|
||||||
updateReadChannelDiscussionInbox#1cc7de54 flags:# channel_id:int top_msg_id:int read_max_id:int broadcast_id:flags.0?int broadcast_post:flags.0?int = Update;
|
updateReadChannelDiscussionInbox#1cc7de54 flags:# channel_id:int top_msg_id:int read_max_id:int broadcast_id:flags.0?int broadcast_post:flags.0?int = Update;
|
||||||
updateReadChannelDiscussionOutbox#4638a26c channel_id:int top_msg_id:int read_max_id:int = Update;
|
updateReadChannelDiscussionOutbox#4638a26c channel_id:int top_msg_id:int read_max_id:int = Update;
|
||||||
|
@ -369,7 +369,9 @@ updatePinnedChannelMessages#8588878b flags:# pinned:flags.0?true channel_id:int
|
||||||
updateChat#1330a196 chat_id:int = Update;
|
updateChat#1330a196 chat_id:int = Update;
|
||||||
updateGroupCallParticipants#f2ebdb4e call:InputGroupCall participants:Vector<GroupCallParticipant> version:int = Update;
|
updateGroupCallParticipants#f2ebdb4e call:InputGroupCall participants:Vector<GroupCallParticipant> version:int = Update;
|
||||||
updateGroupCall#a45eb99b chat_id:int call:GroupCall = Update;
|
updateGroupCall#a45eb99b chat_id:int call:GroupCall = Update;
|
||||||
updatePeerHistoryTTL#1265be8 flags:# peer:Peer ttl:flags.0?PeerHistoryTTL = Update;
|
updatePeerHistoryTTL#bb9bb9a5 flags:# peer:Peer ttl_period:flags.0?int = Update;
|
||||||
|
updateChannelParticipant#65d2b464 flags:# channel_id:int date:int user_id:int prev_participant:flags.0?ChannelParticipant new_participant:flags.1?ChannelParticipant qts:int = Update;
|
||||||
|
updateBotStopped#30ec6ebc user_id:int stopped:Bool qts:int = Update;
|
||||||
|
|
||||||
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
|
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
|
||||||
|
|
||||||
|
@ -1221,9 +1223,6 @@ 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;
|
messages.affectedFoundMessages#ef8d3e6c pts:int pts_count:int offset:int messages:Vector<int> = messages.AffectedFoundMessages;
|
||||||
|
|
||||||
peerHistoryTTLPM#cf622d96 flags:# my_oneside:flags.0?true my_ttl_period:flags.1?int peer_ttl_period:flags.2?int = PeerHistoryTTL;
|
|
||||||
peerHistoryTTL#3e11cee9 ttl_period:int = PeerHistoryTTL;
|
|
||||||
|
|
||||||
chatInviteImporter#1e3e6680 user_id:int date:int = ChatInviteImporter;
|
chatInviteImporter#1e3e6680 user_id:int date:int = ChatInviteImporter;
|
||||||
|
|
||||||
messages.exportedChatInvites#bdc62dcc count:int invites:Vector<ExportedChatInvite> users:Vector<User> = messages.ExportedChatInvites;
|
messages.exportedChatInvites#bdc62dcc count:int invites:Vector<ExportedChatInvite> users:Vector<User> = messages.ExportedChatInvites;
|
||||||
|
@ -1499,7 +1498,7 @@ messages.deleteRevokedExportedChatInvites#56987bd5 peer:InputPeer admin_id:Input
|
||||||
messages.deleteExportedChatInvite#d464a42b peer:InputPeer link:string = Bool;
|
messages.deleteExportedChatInvite#d464a42b peer:InputPeer link:string = Bool;
|
||||||
messages.getAdminsWithInvites#3920e6ef peer:InputPeer = messages.ChatAdminsWithInvites;
|
messages.getAdminsWithInvites#3920e6ef peer:InputPeer = messages.ChatAdminsWithInvites;
|
||||||
messages.getChatInviteImporters#26fb7289 peer:InputPeer link:string offset_date:int offset_user:InputUser limit:int = messages.ChatInviteImporters;
|
messages.getChatInviteImporters#26fb7289 peer:InputPeer link:string offset_date:int offset_user:InputUser limit:int = messages.ChatInviteImporters;
|
||||||
messages.setHistoryTTL#cccb4721 flags:# pm_oneside:flags.0?true peer:InputPeer period:int = Updates;
|
messages.setHistoryTTL#b80e5fe4 peer:InputPeer period:int = Updates;
|
||||||
|
|
||||||
updates.getState#edd4882a = updates.State;
|
updates.getState#edd4882a = updates.State;
|
||||||
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
|
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
|
||||||
|
|
|
@ -1824,11 +1824,7 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||||
const auto &d = update.c_updatePeerHistoryTTL();
|
const auto &d = update.c_updatePeerHistoryTTL();
|
||||||
const auto peerId = peerFromMTP(d.vpeer());
|
const auto peerId = peerFromMTP(d.vpeer());
|
||||||
if (const auto peer = session().data().peerLoaded(peerId)) {
|
if (const auto peer = session().data().peerLoaded(peerId)) {
|
||||||
if (const auto ttl = d.vttl()) {
|
peer->setMessagesTTL(d.vttl_period().value_or_empty());
|
||||||
peer->applyMessagesTTL(*ttl);
|
|
||||||
} else {
|
|
||||||
peer->setMessagesTTL(0, 0, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
|
|
@ -750,9 +750,7 @@ void ApplyChannelUpdate(
|
||||||
channel->clearGroupCall();
|
channel->clearGroupCall();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto ttl = update.vttl()) {
|
channel->setMessagesTTL(update.vttl_period().value_or_empty());
|
||||||
channel->applyMessagesTTL(*ttl);
|
|
||||||
}
|
|
||||||
channel->setFullFlags(update.vflags().v);
|
channel->setFullFlags(update.vflags().v);
|
||||||
channel->setUserpicPhoto(update.vchat_photo());
|
channel->setUserpicPhoto(update.vchat_photo());
|
||||||
if (const auto migratedFrom = update.vmigrated_from_chat_id()) {
|
if (const auto migratedFrom = update.vmigrated_from_chat_id()) {
|
||||||
|
|
|
@ -377,9 +377,7 @@ void ApplyChatUpdate(not_null<ChatData*> chat, const MTPDchatFull &update) {
|
||||||
chat->clearGroupCall();
|
chat->clearGroupCall();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto ttl = update.vttl()) {
|
chat->setMessagesTTL(update.vttl_period().value_or_empty());
|
||||||
chat->applyMessagesTTL(*ttl);
|
|
||||||
}
|
|
||||||
if (const auto info = update.vbot_info()) {
|
if (const auto info = update.vbot_info()) {
|
||||||
for (const auto &item : info->v) {
|
for (const auto &item : info->v) {
|
||||||
item.match([&](const MTPDbotInfo &data) {
|
item.match([&](const MTPDbotInfo &data) {
|
||||||
|
|
|
@ -950,41 +950,18 @@ void PeerData::setLoadedStatus(LoadedStatus status) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeId PeerData::messagesTTL() const {
|
TimeId PeerData::messagesTTL() const {
|
||||||
return (_ttlMyPeriod && _ttlPeerPeriod)
|
return _ttlPeriod;
|
||||||
? std::min(_ttlMyPeriod, _ttlPeerPeriod)
|
|
||||||
: std::max(_ttlMyPeriod, _ttlPeerPeriod);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerData::setMessagesTTL(
|
void PeerData::setMessagesTTL(TimeId period) {
|
||||||
TimeId myPeriod,
|
if (_ttlPeriod != period) {
|
||||||
TimeId peerPeriod,
|
_ttlPeriod = period;
|
||||||
bool oneSide) {
|
|
||||||
if (_ttlMyPeriod != myPeriod
|
|
||||||
|| _ttlPeerPeriod != peerPeriod
|
|
||||||
|| _ttlOneSide != oneSide) {
|
|
||||||
_ttlMyPeriod = myPeriod;
|
|
||||||
_ttlPeerPeriod = peerPeriod;
|
|
||||||
_ttlOneSide = oneSide;
|
|
||||||
session().changes().peerUpdated(
|
session().changes().peerUpdated(
|
||||||
this,
|
this,
|
||||||
Data::PeerUpdate::Flag::MessagesTTL);
|
Data::PeerUpdate::Flag::MessagesTTL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerData::applyMessagesTTL(const MTPPeerHistoryTTL &ttl) {
|
|
||||||
ttl.match([&](const MTPDpeerHistoryTTL &data) {
|
|
||||||
setMessagesTTL(
|
|
||||||
data.vttl_period().v,
|
|
||||||
0,
|
|
||||||
false);
|
|
||||||
}, [&](const MTPDpeerHistoryTTLPM &data) {
|
|
||||||
setMessagesTTL(
|
|
||||||
data.vmy_ttl_period().value_or_empty(),
|
|
||||||
data.vpeer_ttl_period().value_or_empty(),
|
|
||||||
data.is_my_oneside());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
std::vector<ChatRestrictions> ListOfRestrictions() {
|
std::vector<ChatRestrictions> ListOfRestrictions() {
|
||||||
|
|
|
@ -382,18 +382,8 @@ public:
|
||||||
}
|
}
|
||||||
void setLoadedStatus(LoadedStatus status);
|
void setLoadedStatus(LoadedStatus status);
|
||||||
|
|
||||||
[[nodiscard]] TimeId myMessagesTTL() const {
|
|
||||||
return _ttlMyPeriod;
|
|
||||||
}
|
|
||||||
[[nodiscard]] TimeId peerMessagesTTL() const {
|
|
||||||
return _ttlPeerPeriod;
|
|
||||||
}
|
|
||||||
[[nodiscard]] bool oneSideTTL() const {
|
|
||||||
return _ttlOneSide;
|
|
||||||
}
|
|
||||||
[[nodiscard]] TimeId messagesTTL() const;
|
[[nodiscard]] TimeId messagesTTL() const;
|
||||||
void setMessagesTTL(TimeId myPeriod, TimeId peerPeriod, bool oneSide);
|
void setMessagesTTL(TimeId period);
|
||||||
void applyMessagesTTL(const MTPPeerHistoryTTL &ttl);
|
|
||||||
|
|
||||||
[[nodiscard]] Data::GroupCall *groupCall() const;
|
[[nodiscard]] Data::GroupCall *groupCall() const;
|
||||||
|
|
||||||
|
@ -439,9 +429,7 @@ private:
|
||||||
|
|
||||||
crl::time _lastFullUpdate = 0;
|
crl::time _lastFullUpdate = 0;
|
||||||
|
|
||||||
TimeId _ttlMyPeriod = 0;
|
TimeId _ttlPeriod = 0;
|
||||||
TimeId _ttlPeerPeriod = 0;
|
|
||||||
bool _ttlOneSide = false;
|
|
||||||
bool _hasPinnedMessages = false;
|
bool _hasPinnedMessages = false;
|
||||||
|
|
||||||
Settings _settings = { kSettingsUnknown };
|
Settings _settings = { kSettingsUnknown };
|
||||||
|
|
|
@ -256,9 +256,7 @@ void ApplyUserUpdate(not_null<UserData*> user, const MTPDuserFull &update) {
|
||||||
MTP_inputNotifyPeer(user->input),
|
MTP_inputNotifyPeer(user->input),
|
||||||
update.vnotify_settings());
|
update.vnotify_settings());
|
||||||
|
|
||||||
if (const auto ttl = update.vttl()) {
|
user->setMessagesTTL(update.vttl_period().value_or_empty());
|
||||||
user->applyMessagesTTL(*ttl);
|
|
||||||
}
|
|
||||||
if (const auto info = update.vbot_info()) {
|
if (const auto info = update.vbot_info()) {
|
||||||
user->setBotInfo(*info);
|
user->setBotInfo(*info);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1128,6 +1128,8 @@ ServiceAction ParseServiceAction(
|
||||||
content.userIds.push_back(user.v);
|
content.userIds.push_back(user.v);
|
||||||
}
|
}
|
||||||
result.content = content;
|
result.content = content;
|
||||||
|
}, [&](const MTPDmessageActionSetMessagesTTL &data) {
|
||||||
|
// #TODO ttl
|
||||||
}, [](const MTPDmessageActionEmpty &data) {});
|
}, [](const MTPDmessageActionEmpty &data) {});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,6 +371,31 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||||
return prepareInvitedToCallText(action.vusers().v, linkCallId);
|
return prepareInvitedToCallText(action.vusers().v, linkCallId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto prepareSetMessagesTTL = [this](const MTPDmessageActionSetMessagesTTL &action) {
|
||||||
|
auto result = PreparedText{};
|
||||||
|
const auto period = action.vperiod().v;
|
||||||
|
const auto duration = (period == 5) AssertIsDebug()
|
||||||
|
? u"5 seconds"_q AssertIsDebug()
|
||||||
|
: (period < 3 * 86400)
|
||||||
|
? tr::lng_ttl_about_duration1(tr::now)
|
||||||
|
: tr::lng_ttl_about_duration2(tr::now);
|
||||||
|
if (isPost()) {
|
||||||
|
if (!period) {
|
||||||
|
result.text = tr::lng_action_ttl_removed_channel(tr::now);
|
||||||
|
} else {
|
||||||
|
result.text = tr::lng_action_ttl_changed_channel(tr::now, lt_duration, duration);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.links.push_back(fromLink());
|
||||||
|
if (!period) {
|
||||||
|
result.text = tr::lng_action_ttl_removed(tr::now, lt_from, fromLinkText());
|
||||||
|
} else {
|
||||||
|
result.text = tr::lng_action_ttl_changed(tr::now, lt_from, fromLinkText(), lt_duration, duration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
const auto messageText = action.match([&](
|
const auto messageText = action.match([&](
|
||||||
const MTPDmessageActionChatAddUser &data) {
|
const MTPDmessageActionChatAddUser &data) {
|
||||||
return prepareChatAddUserText(data);
|
return prepareChatAddUserText(data);
|
||||||
|
@ -424,6 +449,8 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||||
return prepareGroupCall(data);
|
return prepareGroupCall(data);
|
||||||
}, [&](const MTPDmessageActionInviteToGroupCall &data) {
|
}, [&](const MTPDmessageActionInviteToGroupCall &data) {
|
||||||
return prepareInviteToGroupCall(data);
|
return prepareInviteToGroupCall(data);
|
||||||
|
}, [&](const MTPDmessageActionSetMessagesTTL &data) {
|
||||||
|
return prepareSetMessagesTTL(data);
|
||||||
}, [](const MTPDmessageActionEmpty &) {
|
}, [](const MTPDmessageActionEmpty &) {
|
||||||
return PreparedText{ tr::lng_message_empty(tr::now) };
|
return PreparedText{ tr::lng_message_empty(tr::now) };
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,23 +40,11 @@ void ShowAutoDeleteToast(not_null<PeerData*> peer) {
|
||||||
: (period < 3 * 86400)
|
: (period < 3 * 86400)
|
||||||
? tr::lng_ttl_about_duration1(tr::now)
|
? tr::lng_ttl_about_duration1(tr::now)
|
||||||
: tr::lng_ttl_about_duration2(tr::now);
|
: tr::lng_ttl_about_duration2(tr::now);
|
||||||
auto rich = Ui::Text::Bold(
|
const auto text = peer->isBroadcast()
|
||||||
tr::lng_ttl_about_tooltip_on_title(tr::now, lt_duration, duration)
|
? tr::lng_ttl_about_tooltip_channel(tr::now, lt_duration, duration)
|
||||||
).append('\n');
|
: tr::lng_ttl_about_tooltip(tr::now, lt_duration, duration);
|
||||||
|
|
||||||
const auto myPeriod = peer->myMessagesTTL();
|
|
||||||
rich.append((period == myPeriod)
|
|
||||||
? tr::lng_ttl_about_tooltip(tr::now, lt_duration, duration)
|
|
||||||
: (myPeriod
|
|
||||||
? tr::lng_ttl_about_tooltip_no_longer
|
|
||||||
: tr::lng_ttl_about_tooltip_no_cancel)(
|
|
||||||
tr::now,
|
|
||||||
lt_user,
|
|
||||||
peer->shortName(),
|
|
||||||
lt_duration,
|
|
||||||
duration));
|
|
||||||
Ui::ShowMultilineToast({
|
Ui::ShowMultilineToast({
|
||||||
.text = std::move(rich),
|
.text = { text },
|
||||||
.duration = kToastDuration,
|
.duration = kToastDuration,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -66,27 +54,20 @@ void AutoDeleteSettingsBox(
|
||||||
not_null<PeerData*> peer) {
|
not_null<PeerData*> peer) {
|
||||||
struct State {
|
struct State {
|
||||||
TimeId savingPeriod = 0;
|
TimeId savingPeriod = 0;
|
||||||
bool savingOneSide = false;
|
|
||||||
mtpRequestId savingRequestId = 0;
|
mtpRequestId savingRequestId = 0;
|
||||||
QPointer<Ui::GenericBox> weak;
|
QPointer<Ui::GenericBox> weak;
|
||||||
};
|
};
|
||||||
const auto state = std::make_shared<State>(State{ .weak = box.get() });
|
const auto state = std::make_shared<State>(State{ .weak = box.get() });
|
||||||
auto callback = [=](TimeId period, bool oneSide) {
|
auto callback = [=](TimeId period) {
|
||||||
auto &api = peer->session().api();
|
auto &api = peer->session().api();
|
||||||
if (state->savingRequestId) {
|
if (state->savingRequestId) {
|
||||||
if (period == state->savingPeriod
|
if (period == state->savingPeriod) {
|
||||||
&& oneSide == state->savingOneSide) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
api.request(state->savingRequestId).cancel();
|
api.request(state->savingRequestId).cancel();
|
||||||
}
|
}
|
||||||
state->savingPeriod = period;
|
state->savingPeriod = period;
|
||||||
state->savingOneSide = oneSide;
|
|
||||||
using Flag = MTPmessages_SetHistoryTTL::Flag;
|
|
||||||
state->savingRequestId = api.request(MTPmessages_SetHistoryTTL(
|
state->savingRequestId = api.request(MTPmessages_SetHistoryTTL(
|
||||||
MTP_flags((oneSide && peer->isUser())
|
|
||||||
? Flag::f_pm_oneside
|
|
||||||
: Flag(0)),
|
|
||||||
peer->input,
|
peer->input,
|
||||||
MTP_int(period)
|
MTP_int(period)
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
|
@ -101,12 +82,12 @@ void AutoDeleteSettingsBox(
|
||||||
};
|
};
|
||||||
Ui::AutoDeleteSettingsBox(
|
Ui::AutoDeleteSettingsBox(
|
||||||
box,
|
box,
|
||||||
peer->myMessagesTTL(),
|
peer->messagesTTL(),
|
||||||
peer->peerMessagesTTL(),
|
|
||||||
peer->oneSideTTL(),
|
|
||||||
(peer->isUser()
|
(peer->isUser()
|
||||||
? std::make_optional(peer->shortName())
|
? tr::lng_ttl_edit_about(lt_user, rpl::single(peer->shortName()))
|
||||||
: std::nullopt),
|
: peer->isBroadcast()
|
||||||
|
? tr::lng_ttl_edit_about_channel()
|
||||||
|
: tr::lng_ttl_edit_about_group()),
|
||||||
std::move(callback));
|
std::move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,60 +186,53 @@ object_ptr<Ui::RpWidget> CreateSliderForTTL(
|
||||||
|
|
||||||
void AutoDeleteSettingsBox(
|
void AutoDeleteSettingsBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
TimeId ttlMyPeriod,
|
TimeId ttlPeriod,
|
||||||
TimeId ttlPeerPeriod,
|
rpl::producer<QString> about,
|
||||||
bool ttlOneSide,
|
Fn<void(TimeId)> callback) {
|
||||||
std::optional<QString> userFirstName,
|
|
||||||
Fn<void(TimeId, bool)> callback) {
|
|
||||||
box->setTitle(tr::lng_manage_messages_ttl_title());
|
box->setTitle(tr::lng_manage_messages_ttl_title());
|
||||||
box->setWidth(st::boxWideWidth);
|
box->setWidth(st::boxWideWidth);
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
TimeId my = 0;
|
TimeId period = 0;
|
||||||
bool oneSide = false;
|
|
||||||
rpl::event_stream<rpl::producer<QString>> aboutTexts;
|
|
||||||
Fn<void()> update;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto state = box->lifetime().make_state<State>(State{
|
const auto state = box->lifetime().make_state<State>(State{
|
||||||
.my = ttlMyPeriod,
|
.period = ttlPeriod,
|
||||||
.oneSide = ttlOneSide,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto options = std::vector<QString>{
|
const auto options = std::vector<QString>{
|
||||||
|
tr::lng_manage_messages_ttl_never(tr::now),
|
||||||
u"5 seconds"_q, AssertIsDebug()
|
u"5 seconds"_q, AssertIsDebug()
|
||||||
tr::lng_manage_messages_ttl_after1(tr::now),
|
tr::lng_manage_messages_ttl_after1(tr::now),
|
||||||
tr::lng_manage_messages_ttl_after2(tr::now),
|
tr::lng_manage_messages_ttl_after2(tr::now),
|
||||||
tr::lng_manage_messages_ttl_never(tr::now),
|
|
||||||
};
|
};
|
||||||
const auto periodToIndex = [&](TimeId period) {
|
const auto periodToIndex = [&](TimeId period) {
|
||||||
return !period
|
return !period
|
||||||
? 3
|
? 0
|
||||||
: (period == 5) AssertIsDebug()
|
: (period == 5) AssertIsDebug()
|
||||||
? 0 AssertIsDebug()
|
? 1 AssertIsDebug()
|
||||||
: (period < 3 * 86400)
|
: (period < 3 * 86400)
|
||||||
? 1
|
? 2
|
||||||
: 2;
|
: 3;
|
||||||
};
|
};
|
||||||
const auto indexToPeriod = [&](int index) {
|
const auto indexToPeriod = [&](int index) {
|
||||||
return !index
|
return !index
|
||||||
? 5 AssertIsDebug()
|
? 0
|
||||||
: (index == 1) AssertIsDebug()
|
: (index == 1) AssertIsDebug()
|
||||||
? 86400
|
? 5 AssertIsDebug()
|
||||||
: (index == 2)
|
: (index == 2)
|
||||||
? 7 * 86400
|
? 86400
|
||||||
: 0;
|
: 7 * 86400;
|
||||||
};
|
};
|
||||||
const auto sliderCallback = [=](int index) {
|
const auto sliderCallback = [=](int index) {
|
||||||
state->my = indexToPeriod(index);
|
state->period = indexToPeriod(index);
|
||||||
state->update();
|
|
||||||
};
|
};
|
||||||
const auto slider = box->addRow(
|
const auto slider = box->addRow(
|
||||||
CreateSliderForTTL(
|
CreateSliderForTTL(
|
||||||
box,
|
box,
|
||||||
options | ranges::to_vector,
|
options | ranges::to_vector,
|
||||||
periodToIndex(ttlPeerPeriod),
|
options.size() - 1,
|
||||||
periodToIndex(ttlMyPeriod),
|
periodToIndex(ttlPeriod),
|
||||||
sliderCallback),
|
sliderCallback),
|
||||||
{
|
{
|
||||||
st::boxRowPadding.left(),
|
st::boxRowPadding.left(),
|
||||||
|
@ -247,72 +240,21 @@ void AutoDeleteSettingsBox(
|
||||||
st::boxRowPadding.right(),
|
st::boxRowPadding.right(),
|
||||||
st::boxMediumSkip });
|
st::boxMediumSkip });
|
||||||
|
|
||||||
const auto bothSides = userFirstName
|
|
||||||
? box->addRow(
|
|
||||||
object_ptr<Ui::Checkbox>(
|
|
||||||
box,
|
|
||||||
tr::lng_ttl_also_checkbox(tr::now, lt_user, *userFirstName),
|
|
||||||
!ttlOneSide),
|
|
||||||
{
|
|
||||||
st::boxRowPadding.left(),
|
|
||||||
0,
|
|
||||||
st::boxRowPadding.right(),
|
|
||||||
st::boxMediumSkip })
|
|
||||||
: nullptr;
|
|
||||||
|
|
||||||
const auto description = box->addRow(
|
const auto description = box->addRow(
|
||||||
object_ptr<Ui::DividerLabel>(
|
object_ptr<Ui::DividerLabel>(
|
||||||
box,
|
box,
|
||||||
object_ptr<Ui::FlatLabel>(
|
object_ptr<Ui::FlatLabel>(
|
||||||
box,
|
box,
|
||||||
state->aboutTexts.events() | rpl::flatten_latest(),
|
std::move(about),
|
||||||
st::boxDividerLabel),
|
st::boxDividerLabel),
|
||||||
st::ttlDividerLabelPadding),
|
st::ttlDividerLabelPadding),
|
||||||
style::margins());
|
style::margins());
|
||||||
|
|
||||||
if (bothSides) {
|
|
||||||
bothSides->checkedChanges(
|
|
||||||
) | rpl::start_with_next([=](bool checked) {
|
|
||||||
state->oneSide = !checked;
|
|
||||||
state->update();
|
|
||||||
}, bothSides->lifetime());
|
|
||||||
}
|
|
||||||
|
|
||||||
state->update = [=] {
|
|
||||||
const auto his = ttlPeerPeriod;
|
|
||||||
const auto wrap = [](TimeId period) {
|
|
||||||
Expects(period > 0);
|
|
||||||
|
|
||||||
return (period == 5) AssertIsDebug()
|
|
||||||
? rpl::single(u"5 seconds"_q) AssertIsDebug()
|
|
||||||
: (period < 3 * 86400)
|
|
||||||
? tr::lng_ttl_about_duration1()
|
|
||||||
: tr::lng_ttl_about_duration2();
|
|
||||||
};
|
|
||||||
state->aboutTexts.fire(((!state->my && !his) || !userFirstName)
|
|
||||||
? tr::lng_ttl_edit_about()
|
|
||||||
: (his > 0 && (!state->my || his < state->my))
|
|
||||||
? tr::lng_ttl_edit_about_other(
|
|
||||||
lt_user,
|
|
||||||
rpl::single(*userFirstName),
|
|
||||||
lt_duration,
|
|
||||||
wrap(his))
|
|
||||||
: state->oneSide
|
|
||||||
? tr::lng_ttl_edit_about_you_only(lt_duration, wrap(state->my))
|
|
||||||
: tr::lng_ttl_edit_about_you(
|
|
||||||
lt_duration,
|
|
||||||
wrap(state->my),
|
|
||||||
lt_user,
|
|
||||||
rpl::single(*userFirstName)));
|
|
||||||
};
|
|
||||||
state->update();
|
|
||||||
|
|
||||||
box->addButton(tr::lng_settings_save(), [=] {
|
box->addButton(tr::lng_settings_save(), [=] {
|
||||||
const auto period = state->my;
|
const auto period = state->period;
|
||||||
const auto oneSide = state->oneSide;
|
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
|
|
||||||
callback(period, oneSide);
|
callback(period);
|
||||||
});
|
});
|
||||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,8 @@ namespace Ui {
|
||||||
|
|
||||||
void AutoDeleteSettingsBox(
|
void AutoDeleteSettingsBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
TimeId ttlMyPeriod,
|
TimeId ttlPeriod,
|
||||||
TimeId ttlPeerPeriod,
|
rpl::producer<QString> about,
|
||||||
bool ttlOneSide,
|
Fn<void(TimeId)> callback);
|
||||||
std::optional<QString> userFirstName,
|
|
||||||
Fn<void(TimeId, bool)> callback);
|
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
Loading…
Add table
Reference in a new issue