Send 170 status code when joining supergroups (assuming they are public and basic groups are not)

This commit is contained in:
Bohdan Horbeshko 2025-07-25 17:21:38 -04:00
parent b1a67f6f4e
commit 5ec8eab64b

View file

@ -695,6 +695,7 @@ func (c *Client) sendMUCStatuses(chatID int64) {
} }
} }
// achtung: assuming a locked mucState context
func (c *Client) updateMUCOccupants(mucState *MUCState, chatID int64, members []*client.ChatMember) { func (c *Client) updateMUCOccupants(mucState *MUCState, chatID int64, members []*client.ChatMember) {
sChatId := gateway.MUCNODE(chatID) sChatId := gateway.MUCNODE(chatID)
myNickname := "me" myNickname := "me"
@ -738,6 +739,10 @@ func (c *Client) updateMUCOccupants(mucState *MUCState, chatID int64, members []
} }
// according to the spec, own occupant entry should be sent the last // according to the spec, own occupant entry should be sent the last
selfStatusCodes := []uint16{100, 110, 210}
if chat != nil && chat.Type.ChatTypeType() == client.TypeChatTypeSupergroup {
selfStatusCodes = append(selfStatusCodes, 170)
}
c.sendPresence( c.sendPresence(
gateway.SPFrom(sChatId), gateway.SPFrom(sChatId),
gateway.SPResource(myNickname), gateway.SPResource(myNickname),
@ -745,7 +750,7 @@ func (c *Client) updateMUCOccupants(mucState *MUCState, chatID int64, members []
gateway.SPMUCAffiliation(myAffiliation), gateway.SPMUCAffiliation(myAffiliation),
gateway.SPMUCRole(myRole), gateway.SPMUCRole(myRole),
gateway.SPMUCJid(myJid), gateway.SPMUCJid(myJid),
gateway.SPMUCStatusCodes([]uint16{100, 110, 210}), gateway.SPMUCStatusCodes(selfStatusCodes),
gateway.SPToJids(toJids), gateway.SPToJids(toJids),
) )
} }