Skip to content

Commit

Permalink
feat: add openim docker
Browse files Browse the repository at this point in the history
Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>
  • Loading branch information
cubxxw committed Dec 14, 2023
1 parent a42a44e commit ad47590
Show file tree
Hide file tree
Showing 36 changed files with 113 additions and 77 deletions.
1 change: 1 addition & 0 deletions internal/api/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 2 additions & 1 deletion internal/push/push_rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions internal/rpc/friend/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions internal/rpc/friend/friend.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package friend

import (
"context"

"github.com/OpenIMSDK/tools/tx"

"github.com/OpenIMSDK/protocol/sdkws"
Expand Down
3 changes: 2 additions & 1 deletion internal/rpc/group/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion internal/rpc/group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions internal/rpc/msg/as_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -222,4 +224,4 @@ func (m *msgServer) sendMarkAsReadNotification(
log.ZWarn(ctx, "send has read Receipt err", err)
}
return nil
}
}
2 changes: 2 additions & 0 deletions internal/rpc/msg/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package msg

import (
"context"

"github.com/OpenIMSDK/protocol/sdkws"
"google.golang.org/protobuf/proto"

Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions internal/rpc/user/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package user

import (
"context"

pbuser "github.com/OpenIMSDK/protocol/user"
"github.com/OpenIMSDK/tools/utils"

Expand Down
36 changes: 18 additions & 18 deletions pkg/apistruct/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -34,38 +34,38 @@ 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"`
AtUserList []string `mapstructure:"atUserList" validate:"required,max=1000"`
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"`
Expand All @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions pkg/common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package config

import (
"bytes"

"github.com/OpenIMSDK/tools/discoveryregistry"
"gopkg.in/yaml.v3"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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])

Expand Down
3 changes: 2 additions & 1 deletion pkg/common/convert/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/common/db/cache/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down
6 changes: 3 additions & 3 deletions pkg/common/db/cache/init_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
Expand Down Expand Up @@ -95,4 +95,4 @@ func overrideConfigFromEnv() {
if envPass := os.Getenv("REDIS_PASSWORD"); envPass != "" {
config.Config.Redis.Password = envPass
}
}
}
2 changes: 1 addition & 1 deletion pkg/common/discoveryregister/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!!!!!!!!!!!!!!!!!!!!!!!!!")

Expand Down
1 change: 1 addition & 0 deletions pkg/common/discoveryregister/zookeeper/zookeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/common/kafka/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/prommetrics/gin_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/version/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
14 changes: 7 additions & 7 deletions test/e2e/api/token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"`
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit ad47590

Please sign in to comment.