mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-30 22:37:04 +08:00
Merge branch '3.6.1-code-conventions' of https://github.com/FGadvancer/Open-IM-Server into 3.6.1-code-conventions
This commit is contained in:
commit
96c770863d
4
go.mod
4
go.mod
@ -2,8 +2,6 @@ module github.com/openimsdk/open-im-server/v3
|
|||||||
|
|
||||||
go 1.21
|
go 1.21
|
||||||
|
|
||||||
toolchain go1.21.8
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
firebase.google.com/go v3.13.0+incompatible
|
firebase.google.com/go v3.13.0+incompatible
|
||||||
github.com/dtm-labs/rockscache v0.1.1
|
github.com/dtm-labs/rockscache v0.1.1
|
||||||
@ -16,7 +14,7 @@ require (
|
|||||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect
|
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0
|
github.com/mitchellh/mapstructure v1.5.0
|
||||||
github.com/openimsdk/localcache v0.0.1
|
github.com/openimsdk/localcache v0.0.1
|
||||||
github.com/openimsdk/protocol v0.0.58-google
|
github.com/openimsdk/protocol v0.0.58
|
||||||
github.com/openimsdk/tools v0.0.47-alpha.10
|
github.com/openimsdk/tools v0.0.47-alpha.10
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/prometheus/client_golang v1.18.0
|
github.com/prometheus/client_golang v1.18.0
|
||||||
|
|||||||
4
go.sum
4
go.sum
@ -257,8 +257,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
|
|||||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||||
github.com/openimsdk/protocol v0.0.58-google h1:cGNUVaXO9LqcFgIb4NvrtEOrv0spGecoQKyN8YWhyZs=
|
github.com/openimsdk/protocol v0.0.58 h1:wxCZBty7zNOcBsiZmrZRQLtaLPv4UpGyxLZp1GGrwic=
|
||||||
github.com/openimsdk/protocol v0.0.58-google/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
|
github.com/openimsdk/protocol v0.0.58/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
|
||||||
github.com/openimsdk/tools v0.0.47-alpha.10 h1:bel44PB4xcC1uO+1y/LYhgsPmAGpxrlNd8JaFL4yc50=
|
github.com/openimsdk/tools v0.0.47-alpha.10 h1:bel44PB4xcC1uO+1y/LYhgsPmAGpxrlNd8JaFL4yc50=
|
||||||
github.com/openimsdk/tools v0.0.47-alpha.10/go.mod h1:mUsH+ANKbdmhUih43ijJHvuYcU8owm7X3kdFH7FsIec=
|
github.com/openimsdk/tools v0.0.47-alpha.10/go.mod h1:mUsH+ANKbdmhUih43ijJHvuYcU8owm7X3kdFH7FsIec=
|
||||||
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
|
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openimsdk/tools/db/redisutil"
|
"github.com/openimsdk/tools/db/redisutil"
|
||||||
"net"
|
"net"
|
||||||
@ -54,8 +53,7 @@ import (
|
|||||||
|
|
||||||
func Start(ctx context.Context, config *config.GlobalConfig, port int, proPort int) error {
|
func Start(ctx context.Context, config *config.GlobalConfig, port int, proPort int) error {
|
||||||
if port == 0 || proPort == 0 {
|
if port == 0 || proPort == 0 {
|
||||||
wrappedErr := errs.WrapMsg(errors.New("port or proPort is empty"), "validation error", "port", port, "proPort", proPort)
|
return errs.New("port or proPort is empty", "port", port, "proPort", proPort).Wrap()
|
||||||
return wrappedErr
|
|
||||||
}
|
}
|
||||||
rdb, err := redisutil.NewRedisClient(ctx, config.Redis.Build())
|
rdb, err := redisutil.NewRedisClient(ctx, config.Redis.Build())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package msggateway
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"sync"
|
"sync"
|
||||||
@ -34,10 +33,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrConnClosed = errors.New("conn has closed")
|
ErrConnClosed = errs.New("conn has closed")
|
||||||
ErrNotSupportMessageProtocol = errors.New("not support message protocol")
|
ErrNotSupportMessageProtocol = errs.New("not support message protocol")
|
||||||
ErrClientClosed = errors.New("client actively close the connection")
|
ErrClientClosed = errs.New("client actively close the connection")
|
||||||
ErrPanic = errors.New("panic error")
|
ErrPanic = errs.New("panic error")
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -187,7 +186,7 @@ func (c *Client) handleMessage(message []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if binaryReq.SendID != c.UserID {
|
if binaryReq.SendID != c.UserID {
|
||||||
return errs.WrapMsg(errors.New("exception conn userID not same to req userID"), binaryReq.String())
|
return errs.New("exception conn userID not same to req userID", "binaryReq", binaryReq.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := mcontext.WithMustInfoCtx(
|
ctx := mcontext.WithMustInfoCtx(
|
||||||
@ -267,7 +266,7 @@ func (c *Client) replyMessage(ctx context.Context, binaryReq *Req, err error, re
|
|||||||
}
|
}
|
||||||
|
|
||||||
if binaryReq.ReqIdentifier == WsLogoutMsg {
|
if binaryReq.ReqIdentifier == WsLogoutMsg {
|
||||||
return errs.WrapMsg(errors.New("user logout"), "user requested logout", "operationID", binaryReq.OperationID)
|
return errs.New("user logout", "operationID", binaryReq.OperationID).Wrap()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@
|
|||||||
package msggateway
|
package msggateway
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -99,9 +98,8 @@ func (d *GWebSocket) SetReadDeadline(timeout time.Duration) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *GWebSocket) SetWriteDeadline(timeout time.Duration) error {
|
func (d *GWebSocket) SetWriteDeadline(timeout time.Duration) error {
|
||||||
// TODO add error
|
|
||||||
if timeout <= 0 {
|
if timeout <= 0 {
|
||||||
return errs.Wrap(errors.New("timeout must be greater than 0"))
|
return errs.New("timeout must be greater than 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO SetWriteDeadline Future add error handling
|
// TODO SetWriteDeadline Future add error handling
|
||||||
|
|||||||
@ -17,7 +17,6 @@ package msggateway
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -59,13 +58,6 @@ type LongConnServer interface {
|
|||||||
MessageHandler
|
MessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
// bufferPool is unused
|
|
||||||
// var bufferPool = sync.Pool{
|
|
||||||
// New: func() any {
|
|
||||||
// return make([]byte, 1024)
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
|
|
||||||
type WsServer struct {
|
type WsServer struct {
|
||||||
globalConfig *config.GlobalConfig
|
globalConfig *config.GlobalConfig
|
||||||
port int
|
port int
|
||||||
@ -128,10 +120,7 @@ func (ws *WsServer) UnRegister(c *Client) {
|
|||||||
ws.unregisterChan <- c
|
ws.unregisterChan <- c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WsServer) Validate(s any) error {
|
func (ws *WsServer) Validate(_ any) error {
|
||||||
if s == nil {
|
|
||||||
return errs.WrapMsg(errors.New("input cannot be nil"), "Validate: input is nil", "action", "validate", "dataType", "any")
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +361,7 @@ func (ws *WsServer) multiTerminalLoginChecker(clientOK bool, oldClients []*Clien
|
|||||||
log.ZWarn(
|
log.ZWarn(
|
||||||
newClient.ctx,
|
newClient.ctx,
|
||||||
"m is nil",
|
"m is nil",
|
||||||
errors.New("m is nil"),
|
errs.New("m is nil"),
|
||||||
"userID",
|
"userID",
|
||||||
newClient.UserID,
|
newClient.UserID,
|
||||||
"platformID",
|
"platformID",
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package msgtransfer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openimsdk/tools/db/mongoutil"
|
"github.com/openimsdk/tools/db/mongoutil"
|
||||||
"github.com/openimsdk/tools/db/redisutil"
|
"github.com/openimsdk/tools/db/redisutil"
|
||||||
@ -114,7 +113,7 @@ func NewMsgTransfer(kafkaConf *config.Kafka, msgDatabase controller.CommonMsgDat
|
|||||||
|
|
||||||
func (m *MsgTransfer) Start(prometheusPort int, config *config.GlobalConfig, index int) error {
|
func (m *MsgTransfer) Start(prometheusPort int, config *config.GlobalConfig, index int) error {
|
||||||
if prometheusPort <= 0 {
|
if prometheusPort <= 0 {
|
||||||
return errs.WrapMsg(errors.New("invalid prometheus port"), "prometheusPort validation failed", "providedPort", prometheusPort)
|
return errs.New("invalid prometheus port", "prometheusPort", prometheusPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
m.ctx, m.cancel = context.WithCancel(context.Background())
|
m.ctx, m.cancel = context.WithCancel(context.Background())
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -35,8 +34,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrTokenExpire = errors.New("token expire")
|
ErrTokenExpire = errs.New("token expire")
|
||||||
ErrUserIDEmpty = errors.New("userIDs is empty")
|
ErrUserIDEmpty = errs.New("userIDs is empty")
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
package body
|
package body
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"github.com/openimsdk/tools/errs"
|
||||||
|
|
||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
)
|
)
|
||||||
@ -39,7 +39,7 @@ func (p *Platform) Set(os string) error {
|
|||||||
} else {
|
} else {
|
||||||
switch p.Os.(type) {
|
switch p.Os.(type) {
|
||||||
case string:
|
case string:
|
||||||
return errors.New("platform is all")
|
return errs.New("platform is all")
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ func (p *Platform) Set(os string) error {
|
|||||||
p.osArry = append(p.osArry, os)
|
p.osArry = append(p.osArry, os)
|
||||||
p.Os = p.osArry
|
p.Os = p.osArry
|
||||||
default:
|
default:
|
||||||
return errors.New("unknow platform")
|
return errs.New("unknow platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -74,7 +74,7 @@ func (p *Platform) SetPlatform(platform string) error {
|
|||||||
case constant.IOSPlatformStr:
|
case constant.IOSPlatformStr:
|
||||||
return p.SetIOS()
|
return p.SetIOS()
|
||||||
default:
|
default:
|
||||||
return errors.New("platform err")
|
return errs.New("platform err")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ package push
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"github.com/openimsdk/tools/errs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/push/offlinepush"
|
"github.com/openimsdk/open-im-server/v3/internal/push/offlinepush"
|
||||||
@ -59,7 +59,7 @@ type Pusher struct {
|
|||||||
groupRpcClient *rpcclient.GroupRpcClient
|
groupRpcClient *rpcclient.GroupRpcClient
|
||||||
}
|
}
|
||||||
|
|
||||||
var errNoOfflinePusher = errors.New("no offlinePusher is configured")
|
var errNoOfflinePusher = errs.New("no offlinePusher is configured")
|
||||||
|
|
||||||
func NewPusher(config *config.GlobalConfig, discov discovery.SvcDiscoveryRegistry, offlinePusher offlinepush.OfflinePusher, database controller.PushDatabase,
|
func NewPusher(config *config.GlobalConfig, discov discovery.SvcDiscoveryRegistry, offlinePusher offlinepush.OfflinePusher, database controller.PushDatabase,
|
||||||
groupLocalCache *rpccache.GroupLocalCache, conversationLocalCache *rpccache.ConversationLocalCache,
|
groupLocalCache *rpccache.GroupLocalCache, conversationLocalCache *rpccache.ConversationLocalCache,
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package conversation
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"github.com/openimsdk/tools/db/redisutil"
|
"github.com/openimsdk/tools/db/redisutil"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
@ -315,12 +314,7 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
|
|||||||
|
|
||||||
// Get user IDs with "Do Not Disturb" enabled in super large groups.
|
// Get user IDs with "Do Not Disturb" enabled in super large groups.
|
||||||
func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req *pbconversation.GetRecvMsgNotNotifyUserIDsReq) (*pbconversation.GetRecvMsgNotNotifyUserIDsResp, error) {
|
func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req *pbconversation.GetRecvMsgNotNotifyUserIDsReq) (*pbconversation.GetRecvMsgNotNotifyUserIDsResp, error) {
|
||||||
// userIDs, err := c.conversationDatabase.FindRecvMsgNotNotifyUserIDs(ctx, req.GroupID)
|
return nil, errs.New("deprecated")
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
//}
|
|
||||||
// return &pbconversation.GetRecvMsgNotNotifyUserIDsResp{UserIDs: userIDs}, nil
|
|
||||||
return nil, errors.New("deprecated")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create conversation without notification for msg redis transfer.
|
// create conversation without notification for msg redis transfer.
|
||||||
|
|||||||
@ -299,7 +299,6 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
// s.Notification.GroupCreatedNotification(ctx, group, groupMembers, userMap)
|
|
||||||
tips := &sdkws.GroupCreatedTips{
|
tips := &sdkws.GroupCreatedTips{
|
||||||
Group: resp.GroupInfo,
|
Group: resp.GroupInfo,
|
||||||
OperationTime: group.CreateTime.UnixMilli(),
|
OperationTime: group.CreateTime.UnixMilli(),
|
||||||
@ -333,7 +332,6 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbgroup.GetJoinedGroupListReq) (*pbgroup.GetJoinedGroupListResp, error) {
|
func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbgroup.GetJoinedGroupListReq) (*pbgroup.GetJoinedGroupListResp, error) {
|
||||||
resp := &pbgroup.GetJoinedGroupListResp{}
|
|
||||||
if err := authverify.CheckAccessV3(ctx, req.FromUserID, &s.config.Manager, &s.config.IMAdmin); err != nil {
|
if err := authverify.CheckAccessV3(ctx, req.FromUserID, &s.config.Manager, &s.config.IMAdmin); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -341,9 +339,10 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbgroup.GetJo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var resp pbgroup.GetJoinedGroupListResp
|
||||||
resp.Total = uint32(total)
|
resp.Total = uint32(total)
|
||||||
if len(members) == 0 {
|
if len(members) == 0 {
|
||||||
return resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
groupIDs := datautil.Slice(members, func(e *relationtb.GroupMemberModel) string {
|
groupIDs := datautil.Slice(members, func(e *relationtb.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
@ -375,12 +374,10 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbgroup.GetJo
|
|||||||
}
|
}
|
||||||
return convert.Db2PbGroupInfo(group, userID, groupMemberNum[group.GroupID])
|
return convert.Db2PbGroupInfo(group, userID, groupMemberNum[group.GroupID])
|
||||||
})
|
})
|
||||||
return resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.InviteUserToGroupReq) (*pbgroup.InviteUserToGroupResp, error) {
|
func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.InviteUserToGroupReq) (*pbgroup.InviteUserToGroupResp, error) {
|
||||||
resp := &pbgroup.InviteUserToGroupResp{}
|
|
||||||
|
|
||||||
if len(req.InvitedUserIDs) == 0 {
|
if len(req.InvitedUserIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.WrapMsg("user empty")
|
return nil, errs.ErrArgs.WrapMsg("user empty")
|
||||||
}
|
}
|
||||||
@ -453,7 +450,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
InviterUserID: request.InviterUserID,
|
InviterUserID: request.InviterUserID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return resp, nil
|
return &pbgroup.InviteUserToGroupResp{}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -484,7 +481,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.Notification.MemberInvitedNotification(ctx, req.GroupID, req.Reason, req.InvitedUserIDs)
|
s.Notification.MemberInvitedNotification(ctx, req.GroupID, req.Reason, req.InvitedUserIDs)
|
||||||
return resp, nil
|
return &pbgroup.InviteUserToGroupResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbgroup.GetGroupAllMemberReq) (*pbgroup.GetGroupAllMemberResp, error) {
|
func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbgroup.GetGroupAllMemberReq) (*pbgroup.GetGroupAllMemberResp, error) {
|
||||||
@ -495,15 +492,14 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbgroup.GetGro
|
|||||||
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp := &pbgroup.GetGroupAllMemberResp{}
|
var resp pbgroup.GetGroupAllMemberResp
|
||||||
resp.Members = datautil.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
resp.Members = datautil.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||||
return convert.Db2PbGroupMember(e)
|
return convert.Db2PbGroupMember(e)
|
||||||
})
|
})
|
||||||
return resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbgroup.GetGroupMemberListReq) (*pbgroup.GetGroupMemberListResp, error) {
|
func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbgroup.GetGroupMemberListReq) (*pbgroup.GetGroupMemberListResp, error) {
|
||||||
resp := &pbgroup.GetGroupMemberListResp{}
|
|
||||||
var (
|
var (
|
||||||
total int64
|
total int64
|
||||||
members []*relationtb.GroupMemberModel
|
members []*relationtb.GroupMemberModel
|
||||||
@ -535,18 +531,19 @@ func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbgroup.GetGr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GMembers := datautil.Paginate(groupMembers, int(req.Pagination.GetPageNumber()), int(req.Pagination.GetShowNumber()))
|
members := datautil.Paginate(groupMembers, int(req.Pagination.GetPageNumber()), int(req.Pagination.GetShowNumber()))
|
||||||
resp.Members = datautil.Batch(convert.Db2PbGroupMember, GMembers)
|
return &pbgroup.GetGroupMemberListResp{
|
||||||
resp.Total = uint32(total)
|
Total: uint32(total),
|
||||||
return resp, nil
|
Members: datautil.Batch(convert.Db2PbGroupMember, members),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
resp.Total = uint32(total)
|
return &pbgroup.GetGroupMemberListResp{
|
||||||
resp.Members = datautil.Batch(convert.Db2PbGroupMember, members)
|
Total: uint32(total),
|
||||||
return resp, nil
|
Members: datautil.Batch(convert.Db2PbGroupMember, members),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGroupMemberReq) (*pbgroup.KickGroupMemberResp, error) {
|
func (s *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGroupMemberReq) (*pbgroup.KickGroupMemberResp, error) {
|
||||||
resp := &pbgroup.KickGroupMemberResp{}
|
|
||||||
group, err := s.db.TakeGroup(ctx, req.GroupID)
|
group, err := s.db.TakeGroup(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -652,11 +649,10 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGrou
|
|||||||
if err := CallbackKillGroupMember(ctx, killGroupMemberConfig, req); err != nil {
|
if err := CallbackKillGroupMember(ctx, killGroupMemberConfig, req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return resp, nil
|
return &pbgroup.KickGroupMemberResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbgroup.GetGroupMembersInfoReq) (*pbgroup.GetGroupMembersInfoResp, error) {
|
func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbgroup.GetGroupMembersInfoReq) (*pbgroup.GetGroupMembersInfoResp, error) {
|
||||||
resp := &pbgroup.GetGroupMembersInfoResp{}
|
|
||||||
if len(req.UserIDs) == 0 {
|
if len(req.UserIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.WrapMsg("userIDs empty")
|
return nil, errs.ErrArgs.WrapMsg("userIDs empty")
|
||||||
}
|
}
|
||||||
@ -670,10 +666,11 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbgroup.GetG
|
|||||||
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Members = datautil.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
return &pbgroup.GetGroupMembersInfoResp{
|
||||||
return convert.Db2PbGroupMember(e)
|
Members: datautil.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||||
})
|
return convert.Db2PbGroupMember(e)
|
||||||
return resp, nil
|
}),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGroupApplicationList handles functions that get a list of group requests.
|
// GetGroupApplicationList handles functions that get a list of group requests.
|
||||||
@ -739,7 +736,6 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbgroup.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbgroup.GetGroupsInfoReq) (*pbgroup.GetGroupsInfoResp, error) {
|
func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbgroup.GetGroupsInfoReq) (*pbgroup.GetGroupsInfoResp, error) {
|
||||||
resp := &pbgroup.GetGroupsInfoResp{}
|
|
||||||
if len(req.GroupIDs) == 0 {
|
if len(req.GroupIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.WrapMsg("groupID is empty")
|
return nil, errs.ErrArgs.WrapMsg("groupID is empty")
|
||||||
}
|
}
|
||||||
@ -761,14 +757,15 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbgroup.GetGroupsI
|
|||||||
ownerMap := datautil.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
ownerMap := datautil.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
resp.GroupInfos = datautil.Slice(groups, func(e *relationtb.GroupModel) *sdkws.GroupInfo {
|
return &pbgroup.GetGroupsInfoResp{
|
||||||
var ownerUserID string
|
GroupInfos: datautil.Slice(groups, func(e *relationtb.GroupModel) *sdkws.GroupInfo {
|
||||||
if owner, ok := ownerMap[e.GroupID]; ok {
|
var ownerUserID string
|
||||||
ownerUserID = owner.UserID
|
if owner, ok := ownerMap[e.GroupID]; ok {
|
||||||
}
|
ownerUserID = owner.UserID
|
||||||
return convert.Db2PbGroupInfo(e, ownerUserID, groupMemberNumMap[e.GroupID])
|
}
|
||||||
})
|
return convert.Db2PbGroupInfo(e, ownerUserID, groupMemberNumMap[e.GroupID])
|
||||||
return resp, nil
|
}),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup.GroupApplicationResponseReq) (*pbgroup.GroupApplicationResponseResp, error) {
|
func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup.GroupApplicationResponseReq) (*pbgroup.GroupApplicationResponseResp, error) {
|
||||||
@ -887,7 +884,6 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.ZInfo(ctx, "JoinGroup.groupInfo", "group", group, "eq", group.NeedVerification == constant.Directly)
|
log.ZInfo(ctx, "JoinGroup.groupInfo", "group", group, "eq", group.NeedVerification == constant.Directly)
|
||||||
resp = &pbgroup.JoinGroupResp{}
|
|
||||||
if group.NeedVerification == constant.Directly {
|
if group.NeedVerification == constant.Directly {
|
||||||
groupMember := &relationtb.GroupMemberModel{
|
groupMember := &relationtb.GroupMemberModel{
|
||||||
GroupID: group.GroupID,
|
GroupID: group.GroupID,
|
||||||
@ -914,7 +910,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
|||||||
if err = CallbackAfterJoinGroup(ctx, afterJoinGroupConfig, req); err != nil {
|
if err = CallbackAfterJoinGroup(ctx, afterJoinGroupConfig, req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return resp, nil
|
return &pbgroup.JoinGroupResp{}, nil
|
||||||
}
|
}
|
||||||
groupRequest := relationtb.GroupRequestModel{
|
groupRequest := relationtb.GroupRequestModel{
|
||||||
UserID: req.InviterUserID,
|
UserID: req.InviterUserID,
|
||||||
@ -929,11 +925,10 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.Notification.JoinGroupApplicationNotification(ctx, req)
|
s.Notification.JoinGroupApplicationNotification(ctx, req)
|
||||||
return resp, nil
|
return &pbgroup.JoinGroupResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) QuitGroup(ctx context.Context, req *pbgroup.QuitGroupReq) (*pbgroup.QuitGroupResp, error) {
|
func (s *groupServer) QuitGroup(ctx context.Context, req *pbgroup.QuitGroupReq) (*pbgroup.QuitGroupResp, error) {
|
||||||
resp := &pbgroup.QuitGroupResp{}
|
|
||||||
if req.UserID == "" {
|
if req.UserID == "" {
|
||||||
req.UserID = mcontext.GetOpUserID(ctx)
|
req.UserID = mcontext.GetOpUserID(ctx)
|
||||||
} else {
|
} else {
|
||||||
@ -968,7 +963,7 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbgroup.QuitGroupReq)
|
|||||||
if err := CallbackQuitGroup(ctx, quitGroupConfig, req); err != nil {
|
if err := CallbackQuitGroup(ctx, quitGroupConfig, req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return resp, nil
|
return &pbgroup.QuitGroupResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, groupID string, userIDs []string) error {
|
func (s *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, groupID string, userIDs []string) error {
|
||||||
@ -1011,7 +1006,6 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbgroup.SetGroupInf
|
|||||||
if group.Status == constant.GroupStatusDismissed {
|
if group.Status == constant.GroupStatusDismissed {
|
||||||
return nil, servererrs.ErrDismissedAlready.Wrap()
|
return nil, servererrs.ErrDismissedAlready.Wrap()
|
||||||
}
|
}
|
||||||
resp := &pbgroup.SetGroupInfoResp{}
|
|
||||||
|
|
||||||
count, err := s.db.FindGroupMemberNum(ctx, group.GroupID)
|
count, err := s.db.FindGroupMemberNum(ctx, group.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1026,7 +1020,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbgroup.SetGroupInf
|
|||||||
}
|
}
|
||||||
update := UpdateGroupInfoMap(ctx, req.GroupInfoForSet)
|
update := UpdateGroupInfoMap(ctx, req.GroupInfoForSet)
|
||||||
if len(update) == 0 {
|
if len(update) == 0 {
|
||||||
return resp, nil
|
return &pbgroup.SetGroupInfoResp{}, nil
|
||||||
}
|
}
|
||||||
if err := s.db.UpdateGroup(ctx, group.GroupID, update); err != nil {
|
if err := s.db.UpdateGroup(ctx, group.GroupID, update); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1076,11 +1070,10 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbgroup.SetGroupInf
|
|||||||
if err := CallbackAfterSetGroupInfo(ctx, afterSetGroupInfoConfig, req); err != nil {
|
if err := CallbackAfterSetGroupInfo(ctx, afterSetGroupInfoConfig, req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return resp, nil
|
return &pbgroup.SetGroupInfoResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbgroup.TransferGroupOwnerReq) (*pbgroup.TransferGroupOwnerResp, error) {
|
func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbgroup.TransferGroupOwnerReq) (*pbgroup.TransferGroupOwnerResp, error) {
|
||||||
resp := &pbgroup.TransferGroupOwnerResp{}
|
|
||||||
group, err := s.db.TakeGroup(ctx, req.GroupID)
|
group, err := s.db.TakeGroup(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1128,16 +1121,15 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbgroup.Trans
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.Notification.GroupOwnerTransferredNotification(ctx, req)
|
s.Notification.GroupOwnerTransferredNotification(ctx, req)
|
||||||
return resp, nil
|
return &pbgroup.TransferGroupOwnerResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq) (*pbgroup.GetGroupsResp, error) {
|
func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq) (*pbgroup.GetGroupsResp, error) {
|
||||||
resp := &pbgroup.GetGroupsResp{}
|
|
||||||
var (
|
var (
|
||||||
group []*relationtb.GroupModel
|
group []*relationtb.GroupModel
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
var resp pbgroup.GetGroupsResp
|
||||||
if req.GroupID != "" {
|
if req.GroupID != "" {
|
||||||
group, err = s.db.FindGroup(ctx, []string{req.GroupID})
|
group, err = s.db.FindGroup(ctx, []string{req.GroupID})
|
||||||
resp.Total = uint32(len(group))
|
resp.Total = uint32(len(group))
|
||||||
@ -1178,15 +1170,15 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq)
|
|||||||
}
|
}
|
||||||
return convert.Db2PbCMSGroup(group, userID, username, groupMemberNumMap[group.GroupID])
|
return convert.Db2PbCMSGroup(group, userID, username, groupMemberNumMap[group.GroupID])
|
||||||
})
|
})
|
||||||
return resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbgroup.GetGroupMembersCMSReq) (*pbgroup.GetGroupMembersCMSResp, error) {
|
func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbgroup.GetGroupMembersCMSReq) (*pbgroup.GetGroupMembersCMSResp, error) {
|
||||||
resp := &pbgroup.GetGroupMembersCMSResp{}
|
|
||||||
total, members, err := s.db.SearchGroupMember(ctx, req.UserName, req.GroupID, req.Pagination)
|
total, members, err := s.db.SearchGroupMember(ctx, req.UserName, req.GroupID, req.Pagination)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var resp pbgroup.GetGroupMembersCMSResp
|
||||||
resp.Total = uint32(total)
|
resp.Total = uint32(total)
|
||||||
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1194,11 +1186,10 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbgroup.GetGr
|
|||||||
resp.Members = datautil.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
resp.Members = datautil.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||||
return convert.Db2PbGroupMember(e)
|
return convert.Db2PbGroupMember(e)
|
||||||
})
|
})
|
||||||
return resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbgroup.GetUserReqApplicationListReq) (*pbgroup.GetUserReqApplicationListResp, error) {
|
func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbgroup.GetUserReqApplicationListReq) (*pbgroup.GetUserReqApplicationListResp, error) {
|
||||||
resp := &pbgroup.GetUserReqApplicationListResp{}
|
|
||||||
user, err := s.User.GetPublicUserInfo(ctx, req.UserID)
|
user, err := s.User.GetPublicUserInfo(ctx, req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1207,9 +1198,8 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbgrou
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Total = uint32(total)
|
|
||||||
if len(requests) == 0 {
|
if len(requests) == 0 {
|
||||||
return resp, nil
|
return &pbgroup.GetUserReqApplicationListResp{Total: uint32(total)}, nil
|
||||||
}
|
}
|
||||||
groupIDs := datautil.Distinct(datautil.Slice(requests, func(e *relationtb.GroupRequestModel) string {
|
groupIDs := datautil.Distinct(datautil.Slice(requests, func(e *relationtb.GroupRequestModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
@ -1235,18 +1225,19 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbgrou
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.GroupRequests = datautil.Slice(requests, func(e *relationtb.GroupRequestModel) *sdkws.GroupRequest {
|
return &pbgroup.GetUserReqApplicationListResp{
|
||||||
var ownerUserID string
|
Total: uint32(total),
|
||||||
if owner, ok := ownerMap[e.GroupID]; ok {
|
GroupRequests: datautil.Slice(requests, func(e *relationtb.GroupRequestModel) *sdkws.GroupRequest {
|
||||||
ownerUserID = owner.UserID
|
var ownerUserID string
|
||||||
}
|
if owner, ok := ownerMap[e.GroupID]; ok {
|
||||||
return convert.Db2PbGroupRequest(e, user, convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerUserID, groupMemberNum[e.GroupID]))
|
ownerUserID = owner.UserID
|
||||||
})
|
}
|
||||||
return resp, nil
|
return convert.Db2PbGroupRequest(e, user, convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerUserID, groupMemberNum[e.GroupID]))
|
||||||
|
}),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) DismissGroup(ctx context.Context, req *pbgroup.DismissGroupReq) (*pbgroup.DismissGroupResp, error) {
|
func (s *groupServer) DismissGroup(ctx context.Context, req *pbgroup.DismissGroupReq) (*pbgroup.DismissGroupResp, error) {
|
||||||
resp := &pbgroup.DismissGroupResp{}
|
|
||||||
owner, err := s.db.TakeGroupOwner(ctx, req.GroupID)
|
owner, err := s.db.TakeGroupOwner(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1303,11 +1294,10 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbgroup.DismissGrou
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return &pbgroup.DismissGroupResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbgroup.MuteGroupMemberReq) (*pbgroup.MuteGroupMemberResp, error) {
|
func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbgroup.MuteGroupMemberReq) (*pbgroup.MuteGroupMemberResp, error) {
|
||||||
resp := &pbgroup.MuteGroupMemberResp{}
|
|
||||||
member, err := s.db.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
member, err := s.db.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1338,7 +1328,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbgroup.MuteGrou
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.Notification.GroupMemberMutedNotification(ctx, req.GroupID, req.UserID, req.MutedSeconds)
|
s.Notification.GroupMemberMutedNotification(ctx, req.GroupID, req.UserID, req.MutedSeconds)
|
||||||
return resp, nil
|
return &pbgroup.MuteGroupMemberResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbgroup.CancelMuteGroupMemberReq) (*pbgroup.CancelMuteGroupMemberResp, error) {
|
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbgroup.CancelMuteGroupMemberReq) (*pbgroup.CancelMuteGroupMemberResp, error) {
|
||||||
@ -1376,7 +1366,6 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbgroup.Ca
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) MuteGroup(ctx context.Context, req *pbgroup.MuteGroupReq) (*pbgroup.MuteGroupResp, error) {
|
func (s *groupServer) MuteGroup(ctx context.Context, req *pbgroup.MuteGroupReq) (*pbgroup.MuteGroupResp, error) {
|
||||||
resp := &pbgroup.MuteGroupResp{}
|
|
||||||
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1384,11 +1373,10 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbgroup.MuteGroupReq)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.Notification.GroupMutedNotification(ctx, req.GroupID)
|
s.Notification.GroupMutedNotification(ctx, req.GroupID)
|
||||||
return resp, nil
|
return &pbgroup.MuteGroupResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbgroup.CancelMuteGroupReq) (*pbgroup.CancelMuteGroupResp, error) {
|
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbgroup.CancelMuteGroupReq) (*pbgroup.CancelMuteGroupResp, error) {
|
||||||
resp := &pbgroup.CancelMuteGroupResp{}
|
|
||||||
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1396,11 +1384,10 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbgroup.CancelMu
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.Notification.GroupCancelMutedNotification(ctx, req.GroupID)
|
s.Notification.GroupCancelMutedNotification(ctx, req.GroupID)
|
||||||
return resp, nil
|
return &pbgroup.CancelMuteGroupResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbgroup.SetGroupMemberInfoReq) (*pbgroup.SetGroupMemberInfoResp, error) {
|
func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbgroup.SetGroupMemberInfoReq) (*pbgroup.SetGroupMemberInfoResp, error) {
|
||||||
resp := &pbgroup.SetGroupMemberInfoResp{}
|
|
||||||
if len(req.Members) == 0 {
|
if len(req.Members) == 0 {
|
||||||
return nil, errs.ErrArgs.WrapMsg("members empty")
|
return nil, errs.ErrArgs.WrapMsg("members empty")
|
||||||
}
|
}
|
||||||
@ -1530,11 +1517,10 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbgroup.SetGr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return &pbgroup.SetGroupMemberInfoResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbgroup.GetGroupAbstractInfoReq) (*pbgroup.GetGroupAbstractInfoResp, error) {
|
func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbgroup.GetGroupAbstractInfoReq) (*pbgroup.GetGroupAbstractInfoResp, error) {
|
||||||
resp := &pbgroup.GetGroupAbstractInfoResp{}
|
|
||||||
if len(req.GroupIDs) == 0 {
|
if len(req.GroupIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.WrapMsg("groupIDs empty")
|
return nil, errs.ErrArgs.WrapMsg("groupIDs empty")
|
||||||
}
|
}
|
||||||
@ -1557,15 +1543,15 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbgroup.Get
|
|||||||
if ids := datautil.Single(req.GroupIDs, datautil.Keys(groupUserMap)); len(ids) > 0 {
|
if ids := datautil.Single(req.GroupIDs, datautil.Keys(groupUserMap)); len(ids) > 0 {
|
||||||
return nil, servererrs.ErrGroupIDNotFound.WrapMsg(fmt.Sprintf("group %s not found member", strings.Join(ids, ",")))
|
return nil, servererrs.ErrGroupIDNotFound.WrapMsg(fmt.Sprintf("group %s not found member", strings.Join(ids, ",")))
|
||||||
}
|
}
|
||||||
resp.GroupAbstractInfos = datautil.Slice(groups, func(group *relationtb.GroupModel) *pbgroup.GroupAbstractInfo {
|
return &pbgroup.GetGroupAbstractInfoResp{
|
||||||
users := groupUserMap[group.GroupID]
|
GroupAbstractInfos: datautil.Slice(groups, func(group *relationtb.GroupModel) *pbgroup.GroupAbstractInfo {
|
||||||
return convert.Db2PbGroupAbstractInfo(group.GroupID, users.MemberNum, users.Hash)
|
users := groupUserMap[group.GroupID]
|
||||||
})
|
return convert.Db2PbGroupAbstractInfo(group.GroupID, users.MemberNum, users.Hash)
|
||||||
return resp, nil
|
}),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbgroup.GetUserInGroupMembersReq) (*pbgroup.GetUserInGroupMembersResp, error) {
|
func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbgroup.GetUserInGroupMembersReq) (*pbgroup.GetUserInGroupMembersResp, error) {
|
||||||
resp := &pbgroup.GetUserInGroupMembersResp{}
|
|
||||||
if len(req.GroupIDs) == 0 {
|
if len(req.GroupIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.WrapMsg("groupIDs empty")
|
return nil, errs.ErrArgs.WrapMsg("groupIDs empty")
|
||||||
}
|
}
|
||||||
@ -1576,23 +1562,24 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbgroup.Ge
|
|||||||
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Members = datautil.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
return &pbgroup.GetUserInGroupMembersResp{
|
||||||
return convert.Db2PbGroupMember(e)
|
Members: datautil.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||||
})
|
return convert.Db2PbGroupMember(e)
|
||||||
return resp, nil
|
}),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMemberUserIDs(ctx context.Context, req *pbgroup.GetGroupMemberUserIDsReq) (resp *pbgroup.GetGroupMemberUserIDsResp, err error) {
|
func (s *groupServer) GetGroupMemberUserIDs(ctx context.Context, req *pbgroup.GetGroupMemberUserIDsReq) (resp *pbgroup.GetGroupMemberUserIDsResp, err error) {
|
||||||
resp = &pbgroup.GetGroupMemberUserIDsResp{}
|
userIDs, err := s.db.FindGroupMemberUserID(ctx, req.GroupID)
|
||||||
resp.UserIDs, err = s.db.FindGroupMemberUserID(ctx, req.GroupID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return resp, nil
|
return &pbgroup.GetGroupMemberUserIDsResp{
|
||||||
|
UserIDs: userIDs,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbgroup.GetGroupMemberRoleLevelReq) (*pbgroup.GetGroupMemberRoleLevelResp, error) {
|
func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbgroup.GetGroupMemberRoleLevelReq) (*pbgroup.GetGroupMemberRoleLevelResp, error) {
|
||||||
resp := &pbgroup.GetGroupMemberRoleLevelResp{}
|
|
||||||
if len(req.RoleLevels) == 0 {
|
if len(req.RoleLevels) == 0 {
|
||||||
return nil, errs.ErrArgs.WrapMsg("RoleLevels empty")
|
return nil, errs.ErrArgs.WrapMsg("RoleLevels empty")
|
||||||
}
|
}
|
||||||
@ -1603,20 +1590,20 @@ func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbgroup.
|
|||||||
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Members = datautil.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
return &pbgroup.GetGroupMemberRoleLevelResp{
|
||||||
return convert.Db2PbGroupMember(e)
|
Members: datautil.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||||
})
|
return convert.Db2PbGroupMember(e)
|
||||||
return resp, nil
|
}),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *pbgroup.GetGroupUsersReqApplicationListReq) (*pbgroup.GetGroupUsersReqApplicationListResp, error) {
|
func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *pbgroup.GetGroupUsersReqApplicationListReq) (*pbgroup.GetGroupUsersReqApplicationListResp, error) {
|
||||||
resp := &pbgroup.GetGroupUsersReqApplicationListResp{}
|
|
||||||
requests, err := s.db.FindGroupRequests(ctx, req.GroupID, req.UserIDs)
|
requests, err := s.db.FindGroupRequests(ctx, req.GroupID, req.UserIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(requests) == 0 {
|
if len(requests) == 0 {
|
||||||
return resp, nil
|
return &pbgroup.GetGroupUsersReqApplicationListResp{}, nil
|
||||||
}
|
}
|
||||||
groupIDs := datautil.Distinct(datautil.Slice(requests, func(e *relationtb.GroupRequestModel) string {
|
groupIDs := datautil.Distinct(datautil.Slice(requests, func(e *relationtb.GroupRequestModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
@ -1645,13 +1632,14 @@ func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.GroupRequests = datautil.Slice(requests, func(e *relationtb.GroupRequestModel) *sdkws.GroupRequest {
|
return &pbgroup.GetGroupUsersReqApplicationListResp{
|
||||||
var ownerUserID string
|
Total: int64(len(requests)),
|
||||||
if owner, ok := ownerMap[e.GroupID]; ok {
|
GroupRequests: datautil.Slice(requests, func(e *relationtb.GroupRequestModel) *sdkws.GroupRequest {
|
||||||
ownerUserID = owner.UserID
|
var ownerUserID string
|
||||||
}
|
if owner, ok := ownerMap[e.GroupID]; ok {
|
||||||
return convert.Db2PbGroupRequest(e, nil, convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerUserID, groupMemberNum[e.GroupID]))
|
ownerUserID = owner.UserID
|
||||||
})
|
}
|
||||||
resp.Total = int64(len(resp.GroupRequests))
|
return convert.Db2PbGroupRequest(e, nil, convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerUserID, groupMemberNum[e.GroupID]))
|
||||||
return resp, nil
|
}),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,31 +0,0 @@
|
|||||||
// Copyright © 2023 OpenIM. All rights reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package group
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
|
|
||||||
pbgroup "github.com/openimsdk/protocol/group"
|
|
||||||
"github.com/openimsdk/tools/errs"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (s *groupServer) GetJoinedSuperGroupList(context.Context, *pbgroup.GetJoinedSuperGroupListReq) (*pbgroup.GetJoinedSuperGroupListResp, error) {
|
|
||||||
return nil, errs.WrapMsg(errors.New("GetJoinedSuperGroupList is deprecated"), "This feature is deprecated and no longer supported.")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) GetSuperGroupsInfo(context.Context, *pbgroup.GetSuperGroupsInfoReq) (resp *pbgroup.GetSuperGroupsInfoResp, err error) {
|
|
||||||
return nil, errs.WrapMsg(errors.New("GetSuperGroupsInfo is deprecated"), "This feature is deprecated and no longer supported.")
|
|
||||||
}
|
|
||||||
@ -16,7 +16,6 @@ package third
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
@ -65,17 +64,17 @@ func (t *thirdServer) checkUploadName(ctx context.Context, name string) error {
|
|||||||
|
|
||||||
func checkValidObjectNamePrefix(objectName string) error {
|
func checkValidObjectNamePrefix(objectName string) error {
|
||||||
if len(objectName) > 1024 {
|
if len(objectName) > 1024 {
|
||||||
return errors.New("object name cannot be longer than 1024 characters")
|
return errs.New("object name cannot be longer than 1024 characters")
|
||||||
}
|
}
|
||||||
if !utf8.ValidString(objectName) {
|
if !utf8.ValidString(objectName) {
|
||||||
return errors.New("object name with non UTF-8 strings are not supported")
|
return errs.New("object name with non UTF-8 strings are not supported")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkValidObjectName(objectName string) error {
|
func checkValidObjectName(objectName string) error {
|
||||||
if strings.TrimSpace(objectName) == "" {
|
if strings.TrimSpace(objectName) == "" {
|
||||||
return errors.New("object name cannot be empty")
|
return errs.New("object name cannot be empty")
|
||||||
}
|
}
|
||||||
return checkValidObjectNamePrefix(objectName)
|
return checkValidObjectNamePrefix(objectName)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package user
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"github.com/openimsdk/tools/db/redisutil"
|
"github.com/openimsdk/tools/db/redisutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strings"
|
"strings"
|
||||||
@ -71,7 +70,7 @@ func Start(ctx context.Context, config *config.GlobalConfig, client registry.Svc
|
|||||||
}
|
}
|
||||||
users := make([]*tablerelation.UserModel, 0)
|
users := make([]*tablerelation.UserModel, 0)
|
||||||
if len(config.IMAdmin.UserID) != len(config.IMAdmin.Nickname) {
|
if len(config.IMAdmin.UserID) != len(config.IMAdmin.Nickname) {
|
||||||
return errs.Wrap(errors.New("the count of ImAdmin.UserID is not equal to the count of ImAdmin.Nickname"))
|
return errs.New("the count of ImAdmin.UserID is not equal to the count of ImAdmin.Nickname").Wrap()
|
||||||
}
|
}
|
||||||
for k, v := range config.IMAdmin.UserID {
|
for k, v := range config.IMAdmin.UserID {
|
||||||
users = append(users, &tablerelation.UserModel{UserID: v, Nickname: config.IMAdmin.Nickname[k], AppMangerLevel: constant.AppNotificationAdmin})
|
users = append(users, &tablerelation.UserModel{UserID: v, Nickname: config.IMAdmin.Nickname[k], AppMangerLevel: constant.AppNotificationAdmin})
|
||||||
|
|||||||
@ -16,8 +16,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
|
|
||||||
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
@ -70,7 +68,7 @@ func (a *RpcCmd) Exec() error {
|
|||||||
|
|
||||||
func (a *RpcCmd) StartSvr(name string, rpcFn func(ctx context.Context, config *config2.GlobalConfig, disCov discovery.SvcDiscoveryRegistry, server *grpc.Server) error) error {
|
func (a *RpcCmd) StartSvr(name string, rpcFn func(ctx context.Context, config *config2.GlobalConfig, disCov discovery.SvcDiscoveryRegistry, server *grpc.Server) error) error {
|
||||||
if a.GetPortFlag() == 0 {
|
if a.GetPortFlag() == 0 {
|
||||||
return errs.Wrap(errors.New("port is required"))
|
return errs.New("port is required").Wrap()
|
||||||
}
|
}
|
||||||
return startrpc.Start(a.ctx, a.GetPortFlag(), name, a.GetPrometheusPortFlag(), a.config, rpcFn)
|
return startrpc.Start(a.ctx, a.GetPortFlag(), name, a.GetPrometheusPortFlag(), a.config, rpcFn)
|
||||||
}
|
}
|
||||||
@ -156,5 +154,5 @@ func (a *RpcCmd) GetRpcRegisterNameFromConfig() (string, error) {
|
|||||||
case RpcUserServer:
|
case RpcUserServer:
|
||||||
return a.config.RpcRegisterName.OpenImUserName, nil
|
return a.config.RpcRegisterName.OpenImUserName, nil
|
||||||
}
|
}
|
||||||
return "", errs.WrapMsg(errors.New("unrecognized RPC server name"), "providedName", a.Name, "hint", "Check if the server name is correctly configured")
|
return "", errs.New("unrecognized RPC server name", "rpcName", a.Name).Wrap()
|
||||||
}
|
}
|
||||||
|
|||||||
26
pkg/common/db/cache/conversation.go
vendored
26
pkg/common/db/cache/conversation.go
vendored
@ -233,7 +233,7 @@ func (c *ConversationRedisCache) DelConversations(ownerUserID string, conversati
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// return 0, errors.New("not found key:" + key + " in keys")
|
// return 0, errs.New("not found key:" + key + " in keys")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func (c *ConversationRedisCache) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationtb.ConversationModel, error) {
|
func (c *ConversationRedisCache) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationtb.ConversationModel, error) {
|
||||||
@ -338,30 +338,6 @@ func (c *ConversationRedisCache) DelSuperGroupRecvMsgNotNotifyUserIDsHash(groupI
|
|||||||
return cache
|
return cache
|
||||||
}
|
}
|
||||||
|
|
||||||
/* func (c *ConversationRedisCache) getUserAllHasReadSeqsIndex(conversationID string, conversationIDs []string) (int, error) {
|
|
||||||
for _i, _conversationID := range conversationIDs {
|
|
||||||
if _conversationID == conversationID {
|
|
||||||
return _i, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0, errors.New("not found key:" + conversationID + " in keys")
|
|
||||||
} */
|
|
||||||
|
|
||||||
/* func (c *ConversationRedisCache) GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error) {
|
|
||||||
conversationIDs, err := c.GetUserConversationIDs(ctx, ownerUserID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var keys []string
|
|
||||||
for _, conversarionID := range conversationIDs {
|
|
||||||
keys = append(keys, c.getConversationHasReadSeqKey(ownerUserID, conversarionID))
|
|
||||||
}
|
|
||||||
return batchGetCacheMap(ctx, c.rcClient, keys, conversationIDs, c.expireTime, c.getUserAllHasReadSeqsIndex, func(ctx context.Context) (map[string]int64, error) {
|
|
||||||
return c.conversationDB.GetUserAllHasReadSeqs(ctx, ownerUserID)
|
|
||||||
})
|
|
||||||
} */
|
|
||||||
|
|
||||||
func (c *ConversationRedisCache) DelUserAllHasReadSeqs(ownerUserID string, conversationIDs ...string) ConversationCache {
|
func (c *ConversationRedisCache) DelUserAllHasReadSeqs(ownerUserID string, conversationIDs ...string) ConversationCache {
|
||||||
cache := c.NewCache()
|
cache := c.NewCache()
|
||||||
for _, conversationID := range conversationIDs {
|
for _, conversationID := range conversationIDs {
|
||||||
|
|||||||
3
pkg/common/db/cache/meta_cache.go
vendored
3
pkg/common/db/cache/meta_cache.go
vendored
@ -17,7 +17,6 @@ package cache
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ const (
|
|||||||
retryInterval = time.Millisecond * 100
|
retryInterval = time.Millisecond * 100
|
||||||
)
|
)
|
||||||
|
|
||||||
var errIndex = errors.New("err index")
|
var errIndex = errs.New("err index")
|
||||||
|
|
||||||
type metaCache interface {
|
type metaCache interface {
|
||||||
ExecDel(ctx context.Context, distinct ...bool) error
|
ExecDel(ctx context.Context, distinct ...bool) error
|
||||||
|
|||||||
@ -17,7 +17,6 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@ -363,10 +362,10 @@ func (db *commonMsgDatabase) BatchInsertChat2Cache(ctx context.Context, conversa
|
|||||||
}
|
}
|
||||||
lenList := len(msgs)
|
lenList := len(msgs)
|
||||||
if int64(lenList) > db.msg.GetSingleGocMsgNum() {
|
if int64(lenList) > db.msg.GetSingleGocMsgNum() {
|
||||||
return 0, false, errs.WrapMsg(errors.New("message count exceeds limit"), "limit", db.msg.GetSingleGocMsgNum())
|
return 0, false, errs.New("message count exceeds limit", "limit", db.msg.GetSingleGocMsgNum()).Wrap()
|
||||||
}
|
}
|
||||||
if lenList < 1 {
|
if lenList < 1 {
|
||||||
return 0, false, errs.WrapMsg(errors.New("no messages to insert"), "minCount", 1)
|
return 0, false, errs.New("no messages to insert", "minCount", 1).Wrap()
|
||||||
}
|
}
|
||||||
if errs.Unwrap(err) == redis.Nil {
|
if errs.Unwrap(err) == redis.Nil {
|
||||||
isNew = true
|
isNew = true
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package relation
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ const (
|
|||||||
NewestList = -1
|
NewestList = -1
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrMsgListNotExist = errors.New("user not have msg in mongoDB")
|
var ErrMsgListNotExist = errs.New("user not have msg in mongoDB")
|
||||||
|
|
||||||
type MsgDocModel struct {
|
type MsgDocModel struct {
|
||||||
DocID string `bson:"doc_id"`
|
DocID string `bson:"doc_id"`
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package direct
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@ -108,7 +107,7 @@ func (cd *ConnDirect) GetConns(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(connections) == 0 {
|
if len(connections) == 0 {
|
||||||
return nil, errs.WrapMsg(errors.New("no connections found for service"), "serviceName", serviceName)
|
return nil, errs.New("no connections found for service", "serviceName", serviceName).Wrap()
|
||||||
}
|
}
|
||||||
return connections, nil
|
return connections, nil
|
||||||
}
|
}
|
||||||
@ -119,7 +118,7 @@ func (cd *ConnDirect) GetConn(ctx context.Context, serviceName string, opts ...g
|
|||||||
&cd.config.RpcPort, cd.config.LongConnSvr.OpenImMessageGatewayPort)
|
&cd.config.RpcPort, cd.config.LongConnSvr.OpenImMessageGatewayPort)
|
||||||
address, ok := addresses[serviceName]
|
address, ok := addresses[serviceName]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errs.WrapMsg(errors.New("unknown service name"), "serviceName", serviceName)
|
return nil, errs.New("unknown service name", "serviceName", serviceName).Wrap()
|
||||||
}
|
}
|
||||||
var result string
|
var result string
|
||||||
for _, addr := range address {
|
for _, addr := range address {
|
||||||
|
|||||||
@ -15,7 +15,6 @@
|
|||||||
package discoveryregister
|
package discoveryregister
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@ -41,7 +40,6 @@ func NewDiscoveryRegister(config *config.GlobalConfig) (discovery.SvcDiscoveryRe
|
|||||||
case "direct":
|
case "direct":
|
||||||
return direct.NewConnDirect(config)
|
return direct.NewConnDirect(config)
|
||||||
default:
|
default:
|
||||||
errMsg := "unsupported discovery type"
|
return nil, errs.New("unsupported discovery type", "type", config.Envs.Discovery).Wrap()
|
||||||
return nil, errs.WrapMsg(errors.New(errMsg), errMsg, "type", config.Envs.Discovery)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,12 +92,7 @@ func TestName(t *testing.T) {
|
|||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
//t.Log(key)
|
//t.Log(key)
|
||||||
fn(key, 10000, func() (string, error) {
|
fn(key, 10000, func() (string, error) {
|
||||||
//time.Sleep(time.Second * 3)
|
|
||||||
//t.Log(time.Now(), "key", key, "fetch")
|
|
||||||
//if rand.Uint32()%5 == 0 {
|
|
||||||
// return "value_" + key, nil
|
|
||||||
//}
|
|
||||||
//return "", errors.New("rand error")
|
|
||||||
return "value_" + key, nil
|
return "value_" + key, nil
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -39,7 +38,7 @@ type Api struct {
|
|||||||
func (a *Api) apiPost(ctx context.Context, path string, req any, resp any) error {
|
func (a *Api) apiPost(ctx context.Context, path string, req any, resp any) error {
|
||||||
operationID, _ := ctx.Value("operationID").(string)
|
operationID, _ := ctx.Value("operationID").(string)
|
||||||
if operationID == "" {
|
if operationID == "" {
|
||||||
return errors.New("call api operationID is empty")
|
return errs.New("call api operationID is empty")
|
||||||
}
|
}
|
||||||
reqBody, err := json.Marshal(req)
|
reqBody, err := json.Marshal(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user