fix(session): address review regressions

This commit is contained in:
Hoshina
2026-04-13 22:51:44 +08:00
parent 0c6ad33a9c
commit c5c5ea22d6
7 changed files with 119 additions and 64 deletions
+16 -3
View File
@@ -93,9 +93,7 @@ func normalizeProcessOptions(opts processOptions) processOptions {
MessageID: strings.TrimSpace(opts.MessageID),
ReplyToMessageID: strings.TrimSpace(opts.ReplyToMessageID),
}
if inbound.Channel != "" && inbound.ChatID != "" {
inbound.ChatType = "direct"
}
inbound.ChatType = inferChatTypeFromSessionScope(opts.Dispatch.SessionScope)
if inbound.Channel != "" || inbound.ChatID != "" || inbound.SenderID != "" ||
inbound.MessageID != "" || inbound.ReplyToMessageID != "" {
inbound = bus.NormalizeInboundMessage(bus.InboundMessage{Context: inbound}).Context
@@ -132,3 +130,18 @@ func normalizeProcessOptions(opts processOptions) processOptions {
return opts
}
func inferChatTypeFromSessionScope(scope *session.SessionScope) string {
if scope == nil || len(scope.Values) == 0 {
return ""
}
chatValue := strings.TrimSpace(scope.Values["chat"])
if chatValue == "" {
return ""
}
chatType, _, ok := strings.Cut(chatValue, ":")
if !ok {
return ""
}
return strings.ToLower(strings.TrimSpace(chatType))
}