refactor(di): migrate from setter to constructor injection for logService
- Remove SetLogService methods from user, post, comment, and admin post services - Add logService as constructor parameter to all dependent services - Centralize call-related and message error definitions in app_errors.go - Add ConversationID field to WSEventResponse for improved message tracking - Simplify wire provider functions by removing manual setter calls
This commit is contained in:
@@ -65,7 +65,7 @@ type pushServiceImpl struct {
|
||||
pushRepo repository.PushRecordRepository
|
||||
deviceRepo repository.DeviceTokenRepository
|
||||
messageRepo repository.MessageRepository
|
||||
wsHub *ws.Hub
|
||||
wsHub *ws.Hub
|
||||
|
||||
// 推送队列
|
||||
pushQueue chan *pushTask
|
||||
@@ -90,7 +90,7 @@ func NewPushService(
|
||||
pushRepo: pushRepo,
|
||||
deviceRepo: deviceRepo,
|
||||
messageRepo: messageRepo,
|
||||
wsHub: wsHub,
|
||||
wsHub: wsHub,
|
||||
pushQueue: make(chan *pushTask, PushQueueSize),
|
||||
stopChan: make(chan struct{}),
|
||||
}
|
||||
@@ -190,13 +190,14 @@ func (s *pushServiceImpl) pushViaWebSocket(ctx context.Context, userID string, m
|
||||
segments := message.Segments
|
||||
|
||||
event := &dto.WSEventResponse{
|
||||
ID: fmt.Sprintf("%s", message.ID),
|
||||
Time: message.CreatedAt.UnixMilli(),
|
||||
Type: "message",
|
||||
DetailType: detailType,
|
||||
Seq: fmt.Sprintf("%d", message.Seq),
|
||||
Segments: segments,
|
||||
SenderID: message.SenderID,
|
||||
ID: fmt.Sprintf("%s", message.ID),
|
||||
Time: message.CreatedAt.UnixMilli(),
|
||||
Type: "message",
|
||||
DetailType: detailType,
|
||||
ConversationID: message.ConversationID,
|
||||
Seq: fmt.Sprintf("%d", message.Seq),
|
||||
Segments: segments,
|
||||
SenderID: message.SenderID,
|
||||
}
|
||||
|
||||
s.wsHub.PublishToUser(userID, "chat_message", map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user