fix room im outbox group id mapping

This commit is contained in:
zhx 2026-06-08 21:00:45 +08:00
parent 1224f3fbc6
commit 1e038aa074
2 changed files with 11 additions and 1 deletions

View File

@ -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 是本地和测试路径的房间消息发布占位实现。 // noopRoomEventPublisher 是本地和测试路径的房间消息发布占位实现。

View File

@ -3,6 +3,7 @@ package integration
import ( import (
"bytes" "bytes"
"context" "context"
"encoding/json"
"io" "io"
"net/http" "net/http"
"testing" "testing"
@ -108,6 +109,7 @@ func TestRoomPasswordChangedSkipsRoomGroupIM(t *testing.T) {
func TestTencentIMPublisherRemovesGroupMemberBeforeKickMessage(t *testing.T) { func TestTencentIMPublisherRemovesGroupMemberBeforeKickMessage(t *testing.T) {
paths := make([]string, 0, 2) paths := make([]string, 0, 2)
bodies := make([]map[string]any, 0, 2)
client, err := tencentim.NewRESTClient(tencentim.RESTConfig{ client, err := tencentim.NewRESTClient(tencentim.RESTConfig{
SDKAppID: 1400000000, SDKAppID: 1400000000,
SecretKey: "secret", SecretKey: "secret",
@ -115,6 +117,11 @@ func TestTencentIMPublisherRemovesGroupMemberBeforeKickMessage(t *testing.T) {
AdminUserSigTTL: time.Hour, AdminUserSigTTL: time.Hour,
HTTPClient: &http.Client{Transport: roundTripFunc(func(request *http.Request) (*http.Response, error) { HTTPClient: &http.Client{Transport: roundTripFunc(func(request *http.Request) (*http.Response, error) {
paths = append(paths, request.URL.Path) 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{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: io.NopCloser(bytes.NewReader([]byte(`{"ActionStatus":"OK","ErrorCode":0,"ErrorInfo":""}`))), 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" { 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) 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) type roundTripFunc func(*http.Request) (*http.Response, error)