fix: 修复P2P主题别名订阅的兼容性问题

1. 订阅重复检查新增Original与RcptTo匹配判断,避免别名订阅误判已订阅
2. 重构订阅get查询处理逻辑,提取为独立函数
3. 针对P2P别名订阅场景返回200响应而非304,帮助客户端完成别名到标准主题名的重命名,避免发布失败
4. 优化群摘要接口的权限校验和异常处理逻辑
This commit is contained in:
Austin
2026-09-15 18:53:49 +08:00
parent 55afd976c9
commit dbb0a06db0
3 changed files with 80 additions and 16 deletions
+8 -1
View File
@@ -749,7 +749,14 @@ func (s *Session) subscribe(msg *ClientComMessage) {
s.inflightReqs.Add(1)
// Session can subscribe to topic on behalf of a single user at a time.
if sub := s.getSub(msg.RcptTo); sub != nil {
// Fast-path the duplicate attach only when the client used the canonical
// topic name itself. A p2p topic may also be addressed by an alias (the
// peer's user id, e.g. "usrXXX") while the session is already attached to
// the canonical topic ("p2pXXX"): forwarding it to the topic lets the
// client complete the alias->canonical rename with a 200 reply instead of
// a 304 that would leave the client-side alias topic object unattached
// (publishes on it then fail with "Cannot publish on inactive topic").
if sub := s.getSub(msg.RcptTo); sub != nil && msg.Original == msg.RcptTo {
s.queueOut(InfoAlreadySubscribed(msg.Id, msg.Original, msg.Timestamp))
s.inflightReqs.Done()
} else {