aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/mod
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2020-03-12 16:57:52 +0100
committerGitHub <noreply@github.com>2020-03-12 16:57:52 +0100
commit033a6fbc4d6639765c56d58d5f8c87cf1d4d6ff6 (patch)
tree16fa02be62ec3e1702bac97a72dcd2524519b304 /server/src/commands/mod
parentMerge pull request #92 from MinusGix/tripInfo (diff)
parentMake dumb use abstracted invite functions rather than duplicating code (diff)
downloadhackchat-033a6fbc4d6639765c56d58d5f8c87cf1d4d6ff6.tar.gz
hackchat-033a6fbc4d6639765c56d58d5f8c87cf1d4d6ff6.zip
Merge pull request #93 from MinusGix/inviteRework
Abstract invite functions, and make dumb.js use them
Diffstat (limited to '')
-rw-r--r--server/src/commands/mod/dumb.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/server/src/commands/mod/dumb.js b/server/src/commands/mod/dumb.js
index 488ed9e..51fc745 100644
--- a/server/src/commands/mod/dumb.js
+++ b/server/src/commands/mod/dumb.js
@@ -4,6 +4,7 @@
*/
import * as UAC from '../utility/UAC/_info';
+import * as Invite from '../core/invite';
// module constructor
export function init(core) {
@@ -117,19 +118,21 @@ export function chatCheck(core, server, socket, payload) {
// shadow-prevent all invites from muzzled users
export function inviteCheck(core, server, socket, payload) {
- if (typeof payload.nick !== 'string') {
- return false;
- }
-
if (core.muzzledHashes[socket.hash]) {
+ const nickValid = Invite.checkNickname(payload.nick);
+ if (nickValid !== null) {
+ server.reply({
+ cmd: 'warn',
+ text: nickValid,
+ }, socket);
+ return false;
+ }
+
// generate common channel
- const channel = Math.random().toString(36).substr(2, 8);
+ const channel = Invite.getChannel();
// send fake reply
- server.reply({
- cmd: 'info',
- text: `You invited ${payload.nick} to ?${channel}`,
- }, socket);
+ server.reply(Invite.createSuccessPayload(payload.nick, channel), socket);
return false;
}