@@ -0,0 +1,11 @@ | |||||
apiVersion: v1 | |||||
kind: ConfigMap | |||||
metadata: | |||||
name: config | |||||
data: | |||||
# 类属性键;每一个键都映射到一个简单的值,仅仅支持键值对,不支持嵌套 | |||||
mysql: "root:ZHIoscnfnuo123@@tcp(zhios123.rwlb.rds.aliyuncs.com:3306)/gim?charset=utf8&parseTime=true" | |||||
redisIP: "116.62.62.35:6379" | |||||
redisPassword: "dengsanhu" | |||||
pushRoomSubscribeNum: "100" | |||||
pushAllSubscribeNum: "100" |
@@ -18,7 +18,7 @@ spec: | |||||
spec: | spec: | ||||
containers: | containers: | ||||
- name: business | - name: business | ||||
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-business:202209020-03' | |||||
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-business:20221128-01' | |||||
imagePullPolicy: Always | imagePullPolicy: Always | ||||
ports: | ports: | ||||
- containerPort: 8000 | - containerPort: 8000 | ||||
@@ -18,7 +18,7 @@ spec: | |||||
spec: | spec: | ||||
containers: | containers: | ||||
- name: connect | - name: connect | ||||
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-connect:202209018-03' | |||||
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-connect:20221128-01' | |||||
imagePullPolicy: Always | imagePullPolicy: Always | ||||
ports: | ports: | ||||
- containerPort: 8000 | - containerPort: 8000 | ||||
@@ -18,7 +18,7 @@ spec: | |||||
spec: | spec: | ||||
containers: | containers: | ||||
- name: logic | - name: logic | ||||
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-logic:202209018-04' | |||||
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-logic:20221128-01' | |||||
imagePullPolicy: Always # 在kind中需要指定,不然会强制到远程拉取镜像,导致部署失败 | imagePullPolicy: Always # 在kind中需要指定,不然会强制到远程拉取镜像,导致部署失败 | ||||
ports: | ports: | ||||
- containerPort: 8001 | - containerPort: 8001 | ||||
@@ -18,7 +18,7 @@ import ( | |||||
) | ) | ||||
func main() { | func main() { | ||||
//config.Init() | |||||
config.Init() | |||||
db.Init() | db.Init() | ||||
server := grpc.NewServer(grpc.UnaryInterceptor(interceptor.NewInterceptor("business_interceptor", urlwhitelist.Business))) | server := grpc.NewServer(grpc.UnaryInterceptor(interceptor.NewInterceptor("business_interceptor", urlwhitelist.Business))) | ||||
@@ -13,7 +13,7 @@ import ( | |||||
type BusinessExtServer struct{} | type BusinessExtServer struct{} | ||||
func (s *BusinessExtServer) SignIn(ctx context.Context, req *pb.SignInReq) (*pb.SignInResp, error) { | func (s *BusinessExtServer) SignIn(ctx context.Context, req *pb.SignInReq) (*pb.SignInResp, error) { | ||||
isNew, userId, token, masterId, err := app.AuthApp.SignIn(ctx, req.PhoneNumber, req.Code, req.MasterId, req.DeviceId) | |||||
isNew, userId, token, masterId, err := app.AuthApp.SignIn(ctx, req.PhoneNumber, req.Code, req.MasterId, req.DeviceId, req.PushAlia) | |||||
if err != nil { | if err != nil { | ||||
return nil, err | return nil, err | ||||
} | } | ||||
@@ -10,8 +10,8 @@ type authApp struct{} | |||||
var AuthApp = new(authApp) | var AuthApp = new(authApp) | ||||
// SignIn 长连接登录 | // SignIn 长连接登录 | ||||
func (*authApp) SignIn(ctx context.Context, phoneNumber, code string, masterId, deviceId int64) (bool, int64, string, int64, error) { | |||||
return service.AuthService.SignIn(ctx, phoneNumber, code, masterId, deviceId) | |||||
func (*authApp) SignIn(ctx context.Context, phoneNumber, code string, masterId, deviceId int64, pushAlia string) (bool, int64, string, int64, error) { | |||||
return service.AuthService.SignIn(ctx, phoneNumber, code, masterId, deviceId, pushAlia) | |||||
} | } | ||||
// Auth 验证用户是否登录 | // Auth 验证用户是否登录 | ||||
@@ -15,9 +15,9 @@ type dbUserPushForJg struct{} | |||||
var DbUserPushForJg = new(dbUserPushForJg) | var DbUserPushForJg = new(dbUserPushForJg) | ||||
// UserPushForJgGetOne 获取一条记录 | // UserPushForJgGetOne 获取一条记录 | ||||
func (*dbUserPushForJg) UserPushForJgGetOne(key string, masterId int64) (*model.UserPushForJg, error) { | |||||
func (*dbUserPushForJg) UserPushForJgGetOne(uid string, masterId int64) (*model.UserPushForJg, error) { | |||||
var cfgList model.UserPushForJg | var cfgList model.UserPushForJg | ||||
if err := db.DB.Where("`key` = ? and `master_id` = ?", key, masterId).First(&cfgList).Error; err != nil { | |||||
if err := db.DB.Where("`uid` = ? and `master_id` = ?", uid, masterId).First(&cfgList).Error; err != nil { | |||||
return nil, gerrors.WrapError(err) | return nil, gerrors.WrapError(err) | ||||
} | } | ||||
return &cfgList, nil | return &cfgList, nil | ||||
@@ -2,12 +2,15 @@ package service | |||||
import ( | import ( | ||||
"context" | "context" | ||||
"errors" | |||||
"gim/internal/business/comm/db" | |||||
"gim/internal/business/domain/user/model" | "gim/internal/business/domain/user/model" | ||||
"gim/internal/business/domain/user/repo" | "gim/internal/business/domain/user/repo" | ||||
"gim/pkg/gerrors" | "gim/pkg/gerrors" | ||||
"gim/pkg/pb" | "gim/pkg/pb" | ||||
"gim/pkg/rpc" | "gim/pkg/rpc" | ||||
"gim/pkg/util" | "gim/pkg/util" | ||||
"strconv" | |||||
"time" | "time" | ||||
) | ) | ||||
@@ -16,7 +19,7 @@ type authService struct{} | |||||
var AuthService = new(authService) | var AuthService = new(authService) | ||||
// SignIn 登录 | // SignIn 登录 | ||||
func (*authService) SignIn(ctx context.Context, phoneNumber, code string, masterId, deviceId int64) (bool, int64, string, int64, error) { | |||||
func (*authService) SignIn(ctx context.Context, phoneNumber, code string, masterId, deviceId int64, pushAlia string) (bool, int64, string, int64, error) { | |||||
if !Verify(phoneNumber, code) { | if !Verify(phoneNumber, code) { | ||||
return false, 0, "", 0, gerrors.ErrBadCode | return false, 0, "", 0, gerrors.ErrBadCode | ||||
} | } | ||||
@@ -58,6 +61,23 @@ func (*authService) SignIn(ctx context.Context, phoneNumber, code string, master | |||||
return false, 0, "", 0, err | return false, 0, "", 0, err | ||||
} | } | ||||
if pushAlia != "" { | |||||
userPushForJg, err := db.DbUserPushForJg.UserPushForJgGetOne(strconv.FormatInt(user.Id, 10), masterId) | |||||
if err != nil { | |||||
return false, 0, "", 0, err | |||||
} | |||||
if userPushForJg == nil { | |||||
save := db.DbUserPushForJg.UserPushForJgInsert(user.Id, masterId, pushAlia) | |||||
if !save { | |||||
return false, 0, "", 0, errors.New("插入user_push_for_jg记录失败") | |||||
} | |||||
} else { | |||||
update := db.DbUserPushForJg.UserPushForJgUpdate(user.Id, masterId, pushAlia) | |||||
if !update { | |||||
return false, 0, "", 0, errors.New("修改user_push_for_jg记录失败") | |||||
} | |||||
} | |||||
} | |||||
return isNew, user.Id, token, masterId, nil | return isNew, user.Id, token, masterId, nil | ||||
} | } | ||||
@@ -33,8 +33,8 @@ func JgPush(args md3.PushParams) { | |||||
if thirdJgPush["jg_push_app_key"] == "" || thirdJgPush["jg_push_app_secret"] == "" { | if thirdJgPush["jg_push_app_key"] == "" || thirdJgPush["jg_push_app_secret"] == "" { | ||||
return | return | ||||
} | } | ||||
alia := db.DbUserPushForJg.UserPushForJgGetWithDb(args.MasterId, args.Uid) | |||||
var aud = md2.PushAudience{Alias: []string{alia}} | |||||
//alia := db.DbUserPushForJg.UserPushForJgGetWithDb(args.MasterId, args.Uid) | |||||
var aud = md2.PushAudience{Alias: []string{args.PushAlia}} | |||||
var extras interface{} | var extras interface{} | ||||
var param = md2.PushParam{ | var param = md2.PushParam{ | ||||
Platform: "all", | Platform: "all", | ||||
@@ -2,6 +2,7 @@ package service | |||||
import ( | import ( | ||||
"context" | "context" | ||||
"gim/internal/business/comm/db" | |||||
svc "gim/internal/business/comm/service" | svc "gim/internal/business/comm/service" | ||||
"gim/internal/logic/domain/message/md" | "gim/internal/logic/domain/message/md" | ||||
"gim/internal/logic/domain/message/model" | "gim/internal/logic/domain/message/model" | ||||
@@ -157,26 +158,32 @@ func (*messageService) SendToUser(ctx context.Context, sender *pb.Sender, toUser | |||||
return 0, err | return 0, err | ||||
} | } | ||||
var isPush = false | |||||
for i := range devices { | for i := range devices { | ||||
// 消息不需要投递给发送消息的设备 | |||||
if sender.DeviceId == devices[i].DeviceId { | |||||
if sender.DeviceId == devices[i].DeviceId && !isPush { | |||||
isOpenAppPush := svc.SysCfgGet(masterId, "is_open_app_push") | isOpenAppPush := svc.SysCfgGet(masterId, "is_open_app_push") | ||||
if req.ReceiverType == 1 && isOpenAppPush == "1" { | if req.ReceiverType == 1 && isOpenAppPush == "1" { | ||||
//TODO::接收者类型为`user`, 进行极光推送 | |||||
CommAddPush(md.PushParams{ | |||||
MasterId: masterId, | |||||
Uid: strconv.FormatInt(req.ReceiverId, 10), | |||||
PushAlia: "", | |||||
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"), | |||||
}) | |||||
uid := strconv.FormatInt(req.ReceiverId, 10) | |||||
alia := db.DbUserPushForJg.UserPushForJgGetWithDb(masterId, uid) | |||||
if alia != "" { | |||||
//TODO::接收者类型为`user`, 进行极光推送 | |||||
CommAddPush(md.PushParams{ | |||||
MasterId: masterId, | |||||
Uid: uid, | |||||
PushAlia: "", | |||||
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"), | |||||
}) | |||||
isPush = true | |||||
} | |||||
} | } | ||||
// 消息不需要投递给发送消息的设备 | |||||
continue | continue | ||||
} | } | ||||
@@ -33,6 +33,7 @@ type SignInReq struct { | |||||
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` // 验证码 | Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` // 验证码 | ||||
DeviceId int64 `protobuf:"varint,3,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty"` // 设备id | DeviceId int64 `protobuf:"varint,3,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty"` // 设备id | ||||
MasterId int64 `protobuf:"varint,4,opt,name=master_id,json=masterId,proto3" json:"master_id,omitempty"` // 站长id | MasterId int64 `protobuf:"varint,4,opt,name=master_id,json=masterId,proto3" json:"master_id,omitempty"` // 站长id | ||||
PushAlia string `protobuf:"varint,5,opt,name=push_alia,json=pushAlia,proto3" json:"push_alia,omitempty"` // 极光推送-别名 | |||||
} | } | ||||
func (x *SignInReq) Reset() { | func (x *SignInReq) Reset() { | ||||
@@ -22,6 +22,7 @@ message SignInReq { | |||||
string code = 2; // 验证码 | string code = 2; // 验证码 | ||||
int64 device_id = 3; // 设备id | int64 device_id = 3; // 设备id | ||||
int64 master_id = 4; // 站长id | int64 master_id = 4; // 站长id | ||||
string push_alia = 5; // 极光推送-别名 | |||||
} | } | ||||
message SignInResp { | message SignInResp { | ||||
bool is_new = 1; // 是否是新用户 | bool is_new = 1; // 是否是新用户 | ||||