serverless-ircd 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +6 -1
- package/.gitmodules +3 -0
- package/CHANGELOG.md +214 -0
- package/README.md +110 -23
- package/apps/aws-stack/package.json +1 -1
- package/apps/cf-tcp-container/package.json +1 -1
- package/apps/cf-worker/package.json +1 -1
- package/apps/cf-worker/src/origin-allowlist.ts +99 -0
- package/apps/cf-worker/src/worker.ts +89 -9
- package/apps/cf-worker/tests/fixtures/web-dist/app/index.html +18 -0
- package/apps/cf-worker/tests/fixtures/web-dist/index.html +18 -0
- package/apps/cf-worker/tests/origin-allowlist.test.ts +101 -0
- package/apps/cf-worker/tests/smoke.test.ts +28 -2
- package/apps/cf-worker/tests/ws-origin.test.ts +89 -0
- package/apps/cf-worker/wrangler.test.toml +23 -0
- package/apps/cf-worker/wrangler.toml +54 -0
- package/apps/local-cli/package.json +1 -1
- package/apps/web/landing/index.html +217 -0
- package/apps/web/package.json +28 -0
- package/apps/web/scripts/build.mjs +125 -0
- package/apps/web/src/build-env.ts +43 -0
- package/apps/web/src/config-schema.ts +138 -0
- package/apps/web/static/config.json +28 -0
- package/apps/web/static/config.prod.json +28 -0
- package/apps/web/static/config.staging.json +28 -0
- package/apps/web/tests/build-env.test.ts +63 -0
- package/apps/web/tests/build-smoke.test.ts +103 -0
- package/apps/web/tests/config-schema.test.ts +432 -0
- package/apps/web/tests/workspace.test.ts +12 -0
- package/apps/web/tsconfig.json +10 -0
- package/apps/web/upstream/.browserslistrc +3 -0
- package/apps/web/upstream/.editorconfig +9 -0
- package/apps/web/upstream/.eslintignore +3 -0
- package/apps/web/upstream/.eslintrc.js +90 -0
- package/apps/web/upstream/.github/FUNDING.yml +12 -0
- package/apps/web/upstream/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/apps/web/upstream/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/apps/web/upstream/.github/workflows/push.yml +26 -0
- package/apps/web/upstream/.github/workflows/release.yml +33 -0
- package/apps/web/upstream/.github/workflows/release_manual.yml +55 -0
- package/apps/web/upstream/.prettierrc.js +9 -0
- package/apps/web/upstream/.stylelintignore +5 -0
- package/apps/web/upstream/.stylelintrc.js +21 -0
- package/apps/web/upstream/LICENSE +201 -0
- package/apps/web/upstream/README.md +76 -0
- package/apps/web/upstream/babel.config.js +25 -0
- package/apps/web/upstream/crowdin.yml +3 -0
- package/apps/web/upstream/index.html +35 -0
- package/apps/web/upstream/jest.config.js +7 -0
- package/apps/web/upstream/jsdoc.json +22 -0
- package/apps/web/upstream/package.json +80 -0
- package/apps/web/upstream/scripts/pre-commit +43 -0
- package/apps/web/upstream/src/components/App.vue +516 -0
- package/apps/web/upstream/src/components/AppSettings.vue +587 -0
- package/apps/web/upstream/src/components/AutoComplete.vue +284 -0
- package/apps/web/upstream/src/components/Avatar.vue +105 -0
- package/apps/web/upstream/src/components/AwayStatusIndicator.vue +77 -0
- package/apps/web/upstream/src/components/BufferKey.vue +121 -0
- package/apps/web/upstream/src/components/BufferSettings.vue +97 -0
- package/apps/web/upstream/src/components/Captcha.vue +85 -0
- package/apps/web/upstream/src/components/ChannelBanlist.vue +96 -0
- package/apps/web/upstream/src/components/ChannelInfo.vue +159 -0
- package/apps/web/upstream/src/components/ChannelInvitelist.vue +276 -0
- package/apps/web/upstream/src/components/ChannelList.vue +345 -0
- package/apps/web/upstream/src/components/Container.vue +401 -0
- package/apps/web/upstream/src/components/ContainerHeader.vue +522 -0
- package/apps/web/upstream/src/components/ControlInput.vue +1016 -0
- package/apps/web/upstream/src/components/LoadingAnimation.vue +104 -0
- package/apps/web/upstream/src/components/MediaViewer.vue +199 -0
- package/apps/web/upstream/src/components/MessageInfo.vue +192 -0
- package/apps/web/upstream/src/components/MessageList.vue +1028 -0
- package/apps/web/upstream/src/components/MessageListAvatar.vue +20 -0
- package/apps/web/upstream/src/components/MessageListMessageCompact.vue +361 -0
- package/apps/web/upstream/src/components/MessageListMessageInline.vue +257 -0
- package/apps/web/upstream/src/components/MessageListMessageModern.vue +430 -0
- package/apps/web/upstream/src/components/NetworkSettings.vue +528 -0
- package/apps/web/upstream/src/components/Nicklist.vue +309 -0
- package/apps/web/upstream/src/components/NicklistUser.vue +181 -0
- package/apps/web/upstream/src/components/NotConnected.vue +271 -0
- package/apps/web/upstream/src/components/SelfUser.vue +283 -0
- package/apps/web/upstream/src/components/ServerSelector.vue +162 -0
- package/apps/web/upstream/src/components/ServerView.vue +126 -0
- package/apps/web/upstream/src/components/SettingsAdvanced.vue +232 -0
- package/apps/web/upstream/src/components/SettingsAliases.vue +121 -0
- package/apps/web/upstream/src/components/Sidebar.vue +429 -0
- package/apps/web/upstream/src/components/SidebarAboutBuffer.vue +288 -0
- package/apps/web/upstream/src/components/SidebarState.vue +145 -0
- package/apps/web/upstream/src/components/StartupError.vue +35 -0
- package/apps/web/upstream/src/components/StateBrowser.vue +420 -0
- package/apps/web/upstream/src/components/StateBrowserBuffer.vue +124 -0
- package/apps/web/upstream/src/components/StateBrowserNetwork.vue +823 -0
- package/apps/web/upstream/src/components/StateBrowserUsermenu.vue +162 -0
- package/apps/web/upstream/src/components/TypingStatusIndicator.vue +34 -0
- package/apps/web/upstream/src/components/TypingUsersList.vue +56 -0
- package/apps/web/upstream/src/components/UrlEmbed.vue +149 -0
- package/apps/web/upstream/src/components/UserBox.vue +728 -0
- package/apps/web/upstream/src/components/inputtools/Emoji.vue +67 -0
- package/apps/web/upstream/src/components/inputtools/TextStyle.vue +142 -0
- package/apps/web/upstream/src/components/startups/CommonLayout.vue +208 -0
- package/apps/web/upstream/src/components/startups/CustomServer.vue +495 -0
- package/apps/web/upstream/src/components/startups/KiwiBnc.vue +361 -0
- package/apps/web/upstream/src/components/startups/Personal.vue +317 -0
- package/apps/web/upstream/src/components/startups/Welcome.vue +544 -0
- package/apps/web/upstream/src/components/startups/ZncLogin.vue +229 -0
- package/apps/web/upstream/src/components/utils/InputConfirm.vue +68 -0
- package/apps/web/upstream/src/components/utils/InputPrompt.vue +118 -0
- package/apps/web/upstream/src/components/utils/InputText.vue +172 -0
- package/apps/web/upstream/src/components/utils/IrcInput.vue +579 -0
- package/apps/web/upstream/src/components/utils/PluginWrapper.vue +26 -0
- package/apps/web/upstream/src/components/utils/TabbedView.vue +149 -0
- package/apps/web/upstream/src/components/utils/TransitionExpand.vue +97 -0
- package/apps/web/upstream/src/helpers/Colours.js +128 -0
- package/apps/web/upstream/src/helpers/IrcdDiffs.js +26 -0
- package/apps/web/upstream/src/helpers/Md5.js +193 -0
- package/apps/web/upstream/src/helpers/Misc.js +401 -0
- package/apps/web/upstream/src/helpers/TextFormatting.js +237 -0
- package/apps/web/upstream/src/libs/AliasRewriter.js +157 -0
- package/apps/web/upstream/src/libs/AudioManager.js +60 -0
- package/apps/web/upstream/src/libs/BouncerMiddleware.js +247 -0
- package/apps/web/upstream/src/libs/BouncerProvider.js +551 -0
- package/apps/web/upstream/src/libs/ChathistoryMiddleware.js +153 -0
- package/apps/web/upstream/src/libs/ConfigLoader.js +94 -0
- package/apps/web/upstream/src/libs/EmojiProvider.js +46 -0
- package/apps/web/upstream/src/libs/GlobalApi.js +346 -0
- package/apps/web/upstream/src/libs/IPC.js +51 -0
- package/apps/web/upstream/src/libs/InputHandler.js +921 -0
- package/apps/web/upstream/src/libs/IrcClient.js +1506 -0
- package/apps/web/upstream/src/libs/Logger.js +71 -0
- package/apps/web/upstream/src/libs/Message.js +169 -0
- package/apps/web/upstream/src/libs/MessageFormatter.js +364 -0
- package/apps/web/upstream/src/libs/MessageParser.js +249 -0
- package/apps/web/upstream/src/libs/Notifications.js +78 -0
- package/apps/web/upstream/src/libs/ServerConnection.js +270 -0
- package/apps/web/upstream/src/libs/ServerSession.js +102 -0
- package/apps/web/upstream/src/libs/SoundBleep.js +20 -0
- package/apps/web/upstream/src/libs/StatePersistence.js +90 -0
- package/apps/web/upstream/src/libs/ThemeManager.js +128 -0
- package/apps/web/upstream/src/libs/TypingMiddleware.js +105 -0
- package/apps/web/upstream/src/libs/WindowTitle.js +63 -0
- package/apps/web/upstream/src/libs/batchedAdd.js +74 -0
- package/apps/web/upstream/src/libs/bufferTools.js +177 -0
- package/apps/web/upstream/src/libs/polyfill/Element.closest.js +18 -0
- package/apps/web/upstream/src/libs/renderers/Html.js +113 -0
- package/apps/web/upstream/src/libs/settingTools.js +31 -0
- package/apps/web/upstream/src/libs/state/BufferState.js +703 -0
- package/apps/web/upstream/src/libs/state/NetworkState.js +158 -0
- package/apps/web/upstream/src/libs/state/UserState.js +89 -0
- package/apps/web/upstream/src/libs/state/common.js +26 -0
- package/apps/web/upstream/src/libs/state.js +961 -0
- package/apps/web/upstream/src/libs/storage/Local.js +51 -0
- package/apps/web/upstream/src/main.js +566 -0
- package/apps/web/upstream/src/res/autocompleteCommands.js +31 -0
- package/apps/web/upstream/src/res/configTemplates.js +373 -0
- package/apps/web/upstream/src/res/globalStyle.css +277 -0
- package/apps/web/upstream/src/res/kiwiLoadingLogo.png +0 -0
- package/apps/web/upstream/src/res/locales/app.af-ZA.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.ar-SA.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.bg-BG.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.bs-BA.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.ca-ES.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.cs-CZ.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.da-DK.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.de-DE.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.dev.po +1246 -0
- package/apps/web/upstream/src/res/locales/app.el-GR.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.en-US.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.es-419.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.es-AR.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.es-EM.po +536 -0
- package/apps/web/upstream/src/res/locales/app.es-ES.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.es-US.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.eu-ES.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.fi-FI.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.fr-FR.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.gl-ES.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.he-IL.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.hi-IN.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.hu-HU.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.id-ID.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.it-IT.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.ja-JP.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.ko-KR.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.nl-NL.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.no-NO.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.pl-PL.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.pt-BR.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.pt-PT.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.ro-RO.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.ru-RU.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.sl-SI.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.sq-AL.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.sr-SP.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.sv-SE.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.tr-TR.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.uk-UA.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.vi-VN.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.zh-CN.po +1145 -0
- package/apps/web/upstream/src/res/locales/app.zh-TW.po +1145 -0
- package/apps/web/upstream/src/res/localesList.json +27 -0
- package/apps/web/upstream/src/res/logo.png +0 -0
- package/apps/web/upstream/src/thirdparty/about.html +43 -0
- package/apps/web/upstream/src/thirdparty/index.js +5 -0
- package/apps/web/upstream/src/thirdparty/kiwiirccom.vue +185 -0
- package/apps/web/upstream/static/config.json +28 -0
- package/apps/web/upstream/static/emoticons/smile.png +0 -0
- package/apps/web/upstream/static/favicon.png +0 -0
- package/apps/web/upstream/static/highlight.mp3 +0 -0
- package/apps/web/upstream/static/highlight.ogg +0 -0
- package/apps/web/upstream/static/locales/.gitignore +2 -0
- package/apps/web/upstream/static/plugins/customise.html.example +10 -0
- package/apps/web/upstream/static/themes/coffee/theme.css +145 -0
- package/apps/web/upstream/static/themes/common/base.css +1064 -0
- package/apps/web/upstream/static/themes/dark/theme.css +196 -0
- package/apps/web/upstream/static/themes/default/theme.css +92 -0
- package/apps/web/upstream/static/themes/elite/theme.css +248 -0
- package/apps/web/upstream/static/themes/grayfox/theme.css +143 -0
- package/apps/web/upstream/static/themes/nightswatch/theme.css +367 -0
- package/apps/web/upstream/static/themes/osprey/theme.css +115 -0
- package/apps/web/upstream/static/themes/radioactive/theme.css +1211 -0
- package/apps/web/upstream/static/themes/sky/theme.css +107 -0
- package/apps/web/upstream/tests/unit/BatchAdd.spec.js +174 -0
- package/apps/web/upstream/tests/unit/MessageParser.spec.js +125 -0
- package/apps/web/upstream/tests/unit/Misc.spec.js +24 -0
- package/apps/web/upstream/tests/unit/NetworkState.spec.js +58 -0
- package/apps/web/upstream/tests/unit/StartupError.spec.js +20 -0
- package/apps/web/upstream/vue.config.js +150 -0
- package/apps/web/upstream/yarn.lock +9767 -0
- package/apps/web/vitest.config.ts +13 -0
- package/biome.json +1 -0
- package/docs/Home.md +1 -0
- package/docs/WebClientGuide.md +535 -0
- package/package.json +2 -2
- package/packages/aws-adapter/package.json +1 -1
- package/packages/cf-adapter/package.json +1 -1
- package/packages/cf-adapter/tests/cf-harness.ts +12 -1
- package/packages/in-memory-runtime/package.json +1 -1
- package/packages/irc-core/package.json +1 -1
- package/packages/irc-core/reports/mutation/mutation.html +342 -0
- package/packages/irc-core/tests/batch.test.ts +15 -0
- package/packages/irc-core/tests/numerics.test.ts +13 -0
- package/packages/irc-core/tests/parser.test.ts +109 -0
- package/packages/irc-server/package.json +1 -1
- package/packages/irc-test-support/package.json +1 -1
- package/packages/irc-test-support/src/scenarios.ts +24 -2
- package/tools/ci-hardening/package.json +1 -1
- package/tools/load-test/package.json +1 -1
- package/tools/tcp-ws-forwarder/package.json +1 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/** @module */
|
|
2
|
+
|
|
3
|
+
import Vue from 'vue';
|
|
4
|
+
import { def } from './common';
|
|
5
|
+
import * as IrcClient from '../IrcClient';
|
|
6
|
+
|
|
7
|
+
/** The IRC network instance */
|
|
8
|
+
export default class NetworkState {
|
|
9
|
+
constructor(id, appState, userDict, bufferDict) {
|
|
10
|
+
// Enumerable properties that become reactive under Vue
|
|
11
|
+
this.id = id;
|
|
12
|
+
this.name = '';
|
|
13
|
+
this.editable_name = false;
|
|
14
|
+
// State of the transport
|
|
15
|
+
this.state = 'disconnected';
|
|
16
|
+
this.state_error = '';
|
|
17
|
+
// Last error from the IRC server. Resets on reconnect
|
|
18
|
+
this.last_error = '';
|
|
19
|
+
this.auto_commands = '';
|
|
20
|
+
this.is_znc = false;
|
|
21
|
+
this.is_bnc = false;
|
|
22
|
+
this.hidden = false;
|
|
23
|
+
this.channel_list = [];
|
|
24
|
+
this.channel_list_state = '';
|
|
25
|
+
// The IRCd type as mentioned in the 002 numeric
|
|
26
|
+
this.ircd = '';
|
|
27
|
+
this.connection = {
|
|
28
|
+
server: '',
|
|
29
|
+
port: 6667,
|
|
30
|
+
tls: false,
|
|
31
|
+
path: '',
|
|
32
|
+
// Server password
|
|
33
|
+
password: '',
|
|
34
|
+
direct: false,
|
|
35
|
+
encoding: 'utf8',
|
|
36
|
+
bncnetid: '',
|
|
37
|
+
nick: '',
|
|
38
|
+
};
|
|
39
|
+
this.settings = {
|
|
40
|
+
show_raw_caps: false,
|
|
41
|
+
};
|
|
42
|
+
this.nick = '';
|
|
43
|
+
this.username = '';
|
|
44
|
+
this.gecos = '';
|
|
45
|
+
// SASL password
|
|
46
|
+
this.account = {
|
|
47
|
+
account: '',
|
|
48
|
+
password: '',
|
|
49
|
+
};
|
|
50
|
+
this.password = '';
|
|
51
|
+
this.away = '';
|
|
52
|
+
|
|
53
|
+
Vue.observable(this);
|
|
54
|
+
|
|
55
|
+
// Some non-enumerable properties (vues $watch won't cover these properties)
|
|
56
|
+
def(this, 'appState', appState, false);
|
|
57
|
+
def(this, 'userDict', userDict, false);
|
|
58
|
+
def(this, 'bufferDict', bufferDict, false);
|
|
59
|
+
def(this, 'frameworkClient', null, true);
|
|
60
|
+
|
|
61
|
+
def(this, 'users', Object.create(null), (newVal) => {
|
|
62
|
+
appState.$set(userDict.networks, this.id, newVal);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Pending prviate messages awaiting whois operator check
|
|
66
|
+
def(this, 'pendingPms', [], false);
|
|
67
|
+
|
|
68
|
+
bufferDict.$set(bufferDict.networks, this.id, []);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get ircClient() {
|
|
72
|
+
if (!this.frameworkClient) {
|
|
73
|
+
this.frameworkClient = IrcClient.create(this.appState, this);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return this.frameworkClient;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get buffers() {
|
|
80
|
+
return this.bufferDict.networks[this.id];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
connect(...args) {
|
|
84
|
+
this.ircClient.connect(...args);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
bufferByName(name) {
|
|
88
|
+
return this.appState.getBufferByName(this.id, name);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
serverBuffer() {
|
|
92
|
+
return this.appState.getBufferByName(this.id, '*');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
setting(name, val) {
|
|
96
|
+
if (typeof val !== 'undefined') {
|
|
97
|
+
this.appState.$set(this.settings, name, val);
|
|
98
|
+
return val;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return this.settings[name];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
isChannelName(input) {
|
|
105
|
+
if (typeof input !== 'string' || !input) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let chanPrefixes = this.ircClient.network.supports('CHANTYPES') || '#&';
|
|
110
|
+
return chanPrefixes.indexOf(input[0]) > -1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
showServerBuffer(tabName) {
|
|
114
|
+
this.appState.$emit('active.component', null);
|
|
115
|
+
this.appState.setActiveBuffer(this.id, this.serverBuffer().name);
|
|
116
|
+
// Hacky, but the server buffer component listens for events to switch
|
|
117
|
+
// between tabs
|
|
118
|
+
setImmediate(() => {
|
|
119
|
+
this.appState.$emit('server.tab.show', tabName || 'settings');
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Check if a nick is exempt from block PM's
|
|
125
|
+
* @param {String} nick of the user to check
|
|
126
|
+
* @returns {Boolean} If the boolean is null a whois check is required
|
|
127
|
+
*/
|
|
128
|
+
isNickExemptFromPmBlocks(nick) {
|
|
129
|
+
// Check if nick is op of shared channel
|
|
130
|
+
let buffers = this.appState.getBuffersWithUser(this.id, nick);
|
|
131
|
+
for (let i = 0; i < buffers.length; i++) {
|
|
132
|
+
let buffer = buffers[i];
|
|
133
|
+
if (buffer.isUserAnOp(nick)) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let user = this.appState.getUser(this.id, nick);
|
|
139
|
+
if (!user || !user.hasWhois) {
|
|
140
|
+
// if we have not seen or whois the user they might be a network oper
|
|
141
|
+
// so return null then a whois can be performed
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (user.operator) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
currentUser() {
|
|
152
|
+
return this.appState.getUser(this.id, this.nick);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
userByName(nick) {
|
|
156
|
+
return this.appState.getUser(this.id, nick);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** @module */
|
|
2
|
+
|
|
3
|
+
import Vue from 'vue';
|
|
4
|
+
import * as TextFormatting from '@/helpers/TextFormatting';
|
|
5
|
+
import { def } from './common';
|
|
6
|
+
|
|
7
|
+
export default class UserState {
|
|
8
|
+
constructor(user) {
|
|
9
|
+
this.key = user.nick.toUpperCase();
|
|
10
|
+
this.nick = user.nick;
|
|
11
|
+
this.host = user.host || '';
|
|
12
|
+
this.username = user.username || '';
|
|
13
|
+
this.realname = user.realname || '';
|
|
14
|
+
this.modes = user.modes || '';
|
|
15
|
+
this.away = user.away || '';
|
|
16
|
+
this.colour = user.colour || '';
|
|
17
|
+
this.account = user.account || '';
|
|
18
|
+
this.buffers = Object.create(null);
|
|
19
|
+
this.hasWhois = false;
|
|
20
|
+
this.typingState = Object.create(null);
|
|
21
|
+
this.avatar = user.avatar || { small: '', large: '' };
|
|
22
|
+
this.ignore = false;
|
|
23
|
+
|
|
24
|
+
Vue.observable(this);
|
|
25
|
+
|
|
26
|
+
// Whois details are non-enumerable properties (vues $watch won't cover these properties)
|
|
27
|
+
def(this, 'actual_host', '', true);
|
|
28
|
+
def(this, 'helpop', '', true);
|
|
29
|
+
def(this, 'bot', '', true);
|
|
30
|
+
def(this, 'server', '', true);
|
|
31
|
+
def(this, 'server_info', '', true);
|
|
32
|
+
def(this, 'operator', '', true);
|
|
33
|
+
def(this, 'channels', '', true);
|
|
34
|
+
def(this, 'modes', '', true);
|
|
35
|
+
def(this, 'idle', '', true);
|
|
36
|
+
def(this, 'logon', '', true);
|
|
37
|
+
def(this, 'registered_nick', '', true);
|
|
38
|
+
def(this, 'secure', '', true);
|
|
39
|
+
def(this, 'special', '', true);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getColour() {
|
|
43
|
+
if (!this.colour) {
|
|
44
|
+
this.colour = TextFormatting.createNickColour(this.nick);
|
|
45
|
+
}
|
|
46
|
+
// default will use the themes default text colour
|
|
47
|
+
return this.colour === 'default' ? '' : this.colour;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
isAway() {
|
|
51
|
+
return !!this.away;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
typingStatus(_target, status) {
|
|
55
|
+
let target = _target.toUpperCase();
|
|
56
|
+
if (!status) {
|
|
57
|
+
return this.typingState[target] || { status: '' };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let typing = this.typingState[target];
|
|
61
|
+
if (!typing) {
|
|
62
|
+
Vue.set(this.typingState, target, { started: 0, status: '' });
|
|
63
|
+
typing = this.typingState[target];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (typing.timeout) {
|
|
67
|
+
clearTimeout(typing.timeout);
|
|
68
|
+
typing.timeout = null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (status === 'done') {
|
|
72
|
+
Vue.delete(this.typingState, target);
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
typing.started = Date.now();
|
|
77
|
+
typing.status = status;
|
|
78
|
+
|
|
79
|
+
// Paused state gets a longer timeout as it's usually someone stopping typing
|
|
80
|
+
// to think about their words
|
|
81
|
+
let timeoutLen = status === 'paused' ?
|
|
82
|
+
30000 :
|
|
83
|
+
6000;
|
|
84
|
+
|
|
85
|
+
typing.timeout = setTimeout(() => this.typingStatus(target, 'done'), timeoutLen);
|
|
86
|
+
|
|
87
|
+
return typing;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Define a non-enumerable property on an object with an optional setter callback
|
|
2
|
+
export function def(target, key, value, canSet) {
|
|
3
|
+
let val = value;
|
|
4
|
+
|
|
5
|
+
let definition = {
|
|
6
|
+
get() {
|
|
7
|
+
return val;
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
if (canSet) {
|
|
12
|
+
definition.set = function set(newVal) {
|
|
13
|
+
let oldVal = val;
|
|
14
|
+
val = newVal;
|
|
15
|
+
if (typeof canSet === 'function') {
|
|
16
|
+
canSet(newVal, oldVal);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Object.defineProperty(target, key, definition);
|
|
22
|
+
|
|
23
|
+
if (typeof canSet === 'function') {
|
|
24
|
+
canSet(val);
|
|
25
|
+
}
|
|
26
|
+
}
|