mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Allow anonymous users to chat.
This commit is contained in:
parent
2b4372ad87
commit
69540e23af
2 changed files with 7 additions and 16 deletions
4
README
4
README
|
@ -106,9 +106,7 @@ fields, all of which are optional.
|
||||||
- `max-history-age`: the time, in seconds, during which chat history is
|
- `max-history-age`: the time, in seconds, during which chat history is
|
||||||
kept (default 14400, i.e. 4 hours);
|
kept (default 14400, i.e. 4 hours);
|
||||||
- `allow-recording`: if true, then recording is allowed in this group;
|
- `allow-recording`: if true, then recording is allowed in this group;
|
||||||
- `allow-anonymous`: if true, then users may connect with an empty
|
- `allow-anonymous`: if true, then users may connect with an empty username.
|
||||||
username; this is not recommended, since anonymous users are not
|
|
||||||
allowed to participate in the chat;
|
|
||||||
- `redirect`: if set, then attempts to join the group will be redirected
|
- `redirect`: if set, then attempts to join the group will be redirected
|
||||||
to the given URL; most other fields are ignored in this case.
|
to the given URL; most other fields are ignored in this case.
|
||||||
|
|
||||||
|
|
|
@ -1275,12 +1275,14 @@ function addToChatbox(peerId, dest, nick, time, kind, message) {
|
||||||
|
|
||||||
if(kind !== 'me') {
|
if(kind !== 'me') {
|
||||||
let p = formatLines(message.split('\n'));
|
let p = formatLines(message.split('\n'));
|
||||||
if(lastMessage.nick !== nick ||
|
if(lastMessage.nick !== (nick || null) ||
|
||||||
lastMessage.peerId !== peerId ||
|
lastMessage.peerId !== peerId ||
|
||||||
lastMessage.dest !== (dest || null)) {
|
lastMessage.dest !== (dest || null)) {
|
||||||
let header = document.createElement('p');
|
let header = document.createElement('p');
|
||||||
let user = document.createElement('span');
|
let user = document.createElement('span');
|
||||||
user.textContent = dest ? `${nick} \u2192 ${users[dest]}` : nick;
|
user.textContent = dest ?
|
||||||
|
`${nick||'(anon)'} \u2192 ${users[dest]||'(anon)'}` :
|
||||||
|
(nick || '(anon)');
|
||||||
user.classList.add('message-user');
|
user.classList.add('message-user');
|
||||||
header.appendChild(user);
|
header.appendChild(user);
|
||||||
if(time) {
|
if(time) {
|
||||||
|
@ -1294,7 +1296,7 @@ function addToChatbox(peerId, dest, nick, time, kind, message) {
|
||||||
}
|
}
|
||||||
p.classList.add('message-content');
|
p.classList.add('message-content');
|
||||||
container.appendChild(p);
|
container.appendChild(p);
|
||||||
lastMessage.nick = nick;
|
lastMessage.nick = (nick || null);
|
||||||
lastMessage.peerId = peerId;
|
lastMessage.peerId = peerId;
|
||||||
lastMessage.dest = (dest || null);
|
lastMessage.dest = (dest || null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1302,7 +1304,7 @@ function addToChatbox(peerId, dest, nick, time, kind, message) {
|
||||||
asterisk.textContent = '*';
|
asterisk.textContent = '*';
|
||||||
asterisk.classList.add('message-me-asterisk');
|
asterisk.classList.add('message-me-asterisk');
|
||||||
let user = document.createElement('span');
|
let user = document.createElement('span');
|
||||||
user.textContent = nick;
|
user.textContent = nick || '(anon)';
|
||||||
user.classList.add('message-me-user');
|
user.classList.add('message-me-user');
|
||||||
let content = document.createElement('span');
|
let content = document.createElement('span');
|
||||||
formatLine(message).forEach(elt => {
|
formatLine(message).forEach(elt => {
|
||||||
|
@ -1472,10 +1474,6 @@ function handleInput() {
|
||||||
}
|
}
|
||||||
if(cmd === '/msg') {
|
if(cmd === '/msg') {
|
||||||
let username = getUsername();
|
let username = getUsername();
|
||||||
if(!username) {
|
|
||||||
displayError("Sorry, you're anonymous, you cannot chat");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
serverConnection.chat(username, '', id, parsed[1]);
|
serverConnection.chat(username, '', id, parsed[1]);
|
||||||
addToChatbox(serverConnection.id,
|
addToChatbox(serverConnection.id,
|
||||||
id, username, Date.now(), '', parsed[1]);
|
id, username, Date.now(), '', parsed[1]);
|
||||||
|
@ -1500,11 +1498,6 @@ function handleInput() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let username = getUsername();
|
let username = getUsername();
|
||||||
if(!username) {
|
|
||||||
displayError("Sorry, you're anonymous, you cannot chat");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
serverConnection.chat(username, me ? 'me' : '', '', message);
|
serverConnection.chat(username, me ? 'me' : '', '', message);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|
Loading…
Reference in a new issue