mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show correct signature in send-as channel posts.
This commit is contained in:
parent
dc1df14a71
commit
f3dca6efb7
7 changed files with 60 additions and 109 deletions
|
@ -165,25 +165,15 @@ void SendExistingMedia(
|
||||||
flags |= MessageFlag::HasReplyInfo;
|
flags |= MessageFlag::HasReplyInfo;
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to;
|
||||||
}
|
}
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
|
||||||
const auto silentPost = ShouldSendSilent(peer, action.options);
|
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||||
InnerFillMessagePostFlags(action.options, peer, flags);
|
InnerFillMessagePostFlags(action.options, peer, flags);
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
||||||
}
|
}
|
||||||
const auto sendAs = action.options.sendAs;
|
const auto sendAs = action.options.sendAs;
|
||||||
const auto messageFromId = sendAs
|
|
||||||
? sendAs->id
|
|
||||||
: anonymousPost
|
|
||||||
? 0
|
|
||||||
: session->userPeerId();
|
|
||||||
if (sendAs) {
|
if (sendAs) {
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
||||||
}
|
}
|
||||||
const auto messagePostAuthor = peer->isBroadcast()
|
|
||||||
? session->user()->name()
|
|
||||||
: QString();
|
|
||||||
|
|
||||||
auto caption = TextWithEntities{
|
auto caption = TextWithEntities{
|
||||||
message.textWithTags.text,
|
message.textWithTags.text,
|
||||||
TextUtilities::ConvertTextTagsToEntities(message.textWithTags.tags)
|
TextUtilities::ConvertTextTagsToEntities(message.textWithTags.tags)
|
||||||
|
@ -219,11 +209,11 @@ void SendExistingMedia(
|
||||||
history->addNewLocalMessage({
|
history->addNewLocalMessage({
|
||||||
.id = newId.msg,
|
.id = newId.msg,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.from = messageFromId,
|
.from = NewMessageFromId(action),
|
||||||
.replyTo = action.replyTo,
|
.replyTo = action.replyTo,
|
||||||
.date = HistoryItem::NewMessageDate(action.options),
|
.date = NewMessageDate(action.options),
|
||||||
.shortcutId = action.options.shortcutId,
|
.shortcutId = action.options.shortcutId,
|
||||||
.postAuthor = messagePostAuthor,
|
.postAuthor = NewMessagePostAuthor(action),
|
||||||
.effectId = action.options.effectId,
|
.effectId = action.options.effectId,
|
||||||
}, media, caption);
|
}, media, caption);
|
||||||
|
|
||||||
|
@ -361,25 +351,15 @@ bool SendDice(MessageToSend &message) {
|
||||||
flags |= MessageFlag::HasReplyInfo;
|
flags |= MessageFlag::HasReplyInfo;
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to;
|
||||||
}
|
}
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
|
||||||
const auto silentPost = ShouldSendSilent(peer, action.options);
|
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||||
InnerFillMessagePostFlags(action.options, peer, flags);
|
InnerFillMessagePostFlags(action.options, peer, flags);
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
||||||
}
|
}
|
||||||
const auto sendAs = action.options.sendAs;
|
const auto sendAs = action.options.sendAs;
|
||||||
const auto messageFromId = sendAs
|
|
||||||
? sendAs->id
|
|
||||||
: anonymousPost
|
|
||||||
? 0
|
|
||||||
: session->userPeerId();
|
|
||||||
if (sendAs) {
|
if (sendAs) {
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
||||||
}
|
}
|
||||||
const auto messagePostAuthor = peer->isBroadcast()
|
|
||||||
? session->user()->name()
|
|
||||||
: QString();
|
|
||||||
|
|
||||||
if (action.options.scheduled) {
|
if (action.options.scheduled) {
|
||||||
flags |= MessageFlag::IsOrWasScheduled;
|
flags |= MessageFlag::IsOrWasScheduled;
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_date;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_date;
|
||||||
|
@ -401,11 +381,11 @@ bool SendDice(MessageToSend &message) {
|
||||||
history->addNewLocalMessage({
|
history->addNewLocalMessage({
|
||||||
.id = newId.msg,
|
.id = newId.msg,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.from = messageFromId,
|
.from = NewMessageFromId(action),
|
||||||
.replyTo = action.replyTo,
|
.replyTo = action.replyTo,
|
||||||
.date = HistoryItem::NewMessageDate(action.options),
|
.date = NewMessageDate(action.options),
|
||||||
.shortcutId = action.options.shortcutId,
|
.shortcutId = action.options.shortcutId,
|
||||||
.postAuthor = messagePostAuthor,
|
.postAuthor = NewMessagePostAuthor(action),
|
||||||
.effectId = action.options.effectId,
|
.effectId = action.options.effectId,
|
||||||
}, TextWithEntities(), MTP_messageMediaDice(
|
}, TextWithEntities(), MTP_messageMediaDice(
|
||||||
MTP_int(0),
|
MTP_int(0),
|
||||||
|
@ -529,7 +509,6 @@ void SendConfirmedFile(
|
||||||
if (file->to.replyTo) {
|
if (file->to.replyTo) {
|
||||||
flags |= MessageFlag::HasReplyInfo;
|
flags |= MessageFlag::HasReplyInfo;
|
||||||
}
|
}
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
|
||||||
FillMessagePostFlags(action, peer, flags);
|
FillMessagePostFlags(action, peer, flags);
|
||||||
if (file->to.options.scheduled) {
|
if (file->to.options.scheduled) {
|
||||||
flags |= MessageFlag::IsOrWasScheduled;
|
flags |= MessageFlag::IsOrWasScheduled;
|
||||||
|
@ -551,16 +530,6 @@ void SendConfirmedFile(
|
||||||
if (file->to.options.invertCaption) {
|
if (file->to.options.invertCaption) {
|
||||||
flags |= MessageFlag::InvertMedia;
|
flags |= MessageFlag::InvertMedia;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto messageFromId = file->to.options.sendAs
|
|
||||||
? file->to.options.sendAs->id
|
|
||||||
: anonymousPost
|
|
||||||
? PeerId()
|
|
||||||
: session->userPeerId();
|
|
||||||
const auto messagePostAuthor = peer->isBroadcast()
|
|
||||||
? session->user()->name()
|
|
||||||
: QString();
|
|
||||||
|
|
||||||
const auto media = MTPMessageMedia([&] {
|
const auto media = MTPMessageMedia([&] {
|
||||||
if (file->type == SendMediaType::Photo) {
|
if (file->type == SendMediaType::Photo) {
|
||||||
using Flag = MTPDmessageMediaPhoto::Flag;
|
using Flag = MTPDmessageMediaPhoto::Flag;
|
||||||
|
@ -626,11 +595,11 @@ void SendConfirmedFile(
|
||||||
history->addNewLocalMessage({
|
history->addNewLocalMessage({
|
||||||
.id = newId.msg,
|
.id = newId.msg,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.from = messageFromId,
|
.from = NewMessageFromId(action),
|
||||||
.replyTo = file->to.replyTo,
|
.replyTo = file->to.replyTo,
|
||||||
.date = HistoryItem::NewMessageDate(file->to.options),
|
.date = NewMessageDate(file->to.options),
|
||||||
.shortcutId = file->to.options.shortcutId,
|
.shortcutId = file->to.options.shortcutId,
|
||||||
.postAuthor = messagePostAuthor,
|
.postAuthor = NewMessagePostAuthor(action),
|
||||||
.groupedId = groupId,
|
.groupedId = groupId,
|
||||||
.effectId = file->to.options.effectId,
|
.effectId = file->to.options.effectId,
|
||||||
}, caption, media);
|
}, caption, media);
|
||||||
|
|
|
@ -3283,7 +3283,6 @@ void ApiWrap::forwardMessages(
|
||||||
histories.readInbox(history);
|
histories.readInbox(history);
|
||||||
}
|
}
|
||||||
const auto sendAs = action.options.sendAs;
|
const auto sendAs = action.options.sendAs;
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
|
||||||
const auto silentPost = ShouldSendSilent(peer, action.options);
|
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||||
|
|
||||||
using SendFlag = MTPmessages_ForwardMessages::Flag;
|
using SendFlag = MTPmessages_ForwardMessages::Flag;
|
||||||
|
@ -3376,22 +3375,14 @@ void ApiWrap::forwardMessages(
|
||||||
peer->id,
|
peer->id,
|
||||||
_session->data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto self = _session->user();
|
const auto self = _session->user();
|
||||||
const auto messageFromId = sendAs
|
|
||||||
? sendAs->id
|
|
||||||
: anonymousPost
|
|
||||||
? PeerId(0)
|
|
||||||
: self->id;
|
|
||||||
const auto messagePostAuthor = peer->isBroadcast()
|
|
||||||
? self->name()
|
|
||||||
: QString();
|
|
||||||
history->addNewLocalMessage({
|
history->addNewLocalMessage({
|
||||||
.id = newId.msg,
|
.id = newId.msg,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.from = messageFromId,
|
.from = NewMessageFromId(action),
|
||||||
.replyTo = { .topicRootId = topMsgId },
|
.replyTo = { .topicRootId = topMsgId },
|
||||||
.date = HistoryItem::NewMessageDate(action.options),
|
.date = NewMessageDate(action.options),
|
||||||
.shortcutId = action.options.shortcutId,
|
.shortcutId = action.options.shortcutId,
|
||||||
.postAuthor = messagePostAuthor,
|
.postAuthor = NewMessagePostAuthor(action),
|
||||||
|
|
||||||
// forwarded messages don't have effects
|
// forwarded messages don't have effects
|
||||||
//.effectId = action.options.effectId,
|
//.effectId = action.options.effectId,
|
||||||
|
@ -3466,8 +3457,6 @@ void ApiWrap::sendSharedContact(
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
peer->id,
|
peer->id,
|
||||||
_session->data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
|
||||||
|
|
||||||
auto flags = NewMessageFlags(peer);
|
auto flags = NewMessageFlags(peer);
|
||||||
if (action.replyTo) {
|
if (action.replyTo) {
|
||||||
flags |= MessageFlag::HasReplyInfo;
|
flags |= MessageFlag::HasReplyInfo;
|
||||||
|
@ -3479,22 +3468,14 @@ void ApiWrap::sendSharedContact(
|
||||||
if (action.options.shortcutId) {
|
if (action.options.shortcutId) {
|
||||||
flags |= MessageFlag::ShortcutMessage;
|
flags |= MessageFlag::ShortcutMessage;
|
||||||
}
|
}
|
||||||
const auto messageFromId = action.options.sendAs
|
|
||||||
? action.options.sendAs->id
|
|
||||||
: anonymousPost
|
|
||||||
? PeerId()
|
|
||||||
: _session->userPeerId();
|
|
||||||
const auto messagePostAuthor = peer->isBroadcast()
|
|
||||||
? _session->user()->name()
|
|
||||||
: QString();
|
|
||||||
const auto item = history->addNewLocalMessage({
|
const auto item = history->addNewLocalMessage({
|
||||||
.id = newId.msg,
|
.id = newId.msg,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.from = messageFromId,
|
.from = NewMessageFromId(action),
|
||||||
.replyTo = action.replyTo,
|
.replyTo = action.replyTo,
|
||||||
.date = HistoryItem::NewMessageDate(action.options),
|
.date = NewMessageDate(action.options),
|
||||||
.shortcutId = action.options.shortcutId,
|
.shortcutId = action.options.shortcutId,
|
||||||
.postAuthor = messagePostAuthor,
|
.postAuthor = NewMessagePostAuthor(action),
|
||||||
.effectId = action.options.effectId,
|
.effectId = action.options.effectId,
|
||||||
}, TextWithEntities(), MTP_messageMediaContact(
|
}, TextWithEntities(), MTP_messageMediaContact(
|
||||||
MTP_string(phone),
|
MTP_string(phone),
|
||||||
|
@ -3780,7 +3761,6 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||||
MTP_string(fields.url),
|
MTP_string(fields.url),
|
||||||
MTP_int(page->pendingTill)));
|
MTP_int(page->pendingTill)));
|
||||||
}
|
}
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
|
||||||
const auto silentPost = ShouldSendSilent(peer, action.options);
|
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||||
FillMessagePostFlags(action, peer, flags);
|
FillMessagePostFlags(action, peer, flags);
|
||||||
if ((exactWebPage && !ignoreWebPage && message.webPage.invert)
|
if ((exactWebPage && !ignoreWebPage && message.webPage.invert)
|
||||||
|
@ -3808,18 +3788,10 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||||
history->startSavingCloudDraft(draftTopicRootId);
|
history->startSavingCloudDraft(draftTopicRootId);
|
||||||
}
|
}
|
||||||
const auto sendAs = action.options.sendAs;
|
const auto sendAs = action.options.sendAs;
|
||||||
const auto messageFromId = sendAs
|
|
||||||
? sendAs->id
|
|
||||||
: anonymousPost
|
|
||||||
? PeerId()
|
|
||||||
: _session->userPeerId();
|
|
||||||
if (sendAs) {
|
if (sendAs) {
|
||||||
sendFlags |= MTPmessages_SendMessage::Flag::f_send_as;
|
sendFlags |= MTPmessages_SendMessage::Flag::f_send_as;
|
||||||
mediaFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
mediaFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
||||||
}
|
}
|
||||||
const auto messagePostAuthor = peer->isBroadcast()
|
|
||||||
? _session->user()->name()
|
|
||||||
: QString();
|
|
||||||
if (action.options.scheduled) {
|
if (action.options.scheduled) {
|
||||||
flags |= MessageFlag::IsOrWasScheduled;
|
flags |= MessageFlag::IsOrWasScheduled;
|
||||||
sendFlags |= MTPmessages_SendMessage::Flag::f_schedule_date;
|
sendFlags |= MTPmessages_SendMessage::Flag::f_schedule_date;
|
||||||
|
@ -3837,11 +3809,11 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||||
lastMessage = history->addNewLocalMessage({
|
lastMessage = history->addNewLocalMessage({
|
||||||
.id = newId.msg,
|
.id = newId.msg,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.from = messageFromId,
|
.from = NewMessageFromId(action),
|
||||||
.replyTo = action.replyTo,
|
.replyTo = action.replyTo,
|
||||||
.date = HistoryItem::NewMessageDate(action.options),
|
.date = NewMessageDate(action.options),
|
||||||
.shortcutId = action.options.shortcutId,
|
.shortcutId = action.options.shortcutId,
|
||||||
.postAuthor = messagePostAuthor,
|
.postAuthor = NewMessagePostAuthor(action),
|
||||||
.effectId = action.options.effectId,
|
.effectId = action.options.effectId,
|
||||||
}, sending, media);
|
}, sending, media);
|
||||||
const auto done = [=](
|
const auto done = [=](
|
||||||
|
@ -3987,7 +3959,6 @@ void ApiWrap::sendInlineResult(
|
||||||
flags |= MessageFlag::HasReplyInfo;
|
flags |= MessageFlag::HasReplyInfo;
|
||||||
sendFlags |= SendFlag::f_reply_to;
|
sendFlags |= SendFlag::f_reply_to;
|
||||||
}
|
}
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
|
||||||
const auto silentPost = ShouldSendSilent(peer, action.options);
|
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||||
FillMessagePostFlags(action, peer, flags);
|
FillMessagePostFlags(action, peer, flags);
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
|
@ -4006,30 +3977,22 @@ void ApiWrap::sendInlineResult(
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto sendAs = action.options.sendAs;
|
const auto sendAs = action.options.sendAs;
|
||||||
const auto messageFromId = sendAs
|
|
||||||
? sendAs->id
|
|
||||||
: anonymousPost ? PeerId()
|
|
||||||
: _session->userPeerId();
|
|
||||||
if (sendAs) {
|
if (sendAs) {
|
||||||
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_send_as;
|
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_send_as;
|
||||||
}
|
}
|
||||||
const auto messagePostAuthor = peer->isBroadcast()
|
|
||||||
? _session->user()->name()
|
|
||||||
: QString();
|
|
||||||
|
|
||||||
_session->data().registerMessageRandomId(randomId, newId);
|
_session->data().registerMessageRandomId(randomId, newId);
|
||||||
|
|
||||||
data->addToHistory(history, {
|
data->addToHistory(history, {
|
||||||
.id = newId.msg,
|
.id = newId.msg,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.from = messageFromId,
|
.from = NewMessageFromId(action),
|
||||||
.replyTo = action.replyTo,
|
.replyTo = action.replyTo,
|
||||||
.date = HistoryItem::NewMessageDate(action.options),
|
.date = NewMessageDate(action.options),
|
||||||
.shortcutId = action.options.shortcutId,
|
.shortcutId = action.options.shortcutId,
|
||||||
.viaBotId = ((bot && !action.options.hideViaBot)
|
.viaBotId = ((bot && !action.options.hideViaBot)
|
||||||
? peerToUser(bot->id)
|
? peerToUser(bot->id)
|
||||||
: UserId()),
|
: UserId()),
|
||||||
.postAuthor = messagePostAuthor,
|
.postAuthor = NewMessagePostAuthor(action),
|
||||||
});
|
});
|
||||||
|
|
||||||
history->clearCloudDraft(topicRootId);
|
history->clearCloudDraft(topicRootId);
|
||||||
|
|
|
@ -671,9 +671,7 @@ HistoryItem::HistoryItem(
|
||||||
.flags = (MessageFlag::Local
|
.flags = (MessageFlag::Local
|
||||||
| MessageFlag::Sponsored
|
| MessageFlag::Sponsored
|
||||||
| (history->peer->isChannel() ? MessageFlag::Post : MessageFlag(0))),
|
| (history->peer->isChannel() ? MessageFlag::Post : MessageFlag(0))),
|
||||||
.date = HistoryItem::NewMessageDate(injectedAfter
|
.date = NewMessageDate(injectedAfter ? injectedAfter->date() : 0),
|
||||||
? injectedAfter->date()
|
|
||||||
: 0),
|
|
||||||
}) {
|
}) {
|
||||||
const auto webpage = history->peer->owner().webpage(
|
const auto webpage = history->peer->owner().webpage(
|
||||||
history->peer->owner().nextLocalMessageId().bare,
|
history->peer->owner().nextLocalMessageId().bare,
|
||||||
|
@ -761,15 +759,6 @@ TimeId HistoryItem::date() const {
|
||||||
return _date;
|
return _date;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeId HistoryItem::NewMessageDate(TimeId scheduled) {
|
|
||||||
return scheduled ? scheduled : base::unixtime::now();
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeId HistoryItem::NewMessageDate(
|
|
||||||
const Api::SendOptions &options) {
|
|
||||||
return options.shortcutId ? 1 : NewMessageDate(options.scheduled);
|
|
||||||
}
|
|
||||||
|
|
||||||
HistoryServiceDependentData *HistoryItem::GetServiceDependentData() {
|
HistoryServiceDependentData *HistoryItem::GetServiceDependentData() {
|
||||||
if (const auto pinned = Get<HistoryServicePinned>()) {
|
if (const auto pinned = Get<HistoryServicePinned>()) {
|
||||||
return pinned;
|
return pinned;
|
||||||
|
|
|
@ -482,10 +482,6 @@ public:
|
||||||
[[nodiscard]] Data::MessagePosition position() const;
|
[[nodiscard]] Data::MessagePosition position() const;
|
||||||
[[nodiscard]] TimeId date() const;
|
[[nodiscard]] TimeId date() const;
|
||||||
|
|
||||||
[[nodiscard]] static TimeId NewMessageDate(TimeId scheduled);
|
|
||||||
[[nodiscard]] static TimeId NewMessageDate(
|
|
||||||
const Api::SendOptions &options);
|
|
||||||
|
|
||||||
[[nodiscard]] Data::Media *media() const {
|
[[nodiscard]] Data::Media *media() const {
|
||||||
return _media.get();
|
return _media.get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,6 +187,32 @@ MessageFlags NewMessageFlags(not_null<PeerData*> peer) {
|
||||||
| (peer->isSelf() ? MessageFlag() : MessageFlag::Outgoing);
|
| (peer->isSelf() ? MessageFlag() : MessageFlag::Outgoing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TimeId NewMessageDate(TimeId scheduled) {
|
||||||
|
return scheduled ? scheduled : base::unixtime::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
TimeId NewMessageDate(const Api::SendOptions &options) {
|
||||||
|
return options.shortcutId ? 1 : NewMessageDate(options.scheduled);
|
||||||
|
}
|
||||||
|
|
||||||
|
PeerId NewMessageFromId(const Api::SendAction &action) {
|
||||||
|
return action.options.sendAs
|
||||||
|
? action.options.sendAs->id
|
||||||
|
: action.history->peer->amAnonymous()
|
||||||
|
? PeerId()
|
||||||
|
: action.history->session().userPeerId();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NewMessagePostAuthor(const Api::SendAction &action) {
|
||||||
|
return !action.history->peer->isBroadcast()
|
||||||
|
? QString()
|
||||||
|
: (action.options.sendAs == action.history->peer)
|
||||||
|
? QString()
|
||||||
|
: action.options.sendAs
|
||||||
|
? action.options.sendAs->name()
|
||||||
|
: action.history->session().user()->name();
|
||||||
|
}
|
||||||
|
|
||||||
bool ShouldSendSilent(
|
bool ShouldSendSilent(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const Api::SendOptions &options) {
|
const Api::SendOptions &options) {
|
||||||
|
@ -320,7 +346,7 @@ ClickHandlerPtr JumpToMessageClickHandler(
|
||||||
const auto separate = Core::App().separateWindowFor(peer);
|
const auto separate = Core::App().separateWindowFor(peer);
|
||||||
const auto controller = separate
|
const auto controller = separate
|
||||||
? separate->sessionController()
|
? separate->sessionController()
|
||||||
: peer->session().tryResolveWindow();
|
: peer->session().tryResolveWindow(peer);
|
||||||
if (controller) {
|
if (controller) {
|
||||||
auto params = Window::SectionShow{
|
auto params = Window::SectionShow{
|
||||||
Window::SectionShow::Way::Forward
|
Window::SectionShow::Way::Forward
|
||||||
|
|
|
@ -83,6 +83,10 @@ void RequestDependentMessageStory(
|
||||||
PeerId peerId,
|
PeerId peerId,
|
||||||
StoryId storyId);
|
StoryId storyId);
|
||||||
[[nodiscard]] MessageFlags NewMessageFlags(not_null<PeerData*> peer);
|
[[nodiscard]] MessageFlags NewMessageFlags(not_null<PeerData*> peer);
|
||||||
|
[[nodiscard]] TimeId NewMessageDate(TimeId scheduled);
|
||||||
|
[[nodiscard]] TimeId NewMessageDate(const Api::SendOptions &options);
|
||||||
|
[[nodiscard]] PeerId NewMessageFromId(const Api::SendAction &action);
|
||||||
|
[[nodiscard]] QString NewMessagePostAuthor(const Api::SendAction &action);
|
||||||
[[nodiscard]] bool ShouldSendSilent(
|
[[nodiscard]] bool ShouldSendSilent(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const Api::SendOptions &options);
|
const Api::SendOptions &options);
|
||||||
|
|
|
@ -117,6 +117,12 @@ not_null<PeerData*> SendAsPeers::ResolveChosen(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const std::vector<SendAsPeer> &list,
|
const std::vector<SendAsPeer> &list,
|
||||||
PeerId chosen) {
|
PeerId chosen) {
|
||||||
|
const auto fallback = peer->amAnonymous()
|
||||||
|
? peer
|
||||||
|
: peer->session().user();
|
||||||
|
if (!chosen) {
|
||||||
|
chosen = fallback->id;
|
||||||
|
}
|
||||||
const auto i = ranges::find(list, chosen, [](const SendAsPeer &as) {
|
const auto i = ranges::find(list, chosen, [](const SendAsPeer &as) {
|
||||||
return as.peer->id;
|
return as.peer->id;
|
||||||
});
|
});
|
||||||
|
@ -124,9 +130,7 @@ not_null<PeerData*> SendAsPeers::ResolveChosen(
|
||||||
? i->peer
|
? i->peer
|
||||||
: !list.empty()
|
: !list.empty()
|
||||||
? list.front().peer
|
? list.front().peer
|
||||||
: peer->amAnonymous()
|
: fallback;
|
||||||
? peer
|
|
||||||
: peer->session().user();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendAsPeers::request(not_null<PeerData*> peer) {
|
void SendAsPeers::request(not_null<PeerData*> peer) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue