Merge pull request 'by Robin at 20241213' (#895) from feat-IRONFANS-212-Robin into test

Reviewed-on: https://git.wishpal.cn/wishpal_ironfan/service/pulls/895
This commit is contained in:
chenhao 2024-12-13 18:26:14 +08:00
commit 7be15f04d8
2 changed files with 30 additions and 4 deletions

View File

@ -118,6 +118,7 @@ func (s *NotifBcstCenter) pushNotifsToMids(ctx *gin.Context, nids []int64, objMi
notifReceives := make([]*dbstruct.NotifReceive, 0)
midRecentReceiveMap := make(map[int64]map[int64]*dbstruct.NotifRecentReceive) // 最近的一条通知nid
for _, mid := range objMids {
recentReceiveMap := make(map[int64]*dbstruct.NotifRecentReceive)
for _, nid := range nids {
notifReceive := &dbstruct.NotifReceive{
ObjMid: mid,
@ -127,8 +128,9 @@ func (s *NotifBcstCenter) pushNotifsToMids(ctx *gin.Context, nids []int64, objMi
Ct: notifMap[nid].GetRt(),
}
notifReceives = append(notifReceives, notifReceive)
s.tryToReplaceRecentReceive(midRecentReceiveMap[mid], notifReceive)
s.tryToReplaceRecentReceive(recentReceiveMap, notifReceive)
}
midRecentReceiveMap[mid] = recentReceiveMap
}
logger.Info("trying to update recent_receive...")
@ -385,9 +387,6 @@ func (s *NotifBcstCenter) groupOnlineMids(ctx *gin.Context) (streamerMids []int6
}
func (s *NotifBcstCenter) tryToReplaceRecentReceive(recentReceiveMap map[int64]*dbstruct.NotifRecentReceive, notifReceive *dbstruct.NotifReceive) {
if recentReceiveMap == nil {
recentReceiveMap = make(map[int64]*dbstruct.NotifRecentReceive)
}
// 比较最近接收时间
recentReceive, ok := recentReceiveMap[notifReceive.NType]
logger.Info("now recent_receive: %v, obj: %v", recentReceive, notifReceive)

View File

@ -84,6 +84,9 @@ func (handler *NotifBuilderHandler) init() {
handler.handleAudShortsPassed()
handler.handleAudShortsRejected()
handler.handleAudStreamerDirectlyUpdated()
handler.handleAudProfileChangeApplied()
handler.handleAudProfilePassed()
handler.handleAudProfileRejected()
handler.handleAudMomentCreated()
handler.handleAudMomentPassed()
handler.handleAudMomentRejected()
@ -474,6 +477,30 @@ func (handler *NotifBuilderHandler) handleAudStreamerDirectlyUpdated() {
}
}
func (handler *NotifBuilderHandler) handleAudProfileChangeApplied() {
handler.handlerMap[consts.AudNotifTemp_ProfileChangeApplied] = func(ctx *gin.Context, args ...any) {
zone := args[0].(*dbstruct.Zone)
if zone.Profile != nil {
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_ProfileChangeApplied, zone.GetMid())
}
}
}
func (handler *NotifBuilderHandler) handleAudProfilePassed() {
handler.handlerMap[consts.AudNotifTemp_ProfilePassed] = func(ctx *gin.Context, args ...any) {
task := args[0].(*dbstruct.ImageAuditTask)
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_ProfilePassed, task.GetMid())
}
}
func (handler *NotifBuilderHandler) handleAudProfileRejected() {
handler.handlerMap[consts.AudNotifTemp_ProfileRejected] = func(ctx *gin.Context, args ...any) {
task := args[0].(*dbstruct.ImageAuditTask)
remarks := args[1].(string)
DefaultService.utilWriteNotifInfo(ctx, consts.AudNotifTemp_ProfileRejected, task.GetMid(), remarks)
}
}
func (handler *NotifBuilderHandler) handleAudMomentCreated() {
handler.handlerMap[consts.AudNotifTemp_MomentCreated] = func(ctx *gin.Context, args ...any) {
moment := args[0].(*dbstruct.Moment)