mirror of
https://github.com/thelounge/thelounge
synced 2024-11-21 19:43:07 +00:00
Run format after updating to prettier 2.0
This commit is contained in:
parent
a46c9e8403
commit
881b3eda19
138 changed files with 584 additions and 631 deletions
|
@ -109,7 +109,7 @@ export default {
|
||||||
|
|
||||||
const inputTrap = Mousetrap(this.$refs.input);
|
const inputTrap = Mousetrap(this.$refs.input);
|
||||||
|
|
||||||
inputTrap.bind(Object.keys(formattingHotkeys), function(e, key) {
|
inputTrap.bind(Object.keys(formattingHotkeys), function (e, key) {
|
||||||
const modifier = formattingHotkeys[key];
|
const modifier = formattingHotkeys[key];
|
||||||
|
|
||||||
wrapCursor(
|
wrapCursor(
|
||||||
|
@ -121,7 +121,7 @@ export default {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
inputTrap.bind(Object.keys(bracketWraps), function(e, key) {
|
inputTrap.bind(Object.keys(bracketWraps), function (e, key) {
|
||||||
if (e.target.selectionStart !== e.target.selectionEnd) {
|
if (e.target.selectionStart !== e.target.selectionEnd) {
|
||||||
wrapCursor(e.target, key, bracketWraps[key]);
|
wrapCursor(e.target, key, bracketWraps[key]);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<span class="content">
|
<span class="content">
|
||||||
<Username :user="message.from" /> 
|
<Username :user="message.from" /> 
|
||||||
<span class="ctcp-message"><ParsedMessage :text="message.ctcpMessage"/></span>
|
<span class="ctcp-message"><ParsedMessage :text="message.ctcpMessage" /></span>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<span class="content">
|
<span class="content">
|
||||||
<Username :user="message.from" />
|
<Username :user="message.from" />
|
||||||
sent a <abbr title="Client-to-client protocol">CTCP</abbr> request:
|
sent a <abbr title="Client-to-client protocol">CTCP</abbr> request:
|
||||||
<span class="ctcp-message"><ParsedMessage :text="message.ctcpMessage"/></span>
|
<span class="ctcp-message"><ParsedMessage :text="message.ctcpMessage" /></span>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<span class="content">
|
<span class="content">
|
||||||
<span class="text"><ParsedMessage :network="network" :text="cleanText"/></span>
|
<span class="text"><ParsedMessage :network="network" :text="cleanText" /></span>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
:is-join-channel-shown="network.isJoinChannelShown"
|
:is-join-channel-shown="network.isJoinChannelShown"
|
||||||
:active="
|
:active="
|
||||||
$store.state.activeChannel &&
|
$store.state.activeChannel &&
|
||||||
network.channels[0] === $store.state.activeChannel.channel
|
network.channels[0] === $store.state.activeChannel.channel
|
||||||
"
|
"
|
||||||
@toggleJoinChannel="network.isJoinChannelShown = !network.isJoinChannelShown"
|
@toggleJoinChannel="network.isJoinChannelShown = !network.isJoinChannelShown"
|
||||||
/>
|
/>
|
||||||
|
@ -114,7 +114,7 @@
|
||||||
:network="network"
|
:network="network"
|
||||||
:active="
|
:active="
|
||||||
$store.state.activeChannel &&
|
$store.state.activeChannel &&
|
||||||
channel === $store.state.activeChannel.channel
|
channel === $store.state.activeChannel.channel
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</Draggable>
|
</Draggable>
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
<template
|
<template
|
||||||
v-if="
|
v-if="
|
||||||
$store.state.versionData &&
|
$store.state.versionData &&
|
||||||
$store.state.versionData.current &&
|
$store.state.versionData.current &&
|
||||||
$store.state.versionData.current.version
|
$store.state.versionData.current.version
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<h1 class="title">
|
<h1 class="title">
|
||||||
|
@ -29,9 +29,7 @@
|
||||||
<p>Unable to retrieve changelog for current release from GitHub.</p>
|
<p>Unable to retrieve changelog for current release from GitHub.</p>
|
||||||
<p>
|
<p>
|
||||||
<a
|
<a
|
||||||
:href="
|
:href="`https://github.com/thelounge/thelounge/releases/tag/v${$store.state.serverConfiguration.version}`"
|
||||||
`https://github.com/thelounge/thelounge/releases/tag/v${$store.state.serverConfiguration.version}`
|
|
||||||
"
|
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
>View release notes for this version on GitHub</a
|
>View release notes for this version on GitHub</a
|
||||||
|
|
|
@ -23,9 +23,7 @@
|
||||||
<template v-if="$store.state.serverConfiguration.gitCommit">
|
<template v-if="$store.state.serverConfiguration.gitCommit">
|
||||||
<p>
|
<p>
|
||||||
The Lounge is running from source (<a
|
The Lounge is running from source (<a
|
||||||
:href="
|
:href="`https://github.com/thelounge/thelounge/tree/${$store.state.serverConfiguration.gitCommit}`"
|
||||||
`https://github.com/thelounge/thelounge/tree/${$store.state.serverConfiguration.gitCommit}`
|
|
||||||
"
|
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
>commit <code>{{ $store.state.serverConfiguration.gitCommit }}</code></a
|
>commit <code>{{ $store.state.serverConfiguration.gitCommit }}</code></a
|
||||||
|
@ -36,9 +34,7 @@
|
||||||
<li>
|
<li>
|
||||||
Compare
|
Compare
|
||||||
<a
|
<a
|
||||||
:href="
|
:href="`https://github.com/thelounge/thelounge/compare/${$store.state.serverConfiguration.gitCommit}...master`"
|
||||||
`https://github.com/thelounge/thelounge/compare/${$store.state.serverConfiguration.gitCommit}...master`
|
|
||||||
"
|
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
>between
|
>between
|
||||||
|
@ -50,9 +46,7 @@
|
||||||
<li>
|
<li>
|
||||||
Compare
|
Compare
|
||||||
<a
|
<a
|
||||||
:href="
|
:href="`https://github.com/thelounge/thelounge/compare/${$store.state.serverConfiguration.version}...${$store.state.serverConfiguration.gitCommit}`"
|
||||||
`https://github.com/thelounge/thelounge/compare/${$store.state.serverConfiguration.version}...${$store.state.serverConfiguration.gitCommit}`
|
|
||||||
"
|
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
>between
|
>between
|
||||||
|
|
|
@ -238,7 +238,7 @@
|
||||||
class="btn"
|
class="btn"
|
||||||
:disabled="
|
:disabled="
|
||||||
$store.state.pushNotificationState !== 'supported' &&
|
$store.state.pushNotificationState !== 'supported' &&
|
||||||
$store.state.pushNotificationState !== 'subscribed'
|
$store.state.pushNotificationState !== 'subscribed'
|
||||||
"
|
"
|
||||||
@click="onPushButtonClick"
|
@click="onPushButtonClick"
|
||||||
>
|
>
|
||||||
|
@ -345,7 +345,7 @@
|
||||||
<div
|
<div
|
||||||
v-if="
|
v-if="
|
||||||
!$store.state.serverConfiguration.public &&
|
!$store.state.serverConfiguration.public &&
|
||||||
!$store.state.serverConfiguration.ldapEnabled
|
!$store.state.serverConfiguration.ldapEnabled
|
||||||
"
|
"
|
||||||
id="change-password"
|
id="change-password"
|
||||||
role="group"
|
role="group"
|
||||||
|
|
|
@ -177,10 +177,7 @@ function enableAutocomplete(input) {
|
||||||
const text = input.value;
|
const text = input.value;
|
||||||
|
|
||||||
if (tabCount === 0) {
|
if (tabCount === 0) {
|
||||||
lastMatch = text
|
lastMatch = text.substring(0, input.selectionStart).split(/\s/).pop();
|
||||||
.substring(0, input.selectionStart)
|
|
||||||
.split(/\s/)
|
|
||||||
.pop();
|
|
||||||
|
|
||||||
if (lastMatch.length === 0) {
|
if (lastMatch.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
export default function(chat) {
|
export default function (chat) {
|
||||||
// Disable in Firefox as it already copies flex text correctly
|
// Disable in Firefox as it already copies flex text correctly
|
||||||
if (typeof window.InstallTrigger !== "undefined") {
|
if (typeof window.InstallTrigger !== "undefined") {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -18,9 +18,7 @@ LinkifyIt.prototype.normalize = function normalize(match) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const linkify = LinkifyIt()
|
const linkify = LinkifyIt().tlds(require("tlds")).tlds("onion", true);
|
||||||
.tlds(require("tlds"))
|
|
||||||
.tlds("onion", true);
|
|
||||||
|
|
||||||
// Known schemes to detect in text
|
// Known schemes to detect in text
|
||||||
const commonSchemes = [
|
const commonSchemes = [
|
||||||
|
|
|
@ -85,10 +85,7 @@ function parse(createElement, text, message = undefined, network = undefined) {
|
||||||
const emojiParts = findEmoji(cleanText);
|
const emojiParts = findEmoji(cleanText);
|
||||||
const nameParts = findNames(cleanText, message ? message.users || [] : []);
|
const nameParts = findNames(cleanText, message ? message.users || [] : []);
|
||||||
|
|
||||||
const parts = channelParts
|
const parts = channelParts.concat(linkParts).concat(emojiParts).concat(nameParts);
|
||||||
.concat(linkParts)
|
|
||||||
.concat(emojiParts)
|
|
||||||
.concat(nameParts);
|
|
||||||
|
|
||||||
// Merge the styling information with the channels / URLs / nicks / text objects and
|
// Merge the styling information with the channels / URLs / nicks / text objects and
|
||||||
// generate HTML strings with the resulting fragments
|
// generate HTML strings with the resulting fragments
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {switchToChannel} from "./router";
|
||||||
import isChannelCollapsed from "./helpers/isChannelCollapsed";
|
import isChannelCollapsed from "./helpers/isChannelCollapsed";
|
||||||
|
|
||||||
// Switch to the next/previous window in the channel list.
|
// Switch to the next/previous window in the channel list.
|
||||||
Mousetrap.bind(["alt+up", "alt+down"], function(e, keys) {
|
Mousetrap.bind(["alt+up", "alt+down"], function (e, keys) {
|
||||||
if (store.state.networks.length === 0) {
|
if (store.state.networks.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ Mousetrap.bind(["alt+up", "alt+down"], function(e, keys) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Switch to the next/previous lobby in the channel list
|
// Switch to the next/previous lobby in the channel list
|
||||||
Mousetrap.bind(["alt+shift+up", "alt+shift+down"], function(e, keys) {
|
Mousetrap.bind(["alt+shift+up", "alt+shift+down"], function (e, keys) {
|
||||||
const length = store.state.networks.length;
|
const length = store.state.networks.length;
|
||||||
|
|
||||||
if (length === 0) {
|
if (length === 0) {
|
||||||
|
@ -71,7 +71,7 @@ Mousetrap.bind(["alt+shift+up", "alt+shift+down"], function(e, keys) {
|
||||||
|
|
||||||
// Jump to the first window with a highlight in it, or the first with unread
|
// Jump to the first window with a highlight in it, or the first with unread
|
||||||
// activity if there are none with highlights.
|
// activity if there are none with highlights.
|
||||||
Mousetrap.bind(["alt+a"], function(e) {
|
Mousetrap.bind(["alt+a"], function (e) {
|
||||||
// Do not handle this keybind in the chat input because
|
// Do not handle this keybind in the chat input because
|
||||||
// it can be used to type letters with umlauts
|
// it can be used to type letters with umlauts
|
||||||
// Normally this is not required, but since chat input has the "mousetrap"
|
// Normally this is not required, but since chat input has the "mousetrap"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* so that the timeout can be triggered while slow JS is loading
|
* so that the timeout can be triggered while slow JS is loading
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function () {
|
||||||
const msg = document.getElementById("loading-page-message");
|
const msg = document.getElementById("loading-page-message");
|
||||||
msg.textContent = "Loading the app…";
|
msg.textContent = "Loading the app…";
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ import store from "../store";
|
||||||
import location from "../location";
|
import location from "../location";
|
||||||
let lastServerHash = null;
|
let lastServerHash = null;
|
||||||
|
|
||||||
socket.on("auth:success", function() {
|
socket.on("auth:success", function () {
|
||||||
store.commit("currentUserVisibleError", "Loading messages…");
|
store.commit("currentUserVisibleError", "Loading messages…");
|
||||||
updateLoadingMessage();
|
updateLoadingMessage();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("auth:failed", function() {
|
socket.on("auth:failed", function () {
|
||||||
storage.remove("token");
|
storage.remove("token");
|
||||||
|
|
||||||
if (store.state.appLoaded) {
|
if (store.state.appLoaded) {
|
||||||
|
@ -22,7 +22,7 @@ socket.on("auth:failed", function() {
|
||||||
showSignIn();
|
showSignIn();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("auth:start", function(serverHash) {
|
socket.on("auth:start", function (serverHash) {
|
||||||
// If we reconnected and serverHash differs, that means the server restarted
|
// If we reconnected and serverHash differs, that means the server restarted
|
||||||
// And we will reload the page to grab the latest version
|
// And we will reload the page to grab the latest version
|
||||||
if (lastServerHash && serverHash !== lastServerHash) {
|
if (lastServerHash && serverHash !== lastServerHash) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("changelog", function(data) {
|
socket.on("changelog", function (data) {
|
||||||
store.commit("versionData", data);
|
store.commit("versionData", data);
|
||||||
store.commit("versionDataExpired", false);
|
store.commit("versionDataExpired", false);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const constants = require("../constants");
|
const constants = require("../constants");
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
|
|
||||||
socket.on("commands", function(commands) {
|
socket.on("commands", function (commands) {
|
||||||
if (commands) {
|
if (commands) {
|
||||||
constants.commands = commands;
|
constants.commands = commands;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import socket from "../socket";
|
||||||
import upload from "../upload";
|
import upload from "../upload";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.once("configuration", function(data) {
|
socket.once("configuration", function (data) {
|
||||||
store.commit("serverConfiguration", data);
|
store.commit("serverConfiguration", data);
|
||||||
|
|
||||||
// 'theme' setting depends on serverConfiguration.themes so
|
// 'theme' setting depends on serverConfiguration.themes so
|
||||||
|
|
|
@ -5,17 +5,17 @@ socket.on("disconnect", handleDisconnect);
|
||||||
socket.on("connect_error", handleDisconnect);
|
socket.on("connect_error", handleDisconnect);
|
||||||
socket.on("error", handleDisconnect);
|
socket.on("error", handleDisconnect);
|
||||||
|
|
||||||
socket.on("reconnecting", function(attempt) {
|
socket.on("reconnecting", function (attempt) {
|
||||||
store.commit("currentUserVisibleError", `Reconnecting… (attempt ${attempt})`);
|
store.commit("currentUserVisibleError", `Reconnecting… (attempt ${attempt})`);
|
||||||
updateLoadingMessage();
|
updateLoadingMessage();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("connecting", function() {
|
socket.on("connecting", function () {
|
||||||
store.commit("currentUserVisibleError", "Connecting…");
|
store.commit("currentUserVisibleError", "Connecting…");
|
||||||
updateLoadingMessage();
|
updateLoadingMessage();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("connect", function() {
|
socket.on("connect", function () {
|
||||||
// Clear send buffer when reconnecting, socket.io would emit these
|
// Clear send buffer when reconnecting, socket.io would emit these
|
||||||
// immediately upon connection and it will have no effect, so we ensure
|
// immediately upon connection and it will have no effect, so we ensure
|
||||||
// nothing is sent to the server that might have happened.
|
// nothing is sent to the server that might have happened.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("history:clear", function(data) {
|
socket.on("history:clear", function (data) {
|
||||||
const {channel} = store.getters.findChannel(data.target);
|
const {channel} = store.getters.findChannel(data.target);
|
||||||
|
|
||||||
channel.messages = [];
|
channel.messages = [];
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {router, switchToChannel, navigate, initialize as routerInitialize} from
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
import parseIrcUri from "../helpers/parseIrcUri";
|
import parseIrcUri from "../helpers/parseIrcUri";
|
||||||
|
|
||||||
socket.on("init", function(data) {
|
socket.on("init", function (data) {
|
||||||
store.commit("networks", mergeNetworkData(data.networks));
|
store.commit("networks", mergeNetworkData(data.networks));
|
||||||
store.commit("isConnected", true);
|
store.commit("isConnected", true);
|
||||||
store.commit("currentUserVisibleError", null);
|
store.commit("currentUserVisibleError", null);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
import {switchToChannel} from "../router";
|
import {switchToChannel} from "../router";
|
||||||
|
|
||||||
socket.on("join", function(data) {
|
socket.on("join", function (data) {
|
||||||
store.getters.initChannel(data.chan);
|
store.getters.initChannel(data.chan);
|
||||||
|
|
||||||
const network = store.getters.findNetwork(data.network);
|
const network = store.getters.findNetwork(data.network);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Vue from "vue";
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("more", function(data) {
|
socket.on("more", function (data) {
|
||||||
const channel = store.getters.findChannel(data.chan);
|
const channel = store.getters.findChannel(data.chan);
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ try {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on("msg", function(data) {
|
socket.on("msg", function (data) {
|
||||||
const receivingChannel = store.getters.findChannel(data.chan);
|
const receivingChannel = store.getters.findChannel(data.chan);
|
||||||
|
|
||||||
if (!receivingChannel) {
|
if (!receivingChannel) {
|
||||||
|
@ -155,7 +155,7 @@ function notifyMessage(targetId, channel, activeChannel, msg) {
|
||||||
body: body,
|
body: body,
|
||||||
timestamp: timestamp,
|
timestamp: timestamp,
|
||||||
});
|
});
|
||||||
notify.addEventListener("click", function() {
|
notify.addEventListener("click", function () {
|
||||||
this.close();
|
this.close();
|
||||||
window.focus();
|
window.focus();
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Vue from "vue";
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("msg:preview", function(data) {
|
socket.on("msg:preview", function (data) {
|
||||||
const {channel} = store.getters.findChannel(data.chan);
|
const {channel} = store.getters.findChannel(data.chan);
|
||||||
const message = channel.messages.find((m) => m.id === data.id);
|
const message = channel.messages.find((m) => m.id === data.id);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
import {switchToChannel} from "../router";
|
import {switchToChannel} from "../router";
|
||||||
|
|
||||||
socket.on("msg:special", function(data) {
|
socket.on("msg:special", function (data) {
|
||||||
const channel = store.getters.findChannel(data.chan);
|
const channel = store.getters.findChannel(data.chan);
|
||||||
channel.channel.data = data.data;
|
channel.channel.data = data.data;
|
||||||
switchToChannel(channel.channel);
|
switchToChannel(channel.channel);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("names", function(data) {
|
socket.on("names", function (data) {
|
||||||
const channel = store.getters.findChannel(data.id);
|
const channel = store.getters.findChannel(data.id);
|
||||||
|
|
||||||
if (channel) {
|
if (channel) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
import {switchToChannel} from "../router";
|
import {switchToChannel} from "../router";
|
||||||
|
|
||||||
socket.on("network", function(data) {
|
socket.on("network", function (data) {
|
||||||
const network = data.networks[0];
|
const network = data.networks[0];
|
||||||
|
|
||||||
network.isJoinChannelShown = false;
|
network.isJoinChannelShown = false;
|
||||||
|
@ -19,7 +19,7 @@ socket.on("network", function(data) {
|
||||||
switchToChannel(network.channels[network.channels.length - 1]);
|
switchToChannel(network.channels[network.channels.length - 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("network:options", function(data) {
|
socket.on("network:options", function (data) {
|
||||||
const network = store.getters.findNetwork(data.network);
|
const network = store.getters.findNetwork(data.network);
|
||||||
|
|
||||||
if (network) {
|
if (network) {
|
||||||
|
@ -27,7 +27,7 @@ socket.on("network:options", function(data) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("network:status", function(data) {
|
socket.on("network:status", function (data) {
|
||||||
const network = store.getters.findNetwork(data.network);
|
const network = store.getters.findNetwork(data.network);
|
||||||
|
|
||||||
if (!network) {
|
if (!network) {
|
||||||
|
@ -45,7 +45,7 @@ socket.on("network:status", function(data) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("channel:state", function(data) {
|
socket.on("channel:state", function (data) {
|
||||||
const channel = store.getters.findChannel(data.chan);
|
const channel = store.getters.findChannel(data.chan);
|
||||||
|
|
||||||
if (channel) {
|
if (channel) {
|
||||||
|
@ -53,7 +53,7 @@ socket.on("channel:state", function(data) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("network:info", function(data) {
|
socket.on("network:info", function (data) {
|
||||||
const network = store.getters.findNetwork(data.uuid);
|
const network = store.getters.findNetwork(data.uuid);
|
||||||
|
|
||||||
if (!network) {
|
if (!network) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("nick", function(data) {
|
socket.on("nick", function (data) {
|
||||||
const network = store.getters.findNetwork(data.network);
|
const network = store.getters.findNetwork(data.network);
|
||||||
|
|
||||||
if (network) {
|
if (network) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
// Sync unread badge and marker when other clients open a channel
|
// Sync unread badge and marker when other clients open a channel
|
||||||
socket.on("open", function(id) {
|
socket.on("open", function (id) {
|
||||||
if (id < 1) {
|
if (id < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
import {switchToChannel} from "../router";
|
import {switchToChannel} from "../router";
|
||||||
|
|
||||||
socket.on("part", function(data) {
|
socket.on("part", function (data) {
|
||||||
// When parting from the active channel/query, jump to the network's lobby
|
// When parting from the active channel/query, jump to the network's lobby
|
||||||
if (store.state.activeChannel && store.state.activeChannel.channel.id === data.chan) {
|
if (store.state.activeChannel && store.state.activeChannel.channel.id === data.chan) {
|
||||||
switchToChannel(store.state.activeChannel.network.channels[0]);
|
switchToChannel(store.state.activeChannel.network.channels[0]);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import socket from "../socket";
|
||||||
import {switchToChannel, navigate} from "../router";
|
import {switchToChannel, navigate} from "../router";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("quit", function(data) {
|
socket.on("quit", function (data) {
|
||||||
// If we're in a channel, and it's on the network that is being removed,
|
// If we're in a channel, and it's on the network that is being removed,
|
||||||
// then open another channel window
|
// then open another channel window
|
||||||
const isCurrentNetworkBeingRemoved =
|
const isCurrentNetworkBeingRemoved =
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("sessions:list", function(data) {
|
socket.on("sessions:list", function (data) {
|
||||||
data.sort((a, b) => b.lastUse - a.lastUse);
|
data.sort((a, b) => b.lastUse - a.lastUse);
|
||||||
store.commit("sessions", data);
|
store.commit("sessions", data);
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("setting:new", function(data) {
|
socket.on("setting:new", function (data) {
|
||||||
const name = data.name;
|
const name = data.name;
|
||||||
const value = data.value;
|
const value = data.value;
|
||||||
store.dispatch("settings/update", {name, value, sync: false});
|
store.dispatch("settings/update", {name, value, sync: false});
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("setting:all", function(settings) {
|
socket.on("setting:all", function (settings) {
|
||||||
const serverHasSettings = Object.keys(settings).length > 0;
|
const serverHasSettings = Object.keys(settings).length > 0;
|
||||||
|
|
||||||
store.commit("serverHasSettings", serverHasSettings);
|
store.commit("serverHasSettings", serverHasSettings);
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import Auth from "../auth";
|
import Auth from "../auth";
|
||||||
|
|
||||||
socket.on("sign-out", function() {
|
socket.on("sign-out", function () {
|
||||||
Auth.signout();
|
Auth.signout();
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("sync_sort", function(data) {
|
socket.on("sync_sort", function (data) {
|
||||||
const order = data.order;
|
const order = data.order;
|
||||||
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("topic", function(data) {
|
socket.on("topic", function (data) {
|
||||||
const channel = store.getters.findChannel(data.chan);
|
const channel = store.getters.findChannel(data.chan);
|
||||||
|
|
||||||
if (channel) {
|
if (channel) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("users", function(data) {
|
socket.on("users", function (data) {
|
||||||
if (store.state.activeChannel && store.state.activeChannel.channel.id === data.chan) {
|
if (store.state.activeChannel && store.state.activeChannel.channel.id === data.chan) {
|
||||||
return socket.emit("names", {
|
return socket.emit("names", {
|
||||||
target: data.chan,
|
target: data.chan,
|
||||||
|
|
|
@ -103,7 +103,7 @@ store.watch(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Vue.config.errorHandler = function(e) {
|
Vue.config.errorHandler = function (e) {
|
||||||
store.commit("currentUserVisibleError", `Vue error: ${e.message}`);
|
store.commit("currentUserVisibleError", `Vue error: ${e.message}`);
|
||||||
console.error(e); // eslint-disable-line
|
console.error(e); // eslint-disable-line
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ import store from "./store";
|
||||||
|
|
||||||
export default {togglePushSubscription};
|
export default {togglePushSubscription};
|
||||||
|
|
||||||
socket.once("push:issubscribed", function(hasSubscriptionOnServer) {
|
socket.once("push:issubscribed", function (hasSubscriptionOnServer) {
|
||||||
if (!isAllowedServiceWorkersHost()) {
|
if (!isAllowedServiceWorkersHost()) {
|
||||||
store.commit("pushNotificationState", "nohttps");
|
store.commit("pushNotificationState", "nohttps");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
const cacheName = "__HASH__";
|
const cacheName = "__HASH__";
|
||||||
const excludedPathsFromCache = /^(?:socket\.io|storage|uploads|cdn-cgi)\//;
|
const excludedPathsFromCache = /^(?:socket\.io|storage|uploads|cdn-cgi)\//;
|
||||||
|
|
||||||
self.addEventListener("install", function() {
|
self.addEventListener("install", function () {
|
||||||
self.skipWaiting();
|
self.skipWaiting();
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener("activate", function(event) {
|
self.addEventListener("activate", function (event) {
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches
|
caches
|
||||||
.keys()
|
.keys()
|
||||||
|
@ -23,7 +23,7 @@ self.addEventListener("activate", function(event) {
|
||||||
event.waitUntil(self.clients.claim());
|
event.waitUntil(self.clients.claim());
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener("fetch", function(event) {
|
self.addEventListener("fetch", function (event) {
|
||||||
if (event.request.method !== "GET") {
|
if (event.request.method !== "GET") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -108,11 +108,11 @@ async function networkOrCache(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.addEventListener("message", function(event) {
|
self.addEventListener("message", function (event) {
|
||||||
showNotification(event, event.data);
|
showNotification(event, event.data);
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener("push", function(event) {
|
self.addEventListener("push", function (event) {
|
||||||
if (!event.data) {
|
if (!event.data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ function showNotification(event, payload) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.addEventListener("notificationclick", function(event) {
|
self.addEventListener("notificationclick", function (event) {
|
||||||
event.notification.close();
|
event.notification.close();
|
||||||
|
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
|
|
|
@ -66,10 +66,7 @@ const changelogPath = path.resolve(__dirname, "..", "CHANGELOG.md");
|
||||||
|
|
||||||
if (token === undefined) {
|
if (token === undefined) {
|
||||||
try {
|
try {
|
||||||
token = fs
|
token = fs.readFileSync(path.resolve(__dirname, "./github_token.txt")).toString().trim();
|
||||||
.readFileSync(path.resolve(__dirname, "./github_token.txt"))
|
|
||||||
.toString()
|
|
||||||
.trim();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error(`Environment variable ${colors.bold("CHANGELOG_TOKEN")} must be set.`);
|
log.error(`Environment variable ${colors.bold("CHANGELOG_TOKEN")} must be set.`);
|
||||||
log.error(`Alternative create ${colors.bold("scripts/github_token.txt")} file.`);
|
log.error(`Alternative create ${colors.bold("scripts/github_token.txt")} file.`);
|
||||||
|
|
|
@ -63,8 +63,5 @@ log.info(
|
||||||
);
|
);
|
||||||
|
|
||||||
function getPrettyDate() {
|
function getPrettyDate() {
|
||||||
return new Date()
|
return new Date().toISOString().split(".")[0].replace("T", " ");
|
||||||
.toISOString()
|
|
||||||
.split(".")[0]
|
|
||||||
.replace("T", " ");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
module.exports = function() {
|
module.exports = function () {
|
||||||
return function() {};
|
return function () {};
|
||||||
};
|
};
|
||||||
|
|
|
@ -138,20 +138,20 @@ function Client(manager, name, config = {}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Client.prototype.createChannel = function(attr) {
|
Client.prototype.createChannel = function (attr) {
|
||||||
const chan = new Chan(attr);
|
const chan = new Chan(attr);
|
||||||
chan.id = this.idChan++;
|
chan.id = this.idChan++;
|
||||||
|
|
||||||
return chan;
|
return chan;
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.emit = function(event, data) {
|
Client.prototype.emit = function (event, data) {
|
||||||
if (this.manager !== null) {
|
if (this.manager !== null) {
|
||||||
this.manager.sockets.in(this.id).emit(event, data);
|
this.manager.sockets.in(this.id).emit(event, data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.find = function(channelId) {
|
Client.prototype.find = function (channelId) {
|
||||||
let network = null;
|
let network = null;
|
||||||
let chan = null;
|
let chan = null;
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ Client.prototype.find = function(channelId) {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.connect = function(args, isStartup = false) {
|
Client.prototype.connect = function (args, isStartup = false) {
|
||||||
const client = this;
|
const client = this;
|
||||||
let channels = [];
|
let channels = [];
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ Client.prototype.connect = function(args, isStartup = false) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.generateToken = function(callback) {
|
Client.prototype.generateToken = function (callback) {
|
||||||
crypto.randomBytes(64, (err, buf) => {
|
crypto.randomBytes(64, (err, buf) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -289,14 +289,11 @@ Client.prototype.generateToken = function(callback) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.calculateTokenHash = function(token) {
|
Client.prototype.calculateTokenHash = function (token) {
|
||||||
return crypto
|
return crypto.createHash("sha512").update(token).digest("hex");
|
||||||
.createHash("sha512")
|
|
||||||
.update(token)
|
|
||||||
.digest("hex");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.updateSession = function(token, ip, request) {
|
Client.prototype.updateSession = function (token, ip, request) {
|
||||||
const client = this;
|
const client = this;
|
||||||
const agent = UAParser(request.headers["user-agent"] || "");
|
const agent = UAParser(request.headers["user-agent"] || "");
|
||||||
let friendlyAgent = "";
|
let friendlyAgent = "";
|
||||||
|
@ -324,12 +321,12 @@ Client.prototype.updateSession = function(token, ip, request) {
|
||||||
client.save();
|
client.save();
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.setPassword = function(hash, callback) {
|
Client.prototype.setPassword = function (hash, callback) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
const oldHash = client.config.password;
|
const oldHash = client.config.password;
|
||||||
client.config.password = hash;
|
client.config.password = hash;
|
||||||
client.manager.saveUser(client, function(err) {
|
client.manager.saveUser(client, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// If user file fails to write, reset it back
|
// If user file fails to write, reset it back
|
||||||
client.config.password = oldHash;
|
client.config.password = oldHash;
|
||||||
|
@ -340,7 +337,7 @@ Client.prototype.setPassword = function(hash, callback) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.input = function(data) {
|
Client.prototype.input = function (data) {
|
||||||
const client = this;
|
const client = this;
|
||||||
data.text.split("\n").forEach((line) => {
|
data.text.split("\n").forEach((line) => {
|
||||||
data.text = line;
|
data.text = line;
|
||||||
|
@ -348,7 +345,7 @@ Client.prototype.input = function(data) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.inputLine = function(data) {
|
Client.prototype.inputLine = function (data) {
|
||||||
const client = this;
|
const client = this;
|
||||||
const target = client.find(data.target);
|
const target = client.find(data.target);
|
||||||
|
|
||||||
|
@ -420,7 +417,7 @@ Client.prototype.inputLine = function(data) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.compileCustomHighlights = function() {
|
Client.prototype.compileCustomHighlights = function () {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
if (typeof client.config.clientSettings.highlights !== "string") {
|
if (typeof client.config.clientSettings.highlights !== "string") {
|
||||||
|
@ -446,7 +443,7 @@ Client.prototype.compileCustomHighlights = function() {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.more = function(data) {
|
Client.prototype.more = function (data) {
|
||||||
const client = this;
|
const client = this;
|
||||||
const target = client.find(data.target);
|
const target = client.find(data.target);
|
||||||
|
|
||||||
|
@ -501,7 +498,7 @@ Client.prototype.more = function(data) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.clearHistory = function(data) {
|
Client.prototype.clearHistory = function (data) {
|
||||||
const client = this;
|
const client = this;
|
||||||
const target = client.find(data.target);
|
const target = client.find(data.target);
|
||||||
|
|
||||||
|
@ -527,7 +524,7 @@ Client.prototype.clearHistory = function(data) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.open = function(socketId, target) {
|
Client.prototype.open = function (socketId, target) {
|
||||||
// Due to how socket.io works internally, normal events may arrive later than
|
// Due to how socket.io works internally, normal events may arrive later than
|
||||||
// the disconnect event, and because we can't control this timing precisely,
|
// the disconnect event, and because we can't control this timing precisely,
|
||||||
// process this event normally even if there is no attached client anymore.
|
// process this event normally even if there is no attached client anymore.
|
||||||
|
@ -558,7 +555,7 @@ Client.prototype.open = function(socketId, target) {
|
||||||
this.emit("open", target.chan.id);
|
this.emit("open", target.chan.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.sort = function(data) {
|
Client.prototype.sort = function (data) {
|
||||||
const order = data.order;
|
const order = data.order;
|
||||||
|
|
||||||
if (!_.isArray(order)) {
|
if (!_.isArray(order)) {
|
||||||
|
@ -610,7 +607,7 @@ Client.prototype.sort = function(data) {
|
||||||
this.save();
|
this.save();
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.names = function(data) {
|
Client.prototype.names = function (data) {
|
||||||
const client = this;
|
const client = this;
|
||||||
const target = client.find(data.target);
|
const target = client.find(data.target);
|
||||||
|
|
||||||
|
@ -624,7 +621,7 @@ Client.prototype.names = function(data) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.quit = function(signOut) {
|
Client.prototype.quit = function (signOut) {
|
||||||
const sockets = this.manager.sockets.sockets;
|
const sockets = this.manager.sockets.sockets;
|
||||||
const room = sockets.adapter.rooms[this.id];
|
const room = sockets.adapter.rooms[this.id];
|
||||||
|
|
||||||
|
@ -652,11 +649,11 @@ Client.prototype.quit = function(signOut) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.clientAttach = function(socketId, token) {
|
Client.prototype.clientAttach = function (socketId, token) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
if (client.awayMessage && _.size(client.attachedClients) === 0) {
|
if (client.awayMessage && _.size(client.attachedClients) === 0) {
|
||||||
client.networks.forEach(function(network) {
|
client.networks.forEach(function (network) {
|
||||||
// Only remove away on client attachment if
|
// Only remove away on client attachment if
|
||||||
// there is no away message on this network
|
// there is no away message on this network
|
||||||
if (network.irc && !network.awayMessage) {
|
if (network.irc && !network.awayMessage) {
|
||||||
|
@ -669,13 +666,13 @@ Client.prototype.clientAttach = function(socketId, token) {
|
||||||
client.attachedClients[socketId] = {token, openChannel};
|
client.attachedClients[socketId] = {token, openChannel};
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.clientDetach = function(socketId) {
|
Client.prototype.clientDetach = function (socketId) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
delete this.attachedClients[socketId];
|
delete this.attachedClients[socketId];
|
||||||
|
|
||||||
if (client.awayMessage && _.size(client.attachedClients) === 0) {
|
if (client.awayMessage && _.size(client.attachedClients) === 0) {
|
||||||
client.networks.forEach(function(network) {
|
client.networks.forEach(function (network) {
|
||||||
// Only set away on client deattachment if
|
// Only set away on client deattachment if
|
||||||
// there is no away message on this network
|
// there is no away message on this network
|
||||||
if (network.irc && !network.awayMessage) {
|
if (network.irc && !network.awayMessage) {
|
||||||
|
@ -685,7 +682,7 @@ Client.prototype.clientDetach = function(socketId) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.registerPushSubscription = function(session, subscription, noSave) {
|
Client.prototype.registerPushSubscription = function (session, subscription, noSave) {
|
||||||
if (
|
if (
|
||||||
!_.isPlainObject(subscription) ||
|
!_.isPlainObject(subscription) ||
|
||||||
!_.isPlainObject(subscription.keys) ||
|
!_.isPlainObject(subscription.keys) ||
|
||||||
|
@ -715,7 +712,7 @@ Client.prototype.registerPushSubscription = function(session, subscription, noSa
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.unregisterPushSubscription = function(token) {
|
Client.prototype.unregisterPushSubscription = function (token) {
|
||||||
this.config.sessions[token].pushSubscription = null;
|
this.config.sessions[token].pushSubscription = null;
|
||||||
this.save();
|
this.save();
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,7 @@ function ClientManager() {
|
||||||
this.clients = [];
|
this.clients = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientManager.prototype.init = function(identHandler, sockets) {
|
ClientManager.prototype.init = function (identHandler, sockets) {
|
||||||
this.sockets = sockets;
|
this.sockets = sockets;
|
||||||
this.identHandler = identHandler;
|
this.identHandler = identHandler;
|
||||||
this.webPush = new WebPush();
|
this.webPush = new WebPush();
|
||||||
|
@ -32,11 +32,11 @@ ClientManager.prototype.init = function(identHandler, sockets) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.findClient = function(name) {
|
ClientManager.prototype.findClient = function (name) {
|
||||||
return this.clients.find((u) => u.name === name);
|
return this.clients.find((u) => u.name === name);
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.loadUsers = function() {
|
ClientManager.prototype.loadUsers = function () {
|
||||||
const users = this.getUsers();
|
const users = this.getUsers();
|
||||||
|
|
||||||
if (users.length === 0) {
|
if (users.length === 0) {
|
||||||
|
@ -48,7 +48,7 @@ ClientManager.prototype.loadUsers = function() {
|
||||||
users.forEach((name) => this.loadUser(name));
|
users.forEach((name) => this.loadUser(name));
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.autoloadUsers = function() {
|
ClientManager.prototype.autoloadUsers = function () {
|
||||||
fs.watch(
|
fs.watch(
|
||||||
Helper.getUsersPath(),
|
Helper.getUsersPath(),
|
||||||
_.debounce(
|
_.debounce(
|
||||||
|
@ -84,7 +84,7 @@ ClientManager.prototype.autoloadUsers = function() {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.loadUser = function(name) {
|
ClientManager.prototype.loadUser = function (name) {
|
||||||
const userConfig = readUserConfig(name);
|
const userConfig = readUserConfig(name);
|
||||||
|
|
||||||
if (!userConfig) {
|
if (!userConfig) {
|
||||||
|
@ -113,14 +113,14 @@ ClientManager.prototype.loadUser = function(name) {
|
||||||
return client;
|
return client;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.getUsers = function() {
|
ClientManager.prototype.getUsers = function () {
|
||||||
return fs
|
return fs
|
||||||
.readdirSync(Helper.getUsersPath())
|
.readdirSync(Helper.getUsersPath())
|
||||||
.filter((file) => file.endsWith(".json"))
|
.filter((file) => file.endsWith(".json"))
|
||||||
.map((file) => file.slice(0, -5));
|
.map((file) => file.slice(0, -5));
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.addUser = function(name, password, enableLog) {
|
ClientManager.prototype.addUser = function (name, password, enableLog) {
|
||||||
if (path.basename(name) !== name) {
|
if (path.basename(name) !== name) {
|
||||||
throw new Error(`${name} is an invalid username.`);
|
throw new Error(`${name} is an invalid username.`);
|
||||||
}
|
}
|
||||||
|
@ -176,20 +176,17 @@ ClientManager.prototype.addUser = function(name, password, enableLog) {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.getDataToSave = function(client) {
|
ClientManager.prototype.getDataToSave = function (client) {
|
||||||
const json = Object.assign({}, client.config, {
|
const json = Object.assign({}, client.config, {
|
||||||
networks: client.networks.map((n) => n.export()),
|
networks: client.networks.map((n) => n.export()),
|
||||||
});
|
});
|
||||||
const newUser = JSON.stringify(json, null, "\t");
|
const newUser = JSON.stringify(json, null, "\t");
|
||||||
const newHash = crypto
|
const newHash = crypto.createHash("sha256").update(newUser).digest("hex");
|
||||||
.createHash("sha256")
|
|
||||||
.update(newUser)
|
|
||||||
.digest("hex");
|
|
||||||
|
|
||||||
return {newUser, newHash};
|
return {newUser, newHash};
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.saveUser = function(client, callback) {
|
ClientManager.prototype.saveUser = function (client, callback) {
|
||||||
const {newUser, newHash} = this.getDataToSave(client);
|
const {newUser, newHash} = this.getDataToSave(client);
|
||||||
|
|
||||||
// Do not write to disk if the exported data hasn't actually changed
|
// Do not write to disk if the exported data hasn't actually changed
|
||||||
|
@ -216,7 +213,7 @@ ClientManager.prototype.saveUser = function(client, callback) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientManager.prototype.removeUser = function(name) {
|
ClientManager.prototype.removeUser = function (name) {
|
||||||
const userPath = Helper.getUserConfigPath(name);
|
const userPath = Helper.getUserConfigPath(name);
|
||||||
|
|
||||||
if (!fs.existsSync(userPath)) {
|
if (!fs.existsSync(userPath)) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ program
|
||||||
.command("install <package>")
|
.command("install <package>")
|
||||||
.description("Install a theme or a package")
|
.description("Install a theme or a package")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function(packageName) {
|
.action(function (packageName) {
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const packageJson = require("package-json");
|
const packageJson = require("package-json");
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ program
|
||||||
.description("Start the server")
|
.description("Start the server")
|
||||||
.option("--dev", "Development mode with hot module reloading")
|
.option("--dev", "Development mode with hot module reloading")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function(options) {
|
.action(function (options) {
|
||||||
initalizeConfig();
|
initalizeConfig();
|
||||||
|
|
||||||
const server = require("../server");
|
const server = require("../server");
|
||||||
|
|
|
@ -10,7 +10,7 @@ program
|
||||||
.command("uninstall <package>")
|
.command("uninstall <package>")
|
||||||
.description("Uninstall a theme or a package")
|
.description("Uninstall a theme or a package")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function(packageName) {
|
.action(function (packageName) {
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ program
|
||||||
.command("upgrade [packages...]")
|
.command("upgrade [packages...]")
|
||||||
.description("Upgrade installed themes and packages to their latest versions")
|
.description("Upgrade installed themes and packages to their latest versions")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function(packages) {
|
.action(function (packages) {
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ program
|
||||||
.command("add <name>")
|
.command("add <name>")
|
||||||
.description("Add a new user")
|
.description("Add a new user")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function(name) {
|
.action(function (name) {
|
||||||
if (!fs.existsSync(Helper.getUsersPath())) {
|
if (!fs.existsSync(Helper.getUsersPath())) {
|
||||||
log.error(`${Helper.getUsersPath()} does not exist.`);
|
log.error(`${Helper.getUsersPath()} does not exist.`);
|
||||||
return;
|
return;
|
||||||
|
@ -36,7 +36,7 @@ program
|
||||||
text: "Enter password:",
|
text: "Enter password:",
|
||||||
silent: true,
|
silent: true,
|
||||||
},
|
},
|
||||||
function(err, password) {
|
function (err, password) {
|
||||||
if (!password) {
|
if (!password) {
|
||||||
log.error("Password cannot be empty.");
|
log.error("Password cannot be empty.");
|
||||||
return;
|
return;
|
||||||
|
@ -48,7 +48,7 @@ program
|
||||||
text: "Save logs to disk?",
|
text: "Save logs to disk?",
|
||||||
default: "yes",
|
default: "yes",
|
||||||
},
|
},
|
||||||
function(err2, enableLog) {
|
function (err2, enableLog) {
|
||||||
if (!err2) {
|
if (!err2) {
|
||||||
add(
|
add(
|
||||||
manager,
|
manager,
|
||||||
|
|
|
@ -12,7 +12,7 @@ program
|
||||||
.command("edit <name>")
|
.command("edit <name>")
|
||||||
.description(`Edit user file located at ${colors.green(Helper.getUserConfigPath("<name>"))}`)
|
.description(`Edit user file located at ${colors.green(Helper.getUserConfigPath("<name>"))}`)
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function(name) {
|
.action(function (name) {
|
||||||
if (!fs.existsSync(Helper.getUsersPath())) {
|
if (!fs.existsSync(Helper.getUsersPath())) {
|
||||||
log.error(`${Helper.getUsersPath()} does not exist.`);
|
log.error(`${Helper.getUsersPath()} does not exist.`);
|
||||||
return;
|
return;
|
||||||
|
@ -36,7 +36,7 @@ program
|
||||||
[Helper.getUserConfigPath(name)],
|
[Helper.getUserConfigPath(name)],
|
||||||
{stdio: "inherit"}
|
{stdio: "inherit"}
|
||||||
);
|
);
|
||||||
child_spawn.on("error", function() {
|
child_spawn.on("error", function () {
|
||||||
log.error(
|
log.error(
|
||||||
`Unable to open ${colors.green(Helper.getUserConfigPath(name))}. ${colors.bold(
|
`Unable to open ${colors.green(Helper.getUserConfigPath(name))}. ${colors.bold(
|
||||||
"$EDITOR"
|
"$EDITOR"
|
||||||
|
|
|
@ -11,7 +11,7 @@ program
|
||||||
.command("list")
|
.command("list")
|
||||||
.description("List all users")
|
.description("List all users")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function() {
|
.action(function () {
|
||||||
if (!fs.existsSync(Helper.getUsersPath())) {
|
if (!fs.existsSync(Helper.getUsersPath())) {
|
||||||
log.error(`${Helper.getUsersPath()} does not exist.`);
|
log.error(`${Helper.getUsersPath()} does not exist.`);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -11,7 +11,7 @@ program
|
||||||
.command("remove <name>")
|
.command("remove <name>")
|
||||||
.description("Remove an existing user")
|
.description("Remove an existing user")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function(name) {
|
.action(function (name) {
|
||||||
if (!fs.existsSync(Helper.getUsersPath())) {
|
if (!fs.existsSync(Helper.getUsersPath())) {
|
||||||
log.error(`${Helper.getUsersPath()} does not exist.`);
|
log.error(`${Helper.getUsersPath()} does not exist.`);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -11,7 +11,7 @@ program
|
||||||
.command("reset <name>")
|
.command("reset <name>")
|
||||||
.description("Reset user password")
|
.description("Reset user password")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function(name) {
|
.action(function (name) {
|
||||||
if (!fs.existsSync(Helper.getUsersPath())) {
|
if (!fs.existsSync(Helper.getUsersPath())) {
|
||||||
log.error(`${Helper.getUsersPath()} does not exist.`);
|
log.error(`${Helper.getUsersPath()} does not exist.`);
|
||||||
return;
|
return;
|
||||||
|
@ -39,7 +39,7 @@ program
|
||||||
text: "Enter new password:",
|
text: "Enter new password:",
|
||||||
silent: true,
|
silent: true,
|
||||||
},
|
},
|
||||||
function(err, password) {
|
function (err, password) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,10 +87,7 @@ function getGitCommit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVersionCacheBust() {
|
function getVersionCacheBust() {
|
||||||
const hash = crypto
|
const hash = crypto.createHash("sha256").update(Helper.getVersion()).digest("hex");
|
||||||
.createHash("sha256")
|
|
||||||
.update(Helper.getVersion())
|
|
||||||
.digest("hex");
|
|
||||||
|
|
||||||
return hash.substring(0, 10);
|
return hash.substring(0, 10);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +205,7 @@ function ip2hex(address) {
|
||||||
|
|
||||||
return address
|
return address
|
||||||
.split(".")
|
.split(".")
|
||||||
.map(function(octet) {
|
.map(function (octet) {
|
||||||
let hex = parseInt(octet, 10).toString(16);
|
let hex = parseInt(octet, 10).toString(16);
|
||||||
|
|
||||||
if (hex.length === 1) {
|
if (hex.length === 1) {
|
||||||
|
|
|
@ -109,7 +109,7 @@ class Identification {
|
||||||
` { reply "${connection.user}" }\n`;
|
` { reply "${connection.user}" }\n`;
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.writeFile(this.oidentdFile, file, {flag: "w+"}, function(err) {
|
fs.writeFile(this.oidentdFile, file, {flag: "w+"}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error("Failed to update oidentd file!", err);
|
log.error("Failed to update oidentd file!", err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,7 @@ const colors = require("chalk");
|
||||||
const read = require("read");
|
const read = require("read");
|
||||||
|
|
||||||
function timestamp() {
|
function timestamp() {
|
||||||
const datetime = new Date()
|
const datetime = new Date().toISOString().split(".")[0].replace("T", " ");
|
||||||
.toISOString()
|
|
||||||
.split(".")[0]
|
|
||||||
.replace("T", " ");
|
|
||||||
|
|
||||||
return colors.dim(datetime);
|
return colors.dim(datetime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,11 @@ function Chan(attr) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Chan.prototype.destroy = function() {
|
Chan.prototype.destroy = function () {
|
||||||
this.dereferencePreviews(this.messages);
|
this.dereferencePreviews(this.messages);
|
||||||
};
|
};
|
||||||
|
|
||||||
Chan.prototype.pushMessage = function(client, msg, increasesUnread) {
|
Chan.prototype.pushMessage = function (client, msg, increasesUnread) {
|
||||||
const chan = this.id;
|
const chan = this.id;
|
||||||
const obj = {chan, msg};
|
const obj = {chan, msg};
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ Chan.prototype.pushMessage = function(client, msg, increasesUnread) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Chan.prototype.dereferencePreviews = function(messages) {
|
Chan.prototype.dereferencePreviews = function (messages) {
|
||||||
if (!Helper.config.prefetch || !Helper.config.prefetchStorage) {
|
if (!Helper.config.prefetch || !Helper.config.prefetchStorage) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ Chan.prototype.dereferencePreviews = function(messages) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Chan.prototype.getSortedUsers = function(irc) {
|
Chan.prototype.getSortedUsers = function (irc) {
|
||||||
const users = Array.from(this.users.values());
|
const users = Array.from(this.users.values());
|
||||||
|
|
||||||
if (!irc || !irc.network || !irc.network.options || !irc.network.options.PREFIX) {
|
if (!irc || !irc.network || !irc.network.options || !irc.network.options.PREFIX) {
|
||||||
|
@ -133,7 +133,7 @@ Chan.prototype.getSortedUsers = function(irc) {
|
||||||
|
|
||||||
userModeSortPriority[""] = 99; // No mode is lowest
|
userModeSortPriority[""] = 99; // No mode is lowest
|
||||||
|
|
||||||
return users.sort(function(a, b) {
|
return users.sort(function (a, b) {
|
||||||
if (a.mode === b.mode) {
|
if (a.mode === b.mode) {
|
||||||
return a.nick.toLowerCase() < b.nick.toLowerCase() ? -1 : 1;
|
return a.nick.toLowerCase() < b.nick.toLowerCase() ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
@ -142,23 +142,23 @@ Chan.prototype.getSortedUsers = function(irc) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Chan.prototype.findMessage = function(msgId) {
|
Chan.prototype.findMessage = function (msgId) {
|
||||||
return this.messages.find((message) => message.id === msgId);
|
return this.messages.find((message) => message.id === msgId);
|
||||||
};
|
};
|
||||||
|
|
||||||
Chan.prototype.findUser = function(nick) {
|
Chan.prototype.findUser = function (nick) {
|
||||||
return this.users.get(nick.toLowerCase());
|
return this.users.get(nick.toLowerCase());
|
||||||
};
|
};
|
||||||
|
|
||||||
Chan.prototype.getUser = function(nick) {
|
Chan.prototype.getUser = function (nick) {
|
||||||
return this.findUser(nick) || new User({nick});
|
return this.findUser(nick) || new User({nick});
|
||||||
};
|
};
|
||||||
|
|
||||||
Chan.prototype.setUser = function(user) {
|
Chan.prototype.setUser = function (user) {
|
||||||
this.users.set(user.nick.toLowerCase(), user);
|
this.users.set(user.nick.toLowerCase(), user);
|
||||||
};
|
};
|
||||||
|
|
||||||
Chan.prototype.removeUser = function(user) {
|
Chan.prototype.removeUser = function (user) {
|
||||||
this.users.delete(user.nick.toLowerCase());
|
this.users.delete(user.nick.toLowerCase());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ Chan.prototype.removeUser = function(user) {
|
||||||
* If true, channel is assumed active.
|
* If true, channel is assumed active.
|
||||||
* @param {int} lastMessage - Last message id seen by active client to avoid sending duplicates.
|
* @param {int} lastMessage - Last message id seen by active client to avoid sending duplicates.
|
||||||
*/
|
*/
|
||||||
Chan.prototype.getFilteredClone = function(lastActiveChannel, lastMessage) {
|
Chan.prototype.getFilteredClone = function (lastActiveChannel, lastMessage) {
|
||||||
return Object.keys(this).reduce((newChannel, prop) => {
|
return Object.keys(this).reduce((newChannel, prop) => {
|
||||||
if (prop === "users") {
|
if (prop === "users") {
|
||||||
// Do not send users, client requests updated user list whenever needed
|
// Do not send users, client requests updated user list whenever needed
|
||||||
|
@ -200,7 +200,7 @@ Chan.prototype.getFilteredClone = function(lastActiveChannel, lastMessage) {
|
||||||
}, {});
|
}, {});
|
||||||
};
|
};
|
||||||
|
|
||||||
Chan.prototype.writeUserLog = function(client, msg) {
|
Chan.prototype.writeUserLog = function (client, msg) {
|
||||||
this.messages.push(msg);
|
this.messages.push(msg);
|
||||||
|
|
||||||
// Are there any logs enabled
|
// Are there any logs enabled
|
||||||
|
@ -235,7 +235,7 @@ Chan.prototype.writeUserLog = function(client, msg) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Chan.prototype.loadMessages = function(client, network) {
|
Chan.prototype.loadMessages = function (client, network) {
|
||||||
if (!this.isLoggable()) {
|
if (!this.isLoggable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ Chan.prototype.loadMessages = function(client, network) {
|
||||||
.catch((err) => log.error(`Failed to load messages: ${err}`));
|
.catch((err) => log.error(`Failed to load messages: ${err}`));
|
||||||
};
|
};
|
||||||
|
|
||||||
Chan.prototype.isLoggable = function() {
|
Chan.prototype.isLoggable = function () {
|
||||||
return this.type === Chan.Type.CHANNEL || this.type === Chan.Type.QUERY;
|
return this.type === Chan.Type.CHANNEL || this.type === Chan.Type.QUERY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ function Network(attr) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Network.prototype.validate = function(client) {
|
Network.prototype.validate = function (client) {
|
||||||
// Remove !, :, @ and whitespace characters from nicknames and usernames
|
// Remove !, :, @ and whitespace characters from nicknames and usernames
|
||||||
const cleanNick = (str) => str.replace(/[\x00\s:!@]/g, "_").substring(0, 100);
|
const cleanNick = (str) => str.replace(/[\x00\s:!@]/g, "_").substring(0, 100);
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ Network.prototype.validate = function(client) {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.createIrcFramework = function(client) {
|
Network.prototype.createIrcFramework = function (client) {
|
||||||
this.irc = new IrcFramework.Client({
|
this.irc = new IrcFramework.Client({
|
||||||
version: false, // We handle it ourselves
|
version: false, // We handle it ourselves
|
||||||
host: this.host,
|
host: this.host,
|
||||||
|
@ -177,7 +177,7 @@ Network.prototype.createIrcFramework = function(client) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.createWebIrc = function(client) {
|
Network.prototype.createWebIrc = function (client) {
|
||||||
if (
|
if (
|
||||||
!Helper.config.webirc ||
|
!Helper.config.webirc ||
|
||||||
!Object.prototype.hasOwnProperty.call(Helper.config.webirc, this.host)
|
!Object.prototype.hasOwnProperty.call(Helper.config.webirc, this.host)
|
||||||
|
@ -207,7 +207,7 @@ Network.prototype.createWebIrc = function(client) {
|
||||||
return webircObject;
|
return webircObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.edit = function(client, args) {
|
Network.prototype.edit = function (client, args) {
|
||||||
const oldNick = this.nick;
|
const oldNick = this.nick;
|
||||||
const oldRealname = this.realname;
|
const oldRealname = this.realname;
|
||||||
|
|
||||||
|
@ -276,11 +276,11 @@ Network.prototype.edit = function(client, args) {
|
||||||
client.save();
|
client.save();
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.destroy = function() {
|
Network.prototype.destroy = function () {
|
||||||
this.channels.forEach((channel) => channel.destroy());
|
this.channels.forEach((channel) => channel.destroy());
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.setNick = function(nick) {
|
Network.prototype.setNick = function (nick) {
|
||||||
this.nick = nick;
|
this.nick = nick;
|
||||||
this.highlightRegex = new RegExp(
|
this.highlightRegex = new RegExp(
|
||||||
// Do not match characters and numbers (unless IRC color)
|
// Do not match characters and numbers (unless IRC color)
|
||||||
|
@ -308,7 +308,7 @@ Network.prototype.setNick = function(nick) {
|
||||||
*
|
*
|
||||||
* @see {@link Chan#getFilteredClone}
|
* @see {@link Chan#getFilteredClone}
|
||||||
*/
|
*/
|
||||||
Network.prototype.getFilteredClone = function(lastActiveChannel, lastMessage) {
|
Network.prototype.getFilteredClone = function (lastActiveChannel, lastMessage) {
|
||||||
const filteredNetwork = Object.keys(this).reduce((newNetwork, prop) => {
|
const filteredNetwork = Object.keys(this).reduce((newNetwork, prop) => {
|
||||||
if (prop === "channels") {
|
if (prop === "channels") {
|
||||||
// Channels objects perform their own cloning
|
// Channels objects perform their own cloning
|
||||||
|
@ -328,7 +328,7 @@ Network.prototype.getFilteredClone = function(lastActiveChannel, lastMessage) {
|
||||||
return filteredNetwork;
|
return filteredNetwork;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.getNetworkStatus = function() {
|
Network.prototype.getNetworkStatus = function () {
|
||||||
const status = {
|
const status = {
|
||||||
connected: false,
|
connected: false,
|
||||||
secure: false,
|
secure: false,
|
||||||
|
@ -349,7 +349,7 @@ Network.prototype.getNetworkStatus = function() {
|
||||||
return status;
|
return status;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.addChannel = function(newChan) {
|
Network.prototype.addChannel = function (newChan) {
|
||||||
let index = this.channels.length; // Default to putting as the last item in the array
|
let index = this.channels.length; // Default to putting as the last item in the array
|
||||||
|
|
||||||
// Don't sort special channels in amongst channels/users.
|
// Don't sort special channels in amongst channels/users.
|
||||||
|
@ -373,7 +373,7 @@ Network.prototype.addChannel = function(newChan) {
|
||||||
return index;
|
return index;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.quit = function(quitMessage) {
|
Network.prototype.quit = function (quitMessage) {
|
||||||
if (!this.irc) {
|
if (!this.irc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,7 @@ Network.prototype.quit = function(quitMessage) {
|
||||||
this.irc.quit(quitMessage || Helper.config.leaveMessage);
|
this.irc.quit(quitMessage || Helper.config.leaveMessage);
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.exportForEdit = function() {
|
Network.prototype.exportForEdit = function () {
|
||||||
let fieldsToReturn;
|
let fieldsToReturn;
|
||||||
|
|
||||||
if (Helper.config.displayNetwork) {
|
if (Helper.config.displayNetwork) {
|
||||||
|
@ -414,7 +414,7 @@ Network.prototype.exportForEdit = function() {
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.export = function() {
|
Network.prototype.export = function () {
|
||||||
const network = _.pick(this, [
|
const network = _.pick(this, [
|
||||||
"uuid",
|
"uuid",
|
||||||
"awayMessage",
|
"awayMessage",
|
||||||
|
@ -433,10 +433,10 @@ Network.prototype.export = function() {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
network.channels = this.channels
|
network.channels = this.channels
|
||||||
.filter(function(channel) {
|
.filter(function (channel) {
|
||||||
return channel.type === Chan.Type.CHANNEL || channel.type === Chan.Type.QUERY;
|
return channel.type === Chan.Type.CHANNEL || channel.type === Chan.Type.QUERY;
|
||||||
})
|
})
|
||||||
.map(function(chan) {
|
.map(function (chan) {
|
||||||
const keys = ["name"];
|
const keys = ["name"];
|
||||||
|
|
||||||
if (chan.type === Chan.Type.CHANNEL) {
|
if (chan.type === Chan.Type.CHANNEL) {
|
||||||
|
@ -451,10 +451,10 @@ Network.prototype.export = function() {
|
||||||
return network;
|
return network;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.getChannel = function(name) {
|
Network.prototype.getChannel = function (name) {
|
||||||
name = name.toLowerCase();
|
name = name.toLowerCase();
|
||||||
|
|
||||||
return _.find(this.channels, function(that, i) {
|
return _.find(this.channels, function (that, i) {
|
||||||
// Skip network lobby (it's always unshifted into first position)
|
// Skip network lobby (it's always unshifted into first position)
|
||||||
return i > 0 && that.name.toLowerCase() === name;
|
return i > 0 && that.name.toLowerCase() === name;
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,14 +16,14 @@ function User(attr, prefixLookup) {
|
||||||
this.setModes(this.modes, prefixLookup);
|
this.setModes(this.modes, prefixLookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.setModes = function(modes, prefixLookup) {
|
User.prototype.setModes = function (modes, prefixLookup) {
|
||||||
// irc-framework sets character mode, but The Lounge works with symbols
|
// irc-framework sets character mode, but The Lounge works with symbols
|
||||||
this.modes = modes.map((mode) => prefixLookup[mode]);
|
this.modes = modes.map((mode) => prefixLookup[mode]);
|
||||||
|
|
||||||
this.mode = this.modes[0] || "";
|
this.mode = this.modes[0] || "";
|
||||||
};
|
};
|
||||||
|
|
||||||
User.prototype.toJSON = function() {
|
User.prototype.toJSON = function () {
|
||||||
return {
|
return {
|
||||||
nick: this.nick,
|
nick: this.nick,
|
||||||
mode: this.mode,
|
mode: this.mode,
|
||||||
|
|
|
@ -12,12 +12,12 @@ function ldapAuthCommon(user, bindDN, password, callback) {
|
||||||
tlsOptions: config.ldap.tlsOptions,
|
tlsOptions: config.ldap.tlsOptions,
|
||||||
});
|
});
|
||||||
|
|
||||||
ldapclient.on("error", function(err) {
|
ldapclient.on("error", function (err) {
|
||||||
log.error(`Unable to connect to LDAP server: ${err}`);
|
log.error(`Unable to connect to LDAP server: ${err}`);
|
||||||
callback(false);
|
callback(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
ldapclient.bind(bindDN, password, function(err) {
|
ldapclient.bind(bindDN, password, function (err) {
|
||||||
ldapclient.unbind();
|
ldapclient.unbind();
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -67,25 +67,25 @@ function advancedLdapAuth(user, password, callback) {
|
||||||
attributes: ["dn"],
|
attributes: ["dn"],
|
||||||
};
|
};
|
||||||
|
|
||||||
ldapclient.on("error", function(err) {
|
ldapclient.on("error", function (err) {
|
||||||
log.error(`Unable to connect to LDAP server: ${err}`);
|
log.error(`Unable to connect to LDAP server: ${err}`);
|
||||||
callback(false);
|
callback(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
ldapclient.bind(config.ldap.searchDN.rootDN, config.ldap.searchDN.rootPassword, function(err) {
|
ldapclient.bind(config.ldap.searchDN.rootDN, config.ldap.searchDN.rootPassword, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error("Invalid LDAP root credentials");
|
log.error("Invalid LDAP root credentials");
|
||||||
ldapclient.unbind();
|
ldapclient.unbind();
|
||||||
callback(false);
|
callback(false);
|
||||||
} else {
|
} else {
|
||||||
ldapclient.search(base, searchOptions, function(err2, res) {
|
ldapclient.search(base, searchOptions, function (err2, res) {
|
||||||
if (err2) {
|
if (err2) {
|
||||||
log.warn(`LDAP User not found: ${userDN}`);
|
log.warn(`LDAP User not found: ${userDN}`);
|
||||||
ldapclient.unbind();
|
ldapclient.unbind();
|
||||||
callback(false);
|
callback(false);
|
||||||
} else {
|
} else {
|
||||||
let found = false;
|
let found = false;
|
||||||
res.on("searchEntry", function(entry) {
|
res.on("searchEntry", function (entry) {
|
||||||
found = true;
|
found = true;
|
||||||
const bindDN = entry.objectName;
|
const bindDN = entry.objectName;
|
||||||
log.info(
|
log.info(
|
||||||
|
@ -95,11 +95,11 @@ function advancedLdapAuth(user, password, callback) {
|
||||||
|
|
||||||
ldapAuthCommon(user, bindDN, password, callback);
|
ldapAuthCommon(user, bindDN, password, callback);
|
||||||
});
|
});
|
||||||
res.on("error", function(err3) {
|
res.on("error", function (err3) {
|
||||||
log.error(`LDAP error: ${err3}`);
|
log.error(`LDAP error: ${err3}`);
|
||||||
callback(false);
|
callback(false);
|
||||||
});
|
});
|
||||||
res.on("end", function(result) {
|
res.on("end", function (result) {
|
||||||
ldapclient.unbind();
|
ldapclient.unbind();
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
|
||||||
|
|
||||||
exports.commands = ["slap", "me"];
|
exports.commands = ["slap", "me"];
|
||||||
|
|
||||||
exports.input = function({irc}, chan, cmd, args) {
|
exports.input = function ({irc}, chan, cmd, args) {
|
||||||
if (chan.type !== Chan.Type.CHANNEL && chan.type !== Chan.Type.QUERY) {
|
if (chan.type !== Chan.Type.CHANNEL && chan.type !== Chan.Type.QUERY) {
|
||||||
chan.pushMessage(
|
chan.pushMessage(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
exports.commands = ["away", "back"];
|
exports.commands = ["away", "back"];
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function (network, chan, cmd, args) {
|
||||||
let reason = "";
|
let reason = "";
|
||||||
|
|
||||||
if (cmd === "away") {
|
if (cmd === "away") {
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
|
||||||
|
|
||||||
exports.commands = ["ban", "unban", "banlist"];
|
exports.commands = ["ban", "unban", "banlist"];
|
||||||
|
|
||||||
exports.input = function({irc}, chan, cmd, args) {
|
exports.input = function ({irc}, chan, cmd, args) {
|
||||||
if (chan.type !== Chan.Type.CHANNEL) {
|
if (chan.type !== Chan.Type.CHANNEL) {
|
||||||
chan.pushMessage(
|
chan.pushMessage(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
|
||||||
exports.commands = ["connect", "server"];
|
exports.commands = ["connect", "server"];
|
||||||
exports.allowDisconnected = true;
|
exports.allowDisconnected = true;
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function (network, chan, cmd, args) {
|
||||||
if (args.length === 0) {
|
if (args.length === 0) {
|
||||||
network.userDisconnected = false;
|
network.userDisconnected = false;
|
||||||
this.save();
|
this.save();
|
||||||
|
|
|
@ -4,7 +4,7 @@ const Msg = require("../../models/msg");
|
||||||
|
|
||||||
exports.commands = ["ctcp"];
|
exports.commands = ["ctcp"];
|
||||||
|
|
||||||
exports.input = function({irc}, chan, cmd, args) {
|
exports.input = function ({irc}, chan, cmd, args) {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
chan.pushMessage(
|
chan.pushMessage(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
exports.commands = ["disconnect"];
|
exports.commands = ["disconnect"];
|
||||||
exports.allowDisconnected = true;
|
exports.allowDisconnected = true;
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function (network, chan, cmd, args) {
|
||||||
const quitMessage = args[0] ? args.join(" ") : null;
|
const quitMessage = args[0] ? args.join(" ") : null;
|
||||||
|
|
||||||
network.quit(quitMessage);
|
network.quit(quitMessage);
|
||||||
|
|
|
@ -6,7 +6,7 @@ const Helper = require("../../helper");
|
||||||
|
|
||||||
exports.commands = ["ignore", "unignore", "ignorelist"];
|
exports.commands = ["ignore", "unignore", "ignorelist"];
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function (network, chan, cmd, args) {
|
||||||
const client = this;
|
const client = this;
|
||||||
let target;
|
let target;
|
||||||
let hostmask;
|
let hostmask;
|
||||||
|
@ -41,7 +41,7 @@ exports.input = function(network, chan, cmd, args) {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
!network.ignoreList.some(function(entry) {
|
!network.ignoreList.some(function (entry) {
|
||||||
return Helper.compareHostmask(entry, hostmask);
|
return Helper.compareHostmask(entry, hostmask);
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
|
@ -70,7 +70,7 @@ exports.input = function(network, chan, cmd, args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case "unignore": {
|
case "unignore": {
|
||||||
const idx = network.ignoreList.findIndex(function(entry) {
|
const idx = network.ignoreList.findIndex(function (entry) {
|
||||||
return Helper.compareHostmask(entry, hostmask);
|
return Helper.compareHostmask(entry, hostmask);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ const userInputs = [
|
||||||
"rejoin",
|
"rejoin",
|
||||||
"topic",
|
"topic",
|
||||||
"whois",
|
"whois",
|
||||||
].reduce(function(plugins, name) {
|
].reduce(function (plugins, name) {
|
||||||
const plugin = require(`./${name}`);
|
const plugin = require(`./${name}`);
|
||||||
plugin.commands.forEach((command) => plugins.set(command, plugin));
|
plugin.commands.forEach((command) => plugins.set(command, plugin));
|
||||||
return plugins;
|
return plugins;
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
|
||||||
|
|
||||||
exports.commands = ["invite", "invitelist"];
|
exports.commands = ["invite", "invitelist"];
|
||||||
|
|
||||||
exports.input = function({irc}, chan, cmd, args) {
|
exports.input = function ({irc}, chan, cmd, args) {
|
||||||
if (cmd === "invitelist") {
|
if (cmd === "invitelist") {
|
||||||
irc.inviteList(chan.name);
|
irc.inviteList(chan.name);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
|
||||||
|
|
||||||
exports.commands = ["kick"];
|
exports.commands = ["kick"];
|
||||||
|
|
||||||
exports.input = function({irc}, chan, cmd, args) {
|
exports.input = function ({irc}, chan, cmd, args) {
|
||||||
if (chan.type !== Chan.Type.CHANNEL) {
|
if (chan.type !== Chan.Type.CHANNEL) {
|
||||||
chan.pushMessage(
|
chan.pushMessage(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
exports.commands = ["kill"];
|
exports.commands = ["kill"];
|
||||||
|
|
||||||
exports.input = function({irc}, chan, cmd, args) {
|
exports.input = function ({irc}, chan, cmd, args) {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
irc.raw("KILL", args[0], args.slice(1).join(" "));
|
irc.raw("KILL", args[0], args.slice(1).join(" "));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
exports.commands = ["list"];
|
exports.commands = ["list"];
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function (network, chan, cmd, args) {
|
||||||
network.chanCache = [];
|
network.chanCache = [];
|
||||||
network.irc.list(...args);
|
network.irc.list(...args);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
|
||||||
|
|
||||||
exports.commands = ["mode", "op", "deop", "hop", "dehop", "voice", "devoice"];
|
exports.commands = ["mode", "op", "deop", "hop", "dehop", "voice", "devoice"];
|
||||||
|
|
||||||
exports.input = function({irc, nick}, chan, cmd, args) {
|
exports.input = function ({irc, nick}, chan, cmd, args) {
|
||||||
if (cmd !== "mode") {
|
if (cmd !== "mode") {
|
||||||
if (chan.type !== Chan.Type.CHANNEL) {
|
if (chan.type !== Chan.Type.CHANNEL) {
|
||||||
chan.pushMessage(
|
chan.pushMessage(
|
||||||
|
@ -40,7 +40,7 @@ exports.input = function({irc, nick}, chan, cmd, args) {
|
||||||
devoice: "-v",
|
devoice: "-v",
|
||||||
}[cmd];
|
}[cmd];
|
||||||
|
|
||||||
args.forEach(function(target) {
|
args.forEach(function (target) {
|
||||||
irc.raw("MODE", chan.name, mode, target);
|
irc.raw("MODE", chan.name, mode, target);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ function getTarget(cmd, args, chan) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function (network, chan, cmd, args) {
|
||||||
let targetName = getTarget(cmd, args, chan);
|
let targetName = getTarget(cmd, args, chan);
|
||||||
|
|
||||||
if (cmd === "query") {
|
if (cmd === "query") {
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
|
||||||
exports.commands = ["nick"];
|
exports.commands = ["nick"];
|
||||||
exports.allowDisconnected = true;
|
exports.allowDisconnected = true;
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function (network, chan, cmd, args) {
|
||||||
if (args.length === 0) {
|
if (args.length === 0) {
|
||||||
chan.pushMessage(
|
chan.pushMessage(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
exports.commands = ["notice"];
|
exports.commands = ["notice"];
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function (network, chan, cmd, args) {
|
||||||
if (!args[1]) {
|
if (!args[1]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ const Helper = require("../../helper");
|
||||||
exports.commands = ["close", "leave", "part"];
|
exports.commands = ["close", "leave", "part"];
|
||||||
exports.allowDisconnected = true;
|
exports.allowDisconnected = true;
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function (network, chan, cmd, args) {
|
||||||
let target = chan;
|
let target = chan;
|
||||||
|
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ const _ = require("lodash");
|
||||||
exports.commands = ["quit"];
|
exports.commands = ["quit"];
|
||||||
exports.allowDisconnected = true;
|
exports.allowDisconnected = true;
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function (network, chan, cmd, args) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
client.networks = _.without(client.networks, network);
|
client.networks = _.without(client.networks, network);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
exports.commands = ["raw", "send", "quote"];
|
exports.commands = ["raw", "send", "quote"];
|
||||||
|
|
||||||
exports.input = function({irc}, chan, cmd, args) {
|
exports.input = function ({irc}, chan, cmd, args) {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
irc.connection.write(args.join(" "));
|
irc.connection.write(args.join(" "));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Chan = require("../../models/chan");
|
||||||
|
|
||||||
exports.commands = ["cycle", "rejoin"];
|
exports.commands = ["cycle", "rejoin"];
|
||||||
|
|
||||||
exports.input = function({irc}, chan) {
|
exports.input = function ({irc}, chan) {
|
||||||
if (chan.type !== Chan.Type.CHANNEL) {
|
if (chan.type !== Chan.Type.CHANNEL) {
|
||||||
chan.pushMessage(
|
chan.pushMessage(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
|
||||||
|
|
||||||
exports.commands = ["topic"];
|
exports.commands = ["topic"];
|
||||||
|
|
||||||
exports.input = function({irc}, chan, cmd, args) {
|
exports.input = function ({irc}, chan, cmd, args) {
|
||||||
if (chan.type !== Chan.Type.CHANNEL) {
|
if (chan.type !== Chan.Type.CHANNEL) {
|
||||||
chan.pushMessage(
|
chan.pushMessage(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
exports.commands = ["whois"];
|
exports.commands = ["whois"];
|
||||||
|
|
||||||
exports.input = function({irc}, chan, cmd, args) {
|
exports.input = function ({irc}, chan, cmd, args) {
|
||||||
if (args.length === 1) {
|
if (args.length === 1) {
|
||||||
// This queries server of the other user and not of the current user, which
|
// This queries server of the other user and not of the current user, which
|
||||||
// does not know idle time.
|
// does not know idle time.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
const Chan = require("../../models/chan");
|
const Chan = require("../../models/chan");
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
irc.on("away", (data) => handleAway(Msg.Type.AWAY, data));
|
irc.on("away", (data) => handleAway(Msg.Type.AWAY, data));
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
const STSPolicies = require("../sts");
|
const STSPolicies = require("../sts");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
irc.on("cap ls", (data) => {
|
irc.on("cap ls", (data) => {
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
// If server supports CHGHOST cap, then changing the hostname does not require
|
// If server supports CHGHOST cap, then changing the hostname does not require
|
||||||
// sending PART and JOIN, which means less work for us over all
|
// sending PART and JOIN, which means less work for us over all
|
||||||
irc.on("user updated", function(data) {
|
irc.on("user updated", function (data) {
|
||||||
network.channels.forEach((chan) => {
|
network.channels.forEach((chan) => {
|
||||||
const user = chan.findUser(data.nick);
|
const user = chan.findUser(data.nick);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ const Msg = require("../../models/msg");
|
||||||
const Chan = require("../../models/chan");
|
const Chan = require("../../models/chan");
|
||||||
const Helper = require("../../helper");
|
const Helper = require("../../helper");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
network.channels[0].pushMessage(
|
network.channels[0].pushMessage(
|
||||||
|
@ -17,7 +17,7 @@ module.exports = function(irc, network) {
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
irc.on("registered", function() {
|
irc.on("registered", function () {
|
||||||
if (network.irc.network.cap.enabled.length > 0) {
|
if (network.irc.network.cap.enabled.length > 0) {
|
||||||
network.channels[0].pushMessage(
|
network.channels[0].pushMessage(
|
||||||
client,
|
client,
|
||||||
|
@ -40,7 +40,7 @@ module.exports = function(irc, network) {
|
||||||
|
|
||||||
if (Array.isArray(network.commands)) {
|
if (Array.isArray(network.commands)) {
|
||||||
network.commands.forEach((cmd) => {
|
network.commands.forEach((cmd) => {
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
client.input({
|
client.input({
|
||||||
target: network.channels[0].id,
|
target: network.channels[0].id,
|
||||||
text: cmd,
|
text: cmd,
|
||||||
|
@ -55,16 +55,16 @@ module.exports = function(irc, network) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
network.irc.join(chan.name, chan.key);
|
network.irc.join(chan.name, chan.key);
|
||||||
}, delay);
|
}, delay);
|
||||||
delay += 1000;
|
delay += 1000;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("socket connected", function() {
|
irc.on("socket connected", function () {
|
||||||
network.prefixLookup = {};
|
network.prefixLookup = {};
|
||||||
irc.network.options.PREFIX.forEach(function(mode) {
|
irc.network.options.PREFIX.forEach(function (mode) {
|
||||||
network.prefixLookup[mode.mode] = mode.symbol;
|
network.prefixLookup[mode.mode] = mode.symbol;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ module.exports = function(irc, network) {
|
||||||
sendStatus();
|
sendStatus();
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("close", function() {
|
irc.on("close", function () {
|
||||||
network.channels[0].pushMessage(
|
network.channels[0].pushMessage(
|
||||||
client,
|
client,
|
||||||
new Msg({
|
new Msg({
|
||||||
|
@ -92,7 +92,7 @@ module.exports = function(irc, network) {
|
||||||
|
|
||||||
let identSocketId;
|
let identSocketId;
|
||||||
|
|
||||||
irc.on("raw socket connected", function(socket) {
|
irc.on("raw socket connected", function (socket) {
|
||||||
let ident = client.name || network.username;
|
let ident = client.name || network.username;
|
||||||
|
|
||||||
if (Helper.config.useHexIp) {
|
if (Helper.config.useHexIp) {
|
||||||
|
@ -102,7 +102,7 @@ module.exports = function(irc, network) {
|
||||||
identSocketId = client.manager.identHandler.addSocket(socket, ident);
|
identSocketId = client.manager.identHandler.addSocket(socket, ident);
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("socket close", function(error) {
|
irc.on("socket close", function (error) {
|
||||||
if (identSocketId > 0) {
|
if (identSocketId > 0) {
|
||||||
client.manager.identHandler.removeSocket(identSocketId);
|
client.manager.identHandler.removeSocket(identSocketId);
|
||||||
identSocketId = 0;
|
identSocketId = 0;
|
||||||
|
@ -141,7 +141,7 @@ module.exports = function(irc, network) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Helper.config.debug.ircFramework) {
|
if (Helper.config.debug.ircFramework) {
|
||||||
irc.on("debug", function(message) {
|
irc.on("debug", function (message) {
|
||||||
log.debug(
|
log.debug(
|
||||||
`[${client.name} (${client.id}) on ${network.name} (${network.uuid}]`,
|
`[${client.name} (${client.id}) on ${network.name} (${network.uuid}]`,
|
||||||
message
|
message
|
||||||
|
@ -150,7 +150,7 @@ module.exports = function(irc, network) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Helper.config.debug.raw) {
|
if (Helper.config.debug.raw) {
|
||||||
irc.on("raw", function(message) {
|
irc.on("raw", function (message) {
|
||||||
network.channels[0].pushMessage(
|
network.channels[0].pushMessage(
|
||||||
client,
|
client,
|
||||||
new Msg({
|
new Msg({
|
||||||
|
@ -163,7 +163,7 @@ module.exports = function(irc, network) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
irc.on("socket error", function(err) {
|
irc.on("socket error", function (err) {
|
||||||
network.channels[0].pushMessage(
|
network.channels[0].pushMessage(
|
||||||
client,
|
client,
|
||||||
new Msg({
|
new Msg({
|
||||||
|
@ -174,7 +174,7 @@ module.exports = function(irc, network) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("reconnecting", function(data) {
|
irc.on("reconnecting", function (data) {
|
||||||
network.channels[0].pushMessage(
|
network.channels[0].pushMessage(
|
||||||
client,
|
client,
|
||||||
new Msg({
|
new Msg({
|
||||||
|
@ -191,7 +191,7 @@ module.exports = function(irc, network) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("ping timeout", function() {
|
irc.on("ping timeout", function () {
|
||||||
network.channels[0].pushMessage(
|
network.channels[0].pushMessage(
|
||||||
client,
|
client,
|
||||||
new Msg({
|
new Msg({
|
||||||
|
@ -201,7 +201,7 @@ module.exports = function(irc, network) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("server options", function(data) {
|
irc.on("server options", function (data) {
|
||||||
network.prefixLookup = {};
|
network.prefixLookup = {};
|
||||||
|
|
||||||
data.options.PREFIX.forEach((mode) => {
|
data.options.PREFIX.forEach((mode) => {
|
||||||
|
|
|
@ -16,12 +16,12 @@ const ctcpResponses = {
|
||||||
VERSION: () => pkg.name + " " + Helper.getVersion() + " -- " + pkg.homepage,
|
VERSION: () => pkg.name + " " + Helper.getVersion() + " -- " + pkg.homepage,
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
const lobby = network.channels[0];
|
const lobby = network.channels[0];
|
||||||
|
|
||||||
irc.on("ctcp response", function(data) {
|
irc.on("ctcp response", function (data) {
|
||||||
const shouldIgnore = network.ignoreList.some(function(entry) {
|
const shouldIgnore = network.ignoreList.some(function (entry) {
|
||||||
return Helper.compareHostmask(entry, data);
|
return Helper.compareHostmask(entry, data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ module.exports = function(irc, network) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const shouldIgnore = network.ignoreList.some(function(entry) {
|
const shouldIgnore = network.ignoreList.some(function (entry) {
|
||||||
return Helper.compareHostmask(entry, data);
|
return Helper.compareHostmask(entry, data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
const Helper = require("../../helper");
|
const Helper = require("../../helper");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
irc.on("irc error", function(data) {
|
irc.on("irc error", function (data) {
|
||||||
const msg = new Msg({
|
const msg = new Msg({
|
||||||
type: Msg.Type.ERROR,
|
type: Msg.Type.ERROR,
|
||||||
error: data.error,
|
error: data.error,
|
||||||
|
@ -33,7 +33,7 @@ module.exports = function(irc, network) {
|
||||||
target.pushMessage(client, msg, true);
|
target.pushMessage(client, msg, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("nick in use", function(data) {
|
irc.on("nick in use", function (data) {
|
||||||
let message = data.nick + ": " + (data.reason || "Nickname is already in use.");
|
let message = data.nick + ": " + (data.reason || "Nickname is already in use.");
|
||||||
|
|
||||||
if (irc.connection.registered === false && !Helper.config.public) {
|
if (irc.connection.registered === false && !Helper.config.public) {
|
||||||
|
@ -65,7 +65,7 @@ module.exports = function(irc, network) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("nick invalid", function(data) {
|
irc.on("nick invalid", function (data) {
|
||||||
const lobby = network.channels[0];
|
const lobby = network.channels[0];
|
||||||
const msg = new Msg({
|
const msg = new Msg({
|
||||||
type: Msg.Type.ERROR,
|
type: Msg.Type.ERROR,
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
irc.on("invite", function(data) {
|
irc.on("invite", function (data) {
|
||||||
let chan = network.getChannel(data.channel);
|
let chan = network.getChannel(data.channel);
|
||||||
|
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
|
|
|
@ -4,10 +4,10 @@ const Chan = require("../../models/chan");
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
const User = require("../../models/user");
|
const User = require("../../models/user");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
irc.on("join", function(data) {
|
irc.on("join", function (data) {
|
||||||
let chan = network.getChannel(data.channel);
|
let chan = network.getChannel(data.channel);
|
||||||
|
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
const Chan = require("../../models/chan");
|
const Chan = require("../../models/chan");
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
irc.on("kick", function(data) {
|
irc.on("kick", function (data) {
|
||||||
const chan = network.getChannel(data.channel);
|
const chan = network.getChannel(data.channel);
|
||||||
|
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
|
|
|
@ -12,7 +12,7 @@ const currentFetchPromises = new Map();
|
||||||
const imageTypeRegex = /^image\/.+/;
|
const imageTypeRegex = /^image\/.+/;
|
||||||
const mediaTypeRegex = /^(audio|video)\/.+/;
|
const mediaTypeRegex = /^(audio|video)\/.+/;
|
||||||
|
|
||||||
module.exports = function(client, chan, msg) {
|
module.exports = function (client, chan, msg) {
|
||||||
if (!Helper.config.prefetch) {
|
if (!Helper.config.prefetch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,7 @@ function parseHtml(preview, res, client) {
|
||||||
preview.type = "link";
|
preview.type = "link";
|
||||||
preview.head =
|
preview.head =
|
||||||
$('meta[property="og:title"]').attr("content") ||
|
$('meta[property="og:title"]').attr("content") ||
|
||||||
$("head > title, title")
|
$("head > title, title").first().text() ||
|
||||||
.first()
|
|
||||||
.text() ||
|
|
||||||
"";
|
"";
|
||||||
preview.body =
|
preview.body =
|
||||||
$('meta[property="og:description"]').attr("content") ||
|
$('meta[property="og:description"]').attr("content") ||
|
||||||
|
@ -136,7 +134,7 @@ function parseHtmlMedia($, preview, client) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(`meta[property="og:${type}:type"]`).each(function(i) {
|
$(`meta[property="og:${type}:type"]`).each(function (i) {
|
||||||
const mimeType = $(this).attr("content");
|
const mimeType = $(this).attr("content");
|
||||||
|
|
||||||
if (mediaTypeRegex.test(mimeType)) {
|
if (mediaTypeRegex.test(mimeType)) {
|
||||||
|
@ -360,7 +358,7 @@ function fetch(uri, headers) {
|
||||||
});
|
});
|
||||||
|
|
||||||
gotStream
|
gotStream
|
||||||
.on("response", function(res) {
|
.on("response", function (res) {
|
||||||
contentLength = parseInt(res.headers["content-length"], 10) || 0;
|
contentLength = parseInt(res.headers["content-length"], 10) || 0;
|
||||||
contentType = res.headers["content-type"];
|
contentType = res.headers["content-type"];
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
const Chan = require("../../models/chan");
|
const Chan = require("../../models/chan");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
const MAX_CHANS = 500;
|
const MAX_CHANS = 500;
|
||||||
|
|
||||||
irc.on("channel list start", function() {
|
irc.on("channel list start", function () {
|
||||||
network.chanCache = [];
|
network.chanCache = [];
|
||||||
|
|
||||||
updateListStatus({
|
updateListStatus({
|
||||||
|
@ -14,7 +14,7 @@ module.exports = function(irc, network) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("channel list", function(channels) {
|
irc.on("channel list", function (channels) {
|
||||||
Array.prototype.push.apply(network.chanCache, channels);
|
Array.prototype.push.apply(network.chanCache, channels);
|
||||||
|
|
||||||
updateListStatus({
|
updateListStatus({
|
||||||
|
@ -22,7 +22,7 @@ module.exports = function(irc, network) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("channel list end", function() {
|
irc.on("channel list end", function () {
|
||||||
updateListStatus(
|
updateListStatus(
|
||||||
network.chanCache.sort((a, b) => b.num_users - a.num_users).slice(0, MAX_CHANS)
|
network.chanCache.sort((a, b) => b.num_users - a.num_users).slice(0, MAX_CHANS)
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,10 +7,10 @@ const cleanIrcMessage = require("../../../client/js/helpers/ircmessageparser/cle
|
||||||
const Helper = require("../../helper");
|
const Helper = require("../../helper");
|
||||||
const nickRegExp = /(?:\x03[0-9]{1,2}(?:,[0-9]{1,2})?)?([\w[\]\\`^{|}-]+)/g;
|
const nickRegExp = /(?:\x03[0-9]{1,2}(?:,[0-9]{1,2})?)?([\w[\]\\`^{|}-]+)/g;
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
irc.on("notice", function(data) {
|
irc.on("notice", function (data) {
|
||||||
// Some servers send notices without any nickname
|
// Some servers send notices without any nickname
|
||||||
if (!data.nick) {
|
if (!data.nick) {
|
||||||
data.from_server = true;
|
data.from_server = true;
|
||||||
|
@ -21,17 +21,17 @@ module.exports = function(irc, network) {
|
||||||
handleMessage(data);
|
handleMessage(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("action", function(data) {
|
irc.on("action", function (data) {
|
||||||
data.type = Msg.Type.ACTION;
|
data.type = Msg.Type.ACTION;
|
||||||
handleMessage(data);
|
handleMessage(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("privmsg", function(data) {
|
irc.on("privmsg", function (data) {
|
||||||
data.type = Msg.Type.MESSAGE;
|
data.type = Msg.Type.MESSAGE;
|
||||||
handleMessage(data);
|
handleMessage(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("wallops", function(data) {
|
irc.on("wallops", function (data) {
|
||||||
data.from_server = true;
|
data.from_server = true;
|
||||||
data.type = Msg.Type.NOTICE;
|
data.type = Msg.Type.NOTICE;
|
||||||
handleMessage(data);
|
handleMessage(data);
|
||||||
|
@ -47,7 +47,7 @@ module.exports = function(irc, network) {
|
||||||
// Check if the sender is in our ignore list
|
// Check if the sender is in our ignore list
|
||||||
const shouldIgnore =
|
const shouldIgnore =
|
||||||
!self &&
|
!self &&
|
||||||
network.ignoreList.some(function(entry) {
|
network.ignoreList.some(function (entry) {
|
||||||
return Helper.compareHostmask(entry, data);
|
return Helper.compareHostmask(entry, data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
const _ = require("lodash");
|
const _ = require("lodash");
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
// The following saves the channel key based on channel mode instead of
|
// The following saves the channel key based on channel mode instead of
|
||||||
// extracting it from `/join #channel key`. This lets us not have to
|
// extracting it from `/join #channel key`. This lets us not have to
|
||||||
// temporarily store the key until successful join, but also saves the key
|
// temporarily store the key until successful join, but also saves the key
|
||||||
// if a key is set or changed while being on the channel.
|
// if a key is set or changed while being on the channel.
|
||||||
irc.on("channel info", function(data) {
|
irc.on("channel info", function (data) {
|
||||||
if (!data.modes) {
|
if (!data.modes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ module.exports = function(irc, network) {
|
||||||
targetChan.pushMessage(client, msg);
|
targetChan.pushMessage(client, msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("mode", function(data) {
|
irc.on("mode", function (data) {
|
||||||
let targetChan;
|
let targetChan;
|
||||||
|
|
||||||
if (data.target === irc.user.nick) {
|
if (data.target === irc.user.nick) {
|
||||||
|
@ -113,7 +113,7 @@ module.exports = function(irc, network) {
|
||||||
_.pull(user.modes, changedMode);
|
_.pull(user.modes, changedMode);
|
||||||
} else if (!user.modes.includes(changedMode)) {
|
} else if (!user.modes.includes(changedMode)) {
|
||||||
user.modes.push(changedMode);
|
user.modes.push(changedMode);
|
||||||
user.modes.sort(function(a, b) {
|
user.modes.sort(function (a, b) {
|
||||||
return userModeSortPriority[a] - userModeSortPriority[b];
|
return userModeSortPriority[a] - userModeSortPriority[b];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
const Chan = require("../../models/chan");
|
const Chan = require("../../models/chan");
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
irc.on("banlist", (list) => {
|
irc.on("banlist", (list) => {
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
irc.on("motd", function(data) {
|
irc.on("motd", function (data) {
|
||||||
const lobby = network.channels[0];
|
const lobby = network.channels[0];
|
||||||
|
|
||||||
if (data.motd) {
|
if (data.motd) {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
irc.on("userlist", function(data) {
|
irc.on("userlist", function (data) {
|
||||||
const chan = network.getChannel(data.channel);
|
const chan = network.getChannel(data.channel);
|
||||||
|
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue