mirror of
https://github.com/jech/galene.git
synced 2024-12-22 15:25:48 +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
|
||||
kept (default 14400, i.e. 4 hours);
|
||||
- `allow-recording`: if true, then recording is allowed in this group;
|
||||
- `allow-anonymous`: if true, then users may connect with an empty
|
||||
username; this is not recommended, since anonymous users are not
|
||||
allowed to participate in the chat;
|
||||
- `allow-anonymous`: if true, then users may connect with an empty username.
|
||||
- `redirect`: if set, then attempts to join the group will be redirected
|
||||
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') {
|
||||
let p = formatLines(message.split('\n'));
|
||||
if(lastMessage.nick !== nick ||
|
||||
if(lastMessage.nick !== (nick || null) ||
|
||||
lastMessage.peerId !== peerId ||
|
||||
lastMessage.dest !== (dest || null)) {
|
||||
let header = document.createElement('p');
|
||||
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');
|
||||
header.appendChild(user);
|
||||
if(time) {
|
||||
|
@ -1294,7 +1296,7 @@ function addToChatbox(peerId, dest, nick, time, kind, message) {
|
|||
}
|
||||
p.classList.add('message-content');
|
||||
container.appendChild(p);
|
||||
lastMessage.nick = nick;
|
||||
lastMessage.nick = (nick || null);
|
||||
lastMessage.peerId = peerId;
|
||||
lastMessage.dest = (dest || null);
|
||||
} else {
|
||||
|
@ -1302,7 +1304,7 @@ function addToChatbox(peerId, dest, nick, time, kind, message) {
|
|||
asterisk.textContent = '*';
|
||||
asterisk.classList.add('message-me-asterisk');
|
||||
let user = document.createElement('span');
|
||||
user.textContent = nick;
|
||||
user.textContent = nick || '(anon)';
|
||||
user.classList.add('message-me-user');
|
||||
let content = document.createElement('span');
|
||||
formatLine(message).forEach(elt => {
|
||||
|
@ -1472,10 +1474,6 @@ function handleInput() {
|
|||
}
|
||||
if(cmd === '/msg') {
|
||||
let username = getUsername();
|
||||
if(!username) {
|
||||
displayError("Sorry, you're anonymous, you cannot chat");
|
||||
return;
|
||||
}
|
||||
serverConnection.chat(username, '', id, parsed[1]);
|
||||
addToChatbox(serverConnection.id,
|
||||
id, username, Date.now(), '', parsed[1]);
|
||||
|
@ -1500,11 +1498,6 @@ function handleInput() {
|
|||
}
|
||||
|
||||
let username = getUsername();
|
||||
if(!username) {
|
||||
displayError("Sorry, you're anonymous, you cannot chat");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
serverConnection.chat(username, me ? 'me' : '', '', message);
|
||||
} catch(e) {
|
||||
|
|
Loading…
Reference in a new issue