summaryrefslogtreecommitdiffstats
path: root/comm/chat/protocols/irc/ircMultiPrefix.sys.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /comm/chat/protocols/irc/ircMultiPrefix.sys.mjs
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/chat/protocols/irc/ircMultiPrefix.sys.mjs')
-rw-r--r--comm/chat/protocols/irc/ircMultiPrefix.sys.mjs60
1 files changed, 60 insertions, 0 deletions
diff --git a/comm/chat/protocols/irc/ircMultiPrefix.sys.mjs b/comm/chat/protocols/irc/ircMultiPrefix.sys.mjs
new file mode 100644
index 0000000000..abf9727981
--- /dev/null
+++ b/comm/chat/protocols/irc/ircMultiPrefix.sys.mjs
@@ -0,0 +1,60 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * This contains an implementation of the multi-prefix IRC extension. This fixes
+ * a protocol level bug where the following can happen:
+ * foo MODE +h
+ * foo MODE +o
+ * bar JOINs the channel (and receives @foo)
+ * foo MODE -o
+ * foo knows that it has mode +h, but bar does not know foo has +h set.
+ *
+ * https://docs.inspircd.org/2/modules/namesx/
+ * https://ircv3.net/specs/extensions/multi-prefix-3.1
+ */
+
+import { ircHandlerPriorities } from "resource:///modules/ircHandlerPriorities.sys.mjs";
+
+export var isupportNAMESX = {
+ name: "ISUPPORT NAMESX",
+ // Slightly above default ISUPPORT priority.
+ priority: ircHandlerPriorities.DEFAULT_PRIORITY + 10,
+ isEnabled: () => true,
+
+ commands: {
+ NAMESX(aMessage) {
+ this.sendMessage("PROTOCTL", "NAMESX");
+ return true;
+ },
+ },
+};
+
+export var capMultiPrefix = {
+ name: "CAP multi-prefix",
+ // Slightly above default ISUPPORT priority.
+ priority: ircHandlerPriorities.HIGH_PRIORITY,
+ isEnabled: () => true,
+
+ commands: {
+ "multi-prefix": function (aMessage) {
+ // Request to use multi-prefix if it is supported.
+ if (
+ aMessage.cap.subcommand === "LS" ||
+ aMessage.cap.subcommand === "NEW"
+ ) {
+ this.addCAP("multi-prefix");
+ this.sendMessage("CAP", ["REQ", "multi-prefix"]);
+ } else if (
+ aMessage.cap.subcommand === "ACK" ||
+ aMessage.cap.subcommand === "NAK"
+ ) {
+ this.removeCAP("multi-prefix");
+ } else {
+ return false;
+ }
+ return true;
+ },
+ },
+};