diff --git a/internal/api/msg.go b/internal/api/msg.go index 22182d985c..664ee505a6 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -27,6 +27,7 @@ import ( "github.com/gin-gonic/gin" "github.com/go-playground/validator/v10" "github.com/mitchellh/mapstructure" + "github.com/openimsdk/open-im-server/v3/pkg/authverify" "github.com/openimsdk/open-im-server/v3/pkg/common/config" diff --git a/internal/push/push_rpc_server.go b/internal/push/push_rpc_server.go index 9e66f8f739..188ddc0e15 100644 --- a/internal/push/push_rpc_server.go +++ b/internal/push/push_rpc_server.go @@ -16,9 +16,10 @@ package push import ( "context" - "github.com/OpenIMSDK/tools/utils" "sync" + "github.com/OpenIMSDK/tools/utils" + "google.golang.org/grpc" "github.com/OpenIMSDK/protocol/constant" diff --git a/internal/rpc/friend/callback.go b/internal/rpc/friend/callback.go index d541071f55..e5054d9a9d 100644 --- a/internal/rpc/friend/callback.go +++ b/internal/rpc/friend/callback.go @@ -16,8 +16,10 @@ package friend import ( "context" + pbfriend "github.com/OpenIMSDK/protocol/friend" "github.com/OpenIMSDK/tools/utils" + cbapi "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/http" diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 21422fae30..20c47ad8fa 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -16,6 +16,7 @@ package friend import ( "context" + "github.com/OpenIMSDK/tools/tx" "github.com/OpenIMSDK/protocol/sdkws" diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go index 1599cc7b41..4a89a16fb0 100644 --- a/internal/rpc/group/callback.go +++ b/internal/rpc/group/callback.go @@ -16,9 +16,10 @@ package group import ( "context" - "github.com/OpenIMSDK/tools/log" "time" + "github.com/OpenIMSDK/tools/log" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/group" "github.com/OpenIMSDK/protocol/wrapperspb" diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 5992ed0311..e8e4dad92c 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -17,13 +17,14 @@ package group import ( "context" "fmt" - "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" "math/big" "math/rand" "strconv" "strings" "time" + "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" + pbconversation "github.com/OpenIMSDK/protocol/conversation" "github.com/OpenIMSDK/protocol/wrapperspb" "github.com/OpenIMSDK/tools/tx" diff --git a/internal/rpc/msg/as_read.go b/internal/rpc/msg/as_read.go index 061498abb3..5324ccba8f 100644 --- a/internal/rpc/msg/as_read.go +++ b/internal/rpc/msg/as_read.go @@ -16,16 +16,18 @@ package msg import ( "context" + utils2 "github.com/OpenIMSDK/tools/utils" "github.com/redis/go-redis/v9" - cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" + + cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" ) func (m *msgServer) GetConversationsHasReadAndMaxSeq(ctx context.Context, req *msg.GetConversationsHasReadAndMaxSeqReq) (resp *msg.GetConversationsHasReadAndMaxSeqResp, err error) { @@ -173,7 +175,7 @@ func (m *msgServer) MarkConversationAsRead( m.conversationAndGetRecvID(conversation, req.UserID), seqs, hasReadSeq); err != nil { return nil, err } - + } else if conversation.ConversationType == constant.SuperGroupChatType || conversation.ConversationType == constant.NotificationChatType { if req.HasReadSeq > hasReadSeq { @@ -222,4 +224,4 @@ func (m *msgServer) sendMarkAsReadNotification( log.ZWarn(ctx, "send has read Receipt err", err) } return nil -} \ No newline at end of file +} diff --git a/internal/rpc/msg/callback.go b/internal/rpc/msg/callback.go index 4ce5a54438..0bd71d9f7d 100644 --- a/internal/rpc/msg/callback.go +++ b/internal/rpc/msg/callback.go @@ -16,6 +16,7 @@ package msg import ( "context" + "github.com/OpenIMSDK/protocol/sdkws" "google.golang.org/protobuf/proto" @@ -24,6 +25,7 @@ import ( "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/utils" + cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" "github.com/openimsdk/open-im-server/v3/pkg/common/config" diff --git a/internal/rpc/user/callback.go b/internal/rpc/user/callback.go index e87b4674ee..7d865af5f3 100644 --- a/internal/rpc/user/callback.go +++ b/internal/rpc/user/callback.go @@ -16,6 +16,7 @@ package user import ( "context" + pbuser "github.com/OpenIMSDK/protocol/user" "github.com/OpenIMSDK/tools/utils" diff --git a/pkg/apistruct/msg.go b/pkg/apistruct/msg.go index 61b4d832be..4b7bd1e6fd 100644 --- a/pkg/apistruct/msg.go +++ b/pkg/apistruct/msg.go @@ -16,11 +16,11 @@ package apistruct type PictureBaseInfo struct { UUID string `mapstructure:"uuid"` - Type string `mapstructure:"type" validate:"required"` + Type string `mapstructure:"type" validate:"required"` Size int64 `mapstructure:"size"` - Width int32 `mapstructure:"width" validate:"required"` + Width int32 `mapstructure:"width" validate:"required"` Height int32 `mapstructure:"height" validate:"required"` - Url string `mapstructure:"url" validate:"required"` + Url string `mapstructure:"url" validate:"required"` } type PictureElem struct { @@ -34,28 +34,28 @@ type SoundElem struct { SoundPath string `mapstructure:"soundPath"` SourceURL string `mapstructure:"sourceUrl" validate:"required"` DataSize int64 `mapstructure:"dataSize"` - Duration int64 `mapstructure:"duration" validate:"required,min=1"` + Duration int64 `mapstructure:"duration" validate:"required,min=1"` } type VideoElem struct { - VideoPath string `mapstructure:"videoPath" ` + VideoPath string `mapstructure:"videoPath"` VideoUUID string `mapstructure:"videoUUID"` - VideoURL string `mapstructure:"videoUrl" validate:"required"` - VideoType string `mapstructure:"videoType" validate:"required"` - VideoSize int64 `mapstructure:"videoSize" validate:"required"` - Duration int64 `mapstructure:"duration" validate:"required"` + VideoURL string `mapstructure:"videoUrl" validate:"required"` + VideoType string `mapstructure:"videoType" validate:"required"` + VideoSize int64 `mapstructure:"videoSize" validate:"required"` + Duration int64 `mapstructure:"duration" validate:"required"` SnapshotPath string `mapstructure:"snapshotPath"` SnapshotUUID string `mapstructure:"snapshotUUID"` SnapshotSize int64 `mapstructure:"snapshotSize"` - SnapshotURL string `mapstructure:"snapshotUrl" validate:"required"` - SnapshotWidth int32 `mapstructure:"snapshotWidth" validate:"required"` + SnapshotURL string `mapstructure:"snapshotUrl" validate:"required"` + SnapshotWidth int32 `mapstructure:"snapshotWidth" validate:"required"` SnapshotHeight int32 `mapstructure:"snapshotHeight" validate:"required"` } type FileElem struct { - FilePath string `mapstructure:"filePath" ` + FilePath string `mapstructure:"filePath"` UUID string `mapstructure:"uuid"` SourceURL string `mapstructure:"sourceUrl" validate:"required"` - FileName string `mapstructure:"fileName" validate:"required"` - FileSize int64 `mapstructure:"fileSize" validate:"required"` + FileName string `mapstructure:"fileName" validate:"required"` + FileSize int64 `mapstructure:"fileSize" validate:"required"` } type AtElem struct { Text string `mapstructure:"text"` @@ -63,9 +63,9 @@ type AtElem struct { IsAtSelf bool `mapstructure:"isAtSelf"` } type LocationElem struct { - Description string `mapstructure:"description" ` - Longitude float64 `mapstructure:"longitude" validate:"required"` - Latitude float64 `mapstructure:"latitude" validate:"required"` + Description string `mapstructure:"description"` + Longitude float64 `mapstructure:"longitude" validate:"required"` + Latitude float64 `mapstructure:"latitude" validate:"required"` } type CustomElem struct { Data string `mapstructure:"data" validate:"required"` @@ -87,7 +87,7 @@ type OANotificationElem struct { NotificationType int32 `mapstructure:"notificationType" json:"notificationType" validate:"required"` Text string `mapstructure:"text" json:"text" validate:"required"` Url string `mapstructure:"url" json:"url"` - MixType int32 `mapstructure:"mixType" json:"mixType" validate:"required"` + MixType int32 `mapstructure:"mixType" json:"mixType" validate:"required"` PictureElem *PictureElem `mapstructure:"pictureElem" json:"pictureElem"` SoundElem *SoundElem `mapstructure:"soundElem" json:"soundElem"` VideoElem *VideoElem `mapstructure:"videoElem" json:"videoElem"` diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 5fb8fe7e21..6da89fc8fe 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -16,6 +16,7 @@ package config import ( "bytes" + "github.com/OpenIMSDK/tools/discoveryregistry" "gopkg.in/yaml.v3" ) diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index 22e458e006..1410a5a4a9 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -35,7 +35,7 @@ const ( DefaultFolderPath = "../config/" ) -// return absolude path join ../config/, this is k8s container config path +// return absolude path join ../config/, this is k8s container config path. func GetDefaultConfigPath() string { b, err := filepath.Abs(os.Args[0]) if err != nil { @@ -45,7 +45,7 @@ func GetDefaultConfigPath() string { return filepath.Join(filepath.Dir(b), "../config/") } -// getProjectRoot returns the absolute path of the project root directory +// getProjectRoot returns the absolute path of the project root directory. func GetProjectRoot() string { b, _ := filepath.Abs(os.Args[0]) diff --git a/pkg/common/convert/user.go b/pkg/common/convert/user.go index 0c71aac22d..8d960546a4 100644 --- a/pkg/common/convert/user.go +++ b/pkg/common/convert/user.go @@ -15,9 +15,10 @@ package convert import ( - "github.com/OpenIMSDK/protocol/sdkws" "time" + "github.com/OpenIMSDK/protocol/sdkws" + relationtb "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation" ) diff --git a/pkg/common/db/cache/group.go b/pkg/common/db/cache/group.go index 603d8e534a..57fcf1a9b4 100644 --- a/pkg/common/db/cache/group.go +++ b/pkg/common/db/cache/group.go @@ -39,7 +39,7 @@ const ( groupMemberIDsKey = "GROUP_MEMBER_IDS:" groupMembersHashKey = "GROUP_MEMBERS_HASH2:" groupMemberInfoKey = "GROUP_MEMBER_INFO:" - //groupOwnerInfoKey = "GROUP_OWNER_INFO:" + //groupOwnerInfoKey = "GROUP_OWNER_INFO:". joinedGroupsKey = "JOIN_GROUPS_KEY:" groupMemberNumKey = "GROUP_MEMBER_NUM_CACHE:" groupRoleLevelMemberIDsKey = "GROUP_ROLE_LEVEL_MEMBER_IDS:" diff --git a/pkg/common/db/cache/init_redis.go b/pkg/common/db/cache/init_redis.go index 0feefc9edf..63d2f5707e 100644 --- a/pkg/common/db/cache/init_redis.go +++ b/pkg/common/db/cache/init_redis.go @@ -66,8 +66,8 @@ func NewRedis() (redis.UniversalClient, error) { Addr: config.Config.Redis.Address[0], Username: config.Config.Redis.Username, Password: config.Config.Redis.Password, - DB: 0, // use default DB - PoolSize: 100, // connection pool size + DB: 0, // use default DB + PoolSize: 100, // connection pool size MaxRetries: maxRetry, }) } @@ -95,4 +95,4 @@ func overrideConfigFromEnv() { if envPass := os.Getenv("REDIS_PASSWORD"); envPass != "" { config.Config.Redis.Password = envPass } -} \ No newline at end of file +} diff --git a/pkg/common/discoveryregister/kubernetes/kubernetes.go b/pkg/common/discoveryregister/kubernetes/kubernetes.go index ce558a4590..f87b8e0d75 100644 --- a/pkg/common/discoveryregister/kubernetes/kubernetes.go +++ b/pkg/common/discoveryregister/kubernetes/kubernetes.go @@ -77,7 +77,7 @@ func (cli *K8sDR) CloseConn(conn *grpc.ClientConn) { conn.Close() } -// do not use this method for call rpc +// do not use this method for call rpc. func (cli *K8sDR) GetClientLocalConns() map[string][]*grpc.ClientConn { fmt.Println("should not call this function!!!!!!!!!!!!!!!!!!!!!!!!!") diff --git a/pkg/common/discoveryregister/zookeeper/zookeeper.go b/pkg/common/discoveryregister/zookeeper/zookeeper.go index c7549fc582..0542065e43 100644 --- a/pkg/common/discoveryregister/zookeeper/zookeeper.go +++ b/pkg/common/discoveryregister/zookeeper/zookeeper.go @@ -8,6 +8,7 @@ import ( "github.com/OpenIMSDK/tools/discoveryregistry" openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper" "github.com/OpenIMSDK/tools/log" + "github.com/openimsdk/open-im-server/v3/pkg/common/config" ) diff --git a/pkg/common/kafka/producer.go b/pkg/common/kafka/producer.go index 8d4f06ed9e..238bc832d3 100644 --- a/pkg/common/kafka/producer.go +++ b/pkg/common/kafka/producer.go @@ -12,8 +12,9 @@ import ( "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/utils" - "github.com/openimsdk/open-im-server/v3/pkg/common/config" "google.golang.org/protobuf/proto" + + "github.com/openimsdk/open-im-server/v3/pkg/common/config" ) const ( diff --git a/pkg/common/prommetrics/gin_api.go b/pkg/common/prommetrics/gin_api.go index 7cd82dad2c..83591163d6 100644 --- a/pkg/common/prommetrics/gin_api.go +++ b/pkg/common/prommetrics/gin_api.go @@ -4,7 +4,7 @@ import ginProm "github.com/openimsdk/open-im-server/v3/pkg/common/ginprometheus" /* labels := prometheus.Labels{"label_one": "any", "label_two": "value"} -ApiCustomCnt.MetricCollector.(*prometheus.CounterVec).With(labels).Inc() +ApiCustomCnt.MetricCollector.(*prometheus.CounterVec).With(labels).Inc(). */ var ( ApiCustomCnt = &ginProm.Metric{ diff --git a/pkg/common/version/base.go b/pkg/common/version/base.go index ac214269f3..8b4f13ebda 100644 --- a/pkg/common/version/base.go +++ b/pkg/common/version/base.go @@ -15,7 +15,7 @@ package version // When releasing a new Kubernetes version, this file is updated by // build/mark_new_version.sh to reflect the new version, and then a // git annotated tag (using format vX.Y where X == Major version and Y -// == Minor version) is created to point to the commit that updates +// == Minor version) is created to point to the commit that updates. var ( // TODO: Deprecate gitMajor and gitMinor, use only gitVersion // instead. First step in deprecation, keep the fields but make diff --git a/pkg/common/version/version.go b/pkg/common/version/version.go index b8ccfaf81a..86368ce3e9 100644 --- a/pkg/common/version/version.go +++ b/pkg/common/version/version.go @@ -25,7 +25,7 @@ func Get() Info { } } -// GetClientVersion returns the git version of the OpenIM client repository +// GetClientVersion returns the git version of the OpenIM client repository. func GetClientVersion() (*OpenIMClientVersion, error) { clientVersion, err := getClientVersion() if err != nil { @@ -52,7 +52,7 @@ func getClientVersion() (string, error) { return ref.Hash().String(), nil } -// GetSingleVersion returns single version of sealer +// GetSingleVersion returns single version of sealer. func GetSingleVersion() string { return gitVersion } diff --git a/test/e2e/api/token/token.go b/test/e2e/api/token/token.go index 4c578e8f70..85c080e2f7 100644 --- a/test/e2e/api/token/token.go +++ b/test/e2e/api/token/token.go @@ -9,7 +9,7 @@ import ( "net/http" ) -// API endpoints and other constants +// API endpoints and other constants. const ( APIHost = "http://127.0.0.1:10002" UserTokenURL = APIHost + "/auth/user_token" @@ -18,27 +18,27 @@ const ( OperationID = "1646445464564" ) -// UserTokenRequest represents a request to get a user token +// UserTokenRequest represents a request to get a user token. type UserTokenRequest struct { Secret string `json:"secret"` PlatformID int `json:"platformID"` UserID string `json:"userID"` } -// UserTokenResponse represents a response containing a user token +// UserTokenResponse represents a response containing a user token. type UserTokenResponse struct { Token string `json:"token"` ErrCode int `json:"errCode"` } -// User represents user data for registration +// User represents user data for registration. type User struct { UserID string `json:"userID"` Nickname string `json:"nickname"` FaceURL string `json:"faceURL"` } -// UserRegisterRequest represents a request to register a user +// UserRegisterRequest represents a request to register a user. type UserRegisterRequest struct { Secret string `json:"secret"` Users []User `json:"users"` @@ -58,7 +58,7 @@ func main() { } } -// GetUserToken requests a user token from the API +// GetUserToken requests a user token from the API. func GetUserToken(userID string) (string, error) { reqBody := UserTokenRequest{ Secret: SecretKey, @@ -88,7 +88,7 @@ func GetUserToken(userID string) (string, error) { return tokenResp.Token, nil } -// RegisterUser registers a new user using the API +// RegisterUser registers a new user using the API. func RegisterUser(token, userID, nickname, faceURL string) error { user := User{ UserID: userID, diff --git a/test/e2e/api/user/curd.go b/test/e2e/api/user/curd.go index c0380b2359..d0b424e3cd 100644 --- a/test/e2e/api/user/curd.go +++ b/test/e2e/api/user/curd.go @@ -7,18 +7,18 @@ import ( "github.com/openimsdk/open-im-server/v3/test/e2e/framework/config" ) -// UserInfoRequest represents a request to get or update user information +// UserInfoRequest represents a request to get or update user information. type UserInfoRequest struct { UserIDs []string `json:"userIDs,omitempty"` UserInfo *gettoken.User `json:"userInfo,omitempty"` } -// GetUsersOnlineStatusRequest represents a request to get users' online status +// GetUsersOnlineStatusRequest represents a request to get users' online status. type GetUsersOnlineStatusRequest struct { UserIDs []string `json:"userIDs"` } -// GetUsersInfo retrieves detailed information for a list of user IDs +// GetUsersInfo retrieves detailed information for a list of user IDs. func GetUsersInfo(token string, userIDs []string) error { url := fmt.Sprintf("http://%s:%s/user/get_users_info", config.LoadConfig().APIHost, config.LoadConfig().APIPort) @@ -29,7 +29,7 @@ func GetUsersInfo(token string, userIDs []string) error { return sendPostRequestWithToken(url, token, requestBody) } -// UpdateUserInfo updates the information for a user +// UpdateUserInfo updates the information for a user. func UpdateUserInfo(token, userID, nickname, faceURL string) error { url := fmt.Sprintf("http://%s:%s/user/update_user_info", config.LoadConfig().APIHost, config.LoadConfig().APIPort) @@ -44,7 +44,7 @@ func UpdateUserInfo(token, userID, nickname, faceURL string) error { return sendPostRequestWithToken(url, token, requestBody) } -// GetUsersOnlineStatus retrieves the online status for a list of user IDs +// GetUsersOnlineStatus retrieves the online status for a list of user IDs. func GetUsersOnlineStatus(token string, userIDs []string) error { url := fmt.Sprintf("http://%s:%s/user/get_users_online_status", config.LoadConfig().APIHost, config.LoadConfig().APIPort) diff --git a/test/e2e/api/user/user.go b/test/e2e/api/user/user.go index 9facf76ac6..ce264ce489 100644 --- a/test/e2e/api/user/user.go +++ b/test/e2e/api/user/user.go @@ -11,29 +11,29 @@ import ( "github.com/openimsdk/open-im-server/v3/test/e2e/framework/config" ) -// ForceLogoutRequest represents a request to force a user logout +// ForceLogoutRequest represents a request to force a user logout. type ForceLogoutRequest struct { PlatformID int `json:"platformID"` UserID string `json:"userID"` } -// CheckUserAccountRequest represents a request to check a user account +// CheckUserAccountRequest represents a request to check a user account. type CheckUserAccountRequest struct { CheckUserIDs []string `json:"checkUserIDs"` } -// GetUsersRequest represents a request to get a list of users +// GetUsersRequest represents a request to get a list of users. type GetUsersRequest struct { Pagination Pagination `json:"pagination"` } -// Pagination specifies the page number and number of items per page +// Pagination specifies the page number and number of items per page. type Pagination struct { PageNumber int `json:"pageNumber"` ShowNumber int `json:"showNumber"` } -// ForceLogout forces a user to log out +// ForceLogout forces a user to log out. func ForceLogout(token, userID string, platformID int) error { url := fmt.Sprintf("http://%s:%s/auth/force_logout", config.LoadConfig().APIHost, config.LoadConfig().APIPort) @@ -45,7 +45,7 @@ func ForceLogout(token, userID string, platformID int) error { return sendPostRequestWithToken(url, token, requestBody) } -// CheckUserAccount checks if the user accounts exist +// CheckUserAccount checks if the user accounts exist. func CheckUserAccount(token string, userIDs []string) error { url := fmt.Sprintf("http://%s:%s/user/account_check", config.LoadConfig().APIHost, config.LoadConfig().APIPort) @@ -56,7 +56,7 @@ func CheckUserAccount(token string, userIDs []string) error { return sendPostRequestWithToken(url, token, requestBody) } -// GetUsers retrieves a list of users with pagination +// GetUsers retrieves a list of users with pagination. func GetUsers(token string, pageNumber, showNumber int) error { url := fmt.Sprintf("http://%s:%s/user/account_check", config.LoadConfig().APIHost, config.LoadConfig().APIPort) @@ -70,7 +70,7 @@ func GetUsers(token string, pageNumber, showNumber int) error { return sendPostRequestWithToken(url, token, requestBody) } -// sendPostRequestWithToken sends a POST request with a token in the header +// sendPostRequestWithToken sends a POST request with a token in the header. func sendPostRequestWithToken(url, token string, body any) error { reqBytes, err := json.Marshal(body) if err != nil { diff --git a/test/e2e/framework/helpers/chat/chat.go b/test/e2e/framework/helpers/chat/chat.go index 4fca28f2a3..a095c9163a 100644 --- a/test/e2e/framework/helpers/chat/chat.go +++ b/test/e2e/framework/helpers/chat/chat.go @@ -10,7 +10,7 @@ import ( ) var ( - // The default template version + // The default template version. defaultTemplateVersion = "v1.3.0" ) @@ -84,7 +84,7 @@ func main() { select {} } -// getLatestVersion fetches the latest version number from a given URL +// getLatestVersion fetches the latest version number from a given URL. func getLatestVersion(url string) (string, error) { resp, err := http.Get(url) if err != nil { @@ -102,7 +102,7 @@ func getLatestVersion(url string) (string, error) { return latestVersion, nil } -// downloadAndExtract downloads a file from a URL and extracts it to a destination directory +// downloadAndExtract downloads a file from a URL and extracts it to a destination directory. func downloadAndExtract(url, destDir string) error { resp, err := http.Get(url) if err != nil { @@ -141,7 +141,7 @@ func downloadAndExtract(url, destDir string) error { return cmd.Run() } -// startProcess starts a process and prints any errors encountered +// startProcess starts a process and prints any errors encountered. func startProcess(cmdPath string) { cmd := exec.Command(cmdPath) cmd.Stdout = os.Stdout diff --git a/tools/up35/pkg/convert.go b/tools/up35/pkg/convert.go index 91fdb474e0..80654d7ea0 100644 --- a/tools/up35/pkg/convert.go +++ b/tools/up35/pkg/convert.go @@ -1,11 +1,12 @@ package pkg import ( + "time" + mongoModel "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation" mysqlModel "github.com/openimsdk/open-im-server/v3/tools/data-conversion/openim/mysql/v3" mongoModelRtc "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" mysqlModelRtc "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mysql" - "time" ) type convert struct{} diff --git a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting.go b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting.go index e3bab7af93..cc5f833f5b 100644 --- a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting.go +++ b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting.go @@ -2,13 +2,15 @@ package mgo import ( "context" + "time" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" ) func NewMeeting(db *mongo.Database) (table.MeetingInterface, error) { diff --git a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_invitation.go b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_invitation.go index 5286ffa954..2a393d7aa1 100644 --- a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_invitation.go +++ b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_invitation.go @@ -2,14 +2,16 @@ package mgo import ( "context" + "time" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "github.com/OpenIMSDK/tools/utils" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" ) func NewMeetingInvitation(db *mongo.Database) (table.MeetingInvitationInterface, error) { @@ -55,7 +57,12 @@ func (x *meetingInvitation) CreateMeetingInvitationInfo(ctx context.Context, roo func (x *meetingInvitation) GetUserInvitedMeetingIDs(ctx context.Context, userID string) (meetingIDs []string, err error) { fiveDaysAgo := time.Now().AddDate(0, 0, -5) - return mgoutil.Find[string](ctx, x.coll, bson.M{"user_id": userID, "create_time": bson.M{"$gte": fiveDaysAgo}}, options.Find().SetSort(bson.M{"create_time": -1}).SetProjection(bson.M{"_id": 0, "room_id": 1})) + return mgoutil.Find[string]( + ctx, + x.coll, + bson.M{"user_id": userID, "create_time": bson.M{"$gte": fiveDaysAgo}}, + options.Find().SetSort(bson.M{"create_time": -1}).SetProjection(bson.M{"_id": 0, "room_id": 1}), + ) } func (x *meetingInvitation) Delete(ctx context.Context, roomIDs []string) error { diff --git a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_record.go b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_record.go index 90fc9cdca0..8d173292b0 100644 --- a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_record.go +++ b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_record.go @@ -2,10 +2,12 @@ package mgo import ( "context" + "github.com/OpenIMSDK/tools/mgoutil" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" ) func NewMeetingRecord(db *mongo.Database) (table.MeetingRecordInterface, error) { diff --git a/tools/up35/pkg/internal/rtc/mongo/mgo/signal.go b/tools/up35/pkg/internal/rtc/mongo/mgo/signal.go index 0c18790079..0fa4192909 100644 --- a/tools/up35/pkg/internal/rtc/mongo/mgo/signal.go +++ b/tools/up35/pkg/internal/rtc/mongo/mgo/signal.go @@ -2,13 +2,15 @@ package mgo import ( "context" + "time" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" ) func NewSignal(db *mongo.Database) (table.SignalInterface, error) { diff --git a/tools/up35/pkg/internal/rtc/mongo/mgo/signal_invitation.go b/tools/up35/pkg/internal/rtc/mongo/mgo/signal_invitation.go index 274f2f11f9..64f1cee9f2 100644 --- a/tools/up35/pkg/internal/rtc/mongo/mgo/signal_invitation.go +++ b/tools/up35/pkg/internal/rtc/mongo/mgo/signal_invitation.go @@ -2,14 +2,16 @@ package mgo import ( "context" + "time" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "github.com/OpenIMSDK/tools/utils" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" ) func NewSignalInvitation(db *mongo.Database) (table.SignalInvitationInterface, error) { diff --git a/tools/up35/pkg/internal/rtc/mongo/table/meeting.go b/tools/up35/pkg/internal/rtc/mongo/table/meeting.go index 3b341cfb19..79ec4e58f0 100644 --- a/tools/up35/pkg/internal/rtc/mongo/table/meeting.go +++ b/tools/up35/pkg/internal/rtc/mongo/table/meeting.go @@ -2,8 +2,9 @@ package table import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + + "github.com/OpenIMSDK/tools/pagination" ) type MeetingInfo struct { diff --git a/tools/up35/pkg/internal/rtc/mongo/table/signal.go b/tools/up35/pkg/internal/rtc/mongo/table/signal.go index 0cec050fff..8482957cd8 100644 --- a/tools/up35/pkg/internal/rtc/mongo/table/signal.go +++ b/tools/up35/pkg/internal/rtc/mongo/table/signal.go @@ -2,11 +2,12 @@ package table import ( "context" + "time" + "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/pagination" "github.com/redis/go-redis/v9" "go.mongodb.org/mongo-driver/mongo" - "time" ) type SignalModel struct { diff --git a/tools/up35/pkg/internal/rtc/mysql/signal.go b/tools/up35/pkg/internal/rtc/mysql/signal.go index 3a4d607d40..d5a75a0d0d 100644 --- a/tools/up35/pkg/internal/rtc/mysql/signal.go +++ b/tools/up35/pkg/internal/rtc/mysql/signal.go @@ -16,7 +16,7 @@ type SignalModel struct { SessionType int32 `gorm:"column:sesstion_type"` InitiateTime time.Time `gorm:"column:initiate_time"` EndTime time.Time `gorm:"column:end_time"` - FileURL string `gorm:"column:file_url" json:"-"` + FileURL string `gorm:"column:file_url" json:"-"` Title string `gorm:"column:title;size:128"` Desc string `gorm:"column:desc;size:1024"` diff --git a/tools/up35/pkg/pkg.go b/tools/up35/pkg/pkg.go index d834b84922..54accb98a1 100644 --- a/tools/up35/pkg/pkg.go +++ b/tools/up35/pkg/pkg.go @@ -4,12 +4,13 @@ import ( "context" "errors" "fmt" - "gopkg.in/yaml.v3" "log" "os" "reflect" "strconv" + "gopkg.in/yaml.v3" + "github.com/go-sql-driver/mysql" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" diff --git a/tools/up35/up35.go b/tools/up35/up35.go index 0ce56ee132..261e51b5b6 100644 --- a/tools/up35/up35.go +++ b/tools/up35/up35.go @@ -2,9 +2,10 @@ package main import ( "flag" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg" "log" "os" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg" ) func main() {