mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 21:27:07 +02:00
Show via_business_bot name in signature.
This commit is contained in:
parent
90e572c8b1
commit
caa4c5428a
5 changed files with 29 additions and 16 deletions
|
@ -146,6 +146,7 @@ struct HistoryItem::CreateConfig {
|
|||
ReplyFields reply;
|
||||
|
||||
UserId viaBotId = 0;
|
||||
UserId viaBusinessBotId = 0;
|
||||
int viewsCount = -1;
|
||||
int forwardsCount = -1;
|
||||
int boostsApplied = 0;
|
||||
|
@ -2577,8 +2578,8 @@ QString HistoryItem::originalPostAuthor() const {
|
|||
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||
return forwarded->originalPostAuthor;
|
||||
} else if (const auto msgsigned = Get<HistoryMessageSigned>()) {
|
||||
if (!msgsigned->isAnonymousRank) {
|
||||
return msgsigned->postAuthor;
|
||||
if (!msgsigned->isAnonymousRank && !msgsigned->viaBusinessBot) {
|
||||
return msgsigned->author;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
|
@ -2650,7 +2651,9 @@ void HistoryItem::setForwardsCount(int count) {
|
|||
|
||||
void HistoryItem::setPostAuthor(const QString &postAuthor) {
|
||||
auto msgsigned = Get<HistoryMessageSigned>();
|
||||
if (postAuthor.isEmpty()) {
|
||||
if (msgsigned && msgsigned->viaBusinessBot) {
|
||||
return;
|
||||
} else if (postAuthor.isEmpty()) {
|
||||
if (!msgsigned) {
|
||||
return;
|
||||
}
|
||||
|
@ -2661,10 +2664,10 @@ void HistoryItem::setPostAuthor(const QString &postAuthor) {
|
|||
if (!msgsigned) {
|
||||
AddComponents(HistoryMessageSigned::Bit());
|
||||
msgsigned = Get<HistoryMessageSigned>();
|
||||
} else if (msgsigned->postAuthor == postAuthor) {
|
||||
} else if (msgsigned->author == postAuthor) {
|
||||
return;
|
||||
}
|
||||
msgsigned->postAuthor = postAuthor;
|
||||
msgsigned->author = postAuthor;
|
||||
msgsigned->isAnonymousRank = !isDiscussionPost()
|
||||
&& this->author()->isMegagroup();
|
||||
history()->owner().requestItemResize(this);
|
||||
|
@ -3272,7 +3275,7 @@ void HistoryItem::createComponents(CreateConfig &&config) {
|
|||
if (config.viewsCount >= 0 || !config.replies.isNull) {
|
||||
mask |= HistoryMessageViews::Bit();
|
||||
}
|
||||
if (!config.postAuthor.isEmpty()) {
|
||||
if (!config.postAuthor.isEmpty() || config.viaBusinessBotId) {
|
||||
mask |= HistoryMessageSigned::Bit();
|
||||
} else if (_history->peer->isMegagroup() // Discussion posts signatures.
|
||||
&& config.savedFromPeer
|
||||
|
@ -3345,11 +3348,17 @@ void HistoryItem::createComponents(CreateConfig &&config) {
|
|||
edited->date = config.editDate;
|
||||
}
|
||||
if (const auto msgsigned = Get<HistoryMessageSigned>()) {
|
||||
msgsigned->postAuthor = config.postAuthor.isEmpty()
|
||||
? config.originalPostAuthor
|
||||
: config.postAuthor;
|
||||
msgsigned->isAnonymousRank = !isDiscussionPost()
|
||||
&& author()->isMegagroup();
|
||||
if (config.viaBusinessBotId) {
|
||||
msgsigned->viaBusinessBot = _history->owner().user(
|
||||
config.viaBusinessBotId);
|
||||
msgsigned->author = msgsigned->viaBusinessBot->name();
|
||||
} else {
|
||||
msgsigned->author = config.postAuthor.isEmpty()
|
||||
? config.originalPostAuthor
|
||||
: config.postAuthor;
|
||||
msgsigned->isAnonymousRank = !isDiscussionPost()
|
||||
&& author()->isMegagroup();
|
||||
}
|
||||
}
|
||||
setupForwardedComponent(config);
|
||||
if (const auto markup = Get<HistoryMessageReplyMarkup>()) {
|
||||
|
@ -3636,6 +3645,7 @@ void HistoryItem::createComponents(const MTPDmessage &data) {
|
|||
config.reply = ReplyFieldsFromMTP(this, *reply);
|
||||
}
|
||||
config.viaBotId = data.vvia_bot_id().value_or_empty();
|
||||
config.viaBusinessBotId = data.vvia_business_bot_id().value_or_empty();
|
||||
config.viewsCount = data.vviews().value_or(-1);
|
||||
config.forwardsCount = data.vforwards().value_or(-1);
|
||||
config.replies = isScheduled()
|
||||
|
|
|
@ -78,7 +78,8 @@ struct HistoryMessageViews : public RuntimeComponent<HistoryMessageViews, Histor
|
|||
};
|
||||
|
||||
struct HistoryMessageSigned : public RuntimeComponent<HistoryMessageSigned, HistoryItem> {
|
||||
QString postAuthor;
|
||||
QString author;
|
||||
UserData *viaBusinessBot = nullptr;
|
||||
bool isAnonymousRank = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -663,7 +663,7 @@ BottomInfo::Data BottomInfoDataFromMessage(not_null<Message*> message) {
|
|||
}
|
||||
if (const auto msgsigned = item->Get<HistoryMessageSigned>()) {
|
||||
if (!msgsigned->isAnonymousRank) {
|
||||
result.author = msgsigned->postAuthor;
|
||||
result.author = msgsigned->author;
|
||||
}
|
||||
}
|
||||
if (message->displayedEditDate()) {
|
||||
|
|
|
@ -279,7 +279,7 @@ QString DateTooltipText(not_null<Element*> view) {
|
|||
dateText += '\n' + tr::lng_signed_author(
|
||||
tr::now,
|
||||
lt_user,
|
||||
msgsigned->postAuthor);
|
||||
msgsigned->author);
|
||||
}
|
||||
}
|
||||
if (item->isScheduled() && item->isSilent()) {
|
||||
|
|
|
@ -462,8 +462,10 @@ void Message::refreshRightBadge() {
|
|||
: tr::lng_channel_badge(tr::now);
|
||||
} else if (item->author()->isMegagroup()) {
|
||||
if (const auto msgsigned = item->Get<HistoryMessageSigned>()) {
|
||||
Assert(msgsigned->isAnonymousRank);
|
||||
return msgsigned->postAuthor;
|
||||
if (!msgsigned->viaBusinessBot) {
|
||||
Assert(msgsigned->isAnonymousRank);
|
||||
return msgsigned->author;
|
||||
}
|
||||
}
|
||||
}
|
||||
const auto channel = item->history()->peer->asMegagroup();
|
||||
|
|
Loading…
Add table
Reference in a new issue