DengBiao преди 2 години
родител
ревизия
84516cfb8e
променени са 4 файла, в които са добавени 24 реда и са изтрити 5 реда
  1. +5
    -1
      go.mod
  2. +4
    -0
      go.sum
  3. +10
    -0
      internal/logic/domain/device/device_dao.go
  4. +5
    -4
      internal/logic/domain/message/service/message_service.go

+ 5
- 1
go.mod Целия файл

@@ -3,6 +3,7 @@ module gim
go 1.18

require (
code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git v1.0.2
github.com/alberliu/gn v1.10.0
github.com/gin-gonic/gin v1.7.7
github.com/go-redis/redis v6.15.9+incompatible
@@ -22,7 +23,6 @@ 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/urlesc v0.0.0-20170810143723-de5bf2ad4578 // 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/reflect2 v1.0.2 // 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
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect


+ 4
- 0
go.sum Целия файл

@@ -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.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
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/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
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/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
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/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=


+ 10
- 0
internal/logic/domain/device/device_dao.go Целия файл

@@ -47,6 +47,16 @@ func (*deviceDao) ListOnlineByUserId(userId int64) ([]Device, error) {
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 查询用户所有的在线设备
func (*deviceDao) ListOnlineByConnAddr(connAddr string) ([]Device, error) {
var devices []Device


+ 5
- 4
internal/logic/domain/message/service/message_service.go Целия файл

@@ -14,11 +14,10 @@ import (
"gim/pkg/pb"
"gim/pkg/rpc"
"gim/pkg/util"
"strconv"
"time"

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

const MessageLimit = 50 // 最大消息同步数量
@@ -160,7 +159,7 @@ func (*messageService) SendToUser(ctx context.Context, sender *pb.Sender, toUser

var isPush = false
for i := range devices {
if sender.DeviceId == devices[i].DeviceId && !isPush {
if !isPush {
isOpenAppPush := svc.SysCfgGet(masterId, "is_open_app_push")
if req.ReceiverType == 1 && isOpenAppPush == "1" {
uid := strconv.FormatInt(req.ReceiverId, 10)
@@ -183,6 +182,8 @@ func (*messageService) SendToUser(ctx context.Context, sender *pb.Sender, toUser
isPush = true
}
}
}
if sender.DeviceId == devices[i].DeviceId {
// 消息不需要投递给发送消息的设备
continue
}


Зареждане…
Отказ
Запис