Commit aa71205f authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Include username and id in group and user actions.

parent 74b3683c
......@@ -451,15 +451,17 @@ ServerConnection.prototype.chat = function(username, kind, dest, value) {
/**
* userAction sends a request to act on a user.
*
* @param {string} username - The sender's username.
* @param {string} kind - One of "op", "unop", "kick", "present", "unpresent".
* @param {string} dest - The id of the user to act upon.
* @param {string} [value] - An optional user-readable message.
*/
ServerConnection.prototype.userAction = function(kind, dest, value) {
ServerConnection.prototype.userAction = function(username, kind, dest, value) {
this.send({
type: 'useraction',
id: this.id,
dest: dest,
username: username,
kind: kind,
value: value,
});
......@@ -468,15 +470,17 @@ ServerConnection.prototype.userAction = function(kind, dest, value) {
/**
* userMessage sends an application-specific message to a user.
*
* @param {string} username - The sender's username.
* @param {string} kind - The kind of application-specific message.
* @param {string} dest - The id of the user to send the message to.
* @param {string} [value] - An optional parameter.
*/
ServerConnection.prototype.userMessage = function(kind, dest, value) {
ServerConnection.prototype.userMessage = function(username, kind, dest, value) {
this.send({
type: 'usermessage',
id: this.id,
dest: dest,
username: username,
kind: kind,
value: value,
});
......@@ -485,14 +489,17 @@ ServerConnection.prototype.userMessage = function(kind, dest, value) {
/**
* groupAction sends a request to act on the current group.
*
* @param {string} username - The sender's username.
* @param {string} kind - One of "clearchat", "lock", "unlock", "record or
* "unrecord".
* @param {string} [message] - An optional user-readable message.
*/
ServerConnection.prototype.groupAction = function(kind, message) {
ServerConnection.prototype.groupAction = function(username, kind, message) {
this.send({
type: 'groupaction',
id: this.id,
kind: kind,
username: username,
value: message,
});
};
......
......@@ -1660,7 +1660,7 @@ commands.clear = {
predicate: operatorPredicate,
description: 'clear the chat history',
f: (c, r) => {
serverConnection.groupAction('clearchat');
serverConnection.groupAction(getUsername(), 'clearchat');
}
};
......@@ -1669,7 +1669,7 @@ commands.lock = {
description: 'lock this group',
parameters: '[message]',
f: (c, r) => {
serverConnection.groupAction('lock', r);
serverConnection.groupAction(getUsername(), 'lock', r);
}
};
......@@ -1677,7 +1677,7 @@ commands.unlock = {
predicate: operatorPredicate,
description: 'unlock this group, revert the effect of /lock',
f: (c, r) => {
serverConnection.groupAction('unlock');
serverConnection.groupAction(getUsername(), 'unlock');
}
};
......@@ -1685,7 +1685,7 @@ commands.record = {
predicate: recordingPredicate,
description: 'start recording',
f: (c, r) => {
serverConnection.groupAction('record');
serverConnection.groupAction(getUsername(), 'record');
}
};
......@@ -1693,7 +1693,7 @@ commands.unrecord = {
predicate: recordingPredicate,
description: 'stop recording',
f: (c, r) => {
serverConnection.groupAction('unrecord');
serverConnection.groupAction(getUsername(), 'unrecord');
}
};
......@@ -1773,7 +1773,7 @@ function userCommand(c, r) {
let id = findUserId(p[0]);
if(!id)
throw new Error(`Unknown user ${p[0]}`);
serverConnection.userAction(c, id, p[1]);
serverConnection.userAction(getUsername(), c, id, p[1]);
}
function userMessage(c, r) {
......@@ -1783,7 +1783,7 @@ function userMessage(c, r) {
let id = findUserId(p[0]);
if(!id)
throw new Error(`Unknown user ${p[0]}`);
serverConnection.userMessage(c, id, p[1]);
serverConnection.userMessage(getUsername(), c, id, p[1]);
}
commands.kick = {
......@@ -2108,11 +2108,11 @@ async function serverConnect() {
serverConnection.onchat = addToChatbox;
serverConnection.onclearchat = clearChat;
serverConnection.onusermessage = function(id, dest, username, time, priviledged, kind, message) {
let from = id ? (username || 'Anonymous') : 'The Server';
switch(kind) {
case 'error':
case 'warning':
case 'info':
let from = id ? (username || 'Anonymous') : 'The Server';
if(priviledged)
displayError(`${from} said: ${message}`, kind);
else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment