This commit is contained in:
Pavel R. 2026-06-02 14:07:50 +03:00
parent 4fe5b99c6e
commit a6684cdef7
No known key found for this signature in database

View file

@ -762,10 +762,27 @@ func SPAppendFrom(oldArgs []args.V, id int64) []args.V {
return newArgs return newArgs
} }
// isSubscriptionType reports whether a presence type manages the subscription
// state. Per RFC 6121 § 3 such presences must be addressed from a bare JID;
// attaching the component resource makes clients treat the full JID as a
// separate entity and produces a duplicate subscription request.
func isSubscriptionType(typ string) bool {
switch typ {
case "subscribe", "subscribed", "unsubscribe", "unsubscribed":
return true
}
return false
}
// SimplePresence crafts simple presence varargs // SimplePresence crafts simple presence varargs
func SimplePresence(from int64, typ string) []args.V { func SimplePresence(from int64, typ string) []args.V {
args := []args.V{SPType(typ)} args := []args.V{SPType(typ)}
args = SPAppendFrom(args, from) if isSubscriptionType(typ) {
// subscription presences must come from the bare JID
args = append(args, SPFrom(CHATNODE(from)))
} else {
args = SPAppendFrom(args, from)
}
return args return args
} }