From 1de4fba176cd05f39e725e21458472e6f5993413 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Mon, 11 Nov 2024 15:12:48 +0800 Subject: [PATCH] 1 --- app/mix/service/apiservice.go | 20 +++- app/mix/service/notif_builder_handler.go | 124 +++++++++++++++++++++++ app/mix/service/service.go | 15 ++- 3 files changed, 155 insertions(+), 4 deletions(-) diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index a8c46479..3fa8db31 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -387,6 +387,8 @@ func (s *Service) ApiUpdateAccount(ctx *gin.Context, req *accountproto.ApiUpdate } // 发送通知 + DefaultNotifBuilderHandler.Handle(ctx)( + consts.AudNotifTemp_AvatarChangeApplied, consts.AudNotifTemp_NameChangeApplied)(req.Account) return } @@ -1072,7 +1074,8 @@ func (s *Service) ApiCreateStreamerAuthApprovalBasic(ctx *gin.Context, req *stre return } - ctx.Set("notif_template_id", consts.AudNotifTemp_StreamerBasicInfoApplied) + // 发送通知 + DefaultNotifBuilderHandler.Handle(ctx)(consts.AudNotifTemp_StreamerBasicInfoApplied)(req.StreamerAuthApprovalBasic) return } @@ -1206,6 +1209,9 @@ func (s *Service) ApiCreateStreamerAuthApprovalDetails(ctx *gin.Context, req *st s.CreateStreamerAuthApprovalDetailsTextAudit(ctx, req.StreamerAuthApprovalDetails) s.CreateStreamerAuthApprovalDetailsVideoModeration(ctx, req.StreamerAuthApprovalDetails) + // 发送通知 + DefaultNotifBuilderHandler.Handle(ctx)(consts.AudNotifTemp_StreamerDetailsApplied)(req.StreamerAuthApprovalDetails) + return } @@ -1463,6 +1469,12 @@ func (s *Service) ApiUpdateStreamer(ctx *gin.Context, req *streamerproto.ApiUpda return } + // 发送通知 + DefaultNotifBuilderHandler.Handle(ctx)( + consts.AudNotifTemp_BioChangeApplied, consts.AudNotifTemp_AutoResponseMessageChangeApplied, + consts.AudNotifTemp_CoverChangeApplied, consts.AudNotifTemp_AlbumChangeApplied, + consts.AudNotifTemp_ShortsChangeApplied, consts.AudNotifTemp_StreamerDirectlyUpdated)(req.Streamer) + return } @@ -2758,7 +2770,8 @@ func (s *Service) ApiCreateZone(ctx *gin.Context, req *zoneproto.ApiCreateReq) ( } }() - DefaultNotifBuilderHandler.Handle(ctx)(consts.SysNotifTemp_ZoneCreated)(req.Zone) + DefaultNotifBuilderHandler.Handle(ctx)( + consts.AudNotifTemp_ProfileChangeApplied, consts.SysNotifTemp_ZoneCreated)(req.Zone) return } @@ -2818,7 +2831,8 @@ func (s *Service) ApiUpdateZone(ctx *gin.Context, req *zoneproto.ApiUpdateReq) ( s.CreateZoneTextAudit(ctx, oldZone, req.Zone) // 发送通知 - DefaultNotifBuilderHandler.Handle(ctx)(consts.SysNotifTemp_ZoneVasUpdated)(req) + DefaultNotifBuilderHandler.Handle(ctx)( + consts.AudNotifTemp_ProfileChangeApplied, consts.SysNotifTemp_ZoneVasUpdated)(req) return } diff --git a/app/mix/service/notif_builder_handler.go b/app/mix/service/notif_builder_handler.go index e7192cbe..ee7789f1 100644 --- a/app/mix/service/notif_builder_handler.go +++ b/app/mix/service/notif_builder_handler.go @@ -181,3 +181,127 @@ func (handler *NotifBuilderHandler) handleSysMembershipPurchased() { DefaultService.utilWriteNotifInfo(ctx, consts.SysNotifTemp_MembershipPurchased, mid) } } + +func (handler *NotifBuilderHandler) handleAudAvatarChangeApplied() { + handler.handlerMap[consts.AudNotifTemp_AvatarChangeApplied] = func(ctx *gin.Context, args ...any) { + account := args[0].(*dbstruct.Account) + if account.Avatar != nil { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_AvatarChangeApplied, account.GetMid()) + } + } +} + +func (handler *NotifBuilderHandler) handleAudNameChangeApplied() { + handler.handlerMap[consts.AudNotifTemp_NameChangeApplied] = func(ctx *gin.Context, args ...any) { + account := args[0].(*dbstruct.Account) + if account.Name != nil { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_NameChangeApplied, account.GetMid()) + } + } +} + +func (handler *NotifBuilderHandler) handleAudStreamerBasicInfoApplied() { + handler.handlerMap[consts.AudNotifTemp_StreamerBasicInfoApplied] = func(ctx *gin.Context, args ...any) { + streamerBasic := args[0].(*dbstruct.StreamerAuthApprovalBasic) + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_StreamerBasicInfoApplied, streamerBasic.GetMid()) + } +} + +func (handler *NotifBuilderHandler) handleAudStreamerBasicInfoPassed() { + handler.handlerMap[consts.AudNotifTemp_StreamerBasicInfoPassed] = func(ctx *gin.Context, args ...any) { + mids := args[0].([]int64) + for _, mid := range mids { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_StreamerBasicInfoPassed, mid) + } + } +} + +func (handler *NotifBuilderHandler) handleAudStreamerBasicInfoRejected() { + handler.handlerMap[consts.AudNotifTemp_StreamerBasicInfoRejected] = func(ctx *gin.Context, args ...any) { + mids := args[0].([]int64) + remarks := args[1].(string) + for _, mid := range mids { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_StreamerBasicInfoRejected, mid, remarks) + } + } +} + +func (handler *NotifBuilderHandler) handleAudStreamerDetailsApplied() { + handler.handlerMap[consts.AudNotifTemp_StreamerDetailsApplied] = func(ctx *gin.Context, args ...any) { + streamerDetails := args[0].(*dbstruct.StreamerAuthApprovalDetails) + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_StreamerDetailsApplied, streamerDetails.GetMid()) + } +} + +func (handler *NotifBuilderHandler) handleAudStreamerDetailsPassed() { + handler.handlerMap[consts.AudNotifTemp_StreamerDetailsPassed] = func(ctx *gin.Context, args ...any) { + mids := args[0].([]int64) + for _, mid := range mids { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_StreamerDetailsPassed, mid) + } + } +} + +func (handler *NotifBuilderHandler) handleAudStreamerDetailsRejected() { + handler.handlerMap[consts.AudNotifTemp_StreamerDetailsRejected] = func(ctx *gin.Context, args ...any) { + mids := args[0].([]int64) + remarks := args[1].(string) + for _, mid := range mids { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_StreamerDetailsRejected, mid, remarks) + } + } +} + +func (handler *NotifBuilderHandler) handleAudBioChangeApplied() { + handler.handlerMap[consts.AudNotifTemp_BioChangeApplied] = func(ctx *gin.Context, args ...any) { + streamer := args[0].(*dbstruct.Streamer) + if streamer.Bio != nil { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_BioChangeApplied, streamer.GetMid()) + } + } +} + +func (handler *NotifBuilderHandler) handleAudAutoResponseMessageChangeApplied() { + handler.handlerMap[consts.AudNotifTemp_AutoResponseMessageChangeApplied] = func(ctx *gin.Context, args ...any) { + streamer := args[0].(*dbstruct.Streamer) + if streamer.AutoResponseMessage != nil { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_AutoResponseMessageChangeApplied, streamer.GetMid()) + } + } +} + +func (handler *NotifBuilderHandler) handleAudCoverChangeApplied() { + handler.handlerMap[consts.AudNotifTemp_CoverChangeApplied] = func(ctx *gin.Context, args ...any) { + streamer := args[0].(*dbstruct.Streamer) + if streamer.Cover != nil { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_CoverChangeApplied, streamer.GetMid()) + } + } +} + +func (handler *NotifBuilderHandler) handleAudAlbumChangeApplied() { + handler.handlerMap[consts.AudNotifTemp_AlbumChangeApplied] = func(ctx *gin.Context, args ...any) { + streamer := args[0].(*dbstruct.Streamer) + if streamer.Album != nil { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_AlbumChangeApplied, streamer.GetMid()) + } + } +} + +func (handler *NotifBuilderHandler) handleAudShortsChangeApplied() { + handler.handlerMap[consts.AudNotifTemp_ShortsChangeApplied] = func(ctx *gin.Context, args ...any) { + streamer := args[0].(*dbstruct.Streamer) + if streamer.Shorts != nil { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_ShortsChangeApplied, streamer.GetMid()) + } + } +} + +func (handler *NotifBuilderHandler) handleAudStreamerDirectlyUpdated() { + handler.handlerMap[consts.AudNotifTemp_StreamerDirectlyUpdated] = func(ctx *gin.Context, args ...any) { + streamer := args[0].(*dbstruct.Streamer) + if streamer.Bio == nil && streamer.AutoResponseMessage == nil { + DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_StreamerDirectlyUpdated, streamer.GetMid()) + } + } +} diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 7f59afe3..a78e49c6 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -2053,6 +2053,10 @@ func (s *Service) OpApproveStreamerAuthApprovalBasic(ctx *gin.Context, req *stre ec = errcode.ErrCodeStreamerAuthApprovalDetailsSrvFail return } + + // 发送通知 + DefaultNotifBuilderHandler.Handle(ctx)( + consts.AudNotifTemp_StreamerBasicInfoRejected)(mids, util.DerefString(req.Remarks)) return } @@ -2102,6 +2106,9 @@ func (s *Service) OpApproveStreamerAuthApprovalBasic(ctx *gin.Context, req *stre ec = errcode.ErrCodeAccountSrvFail return } + + // 发送通知 + DefaultNotifBuilderHandler.Handle(ctx)(consts.AudNotifTemp_StreamerBasicInfoPassed)(midList) } return @@ -2246,6 +2253,11 @@ func (s *Service) OpApproveStreamerAuthApprovalDetails(ctx *gin.Context, req *st ec = errcode.ErrCodeStreamerAuthApprovalDetailsSrvFail return } + + // 发送通知 + DefaultNotifBuilderHandler.Handle(ctx)( + consts.AudNotifTemp_StreamerDetailsRejected)(mids, util.DerefString(req.Remarks)) + return } @@ -2324,7 +2336,8 @@ func (s *Service) OpApproveStreamerAuthApprovalDetails(ctx *gin.Context, req *st } // 发送通知 - DefaultNotifBuilderHandler.Handle(ctx)(consts.SysNotifTemp_StreamerAuthApprovalPassed)(mids) + DefaultNotifBuilderHandler.Handle(ctx)( + consts.AudNotifTemp_StreamerDetailsPassed, consts.SysNotifTemp_StreamerAuthApprovalPassed)(mids) } return