feat(report): integrate report handling into application
- Added Report and AdminReport handlers to manage report-related functionalities. - Updated router and wire generation to include new report services and handlers. - Enhanced error handling in report and admin report handlers to return appropriate status codes. - Refactored notification logic in admin report service to utilize a dedicated notification repository and push service.
This commit is contained in:
@@ -379,13 +379,7 @@ func (s *adminReportServiceImpl) deleteTargetContent(ctx context.Context, target
|
||||
|
||||
// notifyReporter 通知举报人
|
||||
func (s *adminReportServiceImpl) notifyReporter(ctx context.Context, report *model.Report, action, result string) {
|
||||
if s.systemNotify == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取举报人信息
|
||||
reporter, err := s.userRepo.GetByID(report.ReporterID)
|
||||
if err != nil {
|
||||
if s.notifyRepo == nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -408,22 +402,26 @@ func (s *adminReportServiceImpl) notifyReporter(ctx context.Context, report *mod
|
||||
}
|
||||
}
|
||||
|
||||
// 发送通知
|
||||
_, err = s.systemNotify.CreateNotification(ctx, &model.SystemNotification{
|
||||
// 创建通知
|
||||
notification := &model.SystemNotification{
|
||||
ReceiverID: report.ReporterID,
|
||||
Type: notifyType,
|
||||
Title: title,
|
||||
Content: content,
|
||||
Type: notifyType,
|
||||
Title: title,
|
||||
Content: content,
|
||||
ExtraData: &model.SystemNotificationExtra{
|
||||
ActorIDStr: report.ReporterID,
|
||||
ActorName: reporter.Nickname,
|
||||
TargetID: report.TargetID,
|
||||
TargetType: string(report.TargetType),
|
||||
ActorIDStr: report.ReporterID,
|
||||
TargetID: report.TargetID,
|
||||
TargetType: string(report.TargetType),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
zap.L().Error("failed to send report notification", zap.Error(err))
|
||||
if err := s.notifyRepo.Create(notification); err != nil {
|
||||
zap.L().Error("failed to create notification", zap.Error(err))
|
||||
}
|
||||
|
||||
// 推送通知
|
||||
if s.pushService != nil {
|
||||
s.pushService.PushSystemNotification(ctx, report.ReporterID, notification)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,14 +462,9 @@ func extractTextFromSegments(segments model.MessageSegments) string {
|
||||
}
|
||||
|
||||
// convertUserToBrief 将用户模型转换为举报用的简要信息
|
||||
func convertUserToBrief(user *model.User) *dto.ReportUserBrief {
|
||||
func convertUserToBrief(user *model.User) *dto.UserResponse {
|
||||
if user == nil {
|
||||
return nil
|
||||
}
|
||||
return &dto.ReportUserBrief{
|
||||
ID: user.ID,
|
||||
Username: user.Username,
|
||||
Nickname: user.Nickname,
|
||||
Avatar: user.Avatar,
|
||||
}
|
||||
return dto.ConvertUserToResponse(user)
|
||||
}
|
||||
Reference in New Issue
Block a user