diff --git a/internal/logic/domain/message/service/message_service.go b/internal/logic/domain/message/service/message_service.go index 5cb2c4d..903383b 100644 --- a/internal/logic/domain/message/service/message_service.go +++ b/internal/logic/domain/message/service/message_service.go @@ -158,35 +158,37 @@ func (*messageService) SendToUser(ctx context.Context, sender *pb.Sender, toUser return 0, err } - isOpenAppPush := svc.SysCfgGet(masterId, "is_open_app_push") - if sender.SenderType == pb.SenderType_ST_USER && req.ReceiverType == pb.ReceiverType_RT_USER && isOpenAppPush == "1" && req.ReceiverId != toUserId { - uid := strconv.FormatInt(req.ReceiverId, 10) - alia := db.DbUserPushForJg.UserPushForJgGetWithDb(masterId, uid) - if alia != "" { - if sender.Nickname == "" { - sendUser, err := repo2.UserRepo.Get(sender.SenderId) - if err != nil { - logger.Sugar.Error(err) - return 0, err + if len(devices) <= 0 { + isOpenAppPush := svc.SysCfgGet(masterId, "is_open_app_push") + if sender.SenderType == pb.SenderType_ST_USER && req.ReceiverType == pb.ReceiverType_RT_USER && isOpenAppPush == "1" && req.ReceiverId != toUserId { + uid := strconv.FormatInt(req.ReceiverId, 10) + alia := db.DbUserPushForJg.UserPushForJgGetWithDb(masterId, uid) + if alia != "" { + if sender.Nickname == "" { + sendUser, err := repo2.UserRepo.Get(sender.SenderId) + if err != nil { + logger.Sugar.Error(err) + return 0, err + } + sender.Nickname = sendUser.Nickname + sender.AvatarUrl = sendUser.AvatarUrl } - sender.Nickname = sendUser.Nickname - sender.AvatarUrl = sendUser.AvatarUrl + //TODO::接收者类型为`user`, 进行极光推送 + CommAddPush(md.PushParams{ + MasterId: masterId, + Uid: uid, + PushAlia: alia, + Title: "新消息提醒", + Content: "您收到一条新消息,来自会员\"[消息发送者-会员昵称]\",发送时间\"[时间]\"", + //Content: "您收到一条新消息,来自会员\"[消息发送者-会员昵称]\",发送时间\"[时间]\",消息类型\"[消息类型]\",备注\"[备注]\"", + PushType: "zhi_ying_gim", + MessageType: req.MessageType.String(), + SendUserNickname: sender.Nickname, + SendUserAvatarUrl: sender.AvatarUrl, + Memo: sender.SenderType.String(), + Times: time.Now().Format("2006-01-02 15:04:05"), + }) } - //TODO::接收者类型为`user`, 进行极光推送 - CommAddPush(md.PushParams{ - MasterId: masterId, - Uid: uid, - PushAlia: alia, - Title: "新消息提醒", - Content: "您收到一条新消息,来自会员\"[消息发送者-会员昵称]\",发送时间\"[时间]\"", - //Content: "您收到一条新消息,来自会员\"[消息发送者-会员昵称]\",发送时间\"[时间]\",消息类型\"[消息类型]\",备注\"[备注]\"", - PushType: "zhi_ying_gim", - MessageType: req.MessageType.String(), - SendUserNickname: sender.Nickname, - SendUserAvatarUrl: sender.AvatarUrl, - Memo: sender.SenderType.String(), - Times: time.Now().Format("2006-01-02 15:04:05"), - }) } } @@ -195,7 +197,6 @@ func (*messageService) SendToUser(ctx context.Context, sender *pb.Sender, toUser // 消息不需要投递给发送消息的设备 continue } - err = MessageService.SendToDevice(ctx, devices[i], &message) if err != nil { logger.Sugar.Error(err, zap.Any("SendToUser error", devices[i]), zap.Error(err))