mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-05 04:07:07 +00:00
Avoid empty jid attribute in MUC user extension item
This commit is contained in:
parent
863c5afa91
commit
32b00c244c
3 changed files with 19 additions and 24 deletions
|
|
@ -252,7 +252,7 @@ type PresenceXMucUserExtension struct {
|
|||
type PresenceXMucUserItem struct {
|
||||
XMLName xml.Name `xml:"item"`
|
||||
Affiliation string `xml:"affiliation,attr"`
|
||||
Jid string `xml:"jid,attr"`
|
||||
Jid *string `xml:"jid,attr"`
|
||||
Nick string `xml:"nick,attr,omitempty"`
|
||||
Role string `xml:"role,attr"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -414,6 +414,9 @@ func LogBadPresence(presence *stanza.Presence) {
|
|||
// SPFrom is a Telegram user id
|
||||
var SPFrom = args.NewString()
|
||||
|
||||
// SPFullFrom is for specifying a full from when desired
|
||||
var SPFullFrom = args.NewString()
|
||||
|
||||
// SPType is a presence type
|
||||
var SPType = args.NewString()
|
||||
|
||||
|
|
@ -458,7 +461,9 @@ var SPToResources = args.New()
|
|||
|
||||
func newPresence(bareJid string, to string, args ...args.V) stanza.Presence {
|
||||
var presenceFrom string
|
||||
if SPFrom.IsSet(args) {
|
||||
if SPFullFrom.IsSet(args) {
|
||||
presenceFrom = SPFullFrom.Get(args)
|
||||
} else if SPFrom.IsSet(args) {
|
||||
presenceFrom = SPFrom.Get(args) + "@" + bareJid
|
||||
if SPResource.IsSet(args) {
|
||||
resource := SPResource.Get(args)
|
||||
|
|
@ -530,7 +535,8 @@ func newPresence(bareJid string, to string, args ...args.V) stanza.Presence {
|
|||
userExt.Item.Nick = SPMUCNick.Get(args)
|
||||
}
|
||||
if SPMUCJid.IsSet(args) {
|
||||
userExt.Item.Jid = SPMUCJid.Get(args)
|
||||
mucJid := SPMUCJid.Get(args)
|
||||
userExt.Item.Jid = &mucJid
|
||||
}
|
||||
if SPMUCStatusCodes.IsSet(args) {
|
||||
statusCodes := SPMUCStatusCodes.Get(args).([]uint16)
|
||||
|
|
|
|||
|
|
@ -698,27 +698,16 @@ func handleMUCUnavailable(component *xmpp.Component, p stanza.Presence, session
|
|||
|
||||
session.LeaveMUC(chatId, resource)
|
||||
|
||||
reply := &stanza.Presence{
|
||||
Attrs: stanza.Attrs{
|
||||
From: p.To,
|
||||
To: p.From,
|
||||
Id: p.Id,
|
||||
Type: stanza.PresenceTypeUnavailable,
|
||||
},
|
||||
Extensions: []stanza.PresExtension{
|
||||
extensions.PresenceXMucUserExtension{
|
||||
Item: extensions.PresenceXMucUserItem{
|
||||
Affiliation: "member",
|
||||
Jid: p.From,
|
||||
Role: "none",
|
||||
},
|
||||
Statuses: []extensions.PresenceXMucUserStatus{
|
||||
extensions.PresenceXMucUserStatus{Code: 110},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
gateway.ResumableSend(component, reply)
|
||||
gateway.SendPresence(
|
||||
component,
|
||||
p.From,
|
||||
gateway.SPFullFrom(p.To),
|
||||
gateway.SPType("unavailable"),
|
||||
gateway.SPMUCAffiliation("member"),
|
||||
gateway.SPMUCRole("none"),
|
||||
gateway.SPMUCJid(p.From),
|
||||
gateway.SPMUCStatusCodes([]uint16{110}),
|
||||
)
|
||||
}
|
||||
|
||||
func handleGetVcardIq(s xmpp.Sender, iq *stanza.IQ, typ byte) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue