fix duplicated offline push ()

pull/1832/head
a3d21 1 year ago committed by GitHub
parent 1d5732c97e
commit b14c0475d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -118,18 +118,25 @@ func (p *Pusher) Push2User(ctx context.Context, userIDs []string, msg *sdkws.Msg
return nil return nil
} }
for _, v := range wsResults { if len(wsResults) == 0 {
if !v.OnlinePush && msg.SendID == v.UserID { return nil
if err = callbackOfflinePush(ctx, userIDs, msg, &[]string{}); err != nil { }
return err onlinePushSuccUserIDSet := utils.SliceSet(utils.Filter(wsResults, func(e *msggateway.SingleMsgToUserResults) (string, bool) {
} return e.UserID, e.OnlinePush && e.UserID != ""
}))
offlinePushUserIDList := utils.Filter(wsResults, func(e *msggateway.SingleMsgToUserResults) (string, bool) {
_, exist := onlinePushSuccUserIDSet[e.UserID]
return e.UserID, !exist && e.UserID != "" && e.UserID != msg.SendID
})
err = p.offlinePushMsg(ctx, msg.SendID, msg, []string{v.UserID}) if len(offlinePushUserIDList) > 0 {
if err != nil { if err = callbackOfflinePush(ctx, offlinePushUserIDList, msg, &[]string{}); err != nil {
return err return err
} }
err = p.offlinePushMsg(ctx, msg.SendID, msg, offlinePushUserIDList)
if err != nil {
return err
} }
} }
return nil return nil
} }

Loading…
Cancel
Save