refactor: upgrade to Go 1.26 and modernize code idioms
- Replace `interface{}` with `any` type alias across all packages
- Use built-in `min()`/`max()` for parameter clamping
- Use `slices.SortFunc`, `slices.Min`, `slices.Max` for cleaner code
- Use `strings.Cut()` for simpler string parsing in auth middleware
- Use `errors.Is()` for proper error comparison in handlers
- Update dependencies: golang.org/x/image 0.37.0 -> 0.38.0
- Add Wire code generation guidelines to ARCHITECTURE.md
- Disable Go cache in CI build workflow
This commit is contained in:
@@ -97,7 +97,7 @@ func NewChatService(
|
||||
}
|
||||
}
|
||||
|
||||
func (s *chatServiceImpl) publishToUsers(userIDs []string, event string, payload interface{}) {
|
||||
func (s *chatServiceImpl) publishToUsers(userIDs []string, event string, payload any) {
|
||||
if s.wsHub == nil || len(userIDs) == 0 {
|
||||
return
|
||||
}
|
||||
@@ -329,7 +329,7 @@ func (s *chatServiceImpl) SendMessage(ctx context.Context, senderID string, conv
|
||||
if conv.Type == model.ConversationTypeGroup {
|
||||
detailType = "group"
|
||||
}
|
||||
s.publishToUsers(targetIDs, "chat_message", map[string]interface{}{
|
||||
s.publishToUsers(targetIDs, "chat_message", map[string]any{
|
||||
"detail_type": detailType,
|
||||
"message": dto.ConvertMessageToResponse(message),
|
||||
})
|
||||
@@ -342,7 +342,7 @@ func (s *chatServiceImpl) SendMessage(ctx context.Context, senderID string, conv
|
||||
s.conversationCache.InvalidateUnreadCount(p.UserID, conversationID)
|
||||
}
|
||||
if totalUnread, uErr := s.repo.GetAllUnreadCount(p.UserID); uErr == nil {
|
||||
s.publishToUsers([]string{p.UserID}, "conversation_unread", map[string]interface{}{
|
||||
s.publishToUsers([]string{p.UserID}, "conversation_unread", map[string]any{
|
||||
"conversation_id": conversationID,
|
||||
"total_unread": totalUnread,
|
||||
})
|
||||
@@ -490,7 +490,7 @@ func (s *chatServiceImpl) MarkAsRead(ctx context.Context, conversationID string,
|
||||
for _, p := range participants {
|
||||
targetIDs = append(targetIDs, p.UserID)
|
||||
}
|
||||
s.publishToUsers(targetIDs, "message_read", map[string]interface{}{
|
||||
s.publishToUsers(targetIDs, "message_read", map[string]any{
|
||||
"detail_type": detailType,
|
||||
"conversation_id": conversationID,
|
||||
"group_id": groupID,
|
||||
@@ -499,7 +499,7 @@ func (s *chatServiceImpl) MarkAsRead(ctx context.Context, conversationID string,
|
||||
})
|
||||
}
|
||||
if totalUnread, uErr := s.repo.GetAllUnreadCount(userID); uErr == nil {
|
||||
s.publishToUsers([]string{userID}, "conversation_unread", map[string]interface{}{
|
||||
s.publishToUsers([]string{userID}, "conversation_unread", map[string]any{
|
||||
"conversation_id": conversationID,
|
||||
"total_unread": totalUnread,
|
||||
})
|
||||
@@ -579,7 +579,7 @@ func (s *chatServiceImpl) RecallMessage(ctx context.Context, messageID string, u
|
||||
for _, p := range participants {
|
||||
targetIDs = append(targetIDs, p.UserID)
|
||||
}
|
||||
s.publishToUsers(targetIDs, "message_recall", map[string]interface{}{
|
||||
s.publishToUsers(targetIDs, "message_recall", map[string]any{
|
||||
"detail_type": detailType,
|
||||
"conversation_id": message.ConversationID,
|
||||
"group_id": groupID,
|
||||
@@ -652,7 +652,7 @@ func (s *chatServiceImpl) SendTyping(ctx context.Context, senderID string, conve
|
||||
continue
|
||||
}
|
||||
if s.wsHub != nil {
|
||||
s.wsHub.PublishToUser(p.UserID, "typing", map[string]interface{}{
|
||||
s.wsHub.PublishToUser(p.UserID, "typing", map[string]any{
|
||||
"detail_type": detailType,
|
||||
"conversation_id": conversationID,
|
||||
"user_id": senderID,
|
||||
|
||||
Reference in New Issue
Block a user