mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Handle fwd_from without a link to the account.
This commit is contained in:
@@ -203,6 +203,9 @@ Stats AbstractWriter::produceTestExample(
|
||||
if (++count % 3 == 0) {
|
||||
message.forwardedFromId = Data::UserPeerId(user.info.userId);
|
||||
message.forwardedDate = date();
|
||||
} else if (count % 3 == 2) {
|
||||
message.forwardedFromName = "Test hidden forward";
|
||||
message.forwardedDate = date();
|
||||
}
|
||||
message.fromId = user.info.userId;
|
||||
message.replyToMsgId = counter();
|
||||
|
@@ -513,6 +513,8 @@ struct HtmlWriter::MessageInfo {
|
||||
int32 fromId = 0;
|
||||
TimeId date = 0;
|
||||
Data::PeerId forwardedFromId = 0;
|
||||
QString forwardedFromName;
|
||||
bool forwarded = false;
|
||||
TimeId forwardedDate = 0;
|
||||
};
|
||||
|
||||
@@ -648,6 +650,20 @@ void FillUserpicNames(UserpicData &data, const Data::Peer &peer) {
|
||||
}
|
||||
}
|
||||
|
||||
void FillUserpicNames(UserpicData &data, const QByteArray &full) {
|
||||
const auto names = full.split(' ');
|
||||
data.firstName = names[0];
|
||||
for (auto i = 1; i != names.size(); ++i) {
|
||||
if (names[i].isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (!data.lastName.isEmpty()) {
|
||||
data.lastName.append(' ');
|
||||
}
|
||||
data.lastName.append(names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray ComposeName(const UserpicData &data, const QByteArray &empty) {
|
||||
return ((data.firstName.isEmpty() && data.lastName.isEmpty())
|
||||
? empty
|
||||
@@ -948,7 +964,9 @@ auto HtmlWriter::Wrap::pushMessage(
|
||||
info.fromId = message.fromId;
|
||||
info.date = message.date;
|
||||
info.forwardedFromId = message.forwardedFromId;
|
||||
info.forwardedFromName = message.forwardedFromName;
|
||||
info.forwardedDate = message.forwardedDate;
|
||||
info.forwarded = message.forwarded;
|
||||
if (message.media.content.is<UnsupportedMedia>()) {
|
||||
return { info, pushServiceMessage(
|
||||
message.id,
|
||||
@@ -1122,19 +1140,24 @@ auto HtmlWriter::Wrap::pushMessage(
|
||||
block.append(pushDiv("from_name"));
|
||||
block.append(SerializeString(
|
||||
ComposeName(userpic, "Deleted Account")));
|
||||
if (!via.isEmpty() && !message.forwardedFromId) {
|
||||
if (!via.isEmpty() && !message.forwarded) {
|
||||
block.append(" via @" + via);
|
||||
}
|
||||
block.append(popTag());
|
||||
}
|
||||
if (message.forwardedFromId) {
|
||||
if (message.forwarded) {
|
||||
auto forwardedUserpic = UserpicData();
|
||||
forwardedUserpic.colorIndex = PeerColorIndex(
|
||||
BarePeerId(message.forwardedFromId));
|
||||
forwardedUserpic.colorIndex = message.forwardedFromId
|
||||
? PeerColorIndex(BarePeerId(message.forwardedFromId))
|
||||
: PeerColorIndex(message.id);
|
||||
forwardedUserpic.pixelSize = kHistoryUserpicSize;
|
||||
FillUserpicNames(
|
||||
forwardedUserpic,
|
||||
peers.peer(message.forwardedFromId));
|
||||
if (message.forwardedFromId) {
|
||||
FillUserpicNames(
|
||||
forwardedUserpic,
|
||||
peers.peer(message.forwardedFromId));
|
||||
} else {
|
||||
FillUserpicNames(forwardedUserpic, message.forwardedFromName);
|
||||
}
|
||||
|
||||
const auto forwardedWrap = forwardedNeedsWrap(message, previous);
|
||||
if (forwardedWrap) {
|
||||
@@ -1179,7 +1202,7 @@ auto HtmlWriter::Wrap::pushMessage(
|
||||
block.append(SerializeString(message.signature));
|
||||
block.append(popTag());
|
||||
}
|
||||
if (message.forwardedFromId) {
|
||||
if (message.forwarded) {
|
||||
block.append(popTag());
|
||||
}
|
||||
block.append(popTag());
|
||||
@@ -1200,10 +1223,12 @@ bool HtmlWriter::Wrap::messageNeedsWrap(
|
||||
} else if (QDateTime::fromTime_t(previous->date).date()
|
||||
!= QDateTime::fromTime_t(message.date).date()) {
|
||||
return true;
|
||||
} else if (!message.forwardedFromId != !previous->forwardedFromId) {
|
||||
} else if (message.forwarded != previous->forwarded) {
|
||||
return true;
|
||||
} else if (std::abs(message.date - previous->date)
|
||||
> (message.forwardedFromId ? 1 : kJoinWithinSeconds)) {
|
||||
> ((message.forwardedFromId || !message.forwardedFromName.isEmpty())
|
||||
? 1
|
||||
: kJoinWithinSeconds)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1725,11 +1750,12 @@ MediaData HtmlWriter::Wrap::prepareMediaData(
|
||||
bool HtmlWriter::Wrap::forwardedNeedsWrap(
|
||||
const Data::Message &message,
|
||||
const MessageInfo *previous) const {
|
||||
Expects(message.forwardedFromId != 0);
|
||||
Expects(message.forwarded);
|
||||
|
||||
if (messageNeedsWrap(message, previous)) {
|
||||
return true;
|
||||
} else if (message.forwardedFromId != previous->forwardedFromId) {
|
||||
} else if (!message.forwardedFromId
|
||||
|| message.forwardedFromId != previous->forwardedFromId) {
|
||||
return true;
|
||||
} else if (Data::IsChatPeerId(message.forwardedFromId)) {
|
||||
return true;
|
||||
|
@@ -471,6 +471,10 @@ QByteArray SerializeMessage(
|
||||
pushBare(
|
||||
"forwarded_from",
|
||||
wrapPeerName(message.forwardedFromId));
|
||||
} else if (!message.forwardedFromName.isEmpty()) {
|
||||
pushBare(
|
||||
"forwarded_from",
|
||||
StringAllowNull(message.forwardedFromName));
|
||||
}
|
||||
if (message.savedFromChatId) {
|
||||
pushBare("saved_from", wrapPeerName(message.savedFromChatId));
|
||||
|
@@ -342,6 +342,8 @@ QByteArray SerializeMessage(
|
||||
push("Author", message.signature);
|
||||
if (message.forwardedFromId) {
|
||||
push("Forwarded from", wrapPeerName(message.forwardedFromId));
|
||||
} else if (!message.forwardedFromName.isEmpty()) {
|
||||
push("Forwarded from", message.forwardedFromName);
|
||||
}
|
||||
if (message.savedFromChatId) {
|
||||
push("Saved from", wrapPeerName(message.savedFromChatId));
|
||||
|
Reference in New Issue
Block a user