mirror of https://github.com/procxx/kepka.git
Added handler for SCHEDULE_STATUS_PRIVATE error when send file.
This commit is contained in:
parent
ef5055f4f3
commit
e7fbcce9d9
|
@ -579,6 +579,13 @@ void ApiWrap::sendMessageFail(
|
||||||
requestFullPeer(peer);
|
requestFullPeer(peer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (error.type() == qstr("SCHEDULE_STATUS_PRIVATE")) {
|
||||||
|
auto &scheduled = _session->data().scheduledMessages();
|
||||||
|
Assert(peer->isUser());
|
||||||
|
if (const auto item = scheduled.lookupItem(peer->id, itemId.msg)) {
|
||||||
|
scheduled.removeSending(item);
|
||||||
|
Ui::show(Box<InformBox>(tr::lng_cant_do_this(tr::now)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (const auto item = _session->data().message(itemId)) {
|
if (const auto item = _session->data().message(itemId)) {
|
||||||
Assert(randomId != 0);
|
Assert(randomId != 0);
|
||||||
|
|
|
@ -112,6 +112,27 @@ MsgId ScheduledMessages::lookupId(not_null<HistoryItem*> item) const {
|
||||||
return j->second;
|
return j->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HistoryItem *ScheduledMessages::lookupItem(PeerId peer, MsgId msg) const {
|
||||||
|
const auto history = _session->data().historyLoaded(peer);
|
||||||
|
if (!history) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto i = _data.find(history);
|
||||||
|
if (i == end(_data)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto &items = i->second.items;
|
||||||
|
const auto j = ranges::find_if(items, [&](auto &item) {
|
||||||
|
return item->id == msg;
|
||||||
|
});
|
||||||
|
if (j == end(items)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return (*j).get();
|
||||||
|
}
|
||||||
|
|
||||||
int ScheduledMessages::count(not_null<History*> history) const {
|
int ScheduledMessages::count(not_null<History*> history) const {
|
||||||
const auto i = _data.find(history);
|
const auto i = _data.find(history);
|
||||||
return (i != end(_data)) ? i->second.items.size() : 0;
|
return (i != end(_data)) ? i->second.items.size() : 0;
|
||||||
|
|
|
@ -29,6 +29,7 @@ public:
|
||||||
~ScheduledMessages();
|
~ScheduledMessages();
|
||||||
|
|
||||||
[[nodiscard]] MsgId lookupId(not_null<HistoryItem*> item) const;
|
[[nodiscard]] MsgId lookupId(not_null<HistoryItem*> item) const;
|
||||||
|
[[nodiscard]] HistoryItem *lookupItem(PeerId peer, MsgId msg) const;
|
||||||
[[nodiscard]] int count(not_null<History*> history) const;
|
[[nodiscard]] int count(not_null<History*> history) const;
|
||||||
|
|
||||||
void checkEntitiesAndUpdate(const MTPDmessage &data);
|
void checkEntitiesAndUpdate(const MTPDmessage &data);
|
||||||
|
|
Loading…
Reference in New Issue