From 7c35ea11d1a609b223a7ea14d51436154a605324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E9=B8=BF=E9=A3=9E?= Date: Mon, 16 Oct 2023 11:28:52 +0800 Subject: [PATCH] fix(notify): fix role subscriber groupTimes --- pkg/notify/models/subscriber.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/notify/models/subscriber.go b/pkg/notify/models/subscriber.go index 58670d7123..87c62fb37c 100644 --- a/pkg/notify/models/subscriber.go +++ b/pkg/notify/models/subscriber.go @@ -497,10 +497,14 @@ func (srm *SSubscriberManager) getReceiversSent(ctx context.Context, tid string, if err != nil { return nil, err } + // 接受人-聚合时间 receivers := make(map[string]uint32) + // 角色-接受人 roleMap := make(map[string][]string, 3) + // 接受角色-接受人-聚合时间 receivermap := make(map[string]map[string]uint32, 3) - identificationMapToSub := make(map[string]SSubscriber) + // 聚合时间 + roleGroupTimes := 0 for _, sr := range srs { if sr.Type == api.SUBSCRIBER_TYPE_RECEIVER { rIds, err := sr.getReceivers() @@ -512,7 +516,7 @@ func (srm *SSubscriberManager) getReceiversSent(ctx context.Context, tid string, receivers[receiveId] = sr.GroupTimes } } else if sr.Type == api.SUBSCRIBER_TYPE_ROLE { - identificationMapToSub[sr.Identification] = sr + roleGroupTimes = int(sr.GroupTimes) roleMap[sr.RoleScope] = append(roleMap[sr.RoleScope], sr.Identification) receivermap[sr.RoleScope] = map[string]uint32{} } @@ -551,7 +555,7 @@ func (srm *SSubscriberManager) getReceiversSent(ctx context.Context, tid string, return errors.Wrap(err, "unable to get user.id from result of RoleAssignments.List") } if _, ok := receivermap[scope][id]; !ok { - receivermap[scope][id] = identificationMapToSub[scope].GroupTimes + receivermap[scope][id] = uint32(roleGroupTimes) } } } @@ -565,7 +569,7 @@ func (srm *SSubscriberManager) getReceiversSent(ctx context.Context, tid string, for _, res := range receivermap { for receive, time := range res { - if _, ok := receivers[receive]; !ok { + if t, ok := receivers[receive]; !ok || t == 0 { receivers[receive] = time } }