feat: improve group member events and push delivery

This commit is contained in:
richjohnrambo
2026-09-18 01:00:41 +08:00
parent 0e2f4e73d1
commit c6e7f6b923
13 changed files with 521 additions and 19 deletions
+33
View File
@@ -564,6 +564,39 @@ func TestDispatchAlreadySubscribed(t *testing.T) {
verifyResponseCodes(&r, []int{http.StatusNotModified}, t)
}
func TestSubscribeP2PUserAliasReachesTopic(t *testing.T) {
oldHub := globals.hub
globals.hub = &Hub{join: make(chan *ClientComMessage, 1)}
t.Cleanup(func() { globals.hub = oldHub })
self := types.Uid(1)
peer := types.Uid(2)
canonical := self.P2PName(peer)
s := test_makeSession(self)
s.subs = map[string]*Subscription{canonical: {}}
msg := &ClientComMessage{
Sub: &MsgClientSub{Id: "alias-sub", Topic: peer.UserId()},
Id: "alias-sub",
Original: peer.UserId(),
AsUser: self.UserId(),
TenantID: s.tenantID,
Timestamp: types.TimeNow(),
sess: s,
}
s.subscribe(msg)
select {
case routed := <-globals.hub.join:
if routed != msg || routed.RcptTo != canonical {
t.Fatalf("unexpected alias subscription route: %#v", routed)
}
s.inflightReqs.Done()
default:
t.Fatal("p2p user alias was incorrectly handled as an already-subscribed topic")
}
}
func TestDispatchSubscribeJoinChannelFull(t *testing.T) {
uid := types.Uid(1)
s := test_makeSession(uid)