Ver código fonte

update

master
DengBiao 2 anos atrás
pai
commit
a61bb78509
3 arquivos alterados com 40 adições e 2 exclusões
  1. +1
    -1
      internal/logic/domain/message/service/app_push.go
  2. +1
    -1
      internal/logic/domain/message/service/message_service.go
  3. +38
    -0
      internal/logic/domain/message/service/message_service_test.go

+ 1
- 1
internal/logic/domain/message/service/app_push.go Ver arquivo

@@ -58,7 +58,7 @@ func JgPush(args md3.PushParams) {
var aud = md2.PushAudience{Alias: []string{args.PushAlia}}
var extras = map[string]interface{}{
"master_id": args.MasterId,
"uid": args.SendUserNickname,
"uid": args.Uid,
"push_type": args.PushType,
"message_type": args.MessageType,
"send_user_nickname": args.SendUserNickname,


+ 1
- 1
internal/logic/domain/message/service/message_service.go Ver arquivo

@@ -159,7 +159,7 @@ func (*messageService) SendToUser(ctx context.Context, sender *pb.Sender, toUser
}

isOpenAppPush := svc.SysCfgGet(masterId, "is_open_app_push")
if sender.SenderType == 2 && req.ReceiverType == 1 && isOpenAppPush == "1" {
if sender.SenderType == pb.SenderType_ST_USER && req.ReceiverType == pb.ReceiverType_RT_USER && isOpenAppPush == "1" {
uid := strconv.FormatInt(req.ReceiverId, 10)
alia := db.DbUserPushForJg.UserPushForJgGetWithDb(masterId, uid)
if alia != "" {


+ 38
- 0
internal/logic/domain/message/service/message_service_test.go Ver arquivo

@@ -4,7 +4,13 @@ import (
"context"
"fmt"
md3 "gim/internal/logic/domain/message/md"
"gim/pkg/pb"
"gim/pkg/util"
"google.golang.org/grpc/metadata"
"google.golang.org/protobuf/proto"
"strconv"
"testing"
"time"

jsoniter "github.com/json-iterator/go"
)
@@ -55,3 +61,35 @@ func Test_CommAddPush(t *testing.T) {
Times: "sadff",
})
}

func Test_SendToUser(t *testing.T) {
buf, _ := proto.Marshal(&pb.Text{
Text: "hello world!",
})
MessageService.SendToUser(getCtx(),
&pb.Sender{
SenderType: pb.SenderType_ST_USER,
SenderId: 2,
},
21,
&pb.SendMessageReq{
ReceiverType: pb.ReceiverType_RT_USER,
ReceiverId: 21,
ToUserIds: nil,
MessageType: pb.MessageType_MT_TEXT,
MessageContent: buf,
SendTime: util.UnixMilliTime(time.Now()),
IsPersist: true,
},
)
}

func getCtx() context.Context {
token := "ICXKTELAGMMJYXITSIOUNXFHYMTCWJHMJCIRZLPX"
return metadata.NewOutgoingContext(context.TODO(), metadata.Pairs(
"user_id", "2",
"device_id", "5",
"token", token,
"master_id", "123456",
"request_id", strconv.FormatInt(time.Now().UnixNano(), 10)))
}

Carregando…
Cancelar
Salvar