mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-05 04:07:07 +00:00
close #110
This commit is contained in:
parent
7c5584d839
commit
0d5d8e45b0
1 changed files with 18 additions and 1 deletions
|
|
@ -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)}
|
||||||
|
if isSubscriptionType(typ) {
|
||||||
|
// subscription presences must come from the bare JID
|
||||||
|
args = append(args, SPFrom(CHATNODE(from)))
|
||||||
|
} else {
|
||||||
args = SPAppendFrom(args, from)
|
args = SPAppendFrom(args, from)
|
||||||
|
}
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue