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;
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;
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;
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;
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;
wallPaper#ccb03657 id:int title:string sizes:Vector<PhotoSize> color:int = WallPaper;
wallPaperSolid#63117f24 id:int title:string bg_color:int color:int = WallPaper;
wallPaper#f04f91ec id:long flags:# creator:flags.0?true default:flags.1?true access_hash:long slug:string document:Document = WallPaper;
inputReportReasonSpam#58dbcab8 = 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;
updateDeleteChannelMessages#c37521c9 channel_id:int messages:Vector<int> pts:int pts_count: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;
updateNewStickerSet#688a30aa stickerset:messages.StickerSet = 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;
updateChatPinnedMessage#22893b26 chat_id:int id:int = 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;
@ -514,7 +513,7 @@ inputDocumentEmpty#72f0eaae = InputDocument;
inputDocument#1abfb575 id:long access_hash:long file_reference:bytes = InputDocument;
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;
@ -676,8 +675,8 @@ channelMessagesFilter#cd77d957 flags:# exclude_new_messages:flags.1?true ranges:
channelParticipant#15ebac1d user_id:int date:int = ChannelParticipant;
channelParticipantSelf#a3289a6d user_id:int inviter_id:int date: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;
channelParticipantBanned#222c1886 flags:# left:flags.0?true user_id:int kicked_by:int date:int banned_rights:ChannelBannedRights = 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#1c0facaf flags:# left:flags.0?true user_id:int kicked_by:int date:int banned_rights:ChatBannedRights = ChannelParticipant;
channelParticipantsRecent#de3f3c79 = ChannelParticipantsFilter;
channelParticipantsAdmins#b4608969 = ChannelParticipantsFilter;
@ -685,6 +684,7 @@ channelParticipantsKicked#a3b54985 q:string = ChannelParticipantsFilter;
channelParticipantsBots#b0d1865b = ChannelParticipantsFilter;
channelParticipantsBanned#1427a5e1 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.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;
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;
channelAdminLogEventActionChangeAbout#55188a2e 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;
channelAdminLogEventActionChangeStickerSet#b1c3caa7 prev_stickerset:InputStickerSet new_stickerset:InputStickerSet = 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;
@ -1104,6 +1102,16 @@ chatOnlines#f041e250 onlines:int = ChatOnlines;
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---
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.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.getWallPapers#c04cfac2 = Vector<WallPaper>;
account.getWallPapers#aabb1763 hash:int = account.WallPapers;
account.reportPeer#ae189d5f peer:InputPeer reason:ReportReason = Bool;
account.checkUsername#2714d86c username:string = Bool;
account.updateUsername#3e0bdd7c username:string = User;
@ -1178,6 +1186,10 @@ account.cancelPasswordEmail#c1cbd5b6 = Bool;
account.getContactSignUpNotification#9f07c728 = Bool;
account.setContactSignUpNotification#cff43f61 silent:Bool = Bool;
account.getNotifyExceptions#53577479 flags:# compare_sound:flags.1?true peer:flags.0?InputNotifyPeer = Updates;
account.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.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.getAllStickers#1c9618b1 hash:int = messages.AllStickers;
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.importChatInvite#6c50051c hash:string = Updates;
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.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.toggleChatAdmins#ec8bd9e1 chat_id:int enabled:Bool = Updates;
messages.editChatAdmin#a9e69f2e chat_id:int user_id:InputUser is_admin:Bool = Bool;
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;
@ -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.getOnlines#6e2be050 peer:InputPeer = ChatOnlines;
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.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.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull;
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#20b88214 channel:InputChannel user_id:InputUser admin_rights:ChannelAdminRights = Updates;
channels.editAdmin#70f893ba channel:InputChannel user_id:InputUser admin_rights:ChatAdminRights = Updates;
channels.editTitle#566decd0 channel:InputChannel title:string = Updates;
channels.editPhoto#f12e57c9 channel:InputChannel photo:InputChatPhoto = Updates;
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.leaveChannel#f836aa95 channel:InputChannel = Updates;
channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = Updates;
channels.exportInvite#c7560885 channel:InputChannel = ExportedChatInvite;
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.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates;
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.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet = 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.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;
auto botStatus = channel->mgInfo->botStatus;
const auto emptyAdminRights = MTP_channelAdminRights(MTP_flags(0));
const auto emptyRestrictedRights = MTP_channelBannedRights(
const auto emptyAdminRights = MTP_chatAdminRights(MTP_flags(0));
const auto emptyRestrictedRights = MTP_chatBannedRights(
MTP_flags(0),
MTP_int(0));
for (const auto &p : list) {
@ -1406,11 +1406,11 @@ void ApiWrap::applyLastParticipantsList(
}
if (!base::contains(channel->mgInfo->lastParticipants, user)) {
channel->mgInfo->lastParticipants.push_back(user);
if (adminRights.c_channelAdminRights().vflags.v) {
if (adminRights.c_chatAdminRights().vflags.v) {
channel->mgInfo->lastAdmins.emplace(
user,
MegagroupInfo::Admin{ adminRights, adminCanEdit });
} else if (restrictedRights.c_channelBannedRights().vflags.v != 0) {
} else if (restrictedRights.c_chatBannedRights().vflags.v != 0) {
channel->mgInfo->lastRestricted.emplace(
user,
MegagroupInfo::Restricted{ restrictedRights });
@ -1552,7 +1552,9 @@ void ApiWrap::requestSelfParticipant(ChannelData *channel) {
} break;
case mtpc_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;
} break;
}
@ -1582,7 +1584,7 @@ void ApiWrap::kickParticipant(
void ApiWrap::kickParticipant(
not_null<ChannelData*> channel,
not_null<UserData*> user,
const MTPChannelBannedRights &currentRights) {
const MTPChatBannedRights &currentRights) {
const auto kick = KickRequest(channel, user);
if (_kickRequests.contains(kick)) return;
@ -1614,7 +1616,7 @@ void ApiWrap::unblockParticipant(
const auto requestId = request(MTPchannels_EditBanned(
channel->inputChannel,
user->inputUser,
MTP_channelBannedRights(MTP_flags(0), MTP_int(0))
MTP_chatBannedRights(MTP_flags(0), MTP_int(0))
)).done([=](const MTPUpdates &result) {
applyUpdates(result);
@ -1947,36 +1949,26 @@ void ApiWrap::exportInviteLink(not_null<PeerData*> peer) {
return;
}
const auto sendRequest = [this, peer] {
const auto exportFail = [this, peer](const RPCError &error) {
const auto requestId = [&] {
return request(MTPmessages_ExportChatInvite(
peer->input
)).done([=](const MTPExportedChatInvite &result) {
_exportInviteRequests.erase(peer);
};
if (const auto chat = peer->asChat()) {
return request(MTPmessages_ExportChatInvite(
chat->inputChat
)).done([=](const MTPExportedChatInvite &result) {
_exportInviteRequests.erase(chat);
chat->setInviteLink(
(result.type() == mtpc_chatInviteExported
? qs(result.c_chatInviteExported().vlink)
: QString()));
}).fail(exportFail).send();
} else if (const auto channel = peer->asChannel()) {
return request(MTPchannels_ExportInvite(
channel->inputChannel
)).done([=](const MTPExportedChatInvite &result) {
_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);
}
const auto link = (result.type() == mtpc_chatInviteExported)
? qs(result.c_chatInviteExported().vlink)
: QString();
if (const auto chat = peer->asChat()) {
chat->setInviteLink(link);
} else if (const auto channel = peer->asChannel()) {
channel->setInviteLink(link);
} else {
Unexpected("Peer in ApiWrap::exportInviteLink.");
}
}).fail([=](const RPCError &error) {
_exportInviteRequests.erase(peer);
}).send();
}();
_exportInviteRequests.emplace(peer, requestId);
}
void ApiWrap::requestNotifySettings(const MTPInputNotifyPeer &peer) {
@ -3653,17 +3645,18 @@ void ApiWrap::editChatAdmins(
_chatAdminsToSave.emplace(chat, std::move(admins));
}
auto requestId = request(MTPmessages_ToggleChatAdmins(chat->inputChat, MTP_bool(adminsEnabled))).done([this, chat](const MTPUpdates &updates) {
_chatAdminsEnabledRequests.remove(chat);
applyUpdates(updates);
saveChatAdmins(chat);
}).fail([this, chat](const RPCError &error) {
_chatAdminsEnabledRequests.remove(chat);
if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
saveChatAdmins(chat);
}
}).send();
_chatAdminsEnabledRequests.emplace(chat, requestId);
// #TODO groups
//auto requestId = request(MTPmessages_ToggleChatAdmins(chat->inputChat, MTP_bool(adminsEnabled))).done([this, chat](const MTPUpdates &updates) {
// _chatAdminsEnabledRequests.remove(chat);
// applyUpdates(updates);
// saveChatAdmins(chat);
//}).fail([this, chat](const RPCError &error) {
// _chatAdminsEnabledRequests.remove(chat);
// if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
// saveChatAdmins(chat);
// }
//}).send();
//_chatAdminsEnabledRequests.emplace(chat, requestId);
}
void ApiWrap::saveChatAdmins(not_null<ChatData*> chat) {

View file

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

View file

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

View file

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

View file

@ -96,7 +96,7 @@ void ShowAddParticipantsError(
auto box = Box<EditAdminBox>(
channel,
user,
MTP_channelAdminRights(MTP_flags(0)));
MTP_chatAdminRights(MTP_flags(0)));
box->setSaveCallback(saveCallback);
*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));
}
_createdChannel = channel;
_creationRequestId = request(
MTPchannels_ExportInvite(_createdChannel->inputChannel)
).done([this](const MTPExportedChatInvite &result) {
_creationRequestId = request(MTPmessages_ExportChatInvite(
_createdChannel->input
)).done([=](const MTPExportedChatInvite &result) {
_creationRequestId = 0;
if (result.type() == mtpc_chatInviteExported) {
auto link = qs(result.c_chatInviteExported().vlink);
@ -1324,7 +1324,12 @@ void EditChannelBox::save() {
if (_sentTitle == _channel->name) {
saveDescription();
} 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()) {
saveSign();
} 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()) {
saveInvites();
} 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() {
if (!canEditInvites() || _channel->anyoneCanAddMembers() == (_inviteGroup->value() == Invites::Everybody)) {
closeBox();
} else {
_saveInvitesRequestId = MTP::send(MTPchannels_ToggleInvites(_channel->inputChannel, MTP_bool(_inviteGroup->value() == Invites::Everybody)), rpcDone(&EditChannelBox::onSaveInvitesDone), rpcFail(&EditChannelBox::onSaveFail));
}
// #TODO groups
//if (!canEditInvites() || _channel->anyoneCanAddMembers() == (_inviteGroup->value() == Invites::Everybody)) {
// closeBox();
//} 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) {

View file

@ -18,7 +18,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_overview.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:
Inner(QWidget *parent);
@ -35,7 +38,6 @@ protected:
void mouseReleaseEvent(QMouseEvent *e) override;
private:
void gotWallpapers(const MTPVector<MTPWallPaper> &result);
void updateWallpapers();
Fn<void(int index)> _backgroundChosenCallback;
@ -75,12 +77,21 @@ void BackgroundBox::backgroundChosen(int index) {
closeBox();
}
BackgroundBox::Inner::Inner(QWidget *parent) : TWidget(parent)
, _check(std::make_unique<Ui::RoundCheckbox>(st::overviewCheck, [this] { update(); })) {
BackgroundBox::Inner::Inner(QWidget *parent) : RpWidget(parent)
, _check(std::make_unique<Ui::RoundCheckbox>(st::overviewCheck, [=] { update(); })) {
_check->setChecked(true, Ui::RoundCheckbox::SetStyle::Fast);
if (!Auth().data().wallpapersCount()) {
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 {
updateWallpapers();
}
@ -94,11 +105,6 @@ BackgroundBox::Inner::Inner(QWidget *parent) : TWidget(parent)
setMouseTracking(true);
}
void BackgroundBox::Inner::gotWallpapers(const MTPVector<MTPWallPaper> &result) {
Auth().data().setWallpapers(result.v);
updateWallpapers();
}
void BackgroundBox::Inner::updateWallpapers() {
_bgCount = Auth().data().wallpapersCount();
_rows = _bgCount / BackgroundsInRow;

View file

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

View file

@ -202,26 +202,21 @@ void EditParticipantBox::resizeToContent() {
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) {
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()
? (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_post_messages | Flag::f_edit_messages | Flag::f_delete_messages | Flag::f_invite_users | Flag::f_invite_link);
return MTP_channelAdminRights(MTP_flags(defaultRights));
? (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);
return MTP_chatAdminRights(MTP_flags(defaultRights));
}
void EditAdminBox::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));
addControl(object_ptr<BoxContentDivider>(this), QMargins());
@ -231,7 +226,7 @@ void EditAdminBox::prepare() {
const auto filterByMyRights = canSave()
&& !hadRights
&& !channel()->amCreator();
const auto prepareFlags = prepareRights.c_channelAdminRights().vflags.v
const auto prepareFlags = prepareRights.c_chatAdminRights().vflags.v
& (filterByMyRights ? channel()->adminRights() : ~Flag(0));
auto addCheckbox = [&](Flags flags, const QString &text) {
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_delete_messages, lang(lng_rights_group_delete));
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_add_admins, lang(lng_rights_add_admins));
} else {
@ -264,7 +259,7 @@ void EditAdminBox::prepare() {
addCheckbox(Flag::f_post_messages, lang(lng_rights_channel_post));
addCheckbox(Flag::f_edit_messages, lang(lng_rights_channel_edit));
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));
}
@ -286,7 +281,7 @@ void EditAdminBox::prepare() {
if (!_saveCallback) {
return;
}
auto newFlags = MTPDchannelAdminRights::Flags(0);
auto newFlags = MTPDchatAdminRights::Flags(0);
for (auto &&checkbox : _checkboxes) {
if (checkbox.second->checked()) {
newFlags |= checkbox.first;
@ -298,7 +293,7 @@ void EditAdminBox::prepare() {
// Leave only rights that we have so we could save them.
newFlags &= channel()->adminRights();
}
_saveCallback(_oldRights, MTP_channelAdminRights(MTP_flags(newFlags)));
_saveCallback(_oldRights, MTP_chatAdminRights(MTP_flags(newFlags)));
});
addButton(langFactory(lng_cancel), [this] { closeBox(); });
} else {
@ -332,7 +327,7 @@ void EditAdminBox::refreshAboutAddAdminsText() {
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) {
auto dependency = [this](Flag dependent, Flag 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<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()));
_until = prepareRights.c_channelBannedRights().vuntil_date.v;
auto prepareRights = (_oldRights.c_chatBannedRights().vflags.v ? _oldRights : DefaultRights(channel()));
_until = prepareRights.c_chatBannedRights().vuntil_date.v;
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);
control->checkedChanges(
) | rpl::start_with_next([=](bool checked) {
@ -391,7 +386,7 @@ void EditRestrictedBox::prepare() {
if (!_saveCallback) {
return;
}
auto newFlags = MTPDchannelBannedRights::Flags(0);
auto newFlags = MTPDchatBannedRights::Flags(0);
for (auto &&checkbox : _checkboxes) {
if (checkbox.second->checked()) {
newFlags &= ~checkbox.first;
@ -399,7 +394,7 @@ void EditRestrictedBox::prepare() {
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(); });
} else {
@ -418,9 +413,9 @@ void EditRestrictedBox::applyDependencies(QPointer<Ui::Checkbox> 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;
return MTP_channelBannedRights(MTP_flags(defaultRights), MTP_int(0));
return MTP_chatBannedRights(MTP_flags(defaultRights), MTP_int(0));
}
void EditRestrictedBox::showRestrictUntil() {
@ -489,7 +484,7 @@ void EditRestrictedBox::createUntilVariants() {
}
};
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) {
addCustomVariant(oldUntil, from, to);
}

View file

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

View file

@ -684,8 +684,9 @@ void EditChatAdminsBoxController::prepare() {
}
void EditChatAdminsBoxController::createAllAdminsCheckbox() {
// #TODO groups
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(false, st::defaultTextStyle, lang(lng_chat_about_admins), _defaultOptions, labelWidth);
_allAdmins = checkbox;
@ -844,14 +845,15 @@ bool AddBotToGroupBoxController::needToCreateRow(not_null<PeerData*> peer) const
return false;
}
if (auto group = peer->asMegagroup()) {
if (group->restricted(ChannelRestriction::f_send_games)) {
if (group->restricted(ChatRestriction::f_send_games)) {
return false;
}
}
return true;
}
if (auto chat = peer->asChat()) {
if (chat->canEdit()) {
// #TODO groups
if (chat->canEditInformation()) {
return true;
}
} else if (auto group = peer->asMegagroup()) {

View file

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

View file

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

View file

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

View file

@ -326,7 +326,7 @@ bool MediaPhoto::allowsEditCaption() const {
QString MediaPhoto::errorTextForForward(
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 QString();
@ -652,20 +652,20 @@ bool MediaFile::forwardedBecomesUnread() const {
QString MediaFile::errorTextForForward(
not_null<ChannelData*> channel) const {
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);
}
} else if (_document->isAnimation()) {
if (_document->isVideoMessage()) {
if (channel->restricted(ChannelRestriction::f_send_media)) {
if (channel->restricted(ChatRestriction::f_send_media)) {
return lang(lng_restricted_send_media);
}
} else {
if (channel->restricted(ChannelRestriction::f_send_gifs)) {
if (channel->restricted(ChatRestriction::f_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 QString();
@ -1117,7 +1117,7 @@ TextWithEntities MediaGame::clipboardText() const {
QString MediaGame::errorTextForForward(
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 QString();

View file

@ -343,14 +343,16 @@ bool PeerData::canPinMessages() const {
if (const auto user = asUser()) {
return user->fullFlags() & MTPDuserFull::Flag::f_can_pin_message;
} 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()) {
using AdminRight = ChannelData::AdminRight;
if (channel->isMegagroup()) {
return (channel->adminRights() & AdminRight::f_pin_messages)
return (channel->adminRights() & ChatAdminRight::f_pin_messages)
|| channel->amCreator();
}
return (channel->adminRights() & AdminRight::f_edit_messages)
return (channel->adminRights() & ChatAdminRight::f_edit_messages)
|| channel->amCreator();
}
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) {
updateNameDelayed(newName.isEmpty() ? name : newName, QString(), QString());
}
void ChatData::invalidateParticipants() {
auto wasCanEdit = canEdit();
// #TODO groups
auto wasCanEdit = canEditInformation();
participants.clear();
admins.clear();
removeFlags(MTPDchat::Flag::f_admin);
//removeFlags(MTPDchat::Flag::f_admin);
invitedByMe.clear();
botStatus = 0;
if (wasCanEdit != canEdit()) {
if (wasCanEdit != canEditInformation()) {
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::ChatCanEdit);
}
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::MembersChanged | Notify::PeerUpdate::Flag::AdminsChanged);
@ -777,13 +786,13 @@ void ChannelData::setKickedCount(int newKickedCount) {
}
}
MTPChannelBannedRights ChannelData::KickedRestrictedRights() {
using Flag = MTPDchannelBannedRights::Flag;
MTPChatBannedRights ChannelData::KickedRestrictedRights() {
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;
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;
if (mgInfo) {
// 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 it = mgInfo->lastAdmins.find(user);
if (newRights.c_channelAdminRights().vflags.v != 0) {
if (newRights.c_chatAdminRights().vflags.v != 0) {
auto lastAdmin = MegagroupInfo::Admin { newRights };
lastAdmin.canEdit = true;
if (it == mgInfo->lastAdmins.cend()) {
@ -827,7 +836,7 @@ void ChannelData::applyEditAdmin(not_null<UserData*> user, const MTPChannelAdmin
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.
if (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.
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.
setAdminsCount(adminsCount() + 1);
updateFullForced();
@ -844,10 +853,10 @@ void ChannelData::applyEditAdmin(not_null<UserData*> user, const MTPChannelAdmin
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 isKicked = (newRights.c_channelBannedRights().vflags.v & MTPDchannelBannedRights::Flag::f_view_messages);
auto isRestricted = !isKicked && (newRights.c_channelBannedRights().vflags.v != 0);
auto isKicked = (newRights.c_chatBannedRights().vflags.v & MTPDchatBannedRights::Flag::f_view_messages);
auto isRestricted = !isKicked && (newRights.c_chatBannedRights().vflags.v != 0);
if (mgInfo) {
// If rights are empty - still remove admin? TODO check
if (mgInfo->lastAdmins.contains(user)) {
@ -968,7 +977,8 @@ bool ChannelData::canDeleteMessages() const {
}
bool ChannelData::anyoneCanAddMembers() const {
return (flags() & MTPDchannel::Flag::f_democracy);
// #TODO groups
return false;// (flags() & MTPDchannel::Flag::f_democracy);
}
bool ChannelData::hiddenPreHistory() const {
@ -1084,11 +1094,11 @@ bool ChannelData::canRestrictUser(not_null<UserData*> user) const {
return adminRights() & AdminRight::f_ban_users;
}
void ChannelData::setAdminRights(const MTPChannelAdminRights &rights) {
if (rights.c_channelAdminRights().vflags.v == adminRights()) {
void ChannelData::setAdminRights(const MTPChatAdminRights &rights) {
if (rights.c_chatAdminRights().vflags.v == adminRights()) {
return;
}
_adminRights.set(rights.c_channelAdminRights().vflags.v);
_adminRights.set(rights.c_chatAdminRights().vflags.v);
if (isMegagroup()) {
const auto self = session().user();
if (hasAdminRights()) {
@ -1108,13 +1118,13 @@ void ChannelData::setAdminRights(const MTPChannelAdminRights &rights) {
Notify::peerUpdatedDelayed(this, UpdateFlag::ChannelRightsChanged | UpdateFlag::AdminsChanged | UpdateFlag::BannedUsersChanged);
}
void ChannelData::setRestrictedRights(const MTPChannelBannedRights &rights) {
if (rights.c_channelBannedRights().vflags.v == restrictions()
&& rights.c_channelBannedRights().vuntil_date.v == _restrictedUntill) {
void ChannelData::setRestrictedRights(const MTPChatBannedRights &rights) {
if (rights.c_chatBannedRights().vflags.v == restrictions()
&& rights.c_chatBannedRights().vuntil_date.v == _restrictedUntill) {
return;
}
_restrictedUntill = rights.c_channelBannedRights().vuntil_date.v;
_restrictions.set(rights.c_channelBannedRights().vflags.v);
_restrictedUntill = rights.c_chatBannedRights().vuntil_date.v;
_restrictions.set(rights.c_chatBannedRights().vflags.v);
if (isMegagroup()) {
const auto self = session().user();
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 {
public:
static constexpr auto kEssentialFlags = 0
| MTPDchat::Flag::f_creator
| MTPDchat::Flag::f_kicked
| MTPDchat::Flag::f_left
| MTPDchat::Flag::f_admins_enabled
| MTPDchat::Flag::f_admin
| 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<
MTPDchat::Flags,
kEssentialFlags>;
@ -552,11 +557,7 @@ public:
bool amIn() const {
return !isForbidden() && !haveLeft() && !wasKicked();
}
bool canEdit() const {
return !isDeactivated()
&& (amCreator()
|| (adminsEnabled() ? amAdmin() : amIn()));
}
bool canEditInformation() const;
bool canWrite() const {
// Duplicated in Data::CanWriteValue().
return !isDeactivated() && amIn();
@ -567,15 +568,9 @@ public:
bool wasKicked() const {
return flags() & MTPDchat::Flag::f_kicked;
}
bool adminsEnabled() const {
return flags() & MTPDchat::Flag::f_admins_enabled;
}
bool amCreator() const {
return flags() & MTPDchat::Flag::f_creator;
}
bool amAdmin() const {
return (flags() & MTPDchat::Flag::f_admin) && adminsEnabled();
}
bool isDeactivated() const {
return flags() & MTPDchat::Flag::f_deactivated;
}
@ -687,21 +682,21 @@ private:
struct MegagroupInfo {
struct Admin {
explicit Admin(MTPChannelAdminRights rights)
explicit Admin(MTPChatAdminRights rights)
: rights(rights) {
}
Admin(MTPChannelAdminRights rights, bool canEdit)
Admin(MTPChatAdminRights rights, bool canEdit)
: rights(rights)
, canEdit(canEdit) {
}
MTPChannelAdminRights rights;
MTPChatAdminRights rights;
bool canEdit = false;
};
struct Restricted {
explicit Restricted(MTPChannelBannedRights rights)
explicit Restricted(MTPChatBannedRights rights)
: rights(rights) {
}
MTPChannelBannedRights rights;
MTPChatBannedRights rights;
};
std::deque<not_null<UserData*>> lastParticipants;
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 {
public:
static constexpr auto kEssentialFlags = 0
@ -742,7 +732,6 @@ public:
| MTPDchannel::Flag::f_verified
| MTPDchannel::Flag::f_megagroup
| MTPDchannel::Flag::f_restricted
| MTPDchannel::Flag::f_democracy
| MTPDchannel::Flag::f_signatures
| MTPDchannel::Flag::f_username;
using Flags = Data::Flags<
@ -844,19 +833,19 @@ public:
return flags() & MTPDchannel::Flag::f_verified;
}
static MTPChannelBannedRights KickedRestrictedRights();
static MTPChatBannedRights KickedRestrictedRights();
static constexpr auto kRestrictUntilForever = TimeId(INT_MAX);
static bool IsRestrictedForever(TimeId until) {
return !until || (until == kRestrictUntilForever);
}
void applyEditAdmin(
not_null<UserData*> user,
const MTPChannelAdminRights &oldRights,
const MTPChannelAdminRights &newRights);
const MTPChatAdminRights &oldRights,
const MTPChatAdminRights &newRights);
void applyEditBanned(
not_null<UserData*> user,
const MTPChannelBannedRights &oldRights,
const MTPChannelBannedRights &newRights);
const MTPChatBannedRights &oldRights,
const MTPChatBannedRights &newRights);
bool isGroupAdmin(not_null<UserData*> user) const;
@ -889,10 +878,10 @@ public:
return flags() & MTPDchannel::Flag::f_creator;
}
using AdminRight = ChannelAdminRight;
using Restriction = ChannelRestriction;
using AdminRights = ChannelAdminRights;
using Restrictions = ChannelRestrictions;
using AdminRight = ChatAdminRight;
using Restriction = ChatRestriction;
using AdminRights = ChatAdminRights;
using Restrictions = ChatRestrictions;
using AdminRightFlags = Data::Flags<AdminRights>;
using RestrictionFlags = Data::Flags<Restrictions>;
auto adminRights() const {
@ -901,7 +890,7 @@ public:
auto adminRightsValue() const {
return _adminRights.value();
}
void setAdminRights(const MTPChannelAdminRights &rights);
void setAdminRights(const MTPChatAdminRights &rights);
bool hasAdminRights() const {
return (adminRights() != 0);
}
@ -917,7 +906,7 @@ public:
TimeId restrictedUntil() const {
return _restrictedUntill;
}
void setRestrictedRights(const MTPChannelBannedRights &rights);
void setRestrictedRights(const MTPChatBannedRights &rights);
bool hasRestrictions() const {
return (restrictions() != 0);
}
@ -952,7 +941,7 @@ public:
return _inviteLink;
}
bool canHaveInviteLink() const {
return (adminRights() & AdminRight::f_invite_link)
return (adminRights() & AdminRight::f_invite_users)
|| amCreator();
}

View file

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

View file

@ -117,6 +117,26 @@ QString ExtractRestrictionReason(const QString &restriction) {
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
Session::Session(not_null<AuthSession*> session)
@ -407,7 +427,8 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
data.match([&](const MTPDchat &data) {
const auto chat = result->asChat();
const auto canEdit = chat->canEdit();
// #TODO groups
const auto canEdit = chat->canEditInformation();
if (chat->version < data.vversion.v) {
chat->version = data.vversion.v;
@ -458,19 +479,22 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
}, [](const MTPDinputChannelEmpty &) {
});
if (!(chat->flags() & MTPDchat::Flag::f_admins_enabled)
&& (data.vflags.v & MTPDchat::Flag::f_admins_enabled)) {
chat->invalidateParticipants();
}
// #TODO groups
//if (!(chat->flags() & MTPDchat::Flag::f_admins_enabled)
// && (data.vflags.v & MTPDchat::Flag::f_admins_enabled)) {
// chat->invalidateParticipants();
//}
chat->setFlags(data.vflags.v);
chat->count = data.vparticipants_count.v;
if (canEdit != chat->canEdit()) {
// #TODO groups
if (canEdit != chat->canEditInformation()) {
update.flags |= UpdateFlag::ChatCanEdit;
}
}, [&](const MTPDchatForbidden &data) {
const auto chat = result->asChat();
const auto canEdit = chat->canEdit();
// #TODO groups
const auto canEdit = chat->canEditInformation();
chat->input = MTP_inputPeerChat(data.vid);
chat->setName(qs(data.vtitle));
@ -479,7 +503,8 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
chat->count = -1;
chat->invalidateParticipants();
chat->setFlags(MTPDchat_ClientFlag::f_forbidden | 0);
if (canEdit != chat->canEdit()) {
// #TODO groups
if (canEdit != chat->canEditInformation()) {
update.flags |= UpdateFlag::ChatCanEdit;
}
}, [&](const MTPDchannel &data) {
@ -510,19 +535,18 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
| MTPDchannel::Flag::f_broadcast
| MTPDchannel::Flag::f_verified
| MTPDchannel::Flag::f_megagroup
| MTPDchannel::Flag::f_democracy
| MTPDchannel_ClientFlag::f_forbidden;
channel->setFlags((channel->flags() & ~mask) | (data.vflags.v & mask));
} else {
if (data.has_admin_rights()) {
channel->setAdminRights(data.vadmin_rights);
} else if (channel->hasAdminRights()) {
channel->setAdminRights(MTP_channelAdminRights(MTP_flags(0)));
channel->setAdminRights(MTP_chatAdminRights(MTP_flags(0)));
}
if (data.has_banned_rights()) {
channel->setRestrictedRights(data.vbanned_rights);
} 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->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);
if (channel->hasAdminRights()) {
channel->setAdminRights(MTP_channelAdminRights(MTP_flags(0)));
channel->setAdminRights(MTP_chatAdminRights(MTP_flags(0)));
}
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());
@ -1992,6 +2016,7 @@ void Session::documentApplyFields(
void Session::documentApplyFields(
not_null<DocumentData*> document,
const MTPDdocument &data) {
const auto thumb = FindDocumentThumb(data);
documentApplyFields(
document,
data.vaccess_hash.v,
@ -1999,10 +2024,10 @@ void Session::documentApplyFields(
data.vdate.v,
data.vattributes.v,
qs(data.vmime_type),
App::image(data.vthumb),
App::image(thumb),
data.vdc_id.v,
data.vsize.v,
StorageImageLocation::FromMTP(data.vthumb));
StorageImageLocation::FromMTP(thumb));
}
void Session::documentApplyFields(
@ -3007,48 +3032,14 @@ void Session::setWallpapers(const QVector<MTPWallPaper> &data) {
});
for (const auto &paper : data) {
paper.match([&](const MTPDwallPaper &paper) {
const MTPPhotoSize *thumb = nullptr;
const MTPPhotoSize *full = nullptr;
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) {
const auto document = Auth().data().document(paper.vdocument);
if (document->thumb) {
_wallpapers.push_back({
paper.vid.v ? paper.vid.v : INT_MAX,
App::image(*thumb),
App::image(*full)
paper.vid.v ? int32(paper.vid.v) : INT_MAX,
document->thumb,
document->thumb,
});
}
}, [](const MTPDwallPaperSolid &) {
});
}
}

View file

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QDateTime>
#include <QtCore/QRegularExpression>
#include <QtGui/QImageReader>
#include <range/v3/algorithm/max_element.hpp>
#include <range/v3/view/all.hpp>
#include <range/v3/view/transform.hpp>
#include <range/v3/to_container.hpp>
@ -405,6 +406,43 @@ QString DocumentFolder(const Document &data) {
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(
ParseMediaContext &context,
const MTPDocument &data,
@ -423,30 +461,13 @@ Document ParseDocument(
data.vid,
data.vaccess_hash,
data.vfile_reference);
const auto path = result.file.suggestedPath = suggestedFolder
result.file.suggestedPath = suggestedFolder
+ DocumentFolder(result) + '/'
+ CleanDocumentName(ComputeDocumentName(context, result, date));
result.thumb = data.vthumb.match([](const MTPDphotoSizeEmpty &) {
return Image();
}, [](const MTPDphotoStrippedSize &) {
// 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;
});
result.thumb = ParseDocumentThumb(
data.vthumbs.v,
result.file.suggestedPath);
}, [&](const MTPDdocumentEmpty &data) {
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), [=] {
auto editRestrictions = [=](bool hasAdminRights, const MTPChannelBannedRights &currentRights) {
auto editRestrictions = [=](bool hasAdminRights, const MTPChatBannedRights &currentRights) {
auto weak = QPointer<InnerWidget>(this);
auto weakBox = std::make_shared<QPointer<EditRestrictedBox>>();
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) {
weak->restrictUser(user, oldRights, newRights);
}
@ -1144,7 +1144,7 @@ void InnerWidget::suggestRestrictUser(not_null<UserData*> user) {
LayerOption::KeepOther);
};
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 {
request(MTPchannels_GetParticipant(_channel->inputChannel, user->inputUser)).done([=](const MTPchannels_ChannelParticipant &result) {
Expects(result.type() == mtpc_channels_channelParticipant);
@ -1158,13 +1158,13 @@ void InnerWidget::suggestRestrictUser(not_null<UserData*> user) {
} else {
auto hasAdminRights = (type == mtpc_channelParticipantAdmin)
|| (type == mtpc_channelParticipantCreator);
auto bannedRights = MTP_channelBannedRights(
auto bannedRights = MTP_chatBannedRights(
MTP_flags(0),
MTP_int(0));
editRestrictions(hasAdminRights, bannedRights);
}
}).fail([=](const RPCError &error) {
auto bannedRights = MTP_channelBannedRights(
auto bannedRights = MTP_chatBannedRights(
MTP_flags(0),
MTP_int(0));
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);
MTP::send(MTPchannels_EditBanned(_channel->inputChannel, user->inputUser, newRights), rpcDone([megagroup = _channel.get(), user, weak, oldRights, newRights](const MTPUpdates &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) {
Expects(rights.type() == mtpc_channelBannedRights);
if (rights.c_channelBannedRights().vflags.v) {
void InnerWidget::restrictUserDone(not_null<UserData*> user, const MTPChatBannedRights &rights) {
Expects(rights.type() == mtpc_chatBannedRights);
if (rights.c_chatBannedRights().vflags.v) {
_admins.erase(std::remove(_admins.begin(), _admins.end(), user), _admins.end());
_adminsCanEdit.erase(std::remove(_adminsCanEdit.begin(), _adminsCanEdit.end(), user), _adminsCanEdit.end());
}

View file

@ -154,8 +154,8 @@ private:
void copySelectedText();
TextWithEntities getSelectedText() const;
void suggestRestrictUser(not_null<UserData*> user);
void restrictUser(not_null<UserData*> user, const MTPChannelBannedRights &oldRights, const MTPChannelBannedRights &newRights);
void restrictUserDone(not_null<UserData*> user, const MTPChannelBannedRights &rights);
void restrictUser(not_null<UserData*> user, const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights);
void restrictUserDone(not_null<UserData*> user, const MTPChatBannedRights &rights);
void requestAdmins();
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);
};
auto GenerateAdminChangeText(not_null<ChannelData*> channel, const TextWithEntities &user, const MTPChannelAdminRights *newRights, const MTPChannelAdminRights *prevRights) {
using Flag = MTPDchannelAdminRights::Flag;
using Flags = MTPDchannelAdminRights::Flags;
auto GenerateAdminChangeText(not_null<ChannelData*> channel, const TextWithEntities &user, const MTPChatAdminRights *newRights, const MTPChatAdminRights *prevRights) {
using Flag = MTPDchatAdminRights::Flag;
using Flags = MTPDchatAdminRights::Flags;
Expects(!newRights || newRights->type() == mtpc_channelAdminRights);
Expects(!prevRights || prevRights->type() == mtpc_channelAdminRights);
auto newFlags = newRights ? newRights->c_channelAdminRights().vflags.v : MTPDchannelAdminRights::Flags(0);
auto prevFlags = prevRights ? prevRights->c_channelAdminRights().vflags.v : MTPDchannelAdminRights::Flags(0);
Expects(!newRights || newRights->type() == mtpc_chatAdminRights);
Expects(!prevRights || prevRights->type() == mtpc_chatAdminRights);
auto newFlags = newRights ? newRights->c_chatAdminRights().vflags.v : MTPDchatAdminRights::Flags(0);
auto prevFlags = prevRights ? prevRights->c_chatAdminRights().vflags.v : MTPDchatAdminRights::Flags(0);
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 invitePhrase = (useInviteLinkPhrase ? lng_admin_log_admin_invite_link : lng_admin_log_admin_invite_users);
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_delete_messages, lng_admin_log_admin_delete_messages },
{ 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_add_admins, lng_admin_log_admin_add_admins },
};
phraseMap[inviteKey] = invitePhrase;
phraseMap[Flag::f_invite_users] = invitePhrase;
if (!channel->isMegagroup()) {
// Don't display "Ban users" changes in channels.
@ -190,15 +189,15 @@ auto GenerateAdminChangeText(not_null<ChannelData*> channel, const TextWithEntit
return result;
};
auto GenerateBannedChangeText(const TextWithEntities &user, const MTPChannelBannedRights *newRights, const MTPChannelBannedRights *prevRights) {
using Flag = MTPDchannelBannedRights::Flag;
using Flags = MTPDchannelBannedRights::Flags;
auto GenerateBannedChangeText(const TextWithEntities &user, const MTPChatBannedRights *newRights, const MTPChatBannedRights *prevRights) {
using Flag = MTPDchatBannedRights::Flag;
using Flags = MTPDchatBannedRights::Flags;
Expects(!newRights || newRights->type() == mtpc_channelBannedRights);
Expects(!prevRights || prevRights->type() == mtpc_channelBannedRights);
auto newFlags = newRights ? newRights->c_channelBannedRights().vflags.v : MTPDchannelBannedRights::Flags(0);
auto prevFlags = prevRights ? prevRights->c_channelBannedRights().vflags.v : MTPDchannelBannedRights::Flags(0);
auto newUntil = newRights ? newRights->c_channelBannedRights().vuntil_date.v : TimeId(0);
Expects(!newRights || newRights->type() == mtpc_chatBannedRights);
Expects(!prevRights || prevRights->type() == mtpc_chatBannedRights);
auto newFlags = newRights ? newRights->c_chatBannedRights().vflags.v : MTPDchatBannedRights::Flags(0);
auto prevFlags = prevRights ? prevRights->c_chatBannedRights().vflags.v : MTPDchatBannedRights::Flags(0);
auto newUntil = newRights ? newRights->c_chatBannedRights().vuntil_date.v : TimeId(0);
auto indefinitely = ChannelData::IsRestrictedForever(newUntil);
if (newFlags & Flag::f_view_messages) {
return lng_admin_log_banned__generic(lt_user, user);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -64,7 +64,7 @@ QString SendDataCommon::getErrorOnSend(
const Result *owner,
not_null<History*> history) const {
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);
}
}
@ -146,7 +146,7 @@ QString SendPhoto::getErrorOnSend(
const Result *owner,
not_null<History*> history) const {
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);
}
}
@ -181,12 +181,12 @@ QString SendFile::getErrorOnSend(
const Result *owner,
not_null<History*> history) const {
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);
} else if (megagroup->restricted(ChannelRestriction::f_send_stickers)
} else if (megagroup->restricted(ChatRestriction::f_send_stickers)
&& (_document->sticker() != nullptr)) {
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->isVideoMessage()) {
return lang(lng_restricted_send_gifs);
@ -222,7 +222,7 @@ QString SendGame::getErrorOnSend(
const Result *owner,
not_null<History*> history) const {
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);
}
}

View file

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

View file

@ -563,7 +563,7 @@ bool MainWidget::sendPaths(PeerId peerId) {
Ui::show(Box<InformBox>(lang(lng_forward_send_files_cant)));
return false;
} 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)));
return false;
}
@ -4225,9 +4225,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
App::feedParticipantDelete(update.c_updateChatParticipantDelete());
} break;
case mtpc_updateChatAdmins: {
App::feedChatAdmins(update.c_updateChatAdmins());
} break;
// #TODO groups new update
case mtpc_updateChatParticipantAdmin: {
App::feedParticipantAdmin(update.c_updateChatParticipantAdmin());

View file

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

View file

@ -67,11 +67,11 @@ void GroupMembersWidget::editAdmin(not_null<UserData*> user) {
}
auto currentRightsIt = megagroup->mgInfo->lastAdmins.find(user);
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 box = Box<EditAdminBox>(megagroup, user, currentRights);
box->setSaveCallback(SaveAdminCallback(megagroup, user, [=](
const MTPChannelAdminRights &newRights) {
const MTPChatAdminRights &newRights) {
if (*weak) {
(*weak)->closeBox();
}
@ -91,10 +91,10 @@ void GroupMembersWidget::restrictUser(not_null<UserData*> user) {
auto currentRightsIt = megagroup->mgInfo->lastRestricted.find(user);
auto currentRights = (currentRightsIt != megagroup->mgInfo->lastRestricted.end())
? 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 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();
// #TODO use Auth().api().
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);
auto text = lng_profile_sure_kick(lt_user, user->firstName);
auto currentRestrictedRights = [&]() -> MTPChannelBannedRights {
auto currentRestrictedRights = [&]() -> MTPChatBannedRights {
if (auto channel = peer()->asMegagroup()) {
auto it = channel->mgInfo->lastRestricted.find(user);
if (it != channel->mgInfo->lastRestricted.cend()) {
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::hideLayer();
@ -344,12 +344,13 @@ void GroupMembersWidget::refreshLimitReached() {
void GroupMembersWidget::checkSelfAdmin(ChatData *chat) {
if (chat->participants.empty()) return;
// #TODO groups
const auto self = Auth().user();
if (chat->amAdmin() && !chat->admins.contains(self)) {
chat->admins.insert(self);
} else if (!chat->amAdmin() && chat->admins.contains(self)) {
chat->admins.remove(self);
}
//if (chat->amAdmin() && !chat->admins.contains(self)) {
// chat->admins.insert(self);
//} else if (!chat->amAdmin() && chat->admins.contains(self)) {
// chat->admins.remove(self);
//}
}
void GroupMembersWidget::sortMembers() {
@ -418,12 +419,13 @@ void GroupMembersWidget::setItemFlags(Item *item, ChatData *chat) {
using AdminState = Item::AdminState;
auto user = getMember(item)->user();
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;
item->adminState = adminState;
if (item->peer->id == Auth().userPeerId()) {
item->hasRemoveLink = false;
} else if (chat->amCreator() || (chat->amAdmin() && (adminState == AdminState::None))) {
} else if (chat->amCreator() /*|| (chat->amAdmin() && (adminState == AdminState::None))*/) {
item->hasRemoveLink = true;
} else if (chat->invitedByMe.contains(user) && (adminState == AdminState::None)) {
item->hasRemoveLink = true;

View file

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

View file

@ -21,11 +21,11 @@ class Navigation;
namespace Profile {
Fn<void(
const MTPChannelAdminRights &oldRights,
const MTPChannelAdminRights &newRights)> SaveAdminCallback(
const MTPChatAdminRights &oldRights,
const MTPChatAdminRights &newRights)> SaveAdminCallback(
not_null<ChannelData*> channel,
not_null<UserData*> user,
Fn<void(const MTPChannelAdminRights &newRights)> onDone,
Fn<void(const MTPChatAdminRights &newRights)> onDone,
Fn<void()> onFail);
// Viewing admins, banned or restricted users list with search.
@ -48,10 +48,10 @@ public:
Role role);
struct Additional {
std::map<not_null<UserData*>, MTPChannelAdminRights> adminRights;
std::map<not_null<UserData*>, MTPChatAdminRights> adminRights;
std::set<not_null<UserData*>> adminCanEdit;
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::map<not_null<UserData*>, not_null<UserData*>> restrictedBy;
std::set<not_null<UserData*>> external;
@ -122,11 +122,11 @@ private:
void showAdmin(not_null<UserData*> user);
void editAdminDone(
not_null<UserData*> user,
const MTPChannelAdminRights &rights);
const MTPChatAdminRights &rights);
void showRestricted(not_null<UserData*> user);
void editRestrictedDone(
not_null<UserData*> user,
const MTPChannelBannedRights &rights);
const MTPChatBannedRights &rights);
void removeKicked(not_null<PeerListRow*> row, not_null<UserData*> user);
void kickMember(not_null<UserData*> user);
void kickMemberSure(not_null<UserData*> user);
@ -219,8 +219,8 @@ public:
using Role = ParticipantsBoxController::Role;
using Additional = ParticipantsBoxController::Additional;
using AdminDoneCallback = Fn<void(not_null<UserData*> user, const MTPChannelAdminRights &adminRights)>;
using BannedDoneCallback = Fn<void(not_null<UserData*> user, const MTPChannelBannedRights &bannedRights)>;
using AdminDoneCallback = Fn<void(not_null<UserData*> user, const MTPChatAdminRights &adminRights)>;
using BannedDoneCallback = Fn<void(not_null<UserData*> user, const MTPChatBannedRights &bannedRights)>;
AddParticipantBoxController(not_null<ChannelData*> channel, Role role, AdminDoneCallback adminDoneCallback, BannedDoneCallback bannedDoneCallback);
void prepare() override;
@ -238,11 +238,11 @@ private:
bool checkInfoLoaded(not_null<UserData*> user, Callback callback);
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 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 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 prependRow(not_null<UserData*> user);
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.resize(1);
document = MTP_document(
MTP_flags(0),
MTP_long(_id),
MTP_long(0),
MTP_bytes(QByteArray()),
MTP_int(unixtime()),
MTP_string(filemime),
MTP_int(filesize),
thumbSize,
MTP_vector<MTPPhotoSize>(1, thumbSize),
MTP_int(MTP::maindc()),
MTP_vector<MTPDocumentAttribute>(attributes));
} else if (_type != SendMediaType::Photo) {
document = MTP_document(
MTP_flags(0),
MTP_long(_id),
MTP_long(0),
MTP_bytes(QByteArray()),
MTP_int(unixtime()),
MTP_string(filemime),
MTP_int(filesize),
thumbSize,
MTP_vector<MTPPhotoSize>(1, thumbSize),
MTP_int(MTP::maindc()),
MTP_vector<MTPDocumentAttribute>(attributes));
_type = SendMediaType::File;

View file

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