Fix lag issues

This commit is contained in:
2026-04-30 14:55:17 +01:00
parent 7b63799f0b
commit 0bfb140dc7
5 changed files with 223 additions and 70 deletions
+45 -2
View File
@@ -1,7 +1,6 @@
package main
import (
"fmt"
"gosrc.io/xmpp"
"gosrc.io/xmpp/stanza"
)
@@ -31,7 +30,6 @@ func sendMessage(c xmpp.Sender, sendTo string, msgType stanza.StanzaType, body s
func joinMuc(c xmpp.Sender, jid string, muc string, nick string, password string) error {
var joinPresence stanza.Presence
addr := muc + "/" + nick
fmt.Println(addr)
if password == "" {
joinPresence = stanza.Presence{
Attrs: stanza.Attrs{
@@ -63,6 +61,51 @@ func joinMuc(c xmpp.Sender, jid string, muc string, nick string, password string
return nil
}
func joinMucWithoutHistory(c xmpp.Sender, jid string, muc string, nick string, password string) error {
var joinPresence stanza.Presence
addr := muc + "/" + nick
if password == "" {
joinPresence = stanza.Presence{
Attrs: stanza.Attrs{
From: jid,
To: addr,
},
Extensions: []stanza.PresExtension{
&stanza.MucPresence{
History: stanza.History{
MaxChars: stanza.NewNullableInt(0),
MaxStanzas: stanza.NewNullableInt(0),
Seconds: stanza.NewNullableInt(0),
},
},
},
}
} else {
joinPresence = stanza.Presence{
Attrs: stanza.Attrs{
From: jid,
To: addr,
},
Extensions: []stanza.PresExtension{
&stanza.MucPresence{
Password: password,
History: stanza.History{
MaxChars: stanza.NewNullableInt(0),
MaxStanzas: stanza.NewNullableInt(0),
Seconds: stanza.NewNullableInt(0),
},
},
},
}
}
err := client.Send(joinPresence)
if err != nil {
return err
}
return nil
}
// jid MustParse but using gosrc's instead of mellium
// This function will panic if its an invalid JID