Send real JID for room occupants

This commit is contained in:
Bohdan Horbeshko 2023-09-18 01:17:25 -04:00
parent 6c65ef9988
commit 93abbe834e
3 changed files with 16 additions and 7 deletions

View file

@ -302,6 +302,7 @@ func (c *Client) SendMUCStatuses(chatID int64) {
}) })
if err == nil { if err == nil {
chatIDString := strconv.FormatInt(chatID, 10) chatIDString := strconv.FormatInt(chatID, 10)
gatewayJidSuffix := "@" + gateway.Jid.Full()
myNickname := "me" myNickname := "me"
if c.me != nil { if c.me != nil {
@ -337,7 +338,8 @@ func (c *Client) SendMUCStatuses(chatID int64) {
gateway.SPFrom(chatIDString), gateway.SPFrom(chatIDString),
gateway.SPResource(nickname), gateway.SPResource(nickname),
gateway.SPImmed(true), gateway.SPImmed(true),
gateway.SPAffiliation(affiliation), gateway.SPMUCAffiliation(affiliation),
gateway.SPMUCJid(strconv.FormatInt(senderId, 10) + gatewayJidSuffix),
) )
} }
@ -348,8 +350,8 @@ func (c *Client) SendMUCStatuses(chatID int64) {
gateway.SPFrom(chatIDString), gateway.SPFrom(chatIDString),
gateway.SPResource(myNickname), gateway.SPResource(myNickname),
gateway.SPImmed(true), gateway.SPImmed(true),
gateway.SPAffiliation(myAffiliation), gateway.SPMUCAffiliation(myAffiliation),
gateway.SPMUCStatusCodes([]uint16{110, 210}), gateway.SPMUCStatusCodes([]uint16{100, 110, 210}),
) )
} }
} }

View file

@ -224,6 +224,7 @@ type PresenceXMucUserExtension struct {
type PresenceXMucUserItem struct { type PresenceXMucUserItem struct {
XMLName xml.Name `xml:"item"` XMLName xml.Name `xml:"item"`
Affiliation string `xml:"affiliation,attr"` Affiliation string `xml:"affiliation,attr"`
Jid string `xml:"jid,attr"`
Role string `xml:"role,attr"` Role string `xml:"role,attr"`
} }

View file

@ -240,8 +240,11 @@ var SPResource = args.NewString()
// SPImmed skips queueing // SPImmed skips queueing
var SPImmed = args.NewBool(args.Default(true)) var SPImmed = args.NewBool(args.Default(true))
// SPAffiliation is a XEP-0045 MUC affiliation // SPMUCAffiliation is a XEP-0045 MUC affiliation
var SPAffiliation = args.NewString() var SPMUCAffiliation = args.NewString()
// SPMUCJid is a real jid of a MUC member
var SPMUCJid = args.NewString()
// SPMUCStatusCodes is a set of XEP-0045 MUC status codes // SPMUCStatusCodes is a set of XEP-0045 MUC status codes
var SPMUCStatusCodes = args.New() var SPMUCStatusCodes = args.New()
@ -301,8 +304,8 @@ func newPresence(bareJid string, to string, args ...args.V) stanza.Presence {
}) })
} }
} }
if SPAffiliation.IsSet(args) { if SPMUCAffiliation.IsSet(args) {
affiliation := SPAffiliation.Get(args) affiliation := SPMUCAffiliation.Get(args)
if affiliation != "" { if affiliation != "" {
userExt := extensions.PresenceXMucUserExtension{ userExt := extensions.PresenceXMucUserExtension{
Item: extensions.PresenceXMucUserItem{ Item: extensions.PresenceXMucUserItem{
@ -310,6 +313,9 @@ func newPresence(bareJid string, to string, args ...args.V) stanza.Presence {
Role: affilationToRole(affiliation), Role: affilationToRole(affiliation),
}, },
} }
if SPMUCJid.IsSet(args) {
userExt.Item.Jid = SPMUCJid.Get(args)
}
if SPMUCStatusCodes.IsSet(args) { if SPMUCStatusCodes.IsSet(args) {
statusCodes := SPMUCStatusCodes.Get(args).([]uint16) statusCodes := SPMUCStatusCodes.Get(args).([]uint16)
for _, statusCode := range statusCodes { for _, statusCode := range statusCodes {