diff --git a/package-lock.json b/package-lock.json index 3aa58db4..acc7f115 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "http-proxy": "^1.18.1", "log-rotate": "^0.2.8", "validate-color": "^2.2.1", - "xmppjs-chat-bot": "^0.2.2" + "xmppjs-chat-bot": "^0.2.3" }, "devDependencies": { "@peertube/feed": "^5.1.0", @@ -53,49 +53,6 @@ "npm": ">=7" } }, - "../xmppjs-chat-bot": { - "version": "0.2.0", - "extraneous": true, - "funding": [ - "https://paypal.me/JohnXLivingston", - "https://liberapay.com/JohnLivingston/" - ], - "license": "AGPL-3.0", - "dependencies": { - "@xmpp/client": "^0.13.1", - "@xmpp/component": "^0.13.1", - "@xmpp/debug": "^0.13.0", - "@xmpp/jid": "^0.13.1", - "@xmpp/xml": "^0.13.1", - "commander": "^11.0.0" - }, - "bin": { - "xmppjs-chat-bot": "lib/cli/cli.js" - }, - "devDependencies": { - "@tsconfig/node14": "^14.1.0", - "@types/node": "^14.18.0", - "@types/xmpp__client": "^0.13.0", - "@types/xmpp__component": "^0.13.0", - "@types/xmpp__connection": "^0.13.0", - "@types/xmpp__debug": "^0.13.0", - "@types/xmpp__jid": "^1.3.3", - "@types/xmpp__xml": "^0.13.1", - "@typescript-eslint/eslint-plugin": "^4.29.0", - "@typescript-eslint/parser": "^4.29.0", - "eslint": "^7.32.0", - "eslint-config-standard": "^16.0.3", - "eslint-config-standard-with-typescript": "^20.0.0", - "eslint-plugin-import": "^2.25.2", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^5.1.1", - "eslint-plugin-standard": "^5.0.0", - "typescript": "^4.9.5" - }, - "engines": { - "node": ">= 14.4.0" - } - }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", @@ -1223,27 +1180,27 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.9.tgz", - "integrity": "sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.20.tgz", + "integrity": "sha512-BQYjKbpXjoXwFW5jGqiizJQQT/aC7pFm9Ok1OWssonuguICi264lbgMzRp2ZMmRSlfkX6DsWDDcsrctK8Rwfiw==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.22.19", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.19.tgz", - "integrity": "sha512-Q8Yj5X4LHVYTbLCKVz0//2D2aDmHF4xzCdEttYvKOnWvErGsa6geHXD6w46x64n5tP69VfeH+IfSrdyH3MLhwA==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.20.tgz", + "integrity": "sha512-Y6jd1ahLubuYweD/zJH+vvOY141v4f9igNQAQ+MBgq9JlHS2iTsZKn1aMsb3vGccZsXI16VzTBw52Xx0DWmtnA==", "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", "@babel/generator": "^7.22.15", "@babel/helper-compilation-targets": "^7.22.15", - "@babel/helper-module-transforms": "^7.22.19", + "@babel/helper-module-transforms": "^7.22.20", "@babel/helpers": "^7.22.15", "@babel/parser": "^7.22.16", "@babel/template": "^7.22.15", - "@babel/traverse": "^7.22.19", + "@babel/traverse": "^7.22.20", "@babel/types": "^7.22.19", "convert-source-map": "^1.7.0", "debug": "^4.1.0", @@ -1373,9 +1330,9 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "engines": { "node": ">=6.9.0" } @@ -1415,15 +1372,15 @@ } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.22.19", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.19.tgz", - "integrity": "sha512-m6h1cJvn+OJ+R3jOHp30faq5xKJ7VbjwDj5RGgHuRlU9hrMeKsGC+JpihkR5w1g7IfseCPPtZ0r7/hB4UKaYlA==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.20.tgz", + "integrity": "sha512-dLT7JVWIUUxKOs1UnJUBR3S70YK+pKX6AbJgB2vMIvEkZkrfJDbYDJesnPshtKV4LhDOR3Oc5YULeDizRek+5A==", "dependencies": { - "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.20", "@babel/helper-module-imports": "^7.22.15", "@babel/helper-simple-access": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/helper-validator-identifier": "^7.22.19" + "@babel/helper-validator-identifier": "^7.22.20" }, "engines": { "node": ">=6.9.0" @@ -1471,9 +1428,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.19", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.19.tgz", - "integrity": "sha512-Tinq7ybnEPFFXhlYOYFiSjespWQk0dq2dRNAiMdRTOYQzEGqnnNyrTxPYHP5r6wGjlF1rFgABdDV0g8EwD6Qbg==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "engines": { "node": ">=6.9.0" } @@ -1629,13 +1586,13 @@ } }, "node_modules/@babel/traverse": { - "version": "7.22.19", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.19.tgz", - "integrity": "sha512-ZCcpVPK64krfdScRbpxF6xA5fz7IOsfMwx1tcACvCzt6JY+0aHkBk7eIU8FRDSZRU5Zei6Z4JfgAxN1bqXGECg==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.20.tgz", + "integrity": "sha512-eU260mPZbU7mZ0N+X10pxXhQFMGTeLb9eFS0mxehS8HZp9o1uSnFeWQuG1UPrlxgA7QoUzFhOnilHDp0AXCyHw==", "dependencies": { "@babel/code-frame": "^7.22.13", "@babel/generator": "^7.22.15", - "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.20", "@babel/helper-function-name": "^7.22.5", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", @@ -5056,9 +5013,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001534", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001534.tgz", - "integrity": "sha512-vlPVrhsCS7XaSh2VvWluIQEzVhefrUQcEsQWSS5A5V+dM07uv1qHeQzAOTGIMy9i3e9bH15+muvI/UHojVgS/Q==", + "version": "1.0.30001538", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz", + "integrity": "sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw==", "funding": [ { "type": "opencollective", @@ -5801,9 +5758,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.522", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.522.tgz", - "integrity": "sha512-KGKjcafTpOxda0kqwQ72M0tDmX6RsGhUJTy0Hr7slt0+CgHh9Oex8JdjY9Og68dUkTLUlBOJC0A5W5Mw3QSGCg==" + "version": "1.4.523", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.523.tgz", + "integrity": "sha512-9AreocSUWnzNtvLcbpng6N+GkXnCcBR80IQkxRC9Dfdyg4gaWNUPBujAHUpKkiUkoSoR9UlhA4zD/IgBklmhzg==" }, "node_modules/emoji-regex": { "version": "8.0.0", @@ -12069,9 +12026,9 @@ } }, "node_modules/xmppjs-chat-bot": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/xmppjs-chat-bot/-/xmppjs-chat-bot-0.2.2.tgz", - "integrity": "sha512-/t1L2fSW04M/5zEGYQzXqgTa7CVaE1dAT9kO1C5iSOrd4HzksQ6vVsk0PlAbEZere08pbea8Kw8uxBSwGlTiXw==", + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/xmppjs-chat-bot/-/xmppjs-chat-bot-0.2.3.tgz", + "integrity": "sha512-yoCozt3Qezrb/F8UMAYj21FqV5Jzu58x9M6d7eCSD2yNz1O04qkTc5c1oXR288HXpwVQCWcEP6vfH+Ij2AoJAA==", "funding": [ "https://paypal.me/JohnXLivingston", "https://liberapay.com/JohnLivingston/" @@ -13182,24 +13139,24 @@ } }, "@babel/compat-data": { - "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.9.tgz", - "integrity": "sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ==" + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.20.tgz", + "integrity": "sha512-BQYjKbpXjoXwFW5jGqiizJQQT/aC7pFm9Ok1OWssonuguICi264lbgMzRp2ZMmRSlfkX6DsWDDcsrctK8Rwfiw==" }, "@babel/core": { - "version": "7.22.19", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.19.tgz", - "integrity": "sha512-Q8Yj5X4LHVYTbLCKVz0//2D2aDmHF4xzCdEttYvKOnWvErGsa6geHXD6w46x64n5tP69VfeH+IfSrdyH3MLhwA==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.20.tgz", + "integrity": "sha512-Y6jd1ahLubuYweD/zJH+vvOY141v4f9igNQAQ+MBgq9JlHS2iTsZKn1aMsb3vGccZsXI16VzTBw52Xx0DWmtnA==", "requires": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", "@babel/generator": "^7.22.15", "@babel/helper-compilation-targets": "^7.22.15", - "@babel/helper-module-transforms": "^7.22.19", + "@babel/helper-module-transforms": "^7.22.20", "@babel/helpers": "^7.22.15", "@babel/parser": "^7.22.16", "@babel/template": "^7.22.15", - "@babel/traverse": "^7.22.19", + "@babel/traverse": "^7.22.20", "@babel/types": "^7.22.19", "convert-source-map": "^1.7.0", "debug": "^4.1.0", @@ -13294,9 +13251,9 @@ } }, "@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==" + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==" }, "@babel/helper-function-name": { "version": "7.22.5", @@ -13324,15 +13281,15 @@ } }, "@babel/helper-module-transforms": { - "version": "7.22.19", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.19.tgz", - "integrity": "sha512-m6h1cJvn+OJ+R3jOHp30faq5xKJ7VbjwDj5RGgHuRlU9hrMeKsGC+JpihkR5w1g7IfseCPPtZ0r7/hB4UKaYlA==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.20.tgz", + "integrity": "sha512-dLT7JVWIUUxKOs1UnJUBR3S70YK+pKX6AbJgB2vMIvEkZkrfJDbYDJesnPshtKV4LhDOR3Oc5YULeDizRek+5A==", "requires": { - "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.20", "@babel/helper-module-imports": "^7.22.15", "@babel/helper-simple-access": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/helper-validator-identifier": "^7.22.19" + "@babel/helper-validator-identifier": "^7.22.20" } }, "@babel/helper-plugin-utils": { @@ -13362,9 +13319,9 @@ "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==" }, "@babel/helper-validator-identifier": { - "version": "7.22.19", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.19.tgz", - "integrity": "sha512-Tinq7ybnEPFFXhlYOYFiSjespWQk0dq2dRNAiMdRTOYQzEGqnnNyrTxPYHP5r6wGjlF1rFgABdDV0g8EwD6Qbg==" + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==" }, "@babel/helper-validator-option": { "version": "7.22.15", @@ -13470,13 +13427,13 @@ } }, "@babel/traverse": { - "version": "7.22.19", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.19.tgz", - "integrity": "sha512-ZCcpVPK64krfdScRbpxF6xA5fz7IOsfMwx1tcACvCzt6JY+0aHkBk7eIU8FRDSZRU5Zei6Z4JfgAxN1bqXGECg==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.20.tgz", + "integrity": "sha512-eU260mPZbU7mZ0N+X10pxXhQFMGTeLb9eFS0mxehS8HZp9o1uSnFeWQuG1UPrlxgA7QoUzFhOnilHDp0AXCyHw==", "requires": { "@babel/code-frame": "^7.22.13", "@babel/generator": "^7.22.15", - "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.20", "@babel/helper-function-name": "^7.22.5", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", @@ -16118,9 +16075,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001534", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001534.tgz", - "integrity": "sha512-vlPVrhsCS7XaSh2VvWluIQEzVhefrUQcEsQWSS5A5V+dM07uv1qHeQzAOTGIMy9i3e9bH15+muvI/UHojVgS/Q==" + "version": "1.0.30001538", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz", + "integrity": "sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw==" }, "chalk": { "version": "2.4.2", @@ -16686,9 +16643,9 @@ "dev": true }, "electron-to-chromium": { - "version": "1.4.522", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.522.tgz", - "integrity": "sha512-KGKjcafTpOxda0kqwQ72M0tDmX6RsGhUJTy0Hr7slt0+CgHh9Oex8JdjY9Og68dUkTLUlBOJC0A5W5Mw3QSGCg==" + "version": "1.4.523", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.523.tgz", + "integrity": "sha512-9AreocSUWnzNtvLcbpng6N+GkXnCcBR80IQkxRC9Dfdyg4gaWNUPBujAHUpKkiUkoSoR9UlhA4zD/IgBklmhzg==" }, "emoji-regex": { "version": "8.0.0", @@ -21291,9 +21248,9 @@ } }, "xmppjs-chat-bot": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/xmppjs-chat-bot/-/xmppjs-chat-bot-0.2.2.tgz", - "integrity": "sha512-/t1L2fSW04M/5zEGYQzXqgTa7CVaE1dAT9kO1C5iSOrd4HzksQ6vVsk0PlAbEZere08pbea8Kw8uxBSwGlTiXw==", + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/xmppjs-chat-bot/-/xmppjs-chat-bot-0.2.3.tgz", + "integrity": "sha512-yoCozt3Qezrb/F8UMAYj21FqV5Jzu58x9M6d7eCSD2yNz1O04qkTc5c1oXR288HXpwVQCWcEP6vfH+Ij2AoJAA==", "requires": { "@xmpp/client": "^0.13.1", "@xmpp/component": "^0.13.1", diff --git a/package.json b/package.json index 8ca88e53..8f661581 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "http-proxy": "^1.18.1", "log-rotate": "^0.2.8", "validate-color": "^2.2.1", - "xmppjs-chat-bot": "^0.2.2" + "xmppjs-chat-bot": "^0.2.3" }, "devDependencies": { "@peertube/feed": "^5.1.0", diff --git a/prosody-modules/mod_bot_peertubelivechat/README.md b/prosody-modules/mod_bot_peertubelivechat/README.md new file mode 100644 index 00000000..493e848b --- /dev/null +++ b/prosody-modules/mod_bot_peertubelivechat/README.md @@ -0,0 +1,9 @@ +# mod_bot_peertubelivechat + +This module is a custom module for the Peertube livechat plugin, that handle the bot virtualhost. +It provide several functions: + +* bot authentication +* bot vcards (TODO) + +This module is part of peertube-plugin-livechat, and is under the same LICENSE. diff --git a/prosody-modules/mod_bot_peertubelivechat/mod_bot_peertubelivechat.lua b/prosody-modules/mod_bot_peertubelivechat/mod_bot_peertubelivechat.lua new file mode 100644 index 00000000..1cd8a209 --- /dev/null +++ b/prosody-modules/mod_bot_peertubelivechat/mod_bot_peertubelivechat.lua @@ -0,0 +1,99 @@ +-- Prosody IM +-- Copyright (C) 2008-2013 Matthew Wild +-- Copyright (C) 2008-2013 Waqas Hussain +-- Copyright (C) 2014 Kim Alvefur +-- +-- This project is MIT/X11 licensed. Please see the +-- COPYING file in the source package for more information. +-- + +local new_sasl = require "util.sasl".new; +local path = require "util.paths"; +local json = require "util.json"; +-- local have_async, async = pcall(require, "util.async"); + +-- if not have_async then +-- error("Your version of Prosody does not support async and is incompatible"); +-- end + +local host = module.host; +local provider = {}; + +local bot_conf_folder = module:get_option_string('livechat_bot_conf_folder', ''); + +function read_global_conf(filename) + local file = io.open(path.join(bot_conf_folder, filename), "r"); + if file == nil then + module:log("debug", "Cant read global conf file", filename); + return nil; + end + local content = file:read("*all"); + io.close(file); + + local o = json.decode(content); + if (not o) then + module:log("error", "Cant json-decode file", filename); + return nil; + end + if (not o["connection"]) then + return nil; + end + if (not o["connection"]["username"]) then + return nil; + end + if (not o["connection"]["password"]) then + return nil; + end + result = { + username= o["connection"]["username"]; + password= o["connection"]["password"]; + }; + return result; +end + +function provider.test_password(username, password) + -- FIXME: adapt the code for multiple bots + credentials = read_global_conf("moderator.json") + if (credentials and credentials["username"] == username and credentials["password"] == password) then + return true; + end + return false; +end + +function provider.users() + return function() + return nil; + end +end + +function provider.set_password(username, password) + return false; +end + +function provider.user_exists(username) + -- FIXME: adapt the code for multiple bots + credentials = read_global_conf("moderator.json") + if (credentials and credentials["username"] == username) then + return true; + end + return false; +end + +function provider.create_user(username, password) + return false; +end + +function provider.delete_user(username) + return false; +end + +function provider.get_sasl_handler() + return new_sasl(host, { + --luacheck: ignore 212/sasl 212/realm + plain_test = function(sasl, username, password, realm) + return provider.test_password(username, password), true; + end; + }); +end + +module:provides("auth", provider); diff --git a/server/lib/bots/ctl.ts b/server/lib/bots/ctl.ts index 2fc69b3b..f5822a19 100644 --- a/server/lib/bots/ctl.ts +++ b/server/lib/bots/ctl.ts @@ -71,7 +71,8 @@ class BotsCtl { const moderationBotProcess = child_process.spawn('npm', execArgs, { cwd: __dirname, // must be in the livechat plugin tree, so that npm can found the package. env: { - ...process.env // will include NODE_ENV and co + ...process.env, // will include NODE_ENV and co + NODE_TLS_REJECT_UNAUTHORIZED: '0' // Prosody use self-signed certificates, the bot must accept themp } }) moderationBotProcess.stdout?.on('data', (data) => { @@ -114,25 +115,27 @@ class BotsCtl { this.moderationBotProcess as ReturnType let resolved = false - // Trying to kill, and force kill if it takes more than 2 seconds + // Trying to kill, and force kill if it takes more than 1 seconds const timeout = setTimeout(() => { - this.logger.error('Moderation bot was not killed within 2 seconds, force killing') - moderationBotProcess.kill('SIGKILL') + try { + this.logger.error('Moderation bot was not killed within 1 seconds, force killing') + moderationBotProcess.kill('SIGKILL') + } catch (_err) {} resolved = true resolve() - }, 2000) + }, 1000) moderationBotProcess.on('exit', () => { if (resolved) { return } resolved = true - if (timeout) { clearTimeout(timeout) } resolve() + if (timeout) { clearTimeout(timeout) } }) moderationBotProcess.on('close', () => { if (resolved) { return } resolved = true - if (timeout) { clearTimeout(timeout) } resolve() + if (timeout) { clearTimeout(timeout) } }) moderationBotProcess.kill() } catch (err) { diff --git a/server/lib/configuration/bot.ts b/server/lib/configuration/bot.ts index ede246d8..b6d85dcb 100644 --- a/server/lib/configuration/bot.ts +++ b/server/lib/configuration/bot.ts @@ -204,12 +204,14 @@ class BotConfiguration { public configurationPaths (): { moderation: { globalFile: string + globalDir: string roomConfDir: string } } { return { moderation: { globalFile: this.moderationBotGlobalConf, + globalDir: this.confDir, roomConfDir: this.roomConfDir } } diff --git a/server/lib/prosody/config.ts b/server/lib/prosody/config.ts index 040f8b31..cec2ee34 100644 --- a/server/lib/prosody/config.ts +++ b/server/lib/prosody/config.ts @@ -174,8 +174,14 @@ async function getProsodyConfig (options: RegisterServerOptionsV5): Promise=5.0.0, and is a prerequisite to websocket - config.usePeertubeBoshAndWebsocket(prosodyDomain, port, publicServerUrl, useWS) + config.usePeertubeBoshAndWebsocket(prosodyDomain, port, publicServerUrl, useWS, useMultiplexing) config.useMucHttpDefault(roomApiUrl) if (enableC2S) { @@ -294,10 +300,12 @@ async function getProsodyConfig (options: RegisterServerOptionsV5): Promise