mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
fix(channel): add wechatoa webhook delivery and proxy config (#356)
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.
This commit is contained in:
@@ -81,7 +81,7 @@ func shouldSkipJWT(path string) bool {
|
||||
if strings.HasPrefix(path, "/api/docs") {
|
||||
return true
|
||||
}
|
||||
if strings.HasPrefix(path, "/channels/feishu/webhook/") {
|
||||
if isPublicChannelWebhookPath(path) {
|
||||
return true
|
||||
}
|
||||
if strings.HasPrefix(path, "/email/mailgun/webhook/") {
|
||||
@@ -98,3 +98,12 @@ func shouldSkipJWT(path string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isPublicChannelWebhookPath(path string) bool {
|
||||
if !strings.HasPrefix(path, "/channels/") {
|
||||
return false
|
||||
}
|
||||
trimmed := strings.Trim(strings.TrimPrefix(path, "/channels/"), "/")
|
||||
parts := strings.Split(trimmed, "/")
|
||||
return len(parts) >= 3 && strings.TrimSpace(parts[0]) != "" && parts[1] == "webhook" && strings.TrimSpace(parts[2]) != ""
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package server
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestShouldSkipJWT_FeishuWebhookPaths(t *testing.T) {
|
||||
func TestShouldSkipJWT_ChannelWebhookPaths(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cases := []struct {
|
||||
@@ -10,6 +10,7 @@ func TestShouldSkipJWT_FeishuWebhookPaths(t *testing.T) {
|
||||
want bool
|
||||
}{
|
||||
{path: "/channels/feishu/webhook/cfg-1", want: true},
|
||||
{path: "/channels/wechatoa/webhook/cfg-1", want: true},
|
||||
{path: "/channels/feishu/webhook", want: false},
|
||||
{path: "/api/channels/feishu/webhook", want: false},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user