From 9277356df2093b911e82f987abe7e67ad289b4db Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 12 Nov 2024 17:37:18 +0800 Subject: [PATCH] by Robin at 20241112 --- api/consts/notif_template.go | 1 + api/consts/status.go | 6 + app/mix/service/apiservice.go | 1 + app/mix/service/notif_builder_handler.go | 190 +++++++++++++++-------- app/mix/service/service.go | 43 +++-- dbstruct/moment.go | 7 + dbstruct/zonemoment.go | 15 ++ 7 files changed, 184 insertions(+), 79 deletions(-) diff --git a/api/consts/notif_template.go b/api/consts/notif_template.go index e1d8600f..f4568e1f 100644 --- a/api/consts/notif_template.go +++ b/api/consts/notif_template.go @@ -112,6 +112,7 @@ var AudNotifTempKeyMap = map[string][2]int64{ "zone|zone|profile": {AudNotifTemp_ProfilePassed, AudNotifTemp_ProfileRejected}, "moment": {AudNotifTemp_MomentPassed, AudNotifTemp_MomentRejected}, "zone_moment": {AudNotifTemp_ZoneMomentPassed, AudNotifTemp_ZoneMomentRejected}, + "zone_moment_reedition": {AudNotifTemp_ZoneMomentReeditionPassed, AudNotifTemp_ZoneMomentReeditionRejected}, } // 跳转页面id diff --git a/api/consts/status.go b/api/consts/status.go index a3d8fae3..9a6e9939 100644 --- a/api/consts/status.go +++ b/api/consts/status.go @@ -225,6 +225,12 @@ const ( ZoneMomentManuallyReview_Rejected = 2 //已复审拒绝 ) +// 私密动态是否被重新编辑 +const ( + IsReedited_No = 0 //否 + IsReedited_Yes = 1 //是 +) + // 七日内空间是否活跃 const ( ZoneIsActiveWithinAWeek_No = 0 //否 diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index dec8a553..8d950b77 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -3303,6 +3303,7 @@ func (s *Service) ApiUpdateZoneMoment(ctx *gin.Context, req *zonemomentproto.Api req.ZoneMoment.ManuallyReviewStatus = goproto.Int64(consts.ZoneMomentManuallyReview_Waiting) // 等待复审 req.ZoneMoment.ManuallyReviewOpinion = goproto.String("") // 信息抹除 req.ZoneMoment.ManuallyReviewOperator = goproto.Int64(0) // 信息抹除 + req.ZoneMoment.IsReedited = goproto.Int64(consts.IsReedited_Yes) // 已重新编辑 } err = _DefaultZoneMoment.OpUpdate(ctx, &zonemomentproto.OpUpdateReq{ diff --git a/app/mix/service/notif_builder_handler.go b/app/mix/service/notif_builder_handler.go index 7b282c8f..3eeca831 100644 --- a/app/mix/service/notif_builder_handler.go +++ b/app/mix/service/notif_builder_handler.go @@ -4,9 +4,7 @@ import ( "service/api/consts" "service/api/interfaces" accountpunishmentproto "service/api/proto/accountpunishment/proto" - momentproto "service/api/proto/moment/proto" zoneproto "service/api/proto/zone/proto" - zonemomentproto "service/api/proto/zonemoment/proto" "service/bizcommon/util" "service/dbstruct" "service/library/logger" @@ -44,6 +42,7 @@ func NewNotifBuilderHandler() *NotifBuilderHandler { func (handler *NotifBuilderHandler) init() { handler.handlerMap = make(map[int64]func(ctx *gin.Context, args ...any)) + // 注册系统通知处理 handler.handleSysNotifCancelNotif() handler.handleSyncNotifBcstVersForUser() handler.handleSyncNotifBcstVersForStreamer() @@ -56,6 +55,40 @@ func (handler *NotifBuilderHandler) init() { handler.handleSysZoneCreated() handler.handleSysZoneVasUpdated() handler.handleSysZoneThirdPartnerCreated() + // 注册审核通知处理 + handler.handleAudAvatarChangeApplied() + handler.handleAudNameChangeApplied() + handler.handleAudStreamerBasicInfoApplied() + handler.handleAudStreamerBasicInfoPassed() + handler.handleAudStreamerBasicInfoRejected() + handler.handleAudStreamerDetailsApplied() + handler.handleAudStreamerDetailsPassed() + handler.handleAudStreamerDetailsRejected() + handler.handleAudBioChangeApplied() + handler.handleAudBioPassed() + handler.handleAudBioRejected() + handler.handleAudAutoResponseMessageChangeApplied() + handler.handleAudAutoResponseMessagePassed() + handler.handleAudAutoResponseMessageRejected() + handler.handleAudCoverChangeApplied() + handler.handleAudCoverPassed() + handler.handleAudCoverRejected() + handler.handleAudAlbumChangeApplied() + handler.handleAudAlbumPassed() + handler.handleAudAlbumRejected() + handler.handleAudShortsChangeApplied() + handler.handleAudShortsPassed() + handler.handleAudShortsRejected() + handler.handleAudStreamerDirectlyUpdated() + handler.handleAudMomentCreated() + handler.handleAudMomentPassed() + handler.handleAudMomentRejected() + handler.handleAudZoneMomentCreated() + handler.handleAudZoneMomentPassed() + handler.handleAudZoneMomentRejected() + handler.handleAudZoneMomentReedited() + handler.handleAudZoneMomentReeditionPassed() + handler.handleAudZoneMomentReeditionRejected() } func (handler *NotifBuilderHandler) handleSysNotifCancelNotif() { @@ -396,31 +429,17 @@ func (handler *NotifBuilderHandler) handleAudMomentCreated() { func (handler *NotifBuilderHandler) handleAudMomentPassed() { handler.handlerMap[consts.AudNotifTemp_MomentPassed] = func(ctx *gin.Context, args ...any) { - req := args[0].(*momentproto.OpReviewReq) - moments, err := _DefaultMoment.GetByIds(ctx, req.MomentIds) - if err != nil { - logger.Error("_DefaultMoment GetByIds fail, req: %v, err: %v", util.ToJson(req), err) - return - } - for _, moment := range moments { - ctStr := util.FormatTsAsNotifT(moment.GetCt()) - DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_MomentPassed, moment.GetMid(), ctStr) - } + moment := args[0].(*dbstruct.Moment) + ctStr := util.FormatTsAsNotifT(moment.GetCt()) + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_MomentPassed, moment.GetMid(), ctStr) } } func (handler *NotifBuilderHandler) handleAudMomentRejected() { handler.handlerMap[consts.AudNotifTemp_MomentRejected] = func(ctx *gin.Context, args ...any) { - req := args[0].(*momentproto.OpReviewReq) - moments, err := _DefaultMoment.GetByIds(ctx, req.MomentIds) - if err != nil { - logger.Error("_DefaultMoment GetByIds fail, req: %v, err: %v", util.ToJson(req), err) - return - } - for _, moment := range moments { - ctStr := util.FormatTsAsNotifT(moment.GetCt()) - DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_MomentRejected, moment.GetMid(), ctStr) - } + moment := args[0].(*dbstruct.Moment) + ctStr := util.FormatTsAsNotifT(moment.GetCt()) + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_MomentRejected, moment.GetMid(), ctStr) } } @@ -435,24 +454,26 @@ func (handler *NotifBuilderHandler) handleAudZoneMomentCreated() { func (handler *NotifBuilderHandler) handleAudZoneMomentPassed() { handler.handlerMap[consts.AudNotifTemp_ZoneMomentPassed] = func(ctx *gin.Context, args ...any) { - req := args[0].(*zonemomentproto.OpReviewReq) - zonemoments, err := _DefaultZoneMoment.GetByIds(ctx, req.ZoneMomentIds) - if err != nil { - logger.Error("_DefaultZoneMoment GetByIds fail, req: %v, err: %v", util.ToJson(req), err) + zonemoment := args[0].(*dbstruct.ZoneMoment) + if zonemoment.GetIsReedited() != consts.IsReedited_No { return } - for _, zonemoment := range zonemoments { - ctStr := util.FormatTsAsNotifT(zonemoment.GetCt()) - cTypeDesc := consts.ZoneMomentCTypeDescMap[zonemoment.GetCType()] - mTypeDesc := consts.MTypeDescMap[zonemoment.GetMType()] - DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_ZoneMomentPassed, zonemoment.GetMid(), ctStr, cTypeDesc, mTypeDesc) - } + ctStr := util.FormatTsAsNotifT(zonemoment.GetCt()) + cTypeDesc := consts.ZoneMomentCTypeDescMap[zonemoment.GetCType()] + mTypeDesc := consts.MTypeDescMap[zonemoment.GetMType()] + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_ZoneMomentPassed, zonemoment.GetMid(), ctStr, cTypeDesc, mTypeDesc) + } } func (handler *NotifBuilderHandler) handleAudZoneMomentRejected() { handler.handlerMap[consts.AudNotifTemp_ZoneMomentRejected] = func(ctx *gin.Context, args ...any) { - req := args[0].(*zonemomentproto.OpReviewReq) + zonemoment := args[0].(*dbstruct.ZoneMoment) + remarks := args[1].(string) + + if zonemoment.GetIsReedited() != consts.IsReedited_No { + return + } // 获取跳转路径 frontendroute, err := _DefaultFrontendRoute.GetById(ctx, consts.FrontendRouteId_ZoneMomentEdit) @@ -460,39 +481,28 @@ func (handler *NotifBuilderHandler) handleAudZoneMomentRejected() { logger.Error("_DefaultFrontendRoute GetById fail, err: %v", err) } - zonemoments, err := _DefaultZoneMoment.GetByIds(ctx, req.ZoneMomentIds) - if err != nil { - logger.Error("_DefaultZoneMoment GetByIds fail, req: %v, err: %v", util.ToJson(req), err) - return + // 获取缩略图 + preview := &dbstruct.MediaComponent{} + if zonemoment.GetMType() == consts.MediaTypeImg { // 取首图 + imageIds := zonemoment.MediaComp.GetImageIds() + preview.ImageIds = util.Int64Slice([]int64{imageIds[0]}) + } else if zonemoment.GetMType() == consts.MediaTypeVideo { // 取封面 + mediaFillables := make([]mediafiller.MediaFillable, 0) + mediaFillables = append(mediaFillables, zonemoment.MediaComp) + coverIds, _ := mediafiller.GetCoverIds(ctx, mediaFillables) + preview.ImageIds = util.Int64Slice(coverIds) } - for _, zonemoment := range zonemoments { - // 获取缩略图 - preview := &dbstruct.MediaComponent{} - if zonemoment.GetMType() == consts.MediaTypeImg { // 取首图 - imageIds := zonemoment.MediaComp.GetImageIds() - preview.ImageIds = util.Int64Slice([]int64{imageIds[0]}) - } else if zonemoment.GetMType() == consts.MediaTypeVideo { // 取封面 - mediaFillables := make([]mediafiller.MediaFillable, 0) - mediaFillables = append(mediaFillables, zonemoment) - coverIds, err := mediafiller.GetCoverIds(ctx, mediaFillables) - if err != nil { - logger.Error("GetCoverIds fail, req: %v, err: %v", util.ToJson(req), err) - } - preview.ImageIds = util.Int64Slice(coverIds) - } + ctStr := util.FormatTsAsNotifT(zonemoment.GetCt()) + cTypeDesc := consts.ZoneMomentCTypeDescMap[zonemoment.GetCType()] + mTypeDesc := consts.MTypeDescMap[zonemoment.GetMType()] + argsMap := make(map[string]any) + argsMap["template_params"] = []any{ctStr, cTypeDesc, mTypeDesc, remarks} + argsMap["action"] = frontendroute.GetAction() + argsMap["params"] = frontendroute.GetRoutePath() + argsMap["thumbnail"] = preview - ctStr := util.FormatTsAsNotifT(zonemoment.GetCt()) - cTypeDesc := consts.ZoneMomentCTypeDescMap[zonemoment.GetCType()] - mTypeDesc := consts.MTypeDescMap[zonemoment.GetMType()] - argsMap := make(map[string]any) - argsMap["template_params"] = []any{ctStr, cTypeDesc, mTypeDesc, req.ManuallyReviewOpinion} - argsMap["action"] = frontendroute.GetAction() - argsMap["params"] = frontendroute.GetRoutePath() - argsMap["thumbnail"] = preview - - DefaultService.utilWriteNotifInfoByMap(ctx, consts.SysNotifTemp_ZoneCreated, zonemoment.GetMid(), argsMap) - } + DefaultService.utilWriteNotifInfoByMap(ctx, consts.SysNotifTemp_ZoneCreated, zonemoment.GetMid(), argsMap) } } @@ -502,3 +512,57 @@ func (handler *NotifBuilderHandler) handleAudZoneMomentReedited() { DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_ZoneMomentReedited, zonemoment.GetMid()) } } + +func (handler *NotifBuilderHandler) handleAudZoneMomentReeditionPassed() { + handler.handlerMap[consts.AudNotifTemp_ZoneMomentReeditionPassed] = func(ctx *gin.Context, args ...any) { + zonemoment := args[0].(*dbstruct.ZoneMoment) + if zonemoment.GetIsReedited() != consts.IsReedited_Yes { + return + } + ctStr := util.FormatTsAsNotifT(zonemoment.GetCt()) + cTypeDesc := consts.ZoneMomentCTypeDescMap[zonemoment.GetCType()] + mTypeDesc := consts.MTypeDescMap[zonemoment.GetMType()] + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_ZoneMomentReeditionPassed, zonemoment.GetMid(), ctStr, cTypeDesc, mTypeDesc) + + } +} + +func (handler *NotifBuilderHandler) handleAudZoneMomentReeditionRejected() { + handler.handlerMap[consts.AudNotifTemp_ZoneMomentReeditionRejected] = func(ctx *gin.Context, args ...any) { + zonemoment := args[0].(*dbstruct.ZoneMoment) + remarks := args[1].(string) + + if zonemoment.GetIsReedited() != consts.IsReedited_Yes { + return + } + + // 获取跳转路径 + frontendroute, err := _DefaultFrontendRoute.GetById(ctx, consts.FrontendRouteId_ZoneMomentEdit) + if err != nil { + logger.Error("_DefaultFrontendRoute GetById fail, err: %v", err) + } + + // 获取缩略图 + preview := &dbstruct.MediaComponent{} + if zonemoment.GetMType() == consts.MediaTypeImg { // 取首图 + imageIds := zonemoment.MediaComp.GetImageIds() + preview.ImageIds = util.Int64Slice([]int64{imageIds[0]}) + } else if zonemoment.GetMType() == consts.MediaTypeVideo { // 取封面 + mediaFillables := make([]mediafiller.MediaFillable, 0) + mediaFillables = append(mediaFillables, zonemoment.MediaComp) + coverIds, _ := mediafiller.GetCoverIds(ctx, mediaFillables) + preview.ImageIds = util.Int64Slice(coverIds) + } + + ctStr := util.FormatTsAsNotifT(zonemoment.GetCt()) + cTypeDesc := consts.ZoneMomentCTypeDescMap[zonemoment.GetCType()] + mTypeDesc := consts.MTypeDescMap[zonemoment.GetMType()] + argsMap := make(map[string]any) + argsMap["template_params"] = []any{ctStr, cTypeDesc, mTypeDesc, remarks} + argsMap["action"] = frontendroute.GetAction() + argsMap["params"] = frontendroute.GetRoutePath() + argsMap["thumbnail"] = preview + + DefaultService.utilWriteNotifInfoByMap(ctx, consts.SysNotifTemp_ZoneCreated, zonemoment.GetMid(), argsMap) + } +} diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 21c4614e..33f734e7 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -1498,6 +1498,14 @@ func (s *Service) OpReviewMoment(ctx *gin.Context, req *momentproto.OpReviewReq) return } + // 查询得到动态 + moments, err := _DefaultMoment.GetByIds(ctx, req.MomentIds) + if err != nil { + logger.Error("_DefaultMoment GetByIds fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneMomentSrvFail + return + } + // 更新请求,如果是通过,则恢复删除标志 updateReq := &momentproto.OpUpdateReq{ Moment: &dbstruct.Moment{ @@ -1509,7 +1517,7 @@ func (s *Service) OpReviewMoment(ctx *gin.Context, req *momentproto.OpReviewReq) } // 更新动态的状态 - err := _DefaultMoment.OpUpdateByIdsAndStatus(ctx, updateReq, req.MomentIds, consts.Moment_ManuallyReviewing) + err = _DefaultMoment.OpUpdateByIdsAndStatus(ctx, updateReq, req.MomentIds, consts.Moment_ManuallyReviewing) if err != nil { logger.Error("_DefaultMoment OpUpdateByIds fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeMomentSrvFail @@ -1536,7 +1544,9 @@ func (s *Service) OpReviewMoment(ctx *gin.Context, req *momentproto.OpReviewReq) } // 发送通知 - DefaultNotifBuilderHandler.Handle(ctx)(util.GetNotifScene("moment", req.OpType))(req) + for _, moment := range moments { + DefaultNotifBuilderHandler.Handle(ctx)(util.GetNotifScene("moment", req.OpType))(moment) + } return } @@ -4471,8 +4481,16 @@ func (s *Service) OpReviewZoneMoment(ctx *gin.Context, req *zonemomentproto.OpRe return } + // 查询得到空间动态 + zonemoments, err := _DefaultZoneMoment.GetByIds(ctx, req.ZoneMomentIds) + if err != nil { + logger.Error("_DefaultZoneMoment GetByIds fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneMomentSrvFail + return + } + // 更新动态的状态 - err := _DefaultZoneMoment.OpUpdateByIdsAndStatus(ctx, &zonemomentproto.OpUpdateReq{ + err = _DefaultZoneMoment.OpUpdateByIdsAndStatus(ctx, &zonemomentproto.OpUpdateReq{ ZoneMoment: &dbstruct.ZoneMoment{ Status: goproto.Int64(finalZoneMomentStatus), ManuallyReviewStatus: goproto.Int64(finalManuallyReviewStatus), @@ -4504,20 +4522,10 @@ func (s *Service) OpReviewZoneMoment(ctx *gin.Context, req *zonemomentproto.OpRe return } // 增加空间内统计总数 - for _, id := range req.ZoneMomentIds { - zonemoment, err := _DefaultZoneMoment.GetById(ctx, id) - if err != nil { - logger.Error("_DefaultZoneMoment GetById fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeZoneMomentSrvFail - return - } - if zonemoment == nil { - ec = errcode.ErrCodeZoneMomentNotExist - return - } + for _, zonemoment := range zonemoments { mediaCountInc := len(zonemoment.MediaComp.GetImageIds()) videoCountInc := len(zonemoment.MediaComp.GetVideoIds()) - err = _DefaultZone.RecordStatisticsById(ctx, util.DerefInt64(zonemoment.Zid), 1, int64(mediaCountInc), int64(videoCountInc)) + err = _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), 1, int64(mediaCountInc), int64(videoCountInc)) if err != nil { logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeZoneSrvFail @@ -4527,7 +4535,10 @@ func (s *Service) OpReviewZoneMoment(ctx *gin.Context, req *zonemomentproto.OpRe } // 发送通知 - DefaultNotifBuilderHandler.Handle(ctx)(util.GetNotifScene("zone_moment", req.OpType))(req) + for _, zonemoment := range zonemoments { + DefaultNotifBuilderHandler.Handle(ctx)(util.GetNotifScene("zone_moment", req.OpType), + util.GetNotifScene("zone_moment_reedition", req.OpType))(zonemoment, req.ManuallyReviewOpinion) + } return } diff --git a/dbstruct/moment.go b/dbstruct/moment.go index 76a9773f..48252084 100644 --- a/dbstruct/moment.go +++ b/dbstruct/moment.go @@ -39,6 +39,13 @@ func (p *Moment) GetId() int64 { return 0 } +func (p *Moment) GetCt() int64 { + if p != nil && p.Ct != nil { + return *p.Ct + } + return 0 +} + type MomentStatInfo struct { Mid *int64 `json:"id" bson:"_id"` // mid Count *int64 `json:"count" bson:"count"` // count diff --git a/dbstruct/zonemoment.go b/dbstruct/zonemoment.go index 8c2a450d..f8c6c561 100644 --- a/dbstruct/zonemoment.go +++ b/dbstruct/zonemoment.go @@ -30,6 +30,7 @@ type ZoneMoment struct { ManuallyReviewOpinion *string `json:"manually_review_opinion" bson:"manually_review_opinion"` // 人工复审意见 ManuallyReviewOperator *int64 `json:"manually_review_operator" bson:"manually_review_operator"` // 人工复审操作人 IsHeaded *int64 `json:"is_headed" bson:"is_headed"` // 是否已置顶 + IsReedited *int64 `json:"is_reedited" bson:"is_reedited"` // 是否已重新编辑 Ct *int64 `json:"ct" bson:"ct"` // 创建时间 Ut *int64 `json:"ut" bson:"ut"` // 更新时间 DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记 @@ -131,6 +132,20 @@ func (p *ZoneMoment) GetCoinPrice() int64 { return util.RoundUp(float64(p.GetPrice()) / 10.0) } +func (p *ZoneMoment) GetCt() int64 { + if p != nil && p.Ct != nil { + return *p.Ct + } + return 0 +} + +func (p *ZoneMoment) GetIsReedited() int64 { + if p != nil && p.IsReedited != nil { + return *p.IsReedited + } + return 0 +} + type ZoneMomentStatInfo struct { Mid *int64 `json:"id" bson:"_id"` // mid Count *int64 `json:"count" bson:"count"` // count