mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-10 14:54:41 +08:00
fix: fix lint erros in pkg/common/config,convert
This commit is contained in:
parent
e941e9118c
commit
5d798c73ce
@ -336,6 +336,7 @@ func (c *configStruct) RegisterConf2Registry(registry discoveryregistry.SvcDisco
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return registry.RegisterConf2Registry(ConfKey, data)
|
return registry.RegisterConf2Registry(ConfKey, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,5 +349,6 @@ func (c *configStruct) EncodeConfig() []byte {
|
|||||||
if err := yaml.NewEncoder(buf).Encode(c); err != nil {
|
if err := yaml.NewEncoder(buf).Encode(c); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,8 +21,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed version
|
//go:embed version
|
||||||
@ -34,7 +35,7 @@ const (
|
|||||||
DefaultFolderPath = "../config/"
|
DefaultFolderPath = "../config/"
|
||||||
)
|
)
|
||||||
|
|
||||||
// getProjectRoot returns the absolute path of the project root directory
|
// getProjectRoot returns the absolute path of the project root directory.
|
||||||
func GetProjectRoot() string {
|
func GetProjectRoot() string {
|
||||||
b, _ := filepath.Abs(os.Args[0])
|
b, _ := filepath.Abs(os.Args[0])
|
||||||
|
|
||||||
@ -56,6 +57,7 @@ func GetOptionsByNotification(cfg NotificationConf) msgprocessor.Options {
|
|||||||
opts = msgprocessor.WithOptions(opts, msgprocessor.WithHistory(true), msgprocessor.WithPersistent())
|
opts = msgprocessor.WithOptions(opts, msgprocessor.WithHistory(true), msgprocessor.WithPersistent())
|
||||||
}
|
}
|
||||||
opts = msgprocessor.WithOptions(opts, msgprocessor.WithSendMsg(cfg.IsSendMsg))
|
opts = msgprocessor.WithOptions(opts, msgprocessor.WithSendMsg(cfg.IsSendMsg))
|
||||||
|
|
||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +78,7 @@ func initConfig(config interface{}, configName, configFolderPath string) error {
|
|||||||
return fmt.Errorf("unmarshal yaml error: %w", err)
|
return fmt.Errorf("unmarshal yaml error: %w", err)
|
||||||
}
|
}
|
||||||
fmt.Println("use config", configFolderPath)
|
fmt.Println("use config", configFolderPath)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +95,6 @@ func InitConfig(configFolderPath string) error {
|
|||||||
if err := initConfig(&Config, FileName, configFolderPath); err != nil {
|
if err := initConfig(&Config, FileName, configFolderPath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return initConfig(&Config.Notification, NotificationFileName, configFolderPath)
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
"github.com/OpenIMSDK/protocol/sdkws"
|
||||||
sdk "github.com/OpenIMSDK/protocol/sdkws"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
||||||
)
|
)
|
||||||
@ -27,11 +26,11 @@ func BlackDB2Pb(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
blackDBs []*relation.BlackModel,
|
blackDBs []*relation.BlackModel,
|
||||||
f func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error),
|
f func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error),
|
||||||
) (blackPbs []*sdk.BlackInfo, err error) {
|
) (blackPbs []*sdkws.BlackInfo, err error) {
|
||||||
if len(blackDBs) == 0 {
|
if len(blackDBs) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
var userIDs []string
|
userIDs := make([]string, 0, len(blackDBs))
|
||||||
for _, blackDB := range blackDBs {
|
for _, blackDB := range blackDBs {
|
||||||
userIDs = append(userIDs, blackDB.BlockUserID)
|
userIDs = append(userIDs, blackDB.BlockUserID)
|
||||||
}
|
}
|
||||||
@ -40,7 +39,7 @@ func BlackDB2Pb(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, blackDB := range blackDBs {
|
for _, blackDB := range blackDBs {
|
||||||
blackPb := &sdk.BlackInfo{
|
blackPb := &sdkws.BlackInfo{
|
||||||
OwnerUserID: blackDB.OwnerUserID,
|
OwnerUserID: blackDB.OwnerUserID,
|
||||||
CreateTime: blackDB.CreateTime.Unix(),
|
CreateTime: blackDB.CreateTime.Unix(),
|
||||||
AddSource: blackDB.AddSource,
|
AddSource: blackDB.AddSource,
|
||||||
@ -55,5 +54,6 @@ func BlackDB2Pb(
|
|||||||
}
|
}
|
||||||
blackPbs = append(blackPbs, blackPb)
|
blackPbs = append(blackPbs, blackPb)
|
||||||
}
|
}
|
||||||
|
|
||||||
return blackPbs, nil
|
return blackPbs, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ func ConversationDB2Pb(conversationDB *relation.ConversationModel) *conversation
|
|||||||
if err := utils.CopyStructFields(conversationPB, conversationDB); err != nil {
|
if err := utils.CopyStructFields(conversationPB, conversationDB); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return conversationPB
|
return conversationPB
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ func ConversationsDB2Pb(conversationsDB []*relation.ConversationModel) (conversa
|
|||||||
conversationPB.LatestMsgDestructTime = conversationDB.LatestMsgDestructTime.Unix()
|
conversationPB.LatestMsgDestructTime = conversationDB.LatestMsgDestructTime.Unix()
|
||||||
conversationsPB = append(conversationsPB, conversationPB)
|
conversationsPB = append(conversationsPB, conversationPB)
|
||||||
}
|
}
|
||||||
|
|
||||||
return conversationsPB
|
return conversationsPB
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +49,7 @@ func ConversationPb2DB(conversationPB *conversation.Conversation) *relation.Conv
|
|||||||
if err := utils.CopyStructFields(conversationDB, conversationPB); err != nil {
|
if err := utils.CopyStructFields(conversationDB, conversationPB); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return conversationDB
|
return conversationDB
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,5 +61,6 @@ func ConversationsPb2DB(conversationsPB []*conversation.Conversation) (conversat
|
|||||||
}
|
}
|
||||||
conversationsDB = append(conversationsDB, conversationDB)
|
conversationsDB = append(conversationsDB, conversationDB)
|
||||||
}
|
}
|
||||||
|
|
||||||
return conversationsDB
|
return conversationsDB
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ package convert
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
"github.com/OpenIMSDK/protocol/sdkws"
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
@ -25,9 +26,13 @@ import (
|
|||||||
|
|
||||||
func FriendPb2DB(friend *sdkws.FriendInfo) *relation.FriendModel {
|
func FriendPb2DB(friend *sdkws.FriendInfo) *relation.FriendModel {
|
||||||
dbFriend := &relation.FriendModel{}
|
dbFriend := &relation.FriendModel{}
|
||||||
utils.CopyStructFields(dbFriend, friend)
|
err := utils.CopyStructFields(dbFriend, friend)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
dbFriend.FriendUserID = friend.FriendUser.UserID
|
dbFriend.FriendUserID = friend.FriendUser.UserID
|
||||||
dbFriend.CreateTime = utils.UnixSecondToTime(friend.CreateTime)
|
dbFriend.CreateTime = utils.UnixSecondToTime(friend.CreateTime)
|
||||||
|
|
||||||
return dbFriend
|
return dbFriend
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +42,10 @@ func FriendDB2Pb(
|
|||||||
getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error),
|
getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error),
|
||||||
) (*sdkws.FriendInfo, error) {
|
) (*sdkws.FriendInfo, error) {
|
||||||
pbfriend := &sdkws.FriendInfo{FriendUser: &sdkws.UserInfo{}}
|
pbfriend := &sdkws.FriendInfo{FriendUser: &sdkws.UserInfo{}}
|
||||||
utils.CopyStructFields(pbfriend, friendDB)
|
err := utils.CopyStructFields(pbfriend, friendDB)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
users, err := getUsers(ctx, []string{friendDB.FriendUserID})
|
users, err := getUsers(ctx, []string{friendDB.FriendUserID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -47,6 +55,7 @@ func FriendDB2Pb(
|
|||||||
pbfriend.FriendUser.FaceURL = users[friendDB.FriendUserID].FaceURL
|
pbfriend.FriendUser.FaceURL = users[friendDB.FriendUserID].FaceURL
|
||||||
pbfriend.FriendUser.Ex = users[friendDB.FriendUserID].Ex
|
pbfriend.FriendUser.Ex = users[friendDB.FriendUserID].Ex
|
||||||
pbfriend.CreateTime = friendDB.CreateTime.Unix()
|
pbfriend.CreateTime = friendDB.CreateTime.Unix()
|
||||||
|
|
||||||
return pbfriend, nil
|
return pbfriend, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +67,7 @@ func FriendsDB2Pb(
|
|||||||
if len(friendsDB) == 0 {
|
if len(friendsDB) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
var userID []string
|
userID := make([]string, 0, len(friendsDB))
|
||||||
for _, friendDB := range friendsDB {
|
for _, friendDB := range friendsDB {
|
||||||
userID = append(userID, friendDB.FriendUserID)
|
userID = append(userID, friendDB.FriendUserID)
|
||||||
}
|
}
|
||||||
@ -68,7 +77,8 @@ func FriendsDB2Pb(
|
|||||||
}
|
}
|
||||||
for _, friend := range friendsDB {
|
for _, friend := range friendsDB {
|
||||||
friendPb := &sdkws.FriendInfo{FriendUser: &sdkws.UserInfo{}}
|
friendPb := &sdkws.FriendInfo{FriendUser: &sdkws.UserInfo{}}
|
||||||
utils.CopyStructFields(friendPb, friend)
|
err2 := utils.CopyStructFields(friendPb, friend)
|
||||||
|
err = fmt.Errorf("%w, %w", err, err2)
|
||||||
friendPb.FriendUser.UserID = users[friend.FriendUserID].UserID
|
friendPb.FriendUser.UserID = users[friend.FriendUserID].UserID
|
||||||
friendPb.FriendUser.Nickname = users[friend.FriendUserID].Nickname
|
friendPb.FriendUser.Nickname = users[friend.FriendUserID].Nickname
|
||||||
friendPb.FriendUser.FaceURL = users[friend.FriendUserID].FaceURL
|
friendPb.FriendUser.FaceURL = users[friend.FriendUserID].FaceURL
|
||||||
@ -76,7 +86,8 @@ func FriendsDB2Pb(
|
|||||||
friendPb.CreateTime = friend.CreateTime.Unix()
|
friendPb.CreateTime = friend.CreateTime.Unix()
|
||||||
friendsPb = append(friendsPb, friendPb)
|
friendsPb = append(friendsPb, friendPb)
|
||||||
}
|
}
|
||||||
return friendsPb, nil
|
|
||||||
|
return friendsPb, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func FriendRequestDB2Pb(
|
func FriendRequestDB2Pb(
|
||||||
@ -116,5 +127,6 @@ func FriendRequestDB2Pb(
|
|||||||
Ex: friendRequest.Ex,
|
Ex: friendRequest.Ex,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,7 @@ func MsgPb2DB(msg *sdkws.MsgData) *unrelation.MsgDataModel {
|
|||||||
msgDataModel.AtUserIDList = msg.AtUserIDList
|
msgDataModel.AtUserIDList = msg.AtUserIDList
|
||||||
msgDataModel.AttachedInfo = msg.AttachedInfo
|
msgDataModel.AttachedInfo = msg.AttachedInfo
|
||||||
msgDataModel.Ex = msg.Ex
|
msgDataModel.Ex = msg.Ex
|
||||||
|
|
||||||
return &msgDataModel
|
return &msgDataModel
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,5 +96,6 @@ func MsgDB2Pb(msgModel *unrelation.MsgDataModel) *sdkws.MsgData {
|
|||||||
msg.AtUserIDList = msgModel.AtUserIDList
|
msg.AtUserIDList = msgModel.AtUserIDList
|
||||||
msg.AttachedInfo = msgModel.AttachedInfo
|
msg.AttachedInfo = msgModel.AttachedInfo
|
||||||
msg.Ex = msgModel.Ex
|
msg.Ex = msgModel.Ex
|
||||||
|
|
||||||
return &msg
|
return &msg
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,7 @@ func UsersDB2Pb(users []*relationtb.UserModel) (result []*sdkws.UserInfo) {
|
|||||||
userPb.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
|
userPb.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
|
||||||
result = append(result, &userPb)
|
result = append(result, &userPb)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,5 +47,6 @@ func UserPb2DB(user *sdkws.UserInfo) *relationtb.UserModel {
|
|||||||
userDB.CreateTime = time.UnixMilli(user.CreateTime)
|
userDB.CreateTime = time.UnixMilli(user.CreateTime)
|
||||||
userDB.AppMangerLevel = user.AppMangerLevel
|
userDB.AppMangerLevel = user.AppMangerLevel
|
||||||
userDB.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
|
userDB.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
|
||||||
|
|
||||||
return &userDB
|
return &userDB
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user