From e76ffef47380c5a8ea671737d455d509fc24d562 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Tue, 5 Sep 2023 18:44:01 +0800 Subject: [PATCH] fix: user offline push --- internal/push/push_to_client.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/internal/push/push_to_client.go b/internal/push/push_to_client.go index 50010ca84..1642e4171 100644 --- a/internal/push/push_to_client.go +++ b/internal/push/push_to_client.go @@ -107,21 +107,23 @@ func (p *Pusher) Push2User(ctx context.Context, userIDs []string, msg *sdkws.Msg isOfflinePush := utils.GetSwitchFromOptions(msg.Options, constant.IsOfflinePush) log.ZDebug(ctx, "push_result", "ws push result", wsResults, "sendData", msg, "isOfflinePush", isOfflinePush, "push_to_userID", userIDs) p.successCount++ - for _, userID := range userIDs { - if isOfflinePush && userID != msg.SendID { - // save invitation info for offline push + if isOfflinePush { + for _, userID := range userIDs { + if userID == msg.SendID { + continue + } for _, v := range wsResults { - if v.OnlinePush { - return nil + if userID == v.UserID && (!v.OnlinePush) { + if err := callbackOfflinePush(ctx, userIDs, msg, &[]string{}); err != nil { + return err + } + err = p.offlinePushMsg(ctx, userID, msg, userIDs) + if err != nil { + return err + } + break } } - if err := callbackOfflinePush(ctx, userIDs, msg, &[]string{}); err != nil { - return err - } - err = p.offlinePushMsg(ctx, userID, msg, userIDs) - if err != nil { - return err - } } } return nil