@@ -3,6 +3,7 @@ module gim | |||||
go 1.18 | go 1.18 | ||||
require ( | require ( | ||||
code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git v1.0.2 | |||||
github.com/alberliu/gn v1.10.0 | github.com/alberliu/gn v1.10.0 | ||||
github.com/gin-gonic/gin v1.7.7 | github.com/gin-gonic/gin v1.7.7 | ||||
github.com/go-redis/redis v6.15.9+incompatible | github.com/go-redis/redis v6.15.9+incompatible | ||||
@@ -22,7 +23,6 @@ require ( | |||||
) | ) | ||||
require ( | require ( | ||||
code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git v1.0.2 // indirect | |||||
github.com/PuerkitoBio/purell v1.1.1 // indirect | github.com/PuerkitoBio/purell v1.1.1 // indirect | ||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect | ||||
github.com/davecgh/go-spew v1.1.1 // indirect | github.com/davecgh/go-spew v1.1.1 // indirect | ||||
@@ -47,6 +47,10 @@ require ( | |||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||||
github.com/modern-go/reflect2 v1.0.2 // indirect | github.com/modern-go/reflect2 v1.0.2 // indirect | ||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||||
github.com/syyongx/php2go v0.9.7 // indirect | |||||
github.com/tidwall/gjson v1.14.1 // indirect | |||||
github.com/tidwall/match v1.1.1 // indirect | |||||
github.com/tidwall/pretty v1.2.0 // indirect | |||||
github.com/ugorji/go/codec v1.1.7 // indirect | github.com/ugorji/go/codec v1.1.7 // indirect | ||||
go.uber.org/atomic v1.7.0 // indirect | go.uber.org/atomic v1.7.0 // indirect | ||||
go.uber.org/multierr v1.6.0 // indirect | go.uber.org/multierr v1.6.0 // indirect | ||||
@@ -167,9 +167,13 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 | |||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
github.com/syyongx/php2go v0.9.7 h1:boZtLbm2xYbW49mX9M7Vq2zkVhBhv3fCqs2T16d2bGA= | |||||
github.com/syyongx/php2go v0.9.7/go.mod h1:meN2eIhhUoxOd2nMxbpe8g6cFPXI5O9/UAAuz7oDdzw= | github.com/syyongx/php2go v0.9.7/go.mod h1:meN2eIhhUoxOd2nMxbpe8g6cFPXI5O9/UAAuz7oDdzw= | ||||
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo= | |||||
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= | github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= | ||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= | |||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= | github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= | ||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= | |||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= | github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= | ||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= | github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= | ||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= | github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= | ||||
@@ -47,6 +47,16 @@ func (*deviceDao) ListOnlineByUserId(userId int64) ([]Device, error) { | |||||
return devices, nil | return devices, nil | ||||
} | } | ||||
// ListOffLineByUserId 查询用户所有的离线设备 | |||||
func (*deviceDao) ListOffLineByUserId(userId int64) ([]Device, error) { | |||||
var devices []Device | |||||
err := db.DB.Find(&devices, "user_id = ? and status = ?", userId, DeviceOnLine).Error | |||||
if err != nil { | |||||
return nil, gerrors.WrapError(err) | |||||
} | |||||
return devices, nil | |||||
} | |||||
// ListOnlineByConnAddr 查询用户所有的在线设备 | // ListOnlineByConnAddr 查询用户所有的在线设备 | ||||
func (*deviceDao) ListOnlineByConnAddr(connAddr string) ([]Device, error) { | func (*deviceDao) ListOnlineByConnAddr(connAddr string) ([]Device, error) { | ||||
var devices []Device | var devices []Device | ||||
@@ -14,11 +14,10 @@ import ( | |||||
"gim/pkg/pb" | "gim/pkg/pb" | ||||
"gim/pkg/rpc" | "gim/pkg/rpc" | ||||
"gim/pkg/util" | "gim/pkg/util" | ||||
"strconv" | |||||
"time" | |||||
"go.uber.org/zap" | "go.uber.org/zap" | ||||
"google.golang.org/protobuf/proto" | "google.golang.org/protobuf/proto" | ||||
"strconv" | |||||
"time" | |||||
) | ) | ||||
const MessageLimit = 50 // 最大消息同步数量 | const MessageLimit = 50 // 最大消息同步数量 | ||||
@@ -160,7 +159,7 @@ func (*messageService) SendToUser(ctx context.Context, sender *pb.Sender, toUser | |||||
var isPush = false | var isPush = false | ||||
for i := range devices { | for i := range devices { | ||||
if sender.DeviceId == devices[i].DeviceId && !isPush { | |||||
if !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" { | ||||
uid := strconv.FormatInt(req.ReceiverId, 10) | uid := strconv.FormatInt(req.ReceiverId, 10) | ||||
@@ -183,6 +182,8 @@ func (*messageService) SendToUser(ctx context.Context, sender *pb.Sender, toUser | |||||
isPush = true | isPush = true | ||||
} | } | ||||
} | } | ||||
} | |||||
if sender.DeviceId == devices[i].DeviceId { | |||||
// 消息不需要投递给发送消息的设备 | // 消息不需要投递给发送消息的设备 | ||||
continue | continue | ||||
} | } | ||||