aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2020-02-19 18:30:51 +0100
committerGitHub <noreply@github.com>2020-02-19 18:30:51 +0100
commit133740a2504ec87a8361f696329f0797946af677 (patch)
treefa3066af4644dbac8bd31d8c21d6f235a716dce3 /server
parentMerge pull request #84 from MinusGix/master (diff)
parentFix usage of double-equals-comparison to triple-equals (diff)
downloadhackchat-133740a2504ec87a8361f696329f0797946af677.tar.gz
hackchat-133740a2504ec87a8361f696329f0797946af677.zip
Merge pull request #85 from MinusGix/add_channel_invite
Add ability to specify the channel that the invite command invites the user to
Diffstat (limited to '')
-rw-r--r--server/src/commands/core/invite.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/server/src/commands/core/invite.js b/server/src/commands/core/invite.js
index 1811e8b..b594586 100644
--- a/server/src/commands/core/invite.js
+++ b/server/src/commands/core/invite.js
@@ -25,8 +25,12 @@ export async function run(core, server, socket, data) {
return true;
}
- // generate common channel
- const channel = Math.random().toString(36).substr(2, 8);
+ let channel;
+ if (typeof data.to === 'string') {
+ channel = data.to;
+ } else {
+ channel = Math.random().toString(36).substr(2, 8);
+ }
// build and send invite
const payload = {
@@ -67,7 +71,7 @@ export async function run(core, server, socket, data) {
export const requiredData = ['nick'];
export const info = {
name: 'invite',
- description: 'Generates a unique (more or less) room name and passes it to two clients',
+ description: 'Sends an invite to the target client with the provided channel, or a random channel.',
usage: `
- API: { cmd: 'invite', nick: '<target nickname>' }`,
+ API: { cmd: 'invite', nick: '<target nickname>', to: '<optional destination channel>' }`,
};