752 lines
30 KiB
Go
752 lines
30 KiB
Go
package service
|
|
|
|
import (
|
|
"service/api/consts"
|
|
"service/api/interfaces"
|
|
accountpunishmentproto "service/api/proto/accountpunishment/proto"
|
|
streamerproto "service/api/proto/streamer/proto"
|
|
zoneproto "service/api/proto/zone/proto"
|
|
"service/bizcommon/util"
|
|
"service/dbstruct"
|
|
"service/library/logger"
|
|
"service/library/mediafiller"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
goproto "google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
var DefaultNotifBuilderHandler *NotifBuilderHandler
|
|
|
|
type NotifBuilderHandler struct {
|
|
// 处理器map
|
|
handlerMap map[int64]func(ctx *gin.Context, args ...any)
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) Handle(ctx *gin.Context) func(scenes ...int64) func(args ...any) {
|
|
return func(scenes ...int64) func(args ...any) {
|
|
return func(args ...any) {
|
|
for _, scene := range scenes {
|
|
handlerFunc, ok := handler.handlerMap[scene]
|
|
if ok {
|
|
handlerFunc(ctx, args...)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func NewNotifBuilderHandler() *NotifBuilderHandler {
|
|
handler := &NotifBuilderHandler{}
|
|
handler.init()
|
|
return handler
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) init() {
|
|
handler.handlerMap = make(map[int64]func(ctx *gin.Context, args ...any))
|
|
// 注册系统通知处理
|
|
handler.handleSysNotifCancelNotif()
|
|
handler.handleSyncNotifBcstVersForUser()
|
|
handler.handleSyncNotifBcstVersForStreamer()
|
|
handler.handleSysFirstLogin()
|
|
handler.handleSysStreamerPunished()
|
|
handler.handleSysStreamerPunishmentEnds()
|
|
handler.handleSysPswdChanged()
|
|
handler.handleSysAcctCancellationApplied()
|
|
handler.handleSysStreamerAuthApprovalPassed()
|
|
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) GetVasNotifScenes(key string) func(args ...any) []int64 {
|
|
ctx := &gin.Context{}
|
|
switch key {
|
|
case dbstruct.ProductIdH5ZoneSuperfanship:
|
|
scenes := dbstruct.VasNotifTempKeyMap[dbstruct.ProductIdH5ZoneSuperfanship]
|
|
return func(args ...any) []int64 { // 过第一次校验
|
|
zid := args[0].(int64)
|
|
zVas, _ := _DefaultVas.GetZoneVasInfo(ctx, zid)
|
|
if zVas.IsSuperfanshipGiveWechat == 0 { // 不赠送微信
|
|
return []int64{scenes[0], scenes[1]}
|
|
} else {
|
|
uVas, _ := _DefaultVas.GetUserVasInfo(ctx, zVas.Mid)
|
|
if uVas.WechatLockType == dbstruct.UserVasLockTypeOpen {
|
|
return []int64{scenes[0], scenes[2]}
|
|
} else {
|
|
return []int64{scenes[0], scenes[3]}
|
|
}
|
|
}
|
|
}
|
|
default:
|
|
return func(args ...any) []int64 {
|
|
return dbstruct.VasNotifTempKeyMap[key]
|
|
}
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSysNotifCancelNotif() {
|
|
handler.handlerMap[consts.CtrlNotifTemp_CancelNotif] = func(ctx *gin.Context, args ...any) {
|
|
nidAccessor := args[0].(interfaces.NidAccessible)
|
|
DefaultService.utilWriteNotifCancel(ctx, nidAccessor)
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSysFirstLogin() {
|
|
handler.handlerMap[consts.SysNotifTemp_FirstLogin] = func(ctx *gin.Context, args ...any) {
|
|
account := args[0].(*dbstruct.Account)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.SysNotifTemp_FirstLogin, account.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSyncNotifBcstVersForUser() {
|
|
handler.handlerMap[consts.CtrlNotifTemp_SyncNotifBcstVersForUser] = func(ctx *gin.Context, args ...any) {
|
|
account := args[0].(*dbstruct.Account)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.CtrlNotifTemp_SyncNotifBcstVersForUser, account.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSyncNotifBcstVersForStreamer() {
|
|
handler.handlerMap[consts.CtrlNotifTemp_SyncNotifBcstVersForStreamer] = func(ctx *gin.Context, args ...any) {
|
|
account := args[0].(*dbstruct.Account)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.CtrlNotifTemp_SyncNotifBcstVersForStreamer, account.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSysStreamerPunished() {
|
|
handler.handlerMap[consts.SysNotifTemp_StreamerPunished] = func(ctx *gin.Context, args ...any) {
|
|
acctpunishment := args[0].(*dbstruct.AccountPunishment)
|
|
// 封禁通知
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.SysNotifTemp_StreamerPunished, acctpunishment.GetMid(),
|
|
consts.AccountPunishmentMap[acctpunishment.GetType()], util.FormatTsAsNotifT(acctpunishment.GetEndTime()))
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSysStreamerPunishmentEnds() {
|
|
handler.handlerMap[consts.SysNotifTemp_StreamerPunishmentEnds] = func(ctx *gin.Context, args ...any) {
|
|
acctpunishment := args[0].(*dbstruct.AccountPunishment)
|
|
// 解禁通知
|
|
if !acctpunishment.IsPermanent() {
|
|
argsMap := make(map[string]any)
|
|
argsMap["push_time"] = acctpunishment.GetEndTime()
|
|
argsMap["set_nid"] = func(ctx *gin.Context, nid int64) error {
|
|
return _DefaultAccountPunishment.OpUpdate(ctx, &accountpunishmentproto.OpUpdateReq{
|
|
AccountPunishment: &dbstruct.AccountPunishment{
|
|
Id: acctpunishment.Id,
|
|
Nid: goproto.Int64(nid),
|
|
},
|
|
})
|
|
}
|
|
argsMap["template_params"] = []any{util.FormatTsAsNotifT(acctpunishment.GetEndTime())}
|
|
DefaultService.utilWriteNotifInfoByMap(ctx, consts.SysNotifTemp_StreamerPunishmentEnds, acctpunishment.GetMid(), argsMap)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSysPswdChanged() {
|
|
handler.handlerMap[consts.SysNotifTemp_PswdChanged] = func(ctx *gin.Context, args ...any) {
|
|
login := args[0].(*dbstruct.Login)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.SysNotifTemp_PswdChanged, login.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSysAcctCancellationApplied() {
|
|
handler.handlerMap[consts.SysNotifTemp_AcctCancellationApplied] = func(ctx *gin.Context, args ...any) {
|
|
account := args[0].(*dbstruct.Account)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.SysNotifTemp_AcctCancellationApplied, account.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSysStreamerAuthApprovalPassed() {
|
|
handler.handlerMap[consts.SysNotifTemp_AcctCancellationApplied] = func(ctx *gin.Context, args ...any) {
|
|
mids := args[0].([]int64)
|
|
for _, mid := range mids {
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.SysNotifTemp_StreamerAuthApprovalPassed, mid)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSysZoneCreated() {
|
|
handler.handlerMap[consts.SysNotifTemp_ZoneCreated] = func(ctx *gin.Context, args ...any) {
|
|
zone := args[0].(*dbstruct.Zone)
|
|
|
|
// 获取跳转路径
|
|
frontendroute, err := _DefaultFrontendRoute.GetById(ctx, consts.FrontendRouteId_Zone)
|
|
if err != nil {
|
|
logger.Error("_DefaultFrontendRoute GetById fail, err: %v", err)
|
|
}
|
|
|
|
// 获取缩略图
|
|
preview, err := DefaultService.utilGetZonePreviews(ctx, zone.GetId())
|
|
if err != nil {
|
|
logger.Error("utilGetZonePreviews fail, req: %v, err: %v", err)
|
|
}
|
|
|
|
argsMap := make(map[string]any)
|
|
argsMap["action"] = frontendroute.GetAction()
|
|
argsMap["params"] = frontendroute.GetRoutePath()
|
|
argsMap["thumbnail"] = preview
|
|
|
|
DefaultService.utilWriteNotifInfoByMap(ctx, consts.SysNotifTemp_ZoneCreated, zone.GetMid(), argsMap)
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSysZoneVasUpdated() {
|
|
handler.handlerMap[consts.SysNotifTemp_ZoneVasUpdated] = func(ctx *gin.Context, args ...any) {
|
|
req := args[0].(*zoneproto.ApiUpdateReq)
|
|
if req.AdmissionPrice <= 0 && req.IronfanshipPrice <= 0 && req.SuperfanshipPrice <= 0 {
|
|
return
|
|
}
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.SysNotifTemp_ZoneVasUpdated, req.Zone.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSysZoneThirdPartnerCreated() {
|
|
handler.handlerMap[consts.SysNotifTemp_ZoneThirdPartnerCreated] = func(ctx *gin.Context, args ...any) {
|
|
mid := args[0].(int64)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.SysNotifTemp_ZoneThirdPartnerCreated, mid)
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleSysMembershipPurchased() {
|
|
handler.handlerMap[consts.SysNotifTemp_MembershipPurchased] = func(ctx *gin.Context, args ...any) {
|
|
mid := args[0].(int64)
|
|
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) handleAudBioPassed() {
|
|
handler.handlerMap[consts.AudNotifTemp_BioPassed] = func(ctx *gin.Context, args ...any) {
|
|
task := args[0].(*dbstruct.TextAuditTask)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_BioPassed, task.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleAudBioRejected() {
|
|
handler.handlerMap[consts.AudNotifTemp_BioRejected] = func(ctx *gin.Context, args ...any) {
|
|
task := args[0].(*dbstruct.TextAuditTask)
|
|
remarks := args[1].(string)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_BioRejected, task.GetMid(), remarks)
|
|
}
|
|
}
|
|
|
|
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) handleAudAutoResponseMessagePassed() {
|
|
handler.handlerMap[consts.AudNotifTemp_AutoResponseMessagePassed] = func(ctx *gin.Context, args ...any) {
|
|
task := args[0].(*dbstruct.TextAuditTask)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_AutoResponseMessagePassed, task.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleAudAutoResponseMessageRejected() {
|
|
handler.handlerMap[consts.AudNotifTemp_AutoResponseMessageRejected] = func(ctx *gin.Context, args ...any) {
|
|
task := args[0].(*dbstruct.TextAuditTask)
|
|
remarks := args[1].(string)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_AutoResponseMessageRejected, task.GetMid(), remarks)
|
|
}
|
|
}
|
|
|
|
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) handleAudCoverPassed() {
|
|
handler.handlerMap[consts.AudNotifTemp_CoverPassed] = func(ctx *gin.Context, args ...any) {
|
|
task := args[0].(*dbstruct.ImageAuditTask)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_CoverPassed, task.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleAudCoverRejected() {
|
|
handler.handlerMap[consts.AudNotifTemp_CoverRejected] = func(ctx *gin.Context, args ...any) {
|
|
task := args[0].(*dbstruct.ImageAuditTask)
|
|
remarks := args[1].(string)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_CoverRejected, task.GetMid(), remarks)
|
|
}
|
|
}
|
|
|
|
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) handleAudAlbumPassed() {
|
|
handler.handlerMap[consts.AudNotifTemp_AlbumPassed] = func(ctx *gin.Context, args ...any) {
|
|
task := args[0].(*dbstruct.ImageAuditTask)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_AlbumPassed, task.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleAudAlbumRejected() {
|
|
handler.handlerMap[consts.AudNotifTemp_AlbumRejected] = func(ctx *gin.Context, args ...any) {
|
|
task := args[0].(*dbstruct.ImageAuditTask)
|
|
remarks := args[1].(string)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_AlbumRejected, task.GetMid(), remarks)
|
|
}
|
|
}
|
|
|
|
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) handleAudShortsPassed() {
|
|
handler.handlerMap[consts.AudNotifTemp_ShortsPassed] = func(ctx *gin.Context, args ...any) {
|
|
task := args[0].(*dbstruct.VideoModerationTask)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_ShortsPassed, task.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleAudShortsRejected() {
|
|
handler.handlerMap[consts.AudNotifTemp_ShortsRejected] = func(ctx *gin.Context, args ...any) {
|
|
task := args[0].(*dbstruct.VideoModerationTask)
|
|
remarks := args[1].(string)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_ShortsRejected, task.GetMid(), remarks)
|
|
}
|
|
}
|
|
|
|
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())
|
|
}
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleAudMomentCreated() {
|
|
handler.handlerMap[consts.AudNotifTemp_MomentCreated] = func(ctx *gin.Context, args ...any) {
|
|
moment := args[0].(*dbstruct.Moment)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_MomentCreated, moment.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleAudMomentPassed() {
|
|
handler.handlerMap[consts.AudNotifTemp_MomentPassed] = func(ctx *gin.Context, args ...any) {
|
|
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) {
|
|
moment := args[0].(*dbstruct.Moment)
|
|
ctStr := util.FormatTsAsNotifT(moment.GetCt())
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_MomentRejected, moment.GetMid(), ctStr)
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleAudZoneMomentCreated() {
|
|
handler.handlerMap[consts.AudNotifTemp_ZoneMomentCreated] = func(ctx *gin.Context, args ...any) {
|
|
zonemoment := args[0].(*dbstruct.ZoneMoment)
|
|
cTypeDesc := consts.ZoneMomentCTypeDescMap[zonemoment.GetCType()]
|
|
mTypeDesc := consts.MTypeDescMap[zonemoment.GetMType()]
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_ZoneMomentCreated, zonemoment.GetMid(), cTypeDesc, mTypeDesc)
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleAudZoneMomentPassed() {
|
|
handler.handlerMap[consts.AudNotifTemp_ZoneMomentPassed] = func(ctx *gin.Context, args ...any) {
|
|
zonemoment := args[0].(*dbstruct.ZoneMoment)
|
|
if zonemoment.GetIsReedited() != consts.IsReedited_No {
|
|
return
|
|
}
|
|
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) {
|
|
zonemoment := args[0].(*dbstruct.ZoneMoment)
|
|
remarks := args[1].(string)
|
|
|
|
if zonemoment.GetIsReedited() != consts.IsReedited_No {
|
|
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)
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleAudZoneMomentReedited() {
|
|
handler.handlerMap[consts.AudNotifTemp_ZoneMomentReedited] = func(ctx *gin.Context, args ...any) {
|
|
zonemoment := args[0].(*dbstruct.ZoneMoment)
|
|
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)
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasMembershipPurchased() {
|
|
handler.handlerMap[consts.VasNotifTemp_MembershipPurchased] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_MembershipPurchased, order.GetMid())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleWithdrawalFinished() {
|
|
handler.handlerMap[consts.VasNotifTemp_WithdrawalFinished] = func(ctx *gin.Context, args ...any) {
|
|
singleDistributeHis := args[0].(*dbstruct.SingleDistributeHis)
|
|
// 查询订单
|
|
wOrder, _ := _DefaultVas.GetWithdrawOrderById(ctx, nil, singleDistributeHis.GetOrderId())
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_WithdrawalFinished, singleDistributeHis.GetMid(), wOrder.GetWithdrawDias())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasZoneAdmissionPurchased_User() {
|
|
handler.handlerMap[consts.VasNotifTemp_ZoneAdmissionPurchased_User] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
acctMap := args[1].(map[int64]*dbstruct.Account)
|
|
streamerAcct := acctMap[order.GetUid()]
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_ZoneAdmissionPurchased_User, order.GetMid(), streamerAcct.GetName())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasZoneAdmissionPurchased_Streamer() {
|
|
handler.handlerMap[consts.VasNotifTemp_ZoneAdmissionPurchased_Streamer] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
acctMap := args[1].(map[int64]*dbstruct.Account)
|
|
acct := acctMap[order.GetMid()]
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_ZoneAdmissionPurchased_Streamer, order.GetMid(), acct.GetName())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasZoneSuperfanshipPurchased_User() {
|
|
handler.handlerMap[consts.VasNotifTemp_ZoneSuperfanshipPurchased_User] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
streamer, _ := _DefaultStreamer.OpListByMid(ctx, &streamerproto.OpListByMidReq{Mid: goproto.Int64(order.GetUid())})
|
|
|
|
// 获取跳转路径
|
|
frontendroute, err := _DefaultFrontendRoute.GetById(ctx, consts.FrontendRouteId_Zone)
|
|
if err != nil {
|
|
logger.Error("_DefaultFrontendRoute GetById fail, err: %v", err)
|
|
}
|
|
|
|
argsMap := make(map[string]any)
|
|
argsMap["template_params"] = util.FormatTsAsNotifT(order.GetSuperfanshipUntil())
|
|
argsMap["action"] = frontendroute.GetAction()
|
|
argsMap["params"] = frontendroute.GetRoutePath()
|
|
argsMap["thumbnail"] = streamer.Album
|
|
|
|
DefaultService.utilWriteNotifInfoByMap(ctx, consts.VasNotifTemp_ZoneSuperfanshipPurchased_User, order.GetMid(), argsMap)
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasZoneSuperfanshipPurchased_WxNotGifted() {
|
|
handler.handlerMap[consts.VasNotifTemp_ZoneSuperfanshipPurchased_WxNotGifted] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
|
|
zVas, _ := _DefaultVas.GetZoneVasInfo(ctx, order.GetZid())
|
|
if zVas.IsSuperfanshipGiveWechat != 0 { // 不赠送微信
|
|
return
|
|
}
|
|
|
|
acctMap := args[1].(map[int64]*dbstruct.Account)
|
|
acct := acctMap[order.GetMid()]
|
|
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_ZoneSuperfanshipPurchased_WxNotGifted, order.GetMid(), acct.GetName())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasZoneSuperfanshipPurchased_WxPublic() {
|
|
handler.handlerMap[consts.VasNotifTemp_ZoneSuperfanshipPurchased_WxPublic] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
|
|
zVas, _ := _DefaultVas.GetZoneVasInfo(ctx, order.GetZid())
|
|
if zVas.IsSuperfanshipGiveWechat != 1 { // 赠送微信
|
|
return
|
|
}
|
|
uVas, _ := _DefaultVas.GetUserVasInfo(ctx, order.GetMid())
|
|
if uVas.WechatLockType != dbstruct.UserVasLockTypeOpen { // 微信公开
|
|
return
|
|
}
|
|
|
|
acctMap := args[1].(map[int64]*dbstruct.Account)
|
|
acct := acctMap[order.GetMid()]
|
|
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_ZoneSuperfanshipPurchased_WxPublic, order.GetMid(), acct.GetName())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasZoneSuperfanshipPurchased_WxPrivate() {
|
|
handler.handlerMap[consts.VasNotifTemp_ZoneSuperfanshipPurchased_WxPrivate] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
|
|
zVas, _ := _DefaultVas.GetZoneVasInfo(ctx, order.GetZid())
|
|
if zVas.IsSuperfanshipGiveWechat != 1 { // 赠送微信
|
|
return
|
|
}
|
|
uVas, _ := _DefaultVas.GetUserVasInfo(ctx, order.GetMid())
|
|
if uVas.WechatLockType != dbstruct.UserVasLockTypeLock { // 微信私密
|
|
return
|
|
}
|
|
|
|
acctMap := args[1].(map[int64]*dbstruct.Account)
|
|
acct := acctMap[order.GetMid()]
|
|
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_ZoneSuperfanshipPurchased_WxPrivate, order.GetMid(), acct.GetName())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasZoneMomentPurchased_User() {
|
|
handler.handlerMap[consts.VasNotifTemp_ZoneMomentPurchased_User] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
acctMap := args[1].(map[int64]*dbstruct.Account)
|
|
streamerAcct := acctMap[order.GetUid()]
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_ZoneMomentPurchased_User, order.GetMid(), streamerAcct.GetName())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasZoneMomentPurchased_Streamer() {
|
|
handler.handlerMap[consts.VasNotifTemp_ZoneMomentPurchased_Streamer] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
acctMap := args[1].(map[int64]*dbstruct.Account)
|
|
acct := acctMap[order.GetMid()]
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_ZoneMomentPurchased_Streamer, order.GetMid(), acct.GetName())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasZoneIronfanshipUnlocked_User() {
|
|
handler.handlerMap[consts.VasNotifTemp_ZoneIronfanshipUnlocked_User] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
acctMap := args[1].(map[int64]*dbstruct.Account)
|
|
streamerAcct := acctMap[order.GetUid()]
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_ZoneIronfanshipUnlocked_User, order.GetMid(), streamerAcct.GetName())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasZoneIronfanshipUnlocked_Streamer() {
|
|
handler.handlerMap[consts.VasNotifTemp_ZoneIronfanshipUnlocked_Streamer] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
acctMap := args[1].(map[int64]*dbstruct.Account)
|
|
acct := acctMap[order.GetMid()]
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_ZoneIronfanshipUnlocked_Streamer, order.GetMid(), acct.GetName())
|
|
}
|
|
}
|
|
|
|
func (handler *NotifBuilderHandler) handleVasWxPurchased_User() {
|
|
handler.handlerMap[consts.VasNotifTemp_WxPurchased_User] = func(ctx *gin.Context, args ...any) {
|
|
order := args[0].(*dbstruct.Order)
|
|
acctMap := args[1].(map[int64]*dbstruct.Account)
|
|
streamerAcct := acctMap[order.GetUid()]
|
|
DefaultService.utilWriteNotifInfo(ctx, consts.VasNotifTemp_WxPurchased_User, order.GetMid(), streamerAcct.GetName())
|
|
}
|
|
}
|