updating edited messages dependencies (replies, edit / reply / pinned bar), postponing notification about pinned message while the message itself is not yet available

This commit is contained in:
John Preston 2016-03-11 15:20:58 +03:00
parent c36fc92041
commit 5cab9569c3
13 changed files with 345 additions and 39 deletions

View File

@ -937,6 +937,7 @@ namespace App {
if (App::main()) { if (App::main()) {
App::main()->dlgUpdated(existing->history(), existing->id); App::main()->dlgUpdated(existing->history(), existing->id);
} }
App::historyUpdateDependent(existing);
Notify::historyItemResized(existing); Notify::historyItemResized(existing);
} }
} }
@ -1796,6 +1797,18 @@ namespace App {
} }
} }
void historyUpdateDependent(HistoryItem *item) {
DependentItems::iterator j = ::dependentItems.find(item);
if (j != ::dependentItems.cend()) {
for (OrderedSet<HistoryItem*>::const_iterator k = j.value().cbegin(), e = j.value().cend(); k != e; ++k) {
k.key()->updateDependencyItem();
}
}
if (App::main()) {
App::main()->itemEdited(item);
}
}
void historyClearMsgs() { void historyClearMsgs() {
::dependentItems.clear(); ::dependentItems.clear();

View File

@ -150,6 +150,7 @@ namespace App {
void historyRegItem(HistoryItem *item); void historyRegItem(HistoryItem *item);
void historyItemDetached(HistoryItem *item); void historyItemDetached(HistoryItem *item);
void historyUnregItem(HistoryItem *item); void historyUnregItem(HistoryItem *item);
void historyUpdateDependent(HistoryItem *item);
void historyClearMsgs(); void historyClearMsgs();
void historyClearItems(); void historyClearItems();
void historyRegDependency(HistoryItem *dependent, HistoryItem *dependency); void historyRegDependency(HistoryItem *dependent, HistoryItem *dependency);

View File

@ -493,7 +493,7 @@ void RichDeleteMessageBox::onDelete() {
QVector<MsgId> toDestroy; QVector<MsgId> toDestroy;
for (History::Blocks::const_iterator i = h->blocks.cbegin(), e = h->blocks.cend(); i != e; ++i) { for (History::Blocks::const_iterator i = h->blocks.cbegin(), e = h->blocks.cend(); i != e; ++i) {
for (HistoryBlock::Items::const_iterator j = (*i)->items.cbegin(), n = (*i)->items.cend(); j != n; ++j) { for (HistoryBlock::Items::const_iterator j = (*i)->items.cbegin(), n = (*i)->items.cend(); j != n; ++j) {
if ((*j)->from() == _from && (*j)->type() == HistoryItemMsg) { if ((*j)->from() == _from && (*j)->type() == HistoryItemMsg && (*j)->canDelete()) {
toDestroy.push_back((*j)->id); toDestroy.push_back((*j)->id);
} }
} }

View File

@ -7101,11 +7101,19 @@ void HistoryReply::initDimensions() {
} }
bool HistoryReply::updateReplyTo(bool force) { bool HistoryReply::updateReplyTo(bool force) {
if (replyToMsg || !replyToMsgId) return true; if (!force) {
replyToMsg = App::histItemById(channelId(), replyToMsgId); if (replyToMsg || !replyToMsgId) {
return true;
}
}
if (!replyToMsg) {
replyToMsg = App::histItemById(channelId(), replyToMsgId);
if (replyToMsg) {
App::historyRegDependency(this, replyToMsg);
}
}
if (replyToMsg) { if (replyToMsg) {
App::historyRegDependency(this, replyToMsg);
replyToText.setText(st::msgFont, replyToMsg->inReplyText(), _textDlgOptions); replyToText.setText(st::msgFont, replyToMsg->inReplyText(), _textDlgOptions);
replyToNameUpdated(); replyToNameUpdated();
@ -7526,22 +7534,38 @@ bool HistoryServiceMsg::updatePinned(bool force) {
HistoryServicePinned *pinned = Get<HistoryServicePinned>(); HistoryServicePinned *pinned = Get<HistoryServicePinned>();
t_assert(pinned != nullptr); t_assert(pinned != nullptr);
if (!pinned->msgId || pinned->msg) return true; if (!force) {
if (!pinned->msgId || pinned->msg) {
return true;
}
}
if (!pinned->lnk) { if (!pinned->lnk) {
pinned->lnk = TextLinkPtr(new MessageLink(history()->peer->id, pinned->msgId)); pinned->lnk = TextLinkPtr(new MessageLink(history()->peer->id, pinned->msgId));
} }
pinned->msg = App::histItemById(channelId(), pinned->msgId); bool gotDependencyItem = false;
if (!pinned->msg) {
pinned->msg = App::histItemById(channelId(), pinned->msgId);
if (pinned->msg) {
App::historyRegDependency(this, pinned->msg);
gotDependencyItem = true;
}
}
if (pinned->msg) { if (pinned->msg) {
App::historyRegDependency(this, pinned->msg);
updatePinnedText(); updatePinnedText();
} else if (force) { } else if (force) {
pinned->msgId = 0; if (pinned->msgId > 0) {
pinned->msgId = 0;
gotDependencyItem = true;
}
updatePinnedText(); updatePinnedText();
} }
if (force) { if (force) {
initDimensions(); initDimensions();
Notify::historyItemResized(this); Notify::historyItemResized(this);
if (gotDependencyItem && App::wnd()) {
App::wnd()->notifySettingGot();
}
} }
return (pinned->msg || !pinned->msgId); return (pinned->msg || !pinned->msgId);
} }
@ -7613,6 +7637,7 @@ bool HistoryServiceMsg::updatePinnedText(const QString *pfrom, QString *ptext) {
if (App::main()) { if (App::main()) {
App::main()->dlgUpdated(history(), id); App::main()->dlgUpdated(history(), id);
} }
App::historyUpdateDependent(this);
} }
return result; return result;
} }

View File

@ -937,6 +937,9 @@ public:
virtual MsgId dependencyMsgId() const { virtual MsgId dependencyMsgId() const {
return 0; return 0;
} }
virtual bool notificationReady() const {
return true;
}
virtual UserData *viaBot() const { virtual UserData *viaBot() const {
return 0; return 0;
@ -2355,6 +2358,12 @@ public:
} }
return 0; return 0;
} }
bool notificationReady() const override {
if (const HistoryServicePinned *pinned = Get<HistoryServicePinned>()) {
return (pinned->msg || !pinned->msgId);
}
return true;
}
void countPositionAndSize(int32 &left, int32 &width) const; void countPositionAndSize(int32 &left, int32 &width) const;

View File

@ -6267,6 +6267,15 @@ void HistoryWidget::itemRemoved(HistoryItem *item) {
} }
} }
void HistoryWidget::itemEdited(HistoryItem *item) {
if (item == _replyEditMsg) {
updateReplyEditTexts(true);
}
if (_pinnedBar && item->id == _pinnedBar->msgId) {
updatePinnedBar(true);
}
}
void HistoryWidget::updateScrollColors() { void HistoryWidget::updateScrollColors() {
if (!App::historyScrollBarColor()) return; if (!App::historyScrollBarColor()) return;
_scroll.updateColors(App::historyScrollBarColor(), App::historyScrollBgColor(), App::historyScrollBarOverColor(), App::historyScrollBgOverColor()); _scroll.updateColors(App::historyScrollBarColor(), App::historyScrollBgColor(), App::historyScrollBarOverColor(), App::historyScrollBgOverColor());
@ -6785,12 +6794,19 @@ HistoryWidget::PinnedBar::PinnedBar(MsgId msgId, HistoryWidget *parent)
} }
void HistoryWidget::updatePinnedBar(bool force) { void HistoryWidget::updatePinnedBar(bool force) {
if (!_pinnedBar || _pinnedBar->msg) { if (!_pinnedBar) {
return; return;
} }
if (!force) {
if (_pinnedBar->msg) {
return;
}
}
t_assert(_history != nullptr); t_assert(_history != nullptr);
_pinnedBar->msg = App::histItemById(_history->channelId(), _pinnedBar->msgId); if (!_pinnedBar->msg) {
_pinnedBar->msg = App::histItemById(_history->channelId(), _pinnedBar->msgId);
}
if (_pinnedBar->msg) { if (_pinnedBar->msg) {
_pinnedBar->text.setText(st::msgFont, _pinnedBar->msg->inDialogsText(), _textDlgOptions); _pinnedBar->text.setText(st::msgFont, _pinnedBar->msg->inDialogsText(), _textDlgOptions);
} else if (force) { } else if (force) {
@ -7595,10 +7611,14 @@ void HistoryWidget::messageDataReceived(ChannelData *channel, MsgId msgId) {
} }
void HistoryWidget::updateReplyEditTexts(bool force) { void HistoryWidget::updateReplyEditTexts(bool force) {
if (_replyEditMsg || (!_editMsgId && !_replyToId)) { if (!force) {
return; if (_replyEditMsg || (!_editMsgId && !_replyToId)) {
return;
}
}
if (!_replyEditMsg) {
_replyEditMsg = App::histItemById(_channel, _editMsgId ? _editMsgId : _replyToId);
} }
_replyEditMsg = App::histItemById(_channel, _editMsgId ? _editMsgId : _replyToId);
if (_replyEditMsg) { if (_replyEditMsg) {
_replyEditMsgText.setText(st::msgFont, _replyEditMsg->inDialogsText(), _textDlgOptions); _replyEditMsgText.setText(st::msgFont, _replyEditMsg->inDialogsText(), _textDlgOptions);

View File

@ -513,6 +513,7 @@ public:
void fillSelectedItems(SelectedItemSet &sel, bool forDelete = true); void fillSelectedItems(SelectedItemSet &sel, bool forDelete = true);
void itemRemoved(HistoryItem *item); void itemRemoved(HistoryItem *item);
void itemEdited(HistoryItem *item);
void updateScrollColors(); void updateScrollColors();

View File

@ -1541,6 +1541,12 @@ void MainWidget::itemRemoved(HistoryItem *item) {
} }
} }
void MainWidget::itemEdited(HistoryItem *item) {
if (history.peer() == item->history()->peer || (history.peer() && history.peer() == item->history()->peer->migrateTo())) {
history.itemEdited(item);
}
}
bool MainWidget::overviewFailed(PeerData *peer, const RPCError &error, mtpRequestId req) { bool MainWidget::overviewFailed(PeerData *peer, const RPCError &error, mtpRequestId req) {
if (mtpIsFlood(error)) return false; if (mtpIsFlood(error)) return false;

View File

@ -348,6 +348,7 @@ public:
void mediaOverviewUpdated(PeerData *peer, MediaOverviewType type); void mediaOverviewUpdated(PeerData *peer, MediaOverviewType type);
void changingMsgId(HistoryItem *row, MsgId newId); void changingMsgId(HistoryItem *row, MsgId newId);
void itemRemoved(HistoryItem *item); void itemRemoved(HistoryItem *item);
void itemEdited(HistoryItem *item);
void loadMediaBack(PeerData *peer, MediaOverviewType type, bool many = false); void loadMediaBack(PeerData *peer, MediaOverviewType type, bool many = false);
void peerUsernameChanged(PeerData *peer); void peerUsernameChanged(PeerData *peer);

View File

@ -1213,21 +1213,22 @@ void _serialize_channelFull(MTPStringLogger &to, int32 stage, int32 lev, Types &
switch (stage) { 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 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(" can_view_participants: "); ++stages.back(); if (flag & MTPDchannelFull::flag_can_view_participants) { to.add("YES [ BY BIT 3 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 3 IN FIELD flags ]"); } break; case 1: to.add(" can_view_participants: "); ++stages.back(); if (flag & MTPDchannelFull::flag_can_view_participants) { to.add("YES [ BY BIT 3 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 3 IN FIELD flags ]"); } break;
case 2: to.add(" id: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 2: to.add(" can_set_username: "); ++stages.back(); if (flag & MTPDchannelFull::flag_can_set_username) { to.add("YES [ BY BIT 6 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 6 IN FIELD flags ]"); } 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 3: to.add(" id: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 4: to.add(" participants_count: "); ++stages.back(); if (flag & MTPDchannelFull::flag_participants_count) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } 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;
case 5: to.add(" admins_count: "); ++stages.back(); if (flag & MTPDchannelFull::flag_admins_count) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 1 IN FIELD flags ]"); } break; case 5: to.add(" participants_count: "); ++stages.back(); if (flag & MTPDchannelFull::flag_participants_count) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } break;
case 6: to.add(" kicked_count: "); ++stages.back(); if (flag & MTPDchannelFull::flag_kicked_count) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 2 IN FIELD flags ]"); } break; case 6: to.add(" admins_count: "); ++stages.back(); if (flag & MTPDchannelFull::flag_admins_count) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 1 IN FIELD flags ]"); } break;
case 7: to.add(" read_inbox_max_id: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 7: to.add(" kicked_count: "); ++stages.back(); if (flag & MTPDchannelFull::flag_kicked_count) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 2 IN FIELD flags ]"); } break;
case 8: to.add(" unread_count: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 8: to.add(" read_inbox_max_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(" unread_important_count: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 9: to.add(" unread_count: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 10: to.add(" chat_photo: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 10: to.add(" unread_important_count: "); ++stages.back(); types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 11: to.add(" notify_settings: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 11: to.add(" chat_photo: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 12: to.add(" exported_invite: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 12: to.add(" notify_settings: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 13: to.add(" bot_info: "); ++stages.back(); types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break; case 13: to.add(" exported_invite: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 14: to.add(" migrated_from_chat_id: "); ++stages.back(); if (flag & MTPDchannelFull::flag_migrated_from_chat_id) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 4 IN FIELD flags ]"); } break; case 14: to.add(" bot_info: "); ++stages.back(); types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
case 15: to.add(" migrated_from_max_id: "); ++stages.back(); if (flag & MTPDchannelFull::flag_migrated_from_max_id) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 4 IN FIELD flags ]"); } break; case 15: to.add(" migrated_from_chat_id: "); ++stages.back(); if (flag & MTPDchannelFull::flag_migrated_from_chat_id) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 4 IN FIELD flags ]"); } break;
case 16: to.add(" pinned_msg_id: "); ++stages.back(); if (flag & MTPDchannelFull::flag_pinned_msg_id) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 5 IN FIELD flags ]"); } break; case 16: to.add(" migrated_from_max_id: "); ++stages.back(); if (flag & MTPDchannelFull::flag_migrated_from_max_id) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 4 IN FIELD flags ]"); } break;
case 17: to.add(" pinned_msg_id: "); ++stages.back(); if (flag & MTPDchannelFull::flag_pinned_msg_id) { types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 5 IN FIELD flags ]"); } break;
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break; default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
} }
} }
@ -1901,6 +1902,20 @@ void _serialize_peerNotifySettings(MTPStringLogger &to, int32 stage, int32 lev,
} }
} }
void _serialize_peerSettings(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) {
if (stage) {
to.add(",\n").addSpaces(lev);
} else {
to.add("{ peerSettings");
to.add("\n").addSpaces(lev);
}
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(" report_spam: "); ++stages.back(); if (flag & MTPDpeerSettings::flag_report_spam) { to.add("YES [ BY BIT 0 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } break;
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
}
}
void _serialize_wallPaper(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { void _serialize_wallPaper(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) {
if (stage) { if (stage) {
to.add(",\n").addSpaces(lev); to.add(",\n").addSpaces(lev);
@ -5577,6 +5592,19 @@ void _serialize_messages_reportSpam(MTPStringLogger &to, int32 stage, int32 lev,
} }
} }
void _serialize_messages_hideReportSpam(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) {
if (stage) {
to.add(",\n").addSpaces(lev);
} else {
to.add("{ messages_hideReportSpam");
to.add("\n").addSpaces(lev);
}
switch (stage) {
case 0: to.add(" peer: "); ++stages.back(); types.push_back(0); 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;
}
}
void _serialize_messages_discardEncryption(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { void _serialize_messages_discardEncryption(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) {
if (stage) { if (stage) {
to.add(",\n").addSpaces(lev); to.add(",\n").addSpaces(lev);
@ -6974,6 +7002,19 @@ void _serialize_channels_updatePinnedMessage(MTPStringLogger &to, int32 stage, i
} }
} }
void _serialize_messages_getPeerSettings(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) {
if (stage) {
to.add(",\n").addSpaces(lev);
} else {
to.add("{ messages_getPeerSettings");
to.add("\n").addSpaces(lev);
}
switch (stage) {
case 0: to.add(" peer: "); ++stages.back(); types.push_back(0); 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;
}
}
void _serialize_messages_getChats(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) { void _serialize_messages_getChats(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) {
if (stage) { if (stage) {
to.add(",\n").addSpaces(lev); to.add(",\n").addSpaces(lev);
@ -7719,6 +7760,7 @@ namespace {
_serializers.insert(mtpc_peerNotifyEventsAll, _serialize_peerNotifyEventsAll); _serializers.insert(mtpc_peerNotifyEventsAll, _serialize_peerNotifyEventsAll);
_serializers.insert(mtpc_peerNotifySettingsEmpty, _serialize_peerNotifySettingsEmpty); _serializers.insert(mtpc_peerNotifySettingsEmpty, _serialize_peerNotifySettingsEmpty);
_serializers.insert(mtpc_peerNotifySettings, _serialize_peerNotifySettings); _serializers.insert(mtpc_peerNotifySettings, _serialize_peerNotifySettings);
_serializers.insert(mtpc_peerSettings, _serialize_peerSettings);
_serializers.insert(mtpc_wallPaper, _serialize_wallPaper); _serializers.insert(mtpc_wallPaper, _serialize_wallPaper);
_serializers.insert(mtpc_wallPaperSolid, _serialize_wallPaperSolid); _serializers.insert(mtpc_wallPaperSolid, _serialize_wallPaperSolid);
_serializers.insert(mtpc_inputReportReasonSpam, _serialize_inputReportReasonSpam); _serializers.insert(mtpc_inputReportReasonSpam, _serialize_inputReportReasonSpam);
@ -8011,6 +8053,7 @@ namespace {
_serializers.insert(mtpc_contacts_unblock, _serialize_contacts_unblock); _serializers.insert(mtpc_contacts_unblock, _serialize_contacts_unblock);
_serializers.insert(mtpc_messages_setTyping, _serialize_messages_setTyping); _serializers.insert(mtpc_messages_setTyping, _serialize_messages_setTyping);
_serializers.insert(mtpc_messages_reportSpam, _serialize_messages_reportSpam); _serializers.insert(mtpc_messages_reportSpam, _serialize_messages_reportSpam);
_serializers.insert(mtpc_messages_hideReportSpam, _serialize_messages_hideReportSpam);
_serializers.insert(mtpc_messages_discardEncryption, _serialize_messages_discardEncryption); _serializers.insert(mtpc_messages_discardEncryption, _serialize_messages_discardEncryption);
_serializers.insert(mtpc_messages_setEncryptedTyping, _serialize_messages_setEncryptedTyping); _serializers.insert(mtpc_messages_setEncryptedTyping, _serialize_messages_setEncryptedTyping);
_serializers.insert(mtpc_messages_readEncryptedHistory, _serialize_messages_readEncryptedHistory); _serializers.insert(mtpc_messages_readEncryptedHistory, _serialize_messages_readEncryptedHistory);
@ -8111,6 +8154,7 @@ namespace {
_serializers.insert(mtpc_channels_toggleSignatures, _serialize_channels_toggleSignatures); _serializers.insert(mtpc_channels_toggleSignatures, _serialize_channels_toggleSignatures);
_serializers.insert(mtpc_channels_editMessage, _serialize_channels_editMessage); _serializers.insert(mtpc_channels_editMessage, _serialize_channels_editMessage);
_serializers.insert(mtpc_channels_updatePinnedMessage, _serialize_channels_updatePinnedMessage); _serializers.insert(mtpc_channels_updatePinnedMessage, _serialize_channels_updatePinnedMessage);
_serializers.insert(mtpc_messages_getPeerSettings, _serialize_messages_getPeerSettings);
_serializers.insert(mtpc_messages_getChats, _serialize_messages_getChats); _serializers.insert(mtpc_messages_getChats, _serialize_messages_getChats);
_serializers.insert(mtpc_channels_getChannels, _serialize_channels_getChannels); _serializers.insert(mtpc_channels_getChannels, _serialize_channels_getChannels);
_serializers.insert(mtpc_messages_getFullChat, _serialize_messages_getFullChat); _serializers.insert(mtpc_messages_getFullChat, _serialize_messages_getFullChat);

View File

@ -192,6 +192,7 @@ enum {
mtpc_peerNotifyEventsAll = 0x6d1ded88, mtpc_peerNotifyEventsAll = 0x6d1ded88,
mtpc_peerNotifySettingsEmpty = 0x70a68512, mtpc_peerNotifySettingsEmpty = 0x70a68512,
mtpc_peerNotifySettings = 0x9acda4c0, mtpc_peerNotifySettings = 0x9acda4c0,
mtpc_peerSettings = 0x818426cd,
mtpc_wallPaper = 0xccb03657, mtpc_wallPaper = 0xccb03657,
mtpc_wallPaperSolid = 0x63117f24, mtpc_wallPaperSolid = 0x63117f24,
mtpc_inputReportReasonSpam = 0x58dbcab8, mtpc_inputReportReasonSpam = 0x58dbcab8,
@ -523,6 +524,8 @@ enum {
mtpc_messages_sendMedia = 0xc8f16791, mtpc_messages_sendMedia = 0xc8f16791,
mtpc_messages_forwardMessages = 0x708e0195, mtpc_messages_forwardMessages = 0x708e0195,
mtpc_messages_reportSpam = 0xcf1592db, mtpc_messages_reportSpam = 0xcf1592db,
mtpc_messages_hideReportSpam = 0xa8f1709b,
mtpc_messages_getPeerSettings = 0x3672e09c,
mtpc_messages_getChats = 0x3c6aa187, mtpc_messages_getChats = 0x3c6aa187,
mtpc_messages_getFullChat = 0x3b831c66, mtpc_messages_getFullChat = 0x3b831c66,
mtpc_messages_editChatTitle = 0xdc452855, mtpc_messages_editChatTitle = 0xdc452855,
@ -854,6 +857,9 @@ class MTPpeerNotifyEvents;
class MTPpeerNotifySettings; class MTPpeerNotifySettings;
class MTPDpeerNotifySettings; class MTPDpeerNotifySettings;
class MTPpeerSettings;
class MTPDpeerSettings;
class MTPwallPaper; class MTPwallPaper;
class MTPDwallPaper; class MTPDwallPaper;
class MTPDwallPaperSolid; class MTPDwallPaperSolid;
@ -1313,6 +1319,7 @@ typedef MTPBoxed<MTPinputPeerNotifyEvents> MTPInputPeerNotifyEvents;
typedef MTPBoxed<MTPinputPeerNotifySettings> MTPInputPeerNotifySettings; typedef MTPBoxed<MTPinputPeerNotifySettings> MTPInputPeerNotifySettings;
typedef MTPBoxed<MTPpeerNotifyEvents> MTPPeerNotifyEvents; typedef MTPBoxed<MTPpeerNotifyEvents> MTPPeerNotifyEvents;
typedef MTPBoxed<MTPpeerNotifySettings> MTPPeerNotifySettings; typedef MTPBoxed<MTPpeerNotifySettings> MTPPeerNotifySettings;
typedef MTPBoxed<MTPpeerSettings> MTPPeerSettings;
typedef MTPBoxed<MTPwallPaper> MTPWallPaper; typedef MTPBoxed<MTPwallPaper> MTPWallPaper;
typedef MTPBoxed<MTPreportReason> MTPReportReason; typedef MTPBoxed<MTPreportReason> MTPReportReason;
typedef MTPBoxed<MTPuserFull> MTPUserFull; typedef MTPBoxed<MTPuserFull> MTPUserFull;
@ -4311,6 +4318,37 @@ private:
}; };
typedef MTPBoxed<MTPpeerNotifySettings> MTPPeerNotifySettings; typedef MTPBoxed<MTPpeerNotifySettings> MTPPeerNotifySettings;
class MTPpeerSettings : private mtpDataOwner {
public:
MTPpeerSettings();
MTPpeerSettings(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_peerSettings) : mtpDataOwner(0) {
read(from, end, cons);
}
MTPDpeerSettings &_peerSettings() {
if (!data) throw mtpErrorUninitialized();
split();
return *(MTPDpeerSettings*)data;
}
const MTPDpeerSettings &c_peerSettings() const {
if (!data) throw mtpErrorUninitialized();
return *(const MTPDpeerSettings*)data;
}
uint32 innerLength() const;
mtpTypeId type() const;
void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_peerSettings);
void write(mtpBuffer &to) const;
typedef void ResponseType;
private:
explicit MTPpeerSettings(MTPDpeerSettings *_data);
friend MTPpeerSettings MTP_peerSettings(MTPint _flags);
};
typedef MTPBoxed<MTPpeerSettings> MTPPeerSettings;
class MTPwallPaper : private mtpDataOwner { class MTPwallPaper : private mtpDataOwner {
public: public:
MTPwallPaper() : mtpDataOwner(0), _type(0) { MTPwallPaper() : mtpDataOwner(0), _type(0) {
@ -10042,6 +10080,7 @@ public:
enum { enum {
flag_can_view_participants = (1 << 3), flag_can_view_participants = (1 << 3),
flag_can_set_username = (1 << 6),
flag_participants_count = (1 << 0), flag_participants_count = (1 << 0),
flag_admins_count = (1 << 1), flag_admins_count = (1 << 1),
flag_kicked_count = (1 << 2), flag_kicked_count = (1 << 2),
@ -10051,6 +10090,7 @@ public:
}; };
bool is_can_view_participants() const { return vflags.v & flag_can_view_participants; } bool is_can_view_participants() const { return vflags.v & flag_can_view_participants; }
bool is_can_set_username() const { return vflags.v & flag_can_set_username; }
bool has_participants_count() const { return vflags.v & flag_participants_count; } bool has_participants_count() const { return vflags.v & flag_participants_count; }
bool has_admins_count() const { return vflags.v & flag_admins_count; } bool has_admins_count() const { return vflags.v & flag_admins_count; }
bool has_kicked_count() const { return vflags.v & flag_kicked_count; } bool has_kicked_count() const { return vflags.v & flag_kicked_count; }
@ -10608,6 +10648,22 @@ public:
bool is_silent() const { return vflags.v & flag_silent; } bool is_silent() const { return vflags.v & flag_silent; }
}; };
class MTPDpeerSettings : public mtpDataImpl<MTPDpeerSettings> {
public:
MTPDpeerSettings() {
}
MTPDpeerSettings(MTPint _flags) : vflags(_flags) {
}
MTPint vflags;
enum {
flag_report_spam = (1 << 0),
};
bool is_report_spam() const { return vflags.v & flag_report_spam; }
};
class MTPDwallPaper : public mtpDataImpl<MTPDwallPaper> { class MTPDwallPaper : public mtpDataImpl<MTPDwallPaper> {
public: public:
MTPDwallPaper() { MTPDwallPaper() {
@ -16712,6 +16768,84 @@ public:
} }
}; };
class MTPmessages_hideReportSpam { // RPC method 'messages.hideReportSpam'
public:
MTPInputPeer vpeer;
MTPmessages_hideReportSpam() {
}
MTPmessages_hideReportSpam(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_messages_hideReportSpam) {
read(from, end, cons);
}
MTPmessages_hideReportSpam(const MTPInputPeer &_peer) : vpeer(_peer) {
}
uint32 innerLength() const {
return vpeer.innerLength();
}
mtpTypeId type() const {
return mtpc_messages_hideReportSpam;
}
void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_messages_hideReportSpam) {
vpeer.read(from, end);
}
void write(mtpBuffer &to) const {
vpeer.write(to);
}
typedef MTPBool ResponseType;
};
class MTPmessages_HideReportSpam : public MTPBoxed<MTPmessages_hideReportSpam> {
public:
MTPmessages_HideReportSpam() {
}
MTPmessages_HideReportSpam(const MTPmessages_hideReportSpam &v) : MTPBoxed<MTPmessages_hideReportSpam>(v) {
}
MTPmessages_HideReportSpam(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = 0) : MTPBoxed<MTPmessages_hideReportSpam>(from, end, cons) {
}
MTPmessages_HideReportSpam(const MTPInputPeer &_peer) : MTPBoxed<MTPmessages_hideReportSpam>(MTPmessages_hideReportSpam(_peer)) {
}
};
class MTPmessages_getPeerSettings { // RPC method 'messages.getPeerSettings'
public:
MTPInputPeer vpeer;
MTPmessages_getPeerSettings() {
}
MTPmessages_getPeerSettings(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_messages_getPeerSettings) {
read(from, end, cons);
}
MTPmessages_getPeerSettings(const MTPInputPeer &_peer) : vpeer(_peer) {
}
uint32 innerLength() const {
return vpeer.innerLength();
}
mtpTypeId type() const {
return mtpc_messages_getPeerSettings;
}
void read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = mtpc_messages_getPeerSettings) {
vpeer.read(from, end);
}
void write(mtpBuffer &to) const {
vpeer.write(to);
}
typedef MTPPeerSettings ResponseType;
};
class MTPmessages_GetPeerSettings : public MTPBoxed<MTPmessages_getPeerSettings> {
public:
MTPmessages_GetPeerSettings() {
}
MTPmessages_GetPeerSettings(const MTPmessages_getPeerSettings &v) : MTPBoxed<MTPmessages_getPeerSettings>(v) {
}
MTPmessages_GetPeerSettings(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons = 0) : MTPBoxed<MTPmessages_getPeerSettings>(from, end, cons) {
}
MTPmessages_GetPeerSettings(const MTPInputPeer &_peer) : MTPBoxed<MTPmessages_getPeerSettings>(MTPmessages_getPeerSettings(_peer)) {
}
};
class MTPmessages_getChats { // RPC method 'messages.getChats' class MTPmessages_getChats { // RPC method 'messages.getChats'
public: public:
MTPVector<MTPint> vid; MTPVector<MTPint> vid;
@ -24585,6 +24719,33 @@ inline MTPpeerNotifySettings MTP_peerNotifySettings(MTPint _flags, MTPint _mute_
return MTPpeerNotifySettings(new MTPDpeerNotifySettings(_flags, _mute_until, _sound)); return MTPpeerNotifySettings(new MTPDpeerNotifySettings(_flags, _mute_until, _sound));
} }
inline MTPpeerSettings::MTPpeerSettings() : mtpDataOwner(new MTPDpeerSettings()) {
}
inline uint32 MTPpeerSettings::innerLength() const {
const MTPDpeerSettings &v(c_peerSettings());
return v.vflags.innerLength();
}
inline mtpTypeId MTPpeerSettings::type() const {
return mtpc_peerSettings;
}
inline void MTPpeerSettings::read(const mtpPrime *&from, const mtpPrime *end, mtpTypeId cons) {
if (cons != mtpc_peerSettings) throw mtpErrorUnexpected(cons, "MTPpeerSettings");
if (!data) setData(new MTPDpeerSettings());
MTPDpeerSettings &v(_peerSettings());
v.vflags.read(from, end);
}
inline void MTPpeerSettings::write(mtpBuffer &to) const {
const MTPDpeerSettings &v(c_peerSettings());
v.vflags.write(to);
}
inline MTPpeerSettings::MTPpeerSettings(MTPDpeerSettings *_data) : mtpDataOwner(_data) {
}
inline MTPpeerSettings MTP_peerSettings(MTPint _flags) {
return MTPpeerSettings(new MTPDpeerSettings(_flags));
}
inline uint32 MTPwallPaper::innerLength() const { inline uint32 MTPwallPaper::innerLength() const {
switch (_type) { switch (_type) {
case mtpc_wallPaper: { case mtpc_wallPaper: {

View File

@ -213,7 +213,7 @@ channel#a14dca52 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?t
channelForbidden#2d85832c id:int access_hash:long title:string = 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; chatFull#2e02a614 id:int participants:ChatParticipants chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector<BotInfo> = ChatFull;
channelFull#97bee562 flags:# can_view_participants:flags.3?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int read_inbox_max_id:int unread_count:int unread_important_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 = ChatFull; channelFull#97bee562 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int read_inbox_max_id:int unread_count:int unread_important_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 = ChatFull;
chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant; chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant;
chatParticipantCreator#da13538a user_id:int = ChatParticipant; chatParticipantCreator#da13538a user_id:int = ChatParticipant;
@ -289,6 +289,8 @@ peerNotifyEventsAll#6d1ded88 = PeerNotifyEvents;
peerNotifySettingsEmpty#70a68512 = PeerNotifySettings; peerNotifySettingsEmpty#70a68512 = PeerNotifySettings;
peerNotifySettings#9acda4c0 flags:# show_previews:flags.0?true silent:flags.1?true mute_until:int sound:string = PeerNotifySettings; peerNotifySettings#9acda4c0 flags:# show_previews:flags.0?true silent:flags.1?true mute_until:int sound:string = PeerNotifySettings;
peerSettings#818426cd flags:# report_spam:flags.0?true = PeerSettings;
wallPaper#ccb03657 id:int title:string sizes:Vector<PhotoSize> color:int = WallPaper; wallPaper#ccb03657 id:int title:string sizes:Vector<PhotoSize> color:int = WallPaper;
wallPaperSolid#63117f24 id:int title:string bg_color:int color:int = WallPaper; wallPaperSolid#63117f24 id:int title:string bg_color:int color:int = WallPaper;
@ -726,6 +728,8 @@ messages.sendMessage#fa88427a flags:# no_webpage:flags.1?true broadcast:flags.4?
messages.sendMedia#c8f16791 flags:# broadcast:flags.4?true silent:flags.5?true background:flags.6?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia random_id:long reply_markup:flags.2?ReplyMarkup = Updates; messages.sendMedia#c8f16791 flags:# broadcast:flags.4?true silent:flags.5?true background:flags.6?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia random_id:long reply_markup:flags.2?ReplyMarkup = Updates;
messages.forwardMessages#708e0195 flags:# broadcast:flags.4?true silent:flags.5?true background:flags.6?true from_peer:InputPeer id:Vector<int> random_id:Vector<long> to_peer:InputPeer = Updates; messages.forwardMessages#708e0195 flags:# broadcast:flags.4?true silent:flags.5?true background:flags.6?true from_peer:InputPeer id:Vector<int> random_id:Vector<long> to_peer:InputPeer = Updates;
messages.reportSpam#cf1592db peer:InputPeer = Bool; messages.reportSpam#cf1592db peer:InputPeer = Bool;
messages.hideReportSpam#a8f1709b peer:InputPeer = Bool;
messages.getPeerSettings#3672e09c peer:InputPeer = PeerSettings;
messages.getChats#3c6aa187 id:Vector<int> = messages.Chats; messages.getChats#3c6aa187 id:Vector<int> = messages.Chats;
messages.getFullChat#3b831c66 chat_id:int = messages.ChatFull; messages.getFullChat#3b831c66 chat_id:int = messages.ChatFull;
messages.editChatTitle#dc452855 chat_id:int title:string = Updates; messages.editChatTitle#dc452855 chat_id:int title:string = Updates;

View File

@ -1408,6 +1408,9 @@ void Window::notifySchedule(History *history, HistoryItem *item) {
} }
App::wnd()->getNotifySetting(MTP_inputNotifyPeer(history->peer->input)); App::wnd()->getNotifySetting(MTP_inputNotifyPeer(history->peer->input));
} }
if (!item->notificationReady()) {
haveSetting = false;
}
int delay = item->Is<HistoryMessageForwarded>() ? 500 : 100, t = unixtime(); int delay = item->Is<HistoryMessageForwarded>() ? 500 : 100, t = unixtime();
uint64 ms = getms(true); uint64 ms = getms(true);
@ -1419,7 +1422,7 @@ void Window::notifySchedule(History *history, HistoryItem *item) {
delay = Global::NotifyDefaultDelay(); delay = Global::NotifyDefaultDelay();
} }
uint64 when = getms(true) + delay; uint64 when = ms + delay;
notifyWhenAlerts[history].insert(when, notifyByFrom); notifyWhenAlerts[history].insert(when, notifyByFrom);
if (cDesktopNotify() && !psSkipDesktopNotify()) { if (cDesktopNotify() && !psSkipDesktopNotify()) {
NotifyWhenMaps::iterator i = notifyWhenMaps.find(history); NotifyWhenMaps::iterator i = notifyWhenMaps.find(history);
@ -1487,20 +1490,38 @@ void Window::notifySettingGot() {
int32 t = unixtime(); int32 t = unixtime();
for (NotifyWaiters::iterator i = notifySettingWaiters.begin(); i != notifySettingWaiters.end();) { for (NotifyWaiters::iterator i = notifySettingWaiters.begin(); i != notifySettingWaiters.end();) {
History *history = i.key(); History *history = i.key();
if (history->peer->notify == UnknownNotifySettings) { bool loaded = false, muted = false;
++i; if (history->peer->notify != UnknownNotifySettings) {
} else {
if (history->peer->notify == EmptyNotifySettings || history->peer->notify->mute <= t) { if (history->peer->notify == EmptyNotifySettings || history->peer->notify->mute <= t) {
notifyWaiters.insert(i.key(), i.value()); loaded = true;
} else if (PeerData *from = i.value().notifyByFrom) { } else if (PeerData *from = i.value().notifyByFrom) {
if (from->notify == UnknownNotifySettings) { if (from->notify != UnknownNotifySettings) {
++i; if (from->notify == EmptyNotifySettings || from->notify->mute <= t) {
continue; loaded = true;
} else if (from->notify == EmptyNotifySettings || from->notify->mute <= t) { } else {
notifyWaiters.insert(i.key(), i.value()); loaded = muted = true;
}
} }
} else {
loaded = muted = true;
}
}
if (loaded) {
if (HistoryItem *item = App::histItemById(history->channelId(), i.value().msg)) {
if (!item->notificationReady()) {
loaded = false;
}
} else {
muted = true;
}
}
if (loaded) {
if (!muted) {
notifyWaiters.insert(i.key(), i.value());
} }
i = notifySettingWaiters.erase(i); i = notifySettingWaiters.erase(i);
} else {
++i;
} }
} }
notifyWaitTimer.stop(); notifyWaitTimer.stop();