diff --git a/services/room-service/internal/integration/tencent_im.go b/services/room-service/internal/integration/tencent_im.go index 4128d3b3..f9a8f6b2 100644 --- a/services/room-service/internal/integration/tencent_im.go +++ b/services/room-service/internal/integration/tencent_im.go @@ -80,7 +80,7 @@ func (p *TencentIMPublisher) PublishOutboxEvent(ctx context.Context, envelope *r } } - return p.client.PublishRoomEvent(ctx, event) + return p.PublishRoomEvent(ctx, event) } // noopRoomEventPublisher 是本地和测试路径的房间消息发布占位实现。 diff --git a/services/room-service/internal/integration/tencent_im_test.go b/services/room-service/internal/integration/tencent_im_test.go index 3f26948d..01b7ae94 100644 --- a/services/room-service/internal/integration/tencent_im_test.go +++ b/services/room-service/internal/integration/tencent_im_test.go @@ -3,6 +3,7 @@ package integration import ( "bytes" "context" + "encoding/json" "io" "net/http" "testing" @@ -108,6 +109,7 @@ func TestRoomPasswordChangedSkipsRoomGroupIM(t *testing.T) { func TestTencentIMPublisherRemovesGroupMemberBeforeKickMessage(t *testing.T) { paths := make([]string, 0, 2) + bodies := make([]map[string]any, 0, 2) client, err := tencentim.NewRESTClient(tencentim.RESTConfig{ SDKAppID: 1400000000, SecretKey: "secret", @@ -115,6 +117,11 @@ func TestTencentIMPublisherRemovesGroupMemberBeforeKickMessage(t *testing.T) { AdminUserSigTTL: time.Hour, HTTPClient: &http.Client{Transport: roundTripFunc(func(request *http.Request) (*http.Response, error) { paths = append(paths, request.URL.Path) + var body map[string]any + if err := json.NewDecoder(request.Body).Decode(&body); err != nil { + t.Fatalf("decode request body failed: %v", err) + } + bodies = append(bodies, body) return &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{"ActionStatus":"OK","ErrorCode":0,"ErrorInfo":""}`))), @@ -141,6 +148,9 @@ func TestTencentIMPublisherRemovesGroupMemberBeforeKickMessage(t *testing.T) { if len(paths) != 2 || paths[0] != "/v4/group_open_http_svc/delete_group_member" || paths[1] != "/v4/group_open_http_svc/send_group_msg" { t.Fatalf("kick outbox should delete member before system message, paths=%+v", paths) } + if bodies[0]["GroupId"] != "room_kick" || bodies[1]["GroupId"] != "room_kick" { + t.Fatalf("kick outbox must use Tencent-safe room group id, bodies=%+v", bodies) + } } type roundTripFunc func(*http.Request) (*http.Response, error)