Update API scheme to layer 93. Broken.

This commit is contained in:
John Preston 2019-01-03 18:39:19 +04:00
parent 47edb71a68
commit d2d6b319b6
38 changed files with 486 additions and 463 deletions

View File

@ -227,12 +227,12 @@ userStatusLastWeek#7bf09fc = UserStatus;
userStatusLastMonth#77ebc742 = UserStatus; userStatusLastMonth#77ebc742 = UserStatus;
chatEmpty#9ba2d800 id:int = Chat; chatEmpty#9ba2d800 id:int = Chat;
chat#d91cdd54 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true admins_enabled:flags.3?true admin:flags.4?true deactivated:flags.5?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel = Chat; chat#3bda1bde flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true deactivated:flags.5?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat;
chatForbidden#7328bdb id:int title:string = Chat; chatForbidden#7328bdb id:int title:string = Chat;
channel#c88974ac flags:# creator:flags.0?true left:flags.2?true editor:flags.3?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true democracy:flags.10?true signatures:flags.11?true min:flags.12?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?string admin_rights:flags.14?ChannelAdminRights banned_rights:flags.15?ChannelBannedRights participants_count:flags.17?int = Chat; channel#4df30834 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 id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?string 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#edd2a791 flags:# id:int participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int = ChatFull; chatFull#22a235da flags:# can_set_username:flags.7?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int = ChatFull;
channelFull#1c87a71a 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_view_stats:flags.12?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: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 = ChatFull; channelFull#1c87a71a 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_view_stats:flags.12?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: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 = ChatFull;
chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant; chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant;
@ -318,8 +318,7 @@ peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bo
peerSettings#818426cd flags:# report_spam:flags.0?true = PeerSettings; peerSettings#818426cd flags:# report_spam:flags.0?true = PeerSettings;
wallPaper#ccb03657 id:int title:string sizes:Vector<PhotoSize> color:int = WallPaper; wallPaper#f04f91ec id:long flags:# creator:flags.0?true default:flags.1?true access_hash:long slug:string document:Document = WallPaper;
wallPaperSolid#63117f24 id:int title:string bg_color:int color:int = WallPaper;
inputReportReasonSpam#58dbcab8 = ReportReason; inputReportReasonSpam#58dbcab8 = ReportReason;
inputReportReasonViolence#1e22c78d = ReportReason; inputReportReasonViolence#1e22c78d = ReportReason;
@ -413,7 +412,6 @@ updateNewChannelMessage#62ba04d9 message:Message pts:int pts_count:int = Update;
updateReadChannelInbox#4214f37f channel_id:int max_id:int = Update; updateReadChannelInbox#4214f37f channel_id:int max_id:int = Update;
updateDeleteChannelMessages#c37521c9 channel_id:int messages:Vector<int> pts:int pts_count:int = Update; updateDeleteChannelMessages#c37521c9 channel_id:int messages:Vector<int> pts:int pts_count:int = Update;
updateChannelMessageViews#98a12b4b channel_id:int id:int views:int = Update; updateChannelMessageViews#98a12b4b channel_id:int id:int views:int = Update;
updateChatAdmins#6e947941 chat_id:int enabled:Bool version:int = Update;
updateChatParticipantAdmin#b6901959 chat_id:int user_id:int is_admin:Bool version:int = Update; updateChatParticipantAdmin#b6901959 chat_id:int user_id:int is_admin:Bool version:int = Update;
updateNewStickerSet#688a30aa stickerset:messages.StickerSet = Update; updateNewStickerSet#688a30aa stickerset:messages.StickerSet = Update;
updateStickerSetsOrder#bb2d201 flags:# masks:flags.0?true order:Vector<long> = Update; updateStickerSetsOrder#bb2d201 flags:# masks:flags.0?true order:Vector<long> = Update;
@ -450,6 +448,7 @@ updateDialogUnreadMark#e16459c3 flags:# unread:flags.0?true peer:DialogPeer = Up
updateUserPinnedMessage#4c43da18 user_id:int id:int = Update; updateUserPinnedMessage#4c43da18 user_id:int id:int = Update;
updateChatPinnedMessage#22893b26 chat_id:int id:int = Update; updateChatPinnedMessage#22893b26 chat_id:int id:int = Update;
updateMessagePoll#aca1657b flags:# poll_id:long poll:flags.0?Poll results:PollResults = Update; updateMessagePoll#aca1657b flags:# poll_id:long poll:flags.0?Poll results:PollResults = Update;
updateChatDefaultBannedRights#54c01850 peer:Peer default_banned_rights:ChatBannedRights version: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;
@ -514,7 +513,7 @@ inputDocumentEmpty#72f0eaae = InputDocument;
inputDocument#1abfb575 id:long access_hash:long file_reference:bytes = InputDocument; inputDocument#1abfb575 id:long access_hash:long file_reference:bytes = InputDocument;
documentEmpty#36f8c871 id:long = Document; documentEmpty#36f8c871 id:long = Document;
document#59534e4c id:long access_hash:long file_reference:bytes date:int mime_type:string size:int thumb:PhotoSize dc_id:int attributes:Vector<DocumentAttribute> = Document; document#9ba29cc1 flags:# id:long access_hash:long file_reference:bytes date:int mime_type:string size:int thumbs:flags.0?Vector<PhotoSize> dc_id:int attributes:Vector<DocumentAttribute> = Document;
help.support#17c6b5f6 phone_number:string user:User = help.Support; help.support#17c6b5f6 phone_number:string user:User = help.Support;
@ -676,8 +675,8 @@ channelMessagesFilter#cd77d957 flags:# exclude_new_messages:flags.1?true ranges:
channelParticipant#15ebac1d user_id:int date:int = ChannelParticipant; channelParticipant#15ebac1d user_id:int date:int = ChannelParticipant;
channelParticipantSelf#a3289a6d user_id:int inviter_id:int date:int = ChannelParticipant; channelParticipantSelf#a3289a6d user_id:int inviter_id:int date:int = ChannelParticipant;
channelParticipantCreator#e3e2e1f9 user_id:int = ChannelParticipant; channelParticipantCreator#e3e2e1f9 user_id:int = ChannelParticipant;
channelParticipantAdmin#a82fa898 flags:# can_edit:flags.0?true user_id:int inviter_id:int promoted_by:int date:int admin_rights:ChannelAdminRights = ChannelParticipant; channelParticipantAdmin#5daa6e23 flags:# can_edit:flags.0?true self:flags.1?true user_id:int inviter_id:flags.1?int promoted_by:int date:int admin_rights:ChatAdminRights = ChannelParticipant;
channelParticipantBanned#222c1886 flags:# left:flags.0?true user_id:int kicked_by:int date:int banned_rights:ChannelBannedRights = ChannelParticipant; channelParticipantBanned#1c0facaf flags:# left:flags.0?true user_id:int kicked_by:int date:int banned_rights:ChatBannedRights = ChannelParticipant;
channelParticipantsRecent#de3f3c79 = ChannelParticipantsFilter; channelParticipantsRecent#de3f3c79 = ChannelParticipantsFilter;
channelParticipantsAdmins#b4608969 = ChannelParticipantsFilter; channelParticipantsAdmins#b4608969 = ChannelParticipantsFilter;
@ -685,6 +684,7 @@ channelParticipantsKicked#a3b54985 q:string = ChannelParticipantsFilter;
channelParticipantsBots#b0d1865b = ChannelParticipantsFilter; channelParticipantsBots#b0d1865b = ChannelParticipantsFilter;
channelParticipantsBanned#1427a5e1 q:string = ChannelParticipantsFilter; channelParticipantsBanned#1427a5e1 q:string = ChannelParticipantsFilter;
channelParticipantsSearch#656ac4b q:string = ChannelParticipantsFilter; channelParticipantsSearch#656ac4b q:string = ChannelParticipantsFilter;
channelParticipantsContacts#bb6ae88d q:string = ChannelParticipantsFilter;
channels.channelParticipants#f56ee2a8 count:int participants:Vector<ChannelParticipant> users:Vector<User> = channels.ChannelParticipants; channels.channelParticipants#f56ee2a8 count:int participants:Vector<ChannelParticipant> users:Vector<User> = channels.ChannelParticipants;
channels.channelParticipantsNotModified#f0173fe9 = channels.ChannelParticipants; channels.channelParticipantsNotModified#f0173fe9 = channels.ChannelParticipants;
@ -921,10 +921,6 @@ langPackDifference#f385c1f6 lang_code:string from_version:int version:int string
langPackLanguage#eeca5ce3 flags:# official:flags.0?true rtl:flags.2?true beta:flags.3?true name:string native_name:string lang_code:string base_lang_code:flags.1?string plural_code:string strings_count:int translated_count:int translations_url:string = LangPackLanguage; langPackLanguage#eeca5ce3 flags:# official:flags.0?true rtl:flags.2?true beta:flags.3?true name:string native_name:string lang_code:string base_lang_code:flags.1?string plural_code:string strings_count:int translated_count:int translations_url:string = LangPackLanguage;
channelAdminRights#5d7ceba5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true invite_link:flags.6?true pin_messages:flags.7?true add_admins:flags.9?true manage_call:flags.10?true = ChannelAdminRights;
channelBannedRights#58cf4249 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true until_date:int = ChannelBannedRights;
channelAdminLogEventActionChangeTitle#e6dfb825 prev_value:string new_value:string = ChannelAdminLogEventAction; channelAdminLogEventActionChangeTitle#e6dfb825 prev_value:string new_value:string = ChannelAdminLogEventAction;
channelAdminLogEventActionChangeAbout#55188a2e prev_value:string new_value:string = ChannelAdminLogEventAction; channelAdminLogEventActionChangeAbout#55188a2e prev_value:string new_value:string = ChannelAdminLogEventAction;
channelAdminLogEventActionChangeUsername#6a4afc38 prev_value:string new_value:string = ChannelAdminLogEventAction; channelAdminLogEventActionChangeUsername#6a4afc38 prev_value:string new_value:string = ChannelAdminLogEventAction;
@ -941,6 +937,8 @@ channelAdminLogEventActionParticipantToggleBan#e6d83d7e prev_participant:Channel
channelAdminLogEventActionParticipantToggleAdmin#d5676710 prev_participant:ChannelParticipant new_participant:ChannelParticipant = ChannelAdminLogEventAction; channelAdminLogEventActionParticipantToggleAdmin#d5676710 prev_participant:ChannelParticipant new_participant:ChannelParticipant = ChannelAdminLogEventAction;
channelAdminLogEventActionChangeStickerSet#b1c3caa7 prev_stickerset:InputStickerSet new_stickerset:InputStickerSet = ChannelAdminLogEventAction; channelAdminLogEventActionChangeStickerSet#b1c3caa7 prev_stickerset:InputStickerSet new_stickerset:InputStickerSet = ChannelAdminLogEventAction;
channelAdminLogEventActionTogglePreHistoryHidden#5f5c95f1 new_value:Bool = ChannelAdminLogEventAction; channelAdminLogEventActionTogglePreHistoryHidden#5f5c95f1 new_value:Bool = ChannelAdminLogEventAction;
channelAdminLogEventActionDefaultBannedRights#2df5fc0a prev_banned_rights:ChatBannedRights new_banned_rights:ChatBannedRights = ChannelAdminLogEventAction;
channelAdminLogEventActionStopPoll#8f079643 message:Message = ChannelAdminLogEventAction;
channelAdminLogEvent#3b5a3e40 id:long date:int user_id:int action:ChannelAdminLogEventAction = ChannelAdminLogEvent; channelAdminLogEvent#3b5a3e40 id:long date:int user_id:int action:ChannelAdminLogEventAction = ChannelAdminLogEvent;
@ -1104,6 +1102,16 @@ chatOnlines#f041e250 onlines:int = ChatOnlines;
statsURL#47a971e0 url:string = StatsURL; statsURL#47a971e0 url:string = StatsURL;
chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true = ChatAdminRights;
chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true until_date:int = ChatBannedRights;
inputWallPaper#e630b979 id:long access_hash:long = InputWallPaper;
inputWallPaperSlug#72091c80 slug:string = InputWallPaper;
account.wallPapersNotModified#1c199183 = account.WallPapers;
account.wallPapers#702b65a9 hash:int wallpapers:Vector<WallPaper> = account.WallPapers;
---functions--- ---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@ -1137,7 +1145,7 @@ account.getNotifySettings#12b3ad31 peer:InputNotifyPeer = PeerNotifySettings;
account.resetNotifySettings#db7e1747 = Bool; account.resetNotifySettings#db7e1747 = Bool;
account.updateProfile#78515775 flags:# first_name:flags.0?string last_name:flags.1?string about:flags.2?string = User; account.updateProfile#78515775 flags:# first_name:flags.0?string last_name:flags.1?string about:flags.2?string = User;
account.updateStatus#6628562c offline:Bool = Bool; account.updateStatus#6628562c offline:Bool = Bool;
account.getWallPapers#c04cfac2 = Vector<WallPaper>; account.getWallPapers#aabb1763 hash:int = account.WallPapers;
account.reportPeer#ae189d5f peer:InputPeer reason:ReportReason = Bool; account.reportPeer#ae189d5f peer:InputPeer reason:ReportReason = Bool;
account.checkUsername#2714d86c username:string = Bool; account.checkUsername#2714d86c username:string = Bool;
account.updateUsername#3e0bdd7c username:string = User; account.updateUsername#3e0bdd7c username:string = User;
@ -1178,6 +1186,10 @@ account.cancelPasswordEmail#c1cbd5b6 = Bool;
account.getContactSignUpNotification#9f07c728 = Bool; account.getContactSignUpNotification#9f07c728 = Bool;
account.setContactSignUpNotification#cff43f61 silent:Bool = Bool; account.setContactSignUpNotification#cff43f61 silent:Bool = Bool;
account.getNotifyExceptions#53577479 flags:# compare_sound:flags.1?true peer:flags.0?InputNotifyPeer = Updates; account.getNotifyExceptions#53577479 flags:# compare_sound:flags.1?true peer:flags.0?InputNotifyPeer = Updates;
account.uploadWallPaper#c7ba9b4d file:InputFile mime_type:string = WallPaper;
account.getWallPaper#fc8ddbea wallpaper:InputWallPaper = WallPaper;
account.saveWallPaper#189581b3 wallpaper:InputWallPaper unsave:Bool = Bool;
account.installWallPaper#4a0378ce wallpaper:InputWallPaper = Bool;
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>; users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
users.getFullUser#ca30a5b1 id:InputUser = UserFull; users.getFullUser#ca30a5b1 id:InputUser = UserFull;
@ -1239,7 +1251,7 @@ messages.readMessageContents#36a73f77 id:Vector<int> = messages.AffectedMessages
messages.getStickers#43d4f2c emoticon:string hash:int = messages.Stickers; messages.getStickers#43d4f2c emoticon:string hash:int = messages.Stickers;
messages.getAllStickers#1c9618b1 hash:int = messages.AllStickers; messages.getAllStickers#1c9618b1 hash:int = messages.AllStickers;
messages.getWebPagePreview#8b68b0cc flags:# message:string entities:flags.3?Vector<MessageEntity> = MessageMedia; messages.getWebPagePreview#8b68b0cc flags:# message:string entities:flags.3?Vector<MessageEntity> = MessageMedia;
messages.exportChatInvite#7d885289 chat_id:int = ExportedChatInvite; messages.exportChatInvite#df7534c peer:InputPeer = ExportedChatInvite;
messages.checkChatInvite#3eadb1bb hash:string = ChatInvite; messages.checkChatInvite#3eadb1bb hash:string = ChatInvite;
messages.importChatInvite#6c50051c hash:string = Updates; messages.importChatInvite#6c50051c hash:string = Updates;
messages.getStickerSet#2619a90e stickerset:InputStickerSet = messages.StickerSet; messages.getStickerSet#2619a90e stickerset:InputStickerSet = messages.StickerSet;
@ -1247,7 +1259,6 @@ messages.installStickerSet#c78fe460 stickerset:InputStickerSet archived:Bool = m
messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool; messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool;
messages.startBot#e6df7378 bot:InputUser peer:InputPeer random_id:long start_param:string = Updates; messages.startBot#e6df7378 bot:InputUser peer:InputPeer random_id:long start_param:string = Updates;
messages.getMessagesViews#c4c8a55d peer:InputPeer id:Vector<int> increment:Bool = Vector<int>; messages.getMessagesViews#c4c8a55d peer:InputPeer id:Vector<int> increment:Bool = Vector<int>;
messages.toggleChatAdmins#ec8bd9e1 chat_id:int enabled:Bool = Updates;
messages.editChatAdmin#a9e69f2e chat_id:int user_id:InputUser is_admin:Bool = Bool; messages.editChatAdmin#a9e69f2e chat_id:int user_id:InputUser is_admin:Bool = Bool;
messages.migrateChat#15a3b8e3 chat_id:int = Updates; messages.migrateChat#15a3b8e3 chat_id:int = Updates;
messages.searchGlobal#9e3cacb0 q:string offset_date:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; messages.searchGlobal#9e3cacb0 q:string offset_date:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
@ -1306,6 +1317,8 @@ messages.sendVote#10ea6184 peer:InputPeer msg_id:int options:Vector<bytes> = Upd
messages.getPollResults#73bb643b peer:InputPeer msg_id:int = Updates; messages.getPollResults#73bb643b peer:InputPeer msg_id:int = Updates;
messages.getOnlines#6e2be050 peer:InputPeer = ChatOnlines; messages.getOnlines#6e2be050 peer:InputPeer = ChatOnlines;
messages.getStatsURL#83f6c0cd peer:InputPeer = StatsURL; messages.getStatsURL#83f6c0cd peer:InputPeer = StatsURL;
messages.editChatAbout#def60797 peer:InputPeer about:string = Bool;
messages.editChatDefaultBannedRights#a5866b41 peer:InputPeer banned_rights:ChatBannedRights = 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;
@ -1355,8 +1368,7 @@ channels.getParticipant#546dd7a6 channel:InputChannel user_id:InputUser = channe
channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats; channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats;
channels.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull; channels.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull;
channels.createChannel#f4893d7f flags:# broadcast:flags.0?true megagroup:flags.1?true title:string about:string = Updates; channels.createChannel#f4893d7f flags:# broadcast:flags.0?true megagroup:flags.1?true title:string about:string = Updates;
channels.editAbout#13e27f1e channel:InputChannel about:string = Bool; channels.editAdmin#70f893ba channel:InputChannel user_id:InputUser admin_rights:ChatAdminRights = Updates;
channels.editAdmin#20b88214 channel:InputChannel user_id:InputUser admin_rights:ChannelAdminRights = Updates;
channels.editTitle#566decd0 channel:InputChannel title:string = Updates; channels.editTitle#566decd0 channel:InputChannel title:string = Updates;
channels.editPhoto#f12e57c9 channel:InputChannel photo:InputChatPhoto = Updates; channels.editPhoto#f12e57c9 channel:InputChannel photo:InputChatPhoto = Updates;
channels.checkUsername#10e6bd2c channel:InputChannel username:string = Bool; channels.checkUsername#10e6bd2c channel:InputChannel username:string = Bool;
@ -1364,13 +1376,11 @@ channels.updateUsername#3514b3de channel:InputChannel username:string = Bool;
channels.joinChannel#24b524c5 channel:InputChannel = Updates; channels.joinChannel#24b524c5 channel:InputChannel = Updates;
channels.leaveChannel#f836aa95 channel:InputChannel = Updates; channels.leaveChannel#f836aa95 channel:InputChannel = Updates;
channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = Updates; channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = Updates;
channels.exportInvite#c7560885 channel:InputChannel = ExportedChatInvite;
channels.deleteChannel#c0111fe3 channel:InputChannel = Updates; channels.deleteChannel#c0111fe3 channel:InputChannel = Updates;
channels.toggleInvites#49609307 channel:InputChannel enabled:Bool = Updates;
channels.exportMessageLink#ceb77163 channel:InputChannel id:int grouped:Bool = ExportedMessageLink; channels.exportMessageLink#ceb77163 channel:InputChannel id:int grouped:Bool = ExportedMessageLink;
channels.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates; channels.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates;
channels.getAdminedPublicChannels#8d8d82d7 = messages.Chats; channels.getAdminedPublicChannels#8d8d82d7 = messages.Chats;
channels.editBanned#bfd915cd channel:InputChannel user_id:InputUser banned_rights:ChannelBannedRights = Updates; channels.editBanned#72796912 channel:InputChannel user_id:InputUser banned_rights:ChatBannedRights = Updates;
channels.getAdminLog#33ddf480 flags:# channel:InputChannel q:string events_filter:flags.0?ChannelAdminLogEventsFilter admins:flags.1?Vector<InputUser> max_id:long min_id:long limit:int = channels.AdminLogResults; channels.getAdminLog#33ddf480 flags:# channel:InputChannel q:string events_filter:flags.0?ChannelAdminLogEventsFilter admins:flags.1?Vector<InputUser> max_id:long min_id:long limit:int = channels.AdminLogResults;
channels.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet = Bool; channels.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet = Bool;
channels.readMessageContents#eab5dc38 channel:InputChannel id:Vector<int> = Bool; channels.readMessageContents#eab5dc38 channel:InputChannel id:Vector<int> = Bool;
@ -1408,4 +1418,4 @@ langpack.getDifference#9d51e814 lang_code:string from_version:int = LangPackDiff
langpack.getLanguages#42c6978f lang_pack:string = Vector<LangPackLanguage>; langpack.getLanguages#42c6978f lang_pack:string = Vector<LangPackLanguage>;
langpack.getLanguage#6a596502 lang_pack:string lang_code:string = LangPackLanguage; langpack.getLanguage#6a596502 lang_pack:string lang_code:string = LangPackLanguage;
// LAYER 92 // LAYER 93

