fix(server): improve message handling and data privacy
- fix unread count calculation logic in message repository - implement logic to retrieve other participant's last read sequence in conversation handlers - mask real names in verification record responses for privacy - improve error reporting in main entry point by using stderr instead of zap logger during initialization
This commit is contained in:
@@ -244,6 +244,12 @@ func (h *MessageHandler) GetConversationByID(c *gin.Context) {
|
||||
|
||||
// 获取对方用户的已读位置
|
||||
otherLastReadSeq := int64(0)
|
||||
for _, p := range allParticipants {
|
||||
if p.UserID != userID {
|
||||
otherLastReadSeq = p.LastReadSeq
|
||||
break
|
||||
}
|
||||
}
|
||||
response.Success(c, dto.ConvertConversationToDetailResponse(conv, participants, unreadCount, nil, myLastReadSeq, otherLastReadSeq, isPinned, notificationMuted))
|
||||
}
|
||||
|
||||
@@ -768,6 +774,12 @@ func (h *MessageHandler) HandleGetConversation(c *gin.Context) {
|
||||
|
||||
// 获取对方用户的已读位置
|
||||
otherLastReadSeq := int64(0)
|
||||
for _, p := range allParticipants {
|
||||
if p.UserID != userID {
|
||||
otherLastReadSeq = p.LastReadSeq
|
||||
break
|
||||
}
|
||||
}
|
||||
response.Success(c, dto.ConvertConversationToDetailResponse(conv, participants, unreadCount, nil, myLastReadSeq, otherLastReadSeq, isPinned, notificationMuted))
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"with_you/internal/dto"
|
||||
"with_you/internal/model"
|
||||
"with_you/internal/pkg/response"
|
||||
"with_you/internal/pkg/sanitizer"
|
||||
"with_you/internal/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -114,7 +115,7 @@ func convertVerificationRecordToResponse(record *model.VerificationRecord) *dto.
|
||||
UserID: record.UserID,
|
||||
Identity: string(record.Identity),
|
||||
Status: string(record.Status),
|
||||
RealName: record.RealName,
|
||||
RealName: sanitizer.MaskValue("real_name", record.RealName),
|
||||
StudentID: record.StudentID,
|
||||
EmployeeID: record.EmployeeID,
|
||||
Department: record.Department,
|
||||
|
||||
Reference in New Issue
Block a user