mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-09-07 04:24:09 +02:00
Update API scheme & fix monoforum send.
This commit is contained in:
parent
f8913bf9b9
commit
abcf7e3a47
14 changed files with 102 additions and 22 deletions
|
@ -341,6 +341,12 @@ ChannelData *ChannelData::monoforumLink() const {
|
||||||
return _monoforumLink;
|
return _monoforumLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChannelData::requiresMonoforumPeer() const {
|
||||||
|
return isMonoforum()
|
||||||
|
&& _monoforumLink
|
||||||
|
&& (_monoforumLink->amCreator() || _monoforumLink->hasAdminRights());
|
||||||
|
}
|
||||||
|
|
||||||
void ChannelData::setMembersCount(int newMembersCount) {
|
void ChannelData::setMembersCount(int newMembersCount) {
|
||||||
if (_membersCount != newMembersCount) {
|
if (_membersCount != newMembersCount) {
|
||||||
if (isMegagroup()
|
if (isMegagroup()
|
||||||
|
|
|
@ -429,6 +429,7 @@ public:
|
||||||
|
|
||||||
void setMonoforumLink(ChannelData *link);
|
void setMonoforumLink(ChannelData *link);
|
||||||
[[nodiscard]] ChannelData *monoforumLink() const;
|
[[nodiscard]] ChannelData *monoforumLink() const;
|
||||||
|
[[nodiscard]] bool requiresMonoforumPeer() const;
|
||||||
|
|
||||||
void ptsInit(int32 pts) {
|
void ptsInit(int32 pts) {
|
||||||
_ptsWaiter.init(pts);
|
_ptsWaiter.init(pts);
|
||||||
|
|
|
@ -60,6 +60,15 @@ MTPInputReplyTo ReplyToForMTP(
|
||||||
&& (to->history() != history || to->id != replyingToTopicId))
|
&& (to->history() != history || to->id != replyingToTopicId))
|
||||||
? to->topicRootId()
|
? to->topicRootId()
|
||||||
: replyingToTopicId;
|
: replyingToTopicId;
|
||||||
|
const auto possibleMonoforumPeer = (to && to->savedSublistPeer())
|
||||||
|
? to->savedSublistPeer()
|
||||||
|
: replyTo.monoforumPeerId
|
||||||
|
? history->owner().peer(replyTo.monoforumPeerId).get()
|
||||||
|
: history->session().user().get();
|
||||||
|
const auto replyToMonoforumPeer = (history->peer->isChannel()
|
||||||
|
&& history->peer->asChannel()->requiresMonoforumPeer())
|
||||||
|
? possibleMonoforumPeer
|
||||||
|
: nullptr;
|
||||||
const auto external = replyTo.messageId
|
const auto external = replyTo.messageId
|
||||||
&& (replyTo.messageId.peer != history->peer->id
|
&& (replyTo.messageId.peer != history->peer->id
|
||||||
|| replyingToTopicId != replyToTopicId);
|
|| replyingToTopicId != replyToTopicId);
|
||||||
|
@ -74,6 +83,7 @@ MTPInputReplyTo ReplyToForMTP(
|
||||||
| (replyTo.quote.text.isEmpty()
|
| (replyTo.quote.text.isEmpty()
|
||||||
? Flag()
|
? Flag()
|
||||||
: (Flag::f_quote_text | Flag::f_quote_offset))
|
: (Flag::f_quote_text | Flag::f_quote_offset))
|
||||||
|
| (replyToMonoforumPeer ? Flag::f_monoforum_peer_id : Flag())
|
||||||
| (quoteEntities.v.isEmpty()
|
| (quoteEntities.v.isEmpty()
|
||||||
? Flag()
|
? Flag()
|
||||||
: Flag::f_quote_entities)),
|
: Flag::f_quote_entities)),
|
||||||
|
@ -84,7 +94,17 @@ MTPInputReplyTo ReplyToForMTP(
|
||||||
: MTPInputPeer()),
|
: MTPInputPeer()),
|
||||||
MTP_string(replyTo.quote.text),
|
MTP_string(replyTo.quote.text),
|
||||||
quoteEntities,
|
quoteEntities,
|
||||||
MTP_int(replyTo.quoteOffset));
|
MTP_int(replyTo.quoteOffset),
|
||||||
|
(replyToMonoforumPeer
|
||||||
|
? replyToMonoforumPeer->input
|
||||||
|
: MTPInputPeer()));
|
||||||
|
} else if (history->peer->isChannel()
|
||||||
|
&& history->peer->asChannel()->requiresMonoforumPeer()
|
||||||
|
&& replyTo.monoforumPeerId) {
|
||||||
|
const auto replyToMonoforumPeer = replyTo.monoforumPeerId
|
||||||
|
? history->owner().peer(replyTo.monoforumPeerId)
|
||||||
|
: history->session().user();
|
||||||
|
return MTP_inputReplyToMonoForum(replyToMonoforumPeer->input);
|
||||||
}
|
}
|
||||||
return MTPInputReplyTo();
|
return MTPInputReplyTo();
|
||||||
}
|
}
|
||||||
|
@ -1054,13 +1074,12 @@ int Histories::sendPreparedMessage(
|
||||||
_creatingTopicRequests.emplace(id);
|
_creatingTopicRequests.emplace(id);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
const auto realReplyTo = FullReplyTo{
|
auto realReplyTo = replyTo;
|
||||||
.messageId = convertTopicReplyToId(history, replyTo.messageId),
|
const auto topicReplyToId = [&](const auto &id) {
|
||||||
.quote = replyTo.quote,
|
return convertTopicReplyToId(history, id);
|
||||||
.storyId = replyTo.storyId,
|
|
||||||
.topicRootId = convertTopicReplyToId(history, replyTo.topicRootId),
|
|
||||||
.quoteOffset = replyTo.quoteOffset,
|
|
||||||
};
|
};
|
||||||
|
realReplyTo.messageId = topicReplyToId(replyTo.messageId);
|
||||||
|
realReplyTo.topicRootId = topicReplyToId(replyTo.topicRootId);
|
||||||
return v::match(message(history, realReplyTo), [&](const auto &request) {
|
return v::match(message(history, realReplyTo), [&](const auto &request) {
|
||||||
const auto type = RequestType::Send;
|
const auto type = RequestType::Send;
|
||||||
return sendRequest(history, type, [=](Fn<void()> finish) {
|
return sendRequest(history, type, [=](Fn<void()> finish) {
|
||||||
|
|
|
@ -177,10 +177,11 @@ struct FullReplyTo {
|
||||||
TextWithEntities quote;
|
TextWithEntities quote;
|
||||||
FullStoryId storyId;
|
FullStoryId storyId;
|
||||||
MsgId topicRootId = 0;
|
MsgId topicRootId = 0;
|
||||||
|
PeerId monoforumPeerId = 0;
|
||||||
int quoteOffset = 0;
|
int quoteOffset = 0;
|
||||||
|
|
||||||
[[nodiscard]] bool valid() const {
|
[[nodiscard]] bool valid() const {
|
||||||
return messageId || (storyId && storyId.peer);
|
return messageId || (storyId && storyId.peer) || monoforumPeerId;
|
||||||
}
|
}
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return valid();
|
return valid();
|
||||||
|
|
|
@ -163,8 +163,15 @@ void SavedMessages::sendLoadMore(not_null<SavedSublist*> sublist) {
|
||||||
).done([=](const MTPmessages_Messages &result) {
|
).done([=](const MTPmessages_Messages &result) {
|
||||||
auto count = 0;
|
auto count = 0;
|
||||||
auto list = (const QVector<MTPMessage>*)nullptr;
|
auto list = (const QVector<MTPMessage>*)nullptr;
|
||||||
result.match([](const MTPDmessages_channelMessages &) {
|
result.match([&](const MTPDmessages_channelMessages &data) {
|
||||||
LOG(("API Error: messages.channelMessages in sublist."));
|
if (const auto channel = _parentChat) {
|
||||||
|
channel->ptsReceived(data.vpts().v);
|
||||||
|
channel->processTopics(data.vtopics());
|
||||||
|
list = &data.vmessages().v;
|
||||||
|
count = data.vcount().v;
|
||||||
|
} else {
|
||||||
|
LOG(("API Error: messages.channelMessages in sublist."));
|
||||||
|
}
|
||||||
}, [](const MTPDmessages_messagesNotModified &) {
|
}, [](const MTPDmessages_messagesNotModified &) {
|
||||||
LOG(("API Error: messages.messagesNotModified in sublist."));
|
LOG(("API Error: messages.messagesNotModified in sublist."));
|
||||||
}, [&](const auto &data) {
|
}, [&](const auto &data) {
|
||||||
|
|
|
@ -372,18 +372,19 @@ void Session::clear() {
|
||||||
// Optimization: clear notifications before destroying items.
|
// Optimization: clear notifications before destroying items.
|
||||||
Core::App().notifications().clearFromSession(_session);
|
Core::App().notifications().clearFromSession(_session);
|
||||||
|
|
||||||
// We must clear all forums before clearing customEmojiManager.
|
// We must clear all [mono]forums before clearing customEmojiManager.
|
||||||
// Because in Data::ForumTopic an Ui::Text::CustomEmoji is cached.
|
// Because in Data::ForumTopic an Ui::Text::CustomEmoji is cached.
|
||||||
auto forums = base::flat_set<not_null<ChannelData*>>();
|
auto forums = base::flat_set<not_null<ChannelData*>>();
|
||||||
for (const auto &[peerId, peer] : _peers) {
|
for (const auto &[peerId, peer] : _peers) {
|
||||||
if (const auto channel = peer->asChannel()) {
|
if (const auto channel = peer->asChannel()) {
|
||||||
if (channel->isForum()) {
|
if (channel->isForum() || channel->isMonoforum()) {
|
||||||
forums.emplace(channel);
|
forums.emplace(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const auto &channel : forums) {
|
for (const auto &channel : forums) {
|
||||||
channel->setFlags(channel->flags() & ~ChannelDataFlag::Forum);
|
channel->setFlags(channel->flags()
|
||||||
|
& ~(ChannelDataFlag::Forum | ChannelDataFlag::Monoforum));
|
||||||
}
|
}
|
||||||
|
|
||||||
_sendActionManager->clear();
|
_sendActionManager->clear();
|
||||||
|
|
|
@ -2497,6 +2497,15 @@ void Widget::escape() {
|
||||||
} else if (initial != forum) {
|
} else if (initial != forum) {
|
||||||
controller()->showForum(initial);
|
controller()->showForum(initial);
|
||||||
}
|
}
|
||||||
|
} else if (const auto monoforum
|
||||||
|
= controller()->shownMonoforum().current()) {
|
||||||
|
const auto id = controller()->windowId(); // #TODO monoforum
|
||||||
|
const auto initial = (Data::SavedMessages*)nullptr;
|
||||||
|
if (!initial) {
|
||||||
|
controller()->closeMonoforum();
|
||||||
|
} else if (initial != monoforum) {
|
||||||
|
controller()->showMonoforum(initial);
|
||||||
|
}
|
||||||
} else if (controller()->openedFolder().current()) {
|
} else if (controller()->openedFolder().current()) {
|
||||||
if (!controller()->windowId().folder()) {
|
if (!controller()->windowId().folder()) {
|
||||||
controller()->closeFolder();
|
controller()->closeFolder();
|
||||||
|
|
|
@ -458,7 +458,9 @@ void PaintRow(
|
||||||
|
|
||||||
const auto promoted = (history && history->useTopPromotion())
|
const auto promoted = (history && history->useTopPromotion())
|
||||||
&& !context.search;
|
&& !context.search;
|
||||||
const auto verifyInfo = (from && !from->isSelf())
|
const auto verifyInfo = (from
|
||||||
|
&& (!from->isSelf()
|
||||||
|
|| (!(flags & Flag::SavedMessages) && !(flags & Flag::MyNotes))))
|
||||||
? from->botVerifyDetails()
|
? from->botVerifyDetails()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (promoted) {
|
if (promoted) {
|
||||||
|
@ -996,7 +998,7 @@ void RowPainter::Paint(
|
||||||
: nullptr;
|
: nullptr;
|
||||||
const auto allowUserOnline = true;// !context.narrow || badgesState.empty();
|
const auto allowUserOnline = true;// !context.narrow || badgesState.empty();
|
||||||
const auto flags = (allowUserOnline ? Flag::AllowUserOnline : Flag(0))
|
const auto flags = (allowUserOnline ? Flag::AllowUserOnline : Flag(0))
|
||||||
| ((sublist && from->isSelf())
|
| ((sublist && !sublist->parentChat() && from->isSelf())
|
||||||
? Flag::MyNotes
|
? Flag::MyNotes
|
||||||
: (peer && peer->isSelf())
|
: (peer && peer->isSelf())
|
||||||
? Flag::SavedMessages
|
? Flag::SavedMessages
|
||||||
|
|
|
@ -2241,6 +2241,12 @@ Dialogs::BadgesState History::chatListBadgesState() const {
|
||||||
forum->topicsList()->unreadState(),
|
forum->topicsList()->unreadState(),
|
||||||
Dialogs::CountInBadge::Chats,
|
Dialogs::CountInBadge::Chats,
|
||||||
Dialogs::IncludeInBadge::UnmutedOrAll));
|
Dialogs::IncludeInBadge::UnmutedOrAll));
|
||||||
|
} else if (const auto monoforum = peer->monoforum()) {
|
||||||
|
return adjustBadgesStateByFolder(
|
||||||
|
Dialogs::BadgesForUnread(
|
||||||
|
monoforum->chatsList()->unreadState(),
|
||||||
|
Dialogs::CountInBadge::Chats,
|
||||||
|
Dialogs::IncludeInBadge::UnmutedOrAll));
|
||||||
}
|
}
|
||||||
return computeBadgesState();
|
return computeBadgesState();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3435,8 +3435,12 @@ FullStoryId HistoryItem::replyToStory() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
FullReplyTo HistoryItem::replyTo() const {
|
FullReplyTo HistoryItem::replyTo() const {
|
||||||
|
const auto monoforumPeer = _history->peer->isMonoforum()
|
||||||
|
? savedSublistPeer()
|
||||||
|
: nullptr;
|
||||||
auto result = FullReplyTo{
|
auto result = FullReplyTo{
|
||||||
.topicRootId = topicRootId(),
|
.topicRootId = topicRootId(),
|
||||||
|
.monoforumPeerId = monoforumPeer ? monoforumPeer->id : PeerId(),
|
||||||
};
|
};
|
||||||
if (const auto reply = Get<HistoryMessageReply>()) {
|
if (const auto reply = Get<HistoryMessageReply>()) {
|
||||||
const auto &fields = reply->fields();
|
const auto &fields = reply->fields();
|
||||||
|
@ -3564,7 +3568,7 @@ Data::SavedSublist *HistoryItem::savedSublist() const {
|
||||||
that->Get<HistoryMessageSaved>()->sublist = sublist;
|
that->Get<HistoryMessageSaved>()->sublist = sublist;
|
||||||
return sublist;
|
return sublist;
|
||||||
} else if (const auto monoforum = _history->peer->monoforum()) {
|
} else if (const auto monoforum = _history->peer->monoforum()) {
|
||||||
const auto sublist = monoforum->sublist(_history->peer);
|
const auto sublist = monoforum->sublist(_from);
|
||||||
const auto that = const_cast<HistoryItem*>(this);
|
const auto that = const_cast<HistoryItem*>(this);
|
||||||
that->AddComponents(HistoryMessageSaved::Bit());
|
that->AddComponents(HistoryMessageSaved::Bit());
|
||||||
that->Get<HistoryMessageSaved>()->sublist = sublist;
|
that->Get<HistoryMessageSaved>()->sublist = sublist;
|
||||||
|
@ -3766,7 +3770,11 @@ void HistoryItem::createComponents(CreateConfig &&config) {
|
||||||
} else if (config.inlineMarkup) {
|
} else if (config.inlineMarkup) {
|
||||||
mask |= HistoryMessageReplyMarkup::Bit();
|
mask |= HistoryMessageReplyMarkup::Bit();
|
||||||
}
|
}
|
||||||
if (_history->peer->isSelf()) {
|
const auto requiresMonoforumPeer = _history->peer->isChannel()
|
||||||
|
&& _history->peer->asChannel()->requiresMonoforumPeer();
|
||||||
|
if (_history->peer->isSelf()
|
||||||
|
|| config.savedSublistPeer
|
||||||
|
|| requiresMonoforumPeer) {
|
||||||
mask |= HistoryMessageSaved::Bit();
|
mask |= HistoryMessageSaved::Bit();
|
||||||
}
|
}
|
||||||
if (!config.restrictions.empty()) {
|
if (!config.restrictions.empty()) {
|
||||||
|
@ -3780,7 +3788,11 @@ void HistoryItem::createComponents(CreateConfig &&config) {
|
||||||
|
|
||||||
if (const auto saved = Get<HistoryMessageSaved>()) {
|
if (const auto saved = Get<HistoryMessageSaved>()) {
|
||||||
if (!config.savedSublistPeer) {
|
if (!config.savedSublistPeer) {
|
||||||
if (config.savedFromPeer) {
|
if (config.reply.monoforumPeerId) {
|
||||||
|
config.savedSublistPeer = config.reply.monoforumPeerId;
|
||||||
|
} else if (!_history->peer->isSelf()) {
|
||||||
|
config.savedSublistPeer = _from->id;
|
||||||
|
} else if (config.savedFromPeer) {
|
||||||
config.savedSublistPeer = config.savedFromPeer;
|
config.savedSublistPeer = config.savedFromPeer;
|
||||||
} else if (config.originalSenderId) {
|
} else if (config.originalSenderId) {
|
||||||
config.savedSublistPeer = config.originalSenderId;
|
config.savedSublistPeer = config.originalSenderId;
|
||||||
|
@ -4023,6 +4035,11 @@ void HistoryItem::createComponentsHelper(HistoryItemCommonFields &&fields) {
|
||||||
? replyTo.messageId.peer
|
? replyTo.messageId.peer
|
||||||
: PeerId();
|
: PeerId();
|
||||||
const auto to = LookupReplyTo(_history, replyTo.messageId);
|
const auto to = LookupReplyTo(_history, replyTo.messageId);
|
||||||
|
config.reply.monoforumPeerId = (to && to->savedSublistPeer())
|
||||||
|
? to->savedSublistPeer()->id
|
||||||
|
: replyTo.monoforumPeerId
|
||||||
|
? replyTo.monoforumPeerId
|
||||||
|
: PeerId();
|
||||||
const auto replyToTop = replyTo.topicRootId
|
const auto replyToTop = replyTo.topicRootId
|
||||||
? replyTo.topicRootId
|
? replyTo.topicRootId
|
||||||
: LookupReplyToTop(_history, to);
|
: LookupReplyToTop(_history, to);
|
||||||
|
|
|
@ -417,6 +417,13 @@ FullReplyTo ReplyToFromMTP(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return FullReplyTo();
|
return FullReplyTo();
|
||||||
|
}, [&](const MTPDinputReplyToMonoForum &data) {
|
||||||
|
const auto parsed = Data::PeerFromInputMTP(
|
||||||
|
&history->owner(),
|
||||||
|
data.vmonoforum_peer_id());
|
||||||
|
return FullReplyTo{
|
||||||
|
.monoforumPeerId = parsed ? parsed->id : PeerId(),
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,6 +256,7 @@ struct ReplyFields {
|
||||||
QString externalSenderName;
|
QString externalSenderName;
|
||||||
QString externalPostAuthor;
|
QString externalPostAuthor;
|
||||||
PeerId externalPeerId = 0;
|
PeerId externalPeerId = 0;
|
||||||
|
PeerId monoforumPeerId = 0;
|
||||||
MsgId messageId = 0;
|
MsgId messageId = 0;
|
||||||
MsgId topMessageId = 0;
|
MsgId topMessageId = 0;
|
||||||
StoryId storyId = 0;
|
StoryId storyId = 0;
|
||||||
|
|
|
@ -79,8 +79,10 @@ constexpr auto kEmojiInteractionSeenDuration = 3 * crl::time(1000);
|
||||||
|
|
||||||
QString TopBarNameText(
|
QString TopBarNameText(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Dialogs::EntryState::Section section) {
|
const Dialogs::EntryState &state) {
|
||||||
if (section == Dialogs::EntryState::Section::SavedSublist) {
|
if (state.section == Dialogs::EntryState::Section::SavedSublist
|
||||||
|
&& state.key.history()
|
||||||
|
&& state.key.history()->peer->isSelf()) {
|
||||||
if (peer->isSelf()) {
|
if (peer->isSelf()) {
|
||||||
return tr::lng_my_notes(tr::now);
|
return tr::lng_my_notes(tr::now);
|
||||||
} else if (peer->isSavedHiddenAuthor()) {
|
} else if (peer->isSavedHiddenAuthor()) {
|
||||||
|
@ -567,7 +569,7 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
||||||
_titleNameVersion = namePeer->nameVersion();
|
_titleNameVersion = namePeer->nameVersion();
|
||||||
_title.setText(
|
_title.setText(
|
||||||
st::msgNameStyle,
|
st::msgNameStyle,
|
||||||
TopBarNameText(namePeer, _activeChat.section),
|
TopBarNameText(namePeer, _activeChat),
|
||||||
Ui::NameTextOptions());
|
Ui::NameTextOptions());
|
||||||
}
|
}
|
||||||
if (const auto info = namePeer->botVerifyDetails()) {
|
if (const auto info = namePeer->botVerifyDetails()) {
|
||||||
|
|
|
@ -1638,8 +1638,9 @@ stories.storyViewsList#59d78fc5 flags:# count:int views_count:int forwards_count
|
||||||
|
|
||||||
stories.storyViews#de9eed1d views:Vector<StoryViews> users:Vector<User> = stories.StoryViews;
|
stories.storyViews#de9eed1d views:Vector<StoryViews> users:Vector<User> = stories.StoryViews;
|
||||||
|
|
||||||
inputReplyToMessage#22c0f6d5 flags:# reply_to_msg_id:int top_msg_id:flags.0?int reply_to_peer_id:flags.1?InputPeer quote_text:flags.2?string quote_entities:flags.3?Vector<MessageEntity> quote_offset:flags.4?int = InputReplyTo;
|
inputReplyToMessage#b07038b0 flags:# reply_to_msg_id:int top_msg_id:flags.0?int reply_to_peer_id:flags.1?InputPeer quote_text:flags.2?string quote_entities:flags.3?Vector<MessageEntity> quote_offset:flags.4?int monoforum_peer_id:flags.5?InputPeer = InputReplyTo;
|
||||||
inputReplyToStory#5881323a peer:InputPeer story_id:int = InputReplyTo;
|
inputReplyToStory#5881323a peer:InputPeer story_id:int = InputReplyTo;
|
||||||
|
inputReplyToMonoForum#69d66c45 monoforum_peer_id:InputPeer = InputReplyTo;
|
||||||
|
|
||||||
exportedStoryLink#3fc9053b link:string = ExportedStoryLink;
|
exportedStoryLink#3fc9053b link:string = ExportedStoryLink;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue