mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
ci: add go lint and race test workflow (#187)
This commit is contained in:
@@ -3,6 +3,7 @@ package feishu
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -41,10 +42,10 @@ type feishuOutboundStream struct {
|
||||
|
||||
func (s *feishuOutboundStream) Push(ctx context.Context, event channel.StreamEvent) error {
|
||||
if s == nil || s.adapter == nil {
|
||||
return fmt.Errorf("feishu stream not configured")
|
||||
return errors.New("feishu stream not configured")
|
||||
}
|
||||
if s.closed.Load() {
|
||||
return fmt.Errorf("feishu stream is closed")
|
||||
return errors.New("feishu stream is closed")
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
@@ -163,7 +164,7 @@ func (s *feishuOutboundStream) ensureCard(ctx context.Context, text string) erro
|
||||
return nil
|
||||
}
|
||||
if s.client == nil {
|
||||
return fmt.Errorf("feishu client not configured")
|
||||
return errors.New("feishu client not configured")
|
||||
}
|
||||
content, err := buildFeishuStreamCardContent(text)
|
||||
if err != nil {
|
||||
@@ -178,7 +179,7 @@ func (s *feishuOutboundStream) ensureCard(ctx context.Context, text string) erro
|
||||
Uuid(uuid.NewString()).
|
||||
Build()).
|
||||
Build()
|
||||
replyResp, err := s.client.Im.V1.Message.Reply(ctx, replyReq)
|
||||
replyResp, err := s.client.Im.Message.Reply(ctx, replyReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -190,7 +191,7 @@ func (s *feishuOutboundStream) ensureCard(ctx context.Context, text string) erro
|
||||
return fmt.Errorf("feishu stream reply failed: %s (code: %d)", msg, code)
|
||||
}
|
||||
if replyResp.Data == nil || replyResp.Data.MessageId == nil || strings.TrimSpace(*replyResp.Data.MessageId) == "" {
|
||||
return fmt.Errorf("feishu stream reply failed: empty message id")
|
||||
return errors.New("feishu stream reply failed: empty message id")
|
||||
}
|
||||
s.cardMessageID = strings.TrimSpace(*replyResp.Data.MessageId)
|
||||
s.lastPatched = normalizeFeishuStreamText(text)
|
||||
@@ -206,7 +207,7 @@ func (s *feishuOutboundStream) ensureCard(ctx context.Context, text string) erro
|
||||
Uuid(uuid.NewString()).
|
||||
Build()).
|
||||
Build()
|
||||
createResp, err := s.client.Im.V1.Message.Create(ctx, createReq)
|
||||
createResp, err := s.client.Im.Message.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -218,7 +219,7 @@ func (s *feishuOutboundStream) ensureCard(ctx context.Context, text string) erro
|
||||
return fmt.Errorf("feishu stream create failed: %s (code: %d)", msg, code)
|
||||
}
|
||||
if createResp.Data == nil || createResp.Data.MessageId == nil || strings.TrimSpace(*createResp.Data.MessageId) == "" {
|
||||
return fmt.Errorf("feishu stream create failed: empty message id")
|
||||
return errors.New("feishu stream create failed: empty message id")
|
||||
}
|
||||
s.cardMessageID = strings.TrimSpace(*createResp.Data.MessageId)
|
||||
s.lastPatched = normalizeFeishuStreamText(text)
|
||||
@@ -228,7 +229,7 @@ func (s *feishuOutboundStream) ensureCard(ctx context.Context, text string) erro
|
||||
|
||||
func (s *feishuOutboundStream) patchCard(ctx context.Context, text string) error {
|
||||
if strings.TrimSpace(s.cardMessageID) == "" {
|
||||
return fmt.Errorf("feishu stream card message not initialized")
|
||||
return errors.New("feishu stream card message not initialized")
|
||||
}
|
||||
contentText := normalizeFeishuStreamText(text)
|
||||
if contentText == s.lastPatched {
|
||||
@@ -244,7 +245,7 @@ func (s *feishuOutboundStream) patchCard(ctx context.Context, text string) error
|
||||
Content(content).
|
||||
Build()).
|
||||
Build()
|
||||
patchResp, err := s.client.Im.V1.Message.Patch(ctx, patchReq)
|
||||
patchResp, err := s.client.Im.Message.Patch(ctx, patchReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user