mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
Merge pull request #3019 from chengzhichao-xydt/codex/lastinsertid-nilguard
fix: type-switch capture, nil guard, check LastInsertId errors
This commit is contained in:
@@ -269,9 +269,9 @@ func (c *WhatsAppNativeChannel) Stop(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *WhatsAppNativeChannel) eventHandler(evt any) {
|
func (c *WhatsAppNativeChannel) eventHandler(evt any) {
|
||||||
switch evt.(type) {
|
switch v := evt.(type) {
|
||||||
case *events.Message:
|
case *events.Message:
|
||||||
c.handleIncoming(evt.(*events.Message))
|
c.handleIncoming(v)
|
||||||
case *events.Disconnected:
|
case *events.Disconnected:
|
||||||
logger.InfoCF("whatsapp", "WhatsApp disconnected, will attempt reconnection", nil)
|
logger.InfoCF("whatsapp", "WhatsApp disconnected, will attempt reconnection", nil)
|
||||||
c.reconnectMu.Lock()
|
c.reconnectMu.Lock()
|
||||||
|
|||||||
@@ -194,6 +194,9 @@ type ExposePath struct {
|
|||||||
// Uses strings.Replacer for O(n+m) performance (computed once per SecurityConfig).
|
// Uses strings.Replacer for O(n+m) performance (computed once per SecurityConfig).
|
||||||
// Short content (below FilterMinLength) is returned unchanged for performance.
|
// Short content (below FilterMinLength) is returned unchanged for performance.
|
||||||
func (c *Config) FilterSensitiveData(content string) string {
|
func (c *Config) FilterSensitiveData(content string) string {
|
||||||
|
if c == nil {
|
||||||
|
return content
|
||||||
|
}
|
||||||
// Check if filtering is enabled (default: true)
|
// Check if filtering is enabled (default: true)
|
||||||
if !c.Tools.IsFilterSensitiveDataEnabled() {
|
if !c.Tools.IsFilterSensitiveDataEnabled() {
|
||||||
return content
|
return content
|
||||||
|
|||||||
+12
-3
@@ -56,7 +56,10 @@ func (s *Store) GetOrCreateConversation(ctx context.Context, sessionKey string)
|
|||||||
}
|
}
|
||||||
return nil, fmt.Errorf("create conversation: %w", err)
|
return nil, fmt.Errorf("create conversation: %w", err)
|
||||||
}
|
}
|
||||||
id, _ := result.LastInsertId()
|
id, err := result.LastInsertId()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("get last insert id: %w", err)
|
||||||
|
}
|
||||||
return &Conversation{
|
return &Conversation{
|
||||||
ConversationID: id,
|
ConversationID: id,
|
||||||
SessionKey: sessionKey,
|
SessionKey: sessionKey,
|
||||||
@@ -193,7 +196,10 @@ func (s *Store) AddMessageWithReasoning(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("add message: %w", err)
|
return nil, fmt.Errorf("add message: %w", err)
|
||||||
}
|
}
|
||||||
id, _ := result.LastInsertId()
|
id, err := result.LastInsertId()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("get last insert id: %w", err)
|
||||||
|
}
|
||||||
return &Message{
|
return &Message{
|
||||||
ID: id,
|
ID: id,
|
||||||
ConversationID: convID,
|
ConversationID: convID,
|
||||||
@@ -282,7 +288,10 @@ func (s *Store) AddMessageWithPartsAndReasoning(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("add message: %w", err)
|
return nil, fmt.Errorf("add message: %w", err)
|
||||||
}
|
}
|
||||||
msgID, _ := result.LastInsertId()
|
msgID, err := result.LastInsertId()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("get last insert id: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
for i, p := range parts {
|
for i, p := range parts {
|
||||||
_, err = tx.ExecContext(
|
_, err = tx.ExecContext(
|
||||||
|
|||||||
Reference in New Issue
Block a user