View File

@ -1376,8 +1376,8 @@ void ApiWrap::applyLastParticipantsList(
channel->mgInfo->lastParticipantsStatus = MegagroupInfo::LastParticipantsUpToDate; channel->mgInfo->lastParticipantsStatus = MegagroupInfo::LastParticipantsUpToDate;
auto botStatus = channel->mgInfo->botStatus; auto botStatus = channel->mgInfo->botStatus;
const auto emptyAdminRights = MTP_channelAdminRights(MTP_flags(0)); const auto emptyAdminRights = MTP_chatAdminRights(MTP_flags(0));
const auto emptyRestrictedRights = MTP_channelBannedRights( const auto emptyRestrictedRights = MTP_chatBannedRights(
MTP_flags(0), MTP_flags(0),
MTP_int(0)); MTP_int(0));
for (const auto &p : list) { for (const auto &p : list) {
@ -1406,11 +1406,11 @@ void ApiWrap::applyLastParticipantsList(
} }
if (!base::contains(channel->mgInfo->lastParticipants, user)) { if (!base::contains(channel->mgInfo->lastParticipants, user)) {
channel->mgInfo->lastParticipants.push_back(user); channel->mgInfo->lastParticipants.push_back(user);
if (adminRights.c_channelAdminRights().vflags.v) { if (adminRights.c_chatAdminRights().vflags.v) {
channel->mgInfo->lastAdmins.emplace( channel->mgInfo->lastAdmins.emplace(
user, user,
MegagroupInfo::Admin{ adminRights, adminCanEdit }); MegagroupInfo::Admin{ adminRights, adminCanEdit });
} else if (restrictedRights.c_channelBannedRights().vflags.v != 0) { } else if (restrictedRights.c_chatBannedRights().vflags.v != 0) {
channel->mgInfo->lastRestricted.emplace( channel->mgInfo->lastRestricted.emplace(
user, user,
MegagroupInfo::Restricted{ restrictedRights }); MegagroupInfo::Restricted{ restrictedRights });
@ -1552,7 +1552,9 @@ void ApiWrap::requestSelfParticipant(ChannelData *channel) {
} break; } break;
case mtpc_channelParticipantAdmin: { case mtpc_channelParticipantAdmin: {
auto &d = p.vparticipant.c_channelParticipantAdmin(); auto &d = p.vparticipant.c_channelParticipantAdmin();
channel->inviter = d.vinviter_id.v; channel->inviter = (d.is_self() && d.has_inviter_id())
? d.vinviter_id.v
: 0;
channel->inviteDate = d.vdate.v; channel->inviteDate = d.vdate.v;
} break; } break;
} }
@ -1582,7 +1584,7 @@ void ApiWrap::kickParticipant(
void ApiWrap::kickParticipant( void ApiWrap::kickParticipant(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
not_null<UserData*> user, not_null<UserData*> user,
const MTPChannelBannedRights &currentRights) { const MTPChatBannedRights &currentRights) {
const auto kick = KickRequest(channel, user); const auto kick = KickRequest(channel, user);
if (_kickRequests.contains(kick)) return; if (_kickRequests.contains(kick)) return;
@ -1614,7 +1616,7 @@ void ApiWrap::unblockParticipant(
const auto requestId = request(MTPchannels_EditBanned( const auto requestId = request(MTPchannels_EditBanned(
channel->inputChannel, channel->inputChannel,
user->inputUser, user->inputUser,
MTP_channelBannedRights(MTP_flags(0), MTP_int(0)) MTP_chatBannedRights(MTP_flags(0), MTP_int(0))
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
applyUpdates(result); applyUpdates(result);
@ -1947,36 +1949,26 @@ void ApiWrap::exportInviteLink(not_null<PeerData*> peer) {
return; return;
} }
const auto sendRequest = [this, peer] { const auto requestId = [&] {
const auto exportFail = [this, peer](const RPCError &error) { return request(MTPmessages_ExportChatInvite(
peer->input
)).done([=](const MTPExportedChatInvite &result) {
_exportInviteRequests.erase(peer); _exportInviteRequests.erase(peer);
}; const auto link = (result.type() == mtpc_chatInviteExported)
if (const auto chat = peer->asChat()) { ? qs(result.c_chatInviteExported().vlink)
return request(MTPmessages_ExportChatInvite( : QString();
chat->inputChat if (const auto chat = peer->asChat()) {
)).done([=](const MTPExportedChatInvite &result) { chat->setInviteLink(link);
_exportInviteRequests.erase(chat); } else if (const auto channel = peer->asChannel()) {
chat->setInviteLink( channel->setInviteLink(link);
(result.type() == mtpc_chatInviteExported } else {
? qs(result.c_chatInviteExported().vlink) Unexpected("Peer in ApiWrap::exportInviteLink.");
: QString())); }
}).fail(exportFail).send(); }).fail([=](const RPCError &error) {
} else if (const auto channel = peer->asChannel()) { _exportInviteRequests.erase(peer);
return request(MTPchannels_ExportInvite( }).send();
channel->inputChannel }();
)).done([=](const MTPExportedChatInvite &result) { _exportInviteRequests.emplace(peer, requestId);
_exportInviteRequests.erase(channel);
channel->setInviteLink(
(result.type() == mtpc_chatInviteExported
? qs(result.c_chatInviteExported().vlink)
: QString()));
}).fail(exportFail).send();
}
return 0;
};
if (const auto requestId = sendRequest()) {
_exportInviteRequests.emplace(peer, requestId);
}
} }
void ApiWrap::requestNotifySettings(const MTPInputNotifyPeer &peer) { void ApiWrap::requestNotifySettings(const MTPInputNotifyPeer &peer) {
@ -3653,17 +3645,18 @@ void ApiWrap::editChatAdmins(
_chatAdminsToSave.emplace(chat, std::move(admins)); _chatAdminsToSave.emplace(chat, std::move(admins));
} }
auto requestId = request(MTPmessages_ToggleChatAdmins(chat->inputChat, MTP_bool(adminsEnabled))).done([this, chat](const MTPUpdates &updates) { // #TODO groups
_chatAdminsEnabledRequests.remove(chat); //auto requestId = request(MTPmessages_ToggleChatAdmins(chat->inputChat, MTP_bool(adminsEnabled))).done([this, chat](const MTPUpdates &updates) {
applyUpdates(updates); // _chatAdminsEnabledRequests.remove(chat);
saveChatAdmins(chat); // applyUpdates(updates);
}).fail([this, chat](const RPCError &error) { // saveChatAdmins(chat);
_chatAdminsEnabledRequests.remove(chat); //}).fail([this, chat](const RPCError &error) {
if (error.type() == qstr("CHAT_NOT_MODIFIED")) { // _chatAdminsEnabledRequests.remove(chat);
saveChatAdmins(chat); // if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
} // saveChatAdmins(chat);
}).send(); // }
_chatAdminsEnabledRequests.emplace(chat, requestId); //}).send();
//_chatAdminsEnabledRequests.emplace(chat, requestId);
} }
void ApiWrap::saveChatAdmins(not_null<ChatData*> chat) { void ApiWrap::saveChatAdmins(not_null<ChatData*> chat) {

View File

@ -145,7 +145,7 @@ public:
void kickParticipant( void kickParticipant(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
not_null<UserData*> user, not_null<UserData*> user,
const MTPChannelBannedRights &currentRights); const MTPChatBannedRights &currentRights);
void unblockParticipant( void unblockParticipant(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
not_null<UserData*> user); not_null<UserData*> user);

View File

@ -156,7 +156,8 @@ namespace App {
case mtpc_chatParticipants: { case mtpc_chatParticipants: {
const auto &d(p.c_chatParticipants()); const auto &d(p.c_chatParticipants());
chat = App::chat(d.vchat_id.v); chat = App::chat(d.vchat_id.v);
auto canEdit = chat->canEdit(); // #TODO groups
auto canEdit = chat->canEditInformation();
if (!requestBotInfos || chat->version <= d.vversion.v) { // !requestBotInfos is true on getFullChat result if (!requestBotInfos || chat->version <= d.vversion.v) { // !requestBotInfos is true on getFullChat result
chat->version = d.vversion.v; chat->version = d.vversion.v;
auto &v = d.vparticipants.v; auto &v = d.vparticipants.v;
@ -166,7 +167,8 @@ namespace App {
: (chat->participants.begin()->second + 1); : (chat->participants.begin()->second + 1);
chat->invitedByMe.clear(); chat->invitedByMe.clear();
chat->admins.clear(); chat->admins.clear();
chat->removeFlags(MTPDchat::Flag::f_admin); // #TODO groups
//chat->removeFlags(MTPDchat::Flag::f_admin);
for (auto i = v.cbegin(), e = v.cend(); i != e; ++i) { for (auto i = v.cbegin(), e = v.cend(); i != e; ++i) {
int32 uid = 0, inviter = 0; int32 uid = 0, inviter = 0;
switch (i->type()) { switch (i->type()) {
@ -197,7 +199,8 @@ namespace App {
if (i->type() == mtpc_chatParticipantAdmin) { if (i->type() == mtpc_chatParticipantAdmin) {
chat->admins.insert(user); chat->admins.insert(user);
if (user->isSelf()) { if (user->isSelf()) {
chat->addFlags(MTPDchat::Flag::f_admin); // #TODO groups
// chat->addFlags(MTPDchat::Flag::f_admin);
} }
} }
} else { } else {
@ -232,7 +235,8 @@ namespace App {
} }
} }
} }
if (canEdit != chat->canEdit()) { // #TODO groups
if (canEdit != chat->canEditInformation()) {
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::ChatCanEdit); Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::ChatCanEdit);
} }
} break; } break;
@ -284,7 +288,8 @@ namespace App {
Auth().api().requestPeer(chat); Auth().api().requestPeer(chat);
} else if (chat->version <= d.vversion.v && chat->count > 0) { } else if (chat->version <= d.vversion.v && chat->count > 0) {
chat->version = d.vversion.v; chat->version = d.vversion.v;
auto canEdit = chat->canEdit(); // #TODO groups
auto canEdit = chat->canEditInformation();
const auto user = App::userLoaded(d.vuser_id.v); const auto user = App::userLoaded(d.vuser_id.v);
if (user) { if (user) {
if (chat->participants.empty()) { if (chat->participants.empty()) {
@ -299,7 +304,8 @@ namespace App {
chat->invitedByMe.remove(user); chat->invitedByMe.remove(user);
chat->admins.remove(user); chat->admins.remove(user);
if (user->isSelf()) { if (user->isSelf()) {
chat->removeFlags(MTPDchat::Flag::f_admin); // #TODO groups
// chat->removeFlags(MTPDchat::Flag::f_admin);
} }
History *h = App::historyLoaded(chat->id); History *h = App::historyLoaded(chat->id);
@ -325,39 +331,14 @@ namespace App {
chat->invalidateParticipants(); chat->invalidateParticipants();
chat->count--; chat->count--;
} }
if (canEdit != chat->canEdit()) { // #TODO groups
if (canEdit != chat->canEditInformation()) {
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::ChatCanEdit); Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::ChatCanEdit);
} }
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::MembersChanged); Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::MembersChanged);
} }
} }
void feedChatAdmins(const MTPDupdateChatAdmins &d) {
auto chat = App::chat(d.vchat_id.v);
if (chat->version <= d.vversion.v) {
auto wasCanEdit = chat->canEdit();
auto badVersion = (chat->version + 1 < d.vversion.v);
chat->version = d.vversion.v;
if (mtpIsTrue(d.venabled)) {
chat->addFlags(MTPDchat::Flag::f_admins_enabled);
} else {
chat->removeFlags(MTPDchat::Flag::f_admins_enabled);
}
if (badVersion || mtpIsTrue(d.venabled)) {
chat->invalidateParticipants();
Auth().api().requestPeer(chat);
}
if (wasCanEdit != chat->canEdit()) {
Notify::peerUpdatedDelayed(
chat,
Notify::PeerUpdate::Flag::ChatCanEdit);
}
Notify::peerUpdatedDelayed(
chat,
Notify::PeerUpdate::Flag::AdminsChanged);
}
}
void feedParticipantAdmin(const MTPDupdateChatParticipantAdmin &d) { void feedParticipantAdmin(const MTPDupdateChatParticipantAdmin &d) {
ChatData *chat = App::chat(d.vchat_id.v); ChatData *chat = App::chat(d.vchat_id.v);
if (chat->version + 1 < d.vversion.v) { if (chat->version + 1 < d.vversion.v) {
@ -366,12 +347,14 @@ namespace App {
Auth().api().requestPeer(chat); Auth().api().requestPeer(chat);
} else if (chat->version <= d.vversion.v && chat->count > 0) { } else if (chat->version <= d.vversion.v && chat->count > 0) {
chat->version = d.vversion.v; chat->version = d.vversion.v;
auto canEdit = chat->canEdit(); // #TODO groups
auto canEdit = chat->canEditInformation();
UserData *user = App::userLoaded(d.vuser_id.v); UserData *user = App::userLoaded(d.vuser_id.v);
if (user) { if (user) {
if (mtpIsTrue(d.vis_admin)) { if (mtpIsTrue(d.vis_admin)) {
if (user->isSelf()) { if (user->isSelf()) {
chat->addFlags(MTPDchat::Flag::f_admin); // #TODO groups
// chat->addFlags(MTPDchat::Flag::f_admin);
} }
if (chat->noParticipantInfo()) { if (chat->noParticipantInfo()) {
Auth().api().requestFullPeer(chat); Auth().api().requestFullPeer(chat);
@ -380,14 +363,15 @@ namespace App {
} }
} else { } else {
if (user->isSelf()) { if (user->isSelf()) {
chat->removeFlags(MTPDchat::Flag::f_admin); // #TODO groups
//chat->removeFlags(MTPDchat::Flag::f_admin);
} }
chat->admins.remove(user); chat->admins.remove(user);
} }
} else { } else {
chat->invalidateParticipants(); chat->invalidateParticipants();
} }
if (canEdit != chat->canEdit()) { if (canEdit != chat->canEditInformation()) {
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::ChatCanEdit); Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::ChatCanEdit);
} }
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::AdminsChanged); Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::AdminsChanged);

View File

@ -74,7 +74,6 @@ namespace App {
void feedParticipants(const MTPChatParticipants &p, bool requestBotInfos); void feedParticipants(const MTPChatParticipants &p, bool requestBotInfos);
void feedParticipantAdd(const MTPDupdateChatParticipantAdd &d); void feedParticipantAdd(const MTPDupdateChatParticipantAdd &d);
void feedParticipantDelete(const MTPDupdateChatParticipantDelete &d); void feedParticipantDelete(const MTPDupdateChatParticipantDelete &d);
void feedChatAdmins(const MTPDupdateChatAdmins &d);
void feedParticipantAdmin(const MTPDupdateChatParticipantAdmin &d); void feedParticipantAdmin(const MTPDupdateChatParticipantAdmin &d);
bool checkEntitiesAndViewsUpdate(const MTPDmessage &m); // returns true if item found and it is not detached bool checkEntitiesAndViewsUpdate(const MTPDmessage &m); // returns true if item found and it is not detached
void updateEditedMessage(const MTPMessage &m); void updateEditedMessage(const MTPMessage &m);

View File

@ -96,7 +96,7 @@ void ShowAddParticipantsError(
auto box = Box<EditAdminBox>( auto box = Box<EditAdminBox>(
channel, channel,
user, user,
MTP_channelAdminRights(MTP_flags(0))); MTP_chatAdminRights(MTP_flags(0)));
box->setSaveCallback(saveCallback); box->setSaveCallback(saveCallback);
*weak = Ui::show(std::move(box)); *weak = Ui::show(std::move(box));
}; };
@ -642,9 +642,9 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio
Auth().api().uploadPeerPhoto(channel, std::move(image)); Auth().api().uploadPeerPhoto(channel, std::move(image));
} }
_createdChannel = channel; _createdChannel = channel;
_creationRequestId = request( _creationRequestId = request(MTPmessages_ExportChatInvite(
MTPchannels_ExportInvite(_createdChannel->inputChannel) _createdChannel->input
).done([this](const MTPExportedChatInvite &result) { )).done([=](const MTPExportedChatInvite &result) {
_creationRequestId = 0; _creationRequestId = 0;
if (result.type() == mtpc_chatInviteExported) { if (result.type() == mtpc_chatInviteExported) {
auto link = qs(result.c_chatInviteExported().vlink); auto link = qs(result.c_chatInviteExported().vlink);
@ -1324,7 +1324,12 @@ void EditChannelBox::save() {
if (_sentTitle == _channel->name) { if (_sentTitle == _channel->name) {
saveDescription(); saveDescription();
} else { } else {
_saveTitleRequestId = MTP::send(MTPchannels_EditTitle(_channel->inputChannel, MTP_string(_sentTitle)), rpcDone(&EditChannelBox::onSaveTitleDone), rpcFail(&EditChannelBox::onSaveFail)); _saveTitleRequestId = MTP::send(
MTPchannels_EditTitle(
_channel->inputChannel,
MTP_string(_sentTitle)),
rpcDone(&EditChannelBox::onSaveTitleDone),
rpcFail(&EditChannelBox::onSaveFail));
} }
} }
@ -1338,7 +1343,12 @@ void EditChannelBox::saveDescription() {
if (_sentDescription == _channel->about()) { if (_sentDescription == _channel->about()) {
saveSign(); saveSign();
} else { } else {
_saveDescriptionRequestId = MTP::send(MTPchannels_EditAbout(_channel->inputChannel, MTP_string(_sentDescription)), rpcDone(&EditChannelBox::onSaveDescriptionDone), rpcFail(&EditChannelBox::onSaveFail)); _saveDescriptionRequestId = MTP::send(
MTPmessages_EditChatAbout(
_channel->input,
MTP_string(_sentDescription)),
rpcDone(&EditChannelBox::onSaveDescriptionDone),
rpcFail(&EditChannelBox::onSaveFail));
} }
} }
@ -1346,16 +1356,22 @@ void EditChannelBox::saveSign() {
if (!canEditSignatures() || _channel->addsSignature() == _sign->checked()) { if (!canEditSignatures() || _channel->addsSignature() == _sign->checked()) {
saveInvites(); saveInvites();
} else { } else {
_saveSignRequestId = MTP::send(MTPchannels_ToggleSignatures(_channel->inputChannel, MTP_bool(_sign->checked())), rpcDone(&EditChannelBox::onSaveSignDone), rpcFail(&EditChannelBox::onSaveFail)); _saveSignRequestId = MTP::send(
MTPchannels_ToggleSignatures(
_channel->inputChannel,
MTP_bool(_sign->checked())),
rpcDone(&EditChannelBox::onSaveSignDone),
rpcFail(&EditChannelBox::onSaveFail));
} }
} }
void EditChannelBox::saveInvites() { void EditChannelBox::saveInvites() {
if (!canEditInvites() || _channel->anyoneCanAddMembers() == (_inviteGroup->value() == Invites::Everybody)) { // #TODO groups
closeBox(); //if (!canEditInvites() || _channel->anyoneCanAddMembers() == (_inviteGroup->value() == Invites::Everybody)) {
} else { // closeBox();
_saveInvitesRequestId = MTP::send(MTPchannels_ToggleInvites(_channel->inputChannel, MTP_bool(_inviteGroup->value() == Invites::Everybody)), rpcDone(&EditChannelBox::onSaveInvitesDone), rpcFail(&EditChannelBox::onSaveFail)); //} else {
} // _saveInvitesRequestId = MTP::send(MTPchannels_ToggleInvites(_channel->inputChannel, MTP_bool(_inviteGroup->value() == Invites::Everybody)), rpcDone(&EditChannelBox::onSaveInvitesDone), rpcFail(&EditChannelBox::onSaveFail));
//}
} }
bool EditChannelBox::onSaveFail(const RPCError &error, mtpRequestId req) { bool EditChannelBox::onSaveFail(const RPCError &error, mtpRequestId req) {

View File

@ -18,7 +18,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_overview.h" #include "styles/style_overview.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
class BackgroundBox::Inner : public TWidget, public RPCSender, private base::Subscriber { class BackgroundBox::Inner
: public Ui::RpWidget
, private MTP::Sender
, private base::Subscriber {
public: public:
Inner(QWidget *parent); Inner(QWidget *parent);
@ -35,7 +38,6 @@ protected:
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
private: private:
void gotWallpapers(const MTPVector<MTPWallPaper> &result);
void updateWallpapers(); void updateWallpapers();
Fn<void(int index)> _backgroundChosenCallback; Fn<void(int index)> _backgroundChosenCallback;
@ -75,12 +77,21 @@ void BackgroundBox::backgroundChosen(int index) {
closeBox(); closeBox();
} }
BackgroundBox::Inner::Inner(QWidget *parent) : TWidget(parent) BackgroundBox::Inner::Inner(QWidget *parent) : RpWidget(parent)
, _check(std::make_unique<Ui::RoundCheckbox>(st::overviewCheck, [this] { update(); })) { , _check(std::make_unique<Ui::RoundCheckbox>(st::overviewCheck, [=] { update(); })) {
_check->setChecked(true, Ui::RoundCheckbox::SetStyle::Fast); _check->setChecked(true, Ui::RoundCheckbox::SetStyle::Fast);
if (!Auth().data().wallpapersCount()) { if (!Auth().data().wallpapersCount()) {
resize(BackgroundsInRow * (st::backgroundSize.width() + st::backgroundPadding) + st::backgroundPadding, 2 * (st::backgroundSize.height() + st::backgroundPadding) + st::backgroundPadding); resize(BackgroundsInRow * (st::backgroundSize.width() + st::backgroundPadding) + st::backgroundPadding, 2 * (st::backgroundSize.height() + st::backgroundPadding) + st::backgroundPadding);
MTP::send(MTPaccount_GetWallPapers(), rpcDone(&Inner::gotWallpapers)); request(MTPaccount_GetWallPapers(
MTP_int(0)
)).done([=](const MTPaccount_WallPapers &result) {
result.match([&](const MTPDaccount_wallPapers &data) {
Auth().data().setWallpapers(data.vwallpapers.v);
updateWallpapers();
}, [&](const MTPDaccount_wallPapersNotModified &) {
LOG(("API Error: account.wallPapersNotModified received."));
});
}).send();
} else { } else {
updateWallpapers(); updateWallpapers();
} }
@ -94,11 +105,6 @@ BackgroundBox::Inner::Inner(QWidget *parent) : TWidget(parent)
setMouseTracking(true); setMouseTracking(true);
} }
void BackgroundBox::Inner::gotWallpapers(const MTPVector<MTPWallPaper> &result) {
Auth().data().setWallpapers(result.v);
updateWallpapers();
}
void BackgroundBox::Inner::updateWallpapers() { void BackgroundBox::Inner::updateWallpapers() {
_bgCount = Auth().data().wallpapersCount(); _bgCount = Auth().data().wallpapersCount();
_rows = _bgCount / BackgroundsInRow; _rows = _bgCount / BackgroundsInRow;

View File

@ -621,7 +621,7 @@ void DeleteMessagesBox::deleteAndClear() {
Auth().api().kickParticipant( Auth().api().kickParticipant(
_moderateInChannel, _moderateInChannel,
_moderateFrom, _moderateFrom,
MTP_channelBannedRights(MTP_flags(0), MTP_int(0))); MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
} }
if (_reportSpam->checked()) { if (_reportSpam->checked()) {
MTP::send( MTP::send(

View File

@ -202,26 +202,21 @@ void EditParticipantBox::resizeToContent() {
setDimensions(_inner->width(), qMin(_inner->height(), st::boxMaxListHeight)); setDimensions(_inner->width(), qMin(_inner->height(), st::boxMaxListHeight));
} }
EditAdminBox::EditAdminBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, const MTPChannelAdminRights &rights) : EditParticipantBox(nullptr, channel, user, (rights.c_channelAdminRights().vflags.v != 0)) EditAdminBox::EditAdminBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, const MTPChatAdminRights &rights) : EditParticipantBox(nullptr, channel, user, (rights.c_chatAdminRights().vflags.v != 0))
, _oldRights(rights) { , _oldRights(rights) {
auto dependency = [this](Flag dependent, Flag dependency) {
_dependencies.push_back(std::make_pair(dependent, dependency));
};
dependency(Flag::f_invite_link, Flag::f_invite_users); // invite_link <-> invite_users
dependency(Flag::f_invite_users, Flag::f_invite_link);
} }
MTPChannelAdminRights EditAdminBox::DefaultRights(not_null<ChannelData*> channel) { MTPChatAdminRights EditAdminBox::DefaultRights(not_null<ChannelData*> channel) {
auto defaultRights = channel->isMegagroup() auto defaultRights = channel->isMegagroup()
? (Flag::f_change_info | Flag::f_delete_messages | Flag::f_ban_users | Flag::f_invite_users | Flag::f_invite_link | Flag::f_pin_messages) ? (Flag::f_change_info | Flag::f_delete_messages | Flag::f_ban_users | Flag::f_invite_users | Flag::f_pin_messages)
: (Flag::f_change_info | Flag::f_post_messages | Flag::f_edit_messages | Flag::f_delete_messages | Flag::f_invite_users | Flag::f_invite_link); : (Flag::f_change_info | Flag::f_post_messages | Flag::f_edit_messages | Flag::f_delete_messages | Flag::f_invite_users);
return MTP_channelAdminRights(MTP_flags(defaultRights)); return MTP_chatAdminRights(MTP_flags(defaultRights));
} }
void EditAdminBox::prepare() { void EditAdminBox::prepare() {
EditParticipantBox::prepare(); EditParticipantBox::prepare();
auto hadRights = _oldRights.c_channelAdminRights().vflags.v; auto hadRights = _oldRights.c_chatAdminRights().vflags.v;
setTitle(langFactory(hadRights ? lng_rights_edit_admin : lng_channel_add_admin)); setTitle(langFactory(hadRights ? lng_rights_edit_admin : lng_channel_add_admin));
addControl(object_ptr<BoxContentDivider>(this), QMargins()); addControl(object_ptr<BoxContentDivider>(this), QMargins());
@ -231,7 +226,7 @@ void EditAdminBox::prepare() {
const auto filterByMyRights = canSave() const auto filterByMyRights = canSave()
&& !hadRights && !hadRights
&& !channel()->amCreator(); && !channel()->amCreator();
const auto prepareFlags = prepareRights.c_channelAdminRights().vflags.v const auto prepareFlags = prepareRights.c_chatAdminRights().vflags.v
& (filterByMyRights ? channel()->adminRights() : ~Flag(0)); & (filterByMyRights ? channel()->adminRights() : ~Flag(0));
auto addCheckbox = [&](Flags flags, const QString &text) { auto addCheckbox = [&](Flags flags, const QString &text) {
const auto checked = (prepareFlags & flags) != 0; const auto checked = (prepareFlags & flags) != 0;
@ -256,7 +251,7 @@ void EditAdminBox::prepare() {
addCheckbox(Flag::f_change_info, lang(lng_rights_group_info)); addCheckbox(Flag::f_change_info, lang(lng_rights_group_info));
addCheckbox(Flag::f_delete_messages, lang(lng_rights_group_delete)); addCheckbox(Flag::f_delete_messages, lang(lng_rights_group_delete));
addCheckbox(Flag::f_ban_users, lang(lng_rights_group_ban)); addCheckbox(Flag::f_ban_users, lang(lng_rights_group_ban));
addCheckbox(Flag::f_invite_users | Flag::f_invite_link, lang(channel()->anyoneCanAddMembers() ? lng_rights_group_invite_link : lng_rights_group_invite)); addCheckbox(Flag::f_invite_users, lang(channel()->anyoneCanAddMembers() ? lng_rights_group_invite_link : lng_rights_group_invite));
addCheckbox(Flag::f_pin_messages, lang(lng_rights_group_pin)); addCheckbox(Flag::f_pin_messages, lang(lng_rights_group_pin));
addCheckbox(Flag::f_add_admins, lang(lng_rights_add_admins)); addCheckbox(Flag::f_add_admins, lang(lng_rights_add_admins));
} else { } else {
@ -264,7 +259,7 @@ void EditAdminBox::prepare() {
addCheckbox(Flag::f_post_messages, lang(lng_rights_channel_post)); addCheckbox(Flag::f_post_messages, lang(lng_rights_channel_post));
addCheckbox(Flag::f_edit_messages, lang(lng_rights_channel_edit)); addCheckbox(Flag::f_edit_messages, lang(lng_rights_channel_edit));
addCheckbox(Flag::f_delete_messages, lang(lng_rights_channel_delete)); addCheckbox(Flag::f_delete_messages, lang(lng_rights_channel_delete));
addCheckbox(Flag::f_invite_users | Flag::f_invite_link, lang(lng_rights_group_invite)); addCheckbox(Flag::f_invite_users, lang(lng_rights_group_invite));
addCheckbox(Flag::f_add_admins, lang(lng_rights_add_admins)); addCheckbox(Flag::f_add_admins, lang(lng_rights_add_admins));
} }
@ -286,7 +281,7 @@ void EditAdminBox::prepare() {
if (!_saveCallback) { if (!_saveCallback) {
return; return;
} }
auto newFlags = MTPDchannelAdminRights::Flags(0); auto newFlags = MTPDchatAdminRights::Flags(0);
for (auto &&checkbox : _checkboxes) { for (auto &&checkbox : _checkboxes) {
if (checkbox.second->checked()) { if (checkbox.second->checked()) {
newFlags |= checkbox.first; newFlags |= checkbox.first;
@ -298,7 +293,7 @@ void EditAdminBox::prepare() {
// Leave only rights that we have so we could save them. // Leave only rights that we have so we could save them.
newFlags &= channel()->adminRights(); newFlags &= channel()->adminRights();
} }
_saveCallback(_oldRights, MTP_channelAdminRights(MTP_flags(newFlags))); _saveCallback(_oldRights, MTP_chatAdminRights(MTP_flags(newFlags)));
}); });
addButton(langFactory(lng_cancel), [this] { closeBox(); }); addButton(langFactory(lng_cancel), [this] { closeBox(); });
} else { } else {
@ -332,7 +327,7 @@ void EditAdminBox::refreshAboutAddAdminsText() {
resizeToContent(); resizeToContent();
} }
EditRestrictedBox::EditRestrictedBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, bool hasAdminRights, const MTPChannelBannedRights &rights) : EditParticipantBox(nullptr, channel, user, hasAdminRights) EditRestrictedBox::EditRestrictedBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, bool hasAdminRights, const MTPChatBannedRights &rights) : EditParticipantBox(nullptr, channel, user, hasAdminRights)
, _oldRights(rights) { , _oldRights(rights) {
auto dependency = [this](Flag dependent, Flag dependency) { auto dependency = [this](Flag dependent, Flag dependency) {
_dependencies.push_back(std::make_pair(dependent, dependency)); _dependencies.push_back(std::make_pair(dependent, dependency));
@ -357,11 +352,11 @@ void EditRestrictedBox::prepare() {
addControl(object_ptr<BoxContentDivider>(this), QMargins()); addControl(object_ptr<BoxContentDivider>(this), QMargins());
addControl(object_ptr<Ui::FlatLabel>(this, lang(lng_rights_user_restrictions_header), Ui::FlatLabel::InitType::Simple, st::rightsHeaderLabel), st::rightsHeaderMargin); addControl(object_ptr<Ui::FlatLabel>(this, lang(lng_rights_user_restrictions_header), Ui::FlatLabel::InitType::Simple, st::rightsHeaderLabel), st::rightsHeaderMargin);
auto prepareRights = (_oldRights.c_channelBannedRights().vflags.v ? _oldRights : DefaultRights(channel())); auto prepareRights = (_oldRights.c_chatBannedRights().vflags.v ? _oldRights : DefaultRights(channel()));
_until = prepareRights.c_channelBannedRights().vuntil_date.v; _until = prepareRights.c_chatBannedRights().vuntil_date.v;
auto addCheckbox = [&](Flags flags, const QString &text) { auto addCheckbox = [&](Flags flags, const QString &text) {
auto checked = (prepareRights.c_channelBannedRights().vflags.v & flags) == 0; auto checked = (prepareRights.c_chatBannedRights().vflags.v & flags) == 0;
auto control = addControl(object_ptr<Ui::Checkbox>(this, text, checked, st::rightsCheckbox, st::rightsToggle), st::rightsToggleMargin); auto control = addControl(object_ptr<Ui::Checkbox>(this, text, checked, st::rightsCheckbox, st::rightsToggle), st::rightsToggleMargin);
control->checkedChanges( control->checkedChanges(
) | rpl::start_with_next([=](bool checked) { ) | rpl::start_with_next([=](bool checked) {
@ -391,7 +386,7 @@ void EditRestrictedBox::prepare() {
if (!_saveCallback) { if (!_saveCallback) {
return; return;
} }
auto newFlags = MTPDchannelBannedRights::Flags(0); auto newFlags = MTPDchatBannedRights::Flags(0);
for (auto &&checkbox : _checkboxes) { for (auto &&checkbox : _checkboxes) {
if (checkbox.second->checked()) { if (checkbox.second->checked()) {
newFlags &= ~checkbox.first; newFlags &= ~checkbox.first;
@ -399,7 +394,7 @@ void EditRestrictedBox::prepare() {
newFlags |= checkbox.first; newFlags |= checkbox.first;
} }
} }
_saveCallback(_oldRights, MTP_channelBannedRights(MTP_flags(newFlags), MTP_int(getRealUntilValue()))); _saveCallback(_oldRights, MTP_chatBannedRights(MTP_flags(newFlags), MTP_int(getRealUntilValue())));
}); });
addButton(langFactory(lng_cancel), [this] { closeBox(); }); addButton(langFactory(lng_cancel), [this] { closeBox(); });
} else { } else {
@ -418,9 +413,9 @@ void EditRestrictedBox::applyDependencies(QPointer<Ui::Checkbox> changed) {
ApplyDependencies(_checkboxes, _dependencies, changed); ApplyDependencies(_checkboxes, _dependencies, changed);
} }
MTPChannelBannedRights EditRestrictedBox::DefaultRights(not_null<ChannelData*> channel) { MTPChatBannedRights EditRestrictedBox::DefaultRights(not_null<ChannelData*> channel) {
auto defaultRights = Flag::f_send_messages | Flag::f_send_media | Flag::f_embed_links | Flag::f_send_stickers | Flag::f_send_gifs | Flag::f_send_games | Flag::f_send_inline; auto defaultRights = Flag::f_send_messages | Flag::f_send_media | Flag::f_embed_links | Flag::f_send_stickers | Flag::f_send_gifs | Flag::f_send_games | Flag::f_send_inline;
return MTP_channelBannedRights(MTP_flags(defaultRights), MTP_int(0)); return MTP_chatBannedRights(MTP_flags(defaultRights), MTP_int(0));
} }
void EditRestrictedBox::showRestrictUntil() { void EditRestrictedBox::showRestrictUntil() {
@ -489,7 +484,7 @@ void EditRestrictedBox::createUntilVariants() {
} }
}; };
auto addCurrentVariant = [this, addCustomVariant](TimeId from, TimeId to) { auto addCurrentVariant = [this, addCustomVariant](TimeId from, TimeId to) {
auto oldUntil = _oldRights.c_channelBannedRights().vuntil_date.v; auto oldUntil = _oldRights.c_chatBannedRights().vuntil_date.v;
if (oldUntil < _until) { if (oldUntil < _until) {
addCustomVariant(oldUntil, from, to); addCustomVariant(oldUntil, from, to);
} }

View File

@ -56,9 +56,9 @@ private:
class EditAdminBox : public EditParticipantBox { class EditAdminBox : public EditParticipantBox {
public: public:
EditAdminBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, const MTPChannelAdminRights &rights); EditAdminBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, const MTPChatAdminRights &rights);
void setSaveCallback(Fn<void(MTPChannelAdminRights, MTPChannelAdminRights)> callback) { void setSaveCallback(Fn<void(MTPChatAdminRights, MTPChatAdminRights)> callback) {
_saveCallback = std::move(callback); _saveCallback = std::move(callback);
} }
@ -66,10 +66,10 @@ protected:
void prepare() override; void prepare() override;
private: private:
using Flag = MTPDchannelAdminRights::Flag; using Flag = MTPDchatAdminRights::Flag;
using Flags = MTPDchannelAdminRights::Flags; using Flags = MTPDchatAdminRights::Flags;
static MTPChannelAdminRights DefaultRights(not_null<ChannelData*> channel); static MTPChatAdminRights DefaultRights(not_null<ChannelData*> channel);
bool canSave() const { bool canSave() const {
return !!_saveCallback; return !!_saveCallback;
@ -77,9 +77,9 @@ private:
void applyDependencies(QPointer<Ui::Checkbox> changed); void applyDependencies(QPointer<Ui::Checkbox> changed);
void refreshAboutAddAdminsText(); void refreshAboutAddAdminsText();
const MTPChannelAdminRights _oldRights; const MTPChatAdminRights _oldRights;
std::vector<std::pair<Flag, Flag>> _dependencies; std::vector<std::pair<Flag, Flag>> _dependencies;
Fn<void(MTPChannelAdminRights, MTPChannelAdminRights)> _saveCallback; Fn<void(MTPChatAdminRights, MTPChatAdminRights)> _saveCallback;
std::map<Flags, QPointer<Ui::Checkbox>> _checkboxes; std::map<Flags, QPointer<Ui::Checkbox>> _checkboxes;
QPointer<Ui::FlatLabel> _aboutAddAdmins; QPointer<Ui::FlatLabel> _aboutAddAdmins;
@ -91,9 +91,9 @@ private:
class EditRestrictedBox : public EditParticipantBox { class EditRestrictedBox : public EditParticipantBox {
public: public:
EditRestrictedBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, bool hasAdminRights, const MTPChannelBannedRights &rights); EditRestrictedBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, bool hasAdminRights, const MTPChatBannedRights &rights);
void setSaveCallback(Fn<void(MTPChannelBannedRights, MTPChannelBannedRights)> callback) { void setSaveCallback(Fn<void(MTPChatBannedRights, MTPChatBannedRights)> callback) {
_saveCallback = std::move(callback); _saveCallback = std::move(callback);
} }
@ -101,10 +101,10 @@ protected:
void prepare() override; void prepare() override;
private: private:
using Flag = MTPDchannelBannedRights::Flag; using Flag = MTPDchatBannedRights::Flag;
using Flags = MTPDchannelBannedRights::Flags; using Flags = MTPDchatBannedRights::Flags;
static MTPChannelBannedRights DefaultRights(not_null<ChannelData*> channel); static MTPChatBannedRights DefaultRights(not_null<ChannelData*> channel);
bool canSave() const { bool canSave() const {
return !!_saveCallback; return !!_saveCallback;
@ -120,10 +120,10 @@ private:
void createUntilVariants(); void createUntilVariants();
TimeId getRealUntilValue() const; TimeId getRealUntilValue() const;
const MTPChannelBannedRights _oldRights; const MTPChatBannedRights _oldRights;
TimeId _until = 0; TimeId _until = 0;
std::vector<std::pair<Flag, Flag>> _dependencies; std::vector<std::pair<Flag, Flag>> _dependencies;
Fn<void(MTPChannelBannedRights, MTPChannelBannedRights)> _saveCallback; Fn<void(MTPChatBannedRights, MTPChatBannedRights)> _saveCallback;
std::map<Flags, QPointer<Ui::Checkbox>> _checkboxes; std::map<Flags, QPointer<Ui::Checkbox>> _checkboxes;

View File

@ -684,8 +684,9 @@ void EditChatAdminsBoxController::prepare() {
} }
void EditChatAdminsBoxController::createAllAdminsCheckbox() { void EditChatAdminsBoxController::createAllAdminsCheckbox() {
// #TODO groups
auto labelWidth = st::boxWideWidth - st::contactsPadding.left() - st::contactsPadding.right(); auto labelWidth = st::boxWideWidth - st::contactsPadding.left() - st::contactsPadding.right();
auto checkbox = object_ptr<LabeledCheckbox>(nullptr, lang(lng_chat_all_members_admins), !_chat->adminsEnabled(), st::defaultBoxCheckbox); auto checkbox = object_ptr<LabeledCheckbox>(nullptr, lang(lng_chat_all_members_admins), /*!_chat->adminsEnabled()*/false, st::defaultBoxCheckbox);
checkbox->setLabelText(true, st::defaultTextStyle, lang(lng_chat_about_all_admins), _defaultOptions, labelWidth); checkbox->setLabelText(true, st::defaultTextStyle, lang(lng_chat_about_all_admins), _defaultOptions, labelWidth);
checkbox->setLabelText(false, st::defaultTextStyle, lang(lng_chat_about_admins), _defaultOptions, labelWidth); checkbox->setLabelText(false, st::defaultTextStyle, lang(lng_chat_about_admins), _defaultOptions, labelWidth);
_allAdmins = checkbox; _allAdmins = checkbox;
@ -844,14 +845,15 @@ bool AddBotToGroupBoxController::needToCreateRow(not_null<PeerData*> peer) const
return false; return false;
} }
if (auto group = peer->asMegagroup()) { if (auto group = peer->asMegagroup()) {
if (group->restricted(ChannelRestriction::f_send_games)) { if (group->restricted(ChatRestriction::f_send_games)) {
return false; return false;
} }
} }
return true; return true;
} }
if (auto chat = peer->asChat()) { if (auto chat = peer->asChat()) {
if (chat->canEdit()) { // #TODO groups
if (chat->canEditInformation()) {
return true; return true;
} }
} else if (auto group = peer->asMegagroup()) { } else if (auto group = peer->asMegagroup()) {

View File

@ -237,7 +237,7 @@ object_ptr<Ui::RpWidget> Controller::createPhotoAndTitleEdit() {
if (auto channel = _peer->asChannel()) { if (auto channel = _peer->asChannel()) {
return channel->canEditInformation(); return channel->canEditInformation();
} else if (auto chat = _peer->asChat()) { } else if (auto chat = _peer->asChat()) {
return chat->canEdit(); return chat->canEditInformation();
} }
return false; return false;
}(); }();
@ -1305,8 +1305,8 @@ void Controller::saveDescription() {
channel->setAbout(*_savingData.description); channel->setAbout(*_savingData.description);
continueSave(); continueSave();
}; };
request(MTPchannels_EditAbout( request(MTPmessages_EditChatAbout(
channel->inputChannel, channel->input,
MTP_string(*_savingData.description) MTP_string(*_savingData.description)
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
successCallback(); successCallback();
@ -1355,19 +1355,20 @@ void Controller::saveInvites() {
|| *_savingData.everyoneInvites == channel->anyoneCanAddMembers()) { || *_savingData.everyoneInvites == channel->anyoneCanAddMembers()) {
return continueSave(); return continueSave();
} }
request(MTPchannels_ToggleInvites( // #TODO groups
channel->inputChannel, //request(MTPchannels_ToggleInvites(
MTP_bool(*_savingData.everyoneInvites) // channel->inputChannel,
)).done([this](const MTPUpdates &result) { // MTP_bool(*_savingData.everyoneInvites)
Auth().api().applyUpdates(result); //)).done([this](const MTPUpdates &result) {
continueSave(); // Auth().api().applyUpdates(result);
}).fail([this](const RPCError &error) { // continueSave();
if (error.type() == qstr("CHAT_NOT_MODIFIED")) { //}).fail([this](const RPCError &error) {
continueSave(); // if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
} else { // continueSave();
cancelSave(); // } else {
} // cancelSave();
}).send(); // }
//}).send();
} }
void Controller::saveSignatures() { void Controller::saveSignatures() {

View File

@ -672,8 +672,8 @@ void TabbedSelector::setCurrentPeer(PeerData *peer) {
void TabbedSelector::checkRestrictedPeer() { void TabbedSelector::checkRestrictedPeer() {
if (auto megagroup = _currentPeer ? _currentPeer->asMegagroup() : nullptr) { if (auto megagroup = _currentPeer ? _currentPeer->asMegagroup() : nullptr) {
auto restricted = (_currentTabType == SelectorTab::Stickers) ? megagroup->restricted(ChannelRestriction::f_send_stickers) : auto restricted = (_currentTabType == SelectorTab::Stickers) ? megagroup->restricted(ChatRestriction::f_send_stickers) :
(_currentTabType == SelectorTab::Gifs) ? megagroup->restricted(ChannelRestriction::f_send_gifs) : false; (_currentTabType == SelectorTab::Gifs) ? megagroup->restricted(ChatRestriction::f_send_gifs) : false;
if (restricted) { if (restricted) {
if (!_restrictedLabel) { if (!_restrictedLabel) {
auto text = (_currentTabType == SelectorTab::Stickers) auto text = (_currentTabType == SelectorTab::Stickers)

View File

@ -43,7 +43,9 @@ struct FileReferenceAccumulator {
} }
void push(const MTPDocument &data) { void push(const MTPDocument &data) {
data.match([&](const MTPDdocument &data) { data.match([&](const MTPDdocument &data) {
push(data.vthumb); for (const auto &thumb : data.vthumbs.v) {
push(thumb);
}
result.emplace( result.emplace(
DocumentFileLocationId(data.vid.v), DocumentFileLocationId(data.vid.v),
data.vfile_reference.v); data.vfile_reference.v);

View File

@ -326,7 +326,7 @@ bool MediaPhoto::allowsEditCaption() const {
QString MediaPhoto::errorTextForForward( QString MediaPhoto::errorTextForForward(
not_null<ChannelData*> channel) const { not_null<ChannelData*> channel) const {
if (channel->restricted(ChannelRestriction::f_send_media)) { if (channel->restricted(ChatRestriction::f_send_media)) {
return lang(lng_restricted_send_media); return lang(lng_restricted_send_media);
} }
return QString(); return QString();
@ -652,20 +652,20 @@ bool MediaFile::forwardedBecomesUnread() const {
QString MediaFile::errorTextForForward( QString MediaFile::errorTextForForward(
not_null<ChannelData*> channel) const { not_null<ChannelData*> channel) const {
if (const auto sticker = _document->sticker()) { if (const auto sticker = _document->sticker()) {
if (channel->restricted(ChannelRestriction::f_send_stickers)) { if (channel->restricted(ChatRestriction::f_send_stickers)) {
return lang(lng_restricted_send_stickers); return lang(lng_restricted_send_stickers);
} }
} else if (_document->isAnimation()) { } else if (_document->isAnimation()) {
if (_document->isVideoMessage()) { if (_document->isVideoMessage()) {
if (channel->restricted(ChannelRestriction::f_send_media)) { if (channel->restricted(ChatRestriction::f_send_media)) {
return lang(lng_restricted_send_media); return lang(lng_restricted_send_media);
} }
} else { } else {
if (channel->restricted(ChannelRestriction::f_send_gifs)) { if (channel->restricted(ChatRestriction::f_send_gifs)) {
return lang(lng_restricted_send_gifs); return lang(lng_restricted_send_gifs);
} }
} }
} else if (channel->restricted(ChannelRestriction::f_send_media)) { } else if (channel->restricted(ChatRestriction::f_send_media)) {
return lang(lng_restricted_send_media); return lang(lng_restricted_send_media);
} }
return QString(); return QString();
@ -1117,7 +1117,7 @@ TextWithEntities MediaGame::clipboardText() const {
QString MediaGame::errorTextForForward( QString MediaGame::errorTextForForward(
not_null<ChannelData*> channel) const { not_null<ChannelData*> channel) const {
if (channel->restricted(ChannelRestriction::f_send_games)) { if (channel->restricted(ChatRestriction::f_send_games)) {
return lang(lng_restricted_send_inline); return lang(lng_restricted_send_inline);
} }
return QString(); return QString();

View File

@ -343,14 +343,16 @@ bool PeerData::canPinMessages() const {
if (const auto user = asUser()) { if (const auto user = asUser()) {
return user->fullFlags() & MTPDuserFull::Flag::f_can_pin_message; return user->fullFlags() & MTPDuserFull::Flag::f_can_pin_message;
} else if (const auto chat = asChat()) { } else if (const auto chat = asChat()) {
return chat->adminsEnabled() ? chat->amAdmin() : chat->amIn(); // #TODO groups
return !chat->isDeactivated()
/*&& ((chat->adminRights() & ChatAdminRight::f_pin_messages)
|| chat->amCreator())*/;
} else if (const auto channel = asChannel()) { } else if (const auto channel = asChannel()) {
using AdminRight = ChannelData::AdminRight;
if (channel->isMegagroup()) { if (channel->isMegagroup()) {
return (channel->adminRights() & AdminRight::f_pin_messages) return (channel->adminRights() & ChatAdminRight::f_pin_messages)
|| channel->amCreator(); || channel->amCreator();
} }
return (channel->adminRights() & AdminRight::f_edit_messages) return (channel->adminRights() & ChatAdminRight::f_edit_messages)
|| channel->amCreator(); || channel->amCreator();
} }
Unexpected("Peer type in PeerData::canPinMessages."); Unexpected("Peer type in PeerData::canPinMessages.");
@ -652,18 +654,25 @@ void ChatData::setPhoto(PhotoId photoId, const MTPChatPhoto &photo) {
} }
} }
bool ChatData::canEditInformation() const {
// #TODO groups
return !isDeactivated()
/*&& ((adminRights() & AdminRight::f_change_info) || amCreator())*/;
}
void ChatData::setName(const QString &newName) { void ChatData::setName(const QString &newName) {
updateNameDelayed(newName.isEmpty() ? name : newName, QString(), QString()); updateNameDelayed(newName.isEmpty() ? name : newName, QString(), QString());
} }
void ChatData::invalidateParticipants() { void ChatData::invalidateParticipants() {
auto wasCanEdit = canEdit(); // #TODO groups
auto wasCanEdit = canEditInformation();
participants.clear(); participants.clear();
admins.clear(); admins.clear();
removeFlags(MTPDchat::Flag::f_admin); //removeFlags(MTPDchat::Flag::f_admin);
invitedByMe.clear(); invitedByMe.clear();
botStatus = 0; botStatus = 0;
if (wasCanEdit != canEdit()) { if (wasCanEdit != canEditInformation()) {
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::ChatCanEdit); Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::ChatCanEdit);
} }
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::MembersChanged | Notify::PeerUpdate::Flag::AdminsChanged); Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::MembersChanged | Notify::PeerUpdate::Flag::AdminsChanged);
@ -777,13 +786,13 @@ void ChannelData::setKickedCount(int newKickedCount) {
} }
} }
MTPChannelBannedRights ChannelData::KickedRestrictedRights() { MTPChatBannedRights ChannelData::KickedRestrictedRights() {
using Flag = MTPDchannelBannedRights::Flag; using Flag = MTPDchatBannedRights::Flag;
auto flags = Flag::f_view_messages | Flag::f_send_messages | Flag::f_send_media | Flag::f_embed_links | Flag::f_send_stickers | Flag::f_send_gifs | Flag::f_send_games | Flag::f_send_inline; auto flags = Flag::f_view_messages | Flag::f_send_messages | Flag::f_send_media | Flag::f_embed_links | Flag::f_send_stickers | Flag::f_send_gifs | Flag::f_send_games | Flag::f_send_inline;
return MTP_channelBannedRights(MTP_flags(flags), MTP_int(std::numeric_limits<int32>::max())); return MTP_chatBannedRights(MTP_flags(flags), MTP_int(std::numeric_limits<int32>::max()));
} }
void ChannelData::applyEditAdmin(not_null<UserData*> user, const MTPChannelAdminRights &oldRights, const MTPChannelAdminRights &newRights) { void ChannelData::applyEditAdmin(not_null<UserData*> user, const MTPChatAdminRights &oldRights, const MTPChatAdminRights &newRights) {
auto flags = Notify::PeerUpdate::Flag::AdminsChanged | Notify::PeerUpdate::Flag::None; auto flags = Notify::PeerUpdate::Flag::AdminsChanged | Notify::PeerUpdate::Flag::None;
if (mgInfo) { if (mgInfo) {
// If rights are empty - still add participant? TODO check // If rights are empty - still add participant? TODO check
@ -807,7 +816,7 @@ void ChannelData::applyEditAdmin(not_null<UserData*> user, const MTPChannelAdmin
auto userId = peerToUser(user->id); auto userId = peerToUser(user->id);
auto it = mgInfo->lastAdmins.find(user); auto it = mgInfo->lastAdmins.find(user);
if (newRights.c_channelAdminRights().vflags.v != 0) { if (newRights.c_chatAdminRights().vflags.v != 0) {
auto lastAdmin = MegagroupInfo::Admin { newRights }; auto lastAdmin = MegagroupInfo::Admin { newRights };
lastAdmin.canEdit = true; lastAdmin.canEdit = true;
if (it == mgInfo->lastAdmins.cend()) { if (it == mgInfo->lastAdmins.cend()) {
@ -827,7 +836,7 @@ void ChannelData::applyEditAdmin(not_null<UserData*> user, const MTPChannelAdmin
Data::ChannelAdminChanges(this).feed(userId, false); Data::ChannelAdminChanges(this).feed(userId, false);
} }
} }
if (oldRights.c_channelAdminRights().vflags.v && !newRights.c_channelAdminRights().vflags.v) { if (oldRights.c_chatAdminRights().vflags.v && !newRights.c_chatAdminRights().vflags.v) {
// We removed an admin. // We removed an admin.
if (adminsCount() > 1) { if (adminsCount() > 1) {
setAdminsCount(adminsCount() - 1); setAdminsCount(adminsCount() - 1);
@ -836,7 +845,7 @@ void ChannelData::applyEditAdmin(not_null<UserData*> user, const MTPChannelAdmin
// Removing bot admin removes it from channel. // Removing bot admin removes it from channel.
setMembersCount(membersCount() - 1); setMembersCount(membersCount() - 1);
} }
} else if (!oldRights.c_channelAdminRights().vflags.v && newRights.c_channelAdminRights().vflags.v) { } else if (!oldRights.c_chatAdminRights().vflags.v && newRights.c_chatAdminRights().vflags.v) {
// We added an admin. // We added an admin.
setAdminsCount(adminsCount() + 1); setAdminsCount(adminsCount() + 1);
updateFullForced(); updateFullForced();
@ -844,10 +853,10 @@ void ChannelData::applyEditAdmin(not_null<UserData*> user, const MTPChannelAdmin
Notify::peerUpdatedDelayed(this, flags); Notify::peerUpdatedDelayed(this, flags);
} }
void ChannelData::applyEditBanned(not_null<UserData*> user, const MTPChannelBannedRights &oldRights, const MTPChannelBannedRights &newRights) { void ChannelData::applyEditBanned(not_null<UserData*> user, const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights) {
auto flags = Notify::PeerUpdate::Flag::BannedUsersChanged | Notify::PeerUpdate::Flag::None; auto flags = Notify::PeerUpdate::Flag::BannedUsersChanged | Notify::PeerUpdate::Flag::None;
auto isKicked = (newRights.c_channelBannedRights().vflags.v & MTPDchannelBannedRights::Flag::f_view_messages); auto isKicked = (newRights.c_chatBannedRights().vflags.v & MTPDchatBannedRights::Flag::f_view_messages);
auto isRestricted = !isKicked && (newRights.c_channelBannedRights().vflags.v != 0); auto isRestricted = !isKicked && (newRights.c_chatBannedRights().vflags.v != 0);
if (mgInfo) { if (mgInfo) {
// If rights are empty - still remove admin? TODO check // If rights are empty - still remove admin? TODO check
if (mgInfo->lastAdmins.contains(user)) { if (mgInfo->lastAdmins.contains(user)) {
@ -968,7 +977,8 @@ bool ChannelData::canDeleteMessages() const {
} }
bool ChannelData::anyoneCanAddMembers() const { bool ChannelData::anyoneCanAddMembers() const {
return (flags() & MTPDchannel::Flag::f_democracy); // #TODO groups
return false;// (flags() & MTPDchannel::Flag::f_democracy);
} }
bool ChannelData::hiddenPreHistory() const { bool ChannelData::hiddenPreHistory() const {
@ -1084,11 +1094,11 @@ bool ChannelData::canRestrictUser(not_null<UserData*> user) const {
return adminRights() & AdminRight::f_ban_users; return adminRights() & AdminRight::f_ban_users;
} }
void ChannelData::setAdminRights(const MTPChannelAdminRights &rights) { void ChannelData::setAdminRights(const MTPChatAdminRights &rights) {
if (rights.c_channelAdminRights().vflags.v == adminRights()) { if (rights.c_chatAdminRights().vflags.v == adminRights()) {
return; return;
} }
_adminRights.set(rights.c_channelAdminRights().vflags.v); _adminRights.set(rights.c_chatAdminRights().vflags.v);
if (isMegagroup()) { if (isMegagroup()) {
const auto self = session().user(); const auto self = session().user();
if (hasAdminRights()) { if (hasAdminRights()) {
@ -1108,13 +1118,13 @@ void ChannelData::setAdminRights(const MTPChannelAdminRights &rights) {
Notify::peerUpdatedDelayed(this, UpdateFlag::ChannelRightsChanged | UpdateFlag::AdminsChanged | UpdateFlag::BannedUsersChanged); Notify::peerUpdatedDelayed(this, UpdateFlag::ChannelRightsChanged | UpdateFlag::AdminsChanged | UpdateFlag::BannedUsersChanged);
} }
void ChannelData::setRestrictedRights(const MTPChannelBannedRights &rights) { void ChannelData::setRestrictedRights(const MTPChatBannedRights &rights) {
if (rights.c_channelBannedRights().vflags.v == restrictions() if (rights.c_chatBannedRights().vflags.v == restrictions()
&& rights.c_channelBannedRights().vuntil_date.v == _restrictedUntill) { && rights.c_chatBannedRights().vuntil_date.v == _restrictedUntill) {
return; return;
} }
_restrictedUntill = rights.c_channelBannedRights().vuntil_date.v; _restrictedUntill = rights.c_chatBannedRights().vuntil_date.v;
_restrictions.set(rights.c_channelBannedRights().vflags.v); _restrictions.set(rights.c_chatBannedRights().vflags.v);
if (isMegagroup()) { if (isMegagroup()) {
const auto self = session().user(); const auto self = session().user();
if (hasRestrictions()) { if (hasRestrictions()) {

View File

@ -495,16 +495,21 @@ private:
}; };
using ChatAdminRight = MTPDchatAdminRights::Flag;
using ChatRestriction = MTPDchatBannedRights::Flag;
using ChatAdminRights = MTPDchatAdminRights::Flags;
using ChatRestrictions = MTPDchatBannedRights::Flags;
class ChatData : public PeerData { class ChatData : public PeerData {
public: public:
static constexpr auto kEssentialFlags = 0 static constexpr auto kEssentialFlags = 0
| MTPDchat::Flag::f_creator | MTPDchat::Flag::f_creator
| MTPDchat::Flag::f_kicked | MTPDchat::Flag::f_kicked
| MTPDchat::Flag::f_left | MTPDchat::Flag::f_left
| MTPDchat::Flag::f_admins_enabled
| MTPDchat::Flag::f_admin
| MTPDchat::Flag::f_deactivated | MTPDchat::Flag::f_deactivated
| MTPDchat::Flag::f_migrated_to; | MTPDchat::Flag::f_migrated_to
| MTPDchat::Flag::f_admin_rights
| MTPDchat::Flag::f_default_banned_rights;
using Flags = Data::Flags< using Flags = Data::Flags<
MTPDchat::Flags, MTPDchat::Flags,
kEssentialFlags>; kEssentialFlags>;
@ -552,11 +557,7 @@ public:
bool amIn() const { bool amIn() const {
return !isForbidden() && !haveLeft() && !wasKicked(); return !isForbidden() && !haveLeft() && !wasKicked();
} }
bool canEdit() const { bool canEditInformation() const;
return !isDeactivated()
&& (amCreator()
|| (adminsEnabled() ? amAdmin() : amIn()));
}
bool canWrite() const { bool canWrite() const {
// Duplicated in Data::CanWriteValue(). // Duplicated in Data::CanWriteValue().
return !isDeactivated() && amIn(); return !isDeactivated() && amIn();
@ -567,15 +568,9 @@ public:
bool wasKicked() const { bool wasKicked() const {
return flags() & MTPDchat::Flag::f_kicked; return flags() & MTPDchat::Flag::f_kicked;
} }
bool adminsEnabled() const {
return flags() & MTPDchat::Flag::f_admins_enabled;
}
bool amCreator() const { bool amCreator() const {
return flags() & MTPDchat::Flag::f_creator; return flags() & MTPDchat::Flag::f_creator;
} }
bool amAdmin() const {
return (flags() & MTPDchat::Flag::f_admin) && adminsEnabled();
}
bool isDeactivated() const { bool isDeactivated() const {
return flags() & MTPDchat::Flag::f_deactivated; return flags() & MTPDchat::Flag::f_deactivated;
} }
@ -687,21 +682,21 @@ private:
struct MegagroupInfo { struct MegagroupInfo {
struct Admin { struct Admin {
explicit Admin(MTPChannelAdminRights rights) explicit Admin(MTPChatAdminRights rights)
: rights(rights) { : rights(rights) {
} }
Admin(MTPChannelAdminRights rights, bool canEdit) Admin(MTPChatAdminRights rights, bool canEdit)
: rights(rights) : rights(rights)
, canEdit(canEdit) { , canEdit(canEdit) {
} }
MTPChannelAdminRights rights; MTPChatAdminRights rights;
bool canEdit = false; bool canEdit = false;
}; };
struct Restricted { struct Restricted {
explicit Restricted(MTPChannelBannedRights rights) explicit Restricted(MTPChatBannedRights rights)
: rights(rights) { : rights(rights) {
} }
MTPChannelBannedRights rights; MTPChatBannedRights rights;
}; };
std::deque<not_null<UserData*>> lastParticipants; std::deque<not_null<UserData*>> lastParticipants;
base::flat_map<not_null<UserData*>, Admin> lastAdmins; base::flat_map<not_null<UserData*>, Admin> lastAdmins;
@ -728,11 +723,6 @@ struct MegagroupInfo {
}; };
using ChannelAdminRight = MTPDchannelAdminRights::Flag;
using ChannelRestriction = MTPDchannelBannedRights::Flag;
using ChannelAdminRights = MTPDchannelAdminRights::Flags;
using ChannelRestrictions = MTPDchannelBannedRights::Flags;
class ChannelData : public PeerData { class ChannelData : public PeerData {
public: public:
static constexpr auto kEssentialFlags = 0 static constexpr auto kEssentialFlags = 0
@ -742,7 +732,6 @@ public:
| MTPDchannel::Flag::f_verified | MTPDchannel::Flag::f_verified
| MTPDchannel::Flag::f_megagroup | MTPDchannel::Flag::f_megagroup
| MTPDchannel::Flag::f_restricted | MTPDchannel::Flag::f_restricted
| MTPDchannel::Flag::f_democracy
| MTPDchannel::Flag::f_signatures | MTPDchannel::Flag::f_signatures
| MTPDchannel::Flag::f_username; | MTPDchannel::Flag::f_username;
using Flags = Data::Flags< using Flags = Data::Flags<
@ -844,19 +833,19 @@ public:
return flags() & MTPDchannel::Flag::f_verified; return flags() & MTPDchannel::Flag::f_verified;
} }
static MTPChannelBannedRights KickedRestrictedRights(); static MTPChatBannedRights KickedRestrictedRights();
static constexpr auto kRestrictUntilForever = TimeId(INT_MAX); static constexpr auto kRestrictUntilForever = TimeId(INT_MAX);
static bool IsRestrictedForever(TimeId until) { static bool IsRestrictedForever(TimeId until) {
return !until || (until == kRestrictUntilForever); return !until || (until == kRestrictUntilForever);
} }
void applyEditAdmin( void applyEditAdmin(
not_null<UserData*> user, not_null<UserData*> user,
const MTPChannelAdminRights &oldRights, const MTPChatAdminRights &oldRights,
const MTPChannelAdminRights &newRights); const MTPChatAdminRights &newRights);
void applyEditBanned( void applyEditBanned(
not_null<UserData*> user, not_null<UserData*> user,
const MTPChannelBannedRights &oldRights, const MTPChatBannedRights &oldRights,
const MTPChannelBannedRights &newRights); const MTPChatBannedRights &newRights);
bool isGroupAdmin(not_null<UserData*> user) const; bool isGroupAdmin(not_null<UserData*> user) const;
@ -889,10 +878,10 @@ public:
return flags() & MTPDchannel::Flag::f_creator; return flags() & MTPDchannel::Flag::f_creator;
} }
using AdminRight = ChannelAdminRight; using AdminRight = ChatAdminRight;
using Restriction = ChannelRestriction; using Restriction = ChatRestriction;
using AdminRights = ChannelAdminRights; using AdminRights = ChatAdminRights;
using Restrictions = ChannelRestrictions; using Restrictions = ChatRestrictions;
using AdminRightFlags = Data::Flags<AdminRights>; using AdminRightFlags = Data::Flags<AdminRights>;
using RestrictionFlags = Data::Flags<Restrictions>; using RestrictionFlags = Data::Flags<Restrictions>;
auto adminRights() const { auto adminRights() const {
@ -901,7 +890,7 @@ public:
auto adminRightsValue() const { auto adminRightsValue() const {
return _adminRights.value(); return _adminRights.value();
} }
void setAdminRights(const MTPChannelAdminRights &rights); void setAdminRights(const MTPChatAdminRights &rights);
bool hasAdminRights() const { bool hasAdminRights() const {
return (adminRights() != 0); return (adminRights() != 0);
} }
@ -917,7 +906,7 @@ public:
TimeId restrictedUntil() const { TimeId restrictedUntil() const {
return _restrictedUntill; return _restrictedUntill;
} }
void setRestrictedRights(const MTPChannelBannedRights &rights); void setRestrictedRights(const MTPChatBannedRights &rights);
bool hasRestrictions() const { bool hasRestrictions() const {
return (restrictions() != 0); return (restrictions() != 0);
} }
@ -952,7 +941,7 @@ public:
return _inviteLink; return _inviteLink;
} }
bool canHaveInviteLink() const { bool canHaveInviteLink() const {
return (adminRights() & AdminRight::f_invite_link) return (adminRights() & AdminRight::f_invite_users)
|| amCreator(); || amCreator();
} }

View File

@ -76,13 +76,13 @@ inline auto AdminRightsValue(not_null<ChannelData*> channel) {
inline auto AdminRightsValue( inline auto AdminRightsValue(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
MTPDchannelAdminRights::Flags mask) { MTPDchatAdminRights::Flags mask) {
return FlagsValueWithMask(AdminRightsValue(channel), mask); return FlagsValueWithMask(AdminRightsValue(channel), mask);
} }
inline auto AdminRightValue( inline auto AdminRightValue(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
MTPDchannelAdminRights::Flag flag) { MTPDchatAdminRights::Flag flag) {
return SingleFlagValue(AdminRightsValue(channel), flag); return SingleFlagValue(AdminRightsValue(channel), flag);
} }
@ -92,13 +92,13 @@ inline auto RestrictionsValue(not_null<ChannelData*> channel) {
inline auto RestrictionsValue( inline auto RestrictionsValue(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
MTPDchannelBannedRights::Flags mask) { MTPDchatBannedRights::Flags mask) {
return FlagsValueWithMask(RestrictionsValue(channel), mask); return FlagsValueWithMask(RestrictionsValue(channel), mask);
} }
inline auto RestrictionValue( inline auto RestrictionValue(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
MTPDchannelBannedRights::Flag flag) { MTPDchatBannedRights::Flag flag) {
return SingleFlagValue(RestrictionsValue(channel), flag); return SingleFlagValue(RestrictionsValue(channel), flag);
} }
@ -141,10 +141,10 @@ rpl::producer<bool> CanWriteValue(ChannelData *channel) {
PeerFlagsValue(channel, mask), PeerFlagsValue(channel, mask),
AdminRightValue( AdminRightValue(
channel, channel,
MTPDchannelAdminRights::Flag::f_post_messages), MTPDchatAdminRights::Flag::f_post_messages),
RestrictionValue( RestrictionValue(
channel, channel,
MTPDchannelBannedRights::Flag::f_send_messages), MTPDchatBannedRights::Flag::f_send_messages),
[]( [](
MTPDchannel::Flags flags, MTPDchannel::Flags flags,
bool postMessagesRight, bool postMessagesRight,

View File

@ -117,6 +117,26 @@ QString ExtractRestrictionReason(const QString &restriction) {
return QString(); return QString();
} }
MTPPhotoSize FindDocumentThumb(const MTPDdocument &data) {
const auto area = [](const MTPPhotoSize &size) {
static constexpr auto kInvalid = std::numeric_limits<int>::max();
return size.match([](const MTPDphotoSizeEmpty &) {
return kInvalid;
}, [](const MTPDphotoStrippedSize &) {
return kInvalid;
}, [](const auto &data) {
return (data.vw.v >= 90 || data.vh.v >= 90)
? (data.vw.v * data.vh.v)
: kInvalid;
});
};
const auto &thumbs = data.vthumbs.v;
const auto i = ranges::max_element(thumbs, std::greater<>(), area);
return (i != thumbs.end())
? (*i)
: MTPPhotoSize(MTP_photoSizeEmpty(MTP_string("")));
}
} // namespace } // namespace
Session::Session(not_null<AuthSession*> session) Session::Session(not_null<AuthSession*> session)
@ -407,7 +427,8 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
data.match([&](const MTPDchat &data) { data.match([&](const MTPDchat &data) {
const auto chat = result->asChat(); const auto chat = result->asChat();
const auto canEdit = chat->canEdit(); // #TODO groups
const auto canEdit = chat->canEditInformation();
if (chat->version < data.vversion.v) { if (chat->version < data.vversion.v) {
chat->version = data.vversion.v; chat->version = data.vversion.v;
@ -458,19 +479,22 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
}, [](const MTPDinputChannelEmpty &) { }, [](const MTPDinputChannelEmpty &) {
}); });
if (!(chat->flags() & MTPDchat::Flag::f_admins_enabled) // #TODO groups
&& (data.vflags.v & MTPDchat::Flag::f_admins_enabled)) { //if (!(chat->flags() & MTPDchat::Flag::f_admins_enabled)
chat->invalidateParticipants(); // && (data.vflags.v & MTPDchat::Flag::f_admins_enabled)) {
} // chat->invalidateParticipants();
//}
chat->setFlags(data.vflags.v); chat->setFlags(data.vflags.v);
chat->count = data.vparticipants_count.v; chat->count = data.vparticipants_count.v;
if (canEdit != chat->canEdit()) { // #TODO groups
if (canEdit != chat->canEditInformation()) {
update.flags |= UpdateFlag::ChatCanEdit; update.flags |= UpdateFlag::ChatCanEdit;
} }
}, [&](const MTPDchatForbidden &data) { }, [&](const MTPDchatForbidden &data) {
const auto chat = result->asChat(); const auto chat = result->asChat();
const auto canEdit = chat->canEdit(); // #TODO groups
const auto canEdit = chat->canEditInformation();
chat->input = MTP_inputPeerChat(data.vid); chat->input = MTP_inputPeerChat(data.vid);
chat->setName(qs(data.vtitle)); chat->setName(qs(data.vtitle));
@ -479,7 +503,8 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
chat->count = -1; chat->count = -1;
chat->invalidateParticipants(); chat->invalidateParticipants();
chat->setFlags(MTPDchat_ClientFlag::f_forbidden | 0); chat->setFlags(MTPDchat_ClientFlag::f_forbidden | 0);
if (canEdit != chat->canEdit()) { // #TODO groups
if (canEdit != chat->canEditInformation()) {
update.flags |= UpdateFlag::ChatCanEdit; update.flags |= UpdateFlag::ChatCanEdit;
} }
}, [&](const MTPDchannel &data) { }, [&](const MTPDchannel &data) {
@ -510,19 +535,18 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
| MTPDchannel::Flag::f_broadcast | MTPDchannel::Flag::f_broadcast
| MTPDchannel::Flag::f_verified | MTPDchannel::Flag::f_verified
| MTPDchannel::Flag::f_megagroup | MTPDchannel::Flag::f_megagroup
| MTPDchannel::Flag::f_democracy
| MTPDchannel_ClientFlag::f_forbidden; | MTPDchannel_ClientFlag::f_forbidden;
channel->setFlags((channel->flags() & ~mask) | (data.vflags.v & mask)); channel->setFlags((channel->flags() & ~mask) | (data.vflags.v & mask));
} else { } else {
if (data.has_admin_rights()) { if (data.has_admin_rights()) {
channel->setAdminRights(data.vadmin_rights); channel->setAdminRights(data.vadmin_rights);
} else if (channel->hasAdminRights()) { } else if (channel->hasAdminRights()) {
channel->setAdminRights(MTP_channelAdminRights(MTP_flags(0))); channel->setAdminRights(MTP_chatAdminRights(MTP_flags(0)));
} }
if (data.has_banned_rights()) { if (data.has_banned_rights()) {
channel->setRestrictedRights(data.vbanned_rights); channel->setRestrictedRights(data.vbanned_rights);
} else if (channel->hasRestrictions()) { } else if (channel->hasRestrictions()) {
channel->setRestrictedRights(MTP_channelBannedRights(MTP_flags(0), MTP_int(0))); channel->setRestrictedRights(MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
} }
channel->inputChannel = MTP_inputChannel(data.vid, data.vaccess_hash); channel->inputChannel = MTP_inputChannel(data.vid, data.vaccess_hash);
channel->access = data.vaccess_hash.v; channel->access = data.vaccess_hash.v;
@ -572,10 +596,10 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
channel->setFlags((channel->flags() & ~mask) | (mtpCastFlags(data.vflags) & mask) | MTPDchannel_ClientFlag::f_forbidden); channel->setFlags((channel->flags() & ~mask) | (mtpCastFlags(data.vflags) & mask) | MTPDchannel_ClientFlag::f_forbidden);
if (channel->hasAdminRights()) { if (channel->hasAdminRights()) {
channel->setAdminRights(MTP_channelAdminRights(MTP_flags(0))); channel->setAdminRights(MTP_chatAdminRights(MTP_flags(0)));
} }
if (channel->hasRestrictions()) { if (channel->hasRestrictions()) {
channel->setRestrictedRights(MTP_channelBannedRights(MTP_flags(0), MTP_int(0))); channel->setRestrictedRights(MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
} }
channel->setName(qs(data.vtitle), QString()); channel->setName(qs(data.vtitle), QString());
@ -1992,6 +2016,7 @@ void Session::documentApplyFields(
void Session::documentApplyFields( void Session::documentApplyFields(
not_null<DocumentData*> document, not_null<DocumentData*> document,
const MTPDdocument &data) { const MTPDdocument &data) {
const auto thumb = FindDocumentThumb(data);
documentApplyFields( documentApplyFields(
document, document,
data.vaccess_hash.v, data.vaccess_hash.v,
@ -1999,10 +2024,10 @@ void Session::documentApplyFields(
data.vdate.v, data.vdate.v,
data.vattributes.v, data.vattributes.v,
qs(data.vmime_type), qs(data.vmime_type),
App::image(data.vthumb), App::image(thumb),
data.vdc_id.v, data.vdc_id.v,
data.vsize.v, data.vsize.v,
StorageImageLocation::FromMTP(data.vthumb)); StorageImageLocation::FromMTP(thumb));
} }
void Session::documentApplyFields( void Session::documentApplyFields(
@ -3007,48 +3032,14 @@ void Session::setWallpapers(const QVector<MTPWallPaper> &data) {
}); });
for (const auto &paper : data) { for (const auto &paper : data) {
paper.match([&](const MTPDwallPaper &paper) { paper.match([&](const MTPDwallPaper &paper) {
const MTPPhotoSize *thumb = nullptr; const auto document = Auth().data().document(paper.vdocument);
const MTPPhotoSize *full = nullptr; if (document->thumb) {
auto thumbLevel = -1;
auto fullLevel = -1;
for (const auto &photoSize : paper.vsizes.v) {
auto size = char(0);
auto w = 0;
auto h = 0;
photoSize.match([](const MTPDphotoSizeEmpty &) {
LOG(("API Error: photoSizeEmpty in wallpapers."));
}, [](const MTPDphotoStrippedSize &) {
LOG(("API Error: photoStrippedSize in wallpapers."));
}, [&](const auto &photoSize) {
if (photoSize.vtype.v.size()) {
size = photoSize.vtype.v[0];
}
w = photoSize.vw.v;
h = photoSize.vh.v;
});
if (!size || !w || !h) {
continue;
}
const auto newThumbLevel = qAbs((st::backgroundSize.width() * cIntRetinaFactor()) - w);
const auto newFullLevel = qAbs(2560 - w);
if (thumbLevel < 0 || newThumbLevel < thumbLevel) {
thumbLevel = newThumbLevel;
thumb = &photoSize;
}
if (fullLevel < 0 || newFullLevel < fullLevel) {
fullLevel = newFullLevel;
full = &photoSize;
}
}
if (thumb && full) {
_wallpapers.push_back({ _wallpapers.push_back({
paper.vid.v ? paper.vid.v : INT_MAX, paper.vid.v ? int32(paper.vid.v) : INT_MAX,
App::image(*thumb), document->thumb,
App::image(*full) document->thumb,
}); });
} }
}, [](const MTPDwallPaperSolid &) {
}); });
} }
} }

View File

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QDateTime> #include <QtCore/QDateTime>
#include <QtCore/QRegularExpression> #include <QtCore/QRegularExpression>
#include <QtGui/QImageReader> #include <QtGui/QImageReader>
#include <range/v3/algorithm/max_element.hpp>
#include <range/v3/view/all.hpp> #include <range/v3/view/all.hpp>
#include <range/v3/view/transform.hpp> #include <range/v3/view/transform.hpp>
#include <range/v3/to_container.hpp> #include <range/v3/to_container.hpp>
@ -405,6 +406,43 @@ QString DocumentFolder(const Document &data) {
return "files"; return "files";
} }
Image ParseDocumentThumb(
const QVector<MTPPhotoSize> &thumbs,
const QString &documentPath) {
const auto area = [](const MTPPhotoSize &size) {
return size.match([](const MTPDphotoSizeEmpty &) {
return 0;
}, [](const MTPDphotoStrippedSize &) {
return 0;
}, [](const auto &data) {
return data.vw.v * data.vh.v;
});
};
const auto i = ranges::max_element(thumbs, ranges::less(), area);
if (i == thumbs.end()) {
return Image();
}
return i->match([](const MTPDphotoSizeEmpty &) {
return Image();
}, [](const MTPDphotoStrippedSize &) {
return Image();
}, [&](const auto &data) {
auto result = Image();
result.width = data.vw.v;
result.height = data.vh.v;
result.file.location = ParseLocation(data.vlocation);
if constexpr (MTPDphotoCachedSize::Is<decltype(data)>()) {
result.file.content = data.vbytes.v;
result.file.size = result.file.content.size();
} else {
result.file.content = QByteArray();
result.file.size = data.vsize.v;
}
result.file.suggestedPath = documentPath + "_thumb.jpg";
return result;
});
}
Document ParseDocument( Document ParseDocument(
ParseMediaContext &context, ParseMediaContext &context,
const MTPDocument &data, const MTPDocument &data,
@ -423,30 +461,13 @@ Document ParseDocument(
data.vid, data.vid,
data.vaccess_hash, data.vaccess_hash,
data.vfile_reference); data.vfile_reference);
const auto path = result.file.suggestedPath = suggestedFolder result.file.suggestedPath = suggestedFolder
+ DocumentFolder(result) + '/' + DocumentFolder(result) + '/'
+ CleanDocumentName(ComputeDocumentName(context, result, date)); + CleanDocumentName(ComputeDocumentName(context, result, date));
result.thumb = data.vthumb.match([](const MTPDphotoSizeEmpty &) { result.thumb = ParseDocumentThumb(
return Image(); data.vthumbs.v,
}, [](const MTPDphotoStrippedSize &) { result.file.suggestedPath);
// For now stripped images are used only in photos.
return Image();
}, [&](const auto &data) {
auto result = Image();
result.width = data.vw.v;
result.height = data.vh.v;
result.file.location = ParseLocation(data.vlocation);
if constexpr (MTPDphotoCachedSize::Is<decltype(data)>()) {
result.file.content = data.vbytes.v;
result.file.size = result.file.content.size();
} else {
result.file.content = QByteArray();
result.file.size = data.vsize.v;
}
result.file.suggestedPath = path + "_thumb.jpg";
return result;
});
}, [&](const MTPDdocumentEmpty &data) { }, [&](const MTPDdocumentEmpty &data) {
result.id = data.vid.v; result.id = data.vid.v;
}); });

View File

@ -1127,11 +1127,11 @@ void InnerWidget::suggestRestrictUser(not_null<UserData*> user) {
} }
} }
_menu->addAction(lang(lng_context_restrict_user), [=] { _menu->addAction(lang(lng_context_restrict_user), [=] {
auto editRestrictions = [=](bool hasAdminRights, const MTPChannelBannedRights &currentRights) { auto editRestrictions = [=](bool hasAdminRights, const MTPChatBannedRights &currentRights) {
auto weak = QPointer<InnerWidget>(this); auto weak = QPointer<InnerWidget>(this);
auto weakBox = std::make_shared<QPointer<EditRestrictedBox>>(); auto weakBox = std::make_shared<QPointer<EditRestrictedBox>>();
auto box = Box<EditRestrictedBox>(_channel, user, hasAdminRights, currentRights); auto box = Box<EditRestrictedBox>(_channel, user, hasAdminRights, currentRights);
box->setSaveCallback([user, weak, weakBox](const MTPChannelBannedRights &oldRights, const MTPChannelBannedRights &newRights) { box->setSaveCallback([user, weak, weakBox](const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights) {
if (weak) { if (weak) {
weak->restrictUser(user, oldRights, newRights); weak->restrictUser(user, oldRights, newRights);
} }
@ -1144,7 +1144,7 @@ void InnerWidget::suggestRestrictUser(not_null<UserData*> user) {
LayerOption::KeepOther); LayerOption::KeepOther);
}; };
if (base::contains(_admins, user)) { if (base::contains(_admins, user)) {
editRestrictions(true, MTP_channelBannedRights(MTP_flags(0), MTP_int(0))); editRestrictions(true, MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
} else { } else {
request(MTPchannels_GetParticipant(_channel->inputChannel, user->inputUser)).done([=](const MTPchannels_ChannelParticipant &result) { request(MTPchannels_GetParticipant(_channel->inputChannel, user->inputUser)).done([=](const MTPchannels_ChannelParticipant &result) {
Expects(result.type() == mtpc_channels_channelParticipant); Expects(result.type() == mtpc_channels_channelParticipant);
@ -1158,13 +1158,13 @@ void InnerWidget::suggestRestrictUser(not_null<UserData*> user) {
} else { } else {
auto hasAdminRights = (type == mtpc_channelParticipantAdmin) auto hasAdminRights = (type == mtpc_channelParticipantAdmin)
|| (type == mtpc_channelParticipantCreator); || (type == mtpc_channelParticipantCreator);
auto bannedRights = MTP_channelBannedRights( auto bannedRights = MTP_chatBannedRights(
MTP_flags(0), MTP_flags(0),
MTP_int(0)); MTP_int(0));
editRestrictions(hasAdminRights, bannedRights); editRestrictions(hasAdminRights, bannedRights);
} }
}).fail([=](const RPCError &error) { }).fail([=](const RPCError &error) {
auto bannedRights = MTP_channelBannedRights( auto bannedRights = MTP_chatBannedRights(
MTP_flags(0), MTP_flags(0),
MTP_int(0)); MTP_int(0));
editRestrictions(false, bannedRights); editRestrictions(false, bannedRights);
@ -1173,7 +1173,7 @@ void InnerWidget::suggestRestrictUser(not_null<UserData*> user) {
}); });
} }
void InnerWidget::restrictUser(not_null<UserData*> user, const MTPChannelBannedRights &oldRights, const MTPChannelBannedRights &newRights) { void InnerWidget::restrictUser(not_null<UserData*> user, const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights) {
auto weak = QPointer<InnerWidget>(this); auto weak = QPointer<InnerWidget>(this);
MTP::send(MTPchannels_EditBanned(_channel->inputChannel, user->inputUser, newRights), rpcDone([megagroup = _channel.get(), user, weak, oldRights, newRights](const MTPUpdates &result) { MTP::send(MTPchannels_EditBanned(_channel->inputChannel, user->inputUser, newRights), rpcDone([megagroup = _channel.get(), user, weak, oldRights, newRights](const MTPUpdates &result) {
Auth().api().applyUpdates(result); Auth().api().applyUpdates(result);
@ -1184,9 +1184,9 @@ void InnerWidget::restrictUser(not_null<UserData*> user, const MTPChannelBannedR
})); }));
} }
void InnerWidget::restrictUserDone(not_null<UserData*> user, const MTPChannelBannedRights &rights) { void InnerWidget::restrictUserDone(not_null<UserData*> user, const MTPChatBannedRights &rights) {
Expects(rights.type() == mtpc_channelBannedRights); Expects(rights.type() == mtpc_chatBannedRights);
if (rights.c_channelBannedRights().vflags.v) { if (rights.c_chatBannedRights().vflags.v) {
_admins.erase(std::remove(_admins.begin(), _admins.end(), user), _admins.end()); _admins.erase(std::remove(_admins.begin(), _admins.end(), user), _admins.end());
_adminsCanEdit.erase(std::remove(_adminsCanEdit.begin(), _adminsCanEdit.end(), user), _adminsCanEdit.end()); _adminsCanEdit.erase(std::remove(_adminsCanEdit.begin(), _adminsCanEdit.end(), user), _adminsCanEdit.end());
} }

View File

@ -154,8 +154,8 @@ private:
void copySelectedText(); void copySelectedText();
TextWithEntities getSelectedText() const; TextWithEntities getSelectedText() const;
void suggestRestrictUser(not_null<UserData*> user); void suggestRestrictUser(not_null<UserData*> user);
void restrictUser(not_null<UserData*> user, const MTPChannelBannedRights &oldRights, const MTPChannelBannedRights &newRights); void restrictUser(not_null<UserData*> user, const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights);
void restrictUserDone(not_null<UserData*> user, const MTPChannelBannedRights &rights); void restrictUserDone(not_null<UserData*> user, const MTPChatBannedRights &rights);
void requestAdmins(); void requestAdmins();
void checkPreloadMore(); void checkPreloadMore();

View File

@ -151,17 +151,16 @@ const auto CollectChanges = [](auto &phraseMap, auto plusFlags, auto minusFlags)
return withPrefix(plusFlags & ~minusFlags, '+') + withPrefix(minusFlags & ~plusFlags, kMinus); return withPrefix(plusFlags & ~minusFlags, '+') + withPrefix(minusFlags & ~plusFlags, kMinus);
}; };
auto GenerateAdminChangeText(not_null<ChannelData*> channel, const TextWithEntities &user, const MTPChannelAdminRights *newRights, const MTPChannelAdminRights *prevRights) { auto GenerateAdminChangeText(not_null<ChannelData*> channel, const TextWithEntities &user, const MTPChatAdminRights *newRights, const MTPChatAdminRights *prevRights) {
using Flag = MTPDchannelAdminRights::Flag; using Flag = MTPDchatAdminRights::Flag;
using Flags = MTPDchannelAdminRights::Flags; using Flags = MTPDchatAdminRights::Flags;
Expects(!newRights || newRights->type() == mtpc_channelAdminRights); Expects(!newRights || newRights->type() == mtpc_chatAdminRights);
Expects(!prevRights || prevRights->type() == mtpc_channelAdminRights); Expects(!prevRights || prevRights->type() == mtpc_chatAdminRights);
auto newFlags = newRights ? newRights->c_channelAdminRights().vflags.v : MTPDchannelAdminRights::Flags(0); auto newFlags = newRights ? newRights->c_chatAdminRights().vflags.v : MTPDchatAdminRights::Flags(0);
auto prevFlags = prevRights ? prevRights->c_channelAdminRights().vflags.v : MTPDchannelAdminRights::Flags(0); auto prevFlags = prevRights ? prevRights->c_chatAdminRights().vflags.v : MTPDchatAdminRights::Flags(0);
auto result = lng_admin_log_promoted__generic(lt_user, user); auto result = lng_admin_log_promoted__generic(lt_user, user);
auto inviteKey = Flag::f_invite_users | Flag::f_invite_link;
auto useInviteLinkPhrase = channel->isMegagroup() && channel->anyoneCanAddMembers(); auto useInviteLinkPhrase = channel->isMegagroup() && channel->anyoneCanAddMembers();
auto invitePhrase = (useInviteLinkPhrase ? lng_admin_log_admin_invite_link : lng_admin_log_admin_invite_users); auto invitePhrase = (useInviteLinkPhrase ? lng_admin_log_admin_invite_link : lng_admin_log_admin_invite_users);
static auto phraseMap = std::map<Flags, LangKey> { static auto phraseMap = std::map<Flags, LangKey> {
@ -170,11 +169,11 @@ auto GenerateAdminChangeText(not_null<ChannelData*> channel, const TextWithEntit
{ Flag::f_edit_messages, lng_admin_log_admin_edit_messages }, { Flag::f_edit_messages, lng_admin_log_admin_edit_messages },
{ Flag::f_delete_messages, lng_admin_log_admin_delete_messages }, { Flag::f_delete_messages, lng_admin_log_admin_delete_messages },
{ Flag::f_ban_users, lng_admin_log_admin_ban_users }, { Flag::f_ban_users, lng_admin_log_admin_ban_users },
{ inviteKey, invitePhrase }, { Flag::f_invite_users, invitePhrase },
{ Flag::f_pin_messages, lng_admin_log_admin_pin_messages }, { Flag::f_pin_messages, lng_admin_log_admin_pin_messages },
{ Flag::f_add_admins, lng_admin_log_admin_add_admins }, { Flag::f_add_admins, lng_admin_log_admin_add_admins },
}; };
phraseMap[inviteKey] = invitePhrase; phraseMap[Flag::f_invite_users] = invitePhrase;
if (!channel->isMegagroup()) { if (!channel->isMegagroup()) {
// Don't display "Ban users" changes in channels. // Don't display "Ban users" changes in channels.
@ -190,15 +189,15 @@ auto GenerateAdminChangeText(not_null<ChannelData*> channel, const TextWithEntit
return result; return result;
}; };
auto GenerateBannedChangeText(const TextWithEntities &user, const MTPChannelBannedRights *newRights, const MTPChannelBannedRights *prevRights) { auto GenerateBannedChangeText(const TextWithEntities &user, const MTPChatBannedRights *newRights, const MTPChatBannedRights *prevRights) {
using Flag = MTPDchannelBannedRights::Flag; using Flag = MTPDchatBannedRights::Flag;
using Flags = MTPDchannelBannedRights::Flags; using Flags = MTPDchatBannedRights::Flags;
Expects(!newRights || newRights->type() == mtpc_channelBannedRights); Expects(!newRights || newRights->type() == mtpc_chatBannedRights);
Expects(!prevRights || prevRights->type() == mtpc_channelBannedRights); Expects(!prevRights || prevRights->type() == mtpc_chatBannedRights);
auto newFlags = newRights ? newRights->c_channelBannedRights().vflags.v : MTPDchannelBannedRights::Flags(0); auto newFlags = newRights ? newRights->c_chatBannedRights().vflags.v : MTPDchatBannedRights::Flags(0);
auto prevFlags = prevRights ? prevRights->c_channelBannedRights().vflags.v : MTPDchannelBannedRights::Flags(0); auto prevFlags = prevRights ? prevRights->c_chatBannedRights().vflags.v : MTPDchatBannedRights::Flags(0);
auto newUntil = newRights ? newRights->c_channelBannedRights().vuntil_date.v : TimeId(0); auto newUntil = newRights ? newRights->c_chatBannedRights().vuntil_date.v : TimeId(0);
auto indefinitely = ChannelData::IsRestrictedForever(newUntil); auto indefinitely = ChannelData::IsRestrictedForever(newUntil);
if (newFlags & Flag::f_view_messages) { if (newFlags & Flag::f_view_messages) {
return lng_admin_log_banned__generic(lt_user, user); return lng_admin_log_banned__generic(lt_user, user);

View File

@ -503,7 +503,8 @@ bool HistoryItem::canDeleteForEveryone(TimeId now) const {
} }
if (!out()) { if (!out()) {
if (const auto chat = peer->asChat()) { if (const auto chat = peer->asChat()) {
if (!chat->amCreator() && (!chat->amAdmin() || !chat->adminsEnabled())) { // #TODO groups
if (!chat->amCreator()/* && (!chat->amAdmin() || !chat->adminsEnabled())*/) {
return false; return false;
} }
} else if (peer->isUser()) { } else if (peer->isUser()) {

View File

@ -54,7 +54,7 @@ MTPDmessage::Flags NewForwardedFlags(
if (dynamic_cast<Data::MediaWebPage*>(fwd->media())) { if (dynamic_cast<Data::MediaWebPage*>(fwd->media())) {
// Drop web page if we're not allowed to send it. // Drop web page if we're not allowed to send it.
if (channel->restricted( if (channel->restricted(
ChannelRestriction::f_embed_links)) { ChatRestriction::f_embed_links)) {
result &= ~MTPDmessage::Flag::f_media; result &= ~MTPDmessage::Flag::f_media;
} }
} }
@ -263,7 +263,7 @@ QString GetErrorTextForForward(
} }
} }
} }
if (megagroup->restricted(ChannelRestriction::f_send_inline) if (megagroup->restricted(ChatRestriction::f_send_inline)
&& HasInlineItems(items)) { && HasInlineItems(items)) {
return lang(lng_restricted_send_inline); return lang(lng_restricted_send_inline);
} }
@ -431,7 +431,7 @@ HistoryMessage::HistoryMessage(
auto ignoreMedia = [&] { auto ignoreMedia = [&] {
if (mediaOriginal && mediaOriginal->webpage()) { if (mediaOriginal && mediaOriginal->webpage()) {
if (const auto channel = history->peer->asChannel()) { if (const auto channel = history->peer->asChannel()) {
if (channel->restricted(ChannelRestriction::f_embed_links)) { if (channel->restricted(ChatRestriction::f_embed_links)) {
return true; return true;
} }
} }

View File

@ -1933,7 +1933,7 @@ bool HistoryWidget::canWriteMessage() const {
bool HistoryWidget::isRestrictedWrite() const { bool HistoryWidget::isRestrictedWrite() const {
if (auto megagroup = _peer ? _peer->asMegagroup() : nullptr) { if (auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
return megagroup->restricted( return megagroup->restricted(
ChannelRestriction::f_send_messages); ChatRestriction::f_send_messages);
} }
return false; return false;
} }
@ -3033,7 +3033,7 @@ void HistoryWidget::step_recording(float64 ms, bool timer) {
void HistoryWidget::chooseAttach() { void HistoryWidget::chooseAttach() {
if (!_peer || !_peer->canWrite()) return; if (!_peer || !_peer->canWrite()) return;
if (auto megagroup = _peer->asMegagroup()) { if (auto megagroup = _peer->asMegagroup()) {
if (megagroup->restricted(ChannelRestriction::f_send_media)) { if (megagroup->restricted(ChatRestriction::f_send_media)) {
Ui::show(Box<InformBox>(lang(lng_restricted_send_media))); Ui::show(Box<InformBox>(lang(lng_restricted_send_media)));
return; return;
} }
@ -3143,7 +3143,7 @@ void HistoryWidget::recordStartCallback() {
return; return;
} }
if (auto megagroup = _peer ? _peer->asMegagroup() : nullptr) { if (auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
if (megagroup->restricted(ChannelRestriction::f_send_media)) { if (megagroup->restricted(ChatRestriction::f_send_media)) {
Ui::show(Box<InformBox>(lang(lng_restricted_send_media))); Ui::show(Box<InformBox>(lang(lng_restricted_send_media)));
return; return;
} }
@ -3938,7 +3938,7 @@ bool HistoryWidget::showSendingFilesError(
const Storage::PreparedList &list) const { const Storage::PreparedList &list) const {
const auto text = [&] { const auto text = [&] {
if (const auto megagroup = _peer ? _peer->asMegagroup() : nullptr) { if (const auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
if (megagroup->restricted(ChannelRestriction::f_send_media)) { if (megagroup->restricted(ChatRestriction::f_send_media)) {
return lang(lng_restricted_send_media); return lang(lng_restricted_send_media);
} }
} }
@ -5377,7 +5377,7 @@ bool HistoryWidget::sendExistingDocument(
not_null<DocumentData*> document, not_null<DocumentData*> document,
TextWithEntities caption) { TextWithEntities caption) {
if (const auto megagroup = _peer ? _peer->asMegagroup() : nullptr) { if (const auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
if (megagroup->restricted(ChannelRestriction::f_send_stickers)) { if (megagroup->restricted(ChatRestriction::f_send_stickers)) {
Ui::show( Ui::show(
Box<InformBox>(lang(lng_restricted_send_stickers)), Box<InformBox>(lang(lng_restricted_send_stickers)),
LayerOption::KeepOther); LayerOption::KeepOther);
@ -5413,7 +5413,7 @@ bool HistoryWidget::sendExistingPhoto(
not_null<PhotoData*> photo, not_null<PhotoData*> photo,
TextWithEntities caption) { TextWithEntities caption) {
if (const auto megagroup = _peer ? _peer->asMegagroup() : nullptr) { if (const auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
if (megagroup->restricted(ChannelRestriction::f_send_media)) { if (megagroup->restricted(ChatRestriction::f_send_media)) {
Ui::show( Ui::show(
Box<InformBox>(lang(lng_restricted_send_media)), Box<InformBox>(lang(lng_restricted_send_media)),
LayerOption::KeepOther); LayerOption::KeepOther);
@ -5860,7 +5860,7 @@ void HistoryWidget::previewCancel() {
void HistoryWidget::checkPreview() { void HistoryWidget::checkPreview() {
auto previewRestricted = [this] { auto previewRestricted = [this] {
if (auto megagroup = _peer ? _peer->asMegagroup() : nullptr) { if (auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
if (megagroup->restricted(ChannelRestriction::f_embed_links)) { if (megagroup->restricted(ChatRestriction::f_embed_links)) {
return true; return true;
} }
} }

View File

@ -305,7 +305,7 @@ void Cover::initViewers() {
void Cover::refreshUploadPhotoOverlay() { void Cover::refreshUploadPhotoOverlay() {
_userpic->switchChangePhotoOverlay([&] { _userpic->switchChangePhotoOverlay([&] {
if (const auto chat = _peer->asChat()) { if (const auto chat = _peer->asChat()) {
return chat->canEdit(); return chat->canEditInformation();
} else if (const auto channel = _peer->asChannel()) { } else if (const auto channel = _peer->asChannel()) {
return channel->canEditInformation(); return channel->canEditInformation();
} }

View File

@ -230,9 +230,10 @@ std::unique_ptr<PeerListRow> ChatMembersController::createRow(
auto ChatMembersController::computeType( auto ChatMembersController::computeType(
not_null<UserData*> user) -> Type { not_null<UserData*> user) -> Type {
auto isCreator = (peerFromUser(_chat->creator) == user->id); auto isCreator = (peerFromUser(_chat->creator) == user->id);
auto isAdmin = _chat->adminsEnabled() // #TODO groups
&& _chat->admins.contains(user); auto isAdmin = false;/* _chat->adminsEnabled()
auto canRemove = [&] { && _chat->admins.contains(user);*/
auto canRemove = false;/* [&] {
if (user->isSelf()) { if (user->isSelf()) {
return false; return false;
} else if (_chat->amCreator()) { } else if (_chat->amCreator()) {
@ -245,7 +246,7 @@ auto ChatMembersController::computeType(
return true; return true;
} }
return false; return false;
}(); }();*/
auto result = Type(); auto result = Type();
result.rights = isCreator result.rights = isCreator

View File

@ -283,7 +283,7 @@ rpl::producer<bool> CanAddMemberValue(
chat, chat,
Notify::PeerUpdate::Flag::ChatCanEdit Notify::PeerUpdate::Flag::ChatCanEdit
) | rpl::map([chat] { ) | rpl::map([chat] {
return chat->canEdit(); return chat->canEditInformation(); // #TODO groups
}); });
} else if (auto channel = peer->asChannel()) { } else if (auto channel = peer->asChannel()) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(

View File

@ -64,7 +64,7 @@ QString SendDataCommon::getErrorOnSend(
const Result *owner, const Result *owner,
not_null<History*> history) const { not_null<History*> history) const {
if (const auto megagroup = history->peer->asMegagroup()) { if (const auto megagroup = history->peer->asMegagroup()) {
if (megagroup->restricted(ChannelRestriction::f_send_messages)) { if (megagroup->restricted(ChatRestriction::f_send_messages)) {
return lang(lng_restricted_send_message); return lang(lng_restricted_send_message);
} }
} }
@ -146,7 +146,7 @@ QString SendPhoto::getErrorOnSend(
const Result *owner, const Result *owner,
not_null<History*> history) const { not_null<History*> history) const {
if (const auto megagroup = history->peer->asMegagroup()) { if (const auto megagroup = history->peer->asMegagroup()) {
if (megagroup->restricted(ChannelRestriction::f_send_media)) { if (megagroup->restricted(ChatRestriction::f_send_media)) {
return lang(lng_restricted_send_media); return lang(lng_restricted_send_media);
} }
} }
@ -181,12 +181,12 @@ QString SendFile::getErrorOnSend(
const Result *owner, const Result *owner,
not_null<History*> history) const { not_null<History*> history) const {
if (const auto megagroup = history->peer->asMegagroup()) { if (const auto megagroup = history->peer->asMegagroup()) {
if (megagroup->restricted(ChannelRestriction::f_send_media)) { if (megagroup->restricted(ChatRestriction::f_send_media)) {
return lang(lng_restricted_send_media); return lang(lng_restricted_send_media);
} else if (megagroup->restricted(ChannelRestriction::f_send_stickers) } else if (megagroup->restricted(ChatRestriction::f_send_stickers)
&& (_document->sticker() != nullptr)) { && (_document->sticker() != nullptr)) {
return lang(lng_restricted_send_stickers); return lang(lng_restricted_send_stickers);
} else if (megagroup->restricted(ChannelRestriction::f_send_gifs) } else if (megagroup->restricted(ChatRestriction::f_send_gifs)
&& _document->isAnimation() && _document->isAnimation()
&& !_document->isVideoMessage()) { && !_document->isVideoMessage()) {
return lang(lng_restricted_send_gifs); return lang(lng_restricted_send_gifs);
@ -222,7 +222,7 @@ QString SendGame::getErrorOnSend(
const Result *owner, const Result *owner,
not_null<History*> history) const { not_null<History*> history) const {
if (auto megagroup = history->peer->asMegagroup()) { if (auto megagroup = history->peer->asMegagroup()) {
if (megagroup->restricted(ChannelRestriction::f_send_games)) { if (megagroup->restricted(ChatRestriction::f_send_games)) {
return lang(lng_restricted_send_inline); return lang(lng_restricted_send_inline);
} }
} }

View File

@ -79,7 +79,7 @@ void Inner::visibleTopBottomUpdated(
void Inner::checkRestrictedPeer() { void Inner::checkRestrictedPeer() {
if (auto megagroup = _inlineQueryPeer ? _inlineQueryPeer->asMegagroup() : nullptr) { if (auto megagroup = _inlineQueryPeer ? _inlineQueryPeer->asMegagroup() : nullptr) {
if (megagroup->restricted(ChannelRestriction::f_send_inline)) { if (megagroup->restricted(ChatRestriction::f_send_inline)) {
if (!_restrictedLabel) { if (!_restrictedLabel) {
_restrictedLabel.create(this, lang(lng_restricted_send_inline), Ui::FlatLabel::InitType::Simple, st::stickersRestrictedLabel); _restrictedLabel.create(this, lang(lng_restricted_send_inline), Ui::FlatLabel::InitType::Simple, st::stickersRestrictedLabel);
_restrictedLabel->show(); _restrictedLabel->show();

View File

@ -563,7 +563,7 @@ bool MainWidget::sendPaths(PeerId peerId) {
Ui::show(Box<InformBox>(lang(lng_forward_send_files_cant))); Ui::show(Box<InformBox>(lang(lng_forward_send_files_cant)));
return false; return false;
} else if (auto megagroup = peer->asMegagroup()) { } else if (auto megagroup = peer->asMegagroup()) {
if (megagroup->restricted(ChannelRestriction::f_send_media)) { if (megagroup->restricted(ChatRestriction::f_send_media)) {
Ui::show(Box<InformBox>(lang(lng_restricted_send_media))); Ui::show(Box<InformBox>(lang(lng_restricted_send_media)));
return false; return false;
} }
@ -4225,9 +4225,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
App::feedParticipantDelete(update.c_updateChatParticipantDelete()); App::feedParticipantDelete(update.c_updateChatParticipantDelete());
} break; } break;
case mtpc_updateChatAdmins: { // #TODO groups new update
App::feedChatAdmins(update.c_updateChatAdmins());
} break;
case mtpc_updateChatParticipantAdmin: { case mtpc_updateChatParticipantAdmin: {
App::feedParticipantAdmin(update.c_updateChatParticipantAdmin()); App::feedParticipantAdmin(update.c_updateChatParticipantAdmin());

View File

@ -464,7 +464,7 @@ void MediaView::updateActions() {
return _userPhotosData && _fullIndex && _fullCount; return _userPhotosData && _fullIndex && _fullCount;
} else if (_photo && _photo->peer && _photo->peer->userpicPhotoId() == _photo->id) { } else if (_photo && _photo->peer && _photo->peer->userpicPhotoId() == _photo->id) {
if (auto chat = _photo->peer->asChat()) { if (auto chat = _photo->peer->asChat()) {
return chat->canEdit(); return chat->canEditInformation();
} else if (auto channel = _photo->peer->asChannel()) { } else if (auto channel = _photo->peer->asChannel()) {
return channel->canEditInformation(); return channel->canEditInformation();
} }

View File

@ -67,11 +67,11 @@ void GroupMembersWidget::editAdmin(not_null<UserData*> user) {
} }
auto currentRightsIt = megagroup->mgInfo->lastAdmins.find(user); auto currentRightsIt = megagroup->mgInfo->lastAdmins.find(user);
auto hasAdminRights = (currentRightsIt != megagroup->mgInfo->lastAdmins.cend()); auto hasAdminRights = (currentRightsIt != megagroup->mgInfo->lastAdmins.cend());
auto currentRights = hasAdminRights ? currentRightsIt->second.rights : MTP_channelAdminRights(MTP_flags(0)); auto currentRights = hasAdminRights ? currentRightsIt->second.rights : MTP_chatAdminRights(MTP_flags(0));
auto weak = std::make_shared<QPointer<EditAdminBox>>(nullptr); auto weak = std::make_shared<QPointer<EditAdminBox>>(nullptr);
auto box = Box<EditAdminBox>(megagroup, user, currentRights); auto box = Box<EditAdminBox>(megagroup, user, currentRights);
box->setSaveCallback(SaveAdminCallback(megagroup, user, [=]( box->setSaveCallback(SaveAdminCallback(megagroup, user, [=](
const MTPChannelAdminRights &newRights) { const MTPChatAdminRights &newRights) {
if (*weak) { if (*weak) {
(*weak)->closeBox(); (*weak)->closeBox();
} }
@ -91,10 +91,10 @@ void GroupMembersWidget::restrictUser(not_null<UserData*> user) {
auto currentRightsIt = megagroup->mgInfo->lastRestricted.find(user); auto currentRightsIt = megagroup->mgInfo->lastRestricted.find(user);
auto currentRights = (currentRightsIt != megagroup->mgInfo->lastRestricted.end()) auto currentRights = (currentRightsIt != megagroup->mgInfo->lastRestricted.end())
? currentRightsIt->second.rights ? currentRightsIt->second.rights
: MTP_channelBannedRights(MTP_flags(0), MTP_int(0)); : MTP_chatBannedRights(MTP_flags(0), MTP_int(0));
auto hasAdminRights = megagroup->mgInfo->lastAdmins.find(user) != megagroup->mgInfo->lastAdmins.cend(); auto hasAdminRights = megagroup->mgInfo->lastAdmins.find(user) != megagroup->mgInfo->lastAdmins.cend();
auto box = Box<EditRestrictedBox>(megagroup, user, hasAdminRights, currentRights); auto box = Box<EditRestrictedBox>(megagroup, user, hasAdminRights, currentRights);
box->setSaveCallback([megagroup, user](const MTPChannelBannedRights &oldRights, const MTPChannelBannedRights &newRights) { box->setSaveCallback([megagroup, user](const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights) {
Ui::hideLayer(); Ui::hideLayer();
// #TODO use Auth().api(). // #TODO use Auth().api().
MTP::send(MTPchannels_EditBanned(megagroup->inputChannel, user->inputUser, newRights), rpcDone([megagroup, user, oldRights, newRights](const MTPUpdates &result) { MTP::send(MTPchannels_EditBanned(megagroup->inputChannel, user->inputUser, newRights), rpcDone([megagroup, user, oldRights, newRights](const MTPUpdates &result) {
@ -110,14 +110,14 @@ void GroupMembersWidget::removePeer(PeerData *selectedPeer) {
Assert(user != nullptr); Assert(user != nullptr);
auto text = lng_profile_sure_kick(lt_user, user->firstName); auto text = lng_profile_sure_kick(lt_user, user->firstName);
auto currentRestrictedRights = [&]() -> MTPChannelBannedRights { auto currentRestrictedRights = [&]() -> MTPChatBannedRights {
if (auto channel = peer()->asMegagroup()) { if (auto channel = peer()->asMegagroup()) {
auto it = channel->mgInfo->lastRestricted.find(user); auto it = channel->mgInfo->lastRestricted.find(user);
if (it != channel->mgInfo->lastRestricted.cend()) { if (it != channel->mgInfo->lastRestricted.cend()) {
return it->second.rights; return it->second.rights;
} }
} }
return MTP_channelBannedRights(MTP_flags(0), MTP_int(0)); return MTP_chatBannedRights(MTP_flags(0), MTP_int(0));
}(); }();
Ui::show(Box<ConfirmBox>(text, lang(lng_box_remove), [user, currentRestrictedRights, peer = peer()] { Ui::show(Box<ConfirmBox>(text, lang(lng_box_remove), [user, currentRestrictedRights, peer = peer()] {
Ui::hideLayer(); Ui::hideLayer();
@ -344,12 +344,13 @@ void GroupMembersWidget::refreshLimitReached() {
void GroupMembersWidget::checkSelfAdmin(ChatData *chat) { void GroupMembersWidget::checkSelfAdmin(ChatData *chat) {
if (chat->participants.empty()) return; if (chat->participants.empty()) return;
// #TODO groups
const auto self = Auth().user(); const auto self = Auth().user();
if (chat->amAdmin() && !chat->admins.contains(self)) { //if (chat->amAdmin() && !chat->admins.contains(self)) {
chat->admins.insert(self); // chat->admins.insert(self);
} else if (!chat->amAdmin() && chat->admins.contains(self)) { //} else if (!chat->amAdmin() && chat->admins.contains(self)) {
chat->admins.remove(self); // chat->admins.remove(self);
} //}
} }
void GroupMembersWidget::sortMembers() { void GroupMembersWidget::sortMembers() {
@ -418,12 +419,13 @@ void GroupMembersWidget::setItemFlags(Item *item, ChatData *chat) {
using AdminState = Item::AdminState; using AdminState = Item::AdminState;
auto user = getMember(item)->user(); auto user = getMember(item)->user();
auto isCreator = (peerFromUser(chat->creator) == item->peer->id); auto isCreator = (peerFromUser(chat->creator) == item->peer->id);
auto isAdmin = chat->adminsEnabled() && chat->admins.contains(user); // #TODO groups
auto isAdmin = false;// chat->adminsEnabled() && chat->admins.contains(user);
auto adminState = isCreator ? AdminState::Creator : isAdmin ? AdminState::Admin : AdminState::None; auto adminState = isCreator ? AdminState::Creator : isAdmin ? AdminState::Admin : AdminState::None;
item->adminState = adminState; item->adminState = adminState;
if (item->peer->id == Auth().userPeerId()) { if (item->peer->id == Auth().userPeerId()) {
item->hasRemoveLink = false; item->hasRemoveLink = false;
} else if (chat->amCreator() || (chat->amAdmin() && (adminState == AdminState::None))) { } else if (chat->amCreator() /*|| (chat->amAdmin() && (adminState == AdminState::None))*/) {
item->hasRemoveLink = true; item->hasRemoveLink = true;
} else if (chat->invitedByMe.contains(user) && (adminState == AdminState::None)) { } else if (chat->invitedByMe.contains(user) && (adminState == AdminState::None)) {
item->hasRemoveLink = true; item->hasRemoveLink = true;

View File

@ -35,9 +35,9 @@ constexpr auto kSortByOnlineDelay = TimeMs(1000);
void RemoveAdmin( void RemoveAdmin(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
not_null<UserData*> user, not_null<UserData*> user,
const MTPChannelAdminRights &oldRights, const MTPChatAdminRights &oldRights,
Fn<void()> onDone) { Fn<void()> onDone) {
const auto newRights = MTP_channelAdminRights(MTP_flags(0)); const auto newRights = MTP_chatAdminRights(MTP_flags(0));
auto done = [=](const MTPUpdates &result) { auto done = [=](const MTPUpdates &result) {
Auth().api().applyUpdates(result); Auth().api().applyUpdates(result);
channel->applyEditAdmin(user, oldRights, newRights); channel->applyEditAdmin(user, oldRights, newRights);
@ -54,15 +54,15 @@ void RemoveAdmin(
} // namespace } // namespace
Fn<void( Fn<void(
const MTPChannelAdminRights &oldRights, const MTPChatAdminRights &oldRights,
const MTPChannelAdminRights &newRights)> SaveAdminCallback( const MTPChatAdminRights &newRights)> SaveAdminCallback(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
not_null<UserData*> user, not_null<UserData*> user,
Fn<void(const MTPChannelAdminRights &newRights)> onDone, Fn<void(const MTPChatAdminRights &newRights)> onDone,
Fn<void()> onFail) { Fn<void()> onFail) {
return [=]( return [=](
const MTPChannelAdminRights &oldRights, const MTPChatAdminRights &oldRights,
const MTPChannelAdminRights &newRights) { const MTPChatAdminRights &newRights) {
auto done = [=](const MTPUpdates &result) { auto done = [=](const MTPUpdates &result) {
Auth().api().applyUpdates(result); Auth().api().applyUpdates(result);
channel->applyEditAdmin(user, oldRights, newRights); channel->applyEditAdmin(user, oldRights, newRights);
@ -278,11 +278,11 @@ void ParticipantsBoxController::addNewItem() {
return; return;
} }
auto weak = base::make_weak(this); auto weak = base::make_weak(this);
_addBox = Ui::show(Box<PeerListBox>(std::make_unique<AddParticipantBoxController>(_channel, _role, [weak](not_null<UserData*> user, const MTPChannelAdminRights &rights) { _addBox = Ui::show(Box<PeerListBox>(std::make_unique<AddParticipantBoxController>(_channel, _role, [weak](not_null<UserData*> user, const MTPChatAdminRights &rights) {
if (const auto strong = weak.get()) { if (const auto strong = weak.get()) {
strong->editAdminDone(user, rights); strong->editAdminDone(user, rights);
} }
}, [weak](not_null<UserData*> user, const MTPChannelBannedRights &rights) { }, [weak](not_null<UserData*> user, const MTPChatBannedRights &rights) {
if (const auto strong = weak.get()) { if (const auto strong = weak.get()) {
strong->editRestrictedDone(user, rights); strong->editRestrictedDone(user, rights);
} }
@ -688,7 +688,7 @@ bool ParticipantsBoxController::canEditAdmin(
} else if (!canEditAdminByRights(user)) { } else if (!canEditAdminByRights(user)) {
return false; return false;
} }
return _channel->adminRights() & ChannelAdminRight::f_add_admins; return _channel->adminRights() & ChatAdminRight::f_add_admins;
} }
bool ParticipantsBoxController::canRestrictUser( bool ParticipantsBoxController::canRestrictUser(
@ -700,7 +700,7 @@ bool ParticipantsBoxController::canRestrictUser(
} else if (!canEditAdminByRights(user)) { } else if (!canEditAdminByRights(user)) {
return false; return false;
} }
return _channel->adminRights() & ChannelAdminRight::f_ban_users; return _channel->adminRights() & ChatAdminRight::f_ban_users;
} }
base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu( base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu(
@ -761,15 +761,15 @@ void ParticipantsBoxController::showAdmin(not_null<UserData*> user) {
auto isCreator = (user == _additional.creator); auto isCreator = (user == _additional.creator);
auto notAdmin = !isCreator && (it == _additional.adminRights.cend()); auto notAdmin = !isCreator && (it == _additional.adminRights.cend());
auto currentRights = isCreator auto currentRights = isCreator
? MTP_channelAdminRights(MTP_flags(~MTPDchannelAdminRights::Flag::f_add_admins | MTPDchannelAdminRights::Flag::f_add_admins)) ? MTP_chatAdminRights(MTP_flags(~MTPDchatAdminRights::Flag::f_add_admins | MTPDchatAdminRights::Flag::f_add_admins))
: notAdmin ? MTP_channelAdminRights(MTP_flags(0)) : it->second; : notAdmin ? MTP_chatAdminRights(MTP_flags(0)) : it->second;
auto weak = base::make_weak(this); auto weak = base::make_weak(this);
auto box = Box<EditAdminBox>(_channel, user, currentRights); auto box = Box<EditAdminBox>(_channel, user, currentRights);
auto canEdit = (_additional.adminCanEdit.find(user) != _additional.adminCanEdit.end()); auto canEdit = (_additional.adminCanEdit.find(user) != _additional.adminCanEdit.end());
auto canSave = notAdmin ? _channel->canAddAdmins() : canEdit; auto canSave = notAdmin ? _channel->canAddAdmins() : canEdit;
if (canSave) { if (canSave) {
box->setSaveCallback(SaveAdminCallback(_channel, user, [=]( box->setSaveCallback(SaveAdminCallback(_channel, user, [=](
const MTPChannelAdminRights &newRights) { const MTPChatAdminRights &newRights) {
if (weak) { if (weak) {
weak->editAdminDone(user, newRights); weak->editAdminDone(user, newRights);
} }
@ -784,14 +784,14 @@ void ParticipantsBoxController::showAdmin(not_null<UserData*> user) {
void ParticipantsBoxController::editAdminDone( void ParticipantsBoxController::editAdminDone(
not_null<UserData*> user, not_null<UserData*> user,
const MTPChannelAdminRights &rights) { const MTPChatAdminRights &rights) {
if (_editBox) { if (_editBox) {
_editBox->closeBox(); _editBox->closeBox();
} }
if (_addBox) { if (_addBox) {
_addBox->closeBox(); _addBox->closeBox();
} }
auto notAdmin = (rights.c_channelAdminRights().vflags.v == 0); auto notAdmin = (rights.c_chatAdminRights().vflags.v == 0);
if (notAdmin) { if (notAdmin) {
_additional.adminRights.erase(user); _additional.adminRights.erase(user);
_additional.adminPromotedBy.erase(user); _additional.adminPromotedBy.erase(user);
@ -820,13 +820,13 @@ void ParticipantsBoxController::editAdminDone(
void ParticipantsBoxController::showRestricted(not_null<UserData*> user) { void ParticipantsBoxController::showRestricted(not_null<UserData*> user) {
auto it = _additional.restrictedRights.find(user); auto it = _additional.restrictedRights.find(user);
auto restrictedRights = (it == _additional.restrictedRights.cend()) auto restrictedRights = (it == _additional.restrictedRights.cend())
? MTP_channelBannedRights(MTP_flags(0), MTP_int(0)) ? MTP_chatBannedRights(MTP_flags(0), MTP_int(0))
: it->second; : it->second;
auto weak = base::make_weak(this); auto weak = base::make_weak(this);
auto hasAdminRights = false; auto hasAdminRights = false;
auto box = Box<EditRestrictedBox>(_channel, user, hasAdminRights, restrictedRights); auto box = Box<EditRestrictedBox>(_channel, user, hasAdminRights, restrictedRights);
if (_channel->canBanMembers()) { if (_channel->canBanMembers()) {
box->setSaveCallback([megagroup = _channel.get(), user, weak](const MTPChannelBannedRights &oldRights, const MTPChannelBannedRights &newRights) { box->setSaveCallback([megagroup = _channel.get(), user, weak](const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights) {
MTP::send(MTPchannels_EditBanned(megagroup->inputChannel, user->inputUser, newRights), rpcDone([megagroup, user, weak, oldRights, newRights](const MTPUpdates &result) { MTP::send(MTPchannels_EditBanned(megagroup->inputChannel, user->inputUser, newRights), rpcDone([megagroup, user, weak, oldRights, newRights](const MTPUpdates &result) {
Auth().api().applyUpdates(result); Auth().api().applyUpdates(result);
megagroup->applyEditBanned(user, oldRights, newRights); megagroup->applyEditBanned(user, oldRights, newRights);
@ -839,15 +839,15 @@ void ParticipantsBoxController::showRestricted(not_null<UserData*> user) {
_editBox = Ui::show(std::move(box), LayerOption::KeepOther); _editBox = Ui::show(std::move(box), LayerOption::KeepOther);
} }
void ParticipantsBoxController::editRestrictedDone(not_null<UserData*> user, const MTPChannelBannedRights &rights) { void ParticipantsBoxController::editRestrictedDone(not_null<UserData*> user, const MTPChatBannedRights &rights) {
if (_editBox) { if (_editBox) {
_editBox->closeBox(); _editBox->closeBox();
} }
if (_addBox) { if (_addBox) {
_addBox->closeBox(); _addBox->closeBox();
} }
auto notBanned = (rights.c_channelBannedRights().vflags.v == 0); auto notBanned = (rights.c_chatBannedRights().vflags.v == 0);
auto fullBanned = rights.c_channelBannedRights().is_view_messages(); auto fullBanned = rights.c_chatBannedRights().is_view_messages();
if (notBanned) { if (notBanned) {
_additional.kicked.erase(user); _additional.kicked.erase(user);
_additional.restrictedRights.erase(user); _additional.restrictedRights.erase(user);
@ -902,7 +902,7 @@ void ParticipantsBoxController::kickMemberSure(not_null<UserData*> user) {
} }
auto alreadyIt = _additional.restrictedRights.find(user); auto alreadyIt = _additional.restrictedRights.find(user);
auto currentRights = (alreadyIt == _additional.restrictedRights.cend()) auto currentRights = (alreadyIt == _additional.restrictedRights.cend())
? MTP_channelBannedRights(MTP_flags(0), MTP_int(0)) ? MTP_chatBannedRights(MTP_flags(0), MTP_int(0))
: alreadyIt->second; : alreadyIt->second;
if (auto row = delegate()->peerListFindRow(user->id)) { if (auto row = delegate()->peerListFindRow(user->id)) {
@ -933,7 +933,7 @@ void ParticipantsBoxController::removeAdminSure(not_null<UserData*> user) {
const auto weak = base::make_weak(this); const auto weak = base::make_weak(this);
RemoveAdmin(_channel, user, oldRightsIt->second, [=] { RemoveAdmin(_channel, user, oldRightsIt->second, [=] {
if (const auto strong = weak.get()) { if (const auto strong = weak.get()) {
const auto newRights = MTP_channelAdminRights(MTP_flags(0)); const auto newRights = MTP_chatAdminRights(MTP_flags(0));
strong->editAdminDone(user, newRights); strong->editAdminDone(user, newRights);
} }
}); });
@ -1367,8 +1367,8 @@ void AddParticipantBoxController::showAdmin(not_null<UserData*> user, bool sure)
auto weak = base::make_weak(this); auto weak = base::make_weak(this);
auto alreadyIt = _additional.adminRights.find(user); auto alreadyIt = _additional.adminRights.find(user);
auto currentRights = (_additional.creator == user) auto currentRights = (_additional.creator == user)
? MTP_channelAdminRights(MTP_flags(~MTPDchannelAdminRights::Flag::f_add_admins | MTPDchannelAdminRights::Flag::f_add_admins)) ? MTP_chatAdminRights(MTP_flags(~MTPDchatAdminRights::Flag::f_add_admins | MTPDchatAdminRights::Flag::f_add_admins))
: MTP_channelAdminRights(MTP_flags(0)); : MTP_chatAdminRights(MTP_flags(0));
if (alreadyIt != _additional.adminRights.end()) { if (alreadyIt != _additional.adminRights.end()) {
// The user is already an admin. // The user is already an admin.
currentRights = alreadyIt->second; currentRights = alreadyIt->second;
@ -1442,7 +1442,7 @@ void AddParticipantBoxController::showAdmin(not_null<UserData*> user, bool sure)
auto box = Box<EditAdminBox>(_channel, user, currentRights); auto box = Box<EditAdminBox>(_channel, user, currentRights);
if (!canNotEdit) { if (!canNotEdit) {
box->setSaveCallback(SaveAdminCallback(_channel, user, [=]( box->setSaveCallback(SaveAdminCallback(_channel, user, [=](
const MTPChannelAdminRights &newRights) { const MTPChatAdminRights &newRights) {
if (weak) { if (weak) {
weak->editAdminDone(user, newRights); weak->editAdminDone(user, newRights);
} }
@ -1457,13 +1457,13 @@ void AddParticipantBoxController::showAdmin(not_null<UserData*> user, bool sure)
void AddParticipantBoxController::editAdminDone( void AddParticipantBoxController::editAdminDone(
not_null<UserData*> user, not_null<UserData*> user,
const MTPChannelAdminRights &rights) { const MTPChatAdminRights &rights) {
if (_editBox) _editBox->closeBox(); if (_editBox) _editBox->closeBox();
_additional.restrictedRights.erase(user); _additional.restrictedRights.erase(user);
_additional.restrictedBy.erase(user); _additional.restrictedBy.erase(user);
_additional.kicked.erase(user); _additional.kicked.erase(user);
_additional.external.erase(user); _additional.external.erase(user);
if (rights.c_channelAdminRights().vflags.v == 0) { if (rights.c_chatAdminRights().vflags.v == 0) {
_additional.adminRights.erase(user); _additional.adminRights.erase(user);
_additional.adminPromotedBy.erase(user); _additional.adminPromotedBy.erase(user);
_additional.adminCanEdit.erase(user); _additional.adminCanEdit.erase(user);
@ -1493,7 +1493,7 @@ void AddParticipantBoxController::showRestricted(not_null<UserData*> user, bool
// Check restrictions. // Check restrictions.
auto weak = base::make_weak(this); auto weak = base::make_weak(this);
auto alreadyIt = _additional.restrictedRights.find(user); auto alreadyIt = _additional.restrictedRights.find(user);
auto currentRights = MTP_channelBannedRights(MTP_flags(0), MTP_int(0)); auto currentRights = MTP_chatBannedRights(MTP_flags(0), MTP_int(0));
auto hasAdminRights = false; auto hasAdminRights = false;
if (alreadyIt != _additional.restrictedRights.end()) { if (alreadyIt != _additional.restrictedRights.end()) {
// The user is already banned or restricted. // The user is already banned or restricted.
@ -1520,7 +1520,7 @@ void AddParticipantBoxController::showRestricted(not_null<UserData*> user, bool
// Finally edit the restricted. // Finally edit the restricted.
auto box = Box<EditRestrictedBox>(_channel, user, hasAdminRights, currentRights); auto box = Box<EditRestrictedBox>(_channel, user, hasAdminRights, currentRights);
box->setSaveCallback([user, weak](const MTPChannelBannedRights &oldRights, const MTPChannelBannedRights &newRights) { box->setSaveCallback([user, weak](const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights) {
if (weak) { if (weak) {
weak->restrictUserSure(user, oldRights, newRights); weak->restrictUserSure(user, oldRights, newRights);
} }
@ -1528,7 +1528,7 @@ void AddParticipantBoxController::showRestricted(not_null<UserData*> user, bool
_editBox = Ui::show(std::move(box), LayerOption::KeepOther); _editBox = Ui::show(std::move(box), LayerOption::KeepOther);
} }
void AddParticipantBoxController::restrictUserSure(not_null<UserData*> user, const MTPChannelBannedRights &oldRights, const MTPChannelBannedRights &newRights) { void AddParticipantBoxController::restrictUserSure(not_null<UserData*> user, const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights) {
auto weak = base::make_weak(this); auto weak = base::make_weak(this);
MTP::send(MTPchannels_EditBanned(_channel->inputChannel, user->inputUser, newRights), rpcDone([megagroup = _channel.get(), user, weak, oldRights, newRights](const MTPUpdates &result) { MTP::send(MTPchannels_EditBanned(_channel->inputChannel, user->inputUser, newRights), rpcDone([megagroup = _channel.get(), user, weak, oldRights, newRights](const MTPUpdates &result) {
Auth().api().applyUpdates(result); Auth().api().applyUpdates(result);
@ -1541,18 +1541,18 @@ void AddParticipantBoxController::restrictUserSure(not_null<UserData*> user, con
void AddParticipantBoxController::editRestrictedDone( void AddParticipantBoxController::editRestrictedDone(
not_null<UserData*> user, not_null<UserData*> user,
const MTPChannelBannedRights &rights) { const MTPChatBannedRights &rights) {
if (_editBox) _editBox->closeBox(); if (_editBox) _editBox->closeBox();
_additional.adminRights.erase(user); _additional.adminRights.erase(user);
_additional.adminCanEdit.erase(user); _additional.adminCanEdit.erase(user);
_additional.adminPromotedBy.erase(user); _additional.adminPromotedBy.erase(user);
if (rights.c_channelBannedRights().vflags.v == 0) { if (rights.c_chatBannedRights().vflags.v == 0) {
_additional.restrictedRights.erase(user); _additional.restrictedRights.erase(user);
_additional.restrictedBy.erase(user); _additional.restrictedBy.erase(user);
_additional.kicked.erase(user); _additional.kicked.erase(user);
} else { } else {
_additional.restrictedRights[user] = rights; _additional.restrictedRights[user] = rights;
if (rights.c_channelBannedRights().vflags.v & MTPDchannelBannedRights::Flag::f_view_messages) { if (rights.c_chatBannedRights().vflags.v & MTPDchatBannedRights::Flag::f_view_messages) {
_additional.kicked.emplace(user); _additional.kicked.emplace(user);
} else { } else {
_additional.kicked.erase(user); _additional.kicked.erase(user);
@ -1602,7 +1602,7 @@ void AddParticipantBoxController::kickUser(not_null<UserData*> user, bool sure)
}), LayerOption::KeepOther); }), LayerOption::KeepOther);
return; return;
} }
auto currentRights = MTP_channelBannedRights(MTP_flags(0), MTP_int(0)); auto currentRights = MTP_chatBannedRights(MTP_flags(0), MTP_int(0));
auto alreadyIt = _additional.restrictedRights.find(user); auto alreadyIt = _additional.restrictedRights.find(user);
if (alreadyIt != _additional.restrictedRights.end()) { if (alreadyIt != _additional.restrictedRights.end()) {
// The user is already banned or restricted. // The user is already banned or restricted.

View File

@ -21,11 +21,11 @@ class Navigation;
namespace Profile { namespace Profile {
Fn<void( Fn<void(
const MTPChannelAdminRights &oldRights, const MTPChatAdminRights &oldRights,
const MTPChannelAdminRights &newRights)> SaveAdminCallback( const MTPChatAdminRights &newRights)> SaveAdminCallback(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
not_null<UserData*> user, not_null<UserData*> user,
Fn<void(const MTPChannelAdminRights &newRights)> onDone, Fn<void(const MTPChatAdminRights &newRights)> onDone,
Fn<void()> onFail); Fn<void()> onFail);
// Viewing admins, banned or restricted users list with search. // Viewing admins, banned or restricted users list with search.
@ -48,10 +48,10 @@ public:
Role role); Role role);
struct Additional { struct Additional {
std::map<not_null<UserData*>, MTPChannelAdminRights> adminRights; std::map<not_null<UserData*>, MTPChatAdminRights> adminRights;
std::set<not_null<UserData*>> adminCanEdit; std::set<not_null<UserData*>> adminCanEdit;
std::map<not_null<UserData*>, not_null<UserData*>> adminPromotedBy; std::map<not_null<UserData*>, not_null<UserData*>> adminPromotedBy;
std::map<not_null<UserData*>, MTPChannelBannedRights> restrictedRights; std::map<not_null<UserData*>, MTPChatBannedRights> restrictedRights;
std::set<not_null<UserData*>> kicked; std::set<not_null<UserData*>> kicked;
std::map<not_null<UserData*>, not_null<UserData*>> restrictedBy; std::map<not_null<UserData*>, not_null<UserData*>> restrictedBy;
std::set<not_null<UserData*>> external; std::set<not_null<UserData*>> external;
@ -122,11 +122,11 @@ private:
void showAdmin(not_null<UserData*> user); void showAdmin(not_null<UserData*> user);
void editAdminDone( void editAdminDone(
not_null<UserData*> user, not_null<UserData*> user,
const MTPChannelAdminRights &rights); const MTPChatAdminRights &rights);
void showRestricted(not_null<UserData*> user); void showRestricted(not_null<UserData*> user);
void editRestrictedDone( void editRestrictedDone(
not_null<UserData*> user, not_null<UserData*> user,
const MTPChannelBannedRights &rights); const MTPChatBannedRights &rights);
void removeKicked(not_null<PeerListRow*> row, not_null<UserData*> user); void removeKicked(not_null<PeerListRow*> row, not_null<UserData*> user);
void kickMember(not_null<UserData*> user); void kickMember(not_null<UserData*> user);
void kickMemberSure(not_null<UserData*> user); void kickMemberSure(not_null<UserData*> user);
@ -219,8 +219,8 @@ public:
using Role = ParticipantsBoxController::Role; using Role = ParticipantsBoxController::Role;
using Additional = ParticipantsBoxController::Additional; using Additional = ParticipantsBoxController::Additional;
using AdminDoneCallback = Fn<void(not_null<UserData*> user, const MTPChannelAdminRights &adminRights)>; using AdminDoneCallback = Fn<void(not_null<UserData*> user, const MTPChatAdminRights &adminRights)>;
using BannedDoneCallback = Fn<void(not_null<UserData*> user, const MTPChannelBannedRights &bannedRights)>; using BannedDoneCallback = Fn<void(not_null<UserData*> user, const MTPChatBannedRights &bannedRights)>;
AddParticipantBoxController(not_null<ChannelData*> channel, Role role, AdminDoneCallback adminDoneCallback, BannedDoneCallback bannedDoneCallback); AddParticipantBoxController(not_null<ChannelData*> channel, Role role, AdminDoneCallback adminDoneCallback, BannedDoneCallback bannedDoneCallback);
void prepare() override; void prepare() override;
@ -238,11 +238,11 @@ private:
bool checkInfoLoaded(not_null<UserData*> user, Callback callback); bool checkInfoLoaded(not_null<UserData*> user, Callback callback);
void showAdmin(not_null<UserData*> user, bool sure = false); void showAdmin(not_null<UserData*> user, bool sure = false);
void editAdminDone(not_null<UserData*> user, const MTPChannelAdminRights &rights); void editAdminDone(not_null<UserData*> user, const MTPChatAdminRights &rights);
void showRestricted(not_null<UserData*> user, bool sure = false); void showRestricted(not_null<UserData*> user, bool sure = false);
void editRestrictedDone(not_null<UserData*> user, const MTPChannelBannedRights &rights); void editRestrictedDone(not_null<UserData*> user, const MTPChatBannedRights &rights);
void kickUser(not_null<UserData*> user, bool sure = false); void kickUser(not_null<UserData*> user, bool sure = false);
void restrictUserSure(not_null<UserData*> user, const MTPChannelBannedRights &oldRights, const MTPChannelBannedRights &newRights); void restrictUserSure(not_null<UserData*> user, const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights);
bool appendRow(not_null<UserData*> user); bool appendRow(not_null<UserData*> user);
bool prependRow(not_null<UserData*> user); bool prependRow(not_null<UserData*> user);
std::unique_ptr<PeerListRow> createRow(not_null<UserData*> user) const; std::unique_ptr<PeerListRow> createRow(not_null<UserData*> user) const;

View File

@ -749,24 +749,26 @@ void FileLoadTask::process() {
attributes[0] = MTP_documentAttributeAudio(MTP_flags(flags), MTP_int(_duration), MTPstring(), MTPstring(), MTP_bytes(documentWaveformEncode5bit(_waveform))); attributes[0] = MTP_documentAttributeAudio(MTP_flags(flags), MTP_int(_duration), MTPstring(), MTPstring(), MTP_bytes(documentWaveformEncode5bit(_waveform)));
attributes.resize(1); attributes.resize(1);
document = MTP_document( document = MTP_document(
MTP_flags(0),
MTP_long(_id), MTP_long(_id),
MTP_long(0), MTP_long(0),
MTP_bytes(QByteArray()), MTP_bytes(QByteArray()),
MTP_int(unixtime()), MTP_int(unixtime()),
MTP_string(filemime), MTP_string(filemime),
MTP_int(filesize), MTP_int(filesize),
thumbSize, MTP_vector<MTPPhotoSize>(1, thumbSize),
MTP_int(MTP::maindc()), MTP_int(MTP::maindc()),
MTP_vector<MTPDocumentAttribute>(attributes)); MTP_vector<MTPDocumentAttribute>(attributes));
} else if (_type != SendMediaType::Photo) { } else if (_type != SendMediaType::Photo) {
document = MTP_document( document = MTP_document(
MTP_flags(0),
MTP_long(_id), MTP_long(_id),
MTP_long(0), MTP_long(0),
MTP_bytes(QByteArray()), MTP_bytes(QByteArray()),
MTP_int(unixtime()), MTP_int(unixtime()),
MTP_string(filemime), MTP_string(filemime),
MTP_int(filesize), MTP_int(filesize),
thumbSize, MTP_vector<MTPPhotoSize>(1, thumbSize),
MTP_int(MTP::maindc()), MTP_int(MTP::maindc()),
MTP_vector<MTPDocumentAttribute>(attributes)); MTP_vector<MTPDocumentAttribute>(attributes));
_type = SendMediaType::File; _type = SendMediaType::File;

View File

@ -354,7 +354,8 @@ void Filler::addUserActions(not_null<UserData*> user) {
void Filler::addChatActions(not_null<ChatData*> chat) { void Filler::addChatActions(not_null<ChatData*> chat) {
if (_source != PeerMenuSource::ChatsList) { if (_source != PeerMenuSource::ChatsList) {
if (chat->canEdit()) { // #TODO groups
if (chat->canEditInformation()) {
_addAction( _addAction(
lang(lng_manage_group_title), lang(lng_manage_group_title),
[chat] { Ui::show(Box<EditPeerInfoBox>(chat)); }); [chat] { Ui::show(Box<EditPeerInfoBox>(chat)); });