Run format after updating to prettier 2.0

This commit is contained in:
Pavel Djundik 2020-03-21 22:55:36 +02:00
parent a46c9e8403
commit 881b3eda19
138 changed files with 584 additions and 631 deletions

View file

@ -109,7 +109,7 @@ export default {
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];
wrapCursor(
@ -121,7 +121,7 @@ export default {
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) {
wrapCursor(e.target, key, bracketWraps[key]);

View file

@ -1,7 +1,7 @@
<template>
<span class="content">
<Username :user="message.from" />&#32;
<span class="ctcp-message"><ParsedMessage :text="message.ctcpMessage"/></span>
<span class="ctcp-message"><ParsedMessage :text="message.ctcpMessage" /></span>
</span>
</template>

View file

@ -2,7 +2,7 @@
<span class="content">
<Username :user="message.from" />
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>
</template>

View file

@ -1,6 +1,6 @@
<template>
<span class="content">
<span class="text"><ParsedMessage :network="network" :text="cleanText"/></span>
<span class="text"><ParsedMessage :network="network" :text="cleanText" /></span>
</span>
</template>

View file

@ -82,7 +82,7 @@
:is-join-channel-shown="network.isJoinChannelShown"
:active="
$store.state.activeChannel &&
network.channels[0] === $store.state.activeChannel.channel
network.channels[0] === $store.state.activeChannel.channel
"
@toggleJoinChannel="network.isJoinChannelShown = !network.isJoinChannelShown"
/>
@ -114,7 +114,7 @@
:network="network"
:active="
$store.state.activeChannel &&
channel === $store.state.activeChannel.channel
channel === $store.state.activeChannel.channel
"
/>
</Draggable>

View file

@ -9,8 +9,8 @@
<template
v-if="
$store.state.versionData &&
$store.state.versionData.current &&
$store.state.versionData.current.version
$store.state.versionData.current &&
$store.state.versionData.current.version
"
>
<h1 class="title">
@ -29,9 +29,7 @@
<p>Unable to retrieve changelog for current release from GitHub.</p>
<p>
<a
:href="
`https://github.com/thelounge/thelounge/releases/tag/v${$store.state.serverConfiguration.version}`
"
:href="`https://github.com/thelounge/thelounge/releases/tag/v${$store.state.serverConfiguration.version}`"
target="_blank"
rel="noopener"
>View release notes for this version on GitHub</a

View file

@ -23,9 +23,7 @@
<template v-if="$store.state.serverConfiguration.gitCommit">
<p>
The Lounge is running from source (<a
:href="
`https://github.com/thelounge/thelounge/tree/${$store.state.serverConfiguration.gitCommit}`
"
:href="`https://github.com/thelounge/thelounge/tree/${$store.state.serverConfiguration.gitCommit}`"
target="_blank"
rel="noopener"
>commit <code>{{ $store.state.serverConfiguration.gitCommit }}</code></a
@ -36,9 +34,7 @@
<li>
Compare
<a
:href="
`https://github.com/thelounge/thelounge/compare/${$store.state.serverConfiguration.gitCommit}...master`
"
:href="`https://github.com/thelounge/thelounge/compare/${$store.state.serverConfiguration.gitCommit}...master`"
target="_blank"
rel="noopener"
>between
@ -50,9 +46,7 @@
<li>
Compare
<a
:href="
`https://github.com/thelounge/thelounge/compare/${$store.state.serverConfiguration.version}...${$store.state.serverConfiguration.gitCommit}`
"
:href="`https://github.com/thelounge/thelounge/compare/${$store.state.serverConfiguration.version}...${$store.state.serverConfiguration.gitCommit}`"
target="_blank"
rel="noopener"
>between

View file

@ -238,7 +238,7 @@
class="btn"
:disabled="
$store.state.pushNotificationState !== 'supported' &&
$store.state.pushNotificationState !== 'subscribed'
$store.state.pushNotificationState !== 'subscribed'
"
@click="onPushButtonClick"
>
@ -345,7 +345,7 @@
<div
v-if="
!$store.state.serverConfiguration.public &&
!$store.state.serverConfiguration.ldapEnabled
!$store.state.serverConfiguration.ldapEnabled
"
id="change-password"
role="group"

View file

@ -177,10 +177,7 @@ function enableAutocomplete(input) {
const text = input.value;
if (tabCount === 0) {
lastMatch = text
.substring(0, input.selectionStart)
.split(/\s/)
.pop();
lastMatch = text.substring(0, input.selectionStart).split(/\s/).pop();
if (lastMatch.length === 0) {
return;

View file

@ -1,6 +1,6 @@
"use strict";
export default function(chat) {
export default function (chat) {
// Disable in Firefox as it already copies flex text correctly
if (typeof window.InstallTrigger !== "undefined") {
return;

View file

@ -18,9 +18,7 @@ LinkifyIt.prototype.normalize = function normalize(match) {
}
};
const linkify = LinkifyIt()
.tlds(require("tlds"))
.tlds("onion", true);
const linkify = LinkifyIt().tlds(require("tlds")).tlds("onion", true);
// Known schemes to detect in text
const commonSchemes = [

View file

@ -85,10 +85,7 @@ function parse(createElement, text, message = undefined, network = undefined) {
const emojiParts = findEmoji(cleanText);
const nameParts = findNames(cleanText, message ? message.users || [] : []);
const parts = channelParts
.concat(linkParts)
.concat(emojiParts)
.concat(nameParts);
const parts = channelParts.concat(linkParts).concat(emojiParts).concat(nameParts);
// Merge the styling information with the channels / URLs / nicks / text objects and
// generate HTML strings with the resulting fragments

View file

@ -7,7 +7,7 @@ import {switchToChannel} from "./router";
import isChannelCollapsed from "./helpers/isChannelCollapsed";
// 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) {
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
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;
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
// 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
// it can be used to type letters with umlauts
// Normally this is not required, but since chat input has the "mousetrap"

View file

@ -8,7 +8,7 @@
* so that the timeout can be triggered while slow JS is loading
*/
(function() {
(function () {
const msg = document.getElementById("loading-page-message");
msg.textContent = "Loading the app…";

View file

@ -7,12 +7,12 @@ import store from "../store";
import location from "../location";
let lastServerHash = null;
socket.on("auth:success", function() {
socket.on("auth:success", function () {
store.commit("currentUserVisibleError", "Loading messages…");
updateLoadingMessage();
});
socket.on("auth:failed", function() {
socket.on("auth:failed", function () {
storage.remove("token");
if (store.state.appLoaded) {
@ -22,7 +22,7 @@ socket.on("auth:failed", function() {
showSignIn();
});
socket.on("auth:start", function(serverHash) {
socket.on("auth:start", function (serverHash) {
// If we reconnected and serverHash differs, that means the server restarted
// And we will reload the page to grab the latest version
if (lastServerHash && serverHash !== lastServerHash) {

View file

@ -3,7 +3,7 @@
import socket from "../socket";
import store from "../store";
socket.on("changelog", function(data) {
socket.on("changelog", function (data) {
store.commit("versionData", data);
store.commit("versionDataExpired", false);

View file

@ -1,7 +1,7 @@
const constants = require("../constants");
import socket from "../socket";
socket.on("commands", function(commands) {
socket.on("commands", function (commands) {
if (commands) {
constants.commands = commands;
}

View file

@ -4,7 +4,7 @@ import socket from "../socket";
import upload from "../upload";
import store from "../store";
socket.once("configuration", function(data) {
socket.once("configuration", function (data) {
store.commit("serverConfiguration", data);
// 'theme' setting depends on serverConfiguration.themes so

View file

@ -5,17 +5,17 @@ socket.on("disconnect", handleDisconnect);
socket.on("connect_error", handleDisconnect);
socket.on("error", handleDisconnect);
socket.on("reconnecting", function(attempt) {
socket.on("reconnecting", function (attempt) {
store.commit("currentUserVisibleError", `Reconnecting… (attempt ${attempt})`);
updateLoadingMessage();
});
socket.on("connecting", function() {
socket.on("connecting", function () {
store.commit("currentUserVisibleError", "Connecting…");
updateLoadingMessage();
});
socket.on("connect", function() {
socket.on("connect", function () {
// Clear send buffer when reconnecting, socket.io would emit these
// immediately upon connection and it will have no effect, so we ensure
// nothing is sent to the server that might have happened.

View file

@ -3,7 +3,7 @@
import socket from "../socket";
import store from "../store";
socket.on("history:clear", function(data) {
socket.on("history:clear", function (data) {
const {channel} = store.getters.findChannel(data.target);
channel.messages = [];

View file

@ -6,7 +6,7 @@ import {router, switchToChannel, navigate, initialize as routerInitialize} from
import store from "../store";
import parseIrcUri from "../helpers/parseIrcUri";
socket.on("init", function(data) {
socket.on("init", function (data) {
store.commit("networks", mergeNetworkData(data.networks));
store.commit("isConnected", true);
store.commit("currentUserVisibleError", null);

View file

@ -4,7 +4,7 @@ import socket from "../socket";
import store from "../store";
import {switchToChannel} from "../router";
socket.on("join", function(data) {
socket.on("join", function (data) {
store.getters.initChannel(data.chan);
const network = store.getters.findNetwork(data.network);

View file

@ -5,7 +5,7 @@ import Vue from "vue";
import socket from "../socket";
import store from "../store";
socket.on("more", function(data) {
socket.on("more", function (data) {
const channel = store.getters.findChannel(data.chan);
if (!channel) {

View file

@ -16,7 +16,7 @@ try {
};
}
socket.on("msg", function(data) {
socket.on("msg", function (data) {
const receivingChannel = store.getters.findChannel(data.chan);
if (!receivingChannel) {
@ -155,7 +155,7 @@ function notifyMessage(targetId, channel, activeChannel, msg) {
body: body,
timestamp: timestamp,
});
notify.addEventListener("click", function() {
notify.addEventListener("click", function () {
this.close();
window.focus();

View file

@ -5,7 +5,7 @@ import Vue from "vue";
import socket from "../socket";
import store from "../store";
socket.on("msg:preview", function(data) {
socket.on("msg:preview", function (data) {
const {channel} = store.getters.findChannel(data.chan);
const message = channel.messages.find((m) => m.id === data.id);

View file

@ -4,7 +4,7 @@ import socket from "../socket";
import store from "../store";
import {switchToChannel} from "../router";
socket.on("msg:special", function(data) {
socket.on("msg:special", function (data) {
const channel = store.getters.findChannel(data.chan);
channel.channel.data = data.data;
switchToChannel(channel.channel);

View file

@ -3,7 +3,7 @@
import socket from "../socket";
import store from "../store";
socket.on("names", function(data) {
socket.on("names", function (data) {
const channel = store.getters.findChannel(data.id);
if (channel) {

View file

@ -6,7 +6,7 @@ import socket from "../socket";
import store from "../store";
import {switchToChannel} from "../router";
socket.on("network", function(data) {
socket.on("network", function (data) {
const network = data.networks[0];
network.isJoinChannelShown = false;
@ -19,7 +19,7 @@ socket.on("network", function(data) {
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);
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);
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);
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);
if (!network) {

View file

@ -3,7 +3,7 @@
import socket from "../socket";
import store from "../store";
socket.on("nick", function(data) {
socket.on("nick", function (data) {
const network = store.getters.findNetwork(data.network);
if (network) {

View file

@ -4,7 +4,7 @@ import socket from "../socket";
import store from "../store";
// Sync unread badge and marker when other clients open a channel
socket.on("open", function(id) {
socket.on("open", function (id) {
if (id < 1) {
return;
}

View file

@ -4,7 +4,7 @@ import socket from "../socket";
import store from "../store";
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
if (store.state.activeChannel && store.state.activeChannel.channel.id === data.chan) {
switchToChannel(store.state.activeChannel.network.channels[0]);

View file

@ -4,7 +4,7 @@ import socket from "../socket";
import {switchToChannel, navigate} from "../router";
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,
// then open another channel window
const isCurrentNetworkBeingRemoved =

View file

@ -3,7 +3,7 @@
import socket from "../socket";
import store from "../store";
socket.on("sessions:list", function(data) {
socket.on("sessions:list", function (data) {
data.sort((a, b) => b.lastUse - a.lastUse);
store.commit("sessions", data);
});

View file

@ -3,13 +3,13 @@
import socket from "../socket";
import store from "../store";
socket.on("setting:new", function(data) {
socket.on("setting:new", function (data) {
const name = data.name;
const value = data.value;
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;
store.commit("serverHasSettings", serverHasSettings);

View file

@ -3,6 +3,6 @@
import socket from "../socket";
import Auth from "../auth";
socket.on("sign-out", function() {
socket.on("sign-out", function () {
Auth.signout();
});

View file

@ -3,7 +3,7 @@
import socket from "../socket";
import store from "../store";
socket.on("sync_sort", function(data) {
socket.on("sync_sort", function (data) {
const order = data.order;
switch (data.type) {

View file

@ -3,7 +3,7 @@
import socket from "../socket";
import store from "../store";
socket.on("topic", function(data) {
socket.on("topic", function (data) {
const channel = store.getters.findChannel(data.chan);
if (channel) {

View file

@ -3,7 +3,7 @@
import socket from "../socket";
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) {
return socket.emit("names", {
target: data.chan,

View file

@ -103,7 +103,7 @@ store.watch(
}
);
Vue.config.errorHandler = function(e) {
Vue.config.errorHandler = function (e) {
store.commit("currentUserVisibleError", `Vue error: ${e.message}`);
console.error(e); // eslint-disable-line
};

View file

@ -5,7 +5,7 @@ import store from "./store";
export default {togglePushSubscription};
socket.once("push:issubscribed", function(hasSubscriptionOnServer) {
socket.once("push:issubscribed", function (hasSubscriptionOnServer) {
if (!isAllowedServiceWorkersHost()) {
store.commit("pushNotificationState", "nohttps");
return;

View file

@ -5,11 +5,11 @@
const cacheName = "__HASH__";
const excludedPathsFromCache = /^(?:socket\.io|storage|uploads|cdn-cgi)\//;
self.addEventListener("install", function() {
self.addEventListener("install", function () {
self.skipWaiting();
});
self.addEventListener("activate", function(event) {
self.addEventListener("activate", function (event) {
event.waitUntil(
caches
.keys()
@ -23,7 +23,7 @@ self.addEventListener("activate", function(event) {
event.waitUntil(self.clients.claim());
});
self.addEventListener("fetch", function(event) {
self.addEventListener("fetch", function (event) {
if (event.request.method !== "GET") {
return;
}
@ -108,11 +108,11 @@ async function networkOrCache(event) {
}
}
self.addEventListener("message", function(event) {
self.addEventListener("message", function (event) {
showNotification(event, event.data);
});
self.addEventListener("push", function(event) {
self.addEventListener("push", function (event) {
if (!event.data) {
return;
}
@ -147,7 +147,7 @@ function showNotification(event, payload) {
);
}
self.addEventListener("notificationclick", function(event) {
self.addEventListener("notificationclick", function (event) {
event.notification.close();
event.waitUntil(

View file

@ -66,10 +66,7 @@ const changelogPath = path.resolve(__dirname, "..", "CHANGELOG.md");
if (token === undefined) {
try {
token = fs
.readFileSync(path.resolve(__dirname, "./github_token.txt"))
.toString()
.trim();
token = fs.readFileSync(path.resolve(__dirname, "./github_token.txt")).toString().trim();
} catch (e) {
log.error(`Environment variable ${colors.bold("CHANGELOG_TOKEN")} must be set.`);
log.error(`Alternative create ${colors.bold("scripts/github_token.txt")} file.`);

View file

@ -63,8 +63,5 @@ log.info(
);
function getPrettyDate() {
return new Date()
.toISOString()
.split(".")[0]
.replace("T", " ");
return new Date().toISOString().split(".")[0].replace("T", " ");
}

View file

@ -1,5 +1,5 @@
"use strict";
module.exports = function() {
return function() {};
module.exports = function () {
return function () {};
};

View file

@ -138,20 +138,20 @@ function Client(manager, name, config = {}) {
}
}
Client.prototype.createChannel = function(attr) {
Client.prototype.createChannel = function (attr) {
const chan = new Chan(attr);
chan.id = this.idChan++;
return chan;
};
Client.prototype.emit = function(event, data) {
Client.prototype.emit = function (event, data) {
if (this.manager !== null) {
this.manager.sockets.in(this.id).emit(event, data);
}
};
Client.prototype.find = function(channelId) {
Client.prototype.find = function (channelId) {
let network = null;
let chan = null;
@ -172,7 +172,7 @@ Client.prototype.find = function(channelId) {
return false;
};
Client.prototype.connect = function(args, isStartup = false) {
Client.prototype.connect = function (args, isStartup = false) {
const client = this;
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) => {
if (err) {
throw err;
@ -289,14 +289,11 @@ Client.prototype.generateToken = function(callback) {
});
};
Client.prototype.calculateTokenHash = function(token) {
return crypto
.createHash("sha512")
.update(token)
.digest("hex");
Client.prototype.calculateTokenHash = function (token) {
return crypto.createHash("sha512").update(token).digest("hex");
};
Client.prototype.updateSession = function(token, ip, request) {
Client.prototype.updateSession = function (token, ip, request) {
const client = this;
const agent = UAParser(request.headers["user-agent"] || "");
let friendlyAgent = "";
@ -324,12 +321,12 @@ Client.prototype.updateSession = function(token, ip, request) {
client.save();
};
Client.prototype.setPassword = function(hash, callback) {
Client.prototype.setPassword = function (hash, callback) {
const client = this;
const oldHash = client.config.password;
client.config.password = hash;
client.manager.saveUser(client, function(err) {
client.manager.saveUser(client, function (err) {
if (err) {
// If user file fails to write, reset it back
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;
data.text.split("\n").forEach((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 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;
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 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 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
// the disconnect event, and because we can't control this timing precisely,
// 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);
};
Client.prototype.sort = function(data) {
Client.prototype.sort = function (data) {
const order = data.order;
if (!_.isArray(order)) {
@ -610,7 +607,7 @@ Client.prototype.sort = function(data) {
this.save();
};
Client.prototype.names = function(data) {
Client.prototype.names = function (data) {
const client = this;
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 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;
if (client.awayMessage && _.size(client.attachedClients) === 0) {
client.networks.forEach(function(network) {
client.networks.forEach(function (network) {
// Only remove away on client attachment if
// there is no away message on this network
if (network.irc && !network.awayMessage) {
@ -669,13 +666,13 @@ Client.prototype.clientAttach = function(socketId, token) {
client.attachedClients[socketId] = {token, openChannel};
};
Client.prototype.clientDetach = function(socketId) {
Client.prototype.clientDetach = function (socketId) {
const client = this;
delete this.attachedClients[socketId];
if (client.awayMessage && _.size(client.attachedClients) === 0) {
client.networks.forEach(function(network) {
client.networks.forEach(function (network) {
// Only set away on client deattachment if
// there is no away message on this network
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 (
!_.isPlainObject(subscription) ||
!_.isPlainObject(subscription.keys) ||
@ -715,7 +712,7 @@ Client.prototype.registerPushSubscription = function(session, subscription, noSa
return data;
};
Client.prototype.unregisterPushSubscription = function(token) {
Client.prototype.unregisterPushSubscription = function (token) {
this.config.sessions[token].pushSubscription = null;
this.save();
};

View file

@ -16,7 +16,7 @@ function ClientManager() {
this.clients = [];
}
ClientManager.prototype.init = function(identHandler, sockets) {
ClientManager.prototype.init = function (identHandler, sockets) {
this.sockets = sockets;
this.identHandler = identHandler;
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);
};
ClientManager.prototype.loadUsers = function() {
ClientManager.prototype.loadUsers = function () {
const users = this.getUsers();
if (users.length === 0) {
@ -48,7 +48,7 @@ ClientManager.prototype.loadUsers = function() {
users.forEach((name) => this.loadUser(name));
};
ClientManager.prototype.autoloadUsers = function() {
ClientManager.prototype.autoloadUsers = function () {
fs.watch(
Helper.getUsersPath(),
_.debounce(
@ -84,7 +84,7 @@ ClientManager.prototype.autoloadUsers = function() {
);
};
ClientManager.prototype.loadUser = function(name) {
ClientManager.prototype.loadUser = function (name) {
const userConfig = readUserConfig(name);
if (!userConfig) {
@ -113,14 +113,14 @@ ClientManager.prototype.loadUser = function(name) {
return client;
};
ClientManager.prototype.getUsers = function() {
ClientManager.prototype.getUsers = function () {
return fs
.readdirSync(Helper.getUsersPath())
.filter((file) => file.endsWith(".json"))
.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) {
throw new Error(`${name} is an invalid username.`);
}
@ -176,20 +176,17 @@ ClientManager.prototype.addUser = function(name, password, enableLog) {
return true;
};
ClientManager.prototype.getDataToSave = function(client) {
ClientManager.prototype.getDataToSave = function (client) {
const json = Object.assign({}, client.config, {
networks: client.networks.map((n) => n.export()),
});
const newUser = JSON.stringify(json, null, "\t");
const newHash = crypto
.createHash("sha256")
.update(newUser)
.digest("hex");
const newHash = crypto.createHash("sha256").update(newUser).digest("hex");
return {newUser, newHash};
};
ClientManager.prototype.saveUser = function(client, callback) {
ClientManager.prototype.saveUser = function (client, callback) {
const {newUser, newHash} = this.getDataToSave(client);
// 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);
if (!fs.existsSync(userPath)) {

View file

@ -10,7 +10,7 @@ program
.command("install <package>")
.description("Install a theme or a package")
.on("--help", Utils.extraHelp)
.action(function(packageName) {
.action(function (packageName) {
const fs = require("fs");
const packageJson = require("package-json");

View file

@ -14,7 +14,7 @@ program
.description("Start the server")
.option("--dev", "Development mode with hot module reloading")
.on("--help", Utils.extraHelp)
.action(function(options) {
.action(function (options) {
initalizeConfig();
const server = require("../server");

View file

@ -10,7 +10,7 @@ program
.command("uninstall <package>")
.description("Uninstall a theme or a package")
.on("--help", Utils.extraHelp)
.action(function(packageName) {
.action(function (packageName) {
const fs = require("fs");
const path = require("path");

View file

@ -10,7 +10,7 @@ program
.command("upgrade [packages...]")
.description("Upgrade installed themes and packages to their latest versions")
.on("--help", Utils.extraHelp)
.action(function(packages) {
.action(function (packages) {
const fs = require("fs");
const path = require("path");

View file

@ -11,7 +11,7 @@ program
.command("add <name>")
.description("Add a new user")
.on("--help", Utils.extraHelp)
.action(function(name) {
.action(function (name) {
if (!fs.existsSync(Helper.getUsersPath())) {
log.error(`${Helper.getUsersPath()} does not exist.`);
return;
@ -36,7 +36,7 @@ program
text: "Enter password:",
silent: true,
},
function(err, password) {
function (err, password) {
if (!password) {
log.error("Password cannot be empty.");
return;
@ -48,7 +48,7 @@ program
text: "Save logs to disk?",
default: "yes",
},
function(err2, enableLog) {
function (err2, enableLog) {
if (!err2) {
add(
manager,

View file

@ -12,7 +12,7 @@ program
.command("edit <name>")
.description(`Edit user file located at ${colors.green(Helper.getUserConfigPath("<name>"))}`)
.on("--help", Utils.extraHelp)
.action(function(name) {
.action(function (name) {
if (!fs.existsSync(Helper.getUsersPath())) {
log.error(`${Helper.getUsersPath()} does not exist.`);
return;
@ -36,7 +36,7 @@ program
[Helper.getUserConfigPath(name)],
{stdio: "inherit"}
);
child_spawn.on("error", function() {
child_spawn.on("error", function () {
log.error(
`Unable to open ${colors.green(Helper.getUserConfigPath(name))}. ${colors.bold(
"$EDITOR"

View file

@ -11,7 +11,7 @@ program
.command("list")
.description("List all users")
.on("--help", Utils.extraHelp)
.action(function() {
.action(function () {
if (!fs.existsSync(Helper.getUsersPath())) {
log.error(`${Helper.getUsersPath()} does not exist.`);
return;

View file

@ -11,7 +11,7 @@ program
.command("remove <name>")
.description("Remove an existing user")
.on("--help", Utils.extraHelp)
.action(function(name) {
.action(function (name) {
if (!fs.existsSync(Helper.getUsersPath())) {
log.error(`${Helper.getUsersPath()} does not exist.`);
return;

View file

@ -11,7 +11,7 @@ program
.command("reset <name>")
.description("Reset user password")
.on("--help", Utils.extraHelp)
.action(function(name) {
.action(function (name) {
if (!fs.existsSync(Helper.getUsersPath())) {
log.error(`${Helper.getUsersPath()} does not exist.`);
return;
@ -39,7 +39,7 @@ program
text: "Enter new password:",
silent: true,
},
function(err, password) {
function (err, password) {
if (err) {
return;
}

View file

@ -87,10 +87,7 @@ function getGitCommit() {
}
function getVersionCacheBust() {
const hash = crypto
.createHash("sha256")
.update(Helper.getVersion())
.digest("hex");
const hash = crypto.createHash("sha256").update(Helper.getVersion()).digest("hex");
return hash.substring(0, 10);
}
@ -208,7 +205,7 @@ function ip2hex(address) {
return address
.split(".")
.map(function(octet) {
.map(function (octet) {
let hex = parseInt(octet, 10).toString(16);
if (hex.length === 1) {

View file

@ -109,7 +109,7 @@ class Identification {
` { reply "${connection.user}" }\n`;
});
fs.writeFile(this.oidentdFile, file, {flag: "w+"}, function(err) {
fs.writeFile(this.oidentdFile, file, {flag: "w+"}, function (err) {
if (err) {
log.error("Failed to update oidentd file!", err);
}

View file

@ -4,10 +4,7 @@ const colors = require("chalk");
const read = require("read");
function timestamp() {
const datetime = new Date()
.toISOString()
.split(".")[0]
.replace("T", " ");
const datetime = new Date().toISOString().split(".")[0].replace("T", " ");
return colors.dim(datetime);
}

View file

@ -44,11 +44,11 @@ function Chan(attr) {
});
}
Chan.prototype.destroy = function() {
Chan.prototype.destroy = function () {
this.dereferencePreviews(this.messages);
};
Chan.prototype.pushMessage = function(client, msg, increasesUnread) {
Chan.prototype.pushMessage = function (client, msg, increasesUnread) {
const chan = this.id;
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) {
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());
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
return users.sort(function(a, b) {
return users.sort(function (a, b) {
if (a.mode === b.mode) {
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);
};
Chan.prototype.findUser = function(nick) {
Chan.prototype.findUser = function (nick) {
return this.users.get(nick.toLowerCase());
};
Chan.prototype.getUser = function(nick) {
Chan.prototype.getUser = function (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);
};
Chan.prototype.removeUser = function(user) {
Chan.prototype.removeUser = function (user) {
this.users.delete(user.nick.toLowerCase());
};
@ -171,7 +171,7 @@ Chan.prototype.removeUser = function(user) {
* If true, channel is assumed active.
* @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) => {
if (prop === "users") {
// 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);
// 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()) {
return;
}
@ -278,7 +278,7 @@ Chan.prototype.loadMessages = function(client, network) {
.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;
};

View file

@ -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
const cleanNick = (str) => str.replace(/[\x00\s:!@]/g, "_").substring(0, 100);
@ -145,7 +145,7 @@ Network.prototype.validate = function(client) {
return true;
};
Network.prototype.createIrcFramework = function(client) {
Network.prototype.createIrcFramework = function (client) {
this.irc = new IrcFramework.Client({
version: false, // We handle it ourselves
host: this.host,
@ -177,7 +177,7 @@ Network.prototype.createIrcFramework = function(client) {
}
};
Network.prototype.createWebIrc = function(client) {
Network.prototype.createWebIrc = function (client) {
if (
!Helper.config.webirc ||
!Object.prototype.hasOwnProperty.call(Helper.config.webirc, this.host)
@ -207,7 +207,7 @@ Network.prototype.createWebIrc = function(client) {
return webircObject;
};
Network.prototype.edit = function(client, args) {
Network.prototype.edit = function (client, args) {
const oldNick = this.nick;
const oldRealname = this.realname;
@ -276,11 +276,11 @@ Network.prototype.edit = function(client, args) {
client.save();
};
Network.prototype.destroy = function() {
Network.prototype.destroy = function () {
this.channels.forEach((channel) => channel.destroy());
};
Network.prototype.setNick = function(nick) {
Network.prototype.setNick = function (nick) {
this.nick = nick;
this.highlightRegex = new RegExp(
// Do not match characters and numbers (unless IRC color)
@ -308,7 +308,7 @@ Network.prototype.setNick = function(nick) {
*
* @see {@link Chan#getFilteredClone}
*/
Network.prototype.getFilteredClone = function(lastActiveChannel, lastMessage) {
Network.prototype.getFilteredClone = function (lastActiveChannel, lastMessage) {
const filteredNetwork = Object.keys(this).reduce((newNetwork, prop) => {
if (prop === "channels") {
// Channels objects perform their own cloning
@ -328,7 +328,7 @@ Network.prototype.getFilteredClone = function(lastActiveChannel, lastMessage) {
return filteredNetwork;
};
Network.prototype.getNetworkStatus = function() {
Network.prototype.getNetworkStatus = function () {
const status = {
connected: false,
secure: false,
@ -349,7 +349,7 @@ Network.prototype.getNetworkStatus = function() {
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
// Don't sort special channels in amongst channels/users.
@ -373,7 +373,7 @@ Network.prototype.addChannel = function(newChan) {
return index;
};
Network.prototype.quit = function(quitMessage) {
Network.prototype.quit = function (quitMessage) {
if (!this.irc) {
return;
}
@ -384,7 +384,7 @@ Network.prototype.quit = function(quitMessage) {
this.irc.quit(quitMessage || Helper.config.leaveMessage);
};
Network.prototype.exportForEdit = function() {
Network.prototype.exportForEdit = function () {
let fieldsToReturn;
if (Helper.config.displayNetwork) {
@ -414,7 +414,7 @@ Network.prototype.exportForEdit = function() {
return data;
};
Network.prototype.export = function() {
Network.prototype.export = function () {
const network = _.pick(this, [
"uuid",
"awayMessage",
@ -433,10 +433,10 @@ Network.prototype.export = function() {
]);
network.channels = this.channels
.filter(function(channel) {
.filter(function (channel) {
return channel.type === Chan.Type.CHANNEL || channel.type === Chan.Type.QUERY;
})
.map(function(chan) {
.map(function (chan) {
const keys = ["name"];
if (chan.type === Chan.Type.CHANNEL) {
@ -451,10 +451,10 @@ Network.prototype.export = function() {
return network;
};
Network.prototype.getChannel = function(name) {
Network.prototype.getChannel = function (name) {
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)
return i > 0 && that.name.toLowerCase() === name;
});

View file

@ -16,14 +16,14 @@ function User(attr, 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
this.modes = modes.map((mode) => prefixLookup[mode]);
this.mode = this.modes[0] || "";
};
User.prototype.toJSON = function() {
User.prototype.toJSON = function () {
return {
nick: this.nick,
mode: this.mode,

View file

@ -12,12 +12,12 @@ function ldapAuthCommon(user, bindDN, password, callback) {
tlsOptions: config.ldap.tlsOptions,
});
ldapclient.on("error", function(err) {
ldapclient.on("error", function (err) {
log.error(`Unable to connect to LDAP server: ${err}`);
callback(false);
});
ldapclient.bind(bindDN, password, function(err) {
ldapclient.bind(bindDN, password, function (err) {
ldapclient.unbind();
if (err) {
@ -67,25 +67,25 @@ function advancedLdapAuth(user, password, callback) {
attributes: ["dn"],
};
ldapclient.on("error", function(err) {
ldapclient.on("error", function (err) {
log.error(`Unable to connect to LDAP server: ${err}`);
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) {
log.error("Invalid LDAP root credentials");
ldapclient.unbind();
callback(false);
} else {
ldapclient.search(base, searchOptions, function(err2, res) {
ldapclient.search(base, searchOptions, function (err2, res) {
if (err2) {
log.warn(`LDAP User not found: ${userDN}`);
ldapclient.unbind();
callback(false);
} else {
let found = false;
res.on("searchEntry", function(entry) {
res.on("searchEntry", function (entry) {
found = true;
const bindDN = entry.objectName;
log.info(
@ -95,11 +95,11 @@ function advancedLdapAuth(user, password, callback) {
ldapAuthCommon(user, bindDN, password, callback);
});
res.on("error", function(err3) {
res.on("error", function (err3) {
log.error(`LDAP error: ${err3}`);
callback(false);
});
res.on("end", function(result) {
res.on("end", function (result) {
ldapclient.unbind();
if (!found) {

View file

@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
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) {
chan.pushMessage(
this,

View file

@ -2,7 +2,7 @@
exports.commands = ["away", "back"];
exports.input = function(network, chan, cmd, args) {
exports.input = function (network, chan, cmd, args) {
let reason = "";
if (cmd === "away") {

View file

@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
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) {
chan.pushMessage(
this,

View file

@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
exports.commands = ["connect", "server"];
exports.allowDisconnected = true;
exports.input = function(network, chan, cmd, args) {
exports.input = function (network, chan, cmd, args) {
if (args.length === 0) {
network.userDisconnected = false;
this.save();

View file

@ -4,7 +4,7 @@ const Msg = require("../../models/msg");
exports.commands = ["ctcp"];
exports.input = function({irc}, chan, cmd, args) {
exports.input = function ({irc}, chan, cmd, args) {
if (args.length < 2) {
chan.pushMessage(
this,

View file

@ -3,7 +3,7 @@
exports.commands = ["disconnect"];
exports.allowDisconnected = true;
exports.input = function(network, chan, cmd, args) {
exports.input = function (network, chan, cmd, args) {
const quitMessage = args[0] ? args.join(" ") : null;
network.quit(quitMessage);

View file

@ -6,7 +6,7 @@ const Helper = require("../../helper");
exports.commands = ["ignore", "unignore", "ignorelist"];
exports.input = function(network, chan, cmd, args) {
exports.input = function (network, chan, cmd, args) {
const client = this;
let target;
let hostmask;
@ -41,7 +41,7 @@ exports.input = function(network, chan, cmd, args) {
})
);
} else if (
!network.ignoreList.some(function(entry) {
!network.ignoreList.some(function (entry) {
return Helper.compareHostmask(entry, hostmask);
})
) {
@ -70,7 +70,7 @@ exports.input = function(network, chan, cmd, args) {
}
case "unignore": {
const idx = network.ignoreList.findIndex(function(entry) {
const idx = network.ignoreList.findIndex(function (entry) {
return Helper.compareHostmask(entry, hostmask);
});

View file

@ -35,7 +35,7 @@ const userInputs = [
"rejoin",
"topic",
"whois",
].reduce(function(plugins, name) {
].reduce(function (plugins, name) {
const plugin = require(`./${name}`);
plugin.commands.forEach((command) => plugins.set(command, plugin));
return plugins;

View file

@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
exports.commands = ["invite", "invitelist"];
exports.input = function({irc}, chan, cmd, args) {
exports.input = function ({irc}, chan, cmd, args) {
if (cmd === "invitelist") {
irc.inviteList(chan.name);
return;

View file

@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
exports.commands = ["kick"];
exports.input = function({irc}, chan, cmd, args) {
exports.input = function ({irc}, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(
this,

View file

@ -2,7 +2,7 @@
exports.commands = ["kill"];
exports.input = function({irc}, chan, cmd, args) {
exports.input = function ({irc}, chan, cmd, args) {
if (args.length !== 0) {
irc.raw("KILL", args[0], args.slice(1).join(" "));
}

View file

@ -2,7 +2,7 @@
exports.commands = ["list"];
exports.input = function(network, chan, cmd, args) {
exports.input = function (network, chan, cmd, args) {
network.chanCache = [];
network.irc.list(...args);
return true;

View file

@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
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 (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(
@ -40,7 +40,7 @@ exports.input = function({irc, nick}, chan, cmd, args) {
devoice: "-v",
}[cmd];
args.forEach(function(target) {
args.forEach(function (target) {
irc.raw("MODE", chan.name, mode, target);
});

View file

@ -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);
if (cmd === "query") {

View file

@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
exports.commands = ["nick"];
exports.allowDisconnected = true;
exports.input = function(network, chan, cmd, args) {
exports.input = function (network, chan, cmd, args) {
if (args.length === 0) {
chan.pushMessage(
this,

View file

@ -2,7 +2,7 @@
exports.commands = ["notice"];
exports.input = function(network, chan, cmd, args) {
exports.input = function (network, chan, cmd, args) {
if (!args[1]) {
return;
}

View file

@ -8,7 +8,7 @@ const Helper = require("../../helper");
exports.commands = ["close", "leave", "part"];
exports.allowDisconnected = true;
exports.input = function(network, chan, cmd, args) {
exports.input = function (network, chan, cmd, args) {
let target = chan;
if (args.length > 0) {

View file

@ -5,7 +5,7 @@ const _ = require("lodash");
exports.commands = ["quit"];
exports.allowDisconnected = true;
exports.input = function(network, chan, cmd, args) {
exports.input = function (network, chan, cmd, args) {
const client = this;
client.networks = _.without(client.networks, network);

View file

@ -2,7 +2,7 @@
exports.commands = ["raw", "send", "quote"];
exports.input = function({irc}, chan, cmd, args) {
exports.input = function ({irc}, chan, cmd, args) {
if (args.length !== 0) {
irc.connection.write(args.join(" "));
}

View file

@ -5,7 +5,7 @@ const Chan = require("../../models/chan");
exports.commands = ["cycle", "rejoin"];
exports.input = function({irc}, chan) {
exports.input = function ({irc}, chan) {
if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(
this,

View file

@ -5,7 +5,7 @@ const Msg = require("../../models/msg");
exports.commands = ["topic"];
exports.input = function({irc}, chan, cmd, args) {
exports.input = function ({irc}, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(
this,

View file

@ -2,7 +2,7 @@
exports.commands = ["whois"];
exports.input = function({irc}, chan, cmd, args) {
exports.input = function ({irc}, chan, cmd, args) {
if (args.length === 1) {
// This queries server of the other user and not of the current user, which
// does not know idle time.

View file

@ -3,7 +3,7 @@
const Chan = require("../../models/chan");
const Msg = require("../../models/msg");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
irc.on("away", (data) => handleAway(Msg.Type.AWAY, data));

View file

@ -3,7 +3,7 @@
const Msg = require("../../models/msg");
const STSPolicies = require("../sts");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
irc.on("cap ls", (data) => {

View file

@ -2,12 +2,12 @@
const Msg = require("../../models/msg");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
// If server supports CHGHOST cap, then changing the hostname does not require
// 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) => {
const user = chan.findUser(data.nick);

View file

@ -6,7 +6,7 @@ const Msg = require("../../models/msg");
const Chan = require("../../models/chan");
const Helper = require("../../helper");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
network.channels[0].pushMessage(
@ -17,7 +17,7 @@ module.exports = function(irc, network) {
true
);
irc.on("registered", function() {
irc.on("registered", function () {
if (network.irc.network.cap.enabled.length > 0) {
network.channels[0].pushMessage(
client,
@ -40,7 +40,7 @@ module.exports = function(irc, network) {
if (Array.isArray(network.commands)) {
network.commands.forEach((cmd) => {
setTimeout(function() {
setTimeout(function () {
client.input({
target: network.channels[0].id,
text: cmd,
@ -55,16 +55,16 @@ module.exports = function(irc, network) {
return;
}
setTimeout(function() {
setTimeout(function () {
network.irc.join(chan.name, chan.key);
}, delay);
delay += 1000;
});
});
irc.on("socket connected", function() {
irc.on("socket connected", function () {
network.prefixLookup = {};
irc.network.options.PREFIX.forEach(function(mode) {
irc.network.options.PREFIX.forEach(function (mode) {
network.prefixLookup[mode.mode] = mode.symbol;
});
@ -79,7 +79,7 @@ module.exports = function(irc, network) {
sendStatus();
});
irc.on("close", function() {
irc.on("close", function () {
network.channels[0].pushMessage(
client,
new Msg({
@ -92,7 +92,7 @@ module.exports = function(irc, network) {
let identSocketId;
irc.on("raw socket connected", function(socket) {
irc.on("raw socket connected", function (socket) {
let ident = client.name || network.username;
if (Helper.config.useHexIp) {
@ -102,7 +102,7 @@ module.exports = function(irc, network) {
identSocketId = client.manager.identHandler.addSocket(socket, ident);
});
irc.on("socket close", function(error) {
irc.on("socket close", function (error) {
if (identSocketId > 0) {
client.manager.identHandler.removeSocket(identSocketId);
identSocketId = 0;
@ -141,7 +141,7 @@ module.exports = function(irc, network) {
});
if (Helper.config.debug.ircFramework) {
irc.on("debug", function(message) {
irc.on("debug", function (message) {
log.debug(
`[${client.name} (${client.id}) on ${network.name} (${network.uuid}]`,
message
@ -150,7 +150,7 @@ module.exports = function(irc, network) {
}
if (Helper.config.debug.raw) {
irc.on("raw", function(message) {
irc.on("raw", function (message) {
network.channels[0].pushMessage(
client,
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(
client,
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(
client,
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(
client,
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 = {};
data.options.PREFIX.forEach((mode) => {

View file

@ -16,12 +16,12 @@ const ctcpResponses = {
VERSION: () => pkg.name + " " + Helper.getVersion() + " -- " + pkg.homepage,
};
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
const lobby = network.channels[0];
irc.on("ctcp response", function(data) {
const shouldIgnore = network.ignoreList.some(function(entry) {
irc.on("ctcp response", function (data) {
const shouldIgnore = network.ignoreList.some(function (entry) {
return Helper.compareHostmask(entry, data);
});
@ -59,7 +59,7 @@ module.exports = function(irc, network) {
return;
}
const shouldIgnore = network.ignoreList.some(function(entry) {
const shouldIgnore = network.ignoreList.some(function (entry) {
return Helper.compareHostmask(entry, data);
});

View file

@ -3,10 +3,10 @@
const Msg = require("../../models/msg");
const Helper = require("../../helper");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
irc.on("irc error", function(data) {
irc.on("irc error", function (data) {
const msg = new Msg({
type: Msg.Type.ERROR,
error: data.error,
@ -33,7 +33,7 @@ module.exports = function(irc, network) {
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.");
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 msg = new Msg({
type: Msg.Type.ERROR,

View file

@ -2,10 +2,10 @@
const Msg = require("../../models/msg");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
irc.on("invite", function(data) {
irc.on("invite", function (data) {
let chan = network.getChannel(data.channel);
if (typeof chan === "undefined") {

View file

@ -4,10 +4,10 @@ const Chan = require("../../models/chan");
const Msg = require("../../models/msg");
const User = require("../../models/user");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
irc.on("join", function(data) {
irc.on("join", function (data) {
let chan = network.getChannel(data.channel);
if (typeof chan === "undefined") {

View file

@ -3,10 +3,10 @@
const Chan = require("../../models/chan");
const Msg = require("../../models/msg");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
irc.on("kick", function(data) {
irc.on("kick", function (data) {
const chan = network.getChannel(data.channel);
if (typeof chan === "undefined") {

View file

@ -12,7 +12,7 @@ const currentFetchPromises = new Map();
const imageTypeRegex = /^image\/.+/;
const mediaTypeRegex = /^(audio|video)\/.+/;
module.exports = function(client, chan, msg) {
module.exports = function (client, chan, msg) {
if (!Helper.config.prefetch) {
return;
}
@ -78,9 +78,7 @@ function parseHtml(preview, res, client) {
preview.type = "link";
preview.head =
$('meta[property="og:title"]').attr("content") ||
$("head > title, title")
.first()
.text() ||
$("head > title, title").first().text() ||
"";
preview.body =
$('meta[property="og:description"]').attr("content") ||
@ -136,7 +134,7 @@ function parseHtmlMedia($, preview, client) {
return;
}
$(`meta[property="og:${type}:type"]`).each(function(i) {
$(`meta[property="og:${type}:type"]`).each(function (i) {
const mimeType = $(this).attr("content");
if (mediaTypeRegex.test(mimeType)) {
@ -360,7 +358,7 @@ function fetch(uri, headers) {
});
gotStream
.on("response", function(res) {
.on("response", function (res) {
contentLength = parseInt(res.headers["content-length"], 10) || 0;
contentType = res.headers["content-type"];

View file

@ -2,11 +2,11 @@
const Chan = require("../../models/chan");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
const MAX_CHANS = 500;
irc.on("channel list start", function() {
irc.on("channel list start", function () {
network.chanCache = [];
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);
updateListStatus({
@ -22,7 +22,7 @@ module.exports = function(irc, network) {
});
});
irc.on("channel list end", function() {
irc.on("channel list end", function () {
updateListStatus(
network.chanCache.sort((a, b) => b.num_users - a.num_users).slice(0, MAX_CHANS)
);

View file

@ -7,10 +7,10 @@ const cleanIrcMessage = require("../../../client/js/helpers/ircmessageparser/cle
const Helper = require("../../helper");
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;
irc.on("notice", function(data) {
irc.on("notice", function (data) {
// Some servers send notices without any nickname
if (!data.nick) {
data.from_server = true;
@ -21,17 +21,17 @@ module.exports = function(irc, network) {
handleMessage(data);
});
irc.on("action", function(data) {
irc.on("action", function (data) {
data.type = Msg.Type.ACTION;
handleMessage(data);
});
irc.on("privmsg", function(data) {
irc.on("privmsg", function (data) {
data.type = Msg.Type.MESSAGE;
handleMessage(data);
});
irc.on("wallops", function(data) {
irc.on("wallops", function (data) {
data.from_server = true;
data.type = Msg.Type.NOTICE;
handleMessage(data);
@ -47,7 +47,7 @@ module.exports = function(irc, network) {
// Check if the sender is in our ignore list
const shouldIgnore =
!self &&
network.ignoreList.some(function(entry) {
network.ignoreList.some(function (entry) {
return Helper.compareHostmask(entry, data);
});

View file

@ -3,14 +3,14 @@
const _ = require("lodash");
const Msg = require("../../models/msg");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
// The following saves the channel key based on channel mode instead of
// extracting it from `/join #channel key`. This lets us not have to
// temporarily store the key until successful join, but also saves the key
// 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) {
return;
}
@ -39,7 +39,7 @@ module.exports = function(irc, network) {
targetChan.pushMessage(client, msg);
});
irc.on("mode", function(data) {
irc.on("mode", function (data) {
let targetChan;
if (data.target === irc.user.nick) {
@ -113,7 +113,7 @@ module.exports = function(irc, network) {
_.pull(user.modes, changedMode);
} else if (!user.modes.includes(changedMode)) {
user.modes.push(changedMode);
user.modes.sort(function(a, b) {
user.modes.sort(function (a, b) {
return userModeSortPriority[a] - userModeSortPriority[b];
});
}

View file

@ -3,7 +3,7 @@
const Chan = require("../../models/chan");
const Msg = require("../../models/msg");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
irc.on("banlist", (list) => {

View file

@ -2,10 +2,10 @@
const Msg = require("../../models/msg");
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
irc.on("motd", function(data) {
irc.on("motd", function (data) {
const lobby = network.channels[0];
if (data.motd) {

View file

@ -1,9 +1,9 @@
"use strict";
module.exports = function(irc, network) {
module.exports = function (irc, network) {
const client = this;
irc.on("userlist", function(data) {
irc.on("userlist", function (data) {
const chan = network.getChannel(data.channel);
if (typeof chan === "undefined") {

Some files were not shown because too many files have changed in this diff Show more