mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
f376a2abe3
Unify webhook handling across channel adapters and add the WeChat Official Account channel so inbound routing and replies work without platform-specific handlers. Add adapter-scoped proxy support and stable config field ordering so restricted network environments can deliver WeChat and Telegram messages reliably.
40 lines
939 B
Go
40 lines
939 B
Go
package wechatoa
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/memohai/memoh/internal/channel"
|
|
)
|
|
|
|
func TestBuildSendPayload_ImagePlatformKey(t *testing.T) {
|
|
client := &apiClient{}
|
|
payload, err := client.buildSendPayload(context.Background(), channel.PreparedMessage{
|
|
Message: channel.Message{
|
|
Attachments: []channel.Attachment{
|
|
{Type: channel.AttachmentImage, PlatformKey: "mid_123"},
|
|
},
|
|
},
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("buildSendPayload error = %v", err)
|
|
}
|
|
if payload["msgtype"] != "image" {
|
|
t.Fatalf("unexpected msgtype: %v", payload["msgtype"])
|
|
}
|
|
}
|
|
|
|
func TestBuildSendPayload_UnsupportedAttachment(t *testing.T) {
|
|
client := &apiClient{}
|
|
_, err := client.buildSendPayload(context.Background(), channel.PreparedMessage{
|
|
Message: channel.Message{
|
|
Attachments: []channel.Attachment{
|
|
{Type: channel.AttachmentFile, PlatformKey: "mid_file"},
|
|
},
|
|
},
|
|
})
|
|
if err == nil {
|
|
t.Fatal("expected error")
|
|
}
|
|
}
|