@@ -58,7 +58,7 @@ func JgPush(args md3.PushParams) { | |||||
var aud = md2.PushAudience{Alias: []string{args.PushAlia}} | var aud = md2.PushAudience{Alias: []string{args.PushAlia}} | ||||
var extras = map[string]interface{}{ | var extras = map[string]interface{}{ | ||||
"master_id": args.MasterId, | "master_id": args.MasterId, | ||||
"uid": args.SendUserNickname, | |||||
"uid": args.Uid, | |||||
"push_type": args.PushType, | "push_type": args.PushType, | ||||
"message_type": args.MessageType, | "message_type": args.MessageType, | ||||
"send_user_nickname": args.SendUserNickname, | "send_user_nickname": args.SendUserNickname, | ||||
@@ -159,7 +159,7 @@ func (*messageService) SendToUser(ctx context.Context, sender *pb.Sender, toUser | |||||
} | } | ||||
isOpenAppPush := svc.SysCfgGet(masterId, "is_open_app_push") | 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) | uid := strconv.FormatInt(req.ReceiverId, 10) | ||||
alia := db.DbUserPushForJg.UserPushForJgGetWithDb(masterId, uid) | alia := db.DbUserPushForJg.UserPushForJgGetWithDb(masterId, uid) | ||||
if alia != "" { | if alia != "" { | ||||
@@ -4,7 +4,13 @@ import ( | |||||
"context" | "context" | ||||
"fmt" | "fmt" | ||||
md3 "gim/internal/logic/domain/message/md" | 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" | "testing" | ||||
"time" | |||||
jsoniter "github.com/json-iterator/go" | jsoniter "github.com/json-iterator/go" | ||||
) | ) | ||||
@@ -55,3 +61,35 @@ func Test_CommAddPush(t *testing.T) { | |||||
Times: "sadff", | 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))) | |||||
} |