mirror of
https://github.com/jech/galene.git
synced 2024-12-22 15:25:48 +01:00
Add chathistory message.
This commit is contained in:
parent
97a5bf60ad
commit
b527c8757a
4 changed files with 14 additions and 6 deletions
|
@ -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
|
||||
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
|
||||
chat history, and is not expected to contain user-visible content.
|
||||
|
||||
|
|
|
@ -1351,7 +1351,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
|||
h := c.group.GetChatHistory()
|
||||
for _, m := range h {
|
||||
err := c.write(clientMessage{
|
||||
Type: "chat",
|
||||
Type: "chathistory",
|
||||
Id: m.Id,
|
||||
Username: m.User,
|
||||
Time: m.Time,
|
||||
|
|
|
@ -2301,12 +2301,15 @@ let lastMessage = {};
|
|||
|
||||
/**
|
||||
* @param {string} peerId
|
||||
* @param {string} dest
|
||||
* @param {string} nick
|
||||
* @param {number} time
|
||||
* @param {boolean} privileged
|
||||
* @param {boolean} history
|
||||
* @param {string} kind
|
||||
* @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 row = document.createElement('div');
|
||||
row.classList.add('message-row');
|
||||
|
@ -2633,7 +2636,7 @@ commands.msg = {
|
|||
throw new Error(`Unknown user ${p[0]}`);
|
||||
serverConnection.chat('', id, p[1]);
|
||||
addToChatbox(serverConnection.id, id, serverConnection.username,
|
||||
Date.now(), false, '', p[1]);
|
||||
Date.now(), false, false, '', p[1]);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ function ServerConnection() {
|
|||
/**
|
||||
* 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;
|
||||
/**
|
||||
|
@ -379,10 +379,11 @@ ServerConnection.prototype.connect = async function(url) {
|
|||
sc.onuser.call(sc, m.id, m.kind);
|
||||
break;
|
||||
case 'chat':
|
||||
case 'chathistory':
|
||||
if(sc.onchat)
|
||||
sc.onchat.call(
|
||||
sc, m.source, m.dest, m.username, m.time,
|
||||
m.privileged, m.kind, m.value,
|
||||
sc, m.source, m.dest, m.username, m.time, m.privileged,
|
||||
m.type === 'chathistory', m.kind, m.value,
|
||||
);
|
||||
break;
|
||||
case 'usermessage':
|
||||
|
|
Loading…
Reference in a new issue