This commit is contained in:
Leufolium 2024-11-01 15:35:45 +08:00
parent 6824ec209c
commit 680cefa724
9 changed files with 96 additions and 5 deletions

View File

@ -0,0 +1,24 @@
package consts
// notif_template
const (
SysNotifTemp_FirstLogin = 0
SysNotifTemp_StreamerPunished = 1
SysNotifTemp_StreamerPunishmentEnds = 2
SysNotifTemp_PswdChanged = 3
SysNotifTemp_AcctCancellationApplied = 4
SysNotifTemp_AcctCancelled = 5
AudNotifTemp_AvatarChanged = 100
AudNotifTemp_AvatarRollbacked = 101
AudNotifTemp_NameChanged = 102
AudNotifTemp_NameRollbacked = 103
AudNotifTemp_StreamerBasicInfoApplied = 104
AudNotifTemp_StreamerBasicInfoRejected = 105
AudNotifTemp_StreamerDetailsApplied = 106
AudNotifTemp_StreamerDetailsPassed = 107
AudNotifTemp_StreamerDetailsRejected = 108
AudNotifTemp_WithdrawlInfoApplied = 109
AudNotifTemp_WithdrawlInfoPassed = 110
AudNotifTemp_WithdrawlInfoRejected = 111
)

View File

@ -0,0 +1,8 @@
package apollostruct
type NotifTemplateCfg struct {
NotifTemplate string `json:"notif_template"`
NType int64 `json:"n_type"`
LinkTextTemplate string `json:"link_text_template"`
Action string `json:"string"`
}

View File

@ -1060,6 +1060,8 @@ func (s *Service) ApiCreateStreamerAuthApprovalBasic(ctx *gin.Context, req *stre
ec = errcode.ErrCodeStreamerAuthApprovalBasicSrvFail
return
}
ctx.Set("notif_template_id", consts.AudNotifTemp_StreamerBasicInfoApplied)
return
}

View File

@ -101,7 +101,7 @@ apollo:
app_id: "wishpal_live_service"
cluster: "dev"
ip: "http://localhost:8080"
namespace_name: "application,tag,account_init,platform,support_wx_id,Raven_IQ_test"
namespace_name: "application,tag,account_init,platform,support_wx_id,version,zone,Raven_IQ_test,notif_template"
secret: ""
is_back_up_config: true
sync_server_timeout: 2

View File

@ -103,7 +103,7 @@ apollo:
app_id: "wishpal_live_service"
cluster: "dev"
ip: "http://172.16.0.186:8080"
namespace_name: "application,tag,account_init,platform,support_wx_id,version,zone,Raven_IQ_test"
namespace_name: "application,tag,account_init,platform,support_wx_id,version,zone,Raven_IQ_test,notif_template"
secret: ""
is_back_up_config: true
sync_server_timeout: 2

View File

@ -111,7 +111,7 @@ apollo:
app_id: "wishpal_live_service"
cluster: "dev"
ip: "http://172.16.0.186:8080"
namespace_name: "application,tag,account_init,platform,support_wx_id,version,zone,Raven_IQ_test"
namespace_name: "application,tag,account_init,platform,support_wx_id,version,zone,Raven_IQ_test,notif_template"
secret: ""
is_back_up_config: true
sync_server_timeout: 2

View File

@ -97,7 +97,7 @@ apollo:
app_id: "wishpal_live_service"
cluster: "dev"
ip: "http://localhost:8080"
namespace_name: "application,tag,account_init,platform,support_wx_id,version,zone,Raven_IQ_test"
namespace_name: "application,tag,account_init,platform,support_wx_id,version,zone,Raven_IQ_test,notif_template"
secret: ""
is_back_up_config: true
sync_server_timeout: 2

View File

@ -112,7 +112,7 @@ apollo:
app_id: "wishpal_live_service"
cluster: "dev"
ip: "http://172.31.37.71:8080"
namespace_name: "application,tag,account_init,platform,support_wx_id,version,zone,Raven_IQ_test"
namespace_name: "application,tag,account_init,platform,support_wx_id,version,zone,Raven_IQ_test,notif_template"
secret: ""
is_back_up_config: true
sync_server_timeout: 2

View File

@ -0,0 +1,57 @@
package middleware
import (
"service/app/mix/service"
"service/app/mix/service/logic"
"service/dbstruct"
"service/library/logger"
"service/api/consts"
notificationproto "service/api/proto/notification/proto"
goproto "google.golang.org/protobuf/proto"
"github.com/gin-gonic/gin"
)
var (
DefaultNotifSender gin.HandlerFunc
)
func InitNotifSender(_DefaultNotification *logic.Notification, _DefaultNotifBcstCenter service.NotifBcstCenter) {
DefaultNotifSender = func(ctx *gin.Context) {
notifTempId := ctx.MustGet("notif_template_id").(int64)
notifTempParams := ctx.MustGet("notif_template_params").([]string)
notification := &dbstruct.Notification{}
// 通知接收人mids不为空则默认认为是自定义发送
if len(notif.ObjMids) > 0 {
notification.ObjType = goproto.Int64(consts.Notification_ObjType_Customized)
}
notification.SubMid = goproto.Int64(0)
notification.PushTime = goproto.Int64(0)
err := _DefaultNotification.OpCreate(ctx, &notificationproto.OpCreateReq{
Notification: notification,
})
if err != nil {
logger.Error("通知创建失败:%v", err)
ctx.Next()
}
nids := make([]int64, 0)
nids = append(nids, notification.GetId())
err = _DefaultNotifBcstCenter.BcstNotifs(ctx, nids, notification.GetObjType(), notification.ObjMids)
if err != nil {
logger.Error("通知广播失败:%v", err)
ctx.Next()
}
ctx.Next()
}
}
func NotifSender() gin.HandlerFunc {
return DefaultNotifSender
}