test: add snapshot tests for MessageBuilder (#5598)
This commit is contained in:
+1
-37
@@ -59,43 +59,7 @@ inline QString parseTagString(const QString &input)
|
||||
return output;
|
||||
}
|
||||
|
||||
inline QDateTime calculateMessageTime(const Communi::IrcMessage *message)
|
||||
{
|
||||
// Check if message is from recent-messages API
|
||||
if (message->tags().contains("historical"))
|
||||
{
|
||||
bool customReceived = false;
|
||||
auto ts =
|
||||
message->tags().value("rm-received-ts").toLongLong(&customReceived);
|
||||
if (!customReceived)
|
||||
{
|
||||
ts = message->tags().value("tmi-sent-ts").toLongLong();
|
||||
}
|
||||
|
||||
return QDateTime::fromMSecsSinceEpoch(ts);
|
||||
}
|
||||
|
||||
// If present, handle tmi-sent-ts tag and use it as timestamp
|
||||
if (message->tags().contains("tmi-sent-ts"))
|
||||
{
|
||||
auto ts = message->tags().value("tmi-sent-ts").toLongLong();
|
||||
return QDateTime::fromMSecsSinceEpoch(ts);
|
||||
}
|
||||
|
||||
// Some IRC Servers might have server-time tag containing UTC date in ISO format, use it as timestamp
|
||||
// See: https://ircv3.net/irc/#server-time
|
||||
if (message->tags().contains("time"))
|
||||
{
|
||||
QString timedate = message->tags().value("time").toString();
|
||||
|
||||
auto date = QDateTime::fromString(timedate, Qt::ISODate);
|
||||
date.setTimeZone(QTimeZone::utc());
|
||||
return date.toLocalTime();
|
||||
}
|
||||
|
||||
// Fallback to current time
|
||||
return QDateTime::currentDateTime();
|
||||
}
|
||||
QDateTime calculateMessageTime(const Communi::IrcMessage *message);
|
||||
|
||||
// "foo/bar/baz,tri/hard" can be a valid badge-info tag
|
||||
// In that case, valid map content should be 'split by slash' only once:
|
||||
|
||||
Reference in New Issue
Block a user