fix: publish member joined after group invitation

This commit is contained in:
richjohnrambo
2026-09-18 20:58:00 +08:00
parent 753a04ed12
commit 0fcbbb9318
2 changed files with 24 additions and 0 deletions
+18
View File
@@ -3715,16 +3715,19 @@ func TestServeIMGroupInvitationAddsNonMember(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
expectIMBearer(t, ctrl, "token-1", 7, 42)
oldHub := globals.hub
oldSubs := store.Subs
oldGroupBusiness := store.GroupBusiness
oldSecurity := store.Security
subs := mock_store.NewMockSubsPersistenceInterface(ctrl)
groupStore := &testGroupBusinessStore{}
securityStore := &testUserSecurityStore{}
globals.hub = &Hub{routeSrv: make(chan *ServerComMessage, 2)}
store.Subs = subs
store.GroupBusiness = groupStore
store.Security = securityStore
defer func() {
globals.hub = oldHub
store.Subs = oldSubs
store.GroupBusiness = oldGroupBusiness
store.Security = oldSecurity
@@ -3758,6 +3761,21 @@ func TestServeIMGroupInvitationAddsNonMember(t *testing.T) {
if len(securityStore.notifications) != 0 {
t.Fatalf("direct invite should not create approval notification: %#v", securityStore.notifications)
}
select {
case msg := <-globals.hub.routeSrv:
if msg.Info == nil || msg.Info.Event != "group.member.joined" || msg.Info.Topic != "grpAlpha" {
t.Fatalf("unexpected realtime event: %#v", msg)
}
var payload map[string]any
if err := json.Unmarshal(msg.Info.Payload, &payload); err != nil {
t.Fatalf("decode payload: %v", err)
}
if payload["user_id"] != target.UserId() || payload["member_sync"] != "single" || payload["source"] != "direct_invitation" {
t.Fatalf("unexpected member joined payload: %#v", payload)
}
default:
t.Fatal("missing group.member.joined realtime event")
}
}
func TestServeIMGroupInvitationCreatesApprovalRequest(t *testing.T) {