mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Use server time in received IRC messages where available (#3026)
This commit is contained in:
parent
fa2fd4593b
commit
a84e62c6bb
|
@ -4,6 +4,8 @@
|
|||
|
||||
- Major: Newly uploaded Twitch emotes are once again present in emote picker and can be autocompleted with Tab as well. (#2992)
|
||||
- Minor: Added autocompletion in /whispers for Twitch emotes, Global Bttv/Ffz emotes and emojis. (#2999)
|
||||
- Minor: Received Twitch messages now use the exact same timestamp (obtained from Twitch's server) for every Chatterino user instead of assuming message timestamp on client's side. (#3021)
|
||||
- Minor: Received IRC messages use `time` message tag for timestamp if it's available. (#3021)
|
||||
- Bugfix: Fixed "smiley" emotes being unable to be "Tabbed" with autocompletion, introduced in v2.3.3. (#3010)
|
||||
- Dev: Ubuntu packages are now available (#2936)
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ MessagePtr IrcMessageBuilder::build()
|
|||
// PUSH ELEMENTS
|
||||
this->appendChannelName();
|
||||
|
||||
this->emplace<TimestampElement>();
|
||||
this->emplace<TimestampElement>(
|
||||
calculateMessageTimestamp(this->ircMessage));
|
||||
|
||||
this->appendUsername();
|
||||
|
||||
|
@ -70,8 +71,6 @@ void IrcMessageBuilder::addWords(const QStringList &words)
|
|||
|
||||
void IrcMessageBuilder::appendUsername()
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
QString username = this->userName;
|
||||
this->message().loginName = username;
|
||||
this->message().displayName = username;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "providers/irc/IrcChannel2.hpp"
|
||||
#include "providers/irc/IrcMessageBuilder.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "util/IrcHelpers.hpp"
|
||||
#include "util/QObjectRef.hpp"
|
||||
|
||||
#include <QMetaEnum>
|
||||
|
@ -92,7 +93,8 @@ void IrcServer::initializeConnectionSignals(IrcConnection *connection,
|
|||
// XD PAJLADA
|
||||
MessageBuilder builder;
|
||||
|
||||
builder.emplace<TimestampElement>();
|
||||
builder.emplace<TimestampElement>(
|
||||
calculateMessageTimestamp(message));
|
||||
builder.emplace<TextElement>(
|
||||
message->nick(), MessageElementFlag::Username);
|
||||
builder.emplace<TextElement>(
|
||||
|
@ -259,7 +261,8 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
|
|||
{
|
||||
MessageBuilder builder;
|
||||
|
||||
builder.emplace<TimestampElement>();
|
||||
builder.emplace<TimestampElement>(
|
||||
calculateMessageTimestamp(message));
|
||||
builder.emplace<TextElement>(message->toData(),
|
||||
MessageElementFlag::Text);
|
||||
builder->flags.set(MessageFlag::Debug);
|
||||
|
|
|
@ -65,7 +65,7 @@ inline QTime calculateMessageTimestamp(const Communi::IrcMessage *message)
|
|||
if (message->tags().contains("historical"))
|
||||
{
|
||||
bool customReceived = false;
|
||||
qint64 ts =
|
||||
auto ts =
|
||||
message->tags().value("rm-received-ts").toLongLong(&customReceived);
|
||||
if (!customReceived)
|
||||
{
|
||||
|
@ -74,10 +74,27 @@ inline QTime calculateMessageTimestamp(const Communi::IrcMessage *message)
|
|||
|
||||
return QDateTime::fromMSecsSinceEpoch(ts).time();
|
||||
}
|
||||
else
|
||||
|
||||
// If present, handle tmi-sent-ts tag and use it as timestamp
|
||||
if (message->tags().contains("tmi-sent-ts"))
|
||||
{
|
||||
return QTime::currentTime();
|
||||
auto ts = message->tags().value("tmi-sent-ts").toLongLong();
|
||||
return QDateTime::fromMSecsSinceEpoch(ts).time();
|
||||
}
|
||||
|
||||
// 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.setTimeSpec(Qt::TimeSpec::UTC);
|
||||
return date.toLocalTime().time();
|
||||
}
|
||||
|
||||
// Fallback to current time
|
||||
return QTime::currentTime();
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
Loading…
Reference in a new issue