Store serverReceivedTime in messages (#3735)

Co-authored-by: James Upjohn <jammehcow@jammehcow.co.nz>
This commit is contained in:
pajlada
2022-05-15 08:08:28 +02:00
committed by GitHub
parent 1bf31889f9
commit 3119a9bab3
6 changed files with 17 additions and 16 deletions
+5 -5
View File
@@ -58,7 +58,7 @@ inline QString parseTagString(const QString &input)
return output;
}
inline QTime calculateMessageTimestamp(const Communi::IrcMessage *message)
inline QDateTime calculateMessageTime(const Communi::IrcMessage *message)
{
// Check if message is from recent-messages API
if (message->tags().contains("historical"))
@@ -71,14 +71,14 @@ inline QTime calculateMessageTimestamp(const Communi::IrcMessage *message)
ts = message->tags().value("tmi-sent-ts").toLongLong();
}
return QDateTime::fromMSecsSinceEpoch(ts).time();
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).time();
return QDateTime::fromMSecsSinceEpoch(ts);
}
// Some IRC Servers might have server-time tag containing UTC date in ISO format, use it as timestamp
@@ -89,11 +89,11 @@ inline QTime calculateMessageTimestamp(const Communi::IrcMessage *message)
auto date = QDateTime::fromString(timedate, Qt::ISODate);
date.setTimeSpec(Qt::TimeSpec::UTC);
return date.toLocalTime().time();
return date.toLocalTime();
}
// Fallback to current time
return QTime::currentTime();
return QDateTime::currentDateTime();
}
} // namespace chatterino