megagroups started

This commit is contained in:
John Preston 2015-11-02 17:33:57 -05:00
parent 6d7c55e7cc
commit ede2065c26
23 changed files with 193 additions and 125 deletions

View file

@ -101,6 +101,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
"lng_chat_status_members_online" = "{count:_not_used_|# member|# members}, {count_online:_not_used_|# online|# online}";
"lng_channel_status" = "channel";
"lng_group_status" = "group";
"lng_channel_members_link" = "{count:_not_used_|# member|# members} »";
"lng_channel_admins_link" = "{count:Manage administrators|# administrator|# administrators} »";
@ -391,6 +392,8 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
"lng_profile_clear_and_exit" = "Delete and exit";
"lng_profile_leave_channel" = "Leave channel";
"lng_profile_delete_channel" = "Delete channel";
"lng_profile_leave_group" = "Leave group";
"lng_profile_delete_group" = "Delete group";
"lng_profile_search_messages" = "Search for messages";
"lng_profile_block_user" = "Block user";
"lng_profile_unblock_user" = "Unblock user";
@ -430,7 +433,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
"lng_channel_admins" = "Administrators";
"lng_channel_add_admin" = "Add Administrator";
"lng_channel_admin_sure" = "Add {user} to administrators?";
"lng_channel_admins_too_much" = "Sorry, you have reached the limit of channel administrators. Please remove one administrator first.";
"lng_channel_admins_too_much" = "Sorry, you have reached the limit of the administrators. Please remove one administrator first.";
"lng_chat_all_members_admins" = "All Members Are Admins";
"lng_chat_about_all_admins" = "Group members can add new members, edit name and photo of the group.";
@ -474,6 +477,8 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
"lng_sure_delete_and_exit" = "Are you sure, you want to delete all message history and leave «{group}»?\n\nThis action cannot be undone.";
"lng_sure_leave_channel" = "Are you sure, you want to leave\nthis channel?";
"lng_sure_delete_channel" = "Are you sure, you want to delete this channel? All members will be removed and all messages will be lost.";
"lng_sure_leave_group" = "Are you sure, you want to leave\nthis group?";
"lng_sure_delete_group" = "Are you sure, you want to delete this group? All members will be removed and all messages will be lost.";
"lng_message_empty" = "Empty Message";
"lng_media_unsupported" = "Media Unsupported";
@ -481,6 +486,8 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
"lng_action_add_user" = "{from} added {user}";
"lng_action_add_you" = "{from} added you to this channel";
"lng_action_you_joined" = "You joined this channel";
"lng_action_add_you_group" = "{from} added you to this group";
"lng_action_you_joined_group" = "You joined this group";
"lng_action_kick_user" = "{from} removed {user}";
"lng_action_user_left" = "{from} left the group";
"lng_action_user_joined" = "{from} joined the group";
@ -498,6 +505,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
"lng_channel_comments_count" = "{count:_not_used_|# comment|# comments}";
"lng_channel_hide_comments" = "Hide comments";
"lng_channel_not_accessible" = "Sorry, this channel is not accessible.";
"lng_group_not_accessible" = "Sorry, this group is not accessible.";
"lng_channels_too_much_public_existing" = "Sorry, you have created too many public channels already. Please delete one first.";
"lng_channels_too_much_public" = "Sorry, you have created too many public channels.\n\nYou can either create a private channel\nor delete one of your public channels first.";
@ -592,6 +600,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
"lng_bot_description" = "What can this bot do?";
"lng_unblock_button" = "Unblock";
"lng_channel_join" = "Join Channel";
"lng_group_join" = "Join Group";
"lng_channel_mute" = "Mute";
"lng_channel_unmute" = "Unmute";
@ -681,6 +690,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
"lng_send_image_compressed" = "Send compressed image";
"lng_send_image_empty" = "Could not send an empty file :(";
"lng_send_image_too_large" = "Could not send a file, because it is larger than 1.5 GB :(";
"lng_send_folder" = "Could not send «{name}» because it is a directory :(";
"lng_forward_choose" = "Choose recipient..";
"lng_forward_cant" = "Sorry, no way to forward here :(";
@ -700,6 +710,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
"lng_edit_group_title" = "Edit group name";
"lng_edit_contact_title" = "Edit contact name";
"lng_edit_channel_title" = "Edit channel";
"lng_edit_group" = "Edit group";
"lng_edit_self_title" = "Edit your name";
"lng_confirm_contact_data" = "New Contact";
"lng_add_contact" = "Create";

View file

