mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Make 'clearchat' into a user message.
This commit is contained in:
parent
e393819eda
commit
0ec9f92dad
3 changed files with 12 additions and 15 deletions
|
@ -539,7 +539,7 @@ func gotAnswer(c *webClient, id string, sdp string) error {
|
||||||
}
|
}
|
||||||
err := down.pc.SetRemoteDescription(webrtc.SessionDescription{
|
err := down.pc.SetRemoteDescription(webrtc.SessionDescription{
|
||||||
Type: webrtc.SDPTypeAnswer,
|
Type: webrtc.SDPTypeAnswer,
|
||||||
SDP: sdp,
|
SDP: sdp,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -1235,7 +1235,11 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
switch m.Kind {
|
switch m.Kind {
|
||||||
case "clearchat":
|
case "clearchat":
|
||||||
g.ClearChatHistory()
|
g.ClearChatHistory()
|
||||||
m := clientMessage{Type: "clearchat"}
|
m := clientMessage{
|
||||||
|
Type: "usermessage",
|
||||||
|
Kind: "clearchat",
|
||||||
|
Privileged: true,
|
||||||
|
}
|
||||||
clients := g.GetClients(nil)
|
clients := g.GetClients(nil)
|
||||||
for _, cc := range clients {
|
for _, cc := range clients {
|
||||||
cc, ok := cc.(*webClient)
|
cc, ok := cc.(*webClient)
|
||||||
|
|
|
@ -1555,7 +1555,6 @@ function gotUserMessage(id, dest, username, time, privileged, kind, message) {
|
||||||
console.error(`Got unprivileged message of kind ${kind}`);
|
console.error(`Got unprivileged message of kind ${kind}`);
|
||||||
break;
|
break;
|
||||||
case 'mute':
|
case 'mute':
|
||||||
console.log(id, dest, username);
|
|
||||||
if(privileged) {
|
if(privileged) {
|
||||||
setLocalMute(true, true);
|
setLocalMute(true, true);
|
||||||
let by = username ? ' by ' + username : '';
|
let by = username ? ' by ' + username : '';
|
||||||
|
@ -1564,6 +1563,12 @@ function gotUserMessage(id, dest, username, time, privileged, kind, message) {
|
||||||
console.error(`Got unprivileged message of kind ${kind}`);
|
console.error(`Got unprivileged message of kind ${kind}`);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'clearchat':
|
||||||
|
if(privileged) {
|
||||||
|
clearChat();
|
||||||
|
} else {
|
||||||
|
console.error(`Got unprivileged message of kind ${kind}`);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
console.warn(`Got unknown user message ${kind}`);
|
console.warn(`Got unknown user message ${kind}`);
|
||||||
break;
|
break;
|
||||||
|
@ -2319,7 +2324,6 @@ async function serverConnect() {
|
||||||
serverConnection.onuser = gotUser;
|
serverConnection.onuser = gotUser;
|
||||||
serverConnection.onjoined = gotJoined;
|
serverConnection.onjoined = gotJoined;
|
||||||
serverConnection.onchat = addToChatbox;
|
serverConnection.onchat = addToChatbox;
|
||||||
serverConnection.onclearchat = clearChat;
|
|
||||||
serverConnection.onusermessage = gotUserMessage;
|
serverConnection.onusermessage = gotUserMessage;
|
||||||
|
|
||||||
let url = `ws${location.protocol === 'https:' ? 's' : ''}://${location.host}/ws`;
|
let url = `ws${location.protocol === 'https:' ? 's' : ''}://${location.host}/ws`;
|
||||||
|
|
|
@ -161,13 +161,6 @@ function ServerConnection() {
|
||||||
* @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, kind: string, message: unknown) => void}
|
||||||
*/
|
*/
|
||||||
this.onusermessage = null;
|
this.onusermessage = null;
|
||||||
/**
|
|
||||||
* onclearchat is called whenever the server requests that the chat
|
|
||||||
* be cleared.
|
|
||||||
*
|
|
||||||
* @type{(this: ServerConnection) => void}
|
|
||||||
*/
|
|
||||||
this.onclearchat = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -315,10 +308,6 @@ ServerConnection.prototype.connect = async function(url) {
|
||||||
m.privileged, m.kind, m.value,
|
m.privileged, m.kind, m.value,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'clearchat':
|
|
||||||
if(sc.onclearchat)
|
|
||||||
sc.onclearchat.call(sc);
|
|
||||||
break;
|
|
||||||
case 'ping':
|
case 'ping':
|
||||||
sc.send({
|
sc.send({
|
||||||
type: 'pong',
|
type: 'pong',
|
||||||
|
|
Loading…
Reference in a new issue