1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 08:35:57 +01:00

Add chathistory message.

This commit is contained in:
Juliusz Chroboczek 2021-07-31 14:42:26 +02:00
parent 97a5bf60ad
commit b527c8757a
4 changed files with 14 additions and 6 deletions

View file

@ -277,6 +277,10 @@ if the message was originated by a client with the `op` permission. The
field `noecho` is set by the client if it doesn't wish to receive a copy field `noecho` is set by the client if it doesn't wish to receive a copy
of its own message. of its own message.
The `chathistory` message is similar to the `chat` message, but carries
a message taken from the chat history. Most clients should treat
`chathistory` similarly to `chat`.
A user message is similar to a chat message, but is not conserved in the A user message is similar to a chat message, but is not conserved in the
chat history, and is not expected to contain user-visible content. chat history, and is not expected to contain user-visible content.

View file

@ -1351,7 +1351,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
h := c.group.GetChatHistory() h := c.group.GetChatHistory()
for _, m := range h { for _, m := range h {
err := c.write(clientMessage{ err := c.write(clientMessage{
Type: "chat", Type: "chathistory",
Id: m.Id, Id: m.Id,
Username: m.User, Username: m.User,
Time: m.Time, Time: m.Time,

View file

@ -2301,12 +2301,15 @@ let lastMessage = {};
/** /**
* @param {string} peerId * @param {string} peerId
* @param {string} dest
* @param {string} nick * @param {string} nick
* @param {number} time * @param {number} time
* @param {boolean} privileged
* @param {boolean} history
* @param {string} kind * @param {string} kind
* @param {unknown} message * @param {unknown} message
*/ */
function addToChatbox(peerId, dest, nick, time, privileged, kind, message) { function addToChatbox(peerId, dest, nick, time, privileged, history, kind, message) {
let userpass = getUserPass(); let userpass = getUserPass();
let row = document.createElement('div'); let row = document.createElement('div');
row.classList.add('message-row'); row.classList.add('message-row');
@ -2633,7 +2636,7 @@ commands.msg = {
throw new Error(`Unknown user ${p[0]}`); throw new Error(`Unknown user ${p[0]}`);
serverConnection.chat('', id, p[1]); serverConnection.chat('', id, p[1]);
addToChatbox(serverConnection.id, id, serverConnection.username, addToChatbox(serverConnection.id, id, serverConnection.username,
Date.now(), false, '', p[1]); Date.now(), false, false, '', p[1]);
} }
}; };

View file

@ -178,7 +178,7 @@ function ServerConnection() {
/** /**
* onchat is called whenever a new chat message is received. * onchat is called whenever a new chat message is received.
* *
* @type {(this: ServerConnection, id: string, dest: string, username: string, time: number, privileged: boolean, kind: string, message: unknown) => void} * @type {(this: ServerConnection, id: string, dest: string, username: string, time: number, privileged: boolean, history: boolean, kind: string, message: unknown) => void}
*/ */
this.onchat = null; this.onchat = null;
/** /**
@ -379,10 +379,11 @@ ServerConnection.prototype.connect = async function(url) {
sc.onuser.call(sc, m.id, m.kind); sc.onuser.call(sc, m.id, m.kind);
break; break;
case 'chat': case 'chat':
case 'chathistory':
if(sc.onchat) if(sc.onchat)
sc.onchat.call( sc.onchat.call(
sc, m.source, m.dest, m.username, m.time, sc, m.source, m.dest, m.username, m.time, m.privileged,
m.privileged, m.kind, m.value, m.type === 'chathistory', m.kind, m.value,
); );
break; break;
case 'usermessage': case 'usermessage':