@ -292,7 +292,7 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt
channel->invitationUrl = (f.vexported_invite.type() == mtpc_chatInviteExported) ? qs(f.vexported_invite.c_chatInviteExported().vlink) : QString();
if (History *h = App::historyLoaded(channel->id)) {
if (h->inboxReadBefore < f.vread_inbox_max_id.v + 1) {
h->setUnreadCount(f.vunread_important_count.v);
h->setUnreadCount(channel->isMegagroup() ? f.vunread_count.v : f.vunread_important_count.v);
h->inboxReadBefore = f.vread_inbox_max_id.v + 1;
h->asChannelHistory()->unreadCountAll = f.vunread_count.v;
}

View file

@ -549,7 +549,15 @@ namespace App {
cdata->date = d.vdate.v;
cdata->flags = d.vflags.v;
cdata->isForbidden = false;
if (cdata->isMegagroup()) {
if (History *h = App::historyLoaded(cdata->id)) {
if (h->asChannelHistory()->onlyImportant()) {
MsgId fixInScrollMsgId = 0;
int32 fixInScrollMsgTop = 0;
h->asChannelHistory()->getSwitchReadyFor(SwitchAtTopMsgId, fixInScrollMsgId, fixInScrollMsgTop);
}
}
}
if (cdata->version < d.vversion.v) {
cdata->version = d.vversion.v;
}
@ -879,7 +887,7 @@ namespace App {
existing->setText(qs(m.vmessage), m.has_entities() ? entitiesFromMTP(m.ventities.c_vector().v) : EntitiesInText());
existing->initDimensions();
if (App::main()) App::main()->itemResized(existing);
if (existing->hasTextLinks() && (!existing->history()->isChannel() || existing->fromChannel())) {
if (existing->hasTextLinks() && existing->indexInOverview()) {
existing->history()->addToOverview(existing, OverviewLinks);
}
}

View file

@ -500,7 +500,9 @@ void GroupInfoBox::onNext() {
if (_creating == CreatingGroupGroup) {
App::wnd()->replaceLayer(new ContactsBox(title, _photoBig));
} else {
_creationRequestId = MTP::send(MTPchannels_CreateChannel(MTP_int(MTPchannels_CreateChannel::flag_broadcast), MTP_string(title), MTP_string(description), MTP_vector<MTPInputUser>(0)), rpcDone(&GroupInfoBox::creationDone), rpcFail(&GroupInfoBox::creationFail));
bool mega = true;
int32 flags = mega ? MTPchannels_CreateChannel::flag_megagroup : MTPchannels_CreateChannel::flag_broadcast;
_creationRequestId = MTP::send(MTPchannels_CreateChannel(MTP_int(flags), MTP_string(title), MTP_string(description)), rpcDone(&GroupInfoBox::creationDone), rpcFail(&GroupInfoBox::creationFail));
}
}
@ -540,9 +542,6 @@ bool GroupInfoBox::creationFail(const RPCError &error) {
_title.setFocus();
_title.showError();
return true;
} else if (error.type() == "PEER_FLOOD") {
App::wnd()->replaceLayer(new InformBox(lng_cant_invite_not_contact_channel(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info)))));
return true;
}
return false;
}
@ -1217,7 +1216,7 @@ void EditChannelBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, lang(lng_edit_channel_title));
paintTitle(p, lang(_channel->isMegagroup() ? lng_edit_group : lng_edit_channel_title));
}
void EditChannelBox::peerUpdated(PeerData *peer) {

View file

@ -396,6 +396,8 @@ ContactsInner::ContactData *ContactsInner::contactData(DialogRow *row) {
} else {
data->online = lng_chat_status_members(lt_count, chat->count);
}
} else if (peer->isMegagroup()) {
data->online = lang(lng_group_status);
} else if (peer->isChannel()) {
data->online = lang(lng_channel_status);
}
@ -417,7 +419,7 @@ void ContactsInner::paintDialog(Painter &p, PeerData *peer, ContactData *data, b
sel = false;
}
} else {
if (data->inchat || data->check || selectedCount() >= cMaxGroupCount()) {
if (data->inchat || data->check || selectedCount() >= ((_channel && _channel->isMegagroup()) ? cMaxMegaGroupCount() : cMaxGroupCount())) {
sel = false;
}
}
@ -757,7 +759,7 @@ void ContactsInner::changeCheckState(ContactData *data, PeerData *peer) {
data->check = false;
_checkedContacts.remove(peer);
--_selCount;
} else if (selectedCount() < cMaxGroupCount()) {
} else if (selectedCount() < (_chat->isMegagroup() ? cMaxMegaGroupCount() : cMaxGroupCount())) {
data->check = true;
_checkedContacts.insert(peer, true);
++_selCount;
@ -1514,7 +1516,7 @@ void ContactsBox::paintEvent(QPaintEvent *e) {
paintTitle(p, lang(lng_channel_admins));
} else if (_inner.chat() || _inner.creating() != CreatingGroupNone) {
QString title(lang(addingAdmin ? lng_channel_add_admin : lng_profile_add_participant));
QString additional(addingAdmin ? QString() : QString("%1 / %2").arg(_inner.selectedCount()).arg(cMaxGroupCount()));
QString additional(addingAdmin ? QString() : QString("%1 / %2").arg(_inner.selectedCount()).arg(((_inner.channel() && _inner.channel()->isMegagroup()) ? cMaxMegaGroupCount() : cMaxGroupCount())));
paintTitle(p, title, additional);
} else if (_inner.bot()) {
paintTitle(p, lang(lng_bot_choose_group));
@ -1736,7 +1738,7 @@ bool ContactsBox::creationFail(const RPCError &error) {
MembersInner::MembersInner(ChannelData *channel, MembersFilter filter) : TWidget()
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
, _newItemHeight((channel->amCreator() && (channel->count < cMaxGroupCount() || !channel->isPublic() || filter == MembersFilterAdmins)) ? st::contactsNewItemHeight : 0)
, _newItemHeight((channel->amCreator() && (channel->count < (channel->isMegagroup() ? cMaxMegaGroupCount() : cMaxGroupCount()) || (!channel->isMegagroup() && !channel->isPublic()) || filter == MembersFilterAdmins)) ? st::contactsNewItemHeight : 0)
, _newItemSel(false)
, _channel(channel)
, _filter(filter)
@ -1841,7 +1843,7 @@ void MembersInner::mouseReleaseEvent(QMouseEvent *e) {
if (_kickDown >= 0 && _kickDown == _kickSel && !_kickRequestId) {
_kickConfirm = _rows.at(_kickSel);
if (_kickBox) _kickBox->deleteLater();
_kickBox = new ConfirmBox((_filter == MembersFilterRecent ? lng_profile_sure_kick_channel : lng_profile_sure_kick_admin)(lt_user, _kickConfirm->firstName));
_kickBox = new ConfirmBox((_filter == MembersFilterRecent ? (_channel->isMegagroup() ? lng_profile_sure_kick : lng_profile_sure_kick_channel) : lng_profile_sure_kick_admin)(lt_user, _kickConfirm->firstName));
connect(_kickBox, SIGNAL(confirmed()), this, SLOT(onKickConfirm()));
connect(_kickBox, SIGNAL(destroyed(QObject*)), this, SLOT(onKickBoxDestroyed(QObject*)));
App::wnd()->replaceLayer(_kickBox);
@ -2259,7 +2261,7 @@ void MembersBox::onScroll() {
}
void MembersBox::onAdd() {
if (_inner.filter() == MembersFilterRecent && _inner.channel()->count >= cMaxGroupCount()) {
if (_inner.filter() == MembersFilterRecent && _inner.channel()->count >= (_inner.channel()->isMegagroup() ? cMaxMegaGroupCount() : cMaxGroupCount())) {
App::wnd()->replaceLayer(new MaxInviteBox(_inner.channel()->invitationUrl));
return;
}

View file

@ -33,10 +33,10 @@ PhotoCropBox::PhotoCropBox(const QImage &img, const PeerId &peer, bool upload) :
, _cancel(this, lang(lng_cancel), st::cancelBoxButton)
, _img(img)
, _peerId(peer) {
if (peerIsChannel(_peerId)) {
_title = lang(lng_create_channel_crop);
} else if (peerIsChat(_peerId)) {
if (peerIsChat(_peerId)) {
_title = lang(lng_create_group_crop);
} else if (peerIsChannel(_peerId)) {
_title = lang(lng_create_channel_crop);
} else {
_title = lang(lng_settings_crop_profile);
}

View file

@ -788,19 +788,22 @@ void DialogsInner::dialogsReceived(const QVector<MTPDialog> &added) {
case mtpc_dialogChannel: {
const MTPDdialogChannel &d(i->c_dialogChannel());
History *history = App::historyFromDialog(peerFromMTP(d.vpeer), d.vunread_important_count.v, d.vread_inbox_max_id.v);
PeerData *peer = App::peerLoaded(peerFromMTP(d.vpeer));
int32 unreadCount = (peer && peer->isMegagroup()) ? d.vunread_count.v : d.vunread_important_count.v;
History *history = App::historyFromDialog(peerFromMTP(d.vpeer), unreadCount, d.vread_inbox_max_id.v);
if (history->peer->isChannel()) {
history->asChannelHistory()->unreadCountAll = d.vunread_count.v;
history->peer->asChannel()->ptsReceived(d.vpts.v);
if (!history->peer->asChannel()->amCreator()) {
if (HistoryItem *top = App::histItemById(history->channelId(), d.vtop_important_message.v)) {
MsgId topMsg = history->isMegagroup() ? d.vtop_message.v : d.vtop_important_message.v;
if (HistoryItem *top = App::histItemById(history->channelId(), topMsg)) {
if (top->date <= date(history->peer->asChannel()->date) && App::api()) {
App::api()->requestSelfParticipant(history->peer->asChannel());
}
}
}
}
if (d.vtop_message.v > d.vtop_important_message.v) {
if (!history->isMegagroup() && d.vtop_message.v > d.vtop_important_message.v) {
history->setNotLoadedAtBottom();
}
App::main()->applyNotifySetting(MTP_notifyPeer(d.vpeer), d.vnotify_settings, history);
@ -1654,8 +1657,9 @@ void DialogsWidget::unreadCountsReceived(const QVector<MTPDialog> &dialogs) {
}
}
App::main()->applyNotifySetting(MTP_notifyPeer(d.vpeer), d.vnotify_settings, h);
if (d.vunread_important_count.v >= h->unreadCount) {
h->setUnreadCount(d.vunread_important_count.v, false);
int32 unreadCount = h->isMegagroup() ? d.vunread_count.v : d.vunread_important_count.v;
if (unreadCount >= h->unreadCount) {
h->setUnreadCount(unreadCount, false);
h->inboxReadBefore = d.vread_inbox_max_id.v + 1;
}
}
@ -1771,7 +1775,7 @@ bool DialogsWidget::onSearchMessages(bool searchCache) {
} else if (_searchQuery != q) {
_searchQuery = q;
_searchFull = false;
int32 flags = (_searchInPeer && _searchInPeer->isChannel()) ? MTPmessages_Search::flag_important_only : 0;
int32 flags = (_searchInPeer && _searchInPeer->isChannel() && !_searchInPeer->isMegagroup()) ? MTPmessages_Search::flag_important_only : 0;
if (_searchRequest) {
MTP::cancel(_searchRequest);
}
@ -1825,7 +1829,7 @@ void DialogsWidget::searchMessages(const QString &query, PeerData *inPeer) {
void DialogsWidget::onSearchMore(MsgId minMsgId) {
if (!_searchRequest && !_searchFull) {
int32 flags = (_searchInPeer && _searchInPeer->isChannel()) ? MTPmessages_Search::flag_important_only : 0;
int32 flags = (_searchInPeer && _searchInPeer->isChannel() && !_searchInPeer->isMegagroup()) ? MTPmessages_Search::flag_important_only : 0;
_searchRequest = MTP::send(MTPmessages_Search(MTP_int(flags), _searchInPeer ? _searchInPeer->input : MTP_inputPeerEmpty(), MTP_string(_searchQuery), MTP_inputMessagesFilterEmpty(), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(minMsgId), MTP_int(SearchPerPage)), rpcDone(&DialogsWidget::searchReceived, !minMsgId), rpcFail(&DialogsWidget::searchFailed));
if (!minMsgId) {
_searchQueries.insert(_searchRequest, _searchQuery);

View file

@ -186,7 +186,7 @@ void DialogRow::paint(Painter &p, int32 w, bool act, bool sel, bool onlyBackgrou
QRect rectForName(nameleft, st::dlgPaddingVer + st::dlgNameTop, namewidth, st::msgNameFont->height);
// draw chat icon
if (history->peer->isChat()) {
if (history->peer->isChat() || history->peer->isMegagroup()) {
p.drawPixmap(QPoint(rectForName.left() + st::dlgChatImgPos.x(), rectForName.top() + st::dlgChatImgPos.y()), App::sprite(), (act ? st::dlgActiveChatImg : st::dlgChatImg));
rectForName.setLeft(rectForName.left() + st::dlgImgSkip);
} else if (history->peer->isChannel()) {
@ -280,7 +280,7 @@ void FakeDialogRow::paint(Painter &p, int32 w, bool act, bool sel, bool onlyBack
QRect rectForName(nameleft, st::dlgPaddingVer + st::dlgNameTop, namewidth, st::msgNameFont->height);
// draw chat icon
if (history->peer->isChat()) {
if (history->peer->isChat() || history->peer->isMegagroup()) {
p.drawPixmap(QPoint(rectForName.left() + st::dlgChatImgPos.x(), rectForName.top() + st::dlgChatImgPos.y()), App::sprite(), (act ? st::dlgActiveChatImg : st::dlgChatImg));
rectForName.setLeft(rectForName.left() + st::dlgImgSkip);
} else if (history->peer->isChannel()) {
@ -453,14 +453,17 @@ void History::eraseFromOverview(MediaOverviewType type, MsgId msgId) {
ChannelHistory::ChannelHistory(const PeerId &peer) : History(peer),
unreadCountAll(0),
_onlyImportant(true),
_onlyImportant(!isMegagroup()),
_otherOldLoaded(false), _otherNewLoaded(true),
_collapseMessage(0), _joinedMessage(0) {
}
bool ChannelHistory::isSwitchReadyFor(MsgId switchId, MsgId &fixInScrollMsgId, int32 &fixInScrollMsgTop) {
if (switchId == SwitchAtTopMsgId) {
if (_onlyImportant) return true;
if (_onlyImportant) {
if (isMegagroup()) switchMode();
return true;
}
int32 bottomUnderScrollTop = 0;
HistoryItem *atTopItem = App::main()->atTopImportantMsg(bottomUnderScrollTop);
@ -482,6 +485,7 @@ bool ChannelHistory::isSwitchReadyFor(MsgId switchId, MsgId &fixInScrollMsgId, i
if (HistoryItem *item = App::histItemById(channelId(), switchId)) {
HistoryItemType itemType = item->type();
if (itemType == HistoryItemGroup || itemType == HistoryItemCollapse) {
if (isMegagroup()) return true;
if (itemType == HistoryItemGroup && !_onlyImportant) return true;
if (itemType == HistoryItemCollapse && _onlyImportant) return true;
bool willNeedCollapse = (itemType == HistoryItemGroup);
@ -563,7 +567,7 @@ void ChannelHistory::getSwitchReadyFor(MsgId switchId, MsgId &fixInScrollMsgId,
}
void ChannelHistory::insertCollapseItem(MsgId wasMinId) {
if (_onlyImportant) return;
if (_onlyImportant || isMegagroup()) return;
bool insertAfter = false;
for (int32 blockIndex = 1, blocksCount = blocks.size(); blockIndex < blocksCount; ++blockIndex) { // skip first date block
@ -860,7 +864,7 @@ void ChannelHistory::checkMaxReadMessageDate() {
HistoryBlock *block = blocks.at(--blockIndex);
for (int32 itemIndex = block->items.size(); itemIndex > 0;) {
HistoryItem *item = block->items.at(--itemIndex);
if (item->isImportant() && !item->unread()) {
if ((item->isImportant() || isMegagroup()) && !item->unread()) {
_maxReadMessageDate = item->date;
return;
}
@ -884,7 +888,8 @@ HistoryItem *ChannelHistory::addNewChannelMessage(const MTPMessage &msg, NewMess
}
HistoryItem *ChannelHistory::addNewToBlocks(const MTPMessage &msg, NewMessageType type) {
bool isImportant = isChannel() ? isImportantChannelMessage(idFromMessage(msg), flagsFromMessage(msg)) : true;
bool isImportantFlags = isImportantChannelMessage(idFromMessage(msg), flagsFromMessage(msg));
bool isImportant = (isChannel() && !isMegagroup()) ? isImportantFlags : true;
if (!loadedAtBottom()) {
HistoryItem *item = addToHistory(msg);
@ -906,7 +911,7 @@ HistoryItem *ChannelHistory::addNewToBlocks(const MTPMessage &msg, NewMessageTyp
return item;
}
if (!isImportant && !onlyImportant() && !isEmpty() && type == NewMessageLast) {
if (!isImportantFlags && !onlyImportant() && !isEmpty() && type == NewMessageLast) {
clear(true);
}
@ -921,7 +926,7 @@ HistoryItem *ChannelHistory::addNewToBlocks(const MTPMessage &msg, NewMessageTyp
}
void ChannelHistory::addNewToOther(HistoryItem *item, NewMessageType type) {
if (!_otherNewLoaded) return;
if (!_otherNewLoaded || isMegagroup()) return;
if (!item->isImportant()) {
if (onlyImportant()) {
@ -942,6 +947,8 @@ void ChannelHistory::addNewToOther(HistoryItem *item, NewMessageType type) {
}
void ChannelHistory::switchMode() {
if (isMegagroup() && !_onlyImportant) return;
OtherList savedList;
if (!blocks.isEmpty()) {
savedList.reserve(((blocks.size() - 2) * MessagesPerPage + blocks.back()->items.size()) * (onlyImportant() ? 2 : 1));
@ -1668,7 +1675,7 @@ HistoryItem *History::addNewItem(HistoryBlock *to, bool newBlock, HistoryItem *a
newItemAdded(adding);
}
if (!isChannel() || adding->fromChannel()) {
if (adding->indexInOverview()) {
HistoryMedia *media = adding->getMedia(true);
if (media) {
HistoryMediaType mt = media->type();
@ -1883,7 +1890,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
QList<UserData*> *lastAuthors = peer->isChat() ? &(peer->asChat()->lastAuthors) : 0;
for (int32 i = block->items.size(); i > 0; --i) {
HistoryItem *item = block->items[i - 1];
if (channel && !item->fromChannel()) continue;
if (!item->indexInOverview()) continue;
HistoryMedia *media = item->getMedia(true);
if (media) {
@ -2043,7 +2050,7 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
HistoryBlock *b = blocks[i];
for (int32 j = 0; j < b->items.size(); ++j) {
HistoryItem *item = b->items[j];
if (channel && !item->fromChannel()) continue;
if (!item->indexInOverview()) continue;
HistoryMedia *media = item->getMedia(true);
if (media) {
@ -2172,7 +2179,7 @@ HistoryItem *History::lastImportantMessage() const {
HistoryBlock *block = blocks.at(--blockIndex);
for (int32 itemIndex = block->items.size(); itemIndex > 0;) {
HistoryItem *item = block->items.at(--itemIndex);
if (channel ? item->isImportant() : (item->type() == HistoryItemMsg)) {
if ((channel && !isMegagroup()) ? item->isImportant() : (item->type() == HistoryItemMsg)) {
return item;
}
}
@ -7367,7 +7374,11 @@ void HistoryServiceMsg::setMessageByAction(const MTPmessageAction &action) {
case mtpc_messageActionChannelCreate: {
const MTPDmessageActionChannelCreate &d(action.c_messageActionChannelCreate());
text = lng_action_created_channel(lt_title, textClean(qs(d.vtitle)));
if (fromChannel()) {
text = lng_action_created_channel(lt_title, textClean(qs(d.vtitle)));
} else {
text = lng_action_created_chat(lt_from, from, lt_title, textClean(qs(d.vtitle)));
}
} break;
case mtpc_messageActionChatDeletePhoto: {
@ -7682,9 +7693,9 @@ void HistoryCollapse::getState(TextLinkPtr &lnk, HistoryCursorState &state, int3
HistoryJoined::HistoryJoined(History *history, HistoryBlock *block, const QDateTime &inviteDate, UserData *inviter, int32 flags) :
HistoryServiceMsg(history, block, clientMsgId(), inviteDate, QString(), flags) {
if (peerToUser(inviter->id) == MTP::authedId()) {
_text.setText(st::msgServiceFont, lang(lng_action_you_joined), _historySrvOptions);
_text.setText(st::msgServiceFont, lang(history->isMegagroup() ? lng_action_you_joined_group : lng_action_you_joined), _historySrvOptions);
} else {
_text.setText(st::msgServiceFont, lng_action_add_you(lt_from, textcmdLink(1, inviter->name)), _historySrvOptions);
_text.setText(st::msgServiceFont, history->isMegagroup() ? lng_action_add_you_group(lt_from, textcmdLink(1, inviter->name)) : lng_action_add_you(lt_from, textcmdLink(1, inviter->name)), _historySrvOptions);
_text.setLink(1, TextLinkPtr(new PeerLink(inviter)));
}
}

View file

@ -183,6 +183,9 @@ public:
bool isChannel() const {
return peerIsChannel(peer->id);
}
bool isMegagroup() const {
return peer->isMegagroup();
}
ChannelHistory *asChannelHistory();
const ChannelHistory *asChannelHistory() const;
@ -857,6 +860,10 @@ public:
bool isImportant() const {
return _history->isChannel() && isImportantChannelMessage(id, _flags);
}
bool indexInOverview() const {
return (!history()->isChannel() || history()->isMegagroup() || fromChannel());
}
virtual bool needCheck() const {
return out() || (id < 0 && history()->peer->isSelf());
}

View file

@ -1741,7 +1741,7 @@ void ReportSpamPanel::paintEvent(QPaintEvent *e) {
void ReportSpamPanel::setReported(bool reported, PeerData *onPeer) {
if (reported) {
_report.hide();
_clear.setText(lang(onPeer->isChannel() ? lng_profile_leave_channel : lng_profile_delete_conversation));
_clear.setText(lang(onPeer->isChannel() ? (onPeer->isMegagroup() ? lng_profile_leave_group : lng_profile_leave_channel) : lng_profile_delete_conversation));
_clear.show();
} else {
_report.show();
@ -3012,7 +3012,10 @@ void HistoryWidget::showPeerHistory(const PeerId &peerId, MsgId showAtMsgId) {
_peer = peerId ? App::peer(peerId) : 0;
_channel = _peer ? peerToChannel(_peer->id) : NoChannel;
_canSendMessages = canSendMessages(_peer);
if (_peer && _peer->isChannel()) _peer->asChannel()->updateFull();
if (_peer && _peer->isChannel()) {
_peer->asChannel()->updateFull();
_joinChannel.setText(lang(_peer->isMegagroup() ? lng_group_join : lng_channel_join));
}
_unblockRequest = _reportSpamRequest = 0;
@ -3400,7 +3403,7 @@ void HistoryWidget::updateControlsVisibility() {
_field.setPlaceholder(lang(_broadcast.checked() ? lng_broadcast_ph : lng_comment_ph));
} else {
_broadcast.hide();
_field.setPlaceholder(lang((_history && _history->peer->isChannel()) ? (_history->peer->asChannel()->canPublish() ? lng_broadcast_ph : lng_comment_ph) : lng_message_ph));
_field.setPlaceholder(lang((_history && _history->isChannel() && !_history->isMegagroup()) ? (_history->peer->asChannel()->canPublish() ? lng_broadcast_ph : lng_comment_ph) : lng_message_ph));
}
}
if (_replyToId || readyToForward() || (_previewData && _previewData->pendingTill >= 0) || _kbReplyTo) {
@ -3485,8 +3488,9 @@ bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId
if (mtpIsFlood(error)) return false;
if (error.type() == qstr("CHANNEL_PRIVATE")) {
PeerData *was = _peer;
App::main()->showDialogs();
App::wnd()->showLayer(new InformBox(lang(lng_channel_not_accessible)));
App::wnd()->showLayer(new InformBox(lang((was && was->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible)));
return true;
}
@ -3640,7 +3644,8 @@ bool HistoryWidget::isActive() const {
void HistoryWidget::firstLoadMessages() {
if (!_history || _firstLoadRequest) return;
bool loadImportant = _history->isChannel() ? _history->asChannelHistory()->onlyImportant() : false, wasOnlyImportant = loadImportant;
bool loadImportant = (_history->isChannel() && !_history->isMegagroup()) ? _history->asChannelHistory()->onlyImportant() : false;
bool wasOnlyImportant = loadImportant;
int32 from = 0, offset = 0, loadCount = MessagesPerPage;
if (_showAtMsgId == ShowAtUnreadMsgId) {
if (_history->unreadCount) {
@ -3661,7 +3666,7 @@ void HistoryWidget::firstLoadMessages() {
if (_showAtMsgId == SwitchAtTopMsgId) {
_history->getReadyFor(_showAtMsgId, _fixedInScrollMsgId, _fixedInScrollMsgTop);
loadImportant = true;
} else if (HistoryItem *item = App::histItemById(_channel, _delayedShowAtMsgId)) {
} else if (HistoryItem *item = App::histItemById(_channel, _showAtMsgId)) {
if (item->type() == HistoryItemGroup) {
_history->getReadyFor(_showAtMsgId, _fixedInScrollMsgId, _fixedInScrollMsgTop);
offset = -loadCount / 2;
@ -3677,6 +3682,9 @@ void HistoryWidget::firstLoadMessages() {
if (_fixedInScrollMsgId) {
_fixedInScrollMsgTop += _list->height() - _scroll.scrollTop() - st::historyPadding;
}
if (_history->isMegagroup()) {
loadImportant = false;
}
if (_history->isEmpty() || wasOnlyImportant != loadImportant) {
clearAllLoadRequests();
}
@ -3692,7 +3700,7 @@ void HistoryWidget::firstLoadMessages() {
void HistoryWidget::loadMessages() {
if (!_history || _history->loadedAtTop() || _preloadRequest) return;
bool loadImportant = _history->isChannel() ? _history->asChannelHistory()->onlyImportant() : false;
bool loadImportant = (_history->isChannel() && !_history->isMegagroup()) ? _history->asChannelHistory()->onlyImportant() : false;
MsgId min = _history->minMsgId();
int32 offset = 0, loadCount = min ? MessagesPerPage : MessagesFirstLoad;
@ -3709,7 +3717,7 @@ void HistoryWidget::loadMessagesDown() {
MsgId max = _history->maxMsgId();
if (!max) return;
bool loadImportant = _history->isChannel() ? _history->asChannelHistory()->onlyImportant() : false;
bool loadImportant = (_history->isChannel() && !_history->isMegagroup()) ? _history->asChannelHistory()->onlyImportant() : false;
int32 loadCount = MessagesPerPage, offset = -loadCount;
if (loadImportant) {
@ -3725,7 +3733,7 @@ void HistoryWidget::delayedShowAt(MsgId showAtMsgId) {
clearDelayedShowAt();
_delayedShowAtMsgId = showAtMsgId;
bool loadImportant = _history->isChannel() ? _history->asChannelHistory()->onlyImportant() : false;
bool loadImportant = (_history->isChannel() && !_history->isMegagroup()) ? _history->asChannelHistory()->onlyImportant() : false;
int32 from = 0, offset = 0, loadCount = MessagesPerPage;
if (_delayedShowAtMsgId == ShowAtUnreadMsgId) {
if (_history->unreadCount) {
@ -3758,6 +3766,9 @@ void HistoryWidget::delayedShowAt(MsgId showAtMsgId) {
loadImportant = true;
}
}
if (_history->isMegagroup()) {
loadImportant = false;
}
}
if (loadImportant) {
@ -3922,7 +3933,7 @@ bool HistoryWidget::joinFail(const RPCError &error, mtpRequestId req) {
if (_unblockRequest == req) _unblockRequest = 0;
if (error.type() == qstr("CHANNEL_PRIVATE")) {
App::wnd()->showLayer(new InformBox(lang(lng_channel_not_accessible)));
App::wnd()->showLayer(new InformBox(lang((_peer && _peer->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible)));
return true;
}
return false;
@ -3965,9 +3976,9 @@ void HistoryWidget::shareContact(const PeerId &peer, const QString &phone, const
sendFlags |= MTPmessages_SendMedia::flag_reply_to_msg_id;
}
bool fromChannelName = p->isChannel() && p->asChannel()->canPublish() && (p->asChannel()->isBroadcast() || _broadcast.checked());
bool fromChannelName = p->isChannel() && !p->isMegagroup() && p->asChannel()->canPublish() && (p->asChannel()->isBroadcast() || _broadcast.checked());
if (fromChannelName) {
sendFlags |= MTPmessages_SendMessage_flag_broadcast;
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
flags |= MTPDmessage::flag_views;
} else {
flags |= MTPDmessage::flag_from_id;
@ -4378,7 +4389,10 @@ DragState HistoryWidget::getDragState(const QMimeData *d) {
QString file(i->toLocalFile());
if (file.startsWith(qsl("/.file/id="))) file = psConvertFileUrl(file);
quint64 s = QFileInfo(file).size();
QFileInfo info(file);
if (info.isDir()) return DragStateNone;
quint64 s = info.size();
if (s >= MaxUploadDocumentSize) {
return DragStateNone;
}
@ -4447,7 +4461,7 @@ bool HistoryWidget::readyToForward() const {
}
bool HistoryWidget::hasBroadcastToggle() const {
return _history && _history->peer->isChannel() && _history->peer->asChannel()->canPublish() && !_history->peer->asChannel()->isBroadcast();
return _history && _history->peer->isChannel() && !_history->peer->isMegagroup() && _history->peer->asChannel()->canPublish() && !_history->peer->asChannel()->isBroadcast();
}
bool HistoryWidget::isBotStart() const {
@ -4527,7 +4541,7 @@ void HistoryWidget::onFilesDrop(const QMimeData *data) {
return;
}
if (files.size() == 1) {
if (files.size() == 1 && !QFileInfo(files.at(0)).isDir()) {
uploadFile(files.at(0), PrepareAuto);
}
// uploadFiles(files, PrepareAuto); // multiple confirm with "compressed" checkbox
@ -4688,21 +4702,21 @@ void HistoryWidget::updateOnlineDisplay(int32 x, int32 w) {
text = _titlePeerText.isEmpty() ? lng_chat_status_members(lt_count, chat->count < 0 ? 0 : chat->count) : _titlePeerText;
} else {
int32 onlineCount = 0;
bool onlyMe = true;
bool onlyMe = true;
for (ChatData::Participants::const_iterator i = chat->participants.cbegin(), e = chat->participants.cend(); i != e; ++i) {
if (i.key()->onlineTill > t) {
++onlineCount;
if (onlyMe && i.key() != App::self()) onlyMe = false;
if (onlyMe && i.key() != App::self()) onlyMe = false;
}
}
if (onlineCount && !onlyMe) {
if (onlineCount && !onlyMe) {
text = lng_chat_status_members_online(lt_count, chat->participants.size(), lt_count_online, onlineCount);
} else {
text = lng_chat_status_members(lt_count, chat->participants.size());
}
}
} else if (_peer->isChannel()) {
text = _peer->asChannel()->count ? lng_chat_status_members(lt_count, _peer->asChannel()->count) : lang(lng_channel_status);
text = _peer->asChannel()->count ? lng_chat_status_members(lt_count, _peer->asChannel()->count) : lang(_peer->isMegagroup() ? lng_group_status : lng_channel_status);
}
if (_titlePeerText != text) {
_titlePeerText = text;
@ -4816,7 +4830,7 @@ void HistoryWidget::uploadFile(const QString &file, PrepareMediaType type, FileL
void HistoryWidget::uploadFiles(const QStringList &files, PrepareMediaType type) {
if (!_history || files.isEmpty()) return;
if (files.size() == 1) return uploadFile(files.at(0), type);
if (files.size() == 1 && !QFileInfo(files.at(0)).isDir()) return uploadFile(files.at(0), type);
App::wnd()->activateWindow();
@ -4941,7 +4955,7 @@ void HistoryWidget::onPhotoUploaded(const FullMsgId &newId, const MTPInputFile &
bool fromChannelName = hist->peer->isChannel() && hist->peer->asChannel()->canPublish() && item->fromChannel();
if (fromChannelName) {
sendFlags |= MTPmessages_SendMessage_flag_broadcast;
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
}
QString caption = item->getMedia() ? item->getMedia()->getCaption() : QString();
hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), item->history()->peer->input, MTP_int(replyTo), MTP_inputMediaUploadedPhoto(file, MTP_string(caption)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId);
@ -4985,9 +4999,9 @@ void HistoryWidget::onDocumentUploaded(const FullMsgId &newId, const MTPInputFil
sendFlags |= MTPmessages_SendMedia::flag_reply_to_msg_id;
}
bool fromChannelName = hist->peer->isChannel() && hist->peer->asChannel()->canPublish() && item->fromChannel();
bool fromChannelName = hist->peer->isChannel() && !hist->peer->isMegagroup() && hist->peer->asChannel()->canPublish() && item->fromChannel();
if (fromChannelName) {
sendFlags |= MTPmessages_SendMessage_flag_broadcast;
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
}
hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), item->history()->peer->input, MTP_int(replyTo), MTP_inputMediaUploadedDocument(file, MTP_string(document->mime), _composeDocumentAttributes(document)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId);
}
@ -5014,9 +5028,9 @@ void HistoryWidget::onThumbDocumentUploaded(const FullMsgId &newId, const MTPInp
sendFlags |= MTPmessages_SendMedia::flag_reply_to_msg_id;
}
bool fromChannelName = hist->peer->isChannel() && hist->peer->asChannel()->canPublish() && item->fromChannel();
bool fromChannelName = hist->peer->isChannel() && !hist->peer->isMegagroup() && hist->peer->asChannel()->canPublish() && item->fromChannel();
if (fromChannelName) {
sendFlags |= MTPmessages_SendMessage_flag_broadcast;
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
}
hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), item->history()->peer->input, MTP_int(replyTo), MTP_inputMediaUploadedThumbDocument(file, thumb, MTP_string(document->mime), _composeDocumentAttributes(document)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId);
}
@ -5041,9 +5055,9 @@ void HistoryWidget::onAudioUploaded(const FullMsgId &newId, const MTPInputFile &
sendFlags |= MTPmessages_SendMedia::flag_reply_to_msg_id;
}
bool fromChannelName = hist->peer->isChannel() && hist->peer->asChannel()->canPublish() && item->fromChannel();
bool fromChannelName = hist->peer->isChannel() && !hist->peer->isMegagroup() && hist->peer->asChannel()->canPublish() && item->fromChannel();
if (fromChannelName) {
sendFlags |= MTPmessages_SendMessage_flag_broadcast;
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
}
hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), item->history()->peer->input, MTP_int(replyTo), MTP_inputMediaUploadedAudio(file, MTP_int(audio->duration), MTP_string(audio->mime)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId);
}
@ -5117,7 +5131,7 @@ void HistoryWidget::onAudioFailed(const FullMsgId &newId) {
}
void HistoryWidget::onReportSpamClicked() {
ConfirmBox *box = new ConfirmBox(lang(_peer->isUser() ? lng_report_spam_sure : (_peer->isChat() ? lng_report_spam_sure_group : lng_report_spam_sure_channel)), lang(lng_report_spam_ok), st::attentionBoxButton);
ConfirmBox *box = new ConfirmBox(lang(_peer->isUser() ? lng_report_spam_sure : ((_peer->isChat() || _peer->isMegagroup()) ? lng_report_spam_sure_group : lng_report_spam_sure_channel)), lang(lng_report_spam_ok), st::attentionBoxButton);
connect(box, SIGNAL(confirmed()), this, SLOT(onReportSpamSure()));
App::wnd()->showLayer(box);
_clearPeer = _peer;
@ -5532,7 +5546,7 @@ void HistoryWidget::updateToEndVisibility() {
void HistoryWidget::updateCollapseCommentsVisibility() {
int32 collapseCommentsLeft = (width() - _collapseComments.width()) / 2, collapseCommentsTop = st::msgServiceMargin.top();
bool collapseCommentsVisible = !_a_show.animating() && _history && !_firstLoadRequest && _history->isChannel() && !_history->asChannelHistory()->onlyImportant();
bool collapseCommentsVisible = !_a_show.animating() && _history && !_firstLoadRequest && _history->isChannel() && !_history->isMegagroup() && !_history->asChannelHistory()->onlyImportant();
if (collapseCommentsVisible) {
if (HistoryItem *collapse = _history->asChannelHistory()->collapse()) {
if (!collapse->detached()) {
@ -5661,9 +5675,9 @@ void HistoryWidget::onStickerSend(DocumentData *sticker) {
flags |= MTPDmessage::flag_reply_to_msg_id;
sendFlags |= MTPmessages_SendMedia::flag_reply_to_msg_id;
}
bool fromChannelName = _history->peer->isChannel() && _history->peer->asChannel()->canPublish() && (_history->peer->asChannel()->isBroadcast() || _broadcast.checked());
bool fromChannelName = _history->peer->isChannel() && !_history->peer->isMegagroup() && _history->peer->asChannel()->canPublish() && (_history->peer->asChannel()->isBroadcast() || _broadcast.checked());
if (fromChannelName) {
sendFlags |= MTPmessages_SendMessage_flag_broadcast;
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
} else {
flags |= MTPDmessage::flag_from_id;
}

View file

@ -601,7 +601,7 @@ void MainWidget::cancelForwarding() {
void MainWidget::finishForwarding(History *hist, bool broadcast) {
if (!hist) return;
bool fromChannelName = hist->peer->isChannel() && hist->peer->asChannel()->canPublish() && (hist->peer->asChannel()->isBroadcast() || broadcast);
bool fromChannelName = hist->peer->isChannel() && !hist->peer->isMegagroup() && hist->peer->asChannel()->canPublish() && (hist->peer->asChannel()->isBroadcast() || broadcast);
if (!_toForward.isEmpty()) {
bool genClientSideMessage = (_toForward.size() < 2);
PeerData *forwardFrom = _toForward.cbegin().value()->history()->peer;
@ -942,7 +942,7 @@ void MainWidget::addParticipants(PeerData *chatOrChannel, const QVector<UserData
for (QVector<UserData*>::const_iterator i = users.cbegin(), e = users.cend(); i != e; ++i) {
inputUsers.push_back((*i)->inputUser);
}
MTP::send(MTPchannels_InviteToChannel(chatOrChannel->asChannel()->inputChannel, MTP_vector<MTPInputUser>(inputUsers)), rpcDone(&MainWidget::inviteToChannelDone, chatOrChannel->asChannel()), rpcFail(&MainWidget::addParticipantsFail), 0, 5);
MTP::send(MTPchannels_InviteToChannel(chatOrChannel->asChannel()->inputChannel, MTP_vector<MTPInputUser>(inputUsers)), rpcDone(&MainWidget::inviteToChannelDone, chatOrChannel->asChannel()), rpcFail(&MainWidget::addParticipantsFail, chatOrChannel->asChannel()), 0, 5);
}
}
@ -962,13 +962,13 @@ bool MainWidget::addParticipantFail(UserData *user, const RPCError &error) {
return false;
}
bool MainWidget::addParticipantsFail(const RPCError &error) {
bool MainWidget::addParticipantsFail(ChannelData *channel, const RPCError &error) {
if (mtpIsFlood(error)) return false;
QString text = lang(lng_failed_add_participant);
if (error.type() == "USER_LEFT_CHAT") { // trying to return banned user to his group
} else if (error.type() == "USER_NOT_MUTUAL_CONTACT") { // trying to return user who does not have me in contacts
text = lang(lng_failed_add_not_mutual_channel);
text = lang(channel->isMegagroup() ? lng_failed_add_not_mutual : lng_failed_add_not_mutual_channel);
} else if (error.type() == "PEER_FLOOD") {
text = lng_cant_invite_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info)));
}
@ -990,7 +990,7 @@ bool MainWidget::kickParticipantFail(ChatData *chat, const RPCError &error) {
}
void MainWidget::checkPeerHistory(PeerData *peer) {
if (peer->isChannel()) {
if (peer->isChannel() && !peer->isMegagroup()) {
MTP::send(MTPchannels_GetImportantHistory(peer->asChannel()->inputChannel, MTP_int(0), MTP_int(0), MTP_int(1), MTP_int(0), MTP_int(0)), rpcDone(&MainWidget::checkedHistory, peer));
} else {
MTP::send(MTPmessages_GetHistory(peer->input, MTP_int(0), MTP_int(0), MTP_int(1), MTP_int(0), MTP_int(0)), rpcDone(&MainWidget::checkedHistory, peer));
@ -1183,9 +1183,9 @@ void MainWidget::sendMessage(History *hist, const QString &text, MsgId replyTo,
media = MTP_messageMediaWebPage(MTP_webPagePending(MTP_long(page->id), MTP_int(page->pendingTill)));
flags |= MTPDmessage::flag_media;
}
bool fromChannelName = hist->peer->isChannel() && hist->peer->asChannel()->canPublish() && (hist->peer->asChannel()->isBroadcast() || broadcast);
bool fromChannelName = hist->peer->isChannel() && !hist->peer->isMegagroup() && hist->peer->asChannel()->canPublish() && (hist->peer->asChannel()->isBroadcast() || broadcast);
if (fromChannelName) {
sendFlags |= MTPmessages_SendMessage_flag_broadcast;
sendFlags |= MTPmessages_SendMessage::flag_broadcast;
flags |= MTPDmessage::flag_views;
} else {
flags |= MTPDmessage::flag_from_id;
@ -1296,7 +1296,7 @@ void MainWidget::preloadOverviews(PeerData *peer) {
MTPMessagesFilter filter = typeToMediaFilter(type);
if (type == OverviewCount) break;
int32 flags = peer->isChannel() ? MTPmessages_Search::flag_important_only : 0;
int32 flags = (peer->isChannel() && !peer->isMegagroup()) ? MTPmessages_Search::flag_important_only : 0;
_overviewPreload[i].insert(peer, MTP::send(MTPmessages_Search(MTP_int(flags), peer->input, MTP_string(""), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(0)), rpcDone(&MainWidget::overviewPreloaded, peer), rpcFail(&MainWidget::overviewFailed, peer), 0, (i == last) ? 0 : 10));
}
}
@ -1483,7 +1483,7 @@ void MainWidget::loadMediaBack(PeerData *peer, MediaOverviewType type, bool many
MTPMessagesFilter filter = typeToMediaFilter(type);
if (type == OverviewCount) return;
int32 flags = peer->isChannel() ? MTPmessages_Search::flag_important_only : 0;
int32 flags = (peer->isChannel() && !peer->isMegagroup()) ? MTPmessages_Search::flag_important_only : 0;
_overviewLoad[type].insert(peer, MTP::send(MTPmessages_Search(MTP_int(flags), peer->input, MTPstring(), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(minId), MTP_int(limit)), rpcDone(&MainWidget::overviewLoaded, hist)));
}
@ -3029,11 +3029,13 @@ void MainWidget::gotChannelDifference(ChannelData *channel, const MTPupdates_Cha
}
App::feedMsgs(d.vmessages, NewMessageLast);
if (h) {
if (HistoryItem *item = App::histItemById(peerToChannel(channel->id), d.vtop_important_message.v)) {
MsgId topMsg = h->isMegagroup() ? d.vtop_message.v : d.vtop_important_message.v;
if (HistoryItem *item = App::histItemById(peerToChannel(channel->id), topMsg)) {
h->setLastMessage(item);
}
if (d.vunread_important_count.v >= h->unreadCount) {
h->setUnreadCount(d.vunread_important_count.v, false);
int32 unreadCount = h->isMegagroup() ? d.vunread_count.v : d.vunread_important_count.v;
if (unreadCount >= h->unreadCount) {
h->setUnreadCount(unreadCount, false);
h->inboxReadBefore = d.vread_inbox_max_id.v + 1;
}
if (d.vunread_count.v >= h->asChannelHistory()->unreadCountAll) {
@ -3437,7 +3439,7 @@ void MainWidget::getChannelDifference(ChannelData *channel, GetChannelDifference
} else {
filter = MTP_channelMessagesFilterEmpty(); //MTP_channelMessagesFilterCollapsed(); - not supported
if (History *history = App::historyLoaded(channel->id)) {
if (!history->asChannelHistory()->onlyImportant()) {
if (!history->isMegagroup() && !history->asChannelHistory()->onlyImportant()) {
MsgId fixInScrollMsgId = 0;
int32 fixInScrollMsgTop = 0;
history->asChannelHistory()->getSwitchReadyFor(SwitchAtTopMsgId, fixInScrollMsgId, fixInScrollMsgTop);
@ -4148,7 +4150,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
item->setText(text, d.has_entities() ? entitiesFromMTP(d.ventities.c_vector().v) : EntitiesInText());
item->initDimensions();
itemResized(item);
if (item->hasTextLinks() && (!item->history()->isChannel() || item->fromChannel())) {
if (item->hasTextLinks() && item->indexInOverview()) {
item->history()->addToOverview(item, OverviewLinks);
}
}

View file

@ -310,7 +310,7 @@ public:
void addParticipants(PeerData *chatOrChannel, const QVector<UserData*> &users);
bool addParticipantFail(UserData *user, const RPCError &e);
bool addParticipantsFail(const RPCError &e); // for multi invite in channels
bool addParticipantsFail(ChannelData *channel, const RPCError &e); // for multi invite in channels
void kickParticipant(ChatData *chat, UserData *user);
bool kickParticipantFail(ChatData *chat, const RPCError &e);

View file

@ -1946,10 +1946,10 @@ void MediaView::updateHeader() {
_headerText = _doc->name.isEmpty() ? lang(lng_mediaview_doc_image) : _doc->name;
} else if (_user) {
_headerText = lang(lng_mediaview_profile_photo);
} else if (_channel) {
_headerText = lang(lng_mediaview_group_photo);
} else if (_peer) {
} else if (_channel && !_history->isMegagroup()) {
_headerText = lang(lng_mediaview_channel_photo);
} else if (_peer) {
_headerText = lang(lng_mediaview_group_photo);
} else {
_headerText = lang(lng_mediaview_single_photo);
}

View file

@ -368,7 +368,7 @@ static const mtpTypeId mtpLayers[] = {
mtpTypeId(mtpc_invokeWithLayer18),
};
static const uint32 mtpLayerMaxSingle = sizeof(mtpLayers) / sizeof(mtpLayers[0]);
static const mtpPrime mtpCurrentLayer = 40;
static const mtpPrime mtpCurrentLayer = 41;
template <typename bareT>
class MTPBoxed : public bareT {
@ -982,7 +982,6 @@ inline bool mtpIsFalse(const MTPBool &v) {
enum { // client side flags
MTPDmessage_flag_HAS_TEXT_LINKS = (1 << 31), // message has links for "shared links" indexing
MTPmessages_SendMessage_flag_broadcast = (1 << 4),
MTPDreplyKeyboardMarkup_flag_FORCE_REPLY = (1 << 30), // markup just wants a text reply
MTPDreplyKeyboardMarkup_flag_ZERO = (1 << 31), // none (zero) markup
MTPDstickerSet_flag_NOT_LOADED = (1 << 31), // sticker set is not yet loaded

View file

@ -1257,13 +1257,14 @@ void _serialize_channel(MTPStringLogger &to, int32 stage, int32 lev, Types &type
case 5: to.add(" moderator: "); ++stages.back(); if (flag & MTPDchannel::flag_moderator) { to.add("YES [ BY BIT 4 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 4 IN FIELD flags ]"); } break;
case 6: to.add(" broadcast: "); ++stages.back(); if (flag & MTPDchannel::flag_broadcast) { to.add("YES [ BY BIT 5 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 5 IN FIELD flags ]"); } break;
case 7: to.add(" verified: "); ++stages.back(); if (flag & MTPDchannel::flag_verified) { to.add("YES [ BY BIT 7 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 7 IN FIELD flags ]"); } break;
case 8: to.add(" id: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 9: to.add(" access_hash: "); ++stages.back(); types.push_back(mtpc_long); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 10: to.add(" title: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 11: to.add(" username: "); ++stages.back(); if (flag & MTPDchannel::flag_username) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 6 IN FIELD flags ]"); } break;
case 12: to.add(" photo: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 13: to.add(" date: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 14: to.add(" version: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 8: to.add(" megagroup: "); ++stages.back(); if (flag & MTPDchannel::flag_megagroup) { to.add("YES [ BY BIT 8 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 8 IN FIELD flags ]"); } break;
case 9: to.add(" id: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 10: to.add(" access_hash: "); ++stages.back(); types.push_back(mtpc_long); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 11: to.add(" title: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 12: to.add(" username: "); ++stages.back(); if (flag & MTPDchannel::flag_username) { types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 6 IN FIELD flags ]"); } break;
case 13: to.add(" photo: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 14: to.add(" date: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 15: to.add(" version: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
}
}
@ -6457,9 +6458,9 @@ void _serialize_channels_createChannel(MTPStringLogger &to, int32 stage, int32 l
switch (stage) {
case 0: to.add(" flags: "); ++stages.back(); if (start >= end) throw Exception("start >= end in flags"); else flags.back() = *start; types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 1: to.add(" broadcast: "); ++stages.back(); if (flag & MTPchannels_createChannel::flag_broadcast) { to.add("YES [ BY BIT 0 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } break;
case 2: to.add(" title: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 3: to.add(" about: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 4: to.add(" users: "); ++stages.back(); types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 2: to.add(" megagroup: "); ++stages.back(); if (flag & MTPchannels_createChannel::flag_megagroup) { to.add("YES [ BY BIT 1 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 1 IN FIELD flags ]"); } break;
case 3: to.add(" title: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 4: to.add(" about: "); ++stages.back(); types.push_back(mtpc_string); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
}
}

View file

@ -566,7 +566,7 @@ enum {
mtpc_channels_getParticipant = 0x546dd7a6,
mtpc_channels_getChannels = 0xa7f6bbb,
mtpc_channels_getFullChannel = 0x8736a09,
mtpc_channels_createChannel = 0x5521d844,
mtpc_channels_createChannel = 0xf4893d7f,
mtpc_channels_editAbout = 0x13e27f1e,
mtpc_channels_editAdmin = 0x52b16962,
mtpc_channels_editTitle = 0x566decd0,
@ -9684,6 +9684,7 @@ public:
flag_moderator = (1 << 4),
flag_broadcast = (1 << 5),
flag_verified = (1 << 7),
flag_megagroup = (1 << 8),
flag_username = (1 << 6),
};
@ -9694,6 +9695,7 @@ public:
bool is_moderator() const { return vflags.v & flag_moderator; }
bool is_broadcast() const { return vflags.v & flag_broadcast; }
bool is_verified() const { return vflags.v & flag_verified; }
bool is_megagroup() const { return vflags.v & flag_megagroup; }
bool has_username() const { return vflags.v & flag_username; }
};
@ -18582,24 +18584,25 @@ public:
MTPint vflags;
MTPstring vtitle;
MTPstring vabout;
MTPVector<MTPInputUser> vusers;
MTPchannels_createChannel() {
}
MTPchannels_createChannel(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_channels_createChannel) {
read(from, end, cons);
}
MTPchannels_createChannel(MTPint _flags, const MTPstring &_title, const MTPstring &_about, const MTPVector<MTPInputUser> &_users) : vflags(_flags), vtitle(_title), vabout(_about), vusers(_users) {
MTPchannels_createChannel(MTPint _flags, const MTPstring &_title, const MTPstring &_about) : vflags(_flags), vtitle(_title), vabout(_about) {
}
enum {
flag_broadcast = (1 << 0),
flag_megagroup = (1 << 1),
};
bool is_broadcast() const { return vflags.v & flag_broadcast; }
bool is_megagroup() const { return vflags.v & flag_megagroup; }
uint32 innerLength() const {
return vflags.innerLength() + vtitle.innerLength() + vabout.innerLength() + vusers.innerLength();
return vflags.innerLength() + vtitle.innerLength() + vabout.innerLength();
}
mtpTypeId type() const {
return mtpc_channels_createChannel;
@ -18608,13 +18611,11 @@ public:
vflags.read(from, end);
vtitle.read(from, end);
vabout.read(from, end);
vusers.read(from, end);
}
void write(mtpBuffer &to) const {
vflags.write(to);
vtitle.write(to);
vabout.write(to);
vusers.write(to);
}
typedef MTPUpdates ResponseType;
@ -18627,7 +18628,7 @@ public:
}
MTPchannels_CreateChannel(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = 0) : MTPBoxed<MTPchannels_createChannel>(from, end, cons) {
}
MTPchannels_CreateChannel(MTPint _flags, const MTPstring &_title, const MTPstring &_about, const MTPVector<MTPInputUser> &_users) : MTPBoxed<MTPchannels_createChannel>(MTPchannels_createChannel(_flags, _title, _about, _users)) {
MTPchannels_CreateChannel(MTPint _flags, const MTPstring &_title, const MTPstring &_about) : MTPBoxed<MTPchannels_createChannel>(MTPchannels_createChannel(_flags, _title, _about)) {
}
};

View file

@ -218,7 +218,7 @@ userStatusLastMonth#77ebc742 = UserStatus;
chatEmpty#9ba2d800 id:int = Chat;
chat#7312bc48 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true admins_enabled:flags.3?true admin:flags.4?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int = Chat;
chatForbidden#7328bdb id:int title:string = Chat;
channel#678e9587 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true editor:flags.3?true moderator:flags.4?true broadcast:flags.5?true verified:flags.7?true id:int access_hash:long title:string username:flags.6?string photo:ChatPhoto date:int version:int = Chat;
channel#678e9587 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true editor:flags.3?true moderator:flags.4?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true id:int access_hash:long title:string username:flags.6?string photo:ChatPhoto date:int version:int = Chat;
channelForbidden#2d85832c id:int access_hash:long title:string = Chat;
chatFull#2e02a614 id:int participants:ChatParticipants chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector<BotInfo> = ChatFull;
@ -767,7 +767,7 @@ channels.getParticipants#24d98f92 channel:InputChannel filter:ChannelParticipant
channels.getParticipant#546dd7a6 channel:InputChannel user_id:InputUser = channels.ChannelParticipant;
channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats;
channels.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull;
channels.createChannel#5521d844 flags:# broadcast:flags.0?true title:string about:string users:Vector<InputUser> = Updates;
channels.createChannel#f4893d7f flags:# broadcast:flags.0?true megagroup:flags.1?true title:string about:string = Updates;
channels.editAbout#13e27f1e channel:InputChannel about:string = Bool;
channels.editAdmin#52b16962 channel:InputChannel user_id:InputUser role:ChannelParticipantRole = Bool;
channels.editTitle#566decd0 channel:InputChannel title:string = Updates;

View file

@ -951,7 +951,7 @@ int32 OverviewInner::itemTop(const FullMsgId &msgId) const {
void OverviewInner::preloadMore() {
if (_inSearch) {
if (!_searchRequest && !_searchFull) {
int32 flags = _hist->peer->isChannel() ? MTPmessages_Search::flag_important_only : 0;
int32 flags = (_hist->peer->isChannel() && !_hist->peer->isMegagroup()) ? MTPmessages_Search::flag_important_only : 0;
_searchRequest = MTP::send(MTPmessages_Search(MTP_int(flags), _hist->peer->input, MTP_string(_searchQuery), MTP_inputMessagesFilterUrl(), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(_lastSearchId), MTP_int(SearchPerPage)), rpcDone(&OverviewInner::searchReceived, !_lastSearchId), rpcFail(&OverviewInner::searchFailed));
if (!_lastSearchId) {
_searchQueries.insert(_searchRequest, _searchQuery);
@ -2033,7 +2033,7 @@ bool OverviewInner::onSearchMessages(bool searchCache) {
} else if (_searchQuery != q) {
_searchQuery = q;
_searchFull = false;
int32 flags = _hist->peer->isChannel() ? MTPmessages_Search::flag_important_only : 0;
int32 flags = (_hist->peer->isChannel() && !_hist->peer->isMegagroup()) ? MTPmessages_Search::flag_important_only : 0;
_searchRequest = MTP::send(MTPmessages_Search(MTP_int(flags), _hist->peer->input, MTP_string(_searchQuery), MTP_inputMessagesFilterUrl(), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(SearchPerPage)), rpcDone(&OverviewInner::searchReceived, true), rpcFail(&OverviewInner::searchFailed));
_searchQueries.insert(_searchRequest, _searchQuery);
}

View file

@ -70,11 +70,11 @@ ProfileInner::ProfileInner(ProfileWidget *profile, ScrollArea *scroll, const Pee
// actions
_searchInPeer(this, lang(lng_profile_search_messages)),
_clearHistory(this, lang(lng_profile_clear_history)),
_deleteConversation(this, lang(_peer->isUser() ? lng_profile_delete_conversation : (_peer->isChat() ? lng_profile_clear_and_exit : lng_profile_leave_channel))),
_deleteConversation(this, lang(_peer->isUser() ? lng_profile_delete_conversation : (_peer->isChat() ? lng_profile_clear_and_exit : (_peer->isMegagroup() ? lng_profile_leave_group : lng_profile_leave_channel)))),
_wasBlocked(_peerUser ? _peerUser->blocked : UserBlockUnknown),
_blockRequest(0),
_blockUser(this, lang((_peerUser && _peerUser->botInfo) ? lng_profile_block_bot : lng_profile_block_user), st::btnRedLink),
_deleteChannel(this, lang(lng_profile_delete_channel), st::btnRedLink),
_deleteChannel(this, lang(_peer->isMegagroup() ? lng_profile_delete_group : lng_profile_delete_channel), st::btnRedLink),
// participants
_pHeight(st::profileListPhotoSize + st::profileListPadding.height() * 2),
@ -292,7 +292,7 @@ void ProfileInner::onClearHistorySure() {
}
void ProfileInner::onDeleteConversation() {
ConfirmBox *box = new ConfirmBox(_peer->isUser() ? lng_sure_delete_history(lt_contact, _peer->name) : (_peer->isChat() ? lng_sure_delete_and_exit(lt_group, _peer->name) : lang(lng_sure_leave_channel)), lang(_peer->isUser() ? lng_box_delete : lng_box_leave), _peer->isChannel() ? st::defaultBoxButton : st::attentionBoxButton);
ConfirmBox *box = new ConfirmBox(_peer->isUser() ? lng_sure_delete_history(lt_contact, _peer->name) : (_peer->isChat() ? lng_sure_delete_and_exit(lt_group, _peer->name) : lang(_peer->isMegagroup() ? lng_sure_leave_group : lng_sure_leave_channel)), lang(_peer->isUser() ? lng_box_delete : lng_box_leave), _peer->isChannel() ? st::defaultBoxButton : st::attentionBoxButton);
connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteConversationSure()));
App::wnd()->showLayer(box);
}
@ -313,7 +313,7 @@ void ProfileInner::onDeleteConversationSure() {
void ProfileInner::onDeleteChannel() {
if (!_peerChannel) return;
ConfirmBox *box = new ConfirmBox(lang(lng_sure_delete_channel), lang(lng_box_delete), st::attentionBoxButton);
ConfirmBox *box = new ConfirmBox(lang(_peer->isMegagroup() ? lng_sure_delete_group : lng_sure_delete_channel), lang(lng_box_delete), st::attentionBoxButton);
connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteChannelSure()));
App::wnd()->showLayer(box);
}
@ -492,7 +492,7 @@ void ProfileInner::onFullPeerUpdated(PeerData *peer) {
updateInvitationLink();
_members.setText(lng_channel_members_link(lt_count, (_peerChannel->count > 0) ? _peerChannel->count : 1));
_admins.setText(lng_channel_admins_link(lt_count, (_peerChannel->adminsCount > 0) ? _peerChannel->adminsCount : 1));
_onlineText = (_peerChannel->count > 0) ? lng_chat_status_members(lt_count, _peerChannel->count) : lang(lng_channel_status);
_onlineText = (_peerChannel->count > 0) ? lng_chat_status_members(lt_count, _peerChannel->count) : lang(_peerChannel->isMegagroup() ? lng_group_status : lng_channel_status);
if (_peerChannel->about.isEmpty()) {
_about = Text(st::wndMinWidth - st::profilePadding.left() - st::profilePadding.right());
} else {
@ -552,7 +552,7 @@ void ProfileInner::peerUpdated(PeerData *data) {
}
_members.setText(lng_channel_members_link(lt_count, (_peerChannel->count > 0) ? _peerChannel->count : 1));
_admins.setText(lng_channel_admins_link(lt_count, (_peerChannel->adminsCount > 0) ? _peerChannel->adminsCount : 1));
_onlineText = (_peerChannel->count > 0) ? lng_chat_status_members(lt_count, _peerChannel->count) : lang(lng_channel_status);
_onlineText = (_peerChannel->count > 0) ? lng_chat_status_members(lt_count, _peerChannel->count) : lang(_peerChannel->isMegagroup() ? lng_group_status : lng_channel_status);
}
_photoLink = (photo && photo->date) ? TextLinkPtr(new PhotoLink(photo, _peer)) : TextLinkPtr();
if (_peer->name != _nameCache) {
@ -638,7 +638,7 @@ void ProfileInner::reorderParticipants() {
if (_peerUser) {
_onlineText = App::onlineText(_peerUser, t, true);
} else if (_peerChannel) {
_onlineText = (_peerChannel->count > 0) ? lng_chat_status_members(lt_count, _peerChannel->count) : lang(lng_channel_status);
_onlineText = (_peerChannel->count > 0) ? lng_chat_status_members(lt_count, _peerChannel->count) : lang(_peerChannel->isMegagroup() ? lng_group_status : lng_channel_status);
} else {
_onlineText = lang(lng_chat_status_unaccessible);
}
@ -1120,7 +1120,7 @@ void ProfileInner::resizeEvent(QResizeEvent *e) {
// profile
top += st::profilePadding.top();
int32 addbyname = 0;
if (_peerChannel && (_amCreator || _peerChannel->isPublic())) {
if (_peerChannel && !_peerChannel->isMegagroup() && (_amCreator || _peerChannel->isPublic())) {
_username.move(_left + st::profilePhotoSize + st::profileStatusLeft, top + st::profileStatusTop);
addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent);
}
@ -1445,7 +1445,7 @@ void ProfileInner::showAll() {
_uploadPhoto.hide();
_cancelPhoto.show();
} else {
if (_amCreator) {
if (_amCreator || (_peerChannel->amEditor() && _peerChannel->isMegagroup())) {
_uploadPhoto.show();
} else {
_uploadPhoto.hide();
@ -1471,7 +1471,7 @@ void ProfileInner::showAll() {
} else {
_deleteChannel.hide();
}
if (_peerChannel->isPublic() || _amCreator) {
if (!_peerChannel->isMegagroup() && (_peerChannel->isPublic() || _amCreator)) {
_username.show();
} else {
_username.hide();
@ -1626,7 +1626,7 @@ void ProfileWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth)
p.drawPixmap(QPoint(st::topBarBackPadding.left(), (st::topBarHeight - st::topBarBackImg.pxHeight()) / 2), App::sprite(), st::topBarBackImg);
p.setFont(st::topBarBackFont->f);
p.setPen(st::topBarBackColor->p);
p.drawText(st::topBarBackPadding.left() + st::topBarBackImg.pxWidth() + st::topBarBackPadding.right(), (st::topBarHeight - st::topBarBackFont->height) / 2 + st::topBarBackFont->ascent, lang(peer()->isUser() ? lng_profile_info : (peer()->isChat() ? lng_profile_group_info : lng_profile_channel_info)));
p.drawText(st::topBarBackPadding.left() + st::topBarBackImg.pxWidth() + st::topBarBackPadding.right(), (st::topBarHeight - st::topBarBackFont->height) / 2 + st::topBarBackFont->ascent, lang(peer()->isUser() ? lng_profile_info : ((peer()->isChat() || peer()->isMegagroup()) ? lng_profile_group_info : lng_profile_channel_info)));
}
void ProfileWidget::topBarClick() {

View file

@ -69,6 +69,7 @@ int32 gLastUpdateCheck = 0;
bool gNoStartUpdate = false;
bool gStartToSettings = false;
int32 gMaxGroupCount = 200;
int32 gMaxMegaGroupCount = 500;
DBIDefaultAttach gDefaultAttach = dbidaDocument;
bool gReplaceEmojis = true;
bool gAskDownloadPath = false;

View file

@ -129,6 +129,7 @@ DeclareSetting(int32, LastUpdateCheck);
DeclareSetting(bool, NoStartUpdate);
DeclareSetting(bool, StartToSettings);
DeclareSetting(int32, MaxGroupCount);
DeclareSetting(int32, MaxMegaGroupCount);
DeclareSetting(bool, ReplaceEmojis);
DeclareReadSetting(bool, ManyInstance);
DeclareSetting(bool, AskDownloadPath);

View file

@ -995,7 +995,7 @@ void PeerLink::onClick(Qt::MouseButton button) const {
if (button == Qt::LeftButton && App::main()) {
if (peer() && peer()->isChannel() && App::main()->historyPeer() != peer()) {
if (!peer()->asChannel()->isPublic() && !peer()->asChannel()->amIn()) {
App::wnd()->showLayer(new InformBox(lang(lng_channel_not_accessible)));
App::wnd()->showLayer(new InformBox(lang((peer()->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible)));
} else {
App::main()->showPeerHistory(peer()->id, ShowAtUnreadMsgId);
}

View file

@ -211,6 +211,7 @@ public:
return (input.type() == mtpc_inputPeerSelf);
}
bool isVerified() const;
bool isMegagroup() const;
UserData *asUser();
const UserData *asUser() const;
ChatData *asChat();
@ -515,6 +516,9 @@ public:
int32 date;
int32 version;
int32 flags, flagsFull;
bool isMegagroup() const {
return flags & MTPDchannel::flag_megagroup;
}
bool isBroadcast() const {
return flags & MTPDchannel::flag_broadcast;
}
@ -626,6 +630,9 @@ inline const QString &PeerData::userName() const {
inline bool PeerData::isVerified() const {
return isUser() ? asUser()->isVerified() : (isChannel() ? asChannel()->isVerified() : false);
}
inline bool PeerData::isMegagroup() const {
return isChannel() ? asChannel()->isMegagroup() : false;
}
inline int32 newMessageFlags(PeerData *p) {
return p->isSelf() ? 0 : (((p->isChat() || (p->isUser() && !p->asUser()->botInfo)) ? MTPDmessage::flag_unread : 0) | MTPDmessage::flag_out);