Kaynağa Gözat

update push

master
DengBiao 2 yıl önce
ebeveyn
işleme
4b935d2b9d
1 değiştirilmiş dosya ile 2 ekleme ve 40 silme
  1. +2
    -40
      internal/logic/domain/message/service/message_service.go

+ 2
- 40
internal/logic/domain/message/service/message_service.go Dosyayı Görüntüle

@@ -2,10 +2,6 @@ package service

import (
"context"
"gim/internal/business/comm/db"
svc "gim/internal/business/comm/service"
repo2 "gim/internal/business/domain/user/repo"
"gim/internal/logic/domain/message/md"
"gim/internal/logic/domain/message/model"
"gim/internal/logic/domain/message/repo"
"gim/internal/logic/proxy"
@@ -15,10 +11,9 @@ import (
"gim/pkg/pb"
"gim/pkg/rpc"
"gim/pkg/util"

"go.uber.org/zap"
"google.golang.org/protobuf/proto"
"strconv"
"time"
)

const MessageLimit = 50 // 最大消息同步数量
@@ -94,9 +89,7 @@ func (*messageService) ListByUserIdAndSeq(ctx context.Context, userId, seq int64

// SendToUser 将消息发送给用户
func (*messageService) SendToUser(ctx context.Context, sender *pb.Sender, toUserId int64, req *pb.SendMessageReq) (int64, error) {
masterId, _ := grpclib.GetCtxMasterId(ctx)
logger.Logger.Debug("SendToUser",
zap.String("master_id", masterId),
zap.Int64("request_id", grpclib.GetCtxRequestId(ctx)),
zap.Int64("to_user_id", toUserId))
var (
@@ -158,40 +151,9 @@ 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
}
sender.Nickname = sendUser.Nickname
sender.AvatarUrl = sendUser.AvatarUrl
}
//TODO::接收者类型为`user`, 进行极光推送
CommAddPush(md.PushParams{
MasterId: masterId,
Uid: uid,
PushAlia: alia,
Title: "新消息提醒",
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.000"),
})
}
}

for i := range devices {
// 消息不需要投递给发送消息的设备
if sender.DeviceId == devices[i].DeviceId {
// 消息不需要投递给发送消息的设备
continue
}



Yükleniyor…
İptal
Kaydet