Skip to content

Commit

Permalink
Make dumb use abstracted invite functions rather than duplicating code
Browse files Browse the repository at this point in the history
  • Loading branch information
MinusGix committed Mar 6, 2020
1 parent f2ad0e5 commit 1d01376
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions server/src/commands/mod/dumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import * as UAC from '../utility/UAC/_info';
import * as Invite from '../core/invite';

// module constructor
export function init(core) {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1d01376

Please sign in to comment.