Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cicd: bump League Patch
Browse files Browse the repository at this point in the history
kubbot committed Mar 27, 2024
1 parent 0d3afa4 commit ddc3999
Showing 60 changed files with 198 additions and 113 deletions.
8 changes: 5 additions & 3 deletions cmd/api/admin-api/main.go
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ package main
import (
"context"
"fmt"
"github.com/OpenIMSDK/chat/pkg/util"
"math/rand"
"net"
"net/http"
@@ -27,6 +26,10 @@ import (
"syscall"
"time"

"github.com/OpenIMSDK/chat/pkg/util"

"github.com/OpenIMSDK/chat/pkg/util"

"github.com/OpenIMSDK/tools/errs"

"github.com/OpenIMSDK/chat/pkg/discovery_register"
@@ -79,7 +82,7 @@ func main() {
}
var zk discoveryregistry.SvcDiscoveryRegistry
zk, err = discovery_register.NewDiscoveryRegister(config.Config.Envs.Discovery)
//zk, err = openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
// zk, err = openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
// openKeeper.WithFreq(time.Hour), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username, config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))
if err != nil {
util.ExitWithError(err)
@@ -126,5 +129,4 @@ func main() {
close(netDone)
util.ExitWithError(netErr)
}

}
9 changes: 5 additions & 4 deletions cmd/api/chat-api/main.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ import (
"context"
"flag"
"fmt"
"github.com/OpenIMSDK/chat/pkg/util"
"net"
"net/http"
"os"
@@ -27,6 +26,10 @@ import (
"syscall"
"time"

"github.com/OpenIMSDK/chat/pkg/util"

"github.com/OpenIMSDK/chat/pkg/util"

"github.com/OpenIMSDK/tools/errs"

"github.com/OpenIMSDK/chat/pkg/discovery_register"
@@ -46,7 +49,6 @@ import (
)

func main() {

configFile, ginPort, showVersion, err := config.FlagParse()
if err != nil {
util.ExitWithError(err)
@@ -83,8 +85,7 @@ func main() {
zk, err = discovery_register.NewDiscoveryRegister(config.Config.Envs.Discovery)
/*zk, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
openKeeper.WithFreq(time.Hour), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))*/
if err != nil {
config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))*/if err != nil {
util.ExitWithError(err)
}
if err := zk.CreateRpcRootNodes([]string{config.Config.RpcRegisterName.OpenImAdminName, config.Config.RpcRegisterName.OpenImChatName}); err != nil {
5 changes: 4 additions & 1 deletion cmd/rpc/admin-rpc/main.go
Original file line number Diff line number Diff line change
@@ -17,10 +17,13 @@ package main
import (
"flag"
"fmt"
"github.com/OpenIMSDK/chat/pkg/util"
"math/rand"
"time"

"github.com/OpenIMSDK/chat/pkg/util"

"github.com/OpenIMSDK/chat/pkg/util"

"github.com/OpenIMSDK/chat/pkg/common/chatrpcstart"
"github.com/OpenIMSDK/chat/pkg/common/version"
"github.com/OpenIMSDK/tools/log"
5 changes: 4 additions & 1 deletion cmd/rpc/chat-rpc/main.go
Original file line number Diff line number Diff line change
@@ -16,10 +16,13 @@ package main

import (
"fmt"
"github.com/OpenIMSDK/chat/pkg/util"
"math/rand"
"time"

"github.com/OpenIMSDK/chat/pkg/util"

"github.com/OpenIMSDK/chat/pkg/util"

"github.com/OpenIMSDK/chat/pkg/common/chatrpcstart"
"github.com/OpenIMSDK/tools/log"

29 changes: 14 additions & 15 deletions example/callback/callback.go
Original file line number Diff line number Diff line change
@@ -7,6 +7,12 @@ import (
"encoding/hex"
"encoding/json"
"errors"
"io"
"net/http"
"reflect"
"strings"
"time"

"github.com/OpenIMSDK/chat/pkg/common/apistruct"
"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/OpenIMSDK/chat/pkg/proto/admin"
@@ -17,11 +23,6 @@ import (
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/utils"
"github.com/gin-gonic/gin"
"io"
"net/http"
"reflect"
"strings"
"time"
)

func CallbackExample(c *gin.Context) {
@@ -73,7 +74,7 @@ func CallbackExample(c *gin.Context) {
}
}

// struct to map
// struct to map.
func convertStructToMap(input interface{}) (map[string]interface{}, error) {
result := make(map[string]interface{})
inputType := reflect.TypeOf(input)
@@ -100,12 +101,11 @@ func convertStructToMap(input interface{}) (map[string]interface{}, error) {
}

func Post(ctx context.Context, url string, header map[string]string, data any, timeout int) (content []byte, err error) {
var (
// define http client.
client = &http.Client{
Timeout: 15 * time.Second, // max timeout is 15s
}
)

// define http client.
client := &http.Client{
Timeout: 15 * time.Second, // max timeout is 15s
}

if timeout > 0 {
var cancel func()
@@ -145,9 +145,8 @@ func Post(ctx context.Context, url string, header map[string]string, data any, t
return result, nil
}

// handlingCallbackAfterSendMsg Handling callbacks after sending a message
// handlingCallbackAfterSendMsg Handling callbacks after sending a message.
func handlingCallbackAfterSendMsg(c *gin.Context) (*apistruct.CallbackAfterSendSingleMsgReq, error) {

var req apistruct.CallbackAfterSendSingleMsgReq

if err := c.BindJSON(&req); err != nil {
@@ -200,7 +199,7 @@ func getAdminToken(c *gin.Context) (*apistruct.AdminLoginResp, error) {
return &apistruct.AdminLoginResp{AdminToken: adminOutput.Data.AdminToken, ImToken: adminOutput.Data.ImToken}, nil
}

// CheckRobotAccount Verify if the robot account exists
// CheckRobotAccount Verify if the robot account exists.
func getRobotAccountInfo(c *gin.Context, token, robotics string) (*common.UserPublicInfo, error) {
header := make(map[string]string)
header["token"] = token
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/OpenIMSDK/chat

go 1.21
toolchain go1.21.2

toolchain go1.21.2

require (
github.com/gin-gonic/gin v1.9.1
46 changes: 46 additions & 0 deletions go.sum

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions internal/api/admin.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM open source community. All rights reserved.

Check failure on line 1 in internal/api/admin.go

GitHub Actions / comment-language-detector

Lines [70 105 145 330 399]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -19,6 +19,12 @@
"crypto/md5"
"encoding/hex"
"fmt"
"net"
"net/http"
"strconv"
"strings"
"time"

"github.com/OpenIMSDK/chat/pkg/common/apicall"
"github.com/OpenIMSDK/chat/pkg/common/apistruct"
"github.com/OpenIMSDK/chat/pkg/common/config"
@@ -39,11 +45,6 @@
"github.com/OpenIMSDK/tools/utils"
"github.com/gin-gonic/gin"
"google.golang.org/grpc"
"net"
"net/http"
"strconv"
"strings"
"time"
)

func NewAdmin(chatConn, adminConn grpc.ClientConnInterface) *AdminApi {
@@ -160,7 +161,6 @@
}

apiresp.GinSuccess(c, nil)

}

func (o *AdminApi) DelAdminAccount(c *gin.Context) {
2 changes: 1 addition & 1 deletion internal/api/router.go
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ func NewAdminRoute(router gin.IRouter, discov discoveryregistry.SvcDiscoveryRegi
adminRouterGroup.POST("/add_user", mw.CheckAdmin, admin.AddUserAccount) // Add user account
adminRouterGroup.POST("/del_admin", mw.CheckAdmin, admin.DelAdminAccount) // Delete admin
adminRouterGroup.POST("/search", mw.CheckAdmin, admin.SearchAdminAccount) // Get admin list
//account.POST("/add_notification_account")
// account.POST("/add_notification_account")

importGroup := router.Group("/user/import")
importGroup.POST("/json", mw.CheckAdminOrNil, admin.ImportUserByJson)
10 changes: 6 additions & 4 deletions internal/rpc/admin/admin.go
Original file line number Diff line number Diff line change
@@ -17,14 +17,15 @@ package admin
import (
"context"
"fmt"
"math/rand"
"time"

"github.com/OpenIMSDK/chat/pkg/common/db/cache"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils"
"google.golang.org/grpc"
"math/rand"
"time"

"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/OpenIMSDK/chat/pkg/common/constant"
@@ -60,8 +61,9 @@ func Start(discov discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
return errs.Wrap(err, "CreateRpcRootNodes error")
}

admin.RegisterAdminServer(server, &adminServer{Database: adminDatabase,
Chat: chat.NewChatClient(discov),
admin.RegisterAdminServer(server, &adminServer{
Database: adminDatabase,
Chat: chat.NewChatClient(discov),
})
return nil
}
1 change: 0 additions & 1 deletion internal/rpc/chat/login.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM open source community. All rights reserved.

Check failure on line 1 in internal/rpc/chat/login.go

GitHub Actions / comment-language-detector

Lines [159]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -290,7 +290,6 @@
return nil, err
}
}

}
if req.User.UserID == "" {
for i := 0; i < 20; i++ {
1 change: 1 addition & 0 deletions internal/rpc/chat/password.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package chat

import (
"context"

"github.com/OpenIMSDK/tools/errs"

"github.com/OpenIMSDK/chat/pkg/common/constant"
3 changes: 2 additions & 1 deletion internal/rpc/chat/user.go
Original file line number Diff line number Diff line change
@@ -16,12 +16,13 @@ package chat

import (
"context"
"time"

"github.com/OpenIMSDK/chat/pkg/common/db/dbutil"
chat2 "github.com/OpenIMSDK/chat/pkg/common/db/table/chat"
"github.com/OpenIMSDK/chat/pkg/common/rtc"
constant2 "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/tools/mcontext"
"time"

"github.com/OpenIMSDK/chat/pkg/common/constant"
"github.com/OpenIMSDK/chat/pkg/common/mctx"
5 changes: 4 additions & 1 deletion pkg/common/apicall/caller.go
Original file line number Diff line number Diff line change
@@ -16,10 +16,13 @@ package apicall

import (
"context"
"github.com/OpenIMSDK/tools/log"
"sync"
"time"

"github.com/OpenIMSDK/tools/log"

"github.com/OpenIMSDK/tools/log"

"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/OpenIMSDK/protocol/auth"
"github.com/OpenIMSDK/protocol/constant"
2 changes: 1 addition & 1 deletion pkg/common/apistruct/chat.go
Original file line number Diff line number Diff line change
@@ -130,4 +130,4 @@ type SendMsg struct {

// OfflinePushInfo contains information for offline push notifications.
OfflinePushInfo *sdkws.OfflinePushInfo `json:"offlinePushInfo"`
}
}
5 changes: 4 additions & 1 deletion pkg/common/chatrpcstart/start.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ import (
"context"
"errors"
"fmt"
"github.com/OpenIMSDK/chat/pkg/util"
"net"
"os"
"os/signal"
@@ -27,6 +26,10 @@ import (
"syscall"
"time"

"github.com/OpenIMSDK/chat/pkg/util"

"github.com/OpenIMSDK/chat/pkg/util"

"github.com/OpenIMSDK/chat/pkg/common/config"
chatMw "github.com/OpenIMSDK/chat/pkg/common/mw"
"github.com/OpenIMSDK/chat/pkg/discovery_register"
9 changes: 5 additions & 4 deletions pkg/common/config/parse.go
Original file line number Diff line number Diff line change
@@ -19,14 +19,17 @@ import (
"errors"
"flag"
"fmt"
"github.com/OpenIMSDK/tools/errs"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"

"github.com/OpenIMSDK/tools/errs"

"github.com/OpenIMSDK/tools/errs"

Constant "github.com/OpenIMSDK/chat/pkg/common/constant"
"gopkg.in/yaml.v3"
)
@@ -154,7 +157,6 @@ func findConfigFile(paths []string) (string, error) {
}

func CreateCatalogPath(path string) []string {

path1 := filepath.Dir(path)
path1 = filepath.Dir(path1)
// the parent of binary file
@@ -169,7 +171,6 @@ func CreateCatalogPath(path string) []string {
pa3 := filepath.Join(path3, Constant.ConfigPath)

return []string{pa1, pa2, pa3}

}

func findConfigPath(configFile string) (string, error) {
@@ -184,7 +185,7 @@ func findConfigPath(configFile string) (string, error) {
}

// Second, check for OPENIMCONFIG environment variable
//envConfigPath := os.Getenv(Constant.OpenIMConfig)
// envConfigPath := os.Getenv(Constant.OpenIMConfig)
envConfigPath := os.Getenv(Constant.OpenIMConfig)
if envConfigPath != "" {
if _, err := findConfigFile([]string{envConfigPath}); err != nil {
2 changes: 1 addition & 1 deletion pkg/common/config/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.3.5
1.6.1
6 changes: 3 additions & 3 deletions pkg/common/constant/constant.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ package constant

import "github.com/OpenIMSDK/protocol/constant"

// config path
// config path.
const (
ConfigPath = "/config/config.yaml"

@@ -128,7 +128,7 @@ const (
NeedInvitationCodeRegister = 1 // Invitation code required
)

// mini-app
// mini-app.
const (
StatusOnShelf = 1 // OnShelf
StatusUnShelf = 2 // UnShelf
@@ -155,7 +155,7 @@ const (
InvitationCodeUnused = 2 // Unused
)

// Default discovery page
// Default discovery page.
const DefaultDiscoverPageURL = "https://doc.rentsoft.cn/#/"

// const OperationID = "operationID"
2 changes: 2 additions & 0 deletions pkg/common/db/database/admin.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package database

import (
"context"

"github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/mongo"

@@ -166,6 +167,7 @@ func (o *AdminDatabase) UpdateAdmin(ctx context.Context, userID string, update m
func (o *AdminDatabase) ChangePassword(ctx context.Context, userID string, newPassword string) error {
return o.admin.ChangePassword(ctx, userID, newPassword)
}

func (o *AdminDatabase) AddAdminAccount(ctx context.Context, admins []*table.Admin) error {
return o.admin.Create(ctx, admins)
}
5 changes: 4 additions & 1 deletion pkg/common/db/database/chat.go
Original file line number Diff line number Diff line change
@@ -16,10 +16,11 @@ package database

import (
"context"
"time"

"github.com/OpenIMSDK/chat/pkg/common/db/dbutil"
"github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/mongo"
"time"

constant2 "github.com/OpenIMSDK/chat/pkg/common/constant"
admin2 "github.com/OpenIMSDK/chat/pkg/common/db/model/admin"
@@ -245,9 +246,11 @@ func (o *ChatDatabase) GetAttributeByAccount(ctx context.Context, account string
func (o *ChatDatabase) GetAttributeByPhone(ctx context.Context, areaCode string, phoneNumber string) (*table.Attribute, error) {
return o.attribute.TakePhone(ctx, areaCode, phoneNumber)
}

func (o *ChatDatabase) GetAttributeByEmail(ctx context.Context, email string) (*table.Attribute, error) {
return o.attribute.TakeEmail(ctx, email)
}

func (o *ChatDatabase) LoginRecord(ctx context.Context, record *table.UserLoginRecord, verifyCodeID *string) error {
return o.tx.Transaction(ctx, func(ctx context.Context) error {
if err := o.userLoginRecord.Create(ctx, record); err != nil {
4 changes: 2 additions & 2 deletions pkg/common/db/model/admin/admin.go
Original file line number Diff line number Diff line change
@@ -18,13 +18,14 @@ import (
"context"
"crypto/md5"
"encoding/hex"
"time"

"github.com/OpenIMSDK/chat/pkg/common/constant"
"github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"time"

"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/OpenIMSDK/chat/pkg/common/db/table/admin"
@@ -72,7 +73,6 @@ func (o *Admin) Create(ctx context.Context, admins []*admin.Admin) error {

func (o *Admin) ChangePassword(ctx context.Context, userID string, newPassword string) error {
return mgoutil.UpdateOne(ctx, o.coll, bson.M{"user_id": userID}, bson.M{"$set": bson.M{"password": newPassword}}, false)

}

func (o *Admin) Delete(ctx context.Context, userIDs []string) error {
4 changes: 1 addition & 3 deletions pkg/common/db/model/admin/applet.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package admin

import (
"context"

"github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/bson"
@@ -67,7 +68,6 @@ func (o *Applet) Update(ctx context.Context, id string, data map[string]any) err

func (o *Applet) Take(ctx context.Context, id string) (*admin.Applet, error) {
return mgoutil.FindOne[*admin.Applet](ctx, o.coll, bson.M{"id": id})

}

func (o *Applet) Search(ctx context.Context, keyword string, pagination pagination.Pagination) (int64, []*admin.Applet, error) {
@@ -88,10 +88,8 @@ func (o *Applet) Search(ctx context.Context, keyword string, pagination paginati

func (o *Applet) FindOnShelf(ctx context.Context) ([]*admin.Applet, error) {
return mgoutil.Find[*admin.Applet](ctx, o.coll, bson.M{"status": constant.StatusOnShelf})

}

func (o *Applet) FindID(ctx context.Context, ids []string) ([]*admin.Applet, error) {
return mgoutil.Find[*admin.Applet](ctx, o.coll, bson.M{"id": bson.M{"$in": ids}})

}
2 changes: 1 addition & 1 deletion pkg/common/db/model/admin/client_config.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package admin

import (
"context"

"github.com/OpenIMSDK/tools/mgoutil"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
@@ -55,7 +56,6 @@ func (o *ClientConfig) Set(ctx context.Context, config map[string]string) error
if err != nil {
return err
}

}
return nil
}
1 change: 1 addition & 0 deletions pkg/common/db/model/admin/forbidden_account.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package admin

import (
"context"

"github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/bson"
2 changes: 1 addition & 1 deletion pkg/common/db/model/admin/invitation_register.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package admin

import (
"context"

"github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/bson"
@@ -95,5 +96,4 @@ func (o *InvitationRegister) Search(ctx context.Context, keyword string, state i
}
}
return mgoutil.FindPage[*admin.InvitationRegister](ctx, o.coll, filter, pagination)

}
3 changes: 1 addition & 2 deletions pkg/common/db/model/admin/ip_forbidden.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM open source community. All rights reserved.

Check failure on line 1 in pkg/common/db/model/admin/ip_forbidden.go

GitHub Actions / comment-language-detector

Lines [64]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@

import (
"context"

"github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/bson"
@@ -49,12 +50,10 @@

func (o *IPForbidden) Take(ctx context.Context, ip string) (*admin.IPForbidden, error) {
return mgoutil.FindOne[*admin.IPForbidden](ctx, o.coll, bson.M{"ip": ip})

}

func (o *IPForbidden) Find(ctx context.Context, ips []string) ([]*admin.IPForbidden, error) {
return mgoutil.Find[*admin.IPForbidden](ctx, o.coll, bson.M{"ip": bson.M{"$in": ips}})

}

func (o *IPForbidden) Search(ctx context.Context, keyword string, state int32, pagination pagination.Pagination) (int64, []*admin.IPForbidden, error) {
2 changes: 1 addition & 1 deletion pkg/common/db/model/admin/limit_user_login_ip.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package admin

import (
"context"

"github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/bson"
@@ -75,7 +76,6 @@ func (o *LimitUserLoginIP) Search(ctx context.Context, keyword string, paginatio
},
}
return mgoutil.FindPage[*admin.LimitUserLoginIP](ctx, o.coll, filter, pagination)

}

func (o *LimitUserLoginIP) limitUserLoginIPFilter(ips []*admin.LimitUserLoginIP) bson.M {
1 change: 1 addition & 0 deletions pkg/common/db/model/admin/register_add_friend.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package admin

import (
"context"

"github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/bson"
1 change: 1 addition & 0 deletions pkg/common/db/model/admin/register_add_group.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package admin

import (
"context"

"github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/bson"
3 changes: 2 additions & 1 deletion pkg/common/db/model/chat/account.go
Original file line number Diff line number Diff line change
@@ -16,12 +16,13 @@ package chat

import (
"context"
"time"

"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/mgoutil"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"time"

"github.com/OpenIMSDK/chat/pkg/common/db/table/chat"
)
1 change: 1 addition & 0 deletions pkg/common/db/model/chat/attribute.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package chat

import (
"context"

"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination"
3 changes: 2 additions & 1 deletion pkg/common/db/model/chat/log.go
Original file line number Diff line number Diff line change
@@ -16,13 +16,14 @@ package chat

import (
"context"
"time"

"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"time"

"github.com/OpenIMSDK/chat/pkg/common/db/table/chat"
)
3 changes: 2 additions & 1 deletion pkg/common/db/model/chat/register.go
Original file line number Diff line number Diff line change
@@ -16,11 +16,12 @@ package chat

import (
"context"
"time"

"github.com/OpenIMSDK/tools/mgoutil"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"time"

"github.com/OpenIMSDK/chat/pkg/common/db/table/chat"
"github.com/OpenIMSDK/tools/errs"
3 changes: 2 additions & 1 deletion pkg/common/db/model/chat/user_login_record.go
Original file line number Diff line number Diff line change
@@ -16,10 +16,11 @@ package chat

import (
"context"
"time"

"github.com/OpenIMSDK/tools/mgoutil"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"time"

"github.com/OpenIMSDK/chat/pkg/common/db/table/chat"
)
3 changes: 2 additions & 1 deletion pkg/common/db/model/chat/verify_code.go
Original file line number Diff line number Diff line change
@@ -16,12 +16,13 @@ package chat

import (
"context"
"time"

"github.com/OpenIMSDK/tools/mgoutil"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"time"

"github.com/OpenIMSDK/chat/pkg/common/db/table/chat"
"github.com/OpenIMSDK/tools/errs"
2 changes: 1 addition & 1 deletion pkg/common/db/table/admin/admin.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM open source community. All rights reserved.

Check failure on line 1 in pkg/common/db/table/admin/admin.go

GitHub Actions / comment-language-detector

Lines [23]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@

import (
"context"
"github.com/OpenIMSDK/tools/pagination"
"time"

)

// Admin 后台管理员.
2 changes: 1 addition & 1 deletion pkg/common/db/table/admin/applet.go
Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@ package admin

import (
"context"
"github.com/OpenIMSDK/tools/pagination"
"time"

)

type Applet struct {
2 changes: 1 addition & 1 deletion pkg/common/db/table/admin/forbidden_account.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM open source community. All rights reserved.

Check failure on line 1 in pkg/common/db/table/admin/forbidden_account.go

GitHub Actions / comment-language-detector

Lines [23]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@

import (
"context"
"github.com/OpenIMSDK/tools/pagination"
"time"

)

// ForbiddenAccount 封号表.
2 changes: 1 addition & 1 deletion pkg/common/db/table/admin/invitation_register.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM open source community. All rights reserved.

Check failure on line 1 in pkg/common/db/table/admin/invitation_register.go

GitHub Actions / comment-language-detector

Lines [23]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@

import (
"context"
"github.com/OpenIMSDK/tools/pagination"
"time"

)

// 邀请码被注册使用.
2 changes: 1 addition & 1 deletion pkg/common/db/table/admin/ip_forbidden.go
Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@ package admin

import (
"context"
"github.com/OpenIMSDK/tools/pagination"
"time"

)

// 禁止ip登录 注册.
2 changes: 1 addition & 1 deletion pkg/common/db/table/admin/limit_user_login_ip.go
Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@ package admin

import (
"context"
"github.com/OpenIMSDK/tools/pagination"
"time"

)

// 限制userID只能在某些ip登录.
2 changes: 1 addition & 1 deletion pkg/common/db/table/admin/register_add_friend.go
Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@ package admin

import (
"context"
"github.com/OpenIMSDK/tools/pagination"
"time"

)

// RegisterAddFriend 注册时默认好友.
2 changes: 1 addition & 1 deletion pkg/common/db/table/admin/register_add_group.go
Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@ package admin

import (
"context"
"github.com/OpenIMSDK/tools/pagination"
"time"

)

// RegisterAddGroup 注册时默认群组.
4 changes: 2 additions & 2 deletions pkg/common/db/table/chat/attribute.go
Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@ package chat

import (
"context"
"github.com/OpenIMSDK/tools/pagination"
"time"

)

// Attribute 用户属性表.
@@ -46,7 +46,7 @@ func (Attribute) TableName() string {
}

type AttributeInterface interface {
//NewTx(tx any) AttributeInterface
// NewTx(tx any) AttributeInterface
Create(ctx context.Context, attribute ...*Attribute) error
Update(ctx context.Context, userID string, data map[string]any) error
Find(ctx context.Context, userIds []string) ([]*Attribute, error)
2 changes: 1 addition & 1 deletion pkg/common/db/table/chat/log.go
Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@ package chat

import (
"context"
"github.com/OpenIMSDK/tools/pagination"
"time"

)

type Log struct {
2 changes: 1 addition & 1 deletion pkg/common/db/table/chat/register.go
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ func (Register) TableName() string {
}

type RegisterInterface interface {
//NewTx(tx any) RegisterInterface
// NewTx(tx any) RegisterInterface
Create(ctx context.Context, registers ...*Register) error
CountTotal(ctx context.Context, before *time.Time) (int64, error)
}
2 changes: 1 addition & 1 deletion pkg/common/db/table/chat/user_login_record.go
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ func (UserLoginRecord) TableName() string {
}

type UserLoginRecordInterface interface {
//NewTx(tx any) UserLoginRecordInterface
// NewTx(tx any) UserLoginRecordInterface
Create(ctx context.Context, records ...*UserLoginRecord) error
CountTotal(ctx context.Context, before *time.Time) (int64, error)
CountRangeEverydayTotal(ctx context.Context, start *time.Time, end *time.Time) (map[string]int64, int64, error)
7 changes: 4 additions & 3 deletions pkg/common/dbconn/mongo.go
Original file line number Diff line number Diff line change
@@ -3,14 +3,15 @@ package dbconn
import (
"context"
"fmt"
"os"
"strings"
"time"

"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/mw/specialerror"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"os"
"strings"
"time"
)

const (
2 changes: 1 addition & 1 deletion pkg/common/rtc/gene_token.go
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ func GetLiveKitToken(room string, identity string) (string, error) {

token, err := geneLiveKitToken(apiKey, apiSecret, room, identity)

//fmt.Printf("livekit token=%s\n", token)
// fmt.Printf("livekit token=%s\n", token)

return token, err
}
6 changes: 3 additions & 3 deletions pkg/common/version/base.go
Original file line number Diff line number Diff line change
@@ -29,7 +29,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
@@ -55,7 +55,7 @@ var (
// directory. See also https://git-scm.com/docs/gitattributes
gitVersion string = "latest"
gitCommit string = "" // sha1 from git, output of $(git rev-parse HEAD)
gitTreeState string = "" // state of git tree, either "clean" or "dirty"
gitTreeState string = "" // state of git tree, either "clean" or "dirty"

buildDate string = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
)
)
2 changes: 1 addition & 1 deletion pkg/common/version/types.go
Original file line number Diff line number Diff line change
@@ -31,4 +31,4 @@ type Info struct {
// String returns info as a human-friendly version string.
func (info Info) String() string {
return info.GitVersion
}
}
10 changes: 5 additions & 5 deletions pkg/common/version/version.go
Original file line number Diff line number Diff line change
@@ -36,17 +36,17 @@ func Get() Info {
}
}

// GetSingleVersion returns single version of sealer
// GetSingleVersion returns single version of sealer.
func GetSingleVersion() string {
return gitVersion
}

type Output struct {
OpenIMChatVersion Info `json:"OpenIMChatVersion,omitempty" yaml:"OpenIMChatVersion,omitempty"`
OpenIMServerVersion *OpenIMServerVersion `json:"OpenIMServerVersion,omitempty" yaml:"OpenIMServerVersion,omitempty"`
OpenIMChatVersion Info `json:"OpenIMChatVersion,omitempty" yaml:"OpenIMChatVersion,omitempty"`
OpenIMServerVersion *OpenIMServerVersion `json:"OpenIMServerVersion,omitempty" yaml:"OpenIMServerVersion,omitempty"`
}

type OpenIMServerVersion struct {
ServerVersion string `json:"serverVersion,omitempty" yaml:"serverVersion,omitempty"`
ClientVersion string `json:"clientVersion,omitempty" yaml:"clientVersion,omitempty"` //sdk core version
}
ClientVersion string `json:"clientVersion,omitempty" yaml:"clientVersion,omitempty"` //sdk core version
}
3 changes: 2 additions & 1 deletion pkg/common/xlsx/main.go
Original file line number Diff line number Diff line change
@@ -2,9 +2,10 @@ package xlsx

import (
"errors"
"github.com/xuri/excelize/v2"
"io"
"reflect"

"github.com/xuri/excelize/v2"
)

func ParseSheet(file *excelize.File, v interface{}) error {
17 changes: 9 additions & 8 deletions pkg/common/xlsx/utils.go
Original file line number Diff line number Diff line change
@@ -3,11 +3,12 @@ package xlsx
import (
"errors"
"fmt"
"github.com/xuri/excelize/v2"
"io"
"reflect"
"strconv"
"strings"

"github.com/xuri/excelize/v2"
)

func Open(r io.Reader) (*excelize.File, error) {
@@ -22,22 +23,22 @@ func Num2AZ(num int) string {
var (
str string
k int
temp []int //保存转化后每一位数据的值,然后通过索引的方式匹配A-Z
temp []int // 保存转化后每一位数据的值,然后通过索引的方式匹配A-Z
)
//用来匹配的字符A-Z
// 用来匹配的字符A-Z
slices := []string{"", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}

if num > 26 { //数据大于26需要进行拆分
if num > 26 { // 数据大于26需要进行拆分
for {
k = num % 26 //从个位开始拆分,如果求余为0,说明末尾为26,也就是Z,如果是转化为26进制数,则末尾是可以为0的,这里必须为A-Z中的一个
k = num % 26 // 从个位开始拆分,如果求余为0,说明末尾为26,也就是Z,如果是转化为26进制数,则末尾是可以为0的,这里必须为A-Z中的一个
if k == 0 {
temp = append(temp, 26)
k = 26
} else {
temp = append(temp, k)
}
num = (num - k) / 26 //减去num最后一位数的值,因为已经记录在temp中
if num <= 26 { //小于等于26直接进行匹配,不需要进行数据拆分
num = (num - k) / 26 // 减去num最后一位数的值,因为已经记录在temp中
if num <= 26 { // 小于等于26直接进行匹配,不需要进行数据拆分
temp = append(temp, num)
break
}
@@ -46,7 +47,7 @@ func Num2AZ(num int) string {
return slices[num]
}
for _, value := range temp {
str = slices[value] + str //因为数据切分后存储顺序是反的,所以str要放在后面
str = slices[value] + str // 因为数据切分后存储顺序是反的,所以str要放在后面
}
return str
}
7 changes: 5 additions & 2 deletions pkg/discovery_register/k8s_discovery_register.go
Original file line number Diff line number Diff line change
@@ -18,10 +18,13 @@ import (
"context"
"errors"
"fmt"
"github.com/OpenIMSDK/tools/errs"
"strings"
"time"

"github.com/OpenIMSDK/tools/errs"

"github.com/OpenIMSDK/tools/errs"

"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/OpenIMSDK/tools/discoveryregistry"
openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
@@ -61,7 +64,7 @@ type K8sDR struct {
}

func (cli *K8sDR) GetUserIdHashGatewayHost(ctx context.Context, userId string) (string, error) {
//TODO implement me
// TODO implement me
panic("implement me")
}

1 change: 1 addition & 0 deletions pkg/email/mail.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ package email
import (
"context"
"fmt"

"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/OpenIMSDK/tools/errs"
"gopkg.in/gomail.v2"
15 changes: 8 additions & 7 deletions tools/component/component.go
Original file line number Diff line number Diff line change
@@ -17,11 +17,14 @@ package main
import (
"flag"
"fmt"
"github.com/OpenIMSDK/tools/errs"
"os"
"strings"
"time"

"github.com/OpenIMSDK/tools/errs"

"github.com/OpenIMSDK/tools/errs"

"github.com/OpenIMSDK/chat/pkg/common/config"
component "github.com/OpenIMSDK/tools/component"
)
@@ -32,9 +35,7 @@ const (
MaxConnectTimes = 100
)

var (
cfgPath = flag.String("config_folder_path", defaultCfgPath, "Path to the configuration file")
)
var cfgPath = flag.String("config_folder_path", defaultCfgPath, "Path to the configuration file")

type checkFunc struct {
name string
@@ -91,7 +92,7 @@ func main() {
os.Exit(-1)
}

// checkZookeeper checks the Zookeeper connection
// checkZookeeper checks the Zookeeper connection.
func checkZookeeper() error {
zkStu := &component.Zookeeper{
Schema: config.Config.Zookeeper.Schema,
@@ -103,7 +104,7 @@ func checkZookeeper() error {
return err
}

// checkRedis checks the Redis connection
// checkRedis checks the Redis connection.
func checkRedis() error {
redisStu := &component.Redis{
Address: *config.Config.Redis.Address,
@@ -114,7 +115,7 @@ func checkRedis() error {
return err
}

// checkMongo checks the MongoDB connection without retries
// checkMongo checks the MongoDB connection without retries.
func checkMongo() error {
mongoStu := &component.Mongo{
URL: config.Config.Mongo.Uri,
9 changes: 5 additions & 4 deletions tools/mysql2mongo/internal/main.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@ import (
"context"
"errors"
"fmt"
"os"
"reflect"
"strconv"

"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/OpenIMSDK/chat/pkg/common/db/model/admin"
"github.com/OpenIMSDK/chat/pkg/common/db/model/chat"
@@ -16,9 +20,6 @@ import (
gormmysql "gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"os"
"reflect"
"strconv"
)

const (
@@ -65,7 +66,7 @@ func getColl(obj any) (_ *mongo.Collection, err error) {
return nil, errors.New("not found model collection")
}

// NewTask A mysql table B mongodb model C mongodb table
// NewTask A mysql table B mongodb model C mongodb table.
func NewTask[A interface{ TableName() string }, B any, C any](gormDB *gorm.DB, mongoDB *mongo.Database, mongoDBInit func(db *mongo.Database) (B, error), convert func(v A) C) error {
var zero A
tableName := zero.TableName()
1 change: 1 addition & 0 deletions tools/mysql2mongo/mysql2mongo.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"

"github.com/OpenIMSDK/chat/pkg/util"
"github.com/OpenIMSDK/chat/tools/mysql2mongo/internal"
)

0 comments on commit ddc3999

Please sign in to comment.