Improve detection of nickname change presences

This commit is contained in:
Bohdan Horbeshko 2025-07-28 20:44:21 -04:00
parent 5ec8eab64b
commit e85b534e4f

View file

@ -689,18 +689,24 @@ func tryHandleMUCPresence(s xmpp.Sender, p stanza.Presence) {
switch p.Type { switch p.Type {
case "": case "":
handleMUCNicknameChange(component, p, session, chatId, toBare) if p.Show == "" {
handleMUCNicknameChange(component, p, session, chatId, toBare, nickname)
}
case stanza.PresenceTypeUnavailable: case stanza.PresenceTypeUnavailable:
handleMUCUnavailable(component, p, session, chatId, fromResource) handleMUCUnavailable(component, p, session, chatId, fromResource)
} }
} }
func handleMUCNicknameChange(component *xmpp.Component, p stanza.Presence, session *telegram.Client, chatId int64, toBare string) { func handleMUCNicknameChange(component *xmpp.Component, p stanza.Presence, session *telegram.Client, chatId int64, toBare string, newNickname string) {
log.Warn("🗿 Yes") log.Warn("🗿 Yes")
from := toBare from := toBare
nickname, ok := session.GetMyMUCNickname(chatId) nickname, ok := session.GetMyMUCNickname(chatId)
if ok { if ok {
if nickname == newNickname {
log.Warn("But whatever, it's the same")
return
}
from = from+"/"+nickname from = from+"/"+nickname
} }
reply := &stanza.Presence{ reply := &stanza.Presence{