core: Remove away-notify hack for non-spec server
[quassel.git] / src / core / coresessioneventprocessor.cpp
index 76cddb3..04233f3 100644 (file)
@@ -28,7 +28,7 @@
 #include "ctcpevent.h"
 #include "ircevent.h"
 #include "ircuser.h"
-#include "logger.h"
+#include "logmessage.h"
 #include "messageevent.h"
 #include "netsplit.h"
 #include "quassel.h"
@@ -402,11 +402,16 @@ void CoreSessionEventProcessor::processIrcEventJoin(IrcEvent *e)
             break;
     }
 
-    // If using away-notify, check new users.  Works around buggy IRC servers
-    // forgetting to send :away messages for users who join channels when away.
-    if (net->capEnabled(IrcCap::AWAY_NOTIFY)) {
-        net->queueAutoWhoOneshot(ircuser->nick());
-    }
+    // With "away-notify" enabled, some IRC servers forget to send :away messages for users who join
+    // channels while away.  Unfortunately, working around this involves WHO'ng every single user as
+    // they join, which is not very efficient.  If at all possible, it's better to get the issue
+    // fixed in the IRC server instead.
+    //
+    // If pursuing a workaround instead, this is where you'd do it.  Check the version control
+    // history for the commit that added this comment to see how to implement it - there's some
+    // unexpected situations to watch out for!
+    //
+    // See https://ircv3.net/specs/extensions/away-notify-3.1.html
 
     if (!handledByNetsplit)
         ircuser->joinChannel(channel);
@@ -1054,13 +1059,13 @@ void CoreSessionEventProcessor::processIrcEvent322(IrcEvent *e)
     switch (e->params().count()) {
     case 3:
         topic = e->params()[2];
-        [[clang::fallthrough]];
+        // fallthrough
     case 2:
         userCount = e->params()[1].toUInt();
-        [[clang::fallthrough]];
+        // fallthrough
     case 1:
         channelName = e->params()[0];
-        [[clang::fallthrough]];
+        // fallthrough
     default:
         break;
     }
@@ -1134,9 +1139,7 @@ void CoreSessionEventProcessor::processIrcEvent352(IrcEvent *e)
         return;
 
     QString channel = e->params()[0];
-    // Store the nick separate from ircuser for AutoWho check below
-    QString nick = e->params()[4];
-    IrcUser *ircuser = e->network()->ircUser(nick);
+    IrcUser *ircuser = e->network()->ircUser(e->params()[4]);
     if (ircuser) {
         // Only process the WHO information if an IRC user exists.  Don't create an IRC user here;
         // there's no way to track when the user quits, which would leave a phantom IrcUser lying
@@ -1148,10 +1151,7 @@ void CoreSessionEventProcessor::processIrcEvent352(IrcEvent *e)
     }
 
     // Check if channel name has a who in progress.
-    // If not, then check if user nickname has a who in progress.  Use nick directly; don't use
-    // ircuser as that may be deleted (e.g. nick joins channel, leaves before WHO reply received).
-    if (coreNetwork(e)->isAutoWhoInProgress(channel) ||
-        (coreNetwork(e)->isAutoWhoInProgress(nick))) {
+    if (coreNetwork(e)->isAutoWhoInProgress(channel)) {
         e->setFlag(EventManager::Silent);
     }
 }
@@ -1238,8 +1238,7 @@ void CoreSessionEventProcessor::processIrcEvent354(IrcEvent *e)
         return;
 
     QString channel = e->params()[1];
-    QString nick = e->params()[5];
-    IrcUser *ircuser = e->network()->ircUser(nick);
+    IrcUser *ircuser = e->network()->ircUser(e->params()[5]);
     if (ircuser) {
         // Only process the WHO information if an IRC user exists.  Don't create an IRC user here;
         // there's no way to track when the user quits, which would leave a phantom IrcUser lying
@@ -1263,10 +1262,7 @@ void CoreSessionEventProcessor::processIrcEvent354(IrcEvent *e)
     }
 
     // Check if channel name has a who in progress.
-    // If not, then check if user nickname has a who in progress.  Use nick directly; don't use
-    // ircuser as that may be deleted (e.g. nick joins channel, leaves before WHO reply received).
-    if (coreNetwork(e)->isAutoWhoInProgress(channel) ||
-        (coreNetwork(e)->isAutoWhoInProgress(nick))) {
+    if (coreNetwork(e)->isAutoWhoInProgress(channel)) {
         e->setFlag(EventManager::Silent);
     }
 }
@@ -1613,30 +1609,22 @@ void CoreSessionEventProcessor::handleCtcpPing(CtcpEvent *e)
 
 void CoreSessionEventProcessor::handleCtcpTime(CtcpEvent *e)
 {
-    // Explicitly specify the Qt default DateTime format string to allow for modification
-    // Qt::TextDate default roughly corresponds to...
-    // > ddd MMM d yyyy HH:mm:ss
-    //
-    // See https://doc.qt.io/qt-5/qdatetime.html#toString
-    // And https://doc.qt.io/qt-5/qt.html#DateFormat-enum
-#if QT_VERSION > 0x050000
-    // Append the timezone identifier "t", so other other IRC users have a frame of reference for
-    // the current timezone.  This could be figured out before by manually comparing to UTC, so this
-    // is just convenience.
-
-    // Alas, "t" was only added in Qt 5
-    e->setReply(QDateTime::currentDateTime().toString("ddd MMM d yyyy HH:mm:ss t"));
-#else
-    e->setReply(QDateTime::currentDateTime().toString("ddd MMM d yyyy HH:mm:ss"));
-#endif
+    // Use the ISO standard to avoid locale-specific translated names
+    // Include timezone offset data to show which timezone a user's in, otherwise we're providing
+    // NTP-over-IRC with terrible accuracy.
+    e->setReply(formatDateTimeToOffsetISO(QDateTime::currentDateTime()));
 }
 
 
 void CoreSessionEventProcessor::handleCtcpVersion(CtcpEvent *e)
 {
     // Deliberately do not translate project name
+    // Use the ISO standard to avoid locale-specific translated names
+    // Use UTC time to provide a consistent string regardless of timezone
+    // (Statistics tracking tools usually only group client versions by exact string matching)
     e->setReply(QString("Quassel IRC %1 (version date %2) -- https://www.quassel-irc.org")
                 .arg(Quassel::buildInfo().plainVersionString)
                 .arg(Quassel::buildInfo().commitDate.isEmpty() ?
-                      "unknown" : tryFormatUnixEpoch(Quassel::buildInfo().commitDate)));
+                      "unknown" : tryFormatUnixEpoch(Quassel::buildInfo().commitDate,
+                                                     Qt::DateFormat::ISODate, true)));
 }