mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
style: format openim server code style
This commit is contained in:
parent
99b938d9b6
commit
2c2b4c7c4a
@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
// RunWsAndServer run ws server.
|
// RunWsAndServer run ws server.
|
||||||
func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
|
func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
|
||||||
fmt.Println("start rpc/msg_gateway server, port: ", rpcPort, wsPort, prometheusPort, ", OpenIM version: ",config.Version)
|
fmt.Println("start rpc/msg_gateway server, port: ", rpcPort, wsPort, prometheusPort, ", OpenIM version: ", config.Version)
|
||||||
longServer, err := NewWsServer(
|
longServer, err := NewWsServer(
|
||||||
WithPort(wsPort),
|
WithPort(wsPort),
|
||||||
WithMaxConnNum(int64(config.Config.LongConnSvr.WebsocketMaxConnNum)),
|
WithMaxConnNum(int64(config.Config.LongConnSvr.WebsocketMaxConnNum)),
|
||||||
|
|||||||
@ -59,7 +59,7 @@ func callbackOfflinePush(ctx context.Context, userIDs []string, msg *sdkws.MsgDa
|
|||||||
if err := http.CallBackPostReturn(ctx, url(), req, resp, config.Config.Callback.CallbackOfflinePush); err != nil {
|
if err := http.CallBackPostReturn(ctx, url(), req, resp, config.Config.Callback.CallbackOfflinePush); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(resp.UserIDs) != 0 {
|
if len(resp.UserIDs) != 0 {
|
||||||
*offlinePushUserIDs = resp.UserIDs
|
*offlinePushUserIDs = resp.UserIDs
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/msggateway"
|
"github.com/openimsdk/open-im-server/v3/internal/msggateway"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
@ -52,7 +51,7 @@ func (m *MsgGatewayCmd) addRunE() {
|
|||||||
m.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
m.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
wsPort, err := m.getWsPortFlag(cmd)
|
wsPort, err := m.getWsPortFlag(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to get WS port flag")
|
return errs.Wrap(err, "failed to get WS port flag")
|
||||||
}
|
}
|
||||||
port, err := m.getPortFlag(cmd)
|
port, err := m.getPortFlag(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -62,6 +61,6 @@ func (m *MsgGatewayCmd) addRunE() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return msggateway.RunWsAndServer(port, wsPort, prometheusPort)
|
return msggateway.RunWsAndServer(port, wsPort, prometheusPort)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,12 +18,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@ -137,27 +137,27 @@ func (r *RootCmd) getPortFlag(cmd *cobra.Command) (int, error) {
|
|||||||
port, err := cmd.Flags().GetInt(constant.FlagPort)
|
port, err := cmd.Flags().GetInt(constant.FlagPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Wrapping the error with additional context
|
// Wrapping the error with additional context
|
||||||
return 0, errors.Wrap(err, "error getting port flag")
|
return 0, errs.Wrap(err, "error getting port flag")
|
||||||
}
|
}
|
||||||
if port == 0 {
|
if port == 0 {
|
||||||
port, _ = r.PortFromConfig(constant.FlagPort)
|
port, _ = r.PortFromConfig(constant.FlagPort)
|
||||||
// port, err := r.PortFromConfig(constant.FlagPort)
|
// port, err := r.PortFromConfig(constant.FlagPort)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// // Optionally wrap the error if it's an internal error needing context
|
// // Optionally wrap the error if it's an internal error needing context
|
||||||
// return 0, errors.Wrap(err, "error getting port from config")
|
// return 0, errs.Wrap(err, "error getting port from config")
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
return port, nil
|
return port, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPortFlag returns the port flag
|
// // GetPortFlag returns the port flag
|
||||||
func (r *RootCmd) GetPortFlag() (int, error) {
|
// func (r *RootCmd) GetPortFlag() (int, error) {
|
||||||
|
|
||||||
if portFlag == 0 {
|
// if portFlag == 0 {
|
||||||
return errs.Wrap(errors.New("port is 0"), "error getting port flag")
|
// return errs.Wrap(errs.New("port is 0"), "error getting port flag")
|
||||||
}
|
// }
|
||||||
return r.port, nil
|
// return r.port, nil
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (r *RootCmd) AddPrometheusPortFlag() {
|
func (r *RootCmd) AddPrometheusPortFlag() {
|
||||||
r.Command.Flags().IntP(constant.FlagPrometheusPort, "", 0, "server prometheus listen port")
|
r.Command.Flags().IntP(constant.FlagPrometheusPort, "", 0, "server prometheus listen port")
|
||||||
|
|||||||
@ -15,7 +15,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
@ -66,13 +65,7 @@ func (a *RpcCmd) StartSvr(name string, rpcFn func(discov discoveryregistry.SvcDi
|
|||||||
a.port = portFlag
|
a.port = portFlag
|
||||||
}
|
}
|
||||||
|
|
||||||
portFlag, err = a.GetPortFlag()
|
return startrpc.Start(portFlag, name, a.GetPrometheusPortFlag(), rpcFn)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return startrpc.Start(a.GetPortFlag(), name, a.GetPrometheusPortFlag(), rpcFn)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *RpcCmd) GetPortFromConfig(portType string) (int, error) {
|
func (a *RpcCmd) GetPortFromConfig(portType string) (int, error) {
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
||||||
@ -88,18 +89,17 @@ func initConfig(config any, configName, configFolderPath string) error {
|
|||||||
_, err := os.Stat(configFolderPath)
|
_, err := os.Stat(configFolderPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
fmt.Println("stat config path error:", err.Error())
|
return errs.Wrap(err, "stat config path error")
|
||||||
return fmt.Errorf("stat config path error: %w", err)
|
|
||||||
}
|
}
|
||||||
configFolderPath = filepath.Join(GetProjectRoot(), "config", configName)
|
configFolderPath = filepath.Join(GetProjectRoot(), "config", configName)
|
||||||
fmt.Println("flag's path,enviment's path,default path all is not exist,using project path:", configFolderPath)
|
fmt.Println("flag's path,enviment's path,default path all is not exist,using project path:", configFolderPath)
|
||||||
}
|
}
|
||||||
data, err := os.ReadFile(configFolderPath)
|
data, err := os.ReadFile(configFolderPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("read file error: %w", err)
|
return errs.Wrap(err, "read file error")
|
||||||
}
|
}
|
||||||
if err = yaml.Unmarshal(data, config); err != nil {
|
if err = yaml.Unmarshal(data, config); err != nil {
|
||||||
return fmt.Errorf("unmarshal yaml error: %w", err)
|
return errs.Wrap(err, "unmarshal yaml error")
|
||||||
}
|
}
|
||||||
fmt.Println("The path of the configuration file to start the process:", configFolderPath)
|
fmt.Println("The path of the configuration file to start the process:", configFolderPath)
|
||||||
|
|
||||||
|
|||||||
@ -23,11 +23,7 @@ import (
|
|||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BlackDB2Pb(
|
func BlackDB2Pb(ctx context.Context, blackDBs []*relation.BlackModel, f func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error)) (blackPbs []*sdk.BlackInfo, err error) {
|
||||||
ctx context.Context,
|
|
||||||
blackDBs []*relation.BlackModel,
|
|
||||||
f func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error),
|
|
||||||
) (blackPbs []*sdk.BlackInfo, err error) {
|
|
||||||
if len(blackDBs) == 0 {
|
if len(blackDBs) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,11 +53,7 @@ func FriendDB2Pb(ctx context.Context, friendDB *relation.FriendModel,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func FriendsDB2Pb(
|
func FriendsDB2Pb(ctx context.Context, friendsDB []*relation.FriendModel, getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error)) (friendsPb []*sdkws.FriendInfo, err error) {
|
||||||
ctx context.Context,
|
|
||||||
friendsDB []*relation.FriendModel,
|
|
||||||
getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error),
|
|
||||||
) (friendsPb []*sdkws.FriendInfo, err error) {
|
|
||||||
if len(friendsDB) == 0 {
|
if len(friendsDB) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|||||||
14
pkg/common/db/cache/meta_cache.go
vendored
14
pkg/common/db/cache/meta_cache.go
vendored
@ -134,7 +134,7 @@ func getCache[T any](ctx context.Context, rcClient *rockscache.Client, key strin
|
|||||||
}
|
}
|
||||||
bs, err := json.Marshal(t)
|
bs, err := json.Marshal(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errs.Wrap(err)
|
return "", errs.Wrap(err, "marshal failed")
|
||||||
}
|
}
|
||||||
write = true
|
write = true
|
||||||
|
|
||||||
@ -152,8 +152,7 @@ func getCache[T any](ctx context.Context, rcClient *rockscache.Client, key strin
|
|||||||
err = json.Unmarshal([]byte(v), &t)
|
err = json.Unmarshal([]byte(v), &t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "cache json.Unmarshal failed", err, "key", key, "value", v, "expire", expire)
|
log.ZError(ctx, "cache json.Unmarshal failed", err, "key", key, "value", v, "expire", expire)
|
||||||
|
return t, errs.Wrap(err, "unmarshal failed")
|
||||||
return t, errs.Wrap(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return t, nil
|
return t, nil
|
||||||
@ -197,14 +196,7 @@ func getCache[T any](ctx context.Context, rcClient *rockscache.Client, key strin
|
|||||||
// return tArrays, nil
|
// return tArrays, nil
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func batchGetCache2[T any, K comparable](
|
func batchGetCache2[T any, K comparable](ctx context.Context, rcClient *rockscache.Client, expire time.Duration, keys []K, keyFn func(key K) string, fns func(ctx context.Context, key K) (T, error)) ([]T, error) {
|
||||||
ctx context.Context,
|
|
||||||
rcClient *rockscache.Client,
|
|
||||||
expire time.Duration,
|
|
||||||
keys []K,
|
|
||||||
keyFn func(key K) string,
|
|
||||||
fns func(ctx context.Context, key K) (T, error),
|
|
||||||
) ([]T, error) {
|
|
||||||
if len(keys) == 0 {
|
if len(keys) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|||||||
5
pkg/common/db/cache/msg.go
vendored
5
pkg/common/db/cache/msg.go
vendored
@ -30,6 +30,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
"github.com/OpenIMSDK/protocol/sdkws"
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
@ -433,7 +434,7 @@ func (c *msgCache) PipeSetMessageToCache(ctx context.Context, conversationID str
|
|||||||
for _, msg := range msgs {
|
for _, msg := range msgs {
|
||||||
s, err := msgprocessor.Pb2String(msg)
|
s, err := msgprocessor.Pb2String(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, errs.Wrap(err, "pb.marshal")
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
key := c.getMessageCacheKey(conversationID, msg.Seq)
|
key := c.getMessageCacheKey(conversationID, msg.Seq)
|
||||||
@ -442,7 +443,7 @@ func (c *msgCache) PipeSetMessageToCache(ctx context.Context, conversationID str
|
|||||||
|
|
||||||
results, err := pipe.Exec(ctx)
|
results, err := pipe.Exec(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, errs.Wrap(err, "pipe.set")
|
return 0, errs.Warp(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, res := range results {
|
for _, res := range results {
|
||||||
|
|||||||
6
pkg/common/db/cache/user.go
vendored
6
pkg/common/db/cache/user.go
vendored
@ -66,11 +66,7 @@ type UserCacheRedis struct {
|
|||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserCacheRedis(
|
func NewUserCacheRedis(rdb redis.UniversalClient, userDB relationtb.UserModelInterface, options rockscache.Options) UserCache {
|
||||||
rdb redis.UniversalClient,
|
|
||||||
userDB relationtb.UserModelInterface,
|
|
||||||
options rockscache.Options,
|
|
||||||
) UserCache {
|
|
||||||
rcClient := rockscache.NewClient(rdb, options)
|
rcClient := rockscache.NewClient(rdb, options)
|
||||||
|
|
||||||
return &UserCacheRedis{
|
return &UserCacheRedis{
|
||||||
|
|||||||
@ -27,14 +27,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type BlackDatabase interface {
|
type BlackDatabase interface {
|
||||||
// Create 增加黑名单
|
// Create add BlackList
|
||||||
Create(ctx context.Context, blacks []*relation.BlackModel) (err error)
|
Create(ctx context.Context, blacks []*relation.BlackModel) (err error)
|
||||||
// Delete 删除黑名单
|
// Delete delete BlackList
|
||||||
Delete(ctx context.Context, blacks []*relation.BlackModel) (err error)
|
Delete(ctx context.Context, blacks []*relation.BlackModel) (err error)
|
||||||
// FindOwnerBlacks 获取黑名单列表
|
// FindOwnerBlacks get BlackList list
|
||||||
FindOwnerBlacks(ctx context.Context, ownerUserID string, pagination pagination.Pagination) (total int64, blacks []*relation.BlackModel, err error)
|
FindOwnerBlacks(ctx context.Context, ownerUserID string, pagination pagination.Pagination) (total int64, blacks []*relation.BlackModel, err error)
|
||||||
FindBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*relation.BlackModel, err error)
|
FindBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*relation.BlackModel, err error)
|
||||||
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
|
// CheckIn Check whether user2 is in the black list of user1 (inUser1Blacks==true) Check whether user1 is in the black list of user2 (inUser2Blacks==true)
|
||||||
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
|
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ func NewBlackDatabase(black relation.BlackModelInterface, cache cache.BlackCache
|
|||||||
return &blackDatabase{black, cache}
|
return &blackDatabase{black, cache}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create 增加黑名单.
|
// Create Add Blacklist.
|
||||||
func (b *blackDatabase) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
func (b *blackDatabase) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||||
if err := b.black.Create(ctx, blacks); err != nil {
|
if err := b.black.Create(ctx, blacks); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -55,7 +55,7 @@ func (b *blackDatabase) Create(ctx context.Context, blacks []*relation.BlackMode
|
|||||||
return b.deleteBlackIDsCache(ctx, blacks)
|
return b.deleteBlackIDsCache(ctx, blacks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete 删除黑名单.
|
// Delete Delete Blacklist.
|
||||||
func (b *blackDatabase) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
func (b *blackDatabase) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||||
if err := b.black.Delete(ctx, blacks); err != nil {
|
if err := b.black.Delete(ctx, blacks); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -63,6 +63,7 @@ func (b *blackDatabase) Delete(ctx context.Context, blacks []*relation.BlackMode
|
|||||||
return b.deleteBlackIDsCache(ctx, blacks)
|
return b.deleteBlackIDsCache(ctx, blacks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindOwnerBlacks Get Blacklist List.
|
||||||
func (b *blackDatabase) deleteBlackIDsCache(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
func (b *blackDatabase) deleteBlackIDsCache(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||||
cache := b.cache.NewCache()
|
cache := b.cache.NewCache()
|
||||||
for _, black := range blacks {
|
for _, black := range blacks {
|
||||||
@ -71,16 +72,13 @@ func (b *blackDatabase) deleteBlackIDsCache(ctx context.Context, blacks []*relat
|
|||||||
return cache.ExecDel(ctx)
|
return cache.ExecDel(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindOwnerBlacks 获取黑名单列表.
|
// FindOwnerBlacks Get Blacklist List.
|
||||||
func (b *blackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pagination pagination.Pagination) (total int64, blacks []*relation.BlackModel, err error) {
|
func (b *blackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pagination pagination.Pagination) (total int64, blacks []*relation.BlackModel, err error) {
|
||||||
return b.black.FindOwnerBlacks(ctx, ownerUserID, pagination)
|
return b.black.FindOwnerBlacks(ctx, ownerUserID, pagination)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true).
|
// FindOwnerBlacks Get Blacklist List.
|
||||||
func (b *blackDatabase) CheckIn(
|
func (b *blackDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error) {
|
||||||
ctx context.Context,
|
|
||||||
userID1, userID2 string,
|
|
||||||
) (inUser1Blacks bool, inUser2Blacks bool, err error) {
|
|
||||||
userID1BlackIDs, err := b.cache.GetBlackIDs(ctx, userID1)
|
userID1BlackIDs, err := b.cache.GetBlackIDs(ctx, userID1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -93,10 +91,12 @@ func (b *blackDatabase) CheckIn(
|
|||||||
return utils.IsContain(userID2, userID1BlackIDs), utils.IsContain(userID1, userID2BlackIDs), nil
|
return utils.IsContain(userID2, userID1BlackIDs), utils.IsContain(userID1, userID2BlackIDs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindBlackIDs Get Blacklist List.
|
||||||
func (b *blackDatabase) FindBlackIDs(ctx context.Context, ownerUserID string) (blackIDs []string, err error) {
|
func (b *blackDatabase) FindBlackIDs(ctx context.Context, ownerUserID string) (blackIDs []string, err error) {
|
||||||
return b.cache.GetBlackIDs(ctx, ownerUserID)
|
return b.cache.GetBlackIDs(ctx, ownerUserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindBlackInfos Get Blacklist List.
|
||||||
func (b *blackDatabase) FindBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*relation.BlackModel, err error) {
|
func (b *blackDatabase) FindBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*relation.BlackModel, err error) {
|
||||||
return b.black.FindOwnerBlackInfos(ctx, ownerUserID, userIDs)
|
return b.black.FindOwnerBlackInfos(ctx, ownerUserID, userIDs)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
|
"github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
)
|
)
|
||||||
|
|||||||
1
pkg/common/tls/tls.go
Executable file → Normal file
1
pkg/common/tls/tls.go
Executable file → Normal file
@ -22,6 +22,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
"github.com/OpenIMSDK/protocol/sdkws"
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -188,7 +189,7 @@ func (s MsgBySeq) Swap(i, j int) {
|
|||||||
func Pb2String(pb proto.Message) (string, error) {
|
func Pb2String(pb proto.Message) (string, error) {
|
||||||
s, err := proto.Marshal(pb)
|
s, err := proto.Marshal(pb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", errs.Wrap(err)
|
||||||
}
|
}
|
||||||
return string(s), nil
|
return string(s), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import (
|
|||||||
pbconversation "github.com/OpenIMSDK/protocol/conversation"
|
pbconversation "github.com/OpenIMSDK/protocol/conversation"
|
||||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
package page
|
package page
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user