mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 01:25:58 +08:00
fix: fix all lint warning in pkg (#1263)
* fix:fix lint errors in internal * fix:fix lint error in interal/tools * fix: fix lint errros in pkg/statics * fix: fix lint erros in pkg/authverify,pkg/rpcclien * fix: fix lint erros in pkg/common/cmd * fix: fix lint erros in pkg/common/config,convert * fix: fix lint erros in pkg/common/db/cache * fix: fix lint errors in pkg/common/db/controller * fix:fix lint errors in pkg/common/db/relation and pkg/common/db/localcache * fix: fix rest lint errors in pkg/common/db * fix: fix rest lint errors in pkg * fix:set back go.work to use go 1.19
This commit is contained in:
@@ -18,7 +18,6 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
sdk "github.com/OpenIMSDK/protocol/sdkws"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
||||
)
|
||||
@@ -27,11 +26,11 @@ 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) {
|
||||
) (blackPbs []*sdkws.BlackInfo, err error) {
|
||||
if len(blackDBs) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
var userIDs []string
|
||||
userIDs := make([]string, 0, len(blackDBs))
|
||||
for _, blackDB := range blackDBs {
|
||||
userIDs = append(userIDs, blackDB.BlockUserID)
|
||||
}
|
||||
@@ -40,7 +39,7 @@ func BlackDB2Pb(
|
||||
return nil, err
|
||||
}
|
||||
for _, blackDB := range blackDBs {
|
||||
blackPb := &sdk.BlackInfo{
|
||||
blackPb := &sdkws.BlackInfo{
|
||||
OwnerUserID: blackDB.OwnerUserID,
|
||||
CreateTime: blackDB.CreateTime.Unix(),
|
||||
AddSource: blackDB.AddSource,
|
||||
@@ -55,5 +54,6 @@ func BlackDB2Pb(
|
||||
}
|
||||
blackPbs = append(blackPbs, blackPb)
|
||||
}
|
||||
|
||||
return blackPbs, nil
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ func ConversationDB2Pb(conversationDB *relation.ConversationModel) *conversation
|
||||
if err := utils.CopyStructFields(conversationPB, conversationDB); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return conversationPB
|
||||
}
|
||||
|
||||
@@ -39,6 +40,7 @@ func ConversationsDB2Pb(conversationsDB []*relation.ConversationModel) (conversa
|
||||
conversationPB.LatestMsgDestructTime = conversationDB.LatestMsgDestructTime.Unix()
|
||||
conversationsPB = append(conversationsPB, conversationPB)
|
||||
}
|
||||
|
||||
return conversationsPB
|
||||
}
|
||||
|
||||
@@ -47,6 +49,7 @@ func ConversationPb2DB(conversationPB *conversation.Conversation) *relation.Conv
|
||||
if err := utils.CopyStructFields(conversationDB, conversationPB); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return conversationDB
|
||||
}
|
||||
|
||||
@@ -58,5 +61,6 @@ func ConversationsPb2DB(conversationsPB []*conversation.Conversation) (conversat
|
||||
}
|
||||
conversationsDB = append(conversationsDB, conversationDB)
|
||||
}
|
||||
|
||||
return conversationsDB
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package convert
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
@@ -25,9 +26,13 @@ import (
|
||||
|
||||
func FriendPb2DB(friend *sdkws.FriendInfo) *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.CreateTime = utils.UnixSecondToTime(friend.CreateTime)
|
||||
|
||||
return dbFriend
|
||||
}
|
||||
|
||||
@@ -37,7 +42,10 @@ func FriendDB2Pb(
|
||||
getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error),
|
||||
) (*sdkws.FriendInfo, error) {
|
||||
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})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -47,6 +55,7 @@ func FriendDB2Pb(
|
||||
pbfriend.FriendUser.FaceURL = users[friendDB.FriendUserID].FaceURL
|
||||
pbfriend.FriendUser.Ex = users[friendDB.FriendUserID].Ex
|
||||
pbfriend.CreateTime = friendDB.CreateTime.Unix()
|
||||
|
||||
return pbfriend, nil
|
||||
}
|
||||
|
||||
@@ -58,7 +67,7 @@ func FriendsDB2Pb(
|
||||
if len(friendsDB) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
var userID []string
|
||||
userID := make([]string, 0, len(friendsDB))
|
||||
for _, friendDB := range friendsDB {
|
||||
userID = append(userID, friendDB.FriendUserID)
|
||||
}
|
||||
@@ -68,7 +77,8 @@ func FriendsDB2Pb(
|
||||
}
|
||||
for _, friend := range friendsDB {
|
||||
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.Nickname = users[friend.FriendUserID].Nickname
|
||||
friendPb.FriendUser.FaceURL = users[friend.FriendUserID].FaceURL
|
||||
@@ -76,7 +86,8 @@ func FriendsDB2Pb(
|
||||
friendPb.CreateTime = friend.CreateTime.Unix()
|
||||
friendsPb = append(friendsPb, friendPb)
|
||||
}
|
||||
return friendsPb, nil
|
||||
|
||||
return friendsPb, err
|
||||
}
|
||||
|
||||
func FriendRequestDB2Pb(
|
||||
@@ -116,5 +127,6 @@ func FriendRequestDB2Pb(
|
||||
Ex: friendRequest.Ex,
|
||||
})
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ func MsgPb2DB(msg *sdkws.MsgData) *unrelation.MsgDataModel {
|
||||
msgDataModel.AtUserIDList = msg.AtUserIDList
|
||||
msgDataModel.AttachedInfo = msg.AttachedInfo
|
||||
msgDataModel.Ex = msg.Ex
|
||||
|
||||
return &msgDataModel
|
||||
}
|
||||
|
||||
@@ -95,5 +96,6 @@ func MsgDB2Pb(msgModel *unrelation.MsgDataModel) *sdkws.MsgData {
|
||||
msg.AtUserIDList = msgModel.AtUserIDList
|
||||
msg.AttachedInfo = msgModel.AttachedInfo
|
||||
msg.Ex = msgModel.Ex
|
||||
|
||||
return &msg
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ func UsersDB2Pb(users []*relationtb.UserModel) (result []*sdkws.UserInfo) {
|
||||
userPb.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
|
||||
result = append(result, &userPb)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -46,5 +47,6 @@ func UserPb2DB(user *sdkws.UserInfo) *relationtb.UserModel {
|
||||
userDB.CreateTime = time.UnixMilli(user.CreateTime)
|
||||
userDB.AppMangerLevel = user.AppMangerLevel
|
||||
userDB.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
|
||||
|
||||
return &userDB
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user