From 5ec628fccb9e4f13fc9fd73ab08968bf5652fc5e Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Mon, 3 Jul 2023 14:12:29 +0800
Subject: [PATCH 01/73] style: add import formatting
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.github/workflows/openim-ci.yml | 72 +++++++++++++++++++
go.mod | 1 +
go.sum | 2 +
internal/msggateway/callback.go | 3 +-
internal/msggateway/context.go | 5 +-
internal/msggateway/encoder.go | 1 +
internal/msggateway/hub_server.go | 1 +
internal/msggateway/long_conn.go | 3 +-
internal/msggateway/user_map.go | 3 +-
internal/push/offlinepush/fcm/push_test.go | 3 +-
internal/push/offlinepush/getui/push.go | 8 ++-
.../push/offlinepush/jpush/body/platform.go | 1 +
internal/push/offlinepush/jpush/push.go | 1 +
internal/rpc/group/fill.go | 1 +
internal/rpc/msg/msg_status.go | 1 +
internal/rpc/msg/revoke.go | 3 +-
internal/rpc/msg/send.go | 1 +
internal/rpc/third/s3.go | 3 +-
internal/rpc/user/statistics.go | 3 +-
internal/rpc/user/user.go | 3 +-
pkg/a2r/api2rpc.go | 1 +
pkg/apiresp/gin.go | 3 +-
pkg/apiresp/resp.go | 3 +-
pkg/common/config/parse.go | 7 +-
pkg/common/db/controller/msg.go | 3 +-
pkg/common/db/controller/storage.go | 11 +--
pkg/common/db/obj/minio.go | 9 +--
pkg/common/db/ormutil/utils.go | 3 +-
pkg/common/db/relation/group_model.go | 1 +
pkg/common/db/relation/group_request_model.go | 1 +
pkg/common/db/relation/mysql_init.go | 3 +-
pkg/common/db/relation/object_hash_model.go | 1 +
pkg/common/db/relation/object_info_model.go | 3 +-
pkg/common/db/relation/object_put_model.go | 3 +-
pkg/common/db/relation/user_model.go | 3 +-
pkg/common/db/tx/mongo.go | 1 +
pkg/common/db/unrelation/super_group.go | 1 +
pkg/common/kafka/consumer_group.go | 1 +
pkg/common/mw/rpc_server_interceptor.go | 3 +-
pkg/common/prome/prometheus.go | 3 +-
pkg/common/tokenverify/jwt_token.go | 3 +-
pkg/errs/coderr.go | 3 +-
pkg/proto/auth/auth.pb.go | 5 +-
pkg/proto/conversation/conversation.pb.go | 5 +-
pkg/proto/errinfo/errinfo.pb.go | 5 +-
pkg/proto/friend/friend.pb.go | 5 +-
pkg/proto/group/group.pb.go | 5 +-
pkg/proto/msg/msg.pb.go | 5 +-
pkg/proto/msggateway/msggateway.pb.go | 5 +-
pkg/proto/push/push.pb.go | 5 +-
pkg/proto/sdkws/sdkws.pb.go | 5 +-
pkg/proto/statistics/statistics.pb.go | 3 +-
pkg/proto/third/third.pb.go | 5 +-
pkg/proto/user/user.pb.go | 5 +-
pkg/proto/wrapperspb/wrapperspb.pb.go | 5 +-
pkg/statistics/statistics.go | 3 +-
pkg/utils/file.go | 3 +-
pkg/utils/platform_number_id_to_name_test.go | 3 +-
pkg/utils/time_format.go | 18 ++---
scripts/make-rules/golang.mk | 2 +-
test/mongo/cmd/main.go | 1 +
test/mongo/mongo_utils.go | 3 +-
62 files changed, 209 insertions(+), 76 deletions(-)
create mode 100644 .github/workflows/openim-ci.yml
diff --git a/.github/workflows/openim-ci.yml b/.github/workflows/openim-ci.yml
new file mode 100644
index 000000000..7ee0545f8
--- /dev/null
+++ b/.github/workflows/openim-ci.yml
@@ -0,0 +1,72 @@
+name: IamCI
+
+on:
+# main branch
+ push:
+ branches:
+ - main
+ pull_request:
+ branches:
+ - main
+
+jobs:
+
+ iamci:
+ name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }}
+ runs-on: ${{ matrix.os }}
+ environment:
+ name: iamci
+
+ strategy:
+ matrix:
+ go_version: [1.18, 1.19, 1.20]
+ os: [ubuntu-latest, macOS-latest]
+
+ steps:
+ - name: Set up Go ${{ matrix.go_version }}
+ uses: actions/setup-go@v2
+ with:
+ go-version: ${{ matrix.go_version }}
+ id: go
+
+ - name: Check out code into the Go module directory
+ uses: actions/checkout@v2
+
+ - name: Run go modules Tidy
+ run: |
+ make tidy
+
+ - name: Generate all necessary files, such as error code files
+ run: |
+ make gen
+
+ - name: Check syntax and styling of go sources
+ run: |
+ make lint
+
+ - name: Run unit test and get test coverage
+ run: |
+ make cover
+
+ - name: Build source code for host platform
+ run: |
+ make build
+
+ - name: Collect Test Coverage File
+ uses: actions/upload-artifact@v1.0.0
+ with:
+ name: main-output
+ path: _output/coverage.out
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
+
+ - name: Login to DockerHub
+ uses: docker/login-action@v1
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build docker images for host arch and push images to registry
+ run: |
+ make push
\ No newline at end of file
diff --git a/go.mod b/go.mod
index 0a8c1fd52..88d5abb09 100644
--- a/go.mod
+++ b/go.mod
@@ -43,6 +43,7 @@ require (
github.com/go-sql-driver/mysql v1.6.0
github.com/go-zookeeper/zk v1.0.3
github.com/redis/go-redis/v9 v9.0.5
+ gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
)
require (
diff --git a/go.sum b/go.sum
index 443d6cb9d..12f5d41bb 100644
--- a/go.sum
+++ b/go.sum
@@ -784,6 +784,8 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw=
+gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/internal/msggateway/callback.go b/internal/msggateway/callback.go
index 2d30b52b4..557e65ea6 100644
--- a/internal/msggateway/callback.go
+++ b/internal/msggateway/callback.go
@@ -2,12 +2,13 @@ package msggateway
import (
"context"
+ "time"
+
cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
- "time"
)
func url() string {
diff --git a/internal/msggateway/context.go b/internal/msggateway/context.go
index cd395e7e0..61f4d7970 100644
--- a/internal/msggateway/context.go
+++ b/internal/msggateway/context.go
@@ -1,11 +1,12 @@
package msggateway
import (
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"net/http"
"strconv"
"time"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
type UserConnContext struct {
diff --git a/internal/msggateway/encoder.go b/internal/msggateway/encoder.go
index 6a4104ff4..6915766c6 100644
--- a/internal/msggateway/encoder.go
+++ b/internal/msggateway/encoder.go
@@ -3,6 +3,7 @@ package msggateway
import (
"bytes"
"encoding/gob"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
diff --git a/internal/msggateway/hub_server.go b/internal/msggateway/hub_server.go
index 633b7c479..ab8f9af26 100644
--- a/internal/msggateway/hub_server.go
+++ b/internal/msggateway/hub_server.go
@@ -2,6 +2,7 @@ package msggateway
import (
"context"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
diff --git a/internal/msggateway/long_conn.go b/internal/msggateway/long_conn.go
index ed31dbda7..911e9a4a1 100644
--- a/internal/msggateway/long_conn.go
+++ b/internal/msggateway/long_conn.go
@@ -1,9 +1,10 @@
package msggateway
import (
- "github.com/gorilla/websocket"
"net/http"
"time"
+
+ "github.com/gorilla/websocket"
)
type LongConn interface {
diff --git a/internal/msggateway/user_map.go b/internal/msggateway/user_map.go
index 63881bc1a..46bdb16a4 100644
--- a/internal/msggateway/user_map.go
+++ b/internal/msggateway/user_map.go
@@ -2,9 +2,10 @@ package msggateway
import (
"context"
+ "sync"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "sync"
)
type UserMap struct {
diff --git a/internal/push/offlinepush/fcm/push_test.go b/internal/push/offlinepush/fcm/push_test.go
index 81b54cfbb..1a7240302 100644
--- a/internal/push/offlinepush/fcm/push_test.go
+++ b/internal/push/offlinepush/fcm/push_test.go
@@ -2,10 +2,11 @@ package fcm
import (
"context"
+ "testing"
+
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/stretchr/testify/assert"
- "testing"
)
func Test_Push(t *testing.T) {
diff --git a/internal/push/offlinepush/getui/push.go b/internal/push/offlinepush/getui/push.go
index db5accbd7..54bd83673 100644
--- a/internal/push/offlinepush/getui/push.go
+++ b/internal/push/offlinepush/getui/push.go
@@ -1,13 +1,17 @@
package getui
import (
- "github.com/go-redis/redis"
"sync"
+ "github.com/go-redis/redis"
+
"context"
"crypto/sha256"
"encoding/hex"
"errors"
+ "strconv"
+ "time"
+
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
@@ -16,8 +20,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils/splitter"
- "strconv"
- "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
diff --git a/internal/push/offlinepush/jpush/body/platform.go b/internal/push/offlinepush/jpush/body/platform.go
index 9aa28f82c..68264fea0 100644
--- a/internal/push/offlinepush/jpush/body/platform.go
+++ b/internal/push/offlinepush/jpush/body/platform.go
@@ -2,6 +2,7 @@ package body
import (
"errors"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
)
diff --git a/internal/push/offlinepush/jpush/push.go b/internal/push/offlinepush/jpush/push.go
index 6a4ea0ceb..75fc2b27b 100644
--- a/internal/push/offlinepush/jpush/push.go
+++ b/internal/push/offlinepush/jpush/push.go
@@ -4,6 +4,7 @@ import (
"context"
"encoding/base64"
"fmt"
+
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush/jpush/body"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
diff --git a/internal/rpc/group/fill.go b/internal/rpc/group/fill.go
index 4302e3bf0..da82e9b5e 100644
--- a/internal/rpc/group/fill.go
+++ b/internal/rpc/group/fill.go
@@ -2,6 +2,7 @@ package group
import (
"context"
+
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
diff --git a/internal/rpc/msg/msg_status.go b/internal/rpc/msg/msg_status.go
index 5639ecc01..3e1f9053b 100644
--- a/internal/rpc/msg/msg_status.go
+++ b/internal/rpc/msg/msg_status.go
@@ -2,6 +2,7 @@ package msg
import (
"context"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
diff --git a/internal/rpc/msg/revoke.go b/internal/rpc/msg/revoke.go
index 746017940..c32050bfe 100644
--- a/internal/rpc/msg/revoke.go
+++ b/internal/rpc/msg/revoke.go
@@ -3,9 +3,10 @@ package msg
import (
"context"
"encoding/json"
- "github.com/google/uuid"
"time"
+ "github.com/google/uuid"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
diff --git a/internal/rpc/msg/send.go b/internal/rpc/msg/send.go
index a7fc6533b..deaee0bed 100644
--- a/internal/rpc/msg/send.go
+++ b/internal/rpc/msg/send.go
@@ -2,6 +2,7 @@ package msg
import (
"context"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
diff --git a/internal/rpc/third/s3.go b/internal/rpc/third/s3.go
index 21471e00d..e0a3a99da 100644
--- a/internal/rpc/third/s3.go
+++ b/internal/rpc/third/s3.go
@@ -2,9 +2,10 @@ package third
import (
"context"
+ "time"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
- "time"
)
func (t *thirdServer) ApplyPut(ctx context.Context, req *third.ApplyPutReq) (*third.ApplyPutResp, error) {
diff --git a/internal/rpc/user/statistics.go b/internal/rpc/user/statistics.go
index 036b09687..12ec0d55f 100644
--- a/internal/rpc/user/statistics.go
+++ b/internal/rpc/user/statistics.go
@@ -2,9 +2,10 @@ package user
import (
"context"
+ "time"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
pbuser "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
- "time"
)
func (s *userServer) UserRegisterCount(ctx context.Context, req *pbuser.UserRegisterCountReq) (*pbuser.UserRegisterCountResp, error) {
diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go
index 3437754dc..277bf4284 100644
--- a/internal/rpc/user/user.go
+++ b/internal/rpc/user/user.go
@@ -2,10 +2,11 @@ package user
import (
"context"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"strings"
"time"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
diff --git a/pkg/a2r/api2rpc.go b/pkg/a2r/api2rpc.go
index 50d5b2ac3..39bd70ce4 100644
--- a/pkg/a2r/api2rpc.go
+++ b/pkg/a2r/api2rpc.go
@@ -2,6 +2,7 @@ package a2r
import (
"context"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/checker"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
diff --git a/pkg/apiresp/gin.go b/pkg/apiresp/gin.go
index e17f0144a..b2bfaf4f9 100644
--- a/pkg/apiresp/gin.go
+++ b/pkg/apiresp/gin.go
@@ -1,8 +1,9 @@
package apiresp
import (
- "github.com/gin-gonic/gin"
"net/http"
+
+ "github.com/gin-gonic/gin"
)
func GinError(c *gin.Context, err error) {
diff --git a/pkg/apiresp/resp.go b/pkg/apiresp/resp.go
index cd215a984..29dc33996 100644
--- a/pkg/apiresp/resp.go
+++ b/pkg/apiresp/resp.go
@@ -1,8 +1,9 @@
package apiresp
import (
- "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"reflect"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
)
type ApiResponse struct {
diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go
index 8ab68b68f..0a32e81c7 100644
--- a/pkg/common/config/parse.go
+++ b/pkg/common/config/parse.go
@@ -3,13 +3,14 @@ package config
import (
"bytes"
"fmt"
+ "os"
+ "path/filepath"
+ "runtime"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"gopkg.in/yaml.v3"
- "os"
- "path/filepath"
- "runtime"
)
var (
diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go
index e732f1f08..dd62e0e2e 100644
--- a/pkg/common/db/controller/msg.go
+++ b/pkg/common/db/controller/msg.go
@@ -2,9 +2,10 @@ package controller
import (
"fmt"
- "github.com/redis/go-redis/v9"
"time"
+ "github.com/redis/go-redis/v9"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
diff --git a/pkg/common/db/controller/storage.go b/pkg/common/db/controller/storage.go
index 5182bb199..6531c5127 100644
--- a/pkg/common/db/controller/storage.go
+++ b/pkg/common/db/controller/storage.go
@@ -9,6 +9,12 @@ import (
"encoding/json"
"errors"
"fmt"
+ "io"
+ "net/url"
+ "path"
+ "strconv"
+ "time"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/obj"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
@@ -16,11 +22,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"github.com/google/uuid"
- "io"
- "net/url"
- "path"
- "strconv"
- "time"
)
const (
diff --git a/pkg/common/db/obj/minio.go b/pkg/common/db/obj/minio.go
index 8e28896bd..488775f27 100644
--- a/pkg/common/db/obj/minio.go
+++ b/pkg/common/db/obj/minio.go
@@ -4,15 +4,16 @@ import (
"context"
"errors"
"fmt"
+ "io"
+ "net/http"
+ "net/url"
+ "time"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/minio/minio-go/v7/pkg/s3utils"
- "io"
- "net/http"
- "net/url"
- "time"
)
func NewMinioInterface() (Interface, error) {
diff --git a/pkg/common/db/ormutil/utils.go b/pkg/common/db/ormutil/utils.go
index 2a916cb39..9c4e19a5b 100644
--- a/pkg/common/db/ormutil/utils.go
+++ b/pkg/common/db/ormutil/utils.go
@@ -2,9 +2,10 @@ package ormutil
import (
"fmt"
+ "strings"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"gorm.io/gorm"
- "strings"
)
func GormPage[E any](db *gorm.DB, pageNumber, showNumber int32) (uint32, []*E, error) {
diff --git a/pkg/common/db/relation/group_model.go b/pkg/common/db/relation/group_model.go
index 39feb5d7a..dd9f59bea 100644
--- a/pkg/common/db/relation/group_model.go
+++ b/pkg/common/db/relation/group_model.go
@@ -2,6 +2,7 @@ package relation
import (
"context"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/ormutil"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
diff --git a/pkg/common/db/relation/group_request_model.go b/pkg/common/db/relation/group_request_model.go
index 679671e5d..407c2b136 100644
--- a/pkg/common/db/relation/group_request_model.go
+++ b/pkg/common/db/relation/group_request_model.go
@@ -2,6 +2,7 @@ package relation
import (
"context"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/ormutil"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
diff --git a/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go
index b63bada05..432af214f 100644
--- a/pkg/common/db/relation/mysql_init.go
+++ b/pkg/common/db/relation/mysql_init.go
@@ -2,13 +2,14 @@ package relation
import (
"fmt"
+ "time"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
mysqlDriver "github.com/go-sql-driver/mysql"
"gorm.io/driver/mysql"
- "time"
"gorm.io/gorm"
"gorm.io/gorm/logger"
diff --git a/pkg/common/db/relation/object_hash_model.go b/pkg/common/db/relation/object_hash_model.go
index e122d9cec..275d09a4e 100644
--- a/pkg/common/db/relation/object_hash_model.go
+++ b/pkg/common/db/relation/object_hash_model.go
@@ -2,6 +2,7 @@ package relation
import (
"context"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"gorm.io/gorm"
diff --git a/pkg/common/db/relation/object_info_model.go b/pkg/common/db/relation/object_info_model.go
index d2a751cff..f5b34755f 100644
--- a/pkg/common/db/relation/object_info_model.go
+++ b/pkg/common/db/relation/object_info_model.go
@@ -2,11 +2,12 @@ package relation
import (
"context"
+ "time"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"gorm.io/gorm"
- "time"
)
type ObjectInfoGorm struct {
diff --git a/pkg/common/db/relation/object_put_model.go b/pkg/common/db/relation/object_put_model.go
index 82f98624c..06a9883af 100644
--- a/pkg/common/db/relation/object_put_model.go
+++ b/pkg/common/db/relation/object_put_model.go
@@ -2,10 +2,11 @@ package relation
import (
"context"
+ "time"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"gorm.io/gorm"
- "time"
)
type ObjectPutGorm struct {
diff --git a/pkg/common/db/relation/user_model.go b/pkg/common/db/relation/user_model.go
index 3390f7d3b..481393ac0 100644
--- a/pkg/common/db/relation/user_model.go
+++ b/pkg/common/db/relation/user_model.go
@@ -2,9 +2,10 @@ package relation
import (
"context"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"time"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"gorm.io/gorm"
diff --git a/pkg/common/db/tx/mongo.go b/pkg/common/db/tx/mongo.go
index f0afaa237..c8c4817ac 100644
--- a/pkg/common/db/tx/mongo.go
+++ b/pkg/common/db/tx/mongo.go
@@ -2,6 +2,7 @@ package tx
import (
"context"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"go.mongodb.org/mongo-driver/mongo"
)
diff --git a/pkg/common/db/unrelation/super_group.go b/pkg/common/db/unrelation/super_group.go
index 23c226974..54de697e4 100644
--- a/pkg/common/db/unrelation/super_group.go
+++ b/pkg/common/db/unrelation/super_group.go
@@ -2,6 +2,7 @@ package unrelation
import (
"context"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"go.mongodb.org/mongo-driver/bson"
diff --git a/pkg/common/kafka/consumer_group.go b/pkg/common/kafka/consumer_group.go
index 318583852..065fc6277 100644
--- a/pkg/common/kafka/consumer_group.go
+++ b/pkg/common/kafka/consumer_group.go
@@ -8,6 +8,7 @@ package kafka
import (
"context"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/Shopify/sarama"
diff --git a/pkg/common/mw/rpc_server_interceptor.go b/pkg/common/mw/rpc_server_interceptor.go
index 518b5f0a2..be37fc0fb 100644
--- a/pkg/common/mw/rpc_server_interceptor.go
+++ b/pkg/common/mw/rpc_server_interceptor.go
@@ -3,11 +3,12 @@ package mw
import (
"context"
"fmt"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/checker"
"math"
"runtime"
"strings"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/checker"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
diff --git a/pkg/common/prome/prometheus.go b/pkg/common/prome/prometheus.go
index a41626cd0..299f07d43 100644
--- a/pkg/common/prome/prometheus.go
+++ b/pkg/common/prome/prometheus.go
@@ -2,10 +2,11 @@ package prome
import (
"bytes"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"net/http"
"strconv"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+
"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
diff --git a/pkg/common/tokenverify/jwt_token.go b/pkg/common/tokenverify/jwt_token.go
index 7d634af3e..582a7f68e 100644
--- a/pkg/common/tokenverify/jwt_token.go
+++ b/pkg/common/tokenverify/jwt_token.go
@@ -3,12 +3,13 @@ package tokenverify
import (
"context"
"fmt"
+ "time"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"github.com/golang-jwt/jwt/v4"
- "time"
)
type Claims struct {
diff --git a/pkg/errs/coderr.go b/pkg/errs/coderr.go
index b8371bd5b..506a0ddcc 100644
--- a/pkg/errs/coderr.go
+++ b/pkg/errs/coderr.go
@@ -2,8 +2,9 @@ package errs
import (
"fmt"
- "github.com/pkg/errors"
"strings"
+
+ "github.com/pkg/errors"
)
type CodeError interface {
diff --git a/pkg/proto/auth/auth.pb.go b/pkg/proto/auth/auth.pb.go
index c5343c677..095998cc6 100644
--- a/pkg/proto/auth/auth.pb.go
+++ b/pkg/proto/auth/auth.pb.go
@@ -8,13 +8,14 @@ package auth
import (
context "context"
+ reflect "reflect"
+ sync "sync"
+
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
)
const (
diff --git a/pkg/proto/conversation/conversation.pb.go b/pkg/proto/conversation/conversation.pb.go
index cab6772e9..8c7451a3d 100644
--- a/pkg/proto/conversation/conversation.pb.go
+++ b/pkg/proto/conversation/conversation.pb.go
@@ -8,14 +8,15 @@ package conversation
import (
context "context"
+ reflect "reflect"
+ sync "sync"
+
wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
)
const (
diff --git a/pkg/proto/errinfo/errinfo.pb.go b/pkg/proto/errinfo/errinfo.pb.go
index 4db1d6d95..ae10fe976 100644
--- a/pkg/proto/errinfo/errinfo.pb.go
+++ b/pkg/proto/errinfo/errinfo.pb.go
@@ -7,10 +7,11 @@
package errinfo
import (
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
+
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)
const (
diff --git a/pkg/proto/friend/friend.pb.go b/pkg/proto/friend/friend.pb.go
index fd97cefb3..515ac8128 100644
--- a/pkg/proto/friend/friend.pb.go
+++ b/pkg/proto/friend/friend.pb.go
@@ -8,14 +8,15 @@ package friend
import (
context "context"
+ reflect "reflect"
+ sync "sync"
+
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
)
const (
diff --git a/pkg/proto/group/group.pb.go b/pkg/proto/group/group.pb.go
index 5febafa2f..5024365cc 100644
--- a/pkg/proto/group/group.pb.go
+++ b/pkg/proto/group/group.pb.go
@@ -8,6 +8,9 @@ package group
import (
context "context"
+ reflect "reflect"
+ sync "sync"
+
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
grpc "google.golang.org/grpc"
@@ -15,8 +18,6 @@ import (
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
)
const (
diff --git a/pkg/proto/msg/msg.pb.go b/pkg/proto/msg/msg.pb.go
index e283b7573..4a35ebe4f 100644
--- a/pkg/proto/msg/msg.pb.go
+++ b/pkg/proto/msg/msg.pb.go
@@ -8,6 +8,9 @@ package msg
import (
context "context"
+ reflect "reflect"
+ sync "sync"
+
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
grpc "google.golang.org/grpc"
@@ -15,8 +18,6 @@ import (
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
)
const (
diff --git a/pkg/proto/msggateway/msggateway.pb.go b/pkg/proto/msggateway/msggateway.pb.go
index 40751e999..9b247c65a 100644
--- a/pkg/proto/msggateway/msggateway.pb.go
+++ b/pkg/proto/msggateway/msggateway.pb.go
@@ -8,14 +8,15 @@ package msggateway
import (
context "context"
+ reflect "reflect"
+ sync "sync"
+
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
)
const (
diff --git a/pkg/proto/push/push.pb.go b/pkg/proto/push/push.pb.go
index 223ecb998..1e6a895f1 100644
--- a/pkg/proto/push/push.pb.go
+++ b/pkg/proto/push/push.pb.go
@@ -8,14 +8,15 @@ package push
import (
context "context"
+ reflect "reflect"
+ sync "sync"
+
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
)
const (
diff --git a/pkg/proto/sdkws/sdkws.pb.go b/pkg/proto/sdkws/sdkws.pb.go
index c8ed2a728..13637d3c9 100644
--- a/pkg/proto/sdkws/sdkws.pb.go
+++ b/pkg/proto/sdkws/sdkws.pb.go
@@ -7,11 +7,12 @@
package sdkws
import (
+ reflect "reflect"
+ sync "sync"
+
wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
)
const (
diff --git a/pkg/proto/statistics/statistics.pb.go b/pkg/proto/statistics/statistics.pb.go
index 6943736ec..092f67b52 100644
--- a/pkg/proto/statistics/statistics.pb.go
+++ b/pkg/proto/statistics/statistics.pb.go
@@ -7,9 +7,10 @@
package statistics
import (
+ reflect "reflect"
+
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
)
const (
diff --git a/pkg/proto/third/third.pb.go b/pkg/proto/third/third.pb.go
index 40268e683..a2512db38 100644
--- a/pkg/proto/third/third.pb.go
+++ b/pkg/proto/third/third.pb.go
@@ -8,13 +8,14 @@ package third
import (
context "context"
+ reflect "reflect"
+ sync "sync"
+
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
)
const (
diff --git a/pkg/proto/user/user.pb.go b/pkg/proto/user/user.pb.go
index f0db26e04..b55abd968 100644
--- a/pkg/proto/user/user.pb.go
+++ b/pkg/proto/user/user.pb.go
@@ -8,6 +8,9 @@ package user
import (
context "context"
+ reflect "reflect"
+ sync "sync"
+
conversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
grpc "google.golang.org/grpc"
@@ -15,8 +18,6 @@ import (
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
)
const (
diff --git a/pkg/proto/wrapperspb/wrapperspb.pb.go b/pkg/proto/wrapperspb/wrapperspb.pb.go
index 0e079bf36..2bb8b39db 100644
--- a/pkg/proto/wrapperspb/wrapperspb.pb.go
+++ b/pkg/proto/wrapperspb/wrapperspb.pb.go
@@ -7,10 +7,11 @@
package wrapperspb
import (
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
+
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)
const (
diff --git a/pkg/statistics/statistics.go b/pkg/statistics/statistics.go
index 700b24746..3ec3c6aa8 100644
--- a/pkg/statistics/statistics.go
+++ b/pkg/statistics/statistics.go
@@ -2,8 +2,9 @@ package statistics
import (
"context"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"time"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
)
type Statistics struct {
diff --git a/pkg/utils/file.go b/pkg/utils/file.go
index d79b11003..7aa7719bd 100644
--- a/pkg/utils/file.go
+++ b/pkg/utils/file.go
@@ -2,13 +2,14 @@ package utils
import (
"fmt"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"math/rand"
"os"
"path"
"strconv"
"strings"
"time"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
)
const (
diff --git a/pkg/utils/platform_number_id_to_name_test.go b/pkg/utils/platform_number_id_to_name_test.go
index c671d37cf..78569aed4 100644
--- a/pkg/utils/platform_number_id_to_name_test.go
+++ b/pkg/utils/platform_number_id_to_name_test.go
@@ -1,9 +1,10 @@
package utils
import (
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"testing"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
+
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/utils/time_format.go b/pkg/utils/time_format.go
index db1d3ac82..59abb90c4 100644
--- a/pkg/utils/time_format.go
+++ b/pkg/utils/time_format.go
@@ -16,17 +16,17 @@ const (
HalfOffset = 12 * 3600 //Half-day hourly offset
)
-//Get the current timestamp by Second
+// Get the current timestamp by Second
func GetCurrentTimestampBySecond() int64 {
return time.Now().Unix()
}
-//Convert timestamp to time.Time type
+// Convert timestamp to time.Time type
func UnixSecondToTime(second int64) time.Time {
return time.Unix(second, 0)
}
-//Convert nano timestamp to time.Time type
+// Convert nano timestamp to time.Time type
func UnixNanoSecondToTime(nanoSecond int64) time.Time {
return time.Unix(0, nanoSecond)
}
@@ -34,35 +34,35 @@ func UnixMillSecondToTime(millSecond int64) time.Time {
return time.Unix(0, millSecond*1e6)
}
-//Get the current timestamp by Nano
+// Get the current timestamp by Nano
func GetCurrentTimestampByNano() int64 {
return time.Now().UnixNano()
}
-//Get the current timestamp by Mill
+// Get the current timestamp by Mill
func GetCurrentTimestampByMill() int64 {
return time.Now().UnixNano() / 1e6
}
-//Get the timestamp at 0 o'clock of the day
+// Get the timestamp at 0 o'clock of the day
func GetCurDayZeroTimestamp() int64 {
timeStr := time.Now().Format("2006-01-02")
t, _ := time.Parse("2006-01-02", timeStr)
return t.Unix() - TimeOffset
}
-//Get the timestamp at 12 o'clock on the day
+// Get the timestamp at 12 o'clock on the day
func GetCurDayHalfTimestamp() int64 {
return GetCurDayZeroTimestamp() + HalfOffset
}
-//Get the formatted time at 0 o'clock of the day, the format is "2006-01-02_00-00-00"
+// Get the formatted time at 0 o'clock of the day, the format is "2006-01-02_00-00-00"
func GetCurDayZeroTimeFormat() string {
return time.Unix(GetCurDayZeroTimestamp(), 0).Format("2006-01-02_15-04-05")
}
-//Get the formatted time at 12 o'clock of the day, the format is "2006-01-02_12-00-00"
+// Get the formatted time at 12 o'clock of the day, the format is "2006-01-02_12-00-00"
func GetCurDayHalfTimeFormat() string {
return time.Unix(GetCurDayZeroTimestamp()+HalfOffset, 0).Format("2006-01-02_15-04-05")
}
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index 1b70f09da..b12ad0c93 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -131,7 +131,7 @@ go.build.multiarch: go.build.verify $(foreach p,$(PLATFORMS),$(addprefix go.buil
.PHONY: go.lint
go.lint: tools.verify.golangci-lint
@echo "===========> Run golangci to lint source codes"
- @$(BIN_DIR)/golangci-lint run -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/...
+ @$(TOOLS_BIN)/golangci-lint run -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/...
## go.test: Run unit test
.PHONY: go.test
diff --git a/test/mongo/cmd/main.go b/test/mongo/cmd/main.go
index 9b4f315f8..3e4017960 100644
--- a/test/mongo/cmd/main.go
+++ b/test/mongo/cmd/main.go
@@ -20,6 +20,7 @@ import (
"context"
"flag"
"fmt"
+
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
diff --git a/test/mongo/mongo_utils.go b/test/mongo/mongo_utils.go
index 50d000f99..18cdcbea3 100644
--- a/test/mongo/mongo_utils.go
+++ b/test/mongo/mongo_utils.go
@@ -19,10 +19,11 @@ import (
server_api_params "Open_IM/pkg/proto/sdk_ws"
"context"
"fmt"
+ "time"
+
"github.com/golang/protobuf/proto"
"go.mongodb.org/mongo-driver/mongo"
"gopkg.in/mgo.v2/bson"
- "time"
)
var (
From 187ee9a3751520f43b67d840cab27fbd4726c70b Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Mon, 3 Jul 2023 14:15:57 +0800
Subject: [PATCH 02/73] feat: fix openim ci
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.github/workflows/openim-ci.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/openim-ci.yml b/.github/workflows/openim-ci.yml
index 7ee0545f8..e063c6e3b 100644
--- a/.github/workflows/openim-ci.yml
+++ b/.github/workflows/openim-ci.yml
@@ -1,4 +1,4 @@
-name: IamCI
+name: OpenIMCI
on:
# main branch
@@ -11,11 +11,11 @@ on:
jobs:
- iamci:
+ openimci:
name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
environment:
- name: iamci
+ name: openimci
strategy:
matrix:
From 166ddb1e34b09ffa5fa79725af532eb4e61e48ec Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Mon, 3 Jul 2023 16:29:22 +0800
Subject: [PATCH 03/73] style: add format
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
cmd/api/main.go | 6 +-
internal/api/auth.go | 3 +-
internal/api/conversation.go | 3 +-
internal/api/custom_validator.go | 3 +-
internal/api/msg.go | 9 +-
internal/api/route.go | 11 +-
internal/api/statistics.go | 3 +-
internal/api/third.go | 8 +-
internal/api/user.go | 3 +-
internal/msggateway/callback.go | 15 +-
internal/msggateway/client.go | 22 +-
internal/msggateway/hub_server.go | 49 +-
internal/msggateway/init.go | 9 +-
internal/msggateway/message_handler.go | 16 +-
internal/msggateway/n_ws_server.go | 75 ++-
internal/msgtransfer/init.go | 38 +-
internal/msgtransfer/modify_msg_handler.go | 26 +-
.../msgtransfer/online_history_msg_handler.go | 147 +++++-
.../online_msg_to_mongo_handler.go | 38 +-
.../msgtransfer/persistent_msg_handler.go | 29 +-
internal/push/callback.go | 14 +-
internal/push/consumer_init.go | 3 +-
internal/push/offlinepush/fcm/push.go | 5 +-
internal/push/offlinepush/fcm/push_test.go | 3 +-
internal/push/offlinepush/getui/push.go | 13 +-
internal/push/offlinepush/jpush/push.go | 11 +-
internal/push/push_handler.go | 5 +-
internal/push/push_rpc_server.go | 19 +-
internal/push/push_to_client.go | 103 +++-
internal/rpc/auth/auth.go | 14 +-
internal/rpc/conversation/conversaion.go | 113 ++++-
internal/rpc/friend/black.go | 17 +-
internal/rpc/friend/friend.go | 82 +++-
internal/rpc/group/cache.go | 10 +-
internal/rpc/group/callback.go | 30 +-
internal/rpc/group/convert.go | 5 +-
internal/rpc/group/fill.go | 19 +-
internal/rpc/group/group.go | 202 ++++++--
internal/rpc/group/super_group.go | 28 +-
internal/rpc/msg/as_read.go | 32 +-
internal/rpc/msg/delete.go | 55 ++-
internal/rpc/msg/extend_msg.go | 79 ++-
internal/rpc/msg/extend_msg_callback.go | 5 +-
internal/rpc/msg/msg_status.go | 10 +-
internal/rpc/msg/revoke.go | 7 +-
internal/rpc/msg/send.go | 18 +-
internal/rpc/msg/seq.go | 5 +-
internal/rpc/msg/server.go | 12 +-
internal/rpc/msg/sync_msg.go | 15 +-
internal/rpc/msg/utils.go | 5 +-
internal/rpc/msg/verify.go | 16 +-
internal/rpc/third/third.go | 21 +-
internal/rpc/user/statistics.go | 5 +-
internal/rpc/user/user.go | 54 ++-
internal/tools/cron_task.go | 3 +-
internal/tools/msg.go | 29 +-
internal/tools/msg_test.go | 33 +-
pkg/a2r/api2rpc.go | 5 +-
pkg/apistruct/auth.go | 16 +-
pkg/apistruct/conversation.go | 50 +-
pkg/apistruct/friend.go | 24 +-
pkg/apistruct/group.go | 72 +--
pkg/apistruct/manage.go | 38 +-
pkg/apistruct/msg.go | 89 ++--
pkg/apistruct/public.go | 16 +-
pkg/apistruct/third.go | 22 +-
pkg/common/cmd/msg_gateway.go | 3 +-
pkg/common/cmd/msg_transfer.go | 3 +-
pkg/common/cmd/msg_utils.go | 3 +-
pkg/common/cmd/root.go | 3 +-
pkg/common/cmd/rpc.go | 10 +-
pkg/common/config/config.go | 13 +-
pkg/common/config/parse.go | 3 +-
pkg/common/constant/constant.go | 3 +-
pkg/common/convert/black.go | 6 +-
pkg/common/convert/friend.go | 18 +-
pkg/common/convert/group.go | 19 +-
pkg/common/db/cache/black.go | 21 +-
pkg/common/db/cache/conversation.go | 266 ++++++++---
pkg/common/db/cache/extend_msg_set.go | 37 +-
pkg/common/db/cache/friend.go | 52 +-
pkg/common/db/cache/group.go | 272 ++++++++---
pkg/common/db/cache/init_redis.go | 3 +-
pkg/common/db/cache/meta_cache.go | 38 +-
pkg/common/db/cache/msg.go | 129 ++++-
pkg/common/db/cache/user.go | 58 ++-
pkg/common/db/controller/auth.go | 9 +-
pkg/common/db/controller/black.go | 17 +-
pkg/common/db/controller/chatlog.go | 12 +-
pkg/common/db/controller/conversation.go | 99 +++-
pkg/common/db/controller/extend_msg.go | 116 ++++-
pkg/common/db/controller/friend.go | 124 ++++-
pkg/common/db/controller/group.go | 197 ++++++--
pkg/common/db/controller/msg.go | 452 +++++++++++++++---
pkg/common/db/controller/msg_test.go | 7 +-
pkg/common/db/controller/storage.go | 23 +-
pkg/common/db/controller/third.go | 8 +-
pkg/common/db/controller/user.go | 11 +-
pkg/common/db/obj/minio.go | 20 +-
pkg/common/db/obj/obj.go | 8 +-
pkg/common/db/ormutil/utils.go | 3 +-
pkg/common/db/relation/black_model.go | 46 +-
pkg/common/db/relation/chat_log_model.go | 15 +-
pkg/common/db/relation/conversation_model.go | 184 +++++--
pkg/common/db/relation/friend_model.go | 117 ++++-
.../db/relation/friend_request_model.go | 87 +++-
pkg/common/db/relation/group_member_model.go | 75 ++-
pkg/common/db/relation/group_model.go | 22 +-
pkg/common/db/relation/group_request_model.go | 71 ++-
pkg/common/db/relation/mysql_init.go | 25 +-
pkg/common/db/relation/object_hash_model.go | 15 +-
pkg/common/db/relation/object_info_model.go | 10 +-
pkg/common/db/relation/object_put_model.go | 9 +-
pkg/common/db/relation/user_model.go | 32 +-
pkg/common/db/table/relation/black.go | 6 +-
pkg/common/db/table/relation/chatlog.go | 28 +-
pkg/common/db/table/relation/conversation.go | 45 +-
pkg/common/db/table/relation/friend.go | 18 +-
.../db/table/relation/friend_request.go | 12 +-
pkg/common/db/table/relation/group.go | 22 +-
pkg/common/db/table/relation/group_member.go | 16 +-
pkg/common/db/table/relation/group_request.go | 12 +-
pkg/common/db/table/relation/utils.go | 3 +-
.../db/table/unrelation/extend_msg_set.go | 61 ++-
pkg/common/db/table/unrelation/msg.go | 3 +-
pkg/common/db/table/unrelation/super_group.go | 4 +-
pkg/common/db/tx/mongo.go | 3 +-
pkg/common/db/unrelation/extend_msg.go | 91 +++-
pkg/common/db/unrelation/mongo.go | 10 +-
pkg/common/db/unrelation/msg.go | 74 ++-
pkg/common/db/unrelation/super_group.go | 61 ++-
pkg/common/http/http_client.go | 35 +-
pkg/common/log/sql_logger.go | 44 +-
pkg/common/log/zap.go | 21 +-
pkg/common/mw/gin.go | 31 +-
pkg/common/mw/rpc_client_interceptor.go | 16 +-
pkg/common/mw/rpc_server_interceptor.go | 35 +-
pkg/common/network/ip.go | 3 +-
pkg/common/tokenverify/jwt_token.go | 3 +-
pkg/common/tokenverify/jwt_token_test.go | 3 +-
pkg/discoveryregistry/zookeeper/discover.go | 28 +-
pkg/discoveryregistry/zookeeper/register.go | 6 +-
pkg/discoveryregistry/zookeeper/resolver.go | 30 +-
pkg/discoveryregistry/zookeeper/zk.go | 7 +-
pkg/proto/conversation/conversation.pb.go | 3 +-
pkg/proto/friend/friend.pb.go | 3 +-
pkg/proto/group/group.pb.go | 5 +-
pkg/proto/msg/msg.pb.go | 5 +-
pkg/proto/msggateway/msggateway.pb.go | 3 +-
pkg/proto/push/push.pb.go | 3 +-
pkg/proto/sdkws/sdkws.pb.go | 3 +-
pkg/proto/user/user.pb.go | 5 +-
pkg/rpcclient/auth.go | 3 +-
pkg/rpcclient/conversation.go | 88 +++-
pkg/rpcclient/friend.go | 13 +-
pkg/rpcclient/group.go | 46 +-
pkg/rpcclient/msg.go | 49 +-
pkg/rpcclient/notification/conevrsation.go | 12 +-
pkg/rpcclient/notification/extend_msg.go | 61 ++-
pkg/rpcclient/notification/friend.go | 49 +-
pkg/rpcclient/notification/group.go | 242 ++++++++--
pkg/rpcclient/push.go | 8 +-
pkg/rpcclient/third.go | 3 +-
pkg/rpcclient/user.go | 15 +-
pkg/startrpc/start.go | 44 +-
pkg/statistics/statistics.go | 16 +-
pkg/utils/callback.go | 3 +-
pkg/utils/utils.go | 7 +-
scripts/make-rules/golang.mk | 3 +-
test/mongo/cmd/main.go | 3 +-
170 files changed, 4841 insertions(+), 1304 deletions(-)
diff --git a/cmd/api/main.go b/cmd/api/main.go
index 6f56a7704..fb613b4da 100644
--- a/cmd/api/main.go
+++ b/cmd/api/main.go
@@ -52,8 +52,10 @@ func run(port int) error {
fmt.Println("api start init discov client")
var client discoveryregistry.SvcDiscoveryRegistry
client, 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()))
+ 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 {
return err
}
diff --git a/internal/api/auth.go b/internal/api/auth.go
index 3fdbc10ac..a9cf17707 100644
--- a/internal/api/auth.go
+++ b/internal/api/auth.go
@@ -1,11 +1,12 @@
package api
import (
+ "github.com/gin-gonic/gin"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/auth"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
- "github.com/gin-gonic/gin"
)
type AuthApi rpcclient.Auth
diff --git a/internal/api/conversation.go b/internal/api/conversation.go
index 22798b2a7..767cc8517 100644
--- a/internal/api/conversation.go
+++ b/internal/api/conversation.go
@@ -1,11 +1,12 @@
package api
import (
+ "github.com/gin-gonic/gin"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
- "github.com/gin-gonic/gin"
)
type ConversationApi rpcclient.Conversation
diff --git a/internal/api/custom_validator.go b/internal/api/custom_validator.go
index 541702677..b434c792e 100644
--- a/internal/api/custom_validator.go
+++ b/internal/api/custom_validator.go
@@ -1,8 +1,9 @@
package api
import (
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/go-playground/validator/v10"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
)
func RequiredIf(fl validator.FieldLevel) bool {
diff --git a/internal/api/msg.go b/internal/api/msg.go
index ea3e63d7e..6f0cf7033 100644
--- a/internal/api/msg.go
+++ b/internal/api/msg.go
@@ -1,6 +1,11 @@
package api
import (
+ "github.com/gin-gonic/gin"
+ "github.com/go-playground/validator/v10"
+ "github.com/mitchellh/mapstructure"
+ "google.golang.org/protobuf/proto"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
@@ -12,10 +17,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/gin-gonic/gin"
- "github.com/go-playground/validator/v10"
- "github.com/mitchellh/mapstructure"
- "google.golang.org/protobuf/proto"
)
type MessageApi struct {
diff --git a/internal/api/route.go b/internal/api/route.go
index fb8c2d9a0..8a786dc6f 100644
--- a/internal/api/route.go
+++ b/internal/api/route.go
@@ -3,17 +3,18 @@ package api
import (
"context"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/go-playground/validator/v10"
"github.com/redis/go-redis/v9"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
)
func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.UniversalClient) *gin.Engine {
diff --git a/internal/api/statistics.go b/internal/api/statistics.go
index 9d2006212..4a85dd5ef 100644
--- a/internal/api/statistics.go
+++ b/internal/api/statistics.go
@@ -1,11 +1,12 @@
package api
import (
+ "github.com/gin-gonic/gin"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
- "github.com/gin-gonic/gin"
)
type StatisticsApi rpcclient.User
diff --git a/internal/api/third.go b/internal/api/third.go
index b04589503..559869f1e 100644
--- a/internal/api/third.go
+++ b/internal/api/third.go
@@ -5,6 +5,8 @@ import (
"net/http"
"strconv"
+ "github.com/gin-gonic/gin"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
@@ -12,7 +14,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
- "github.com/gin-gonic/gin"
)
type ThirdApi rpcclient.Third
@@ -65,7 +66,10 @@ func (o *ThirdApi) GetURL(c *gin.Context) {
}
attachment, _ := strconv.ParseBool(c.Query("attachment"))
c.Set(constant.OperationID, operationID)
- resp, err := o.Client.GetUrl(mcontext.SetOperationID(c, operationID), &third.GetUrlReq{Name: name, Expires: expires, Attachment: attachment})
+ resp, err := o.Client.GetUrl(
+ mcontext.SetOperationID(c, operationID),
+ &third.GetUrlReq{Name: name, Expires: expires, Attachment: attachment},
+ )
if err != nil {
if errs.ErrArgs.Is(err) {
c.String(http.StatusBadRequest, err.Error())
diff --git a/internal/api/user.go b/internal/api/user.go
index 299a33638..d3b7bae0e 100644
--- a/internal/api/user.go
+++ b/internal/api/user.go
@@ -1,6 +1,8 @@
package api
import (
+ "github.com/gin-gonic/gin"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
@@ -9,7 +11,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
- "github.com/gin-gonic/gin"
)
type UserApi rpcclient.User
diff --git a/internal/msggateway/callback.go b/internal/msggateway/callback.go
index 557e65ea6..79bcdac97 100644
--- a/internal/msggateway/callback.go
+++ b/internal/msggateway/callback.go
@@ -78,7 +78,8 @@ func CallbackUserKickOff(ctx context.Context, userID string, platformID int) err
return http.CallBackPostReturn(ctx, url(), req, resp, config.Config.Callback.CallbackUserOffline)
}
-//func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackground bool, connID string) cbApi.CommonCallbackResp {
+// func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackground bool, connID
+// string) cbApi.CommonCallbackResp {
// callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
// if !config.Config.Callback.CallbackUserOnline.Enable {
// return callbackResp
@@ -99,7 +100,9 @@ func CallbackUserKickOff(ctx context.Context, userID string, platformID int) err
// ConnID: connID,
// }
// callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: &callbackResp}
-// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, constant.CallbackUserOnlineCommand, callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil {
+// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, constant.CallbackUserOnlineCommand,
+// callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil
+// {
// callbackResp.ErrCode = http2.StatusInternalServerError
// callbackResp.ErrMsg = err.Error()
// }
@@ -124,7 +127,9 @@ func CallbackUserKickOff(ctx context.Context, userID string, platformID int) err
// ConnID: connID,
// }
// callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: &callbackResp}
-// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, constant.CallbackUserOfflineCommand, callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil {
+// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, constant.CallbackUserOfflineCommand,
+// callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil
+// {
// callbackResp.ErrCode = http2.StatusInternalServerError
// callbackResp.ErrMsg = err.Error()
// }
@@ -148,7 +153,9 @@ func CallbackUserKickOff(ctx context.Context, userID string, platformID int) err
// Seq: int(time.Now().UnixNano() / 1e6),
// }
// callbackUserKickOffResp := &cbApi.CallbackUserKickOffResp{CommonCallbackResp: &callbackResp}
-// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, constant.CallbackUserKickOffCommand, callbackUserKickOffReq, callbackUserKickOffResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil {
+// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, constant.CallbackUserKickOffCommand,
+// callbackUserKickOffReq, callbackUserKickOffResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err !=
+// nil {
// callbackResp.ErrCode = http2.StatusInternalServerError
// callbackResp.ErrMsg = err.Error()
// }
diff --git a/internal/msggateway/client.go b/internal/msggateway/client.go
index fa72297b8..ef92438e6 100644
--- a/internal/msggateway/client.go
+++ b/internal/msggateway/client.go
@@ -7,13 +7,14 @@ import (
"runtime/debug"
"sync"
+ "google.golang.org/protobuf/proto"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "google.golang.org/protobuf/proto"
)
var ErrConnClosed = errors.New("conn has closed")
@@ -65,7 +66,13 @@ func newClient(ctx *UserConnContext, conn LongConn, isCompress bool) *Client {
ctx: ctx,
}
}
-func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, isBackground, isCompress bool, longConnServer LongConnServer) {
+
+func (c *Client) ResetClient(
+ ctx *UserConnContext,
+ conn LongConn,
+ isBackground, isCompress bool,
+ longConnServer LongConnServer,
+) {
c.w = new(sync.Mutex)
c.conn = conn
c.PlatformID = utils.StringToInt(ctx.GetPlatformID())
@@ -145,7 +152,9 @@ func (c *Client) handleMessage(message []byte) error {
if binaryReq.SendID != c.UserID {
return utils.Wrap(errors.New("exception conn userID not same to req userID"), binaryReq.String())
}
- ctx := mcontext.WithMustInfoCtx([]string{binaryReq.OperationID, binaryReq.SendID, constant.PlatformIDToName(c.PlatformID), c.ctx.GetConnID()})
+ ctx := mcontext.WithMustInfoCtx(
+ []string{binaryReq.OperationID, binaryReq.SendID, constant.PlatformIDToName(c.PlatformID), c.ctx.GetConnID()},
+ )
log.ZDebug(ctx, "gateway req message", "req", binaryReq.String())
var messageErr error
var resp []byte
@@ -163,7 +172,12 @@ func (c *Client) handleMessage(message []byte) error {
case WsSetBackgroundStatus:
resp, messageErr = c.setAppBackgroundStatus(ctx, binaryReq)
default:
- return fmt.Errorf("ReqIdentifier failed,sendID:%s,msgIncr:%s,reqIdentifier:%d", binaryReq.SendID, binaryReq.MsgIncr, binaryReq.ReqIdentifier)
+ return fmt.Errorf(
+ "ReqIdentifier failed,sendID:%s,msgIncr:%s,reqIdentifier:%d",
+ binaryReq.SendID,
+ binaryReq.MsgIncr,
+ binaryReq.ReqIdentifier,
+ )
}
c.replyMessage(ctx, &binaryReq, messageErr, resp)
return nil
diff --git a/internal/msggateway/hub_server.go b/internal/msggateway/hub_server.go
index ab8f9af26..6916f5309 100644
--- a/internal/msggateway/hub_server.go
+++ b/internal/msggateway/hub_server.go
@@ -5,6 +5,8 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
@@ -15,7 +17,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msggateway"
"github.com/OpenIMSDK/Open-IM-Server/pkg/startrpc"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "google.golang.org/grpc"
)
func (s *Server) InitServer(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
@@ -31,7 +32,12 @@ func (s *Server) InitServer(client discoveryregistry.SvcDiscoveryRegistry, serve
}
func (s *Server) Start() error {
- return startrpc.Start(s.rpcPort, config.Config.RpcRegisterName.OpenImMessageGatewayName, s.prometheusPort, s.InitServer)
+ return startrpc.Start(
+ s.rpcPort,
+ config.Config.RpcRegisterName.OpenImMessageGatewayName,
+ s.prometheusPort,
+ s.InitServer,
+ )
}
type Server struct {
@@ -46,14 +52,24 @@ func (s *Server) SetLongConnServer(LongConnServer LongConnServer) {
}
func NewServer(rpcPort int, longConnServer LongConnServer) *Server {
- return &Server{rpcPort: rpcPort, LongConnServer: longConnServer, pushTerminal: []int{constant.IOSPlatformID, constant.AndroidPlatformID}}
+ return &Server{
+ rpcPort: rpcPort,
+ LongConnServer: longConnServer,
+ pushTerminal: []int{constant.IOSPlatformID, constant.AndroidPlatformID},
+ }
}
-func (s *Server) OnlinePushMsg(context context.Context, req *msggateway.OnlinePushMsgReq) (*msggateway.OnlinePushMsgResp, error) {
+func (s *Server) OnlinePushMsg(
+ context context.Context,
+ req *msggateway.OnlinePushMsgReq,
+) (*msggateway.OnlinePushMsgResp, error) {
panic("implement me")
}
-func (s *Server) GetUsersOnlineStatus(ctx context.Context, req *msggateway.GetUsersOnlineStatusReq) (*msggateway.GetUsersOnlineStatusResp, error) {
+func (s *Server) GetUsersOnlineStatus(
+ ctx context.Context,
+ req *msggateway.GetUsersOnlineStatusReq,
+) (*msggateway.GetUsersOnlineStatusResp, error) {
if !tokenverify.IsAppManagerUid(ctx) {
return nil, errs.ErrNoPermission.Wrap("only app manager")
}
@@ -83,11 +99,17 @@ func (s *Server) GetUsersOnlineStatus(ctx context.Context, req *msggateway.GetUs
return &resp, nil
}
-func (s *Server) OnlineBatchPushOneMsg(ctx context.Context, req *msggateway.OnlineBatchPushOneMsgReq) (*msggateway.OnlineBatchPushOneMsgResp, error) {
+func (s *Server) OnlineBatchPushOneMsg(
+ ctx context.Context,
+ req *msggateway.OnlineBatchPushOneMsgReq,
+) (*msggateway.OnlineBatchPushOneMsgResp, error) {
panic("implement me")
}
-func (s *Server) SuperGroupOnlineBatchPushOneMsg(ctx context.Context, req *msggateway.OnlineBatchPushOneMsgReq) (*msggateway.OnlineBatchPushOneMsgResp, error) {
+func (s *Server) SuperGroupOnlineBatchPushOneMsg(
+ ctx context.Context,
+ req *msggateway.OnlineBatchPushOneMsgReq,
+) (*msggateway.OnlineBatchPushOneMsgResp, error) {
var singleUserResult []*msggateway.SingleMsgToUserResults
for _, v := range req.PushToUserIDs {
var resp []*msggateway.SingleMsgToUserPlatform
@@ -108,7 +130,8 @@ func (s *Server) SuperGroupOnlineBatchPushOneMsg(ctx context.Context, req *msgga
RecvID: v,
RecvPlatFormID: int32(client.PlatformID),
}
- if !client.IsBackground || (client.IsBackground == true && client.PlatformID != constant.IOSPlatformID) {
+ if !client.IsBackground ||
+ (client.IsBackground == true && client.PlatformID != constant.IOSPlatformID) {
err := client.PushMessage(ctx, req.MsgData)
if err != nil {
temp.ResultCode = -2
@@ -135,7 +158,10 @@ func (s *Server) SuperGroupOnlineBatchPushOneMsg(ctx context.Context, req *msgga
}, nil
}
-func (s *Server) KickUserOffline(ctx context.Context, req *msggateway.KickUserOfflineReq) (*msggateway.KickUserOfflineResp, error) {
+func (s *Server) KickUserOffline(
+ ctx context.Context,
+ req *msggateway.KickUserOfflineReq,
+) (*msggateway.KickUserOfflineResp, error) {
for _, v := range req.KickUserIDList {
if clients, _, ok := s.LongConnServer.GetUserPlatformCons(v, int(req.PlatformID)); ok {
for _, client := range clients {
@@ -149,7 +175,10 @@ func (s *Server) KickUserOffline(ctx context.Context, req *msggateway.KickUserOf
return &msggateway.KickUserOfflineResp{}, nil
}
-func (s *Server) MultiTerminalLoginCheck(ctx context.Context, req *msggateway.MultiTerminalLoginCheckReq) (*msggateway.MultiTerminalLoginCheckResp, error) {
+func (s *Server) MultiTerminalLoginCheck(
+ ctx context.Context,
+ req *msggateway.MultiTerminalLoginCheckReq,
+) (*msggateway.MultiTerminalLoginCheckResp, error) {
//TODO implement me
panic("implement me")
}
diff --git a/internal/msggateway/init.go b/internal/msggateway/init.go
index 2e001667a..c21ac02ce 100644
--- a/internal/msggateway/init.go
+++ b/internal/msggateway/init.go
@@ -8,7 +8,14 @@ import (
)
func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error {
- fmt.Println("start rpc/msg_gateway server, port: ", rpcPort, wsPort, prometheusPort, ", OpenIM version: ", config.Version)
+ fmt.Println(
+ "start rpc/msg_gateway server, port: ",
+ rpcPort,
+ wsPort,
+ prometheusPort,
+ ", OpenIM version: ",
+ config.Version,
+ )
longServer, err := NewWsServer(
WithPort(wsPort),
WithMaxConnNum(int64(config.Config.LongConnSvr.WebsocketMaxConnNum)),
diff --git a/internal/msggateway/message_handler.go b/internal/msggateway/message_handler.go
index 5430c8175..73b22b83d 100644
--- a/internal/msggateway/message_handler.go
+++ b/internal/msggateway/message_handler.go
@@ -6,20 +6,21 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/push"
+ "github.com/go-playground/validator/v10"
+ "google.golang.org/protobuf/proto"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/go-playground/validator/v10"
- "google.golang.org/protobuf/proto"
)
type Req struct {
ReqIdentifier int32 `json:"reqIdentifier" validate:"required"`
- Token string `json:"token" `
- SendID string `json:"sendID" validate:"required"`
- OperationID string `json:"operationID" validate:"required"`
- MsgIncr string `json:"msgIncr" validate:"required"`
+ Token string `json:"token"`
+ SendID string `json:"sendID" validate:"required"`
+ OperationID string `json:"operationID" validate:"required"`
+ MsgIncr string `json:"msgIncr" validate:"required"`
Data []byte `json:"data"`
}
@@ -160,7 +161,8 @@ func (g GrpcHandler) SetUserDeviceBackground(_ context.Context, data Req) ([]byt
return nil, req.IsBackground, nil
}
-//func (g GrpcHandler) call[T any](ctx context.Context, data Req, m proto.Message, rpc func(ctx context.Context, req proto.Message)) ([]byte, error) {
+// func (g GrpcHandler) call[T any](ctx context.Context, data Req, m proto.Message, rpc func(ctx context.Context, req
+// proto.Message)) ([]byte, error) {
// if err := proto.Unmarshal(data.Data, m); err != nil {
// return nil, err
// }
diff --git a/internal/msggateway/n_ws_server.go b/internal/msggateway/n_ws_server.go
index dcf183015..c1ec5d076 100644
--- a/internal/msggateway/n_ws_server.go
+++ b/internal/msggateway/n_ws_server.go
@@ -13,14 +13,16 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/redis/go-redis/v9"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
+
+ "github.com/go-playground/validator/v10"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/go-playground/validator/v10"
)
type LongConnServer interface {
@@ -169,7 +171,14 @@ func (ws *WsServer) registerClient(client *Client) {
atomic.AddInt64(&ws.onlineUserConnNum, 1)
}
}
- log.ZInfo(client.ctx, "user online", "online user Num", ws.onlineUserNum, "online user conn Num", ws.onlineUserConnNum)
+ log.ZInfo(
+ client.ctx,
+ "user online",
+ "online user Num",
+ ws.onlineUserNum,
+ "online user conn Num",
+ ws.onlineUserConnNum,
+ )
}
func getRemoteAdders(client []*Client) string {
var ret string
@@ -200,18 +209,47 @@ func (ws *WsServer) multiTerminalLoginChecker(info *kickHandler) {
log.ZWarn(c.ctx, "KickOnlineMessage", err)
}
}
- m, err := ws.cache.GetTokensWithoutError(info.newClient.ctx, info.newClient.UserID, info.newClient.PlatformID)
+ m, err := ws.cache.GetTokensWithoutError(
+ info.newClient.ctx,
+ info.newClient.UserID,
+ info.newClient.PlatformID,
+ )
if err != nil && err != redis.Nil {
- log.ZWarn(info.newClient.ctx, "get token from redis err", err, "userID", info.newClient.UserID, "platformID", info.newClient.PlatformID)
+ log.ZWarn(
+ info.newClient.ctx,
+ "get token from redis err",
+ err,
+ "userID",
+ info.newClient.UserID,
+ "platformID",
+ info.newClient.PlatformID,
+ )
return
}
if m == nil {
- log.ZWarn(info.newClient.ctx, "m is nil", errors.New("m is nil"), "userID", info.newClient.UserID, "platformID", info.newClient.PlatformID)
+ log.ZWarn(
+ info.newClient.ctx,
+ "m is nil",
+ errors.New("m is nil"),
+ "userID",
+ info.newClient.UserID,
+ "platformID",
+ info.newClient.PlatformID,
+ )
return
}
- log.ZDebug(info.newClient.ctx, "get token from redis", "userID", info.newClient.UserID, "platformID", info.newClient.PlatformID, "tokenMap", m)
+ log.ZDebug(
+ info.newClient.ctx,
+ "get token from redis",
+ "userID",
+ info.newClient.UserID,
+ "platformID",
+ info.newClient.PlatformID,
+ "tokenMap",
+ m,
+ )
- for k, _ := range m {
+ for k := range m {
if k != info.newClient.ctx.GetToken() {
m[k] = constant.KickedToken
}
@@ -219,7 +257,15 @@ func (ws *WsServer) multiTerminalLoginChecker(info *kickHandler) {
log.ZDebug(info.newClient.ctx, "set token map is ", "token map", m, "userID", info.newClient.UserID)
err = ws.cache.SetTokenMapByUidPid(info.newClient.ctx, info.newClient.UserID, info.newClient.PlatformID, m)
if err != nil {
- log.ZWarn(info.newClient.ctx, "SetTokenMapByUidPid err", err, "userID", info.newClient.UserID, "platformID", info.newClient.PlatformID)
+ log.ZWarn(
+ info.newClient.ctx,
+ "SetTokenMapByUidPid err",
+ err,
+ "userID",
+ info.newClient.UserID,
+ "platformID",
+ info.newClient.PlatformID,
+ )
return
}
}
@@ -233,7 +279,16 @@ func (ws *WsServer) unregisterClient(client *Client) {
atomic.AddInt64(&ws.onlineUserNum, -1)
}
atomic.AddInt64(&ws.onlineUserConnNum, -1)
- log.ZInfo(client.ctx, "user offline", "close reason", client.closedErr, "online user Num", ws.onlineUserNum, "online user conn Num", ws.onlineUserConnNum)
+ log.ZInfo(
+ client.ctx,
+ "user offline",
+ "close reason",
+ client.closedErr,
+ "online user Num",
+ ws.onlineUserNum,
+ "online user conn Num",
+ ws.onlineUserConnNum,
+ )
}
func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
diff --git a/internal/msgtransfer/init.go b/internal/msgtransfer/init.go
index 19dda963e..5b82a7d30 100644
--- a/internal/msgtransfer/init.go
+++ b/internal/msgtransfer/init.go
@@ -5,6 +5,9 @@ import (
"sync"
"time"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/credentials/insecure"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@@ -17,8 +20,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
- "google.golang.org/grpc"
- "google.golang.org/grpc/credentials/insecure"
)
type MsgTransfer struct {
@@ -47,9 +48,18 @@ func StartTransfer(prometheusPort int) error {
if err := mongo.CreateMsgIndex(); err != nil {
return err
}
- client, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
- openKeeper.WithFreq(time.Hour), openKeeper.WithRoundRobin(), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
- config.Config.Zookeeper.Password), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))
+ client, err := openKeeper.NewClient(
+ config.Config.Zookeeper.ZkAddr,
+ config.Config.Zookeeper.Schema,
+ openKeeper.WithFreq(
+ time.Hour,
+ ),
+ openKeeper.WithRoundRobin(),
+ openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
+ config.Config.Zookeeper.Password),
+ openKeeper.WithTimeout(10),
+ openKeeper.WithLogger(log.NewZkLogger()),
+ )
if err != nil {
return err
}
@@ -66,7 +76,13 @@ func StartTransfer(prometheusPort int) error {
msgDatabase := controller.NewCommonMsgDatabase(msgDocModel, msgModel)
conversationRpcClient := rpcclient.NewConversationRpcClient(client)
groupRpcClient := rpcclient.NewGroupRpcClient(client)
- msgTransfer := NewMsgTransfer(chatLogDatabase, extendMsgDatabase, msgDatabase, &conversationRpcClient, &groupRpcClient)
+ msgTransfer := NewMsgTransfer(
+ chatLogDatabase,
+ extendMsgDatabase,
+ msgDatabase,
+ &conversationRpcClient,
+ &groupRpcClient,
+ )
msgTransfer.initPrometheus()
return msgTransfer.Start(prometheusPort)
}
@@ -74,8 +90,14 @@ func StartTransfer(prometheusPort int) error {
func NewMsgTransfer(chatLogDatabase controller.ChatLogDatabase,
extendMsgDatabase controller.ExtendMsgDatabase, msgDatabase controller.CommonMsgDatabase,
conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient) *MsgTransfer {
- return &MsgTransfer{persistentCH: NewPersistentConsumerHandler(chatLogDatabase), historyCH: NewOnlineHistoryRedisConsumerHandler(msgDatabase, conversationRpcClient, groupRpcClient),
- historyMongoCH: NewOnlineHistoryMongoConsumerHandler(msgDatabase), modifyCH: NewModifyMsgConsumerHandler(extendMsgDatabase)}
+ return &MsgTransfer{
+ persistentCH: NewPersistentConsumerHandler(chatLogDatabase),
+ historyCH: NewOnlineHistoryRedisConsumerHandler(msgDatabase, conversationRpcClient, groupRpcClient),
+ historyMongoCH: NewOnlineHistoryMongoConsumerHandler(
+ msgDatabase,
+ ),
+ modifyCH: NewModifyMsgConsumerHandler(extendMsgDatabase),
+ }
}
func (m *MsgTransfer) initPrometheus() {
diff --git a/internal/msgtransfer/modify_msg_handler.go b/internal/msgtransfer/modify_msg_handler.go
index 0b9ad2aff..e4130addb 100644
--- a/internal/msgtransfer/modify_msg_handler.go
+++ b/internal/msgtransfer/modify_msg_handler.go
@@ -4,6 +4,8 @@ import (
"context"
"encoding/json"
+ "github.com/Shopify/sarama"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@@ -14,7 +16,6 @@ import (
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/Shopify/sarama"
"google.golang.org/protobuf/proto"
)
@@ -41,7 +42,18 @@ func (mmc *ModifyMsgConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSessi
claim sarama.ConsumerGroupClaim) error {
for msg := range claim.Messages() {
ctx := mmc.modifyMsgConsumerGroup.GetContextFromMsg(msg)
- log.ZDebug(ctx, "kafka get info to mysql", "ModifyMsgConsumerHandler", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value), "key", string(msg.Key))
+ log.ZDebug(
+ ctx,
+ "kafka get info to mysql",
+ "ModifyMsgConsumerHandler",
+ msg.Topic,
+ "msgPartition",
+ msg.Partition,
+ "msg",
+ string(msg.Value),
+ "key",
+ string(msg.Key),
+ )
if len(msg.Value) != 0 {
mmc.ModifyMsg(ctx, msg, string(msg.Key), sess)
} else {
@@ -52,7 +64,12 @@ func (mmc *ModifyMsgConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSessi
return nil
}
-func (mmc *ModifyMsgConsumerHandler) ModifyMsg(ctx context.Context, cMsg *sarama.ConsumerMessage, msgKey string, _ sarama.ConsumerGroupSession) {
+func (mmc *ModifyMsgConsumerHandler) ModifyMsg(
+ ctx context.Context,
+ cMsg *sarama.ConsumerMessage,
+ msgKey string,
+ _ sarama.ConsumerGroupSession,
+) {
msgFromMQ := pbMsg.MsgDataToModifyByMQ{}
operationID := mcontext.GetOperationID(ctx)
err := proto.Unmarshal(cMsg.Value, &msgFromMQ)
@@ -92,7 +109,8 @@ func (mmc *ModifyMsgConsumerHandler) ModifyMsg(ctx context.Context, cMsg *sarama
}
if err := mmc.extendMsgDatabase.InsertExtendMsg(ctx, notification.ConversationID, notification.SessionType, &extendMsg); err != nil {
- // log.ZError(ctx, "MsgFirstModify InsertExtendMsg failed", notification.ConversationID, notification.SessionType, extendMsg, err.Error())
+ // log.ZError(ctx, "MsgFirstModify InsertExtendMsg failed", notification.ConversationID,
+ // notification.SessionType, extendMsg, err.Error())
continue
}
} else {
diff --git a/internal/msgtransfer/online_history_msg_handler.go b/internal/msgtransfer/online_history_msg_handler.go
index 7f776d5ee..ee7c3bd95 100644
--- a/internal/msgtransfer/online_history_msg_handler.go
+++ b/internal/msgtransfer/online_history_msg_handler.go
@@ -9,6 +9,10 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
+ "github.com/Shopify/sarama"
+ "github.com/go-redis/redis"
+ "google.golang.org/protobuf/proto"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@@ -18,9 +22,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/Shopify/sarama"
- "github.com/go-redis/redis"
- "google.golang.org/protobuf/proto"
)
const ConsumerMsgs = 3
@@ -63,7 +64,11 @@ type OnlineHistoryRedisConsumerHandler struct {
groupRpcClient *rpcclient.GroupRpcClient
}
-func NewOnlineHistoryRedisConsumerHandler(database controller.CommonMsgDatabase, conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient) *OnlineHistoryRedisConsumerHandler {
+func NewOnlineHistoryRedisConsumerHandler(
+ database controller.CommonMsgDatabase,
+ conversationRpcClient *rpcclient.ConversationRpcClient,
+ groupRpcClient *rpcclient.GroupRpcClient,
+) *OnlineHistoryRedisConsumerHandler {
var och OnlineHistoryRedisConsumerHandler
och.msgDatabase = database
och.msgDistributionCh = make(chan Cmd2Value) //no buffer channel
@@ -77,7 +82,8 @@ func NewOnlineHistoryRedisConsumerHandler(database controller.CommonMsgDatabase,
och.historyConsumerGroup = kafka.NewMConsumerGroup(&kafka.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.LatestMsgToRedis.Topic},
config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToRedis)
- //statistics.NewStatistics(&och.singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
+ // statistics.NewStatistics(&och.singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d
+ // second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
return &och
}
@@ -90,16 +96,53 @@ func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) {
msgChannelValue := cmd.Value.(MsgChannelValue)
ctxMsgList := msgChannelValue.ctxMsgList
ctx := msgChannelValue.ctx
- log.ZDebug(ctx, "msg arrived channel", "channel id", channelID, "msgList length", len(ctxMsgList), "uniqueKey", msgChannelValue.uniqueKey)
- storageMsgList, notStorageMsgList, storageNotificationList, notStorageNotificationList, modifyMsgList := och.getPushStorageMsgList(ctxMsgList)
- log.ZDebug(ctx, "msg lens", "storageMsgList", len(storageMsgList), "notStorageMsgList", len(notStorageMsgList),
- "storageNotificationList", len(storageNotificationList), "notStorageNotificationList", len(notStorageNotificationList), "modifyMsgList", len(modifyMsgList))
+ log.ZDebug(
+ ctx,
+ "msg arrived channel",
+ "channel id",
+ channelID,
+ "msgList length",
+ len(ctxMsgList),
+ "uniqueKey",
+ msgChannelValue.uniqueKey,
+ )
+ storageMsgList, notStorageMsgList, storageNotificationList, notStorageNotificationList, modifyMsgList := och.getPushStorageMsgList(
+ ctxMsgList,
+ )
+ log.ZDebug(
+ ctx,
+ "msg lens",
+ "storageMsgList",
+ len(storageMsgList),
+ "notStorageMsgList",
+ len(notStorageMsgList),
+ "storageNotificationList",
+ len(storageNotificationList),
+ "notStorageNotificationList",
+ len(notStorageNotificationList),
+ "modifyMsgList",
+ len(modifyMsgList),
+ )
conversationIDMsg := utils.GetChatConversationIDByMsg(ctxMsgList[0].message)
conversationIDNotification := utils.GetNotificationConversationID(ctxMsgList[0].message)
och.handleMsg(ctx, msgChannelValue.uniqueKey, conversationIDMsg, storageMsgList, notStorageMsgList)
- och.handleNotification(ctx, msgChannelValue.uniqueKey, conversationIDNotification, storageNotificationList, notStorageNotificationList)
+ och.handleNotification(
+ ctx,
+ msgChannelValue.uniqueKey,
+ conversationIDNotification,
+ storageNotificationList,
+ notStorageNotificationList,
+ )
if err := och.msgDatabase.MsgToModifyMQ(ctx, msgChannelValue.uniqueKey, conversationIDNotification, modifyMsgList); err != nil {
- log.ZError(ctx, "msg to modify mq error", err, "uniqueKey", msgChannelValue.uniqueKey, "modifyMsgList", modifyMsgList)
+ log.ZError(
+ ctx,
+ "msg to modify mq error",
+ err,
+ "uniqueKey",
+ msgChannelValue.uniqueKey,
+ "modifyMsgList",
+ modifyMsgList,
+ )
}
}
}
@@ -107,7 +150,9 @@ func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) {
}
// 获取消息/通知 存储的消息列表, 不存储并且推送的消息列表,
-func (och *OnlineHistoryRedisConsumerHandler) getPushStorageMsgList(totalMsgs []*ContextMsg) (storageMsgList, notStorageMsgList, storageNotificatoinList, notStorageNotificationList, modifyMsgList []*sdkws.MsgData) {
+func (och *OnlineHistoryRedisConsumerHandler) getPushStorageMsgList(
+ totalMsgs []*ContextMsg,
+) (storageMsgList, notStorageMsgList, storageNotificatoinList, notStorageNotificationList, modifyMsgList []*sdkws.MsgData) {
isStorage := func(msg *sdkws.MsgData) bool {
options2 := utils.Options(msg.Options)
if options2.IsHistory() {
@@ -130,11 +175,17 @@ func (och *OnlineHistoryRedisConsumerHandler) getPushStorageMsgList(totalMsgs []
msg.Options = utils.NewMsgOptions()
}
if options.IsOfflinePush() {
- v.message.Options = utils.WithOptions(utils.Options(v.message.Options), utils.WithOfflinePush(false))
+ v.message.Options = utils.WithOptions(
+ utils.Options(v.message.Options),
+ utils.WithOfflinePush(false),
+ )
msg.Options = utils.WithOptions(utils.Options(msg.Options), utils.WithOfflinePush(true))
}
if options.IsUnreadCount() {
- v.message.Options = utils.WithOptions(utils.Options(v.message.Options), utils.WithUnreadCount(false))
+ v.message.Options = utils.WithOptions(
+ utils.Options(v.message.Options),
+ utils.WithUnreadCount(false),
+ )
msg.Options = utils.WithOptions(utils.Options(msg.Options), utils.WithUnreadCount(true))
}
storageMsgList = append(storageMsgList, msg)
@@ -151,19 +202,32 @@ func (och *OnlineHistoryRedisConsumerHandler) getPushStorageMsgList(totalMsgs []
notStorageMsgList = append(notStorageMsgList, v.message)
}
}
- if v.message.ContentType == constant.ReactionMessageModifier || v.message.ContentType == constant.ReactionMessageDeleter {
+ if v.message.ContentType == constant.ReactionMessageModifier ||
+ v.message.ContentType == constant.ReactionMessageDeleter {
modifyMsgList = append(modifyMsgList, v.message)
}
}
return
}
-func (och *OnlineHistoryRedisConsumerHandler) handleNotification(ctx context.Context, key, conversationID string, storageList, notStorageList []*sdkws.MsgData) {
+func (och *OnlineHistoryRedisConsumerHandler) handleNotification(
+ ctx context.Context,
+ key, conversationID string,
+ storageList, notStorageList []*sdkws.MsgData,
+) {
och.toPushTopic(ctx, key, conversationID, notStorageList)
if len(storageList) > 0 {
lastSeq, _, err := och.msgDatabase.BatchInsertChat2Cache(ctx, conversationID, storageList)
if err != nil {
- log.ZError(ctx, "notification batch insert to redis error", err, "conversationID", conversationID, "storageList", storageList)
+ log.ZError(
+ ctx,
+ "notification batch insert to redis error",
+ err,
+ "conversationID",
+ conversationID,
+ "storageList",
+ storageList,
+ )
return
}
log.ZDebug(ctx, "success to next topic", "conversationID", conversationID)
@@ -172,13 +236,21 @@ func (och *OnlineHistoryRedisConsumerHandler) handleNotification(ctx context.Con
}
}
-func (och *OnlineHistoryRedisConsumerHandler) toPushTopic(ctx context.Context, key, conversationID string, msgs []*sdkws.MsgData) {
+func (och *OnlineHistoryRedisConsumerHandler) toPushTopic(
+ ctx context.Context,
+ key, conversationID string,
+ msgs []*sdkws.MsgData,
+) {
for _, v := range msgs {
och.msgDatabase.MsgToPushMQ(ctx, key, conversationID, v)
}
}
-func (och *OnlineHistoryRedisConsumerHandler) handleMsg(ctx context.Context, key, conversationID string, storageList, notStorageList []*sdkws.MsgData) {
+func (och *OnlineHistoryRedisConsumerHandler) handleMsg(
+ ctx context.Context,
+ key, conversationID string,
+ storageList, notStorageList []*sdkws.MsgData,
+) {
och.toPushTopic(ctx, key, conversationID, notStorageList)
if len(storageList) > 0 {
lastSeq, isNewConversation, err := och.msgDatabase.BatchInsertChat2Cache(ctx, conversationID, storageList)
@@ -240,11 +312,26 @@ func (och *OnlineHistoryRedisConsumerHandler) MessagesDistributionHandle() {
for i, header := range consumerMessages[i].Headers {
arr = append(arr, strconv.Itoa(i), string(header.Key), string(header.Value))
}
- log.ZInfo(ctx, "consumer.kafka.GetContextWithMQHeader", "len", len(consumerMessages[i].Headers), "header", strings.Join(arr, ", "))
+ log.ZInfo(
+ ctx,
+ "consumer.kafka.GetContextWithMQHeader",
+ "len",
+ len(consumerMessages[i].Headers),
+ "header",
+ strings.Join(arr, ", "),
+ )
ctxMsg.ctx = kafka.GetContextWithMQHeader(consumerMessages[i].Headers)
ctxMsg.message = msgFromMQ
- log.ZDebug(ctx, "single msg come to distribution center", "message", msgFromMQ, "key", string(consumerMessages[i].Key))
- //aggregationMsgs[string(consumerMessages[i].Key)] = append(aggregationMsgs[string(consumerMessages[i].Key)], ctxMsg)
+ log.ZDebug(
+ ctx,
+ "single msg come to distribution center",
+ "message",
+ msgFromMQ,
+ "key",
+ string(consumerMessages[i].Key),
+ )
+ // aggregationMsgs[string(consumerMessages[i].Key)] =
+ // append(aggregationMsgs[string(consumerMessages[i].Key)], ctxMsg)
if oldM, ok := aggregationMsgs[string(consumerMessages[i].Key)]; ok {
oldM = append(oldM, ctxMsg)
aggregationMsgs[string(consumerMessages[i].Key)] = oldM
@@ -260,7 +347,16 @@ func (och *OnlineHistoryRedisConsumerHandler) MessagesDistributionHandle() {
hashCode := utils.GetHashCode(uniqueKey)
channelID := hashCode % ChannelNum
newCtx := withAggregationCtx(ctx, v)
- log.ZDebug(newCtx, "generate channelID", "hashCode", hashCode, "channelID", channelID, "uniqueKey", uniqueKey)
+ log.ZDebug(
+ newCtx,
+ "generate channelID",
+ "hashCode",
+ hashCode,
+ "channelID",
+ channelID,
+ "uniqueKey",
+ uniqueKey,
+ )
och.chArrays[channelID] <- Cmd2Value{Cmd: SourceMessages, Value: MsgChannelValue{uniqueKey: uniqueKey, ctxMsgList: v, ctx: newCtx}}
}
}
@@ -288,7 +384,10 @@ func (och *OnlineHistoryRedisConsumerHandler) Cleanup(_ sarama.ConsumerGroupSess
return nil
}
-func (och *OnlineHistoryRedisConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error { // a instance in the consumer group
+func (och *OnlineHistoryRedisConsumerHandler) ConsumeClaim(
+ sess sarama.ConsumerGroupSession,
+ claim sarama.ConsumerGroupClaim,
+) error { // a instance in the consumer group
for {
if sess == nil {
log.ZWarn(context.Background(), "sess == nil, waiting", nil)
diff --git a/internal/msgtransfer/online_msg_to_mongo_handler.go b/internal/msgtransfer/online_msg_to_mongo_handler.go
index 77c5e9a6b..7a4799fac 100644
--- a/internal/msgtransfer/online_msg_to_mongo_handler.go
+++ b/internal/msgtransfer/online_msg_to_mongo_handler.go
@@ -3,13 +3,14 @@ package msgtransfer
import (
"context"
+ "github.com/Shopify/sarama"
+ "google.golang.org/protobuf/proto"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
kfk "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
- "github.com/Shopify/sarama"
- "google.golang.org/protobuf/proto"
)
type OnlineHistoryMongoConsumerHandler struct {
@@ -27,7 +28,12 @@ func NewOnlineHistoryMongoConsumerHandler(database controller.CommonMsgDatabase)
return mc
}
-func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(ctx context.Context, cMsg *sarama.ConsumerMessage, key string, session sarama.ConsumerGroupSession) {
+func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(
+ ctx context.Context,
+ cMsg *sarama.ConsumerMessage,
+ key string,
+ session sarama.ConsumerGroupSession,
+) {
msg := cMsg.Value
msgFromMQ := pbMsg.MsgDataToMongoByMQ{}
err := proto.Unmarshal(msg, &msgFromMQ)
@@ -42,7 +48,15 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(ctx context.Cont
log.ZInfo(ctx, "mongo consumer recv msg", "msgs", msgFromMQ.MsgData)
err = mc.msgDatabase.BatchInsertChat2DB(ctx, msgFromMQ.ConversationID, msgFromMQ.MsgData, msgFromMQ.LastSeq)
if err != nil {
- log.ZError(ctx, "single data insert to mongo err", err, "msg", msgFromMQ.MsgData, "conversationID", msgFromMQ.ConversationID)
+ log.ZError(
+ ctx,
+ "single data insert to mongo err",
+ err,
+ "msg",
+ msgFromMQ.MsgData,
+ "conversationID",
+ msgFromMQ.ConversationID,
+ )
}
var seqs []int64
for _, msg := range msgFromMQ.MsgData {
@@ -50,14 +64,26 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(ctx context.Cont
}
err = mc.msgDatabase.DeleteMessagesFromCache(ctx, msgFromMQ.ConversationID, seqs)
if err != nil {
- log.ZError(ctx, "remove cache msg from redis err", err, "msg", msgFromMQ.MsgData, "conversationID", msgFromMQ.ConversationID)
+ log.ZError(
+ ctx,
+ "remove cache msg from redis err",
+ err,
+ "msg",
+ msgFromMQ.MsgData,
+ "conversationID",
+ msgFromMQ.ConversationID,
+ )
}
mc.msgDatabase.DelUserDeleteMsgsList(ctx, msgFromMQ.ConversationID, seqs)
}
func (OnlineHistoryMongoConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
func (OnlineHistoryMongoConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
-func (mc *OnlineHistoryMongoConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error { // a instance in the consumer group
+
+func (mc *OnlineHistoryMongoConsumerHandler) ConsumeClaim(
+ sess sarama.ConsumerGroupSession,
+ claim sarama.ConsumerGroupClaim,
+) error { // a instance in the consumer group
log.ZDebug(context.Background(), "online new session msg come", "highWaterMarkOffset",
claim.HighWaterMarkOffset(), "topic", claim.Topic(), "partition", claim.Partition())
for msg := range claim.Messages() {
diff --git a/internal/msgtransfer/persistent_msg_handler.go b/internal/msgtransfer/persistent_msg_handler.go
index 026f5f5a0..30b739f7e 100644
--- a/internal/msgtransfer/persistent_msg_handler.go
+++ b/internal/msgtransfer/persistent_msg_handler.go
@@ -3,8 +3,7 @@
** copyright('tuoyun,www.tuoyun.net').
** author("fg,Gordon@tuoyun.net").
** time(2021/5/11 15:37).
- */
-package msgtransfer
+ */package msgtransfer
import (
"context"
@@ -35,7 +34,12 @@ func NewPersistentConsumerHandler(database controller.ChatLogDatabase) *Persiste
}
}
-func (pc *PersistentConsumerHandler) handleChatWs2Mysql(ctx context.Context, cMsg *sarama.ConsumerMessage, msgKey string, _ sarama.ConsumerGroupSession) {
+func (pc *PersistentConsumerHandler) handleChatWs2Mysql(
+ ctx context.Context,
+ cMsg *sarama.ConsumerMessage,
+ msgKey string,
+ _ sarama.ConsumerGroupSession,
+) {
msg := cMsg.Value
var tag bool
msgFromMQ := pbMsg.MsgDataToMQ{}
@@ -73,10 +77,25 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(ctx context.Context, cMs
}
func (PersistentConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
func (PersistentConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
-func (pc *PersistentConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error {
+
+func (pc *PersistentConsumerHandler) ConsumeClaim(
+ sess sarama.ConsumerGroupSession,
+ claim sarama.ConsumerGroupClaim,
+) error {
for msg := range claim.Messages() {
ctx := pc.persistentConsumerGroup.GetContextFromMsg(msg)
- log.ZDebug(ctx, "kafka get info to mysql", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value), "key", string(msg.Key))
+ log.ZDebug(
+ ctx,
+ "kafka get info to mysql",
+ "msgTopic",
+ msg.Topic,
+ "msgPartition",
+ msg.Partition,
+ "msg",
+ string(msg.Value),
+ "key",
+ string(msg.Key),
+ )
if len(msg.Value) != 0 {
pc.handleChatWs2Mysql(ctx, msg, string(msg.Key), sess)
} else {
diff --git a/internal/push/callback.go b/internal/push/callback.go
index db9f36c48..854d27fc2 100644
--- a/internal/push/callback.go
+++ b/internal/push/callback.go
@@ -17,7 +17,12 @@ func url() string {
return config.Config.Callback.CallbackUrl
}
-func callbackOfflinePush(ctx context.Context, userIDs []string, msg *sdkws.MsgData, offlinePushUserIDs *[]string) error {
+func callbackOfflinePush(
+ ctx context.Context,
+ userIDs []string,
+ msg *sdkws.MsgData,
+ offlinePushUserIDs *[]string,
+) error {
if !config.Config.Callback.CallbackOfflinePush.Enable {
return nil
}
@@ -82,7 +87,12 @@ func callbackOnlinePush(ctx context.Context, userIDs []string, msg *sdkws.MsgDat
return http.CallBackPostReturn(ctx, url(), req, resp, config.Config.Callback.CallbackOnlinePush)
}
-func callbackBeforeSuperGroupOnlinePush(ctx context.Context, groupID string, msg *sdkws.MsgData, pushToUserIDs *[]string) error {
+func callbackBeforeSuperGroupOnlinePush(
+ ctx context.Context,
+ groupID string,
+ msg *sdkws.MsgData,
+ pushToUserIDs *[]string,
+) error {
if !config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.Enable {
return nil
}
diff --git a/internal/push/consumer_init.go b/internal/push/consumer_init.go
index 283cf1d1b..a76de754f 100644
--- a/internal/push/consumer_init.go
+++ b/internal/push/consumer_init.go
@@ -21,6 +21,7 @@ func (c *Consumer) initPrometheus() {
}
func (c *Consumer) Start() {
- //statistics.NewStatistics(&c.successCount, config.Config.ModuleName.PushName, fmt.Sprintf("%d second push to msg_gateway count", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
+ // statistics.NewStatistics(&c.successCount, config.Config.ModuleName.PushName, fmt.Sprintf("%d second push to
+ // msg_gateway count", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
go c.pushCh.pushConsumerGroup.RegisterHandleAndConsumer(&c.pushCh)
}
diff --git a/internal/push/offlinepush/fcm/push.go b/internal/push/offlinepush/fcm/push.go
index 1d8478f31..63e945d98 100644
--- a/internal/push/offlinepush/fcm/push.go
+++ b/internal/push/offlinepush/fcm/push.go
@@ -6,12 +6,13 @@ import (
firebase "firebase.google.com/go"
"firebase.google.com/go/messaging"
+ "github.com/redis/go-redis/v9"
+ "google.golang.org/api/option"
+
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
- "github.com/redis/go-redis/v9"
- "google.golang.org/api/option"
)
const SinglePushCountLimit = 400
diff --git a/internal/push/offlinepush/fcm/push_test.go b/internal/push/offlinepush/fcm/push_test.go
index 1a7240302..5cef4ef2b 100644
--- a/internal/push/offlinepush/fcm/push_test.go
+++ b/internal/push/offlinepush/fcm/push_test.go
@@ -4,9 +4,10 @@ import (
"context"
"testing"
+ "github.com/stretchr/testify/assert"
+
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
- "github.com/stretchr/testify/assert"
)
func Test_Push(t *testing.T) {
diff --git a/internal/push/offlinepush/getui/push.go b/internal/push/offlinepush/getui/push.go
index 54bd83673..17278a4ff 100644
--- a/internal/push/offlinepush/getui/push.go
+++ b/internal/push/offlinepush/getui/push.go
@@ -99,7 +99,9 @@ func (g *Client) Push(ctx context.Context, userIDs []string, title, content stri
func (g *Client) Auth(ctx context.Context, timeStamp int64) (token string, expireTime int64, err error) {
h := sha256.New()
- h.Write([]byte(config.Config.Push.GeTui.AppKey + strconv.Itoa(int(timeStamp)) + config.Config.Push.GeTui.MasterSecret))
+ h.Write(
+ []byte(config.Config.Push.GeTui.AppKey + strconv.Itoa(int(timeStamp)) + config.Config.Push.GeTui.MasterSecret),
+ )
sign := hex.EncodeToString(h.Sum(nil))
reqAuth := AuthReq{
Sign: sign,
@@ -150,7 +152,14 @@ func (g *Client) request(ctx context.Context, url string, input interface{}, tok
return g.postReturn(ctx, config.Config.Push.GeTui.PushUrl+url, header, input, resp, 3)
}
-func (g *Client) postReturn(ctx context.Context, url string, header map[string]string, input interface{}, output RespI, timeout int) error {
+func (g *Client) postReturn(
+ ctx context.Context,
+ url string,
+ header map[string]string,
+ input interface{},
+ output RespI,
+ timeout int,
+) error {
err := http2.PostReturn(ctx, url, header, input, output, timeout)
if err != nil {
return err
diff --git a/internal/push/offlinepush/jpush/push.go b/internal/push/offlinepush/jpush/push.go
index 75fc2b27b..e22e97df4 100644
--- a/internal/push/offlinepush/jpush/push.go
+++ b/internal/push/offlinepush/jpush/push.go
@@ -60,5 +60,14 @@ func (j *JPush) Push(ctx context.Context, userIDs []string, title, content strin
}
func (j *JPush) request(ctx context.Context, po body.PushObj, resp interface{}, timeout int) error {
- return http2.PostReturn(ctx, config.Config.Push.Jpns.PushUrl, map[string]string{"Authorization": j.getAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret)}, po, resp, timeout)
+ return http2.PostReturn(
+ ctx,
+ config.Config.Push.Jpns.PushUrl,
+ map[string]string{
+ "Authorization": j.getAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret),
+ },
+ po,
+ resp,
+ timeout,
+ )
}
diff --git a/internal/push/push_handler.go b/internal/push/push_handler.go
index ac128a1c7..2d0694088 100644
--- a/internal/push/push_handler.go
+++ b/internal/push/push_handler.go
@@ -3,6 +3,9 @@ package push
import (
"context"
+ "github.com/Shopify/sarama"
+ "google.golang.org/protobuf/proto"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
kfk "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
@@ -10,8 +13,6 @@ import (
pbChat "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
pbPush "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/push"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/Shopify/sarama"
- "google.golang.org/protobuf/proto"
)
type ConsumerHandler struct {
diff --git a/internal/push/push_rpc_server.go b/internal/push/push_rpc_server.go
index ca45a58fa..08edc738e 100644
--- a/internal/push/push_rpc_server.go
+++ b/internal/push/push_rpc_server.go
@@ -4,6 +4,8 @@ import (
"context"
"sync"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@@ -12,7 +14,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
pbPush "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/push"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
- "google.golang.org/grpc"
)
type pushServer struct {
@@ -30,7 +31,16 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
groupRpcClient := rpcclient.NewGroupRpcClient(client)
conversationRpcClient := rpcclient.NewConversationRpcClient(client)
msgRpcClient := rpcclient.NewMessageRpcClient(client)
- pusher := NewPusher(client, offlinePusher, database, localcache.NewGroupLocalCache(&groupRpcClient), localcache.NewConversationLocalCache(&conversationRpcClient), &conversationRpcClient, &groupRpcClient, &msgRpcClient)
+ pusher := NewPusher(
+ client,
+ offlinePusher,
+ database,
+ localcache.NewGroupLocalCache(&groupRpcClient),
+ localcache.NewConversationLocalCache(&conversationRpcClient),
+ &conversationRpcClient,
+ &groupRpcClient,
+ &msgRpcClient,
+ )
var wg sync.WaitGroup
wg.Add(2)
go func() {
@@ -66,7 +76,10 @@ func (r *pushServer) PushMsg(ctx context.Context, pbData *pbPush.PushMsgReq) (re
return &pbPush.PushMsgResp{}, nil
}
-func (r *pushServer) DelUserPushToken(ctx context.Context, req *pbPush.DelUserPushTokenReq) (resp *pbPush.DelUserPushTokenResp, err error) {
+func (r *pushServer) DelUserPushToken(
+ ctx context.Context,
+ req *pbPush.DelUserPushTokenReq,
+) (resp *pbPush.DelUserPushTokenResp, err error) {
if err = r.pusher.database.DelFcmToken(ctx, req.UserID, int(req.PlatformID)); err != nil {
return nil, err
}
diff --git a/internal/push/push_to_client.go b/internal/push/push_to_client.go
index 7f08ee0aa..3cc91d20f 100644
--- a/internal/push/push_to_client.go
+++ b/internal/push/push_to_client.go
@@ -38,9 +38,16 @@ type Pusher struct {
var errNoOfflinePusher = errors.New("no offlinePusher is configured")
-func NewPusher(discov discoveryregistry.SvcDiscoveryRegistry, offlinePusher offlinepush.OfflinePusher, database controller.PushDatabase,
- groupLocalCache *localcache.GroupLocalCache, conversationLocalCache *localcache.ConversationLocalCache,
- conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient, msgRpcClient *rpcclient.MessageRpcClient) *Pusher {
+func NewPusher(
+ discov discoveryregistry.SvcDiscoveryRegistry,
+ offlinePusher offlinepush.OfflinePusher,
+ database controller.PushDatabase,
+ groupLocalCache *localcache.GroupLocalCache,
+ conversationLocalCache *localcache.ConversationLocalCache,
+ conversationRpcClient *rpcclient.ConversationRpcClient,
+ groupRpcClient *rpcclient.GroupRpcClient,
+ msgRpcClient *rpcclient.MessageRpcClient,
+) *Pusher {
return &Pusher{
discov: discov,
database: database,
@@ -87,7 +94,18 @@ func (p *Pusher) Push2User(ctx context.Context, userIDs []string, msg *sdkws.Msg
return err
}
isOfflinePush := utils.GetSwitchFromOptions(msg.Options, constant.IsOfflinePush)
- log.ZDebug(ctx, "push_result", "ws push result", wsResults, "sendData", msg, "isOfflinePush", isOfflinePush, "push_to_userID", userIDs)
+ log.ZDebug(
+ ctx,
+ "push_result",
+ "ws push result",
+ wsResults,
+ "sendData",
+ msg,
+ "isOfflinePush",
+ isOfflinePush,
+ "push_to_userID",
+ userIDs,
+ )
p.successCount++
for _, userID := range userIDs {
if isOfflinePush && userID != msg.SendID {
@@ -138,7 +156,15 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
}
defer func(groupID string, userIDs []string) {
if err := p.DeleteMemberAndSetConversationSeq(ctx, groupID, userIDs); err != nil {
- log.ZError(ctx, "MemberQuitNotification DeleteMemberAndSetConversationSeq", err, "groupID", groupID, "userIDs", userIDs)
+ log.ZError(
+ ctx,
+ "MemberQuitNotification DeleteMemberAndSetConversationSeq",
+ err,
+ "groupID",
+ groupID,
+ "userIDs",
+ userIDs,
+ )
}
}(groupID, []string{tips.QuitUser.UserID})
pushToUserIDs = append(pushToUserIDs, tips.QuitUser.UserID)
@@ -147,10 +173,21 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
if p.UnmarshalNotificationElem(msg.Content, &tips) != nil {
return err
}
- kickedUsers := utils.Slice(tips.KickedUserList, func(e *sdkws.GroupMemberFullInfo) string { return e.UserID })
+ kickedUsers := utils.Slice(
+ tips.KickedUserList,
+ func(e *sdkws.GroupMemberFullInfo) string { return e.UserID },
+ )
defer func(groupID string, userIDs []string) {
if err := p.DeleteMemberAndSetConversationSeq(ctx, groupID, userIDs); err != nil {
- log.ZError(ctx, "MemberKickedNotification DeleteMemberAndSetConversationSeq", err, "groupID", groupID, "userIDs", userIDs)
+ log.ZError(
+ ctx,
+ "MemberKickedNotification DeleteMemberAndSetConversationSeq",
+ err,
+ "groupID",
+ groupID,
+ "userIDs",
+ userIDs,
+ )
}
}(groupID, kickedUsers)
pushToUserIDs = append(pushToUserIDs, kickedUsers...)
@@ -160,7 +197,16 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
if p.UnmarshalNotificationElem(msg.Content, &tips) != nil {
return err
}
- log.ZInfo(ctx, "GroupDismissedNotificationInfo****", "groupID", groupID, "num", len(pushToUserIDs), "list", pushToUserIDs)
+ log.ZInfo(
+ ctx,
+ "GroupDismissedNotificationInfo****",
+ "groupID",
+ groupID,
+ "num",
+ len(pushToUserIDs),
+ "list",
+ pushToUserIDs,
+ )
if len(config.Config.Manager.UserID) > 0 {
ctx = mcontext.WithOpUserIDContext(ctx, config.Config.Manager.UserID[0])
}
@@ -224,9 +270,23 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
log.ZError(ctx, "offlinePushMsg failed", err, "groupID", groupID, "msg", msg)
return err
}
- _, err := p.GetConnsAndOnlinePush(ctx, msg, utils.IntersectString(needOfflinePushUserIDs, WebAndPcBackgroundUserIDs))
+ _, err := p.GetConnsAndOnlinePush(
+ ctx,
+ msg,
+ utils.IntersectString(needOfflinePushUserIDs, WebAndPcBackgroundUserIDs),
+ )
if err != nil {
- log.ZError(ctx, "offlinePushMsg failed", err, "groupID", groupID, "msg", msg, "userIDs", utils.IntersectString(needOfflinePushUserIDs, WebAndPcBackgroundUserIDs))
+ log.ZError(
+ ctx,
+ "offlinePushMsg failed",
+ err,
+ "groupID",
+ groupID,
+ "msg",
+ msg,
+ "userIDs",
+ utils.IntersectString(needOfflinePushUserIDs, WebAndPcBackgroundUserIDs),
+ )
return err
}
}
@@ -234,7 +294,11 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
return nil
}
-func (p *Pusher) GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData, pushToUserIDs []string) (wsResults []*msggateway.SingleMsgToUserResults, err error) {
+func (p *Pusher) GetConnsAndOnlinePush(
+ ctx context.Context,
+ msg *sdkws.MsgData,
+ pushToUserIDs []string,
+) (wsResults []*msggateway.SingleMsgToUserResults, err error) {
conns, err := p.discov.GetConns(ctx, config.Config.RpcRegisterName.OpenImMessageGatewayName)
log.ZDebug(ctx, "get gateway conn", "conn length", len(conns))
if err != nil {
@@ -243,7 +307,10 @@ func (p *Pusher) GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData,
//Online push message
for _, v := range conns {
msgClient := msggateway.NewMsgGatewayClient(v)
- reply, err := msgClient.SuperGroupOnlineBatchPushOneMsg(ctx, &msggateway.OnlineBatchPushOneMsgReq{MsgData: msg, PushToUserIDs: pushToUserIDs})
+ reply, err := msgClient.SuperGroupOnlineBatchPushOneMsg(
+ ctx,
+ &msggateway.OnlineBatchPushOneMsgReq{MsgData: msg, PushToUserIDs: pushToUserIDs},
+ )
p.discov.CloseConn(v)
if err != nil {
continue
@@ -257,7 +324,12 @@ func (p *Pusher) GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData,
return wsResults, nil
}
-func (p *Pusher) offlinePushMsg(ctx context.Context, conversationID string, msg *sdkws.MsgData, offlinePushUserIDs []string) error {
+func (p *Pusher) offlinePushMsg(
+ ctx context.Context,
+ conversationID string,
+ msg *sdkws.MsgData,
+ offlinePushUserIDs []string,
+) error {
title, content, opts, err := p.getOfflinePushInfos(conversationID, msg)
if err != nil {
return err
@@ -291,7 +363,10 @@ func (p *Pusher) GetOfflinePushOpts(msg *sdkws.MsgData) (opts *offlinepush.Opts,
return opts, nil
}
-func (p *Pusher) getOfflinePushInfos(conversationID string, msg *sdkws.MsgData) (title, content string, opts *offlinepush.Opts, err error) {
+func (p *Pusher) getOfflinePushInfos(
+ conversationID string,
+ msg *sdkws.MsgData,
+) (title, content string, opts *offlinepush.Opts, err error) {
if p.offlinePusher == nil {
err = errNoOfflinePusher
return
diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go
index 378bbfcb3..2e0b7fe53 100644
--- a/internal/rpc/auth/auth.go
+++ b/internal/rpc/auth/auth.go
@@ -3,6 +3,8 @@ package auth
import (
"context"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
@@ -15,7 +17,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msggateway"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "google.golang.org/grpc"
)
type authServer struct {
@@ -33,7 +34,11 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
pbAuth.RegisterAuthServer(server, &authServer{
userRpcClient: &userRpcClient,
RegisterCenter: client,
- authDatabase: controller.NewAuthDatabase(cache.NewMsgCacheModel(rdb), config.Config.Secret, config.Config.TokenPolicy.Expire),
+ authDatabase: controller.NewAuthDatabase(
+ cache.NewMsgCacheModel(rdb),
+ config.Config.Secret,
+ config.Config.TokenPolicy.Expire,
+ ),
})
return nil
}
@@ -80,7 +85,10 @@ func (s *authServer) parseToken(ctx context.Context, tokensString string) (claim
return nil, errs.ErrTokenNotExist.Wrap()
}
-func (s *authServer) ParseToken(ctx context.Context, req *pbAuth.ParseTokenReq) (resp *pbAuth.ParseTokenResp, err error) {
+func (s *authServer) ParseToken(
+ ctx context.Context,
+ req *pbAuth.ParseTokenReq,
+) (resp *pbAuth.ParseTokenResp, err error) {
resp = &pbAuth.ParseTokenResp{}
claims, err := s.parseToken(ctx, req.Token)
if err != nil {
diff --git a/internal/rpc/conversation/conversaion.go b/internal/rpc/conversation/conversaion.go
index c5a454d4d..11859136f 100644
--- a/internal/rpc/conversation/conversaion.go
+++ b/internal/rpc/conversation/conversaion.go
@@ -3,6 +3,8 @@ package conversation
import (
"context"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
@@ -17,7 +19,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "google.golang.org/grpc"
)
type conversationServer struct {
@@ -44,12 +45,19 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
pbConversation.RegisterConversationServer(server, &conversationServer{
conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient),
groupRpcClient: &groupRpcClient,
- conversationDatabase: controller.NewConversationDatabase(conversationDB, cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), conversationDB), tx.NewGorm(db)),
+ conversationDatabase: controller.NewConversationDatabase(
+ conversationDB,
+ cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), conversationDB),
+ tx.NewGorm(db),
+ ),
})
return nil
}
-func (c *conversationServer) GetConversation(ctx context.Context, req *pbConversation.GetConversationReq) (*pbConversation.GetConversationResp, error) {
+func (c *conversationServer) GetConversation(
+ ctx context.Context,
+ req *pbConversation.GetConversationReq,
+) (*pbConversation.GetConversationResp, error) {
conversations, err := c.conversationDatabase.FindConversations(ctx, req.OwnerUserID, []string{req.ConversationID})
if err != nil {
return nil, err
@@ -62,7 +70,10 @@ func (c *conversationServer) GetConversation(ctx context.Context, req *pbConvers
return resp, nil
}
-func (c *conversationServer) GetAllConversations(ctx context.Context, req *pbConversation.GetAllConversationsReq) (*pbConversation.GetAllConversationsResp, error) {
+func (c *conversationServer) GetAllConversations(
+ ctx context.Context,
+ req *pbConversation.GetAllConversationsReq,
+) (*pbConversation.GetAllConversationsResp, error) {
conversations, err := c.conversationDatabase.GetUserAllConversation(ctx, req.OwnerUserID)
if err != nil {
return nil, err
@@ -72,7 +83,10 @@ func (c *conversationServer) GetAllConversations(ctx context.Context, req *pbCon
return resp, nil
}
-func (c *conversationServer) GetConversations(ctx context.Context, req *pbConversation.GetConversationsReq) (*pbConversation.GetConversationsResp, error) {
+func (c *conversationServer) GetConversations(
+ ctx context.Context,
+ req *pbConversation.GetConversationsReq,
+) (*pbConversation.GetConversationsResp, error) {
conversations, err := c.conversationDatabase.FindConversations(ctx, req.OwnerUserID, req.ConversationIDs)
if err != nil {
return nil, err
@@ -82,7 +96,10 @@ func (c *conversationServer) GetConversations(ctx context.Context, req *pbConver
return resp, nil
}
-func (c *conversationServer) BatchSetConversations(ctx context.Context, req *pbConversation.BatchSetConversationsReq) (*pbConversation.BatchSetConversationsResp, error) {
+func (c *conversationServer) BatchSetConversations(
+ ctx context.Context,
+ req *pbConversation.BatchSetConversationsReq,
+) (*pbConversation.BatchSetConversationsResp, error) {
conversations := convert.ConversationsPb2DB(req.Conversations)
err := c.conversationDatabase.SetUserConversations(ctx, req.OwnerUserID, conversations)
if err != nil {
@@ -92,12 +109,19 @@ func (c *conversationServer) BatchSetConversations(ctx context.Context, req *pbC
return &pbConversation.BatchSetConversationsResp{}, nil
}
-func (c *conversationServer) SetConversation(ctx context.Context, req *pbConversation.SetConversationReq) (*pbConversation.SetConversationResp, error) {
+func (c *conversationServer) SetConversation(
+ ctx context.Context,
+ req *pbConversation.SetConversationReq,
+) (*pbConversation.SetConversationResp, error) {
var conversation tableRelation.ConversationModel
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
return nil, err
}
- err := c.conversationDatabase.SetUserConversations(ctx, req.Conversation.OwnerUserID, []*tableRelation.ConversationModel{&conversation})
+ err := c.conversationDatabase.SetUserConversations(
+ ctx,
+ req.Conversation.OwnerUserID,
+ []*tableRelation.ConversationModel{&conversation},
+ )
if err != nil {
return nil, err
}
@@ -106,7 +130,10 @@ func (c *conversationServer) SetConversation(ctx context.Context, req *pbConvers
return resp, nil
}
-func (c *conversationServer) SetRecvMsgOpt(ctx context.Context, req *pbConversation.SetRecvMsgOptReq) (*pbConversation.SetRecvMsgOptResp, error) {
+func (c *conversationServer) SetRecvMsgOpt(
+ ctx context.Context,
+ req *pbConversation.SetRecvMsgOptReq,
+) (*pbConversation.SetRecvMsgOptResp, error) {
if err := c.conversationDatabase.SetUsersConversationFiledTx(ctx, []string{req.OwnerUserID}, &tableRelation.ConversationModel{OwnerUserID: req.OwnerUserID, ConversationID: req.ConversationID, RecvMsgOpt: req.RecvMsgOpt}, map[string]interface{}{"recv_msg_opt": req.RecvMsgOpt}); err != nil {
return nil, err
}
@@ -115,7 +142,10 @@ func (c *conversationServer) SetRecvMsgOpt(ctx context.Context, req *pbConversat
}
// deprecated
-func (c *conversationServer) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) (*pbConversation.ModifyConversationFieldResp, error) {
+func (c *conversationServer) ModifyConversationField(
+ ctx context.Context,
+ req *pbConversation.ModifyConversationFieldReq,
+) (*pbConversation.ModifyConversationFieldResp, error) {
resp := &pbConversation.ModifyConversationFieldResp{}
var err error
if req.Conversation.ConversationType == constant.GroupChatType {
@@ -129,11 +159,19 @@ func (c *conversationServer) ModifyConversationField(ctx context.Context, req *p
}
conversation := convert.ConversationPb2DB(req.Conversation)
if req.FieldType == constant.FieldIsPrivateChat {
- err := c.conversationDatabase.SyncPeerUserPrivateConversationTx(ctx, []*tableRelation.ConversationModel{conversation})
+ err := c.conversationDatabase.SyncPeerUserPrivateConversationTx(
+ ctx,
+ []*tableRelation.ConversationModel{conversation},
+ )
if err != nil {
return nil, err
}
- c.conversationNotificationSender.ConversationSetPrivateNotification(ctx, req.Conversation.OwnerUserID, req.Conversation.UserID, req.Conversation.IsPrivateChat)
+ c.conversationNotificationSender.ConversationSetPrivateNotification(
+ ctx,
+ req.Conversation.OwnerUserID,
+ req.Conversation.UserID,
+ req.Conversation.IsPrivateChat,
+ )
return resp, nil
}
filedMap := make(map[string]interface{})
@@ -161,7 +199,10 @@ func (c *conversationServer) ModifyConversationField(ctx context.Context, req *p
return resp, nil
}
-func (c *conversationServer) SetConversations(ctx context.Context, req *pbConversation.SetConversationsReq) (*pbConversation.SetConversationsResp, error) {
+func (c *conversationServer) SetConversations(
+ ctx context.Context,
+ req *pbConversation.SetConversationsReq,
+) (*pbConversation.SetConversationsResp, error) {
if req.Conversation == nil {
return nil, errs.ErrArgs.Wrap("conversation must not be nil")
}
@@ -207,7 +248,12 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbConver
return nil, err
}
for _, ownerUserID := range req.UserIDs {
- c.conversationNotificationSender.ConversationSetPrivateNotification(ctx, ownerUserID, req.Conversation.UserID, req.Conversation.IsPrivateChat.Value)
+ c.conversationNotificationSender.ConversationSetPrivateNotification(
+ ctx,
+ ownerUserID,
+ req.Conversation.UserID,
+ req.Conversation.IsPrivateChat.Value,
+ )
}
}
if req.Conversation.BurnDuration != nil {
@@ -224,7 +270,10 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbConver
}
// 获取超级大群开启免打扰的用户ID
-func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req *pbConversation.GetRecvMsgNotNotifyUserIDsReq) (*pbConversation.GetRecvMsgNotNotifyUserIDsResp, error) {
+func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(
+ ctx context.Context,
+ req *pbConversation.GetRecvMsgNotNotifyUserIDsReq,
+) (*pbConversation.GetRecvMsgNotNotifyUserIDsResp, error) {
userIDs, err := c.conversationDatabase.FindRecvMsgNotNotifyUserIDs(ctx, req.GroupID)
if err != nil {
return nil, err
@@ -233,7 +282,10 @@ func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req
}
// create conversation without notification for msg redis transfer
-func (c *conversationServer) CreateSingleChatConversations(ctx context.Context, req *pbConversation.CreateSingleChatConversationsReq) (*pbConversation.CreateSingleChatConversationsResp, error) {
+func (c *conversationServer) CreateSingleChatConversations(
+ ctx context.Context,
+ req *pbConversation.CreateSingleChatConversationsReq,
+) (*pbConversation.CreateSingleChatConversationsResp, error) {
var conversation tableRelation.ConversationModel
conversation.ConversationID = utils.GetConversationIDBySessionType(constant.SingleChatType, req.RecvID, req.SendID)
conversation.ConversationType = constant.SingleChatType
@@ -254,7 +306,10 @@ func (c *conversationServer) CreateSingleChatConversations(ctx context.Context,
return &pbConversation.CreateSingleChatConversationsResp{}, nil
}
-func (c *conversationServer) CreateGroupChatConversations(ctx context.Context, req *pbConversation.CreateGroupChatConversationsReq) (*pbConversation.CreateGroupChatConversationsResp, error) {
+func (c *conversationServer) CreateGroupChatConversations(
+ ctx context.Context,
+ req *pbConversation.CreateGroupChatConversationsReq,
+) (*pbConversation.CreateGroupChatConversationsResp, error) {
err := c.conversationDatabase.CreateGroupChatConversation(ctx, req.GroupID, req.UserIDs)
if err != nil {
return nil, err
@@ -262,7 +317,10 @@ func (c *conversationServer) CreateGroupChatConversations(ctx context.Context, r
return &pbConversation.CreateGroupChatConversationsResp{}, nil
}
-func (c *conversationServer) SetConversationMaxSeq(ctx context.Context, req *pbConversation.SetConversationMaxSeqReq) (*pbConversation.SetConversationMaxSeqResp, error) {
+func (c *conversationServer) SetConversationMaxSeq(
+ ctx context.Context,
+ req *pbConversation.SetConversationMaxSeqReq,
+) (*pbConversation.SetConversationMaxSeqResp, error) {
if err := c.conversationDatabase.UpdateUsersConversationFiled(ctx, req.OwnerUserID, req.ConversationID,
map[string]interface{}{"max_seq": req.MaxSeq}); err != nil {
return nil, err
@@ -270,7 +328,10 @@ func (c *conversationServer) SetConversationMaxSeq(ctx context.Context, req *pbC
return &pbConversation.SetConversationMaxSeqResp{}, nil
}
-func (c *conversationServer) GetConversationIDs(ctx context.Context, req *pbConversation.GetConversationIDsReq) (*pbConversation.GetConversationIDsResp, error) {
+func (c *conversationServer) GetConversationIDs(
+ ctx context.Context,
+ req *pbConversation.GetConversationIDsReq,
+) (*pbConversation.GetConversationIDsResp, error) {
conversationIDs, err := c.conversationDatabase.GetConversationIDs(ctx, req.UserID)
if err != nil {
return nil, err
@@ -278,7 +339,10 @@ func (c *conversationServer) GetConversationIDs(ctx context.Context, req *pbConv
return &pbConversation.GetConversationIDsResp{ConversationIDs: conversationIDs}, nil
}
-func (c *conversationServer) GetUserConversationIDsHash(ctx context.Context, req *pbConversation.GetUserConversationIDsHashReq) (*pbConversation.GetUserConversationIDsHashResp, error) {
+func (c *conversationServer) GetUserConversationIDsHash(
+ ctx context.Context,
+ req *pbConversation.GetUserConversationIDsHashReq,
+) (*pbConversation.GetUserConversationIDsHashResp, error) {
hash, err := c.conversationDatabase.GetUserConversationIDsHash(ctx, req.OwnerUserID)
if err != nil {
return nil, err
@@ -286,10 +350,15 @@ func (c *conversationServer) GetUserConversationIDsHash(ctx context.Context, req
return &pbConversation.GetUserConversationIDsHashResp{Hash: hash}, nil
}
-func (c *conversationServer) GetConversationsByConversationID(ctx context.Context, req *pbConversation.GetConversationsByConversationIDReq) (*pbConversation.GetConversationsByConversationIDResp, error) {
+func (c *conversationServer) GetConversationsByConversationID(
+ ctx context.Context,
+ req *pbConversation.GetConversationsByConversationIDReq,
+) (*pbConversation.GetConversationsByConversationIDResp, error) {
conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, req.ConversationIDs)
if err != nil {
return nil, err
}
- return &pbConversation.GetConversationsByConversationIDResp{Conversations: convert.ConversationsDB2Pb(conversations)}, nil
+ return &pbConversation.GetConversationsByConversationIDResp{
+ Conversations: convert.ConversationsDB2Pb(conversations),
+ }, nil
}
diff --git a/internal/rpc/friend/black.go b/internal/rpc/friend/black.go
index 692e83439..784e32d20 100644
--- a/internal/rpc/friend/black.go
+++ b/internal/rpc/friend/black.go
@@ -11,7 +11,10 @@ import (
pbFriend "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
)
-func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *pbFriend.GetPaginationBlacksReq) (resp *pbFriend.GetPaginationBlacksResp, err error) {
+func (s *friendServer) GetPaginationBlacks(
+ ctx context.Context,
+ req *pbFriend.GetPaginationBlacksReq,
+) (resp *pbFriend.GetPaginationBlacksResp, err error) {
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
return nil, err
}
@@ -44,7 +47,10 @@ func (s *friendServer) IsBlack(ctx context.Context, req *pbFriend.IsBlackReq) (*
return resp, nil
}
-func (s *friendServer) RemoveBlack(ctx context.Context, req *pbFriend.RemoveBlackReq) (*pbFriend.RemoveBlackResp, error) {
+func (s *friendServer) RemoveBlack(
+ ctx context.Context,
+ req *pbFriend.RemoveBlackReq,
+) (*pbFriend.RemoveBlackResp, error) {
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
return nil, err
}
@@ -63,7 +69,12 @@ func (s *friendServer) AddBlack(ctx context.Context, req *pbFriend.AddBlackReq)
if err != nil {
return nil, err
}
- black := relation.BlackModel{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID, OperatorUserID: mcontext.GetOpUserID(ctx), CreateTime: time.Now()}
+ black := relation.BlackModel{
+ OwnerUserID: req.OwnerUserID,
+ BlockUserID: req.BlackUserID,
+ OperatorUserID: mcontext.GetOpUserID(ctx),
+ CreateTime: time.Now(),
+ }
if err := s.blackDatabase.Create(ctx, []*relation.BlackModel{&black}); err != nil {
return nil, err
}
diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go
index 7c3723583..da99fd34c 100644
--- a/internal/rpc/friend/friend.go
+++ b/internal/rpc/friend/friend.go
@@ -7,6 +7,8 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@@ -19,7 +21,6 @@ import (
pbfriend "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "google.golang.org/grpc"
)
type friendServer struct {
@@ -46,10 +47,21 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
friendDB := relation.NewFriendGorm(db)
userRpcClient := rpcclient.NewUserRpcClient(client)
msgRpcClient := rpcclient.NewMessageRpcClient(client)
- notificationSender := notification.NewFriendNotificationSender(&msgRpcClient, notification.WithRpcFunc(userRpcClient.GetUsersInfo))
+ notificationSender := notification.NewFriendNotificationSender(
+ &msgRpcClient,
+ notification.WithRpcFunc(userRpcClient.GetUsersInfo),
+ )
pbfriend.RegisterFriendServer(server, &friendServer{
- friendDatabase: controller.NewFriendDatabase(friendDB, relation.NewFriendRequestGorm(db), cache.NewFriendCacheRedis(rdb, friendDB, cache.GetDefaultOpt()), tx.NewGorm(db)),
- blackDatabase: controller.NewBlackDatabase(blackDB, cache.NewBlackCacheRedis(rdb, blackDB, cache.GetDefaultOpt())),
+ friendDatabase: controller.NewFriendDatabase(
+ friendDB,
+ relation.NewFriendRequestGorm(db),
+ cache.NewFriendCacheRedis(rdb, friendDB, cache.GetDefaultOpt()),
+ tx.NewGorm(db),
+ ),
+ blackDatabase: controller.NewBlackDatabase(
+ blackDB,
+ cache.NewBlackCacheRedis(rdb, blackDB, cache.GetDefaultOpt()),
+ ),
userRpcClient: &userRpcClient,
notificationSender: notificationSender,
RegisterCenter: client,
@@ -58,7 +70,10 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
}
// ok
-func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) (resp *pbfriend.ApplyToAddFriendResp, err error) {
+func (s *friendServer) ApplyToAddFriend(
+ ctx context.Context,
+ req *pbfriend.ApplyToAddFriendReq,
+) (resp *pbfriend.ApplyToAddFriendResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.ApplyToAddFriendResp{}
if err := tokenverify.CheckAccessV3(ctx, req.FromUserID); err != nil {
@@ -88,7 +103,10 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.Apply
}
// ok
-func (s *friendServer) ImportFriends(ctx context.Context, req *pbfriend.ImportFriendReq) (resp *pbfriend.ImportFriendResp, err error) {
+func (s *friendServer) ImportFriends(
+ ctx context.Context,
+ req *pbfriend.ImportFriendReq,
+) (resp *pbfriend.ImportFriendResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
if err := tokenverify.CheckAdmin(ctx); err != nil {
return nil, err
@@ -111,14 +129,22 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbfriend.ImportFr
}
// ok
-func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbfriend.RespondFriendApplyReq) (resp *pbfriend.RespondFriendApplyResp, err error) {
+func (s *friendServer) RespondFriendApply(
+ ctx context.Context,
+ req *pbfriend.RespondFriendApplyReq,
+) (resp *pbfriend.RespondFriendApplyResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.RespondFriendApplyResp{}
if err := tokenverify.CheckAccessV3(ctx, req.ToUserID); err != nil {
return nil, err
}
- friendRequest := tablerelation.FriendRequestModel{FromUserID: req.FromUserID, ToUserID: req.ToUserID, HandleMsg: req.HandleMsg, HandleResult: req.HandleResult}
+ friendRequest := tablerelation.FriendRequestModel{
+ FromUserID: req.FromUserID,
+ ToUserID: req.ToUserID,
+ HandleMsg: req.HandleMsg,
+ HandleResult: req.HandleResult,
+ }
if req.HandleResult == constant.FriendResponseAgree {
err := s.friendDatabase.AgreeFriendRequest(ctx, &friendRequest)
if err != nil {
@@ -139,7 +165,10 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbfriend.Res
}
// ok
-func (s *friendServer) DeleteFriend(ctx context.Context, req *pbfriend.DeleteFriendReq) (resp *pbfriend.DeleteFriendResp, err error) {
+func (s *friendServer) DeleteFriend(
+ ctx context.Context,
+ req *pbfriend.DeleteFriendReq,
+) (resp *pbfriend.DeleteFriendResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.DeleteFriendResp{}
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
@@ -157,7 +186,10 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbfriend.DeleteFri
}
// ok
-func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFriendRemarkReq) (resp *pbfriend.SetFriendRemarkResp, err error) {
+func (s *friendServer) SetFriendRemark(
+ ctx context.Context,
+ req *pbfriend.SetFriendRemarkReq,
+) (resp *pbfriend.SetFriendRemarkResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.SetFriendRemarkResp{}
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
@@ -175,7 +207,10 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFri
}
// ok
-func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbfriend.GetDesignatedFriendsReq) (resp *pbfriend.GetDesignatedFriendsResp, err error) {
+func (s *friendServer) GetDesignatedFriends(
+ ctx context.Context,
+ req *pbfriend.GetDesignatedFriendsReq,
+) (resp *pbfriend.GetDesignatedFriendsResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.GetDesignatedFriendsResp{}
if utils.Duplicate(req.FriendUserIDs) {
@@ -192,7 +227,10 @@ func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbfriend.G
}
// ok 获取接收到的好友申请(即别人主动申请的)
-func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyToReq) (resp *pbfriend.GetPaginationFriendsApplyToResp, err error) {
+func (s *friendServer) GetPaginationFriendsApplyTo(
+ ctx context.Context,
+ req *pbfriend.GetPaginationFriendsApplyToReq,
+) (resp *pbfriend.GetPaginationFriendsApplyToResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.GetPaginationFriendsApplyToResp{}
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
@@ -212,7 +250,10 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbf
}
// ok 获取主动发出去的好友申请列表
-func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyFromReq) (resp *pbfriend.GetPaginationFriendsApplyFromResp, err error) {
+func (s *friendServer) GetPaginationFriendsApplyFrom(
+ ctx context.Context,
+ req *pbfriend.GetPaginationFriendsApplyFromReq,
+) (resp *pbfriend.GetPaginationFriendsApplyFromResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.GetPaginationFriendsApplyFromResp{}
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
@@ -232,7 +273,10 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *p
}
// ok
-func (s *friendServer) IsFriend(ctx context.Context, req *pbfriend.IsFriendReq) (resp *pbfriend.IsFriendResp, err error) {
+func (s *friendServer) IsFriend(
+ ctx context.Context,
+ req *pbfriend.IsFriendReq,
+) (resp *pbfriend.IsFriendResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.IsFriendResp{}
resp.InUser1Friends, resp.InUser2Friends, err = s.friendDatabase.CheckIn(ctx, req.UserID1, req.UserID2)
@@ -243,7 +287,10 @@ func (s *friendServer) IsFriend(ctx context.Context, req *pbfriend.IsFriendReq)
}
// ok
-func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.GetPaginationFriendsReq) (resp *pbfriend.GetPaginationFriendsResp, err error) {
+func (s *friendServer) GetPaginationFriends(
+ ctx context.Context,
+ req *pbfriend.GetPaginationFriendsReq,
+) (resp *pbfriend.GetPaginationFriendsResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
return nil, err
@@ -262,7 +309,10 @@ func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.G
return resp, nil
}
-func (s *friendServer) GetFriendIDs(ctx context.Context, req *pbfriend.GetFriendIDsReq) (resp *pbfriend.GetFriendIDsResp, err error) {
+func (s *friendServer) GetFriendIDs(
+ ctx context.Context,
+ req *pbfriend.GetFriendIDsReq,
+) (resp *pbfriend.GetFriendIDsResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
return nil, err
diff --git a/internal/rpc/group/cache.go b/internal/rpc/group/cache.go
index 0bd3316be..0a13a45e5 100644
--- a/internal/rpc/group/cache.go
+++ b/internal/rpc/group/cache.go
@@ -7,7 +7,10 @@ import (
pbGroup "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
)
-func (s *groupServer) GetGroupInfoCache(ctx context.Context, req *pbGroup.GetGroupInfoCacheReq) (resp *pbGroup.GetGroupInfoCacheResp, err error) {
+func (s *groupServer) GetGroupInfoCache(
+ ctx context.Context,
+ req *pbGroup.GetGroupInfoCacheReq,
+) (resp *pbGroup.GetGroupInfoCacheResp, err error) {
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
if err != nil {
return nil, err
@@ -16,7 +19,10 @@ func (s *groupServer) GetGroupInfoCache(ctx context.Context, req *pbGroup.GetGro
return resp, nil
}
-func (s *groupServer) GetGroupMemberCache(ctx context.Context, req *pbGroup.GetGroupMemberCacheReq) (resp *pbGroup.GetGroupMemberCacheResp, err error) {
+func (s *groupServer) GetGroupMemberCache(
+ ctx context.Context,
+ req *pbGroup.GetGroupMemberCacheReq,
+) (resp *pbGroup.GetGroupMemberCacheResp, err error) {
members, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.GroupMemberID)
if err != nil {
return nil, err
diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go
index aa311e4e5..f61413f30 100644
--- a/internal/rpc/group/callback.go
+++ b/internal/rpc/group/callback.go
@@ -43,7 +43,13 @@ func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (
})
}
resp := &callbackstruct.CallbackBeforeCreateGroupResp{}
- err = http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeCreateGroup)
+ err = http.CallBackPostReturn(
+ ctx,
+ config.Config.Callback.CallbackUrl,
+ cbReq,
+ resp,
+ config.Config.Callback.CallbackBeforeCreateGroup,
+ )
if err != nil {
if err == errs.ErrCallbackContinue {
return nil
@@ -65,7 +71,11 @@ func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (
return nil
}
-func CallbackBeforeMemberJoinGroup(ctx context.Context, groupMember *relation.GroupMemberModel, groupEx string) (err error) {
+func CallbackBeforeMemberJoinGroup(
+ ctx context.Context,
+ groupMember *relation.GroupMemberModel,
+ groupEx string,
+) (err error) {
if !config.Config.Callback.CallbackBeforeMemberJoinGroup.Enable {
return nil
}
@@ -78,7 +88,13 @@ func CallbackBeforeMemberJoinGroup(ctx context.Context, groupMember *relation.Gr
GroupEx: groupEx,
}
resp := &callbackstruct.CallbackBeforeMemberJoinGroupResp{}
- err = http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackBeforeMemberJoinGroup)
+ err = http.CallBackPostReturn(
+ ctx,
+ config.Config.Callback.CallbackUrl,
+ callbackReq,
+ resp,
+ config.Config.Callback.CallbackBeforeMemberJoinGroup,
+ )
if err != nil {
if err == errs.ErrCallbackContinue {
return nil
@@ -118,7 +134,13 @@ func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *group.SetGroupMe
callbackReq.Ex = &req.Ex.Value
}
resp := &callbackstruct.CallbackBeforeSetGroupMemberInfoResp{}
- err = http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackBeforeSetGroupMemberInfo)
+ err = http.CallBackPostReturn(
+ ctx,
+ config.Config.Callback.CallbackUrl,
+ callbackReq,
+ resp,
+ config.Config.Callback.CallbackBeforeSetGroupMemberInfo,
+ )
if err != nil {
if err == errs.ErrCallbackContinue {
return nil
diff --git a/internal/rpc/group/convert.go b/internal/rpc/group/convert.go
index 849a8b72a..48e70357b 100644
--- a/internal/rpc/group/convert.go
+++ b/internal/rpc/group/convert.go
@@ -27,7 +27,10 @@ func (s *groupServer) groupDB2PB(group *relation.GroupModel, ownerUserID string,
}
}
-func (s *groupServer) groupMemberDB2PB(member *relation.GroupMemberModel, appMangerLevel int32) *sdkws.GroupMemberFullInfo {
+func (s *groupServer) groupMemberDB2PB(
+ member *relation.GroupMemberModel,
+ appMangerLevel int32,
+) *sdkws.GroupMemberFullInfo {
return &sdkws.GroupMemberFullInfo{
GroupID: member.GroupID,
UserID: member.UserID,
diff --git a/internal/rpc/group/fill.go b/internal/rpc/group/fill.go
index da82e9b5e..64092eeab 100644
--- a/internal/rpc/group/fill.go
+++ b/internal/rpc/group/fill.go
@@ -7,7 +7,12 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
-func (s *groupServer) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error) {
+func (s *groupServer) FindGroupMember(
+ ctx context.Context,
+ groupIDs []string,
+ userIDs []string,
+ roleLevels []int32,
+) ([]*relationTb.GroupMemberModel, error) {
members, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, userIDs, roleLevels)
if err != nil {
return nil, err
@@ -39,7 +44,11 @@ func (s *groupServer) FindGroupMember(ctx context.Context, groupIDs []string, us
return members, nil
}
-func (s *groupServer) TakeGroupMember(ctx context.Context, groupID string, userID string) (*relationTb.GroupMemberModel, error) {
+func (s *groupServer) TakeGroupMember(
+ ctx context.Context,
+ groupID string,
+ userID string,
+) (*relationTb.GroupMemberModel, error) {
member, err := s.GroupDatabase.TakeGroupMember(ctx, groupID, userID)
if err != nil {
return nil, err
@@ -79,7 +88,11 @@ func (s *groupServer) TakeGroupOwner(ctx context.Context, groupID string) (*rela
return owner, nil
}
-func (s *groupServer) PageGetGroupMember(ctx context.Context, groupID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) {
+func (s *groupServer) PageGetGroupMember(
+ ctx context.Context,
+ groupID string,
+ pageNumber, showNumber int32,
+) (uint32, []*relationTb.GroupMemberModel, error) {
total, members, err := s.GroupDatabase.PageGetGroupMember(ctx, groupID, pageNumber, showNumber)
if err != nil {
return 0, nil, err
diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go
index 0d242201d..56bc6cfad 100644
--- a/internal/rpc/group/group.go
+++ b/internal/rpc/group/group.go
@@ -15,6 +15,8 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@@ -29,7 +31,6 @@ import (
pbGroup "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "google.golang.org/grpc"
)
func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
@@ -55,13 +56,17 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
pbGroup.RegisterGroupServer(server, &groupServer{
GroupDatabase: database,
User: userRpcClient,
- Notification: notification.NewGroupNotificationSender(database, &msgRpcClient, func(ctx context.Context, userIDs []string) ([]notification.CommonUser, error) {
- users, err := userRpcClient.GetUsersInfo(ctx, userIDs)
- if err != nil {
- return nil, err
- }
- return utils.Slice(users, func(e *sdkws.UserInfo) notification.CommonUser { return e }), nil
- }),
+ Notification: notification.NewGroupNotificationSender(
+ database,
+ &msgRpcClient,
+ func(ctx context.Context, userIDs []string) ([]notification.CommonUser, error) {
+ users, err := userRpcClient.GetUsersInfo(ctx, userIDs)
+ if err != nil {
+ return nil, err
+ }
+ return utils.Slice(users, func(e *sdkws.UserInfo) notification.CommonUser { return e }), nil
+ },
+ ),
conversationRpcClient: conversationRpcClient,
msgRpcClient: msgRpcClient,
})
@@ -118,7 +123,16 @@ func (s *groupServer) GenGroupID(ctx context.Context, groupID *string) error {
}
}
for i := 0; i < 10; i++ {
- id := utils.Md5(strings.Join([]string{mcontext.GetOperationID(ctx), strconv.FormatInt(time.Now().UnixNano(), 10), strconv.Itoa(rand.Int())}, ",;,"))
+ id := utils.Md5(
+ strings.Join(
+ []string{
+ mcontext.GetOperationID(ctx),
+ strconv.FormatInt(time.Now().UnixNano(), 10),
+ strconv.Itoa(rand.Int()),
+ },
+ ",;,",
+ ),
+ )
bi := big.NewInt(0)
bi.SetString(id[0:8], 16)
id = bi.String()
@@ -232,7 +246,10 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
return resp, nil
}
-func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJoinedGroupListReq) (*pbGroup.GetJoinedGroupListResp, error) {
+func (s *groupServer) GetJoinedGroupList(
+ ctx context.Context,
+ req *pbGroup.GetJoinedGroupListReq,
+) (*pbGroup.GetJoinedGroupListResp, error) {
resp := &pbGroup.GetJoinedGroupListResp{}
if err := tokenverify.CheckAccessV3(ctx, req.FromUserID); err != nil {
return nil, err
@@ -242,7 +259,8 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
pageNumber = req.Pagination.PageNumber
showNumber = req.Pagination.ShowNumber
}
- //total, members, err := s.GroupDatabase.PageGroupMember(ctx, nil, []string{req.FromUserID}, nil, pageNumber, showNumber)
+ // total, members, err := s.GroupDatabase.PageGroupMember(ctx, nil, []string{req.FromUserID}, nil, pageNumber,
+ // showNumber)
total, members, err := s.GroupDatabase.PageGetJoinGroup(ctx, req.FromUserID, pageNumber, showNumber)
if err != nil {
return nil, err
@@ -281,7 +299,10 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
return resp, nil
}
-func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.InviteUserToGroupReq) (*pbGroup.InviteUserToGroupResp, error) {
+func (s *groupServer) InviteUserToGroup(
+ ctx context.Context,
+ req *pbGroup.InviteUserToGroupReq,
+) (*pbGroup.InviteUserToGroupResp, error) {
resp := &pbGroup.InviteUserToGroupResp{}
if len(req.InvitedUserIDs) == 0 {
return nil, errs.ErrArgs.Wrap("user empty")
@@ -382,7 +403,10 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
return resp, nil
}
-func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGroupAllMemberReq) (*pbGroup.GetGroupAllMemberResp, error) {
+func (s *groupServer) GetGroupAllMember(
+ ctx context.Context,
+ req *pbGroup.GetGroupAllMemberReq,
+) (*pbGroup.GetGroupAllMemberResp, error) {
resp := &pbGroup.GetGroupAllMemberResp{}
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
if err != nil {
@@ -410,7 +434,10 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
return resp, nil
}
-func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGroupMemberListReq) (*pbGroup.GetGroupMemberListResp, error) {
+func (s *groupServer) GetGroupMemberList(
+ ctx context.Context,
+ req *pbGroup.GetGroupMemberListReq,
+) (*pbGroup.GetGroupMemberListResp, error) {
resp := &pbGroup.GetGroupMemberListResp{}
total, members, err := s.PageGetGroupMember(ctx, req.GroupID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
log.ZDebug(ctx, "GetGroupMemberList", "total", total, "members", members, "length", len(members))
@@ -423,7 +450,10 @@ func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGr
return resp, nil
}
-func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGroupMemberReq) (*pbGroup.KickGroupMemberResp, error) {
+func (s *groupServer) KickGroupMember(
+ ctx context.Context,
+ req *pbGroup.KickGroupMemberReq,
+) (*pbGroup.KickGroupMemberResp, error) {
resp := &pbGroup.KickGroupMemberResp{}
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
if err != nil {
@@ -531,7 +561,10 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
return resp, nil
}
-func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetGroupMembersInfoReq) (*pbGroup.GetGroupMembersInfoResp, error) {
+func (s *groupServer) GetGroupMembersInfo(
+ ctx context.Context,
+ req *pbGroup.GetGroupMembersInfoReq,
+) (*pbGroup.GetGroupMembersInfoResp, error) {
resp := &pbGroup.GetGroupMembersInfoResp{}
if len(req.UserIDs) == 0 {
return nil, errs.ErrArgs.Wrap("userIDs empty")
@@ -558,7 +591,10 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
return resp, nil
}
-func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.GetGroupApplicationListReq) (*pbGroup.GetGroupApplicationListResp, error) {
+func (s *groupServer) GetGroupApplicationList(
+ ctx context.Context,
+ req *pbGroup.GetGroupApplicationListReq,
+) (*pbGroup.GetGroupApplicationListResp, error) {
pageNumber, showNumber := utils.GetPage(req.Pagination)
groupIDs, err := s.GroupDatabase.FindUserManagedGroupID(ctx, req.FromUserID)
@@ -609,12 +645,19 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
return e.GroupID
})
resp.GroupRequests = utils.Slice(groupRequests, func(e *relationTb.GroupRequestModel) *sdkws.GroupRequest {
- return convert.Db2PbGroupRequest(e, userMap[e.UserID], convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, groupMemberNumMap[e.GroupID]))
+ return convert.Db2PbGroupRequest(
+ e,
+ userMap[e.UserID],
+ convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, groupMemberNumMap[e.GroupID]),
+ )
})
return resp, nil
}
-func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsInfoReq) (*pbGroup.GetGroupsInfoResp, error) {
+func (s *groupServer) GetGroupsInfo(
+ ctx context.Context,
+ req *pbGroup.GetGroupsInfoReq,
+) (*pbGroup.GetGroupsInfoResp, error) {
resp := &pbGroup.GetGroupsInfoResp{}
if len(req.GroupIDs) == 0 {
return nil, errs.ErrArgs.Wrap("groupID is empty")
@@ -644,7 +687,10 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
return resp, nil
}
-func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (*pbGroup.GroupApplicationResponseResp, error) {
+func (s *groupServer) GroupApplicationResponse(
+ ctx context.Context,
+ req *pbGroup.GroupApplicationResponseReq,
+) (*pbGroup.GroupApplicationResponseResp, error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
if !utils.Contain(req.HandleResult, constant.GroupResponseAgree, constant.GroupResponseRefuse) {
return nil, errs.ErrArgs.Wrap("HandleResult unknown")
@@ -716,7 +762,10 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
return &pbGroup.GroupApplicationResponseResp{}, nil
}
-func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) (resp *pbGroup.JoinGroupResp, err error) {
+func (s *groupServer) JoinGroup(
+ ctx context.Context,
+ req *pbGroup.JoinGroupReq,
+) (resp *pbGroup.JoinGroupResp, err error) {
defer log.ZInfo(ctx, "JoinGroup.Return")
user, err := s.User.GetUserInfo(ctx, req.InviterUserID)
if err != nil {
@@ -816,7 +865,10 @@ func (s *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, gro
return s.conversationRpcClient.SetConversationMaxSeq(ctx, userIDs, conevrsationID, maxSeq)
}
-func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInfoReq) (*pbGroup.SetGroupInfoResp, error) {
+func (s *groupServer) SetGroupInfo(
+ ctx context.Context,
+ req *pbGroup.SetGroupInfoReq,
+) (*pbGroup.SetGroupInfoResp, error) {
var opMember *relationTb.GroupMemberModel
if !tokenverify.IsAppManagerUid(ctx) {
var err error
@@ -866,7 +918,10 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
var num int
if req.GroupInfoForSet.Notification != "" {
num++
- s.Notification.GroupInfoSetAnnouncementNotification(ctx, &sdkws.GroupInfoSetAnnouncementTips{Group: tips.Group, OpUser: tips.OpUser})
+ s.Notification.GroupInfoSetAnnouncementNotification(
+ ctx,
+ &sdkws.GroupInfoSetAnnouncementTips{Group: tips.Group, OpUser: tips.OpUser},
+ )
}
switch len(data) - num {
@@ -883,7 +938,10 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
return resp, nil
}
-func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) (*pbGroup.TransferGroupOwnerResp, error) {
+func (s *groupServer) TransferGroupOwner(
+ ctx context.Context,
+ req *pbGroup.TransferGroupOwnerReq,
+) (*pbGroup.TransferGroupOwnerResp, error) {
resp := &pbGroup.TransferGroupOwnerResp{}
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
if err != nil {
@@ -962,9 +1020,20 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq)
return resp, nil
}
-func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) {
+func (s *groupServer) GetGroupMembersCMS(
+ ctx context.Context,
+ req *pbGroup.GetGroupMembersCMSReq,
+) (*pbGroup.GetGroupMembersCMSResp, error) {
resp := &pbGroup.GetGroupMembersCMSResp{}
- total, members, err := s.GroupDatabase.SearchGroupMember(ctx, req.UserName, []string{req.GroupID}, nil, nil, req.Pagination.PageNumber, req.Pagination.ShowNumber)
+ total, members, err := s.GroupDatabase.SearchGroupMember(
+ ctx,
+ req.UserName,
+ []string{req.GroupID},
+ nil,
+ nil,
+ req.Pagination.PageNumber,
+ req.Pagination.ShowNumber,
+ )
if err != nil {
return nil, err
}
@@ -984,7 +1053,10 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGr
return resp, nil
}
-func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGroup.GetUserReqApplicationListReq) (*pbGroup.GetUserReqApplicationListResp, error) {
+func (s *groupServer) GetUserReqApplicationList(
+ ctx context.Context,
+ req *pbGroup.GetUserReqApplicationListReq,
+) (*pbGroup.GetUserReqApplicationListResp, error) {
resp := &pbGroup.GetUserReqApplicationListResp{}
user, err := s.User.GetPublicUserInfo(ctx, req.UserID)
if err != nil {
@@ -1031,12 +1103,19 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
return nil, err
}
resp.GroupRequests = utils.Slice(requests, func(e *relationTb.GroupRequestModel) *sdkws.GroupRequest {
- return convert.Db2PbGroupRequest(e, user, convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNum[e.GroupID])))
+ return convert.Db2PbGroupRequest(
+ e,
+ user,
+ convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNum[e.GroupID])),
+ )
})
return resp, nil
}
-func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGroupReq) (*pbGroup.DismissGroupResp, error) {
+func (s *groupServer) DismissGroup(
+ ctx context.Context,
+ req *pbGroup.DismissGroupReq,
+) (*pbGroup.DismissGroupResp, error) {
defer log.ZInfo(ctx, "DismissGroup.return")
resp := &pbGroup.DismissGroupResp{}
owner, err := s.TakeGroupOwner(ctx, req.GroupID)
@@ -1085,7 +1164,10 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
return resp, nil
}
-func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGroupMemberReq) (*pbGroup.MuteGroupMemberResp, error) {
+func (s *groupServer) MuteGroupMember(
+ ctx context.Context,
+ req *pbGroup.MuteGroupMemberReq,
+) (*pbGroup.MuteGroupMemberResp, error) {
resp := &pbGroup.MuteGroupMemberResp{}
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
// return nil, err
@@ -1120,7 +1202,10 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
return resp, nil
}
-func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.CancelMuteGroupMemberReq) (*pbGroup.CancelMuteGroupMemberResp, error) {
+func (s *groupServer) CancelMuteGroupMember(
+ ctx context.Context,
+ req *pbGroup.CancelMuteGroupMemberReq,
+) (*pbGroup.CancelMuteGroupMemberResp, error) {
resp := &pbGroup.CancelMuteGroupMemberResp{}
//member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
//if err != nil {
@@ -1132,7 +1217,8 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
// return nil, err
// }
// if opMember.RoleLevel <= member.RoleLevel {
- // return nil, errs.ErrNoPermission.Wrap(fmt.Sprintf("self RoleLevel %d target %d", opMember.RoleLevel, member.RoleLevel))
+ // return nil, errs.ErrNoPermission.Wrap(fmt.Sprintf("self RoleLevel %d target %d", opMember.RoleLevel,
+ // member.RoleLevel))
// }
//}
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
@@ -1180,7 +1266,10 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq)
return resp, nil
}
-func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMuteGroupReq) (*pbGroup.CancelMuteGroupResp, error) {
+func (s *groupServer) CancelMuteGroup(
+ ctx context.Context,
+ req *pbGroup.CancelMuteGroupReq,
+) (*pbGroup.CancelMuteGroupResp, error) {
resp := &pbGroup.CancelMuteGroupResp{}
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
return nil, err
@@ -1192,7 +1281,10 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
return resp, nil
}
-func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (*pbGroup.SetGroupMemberInfoResp, error) {
+func (s *groupServer) SetGroupMemberInfo(
+ ctx context.Context,
+ req *pbGroup.SetGroupMemberInfoReq,
+) (*pbGroup.SetGroupMemberInfoResp, error) {
resp := &pbGroup.SetGroupMemberInfoResp{}
if len(req.Members) == 0 {
return nil, errs.ErrArgs.Wrap("members empty")
@@ -1219,9 +1311,11 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
delete(duplicateMap, [...]string{member.GroupID, member.UserID})
}
if len(duplicateMap) > 0 {
- return nil, errs.ErrArgs.Wrap("user not found" + strings.Join(utils.Slice(utils.Keys(duplicateMap), func(e [2]string) string {
- return fmt.Sprintf("[group: %s user: %s]", e[0], e[1])
- }), ","))
+ return nil, errs.ErrArgs.Wrap(
+ "user not found" + strings.Join(utils.Slice(utils.Keys(duplicateMap), func(e [2]string) string {
+ return fmt.Sprintf("[group: %s user: %s]", e[0], e[1])
+ }), ","),
+ )
}
memberMap := utils.SliceToMap(members, func(e *relationTb.GroupMemberModel) [2]string {
return [...]string{e.GroupID, e.UserID}
@@ -1251,7 +1345,9 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
}
dbMember, ok := memberMap[[...]string{member.GroupID, member.UserID}]
if !ok {
- return nil, errs.ErrRecordNotFound.Wrap(fmt.Sprintf("user %s not in group %s", member.UserID, member.GroupID))
+ return nil, errs.ErrRecordNotFound.Wrap(
+ fmt.Sprintf("user %s not in group %s", member.UserID, member.GroupID),
+ )
}
//if opMember.RoleLevel == constant.GroupOwner {
// continue
@@ -1313,14 +1409,25 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
if member.Nickname != nil || member.FaceURL != nil || member.Ex != nil {
log.ZDebug(ctx, "setGroupMemberInfo notification", "member", member.UserID)
if err := s.Notification.GroupMemberInfoSetNotification(ctx, member.GroupID, member.UserID); err != nil {
- log.ZError(ctx, "setGroupMemberInfo notification failed", err, "member", member.UserID, "groupID", member.GroupID)
+ log.ZError(
+ ctx,
+ "setGroupMemberInfo notification failed",
+ err,
+ "member",
+ member.UserID,
+ "groupID",
+ member.GroupID,
+ )
}
}
}
return resp, nil
}
-func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.GetGroupAbstractInfoReq) (*pbGroup.GetGroupAbstractInfoResp, error) {
+func (s *groupServer) GetGroupAbstractInfo(
+ ctx context.Context,
+ req *pbGroup.GetGroupAbstractInfoReq,
+) (*pbGroup.GetGroupAbstractInfoResp, error) {
resp := &pbGroup.GetGroupAbstractInfoResp{}
if len(req.GroupIDs) == 0 {
return nil, errs.ErrArgs.Wrap("groupIDs empty")
@@ -1351,7 +1458,10 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.Get
return resp, nil
}
-func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.GetUserInGroupMembersReq) (*pbGroup.GetUserInGroupMembersResp, error) {
+func (s *groupServer) GetUserInGroupMembers(
+ ctx context.Context,
+ req *pbGroup.GetUserInGroupMembersReq,
+) (*pbGroup.GetUserInGroupMembersResp, error) {
resp := &pbGroup.GetUserInGroupMembersResp{}
if len(req.GroupIDs) == 0 {
return nil, errs.ErrArgs.Wrap("groupIDs empty")
@@ -1375,7 +1485,10 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.Ge
return resp, nil
}
-func (s *groupServer) GetGroupMemberUserIDs(ctx context.Context, req *pbGroup.GetGroupMemberUserIDsReq) (resp *pbGroup.GetGroupMemberUserIDsResp, err error) {
+func (s *groupServer) GetGroupMemberUserIDs(
+ ctx context.Context,
+ req *pbGroup.GetGroupMemberUserIDsReq,
+) (resp *pbGroup.GetGroupMemberUserIDsResp, err error) {
resp = &pbGroup.GetGroupMemberUserIDsResp{}
resp.UserIDs, err = s.GroupDatabase.FindGroupMemberUserID(ctx, req.GroupID)
if err != nil {
@@ -1384,7 +1497,10 @@ func (s *groupServer) GetGroupMemberUserIDs(ctx context.Context, req *pbGroup.Ge
return resp, nil
}
-func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbGroup.GetGroupMemberRoleLevelReq) (*pbGroup.GetGroupMemberRoleLevelResp, error) {
+func (s *groupServer) GetGroupMemberRoleLevel(
+ ctx context.Context,
+ req *pbGroup.GetGroupMemberRoleLevelReq,
+) (*pbGroup.GetGroupMemberRoleLevelResp, error) {
resp := &pbGroup.GetGroupMemberRoleLevelResp{}
if len(req.RoleLevels) == 0 {
return nil, errs.ErrArgs.Wrap("RoleLevels empty")
diff --git a/internal/rpc/group/super_group.go b/internal/rpc/group/super_group.go
index 8d8937db4..ab4cbd5ff 100644
--- a/internal/rpc/group/super_group.go
+++ b/internal/rpc/group/super_group.go
@@ -15,7 +15,10 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
-func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.GetJoinedSuperGroupListReq) (*pbGroup.GetJoinedSuperGroupListResp, error) {
+func (s *groupServer) GetJoinedSuperGroupList(
+ ctx context.Context,
+ req *pbGroup.GetJoinedSuperGroupListReq,
+) (*pbGroup.GetJoinedSuperGroupListResp, error) {
resp := &pbGroup.GetJoinedSuperGroupListResp{}
groupIDs, err := s.GroupDatabase.FindJoinSuperGroup(ctx, req.UserID)
if err != nil {
@@ -48,16 +51,22 @@ func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.
if err != nil {
return nil, err
}
- superGroupMemberMap := utils.SliceToMapAny(superGroupMembers, func(e *unrelation.SuperGroupModel) (string, []string) {
- return e.GroupID, e.MemberIDs
- })
+ superGroupMemberMap := utils.SliceToMapAny(
+ superGroupMembers,
+ func(e *unrelation.SuperGroupModel) (string, []string) {
+ return e.GroupID, e.MemberIDs
+ },
+ )
resp.Groups = utils.Slice(groupIDs, func(groupID string) *sdkws.GroupInfo {
return convert.Db2PbGroupInfo(groupMap[groupID], ownerMap[groupID].UserID, uint32(len(superGroupMemberMap)))
})
return resp, nil
}
-func (s *groupServer) GetSuperGroupsInfo(ctx context.Context, req *pbGroup.GetSuperGroupsInfoReq) (resp *pbGroup.GetSuperGroupsInfoResp, err error) {
+func (s *groupServer) GetSuperGroupsInfo(
+ ctx context.Context,
+ req *pbGroup.GetSuperGroupsInfoReq,
+) (resp *pbGroup.GetSuperGroupsInfoResp, err error) {
resp = &pbGroup.GetSuperGroupsInfoResp{}
if len(req.GroupIDs) == 0 {
return nil, errs.ErrArgs.Wrap("groupIDs empty")
@@ -70,9 +79,12 @@ func (s *groupServer) GetSuperGroupsInfo(ctx context.Context, req *pbGroup.GetSu
if err != nil {
return nil, err
}
- superGroupMemberMap := utils.SliceToMapAny(superGroupMembers, func(e *unrelation.SuperGroupModel) (string, []string) {
- return e.GroupID, e.MemberIDs
- })
+ superGroupMemberMap := utils.SliceToMapAny(
+ superGroupMembers,
+ func(e *unrelation.SuperGroupModel) (string, []string) {
+ return e.GroupID, e.MemberIDs
+ },
+ )
owners, err := s.FindGroupMember(ctx, req.GroupIDs, nil, []int32{constant.GroupOwner})
if err != nil {
return nil, err
diff --git a/internal/rpc/msg/as_read.go b/internal/rpc/msg/as_read.go
index f34e5fd2b..c4707c489 100644
--- a/internal/rpc/msg/as_read.go
+++ b/internal/rpc/msg/as_read.go
@@ -3,15 +3,19 @@ package msg
import (
"context"
+ "github.com/redis/go-redis/v9"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
- "github.com/redis/go-redis/v9"
)
-func (m *msgServer) GetConversationsHasReadAndMaxSeq(ctx context.Context, req *msg.GetConversationsHasReadAndMaxSeqReq) (*msg.GetConversationsHasReadAndMaxSeqResp, error) {
+func (m *msgServer) GetConversationsHasReadAndMaxSeq(
+ ctx context.Context,
+ req *msg.GetConversationsHasReadAndMaxSeqReq,
+) (*msg.GetConversationsHasReadAndMaxSeqResp, error) {
conversationIDs, err := m.ConversationLocalCache.GetConversationIDs(ctx, req.UserID)
if err != nil {
return nil, err
@@ -47,7 +51,10 @@ func (m *msgServer) GetConversationsHasReadAndMaxSeq(ctx context.Context, req *m
return resp, nil
}
-func (m *msgServer) SetConversationHasReadSeq(ctx context.Context, req *msg.SetConversationHasReadSeqReq) (resp *msg.SetConversationHasReadSeqResp, err error) {
+func (m *msgServer) SetConversationHasReadSeq(
+ ctx context.Context,
+ req *msg.SetConversationHasReadSeqReq,
+) (resp *msg.SetConversationHasReadSeqResp, err error) {
maxSeq, err := m.MsgDatabase.GetMaxSeq(ctx, req.ConversationID)
if err != nil {
return
@@ -64,7 +71,10 @@ func (m *msgServer) SetConversationHasReadSeq(ctx context.Context, req *msg.SetC
return &msg.SetConversationHasReadSeqResp{}, nil
}
-func (m *msgServer) MarkMsgsAsRead(ctx context.Context, req *msg.MarkMsgsAsReadReq) (resp *msg.MarkMsgsAsReadResp, err error) {
+func (m *msgServer) MarkMsgsAsRead(
+ ctx context.Context,
+ req *msg.MarkMsgsAsReadReq,
+) (resp *msg.MarkMsgsAsReadResp, err error) {
if len(req.Seqs) < 1 {
return nil, errs.ErrArgs.Wrap("seqs must not be empty")
}
@@ -99,7 +109,10 @@ func (m *msgServer) MarkMsgsAsRead(ctx context.Context, req *msg.MarkMsgsAsReadR
return &msg.MarkMsgsAsReadResp{}, nil
}
-func (m *msgServer) MarkConversationAsRead(ctx context.Context, req *msg.MarkConversationAsReadReq) (resp *msg.MarkConversationAsReadResp, err error) {
+func (m *msgServer) MarkConversationAsRead(
+ ctx context.Context,
+ req *msg.MarkConversationAsReadReq,
+) (resp *msg.MarkConversationAsReadResp, err error) {
conversation, err := m.Conversation.GetConversation(ctx, req.UserID, req.ConversationID)
if err != nil {
return
@@ -136,7 +149,14 @@ func (m *msgServer) MarkConversationAsRead(ctx context.Context, req *msg.MarkCon
return &msg.MarkConversationAsReadResp{}, nil
}
-func (m *msgServer) sendMarkAsReadNotification(ctx context.Context, conversationID string, sesstionType int32, sendID, recvID string, seqs []int64, hasReadSeq int64) error {
+func (m *msgServer) sendMarkAsReadNotification(
+ ctx context.Context,
+ conversationID string,
+ sesstionType int32,
+ sendID, recvID string,
+ seqs []int64,
+ hasReadSeq int64,
+) error {
tips := &sdkws.MarkAsReadTips{
MarkAsReadUserID: sendID,
ConversationID: conversationID,
diff --git a/internal/rpc/msg/delete.go b/internal/rpc/msg/delete.go
index 1b8306614..97efff41b 100644
--- a/internal/rpc/msg/delete.go
+++ b/internal/rpc/msg/delete.go
@@ -27,7 +27,10 @@ func (m *msgServer) validateDeleteSyncOpt(opt *msg.DeleteSyncOpt) (isSyncSelf, i
return opt.IsSyncSelf, opt.IsSyncOther
}
-func (m *msgServer) ClearConversationsMsg(ctx context.Context, req *msg.ClearConversationsMsgReq) (*msg.ClearConversationsMsgResp, error) {
+func (m *msgServer) ClearConversationsMsg(
+ ctx context.Context,
+ req *msg.ClearConversationsMsgReq,
+) (*msg.ClearConversationsMsgResp, error) {
if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
return nil, err
}
@@ -37,7 +40,10 @@ func (m *msgServer) ClearConversationsMsg(ctx context.Context, req *msg.ClearCon
return &msg.ClearConversationsMsgResp{}, nil
}
-func (m *msgServer) UserClearAllMsg(ctx context.Context, req *msg.UserClearAllMsgReq) (*msg.UserClearAllMsgResp, error) {
+func (m *msgServer) UserClearAllMsg(
+ ctx context.Context,
+ req *msg.UserClearAllMsgReq,
+) (*msg.UserClearAllMsgResp, error) {
if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
return nil, err
}
@@ -66,7 +72,14 @@ func (m *msgServer) DeleteMsgs(ctx context.Context, req *msg.DeleteMsgsReq) (*ms
return nil, err
}
tips := &sdkws.DeleteMsgsTips{UserID: req.UserID, ConversationID: req.ConversationID, Seqs: req.Seqs}
- m.notificationSender.NotificationWithSesstionType(ctx, req.UserID, m.conversationAndGetRecvID(conversations[0], req.UserID), constant.DeleteMsgsNotification, conversations[0].ConversationType, tips)
+ m.notificationSender.NotificationWithSesstionType(
+ ctx,
+ req.UserID,
+ m.conversationAndGetRecvID(conversations[0], req.UserID),
+ constant.DeleteMsgsNotification,
+ conversations[0].ConversationType,
+ tips,
+ )
} else {
if err := m.MsgDatabase.DeleteUserMsgsBySeqs(ctx, req.UserID, req.ConversationID, req.Seqs); err != nil {
return nil, err
@@ -79,7 +92,10 @@ func (m *msgServer) DeleteMsgs(ctx context.Context, req *msg.DeleteMsgsReq) (*ms
return &msg.DeleteMsgsResp{}, nil
}
-func (m *msgServer) DeleteMsgPhysicalBySeq(ctx context.Context, req *msg.DeleteMsgPhysicalBySeqReq) (*msg.DeleteMsgPhysicalBySeqResp, error) {
+func (m *msgServer) DeleteMsgPhysicalBySeq(
+ ctx context.Context,
+ req *msg.DeleteMsgPhysicalBySeqReq,
+) (*msg.DeleteMsgPhysicalBySeqResp, error) {
err := m.MsgDatabase.DeleteMsgsPhysicalBySeqs(ctx, req.ConversationID, req.Seqs)
if err != nil {
return nil, err
@@ -87,20 +103,36 @@ func (m *msgServer) DeleteMsgPhysicalBySeq(ctx context.Context, req *msg.DeleteM
return &msg.DeleteMsgPhysicalBySeqResp{}, nil
}
-func (m *msgServer) DeleteMsgPhysical(ctx context.Context, req *msg.DeleteMsgPhysicalReq) (*msg.DeleteMsgPhysicalResp, error) {
+func (m *msgServer) DeleteMsgPhysical(
+ ctx context.Context,
+ req *msg.DeleteMsgPhysicalReq,
+) (*msg.DeleteMsgPhysicalResp, error) {
if err := tokenverify.CheckAdmin(ctx); err != nil {
return nil, err
}
remainTime := utils.GetCurrentTimestampBySecond() - req.Timestamp
for _, conversationID := range req.ConversationIDs {
if err := m.MsgDatabase.DeleteConversationMsgsAndSetMinSeq(ctx, conversationID, remainTime); err != nil {
- log.ZWarn(ctx, "DeleteConversationMsgsAndSetMinSeq error", err, "conversationID", conversationID, "err", err)
+ log.ZWarn(
+ ctx,
+ "DeleteConversationMsgsAndSetMinSeq error",
+ err,
+ "conversationID",
+ conversationID,
+ "err",
+ err,
+ )
}
}
return &msg.DeleteMsgPhysicalResp{}, nil
}
-func (m *msgServer) clearConversation(ctx context.Context, conversationIDs []string, userID string, deleteSyncOpt *msg.DeleteSyncOpt) error {
+func (m *msgServer) clearConversation(
+ ctx context.Context,
+ conversationIDs []string,
+ userID string,
+ deleteSyncOpt *msg.DeleteSyncOpt,
+) error {
defer log.ZDebug(ctx, "clearConversation return line")
conversations, err := m.Conversation.GetConversationsByConversationID(ctx, conversationIDs)
if err != nil {
@@ -125,7 +157,14 @@ func (m *msgServer) clearConversation(ctx context.Context, conversationIDs []str
// notification 2 self
if isSyncSelf {
tips := &sdkws.ClearConversationTips{UserID: userID, ConversationIDs: existConversationIDs}
- m.notificationSender.NotificationWithSesstionType(ctx, userID, userID, constant.ClearConversationNotification, constant.SingleChatType, tips)
+ m.notificationSender.NotificationWithSesstionType(
+ ctx,
+ userID,
+ userID,
+ constant.ClearConversationNotification,
+ constant.SingleChatType,
+ tips,
+ )
}
} else {
if err := m.MsgDatabase.SetMinSeqs(ctx, m.getMinSeqs(maxSeqs)); err != nil {
diff --git a/internal/rpc/msg/extend_msg.go b/internal/rpc/msg/extend_msg.go
index 1da53c322..7ae56c71e 100644
--- a/internal/rpc/msg/extend_msg.go
+++ b/internal/rpc/msg/extend_msg.go
@@ -7,7 +7,10 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
)
-func (m *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg.SetMessageReactionExtensionsReq) (resp *msg.SetMessageReactionExtensionsResp, err error) {
+func (m *msgServer) SetMessageReactionExtensions(
+ ctx context.Context,
+ req *msg.SetMessageReactionExtensionsReq,
+) (resp *msg.SetMessageReactionExtensionsResp, err error) {
//resp = &msg.SetMessageReactionExtensionsResp{}
////resp.ClientMsgID = req.ClientMsgID
////resp.MsgFirstModifyTime = req.MsgFirstModifyTime
@@ -18,7 +21,8 @@ func (m *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg.S
////if ExternalExtension
//if req.IsExternalExtensions {
// resp.MsgFirstModifyTime = req.MsgFirstModifyTime
- // notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.conversationID, req.SessionType, req, &resp, !req.IsReact, false)
+ // notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.conversationID,
+ // req.SessionType, req, &resp, !req.IsReact, false)
// return resp, nil
//}
//isExists, err := m.MsgDatabase.JudgeMessageReactionExist(ctx, req.ClientMsgID, req.SessionType)
@@ -35,12 +39,14 @@ func (m *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg.S
// return nil, err
// }
// v.LatestUpdateTime = utils.GetCurrentTimestampByMill()
- // if err := m.MsgDatabase.SetMessageTypeKeyValue(ctx, req.ClientMsgID, req.SessionType, k, utils.StructToJsonString(v)); err != nil {
+ // if err := m.MsgDatabase.SetMessageTypeKeyValue(ctx, req.ClientMsgID, req.SessionType, k,
+ // utils.StructToJsonString(v)); err != nil {
// return nil, err
// }
// }
// resp.IsReact = true
- // _, err := m.MsgDatabase.SetMessageReactionExpire(ctx, req.ClientMsgID, req.SessionType, time.Duration(24*3)*time.Hour)
+ // _, err := m.MsgDatabase.SetMessageReactionExpire(ctx, req.ClientMsgID, req.SessionType,
+ // time.Duration(24*3)*time.Hour)
// if err != nil {
// return nil, err
// }
@@ -49,7 +55,8 @@ func (m *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg.S
// if err != nil {
// return nil, err
// }
- // mongoValue, err := m.MsgDatabase.GetExtendMsg(ctx, req.conversationID, req.SessionType, req.ClientMsgID, req.MsgFirstModifyTime)
+ // mongoValue, err := m.MsgDatabase.GetExtendMsg(ctx, req.conversationID, req.SessionType, req.ClientMsgID,
+ // req.MsgFirstModifyTime)
// if err != nil {
// return nil, err
// }
@@ -69,7 +76,8 @@ func (m *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg.S
// temp.LatestUpdateTime = utils.GetCurrentTimestampByMill()
// setValue[k] = temp
// }
- // err = db.DB.InsertOrUpdateReactionExtendMsgSet(req.conversationID, req.SessionType, req.ClientMsgID, req.MsgFirstModifyTime, setValue)
+ // err = db.DB.InsertOrUpdateReactionExtendMsgSet(req.conversationID, req.SessionType, req.ClientMsgID,
+ // req.MsgFirstModifyTime, setValue)
// if err != nil {
// for _, value := range setValue {
// temp := new(msg.KeyValueResp)
@@ -112,7 +120,7 @@ func (m *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg.S
// continue
// } else {
// v.LatestUpdateTime = utils.GetCurrentTimestampByMill()
- // newerr := db.DB.SetMessageTypeKeyValue(req.ClientMsgID, req.SessionType, k, utils.StructToJsonString(v))
+ // newerr := db.DB.SetMessageTypeKeyValue(req.ClientMsgID, req.SessionType, k, utils.StructToJsonString(v))
// if newerr != nil {
// setKeyResultInfo(&resp, 201, newerr.Error(), req.ClientMsgID, k, temp)
// continue
@@ -124,18 +132,28 @@ func (m *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg.S
//}
//if !isExists {
// if !req.IsReact {
- // notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.conversationID, req.SessionType, req, &resp, true, true)
+ // notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.conversationID,
+ // req.SessionType, req, &resp, true, true)
// } else {
- // notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.conversationID, req.SessionType, req, &resp, false, false)
+ // notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.conversationID,
+ // req.SessionType, req, &resp, false, false)
// }
//} else {
- // notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.conversationID, req.SessionType, req, &resp, false, true)
+ // notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.conversationID,
+ // req.SessionType, req, &resp, false, true)
//}
//log.Debug(req.OperationID, utils.GetSelfFuncName(), "m return is:", resp.String())
return resp, nil
}
-func (m *msgServer) setKeyResultInfo(ctx context.Context, r *msg.SetMessageReactionExtensionsResp, errCode int32, errMsg, clientMsgID, typeKey string, keyValue *sdkws.KeyValue) {
+
+func (m *msgServer) setKeyResultInfo(
+ ctx context.Context,
+ r *msg.SetMessageReactionExtensionsResp,
+ errCode int32,
+ errMsg, clientMsgID, typeKey string,
+ keyValue *sdkws.KeyValue,
+) {
temp := new(msg.KeyValueResp)
temp.KeyValue = keyValue
temp.ErrCode = errCode
@@ -143,7 +161,14 @@ func (m *msgServer) setKeyResultInfo(ctx context.Context, r *msg.SetMessageReact
r.Result = append(r.Result, temp)
_ = m.MessageLocker.UnLockMessageTypeKey(ctx, clientMsgID, typeKey)
}
-func (m *msgServer) setDeleteKeyResultInfo(ctx context.Context, r *msg.DeleteMessagesReactionExtensionsResp, errCode int32, errMsg, clientMsgID, typeKey string, keyValue *sdkws.KeyValue) {
+
+func (m *msgServer) setDeleteKeyResultInfo(
+ ctx context.Context,
+ r *msg.DeleteMessagesReactionExtensionsResp,
+ errCode int32,
+ errMsg, clientMsgID, typeKey string,
+ keyValue *sdkws.KeyValue,
+) {
temp := new(msg.KeyValueResp)
temp.KeyValue = keyValue
temp.ErrCode = errCode
@@ -152,7 +177,10 @@ func (m *msgServer) setDeleteKeyResultInfo(ctx context.Context, r *msg.DeleteMes
_ = m.MessageLocker.UnLockMessageTypeKey(ctx, clientMsgID, typeKey)
}
-func (m *msgServer) GetMessagesReactionExtensions(ctx context.Context, req *msg.GetMessagesReactionExtensionsReq) (resp *msg.GetMessagesReactionExtensionsResp, err error) {
+func (m *msgServer) GetMessagesReactionExtensions(
+ ctx context.Context,
+ req *msg.GetMessagesReactionExtensionsReq,
+) (resp *msg.GetMessagesReactionExtensionsResp, err error) {
//log.Debug(req.OperationID, utils.GetSelfFuncName(), "m args is:", req.String())
//var rResp msg.GetMessageListReactionExtensionsResp
//for _, messageValue := range req.MessageReactionKeyList {
@@ -183,7 +211,8 @@ func (m *msgServer) GetMessagesReactionExtensions(ctx context.Context, req *msg.
// oneMessage.Pb2Model = keyMap
//
// } else {
- // mongoValue, err := db.DB.GetExtendMsg(req.conversationID, req.SessionType, messageValue.ClientMsgID, messageValue.MsgFirstModifyTime)
+ // mongoValue, err := db.DB.GetExtendMsg(req.conversationID, req.SessionType, messageValue.ClientMsgID,
+ // messageValue.MsgFirstModifyTime)
// if err != nil {
// oneMessage.ErrCode = 100
// oneMessage.ErrMsg = err.Error()
@@ -208,11 +237,17 @@ func (m *msgServer) GetMessagesReactionExtensions(ctx context.Context, req *msg.
}
-func (m *msgServer) AddMessageReactionExtensions(ctx context.Context, req *msg.ModifyMessageReactionExtensionsReq) (resp *msg.ModifyMessageReactionExtensionsResp, err error) {
+func (m *msgServer) AddMessageReactionExtensions(
+ ctx context.Context,
+ req *msg.ModifyMessageReactionExtensionsReq,
+) (resp *msg.ModifyMessageReactionExtensionsResp, err error) {
return
}
-func (m *msgServer) DeleteMessageReactionExtensions(ctx context.Context, req *msg.DeleteMessagesReactionExtensionsReq) (resp *msg.DeleteMessagesReactionExtensionsResp, err error) {
+func (m *msgServer) DeleteMessageReactionExtensions(
+ ctx context.Context,
+ req *msg.DeleteMessagesReactionExtensionsReq,
+) (resp *msg.DeleteMessagesReactionExtensionsResp, err error) {
//log.Debug(req.OperationID, utils.GetSelfFuncName(), "m args is:", req.String())
//var rResp msg.DeleteMessagesReactionExtensionsResp
//callbackResp := notification.callbackDeleteMessageReactionExtensions(req)
@@ -231,7 +266,8 @@ func (m *msgServer) DeleteMessageReactionExtensions(ctx context.Context, req *ms
////if ExternalExtension
//if req.IsExternalExtensions {
// rResp.Result = callbackResp.ResultReactionExtensionList
- // notification.ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.conversationID, req.SessionType, req, &rResp, false, false)
+ // notification.ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.conversationID, req.SessionType,
+ // req, &rResp, false, false)
// return &rResp, nil
//
//}
@@ -303,7 +339,8 @@ func (m *msgServer) DeleteMessageReactionExtensions(ctx context.Context, req *ms
// }
// return &rResp, nil
// }
- // mongoValue, err := db.DB.GetExtendMsg(req.conversationID, req.SessionType, req.ClientMsgID, req.MsgFirstModifyTime)
+ // mongoValue, err := db.DB.GetExtendMsg(req.conversationID, req.SessionType, req.ClientMsgID,
+ // req.MsgFirstModifyTime)
// if err != nil {
// rResp.ErrCode = 200
// rResp.ErrMsg = err.Error()
@@ -333,7 +370,8 @@ func (m *msgServer) DeleteMessageReactionExtensions(ctx context.Context, req *ms
// temp.TypeKey = v.TypeKey
// setValue[v.TypeKey] = temp
// }
- // err = db.DB.DeleteReactionExtendMsgSet(req.conversationID, req.SessionType, req.ClientMsgID, req.MsgFirstModifyTime, setValue)
+ // err = db.DB.DeleteReactionExtendMsgSet(req.conversationID, req.SessionType, req.ClientMsgID,
+ // req.MsgFirstModifyTime, setValue)
// if err != nil {
// for _, value := range setValue {
// temp := new(msg.KeyValueResp)
@@ -355,7 +393,8 @@ func (m *msgServer) DeleteMessageReactionExtensions(ctx context.Context, req *ms
// }
//
//}
- //notification.ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.conversationID, req.SessionType, req, &rResp, false, isExists)
+ // notification.ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.conversationID, req.SessionType,
+ // req, &rResp, false, isExists)
//log.Debug(req.OperationID, utils.GetSelfFuncName(), "m return is:", rResp.String())
return resp, nil
}
diff --git a/internal/rpc/msg/extend_msg_callback.go b/internal/rpc/msg/extend_msg_callback.go
index 216d65dfa..09fa40735 100644
--- a/internal/rpc/msg/extend_msg_callback.go
+++ b/internal/rpc/msg/extend_msg_callback.go
@@ -35,7 +35,10 @@ func callbackSetMessageReactionExtensions(ctx context.Context, setReq *msg.SetMe
return nil
}
-func callbackDeleteMessageReactionExtensions(ctx context.Context, setReq *msg.DeleteMessagesReactionExtensionsReq) error {
+func callbackDeleteMessageReactionExtensions(
+ ctx context.Context,
+ setReq *msg.DeleteMessagesReactionExtensionsReq,
+) error {
if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable {
return nil
}
diff --git a/internal/rpc/msg/msg_status.go b/internal/rpc/msg/msg_status.go
index 3e1f9053b..b867e3065 100644
--- a/internal/rpc/msg/msg_status.go
+++ b/internal/rpc/msg/msg_status.go
@@ -8,7 +8,10 @@ import (
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
)
-func (m *msgServer) SetSendMsgStatus(ctx context.Context, req *pbMsg.SetSendMsgStatusReq) (*pbMsg.SetSendMsgStatusResp, error) {
+func (m *msgServer) SetSendMsgStatus(
+ ctx context.Context,
+ req *pbMsg.SetSendMsgStatusReq,
+) (*pbMsg.SetSendMsgStatusResp, error) {
resp := &pbMsg.SetSendMsgStatusResp{}
if err := m.MsgDatabase.SetSendMsgStatus(ctx, mcontext.GetOperationID(ctx), req.Status); err != nil {
return nil, err
@@ -16,7 +19,10 @@ func (m *msgServer) SetSendMsgStatus(ctx context.Context, req *pbMsg.SetSendMsgS
return resp, nil
}
-func (m *msgServer) GetSendMsgStatus(ctx context.Context, req *pbMsg.GetSendMsgStatusReq) (*pbMsg.GetSendMsgStatusResp, error) {
+func (m *msgServer) GetSendMsgStatus(
+ ctx context.Context,
+ req *pbMsg.GetSendMsgStatusReq,
+) (*pbMsg.GetSendMsgStatusResp, error) {
resp := &pbMsg.GetSendMsgStatusResp{}
status, err := m.MsgDatabase.GetSendMsgStatus(ctx, mcontext.GetOperationID(ctx))
if IsNotFound(err) {
diff --git a/internal/rpc/msg/revoke.go b/internal/rpc/msg/revoke.go
index c32050bfe..2ea89ee87 100644
--- a/internal/rpc/msg/revoke.go
+++ b/internal/rpc/msg/revoke.go
@@ -56,7 +56,12 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
}
role = user.AppMangerLevel
case constant.SuperGroupChatType:
- members, err := m.Group.GetGroupMemberInfoMap(ctx, msgs[0].GroupID, utils.Distinct([]string{req.UserID, msgs[0].SendID}), true)
+ members, err := m.Group.GetGroupMemberInfoMap(
+ ctx,
+ msgs[0].GroupID,
+ utils.Distinct([]string{req.UserID, msgs[0].SendID}),
+ true,
+ )
if err != nil {
return nil, err
}
diff --git a/internal/rpc/msg/send.go b/internal/rpc/msg/send.go
index deaee0bed..c7450fd00 100644
--- a/internal/rpc/msg/send.go
+++ b/internal/rpc/msg/send.go
@@ -34,7 +34,10 @@ func (m *msgServer) SendMsg(ctx context.Context, req *pbMsg.SendMsgReq) (resp *p
}
}
-func (m *msgServer) sendMsgSuperGroupChat(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, err error) {
+func (m *msgServer) sendMsgSuperGroupChat(
+ ctx context.Context,
+ req *pbMsg.SendMsgReq,
+) (resp *pbMsg.SendMsgResp, err error) {
promePkg.Inc(promePkg.WorkSuperGroupChatMsgRecvSuccessCounter)
if err = m.messageVerification(ctx, req); err != nil {
promePkg.Inc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter)
@@ -105,7 +108,10 @@ func (m *msgServer) setConversationAtInfo(nctx context.Context, msg *sdkws.MsgDa
}
-func (m *msgServer) sendMsgNotification(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, err error) {
+func (m *msgServer) sendMsgNotification(
+ ctx context.Context,
+ req *pbMsg.SendMsgReq,
+) (resp *pbMsg.SendMsgResp, err error) {
promePkg.Inc(promePkg.SingleChatMsgRecvSuccessCounter)
if err := m.MsgDatabase.MsgToMQ(ctx, utils.GenConversationUniqueKeyForSingle(req.MsgData.SendID, req.MsgData.RecvID), req.MsgData); err != nil {
promePkg.Inc(promePkg.SingleChatMsgProcessFailedCounter)
@@ -127,7 +133,13 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbMsg.SendMsgReq
var isSend bool = true
isNotification := utils.IsNotificationByMsg(req.MsgData)
if !isNotification {
- isSend, err = m.modifyMessageByUserMessageReceiveOpt(ctx, req.MsgData.RecvID, utils.GenConversationIDForSingle(req.MsgData.SendID, req.MsgData.RecvID), constant.SingleChatType, req)
+ isSend, err = m.modifyMessageByUserMessageReceiveOpt(
+ ctx,
+ req.MsgData.RecvID,
+ utils.GenConversationIDForSingle(req.MsgData.SendID, req.MsgData.RecvID),
+ constant.SingleChatType,
+ req,
+ )
if err != nil {
return nil, err
}
diff --git a/internal/rpc/msg/seq.go b/internal/rpc/msg/seq.go
index 0d5e23d38..892d39bfe 100644
--- a/internal/rpc/msg/seq.go
+++ b/internal/rpc/msg/seq.go
@@ -6,7 +6,10 @@ import (
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
)
-func (m *msgServer) GetConversationMaxSeq(ctx context.Context, req *pbMsg.GetConversationMaxSeqReq) (resp *pbMsg.GetConversationMaxSeqResp, err error) {
+func (m *msgServer) GetConversationMaxSeq(
+ ctx context.Context,
+ req *pbMsg.GetConversationMaxSeqReq,
+) (resp *pbMsg.GetConversationMaxSeqResp, err error) {
maxSeq, err := m.MsgDatabase.GetMaxSeq(ctx, req.ConversationID)
if err != nil {
return nil, err
diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go
index c70d28e35..a077adb83 100644
--- a/internal/rpc/msg/server.go
+++ b/internal/rpc/msg/server.go
@@ -3,6 +3,8 @@ package msg
import (
"context"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@@ -14,7 +16,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
- "google.golang.org/grpc"
)
type MessageInterceptorChain []MessageInterceptorFunc
@@ -64,7 +65,11 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
msgDocModel := unrelation.NewMsgMongoDriver(mongo.GetDatabase())
extendMsgModel := unrelation.NewExtendMsgSetMongoDriver(mongo.GetDatabase())
extendMsgCacheModel := cache.NewExtendMsgSetCacheRedis(rdb, extendMsgModel, cache.GetDefaultOpt())
- extendMsgDatabase := controller.NewExtendMsgDatabase(extendMsgModel, extendMsgCacheModel, tx.NewMongo(mongo.GetClient()))
+ extendMsgDatabase := controller.NewExtendMsgDatabase(
+ extendMsgModel,
+ extendMsgCacheModel,
+ tx.NewMongo(mongo.GetClient()),
+ )
msgDatabase := controller.NewCommonMsgDatabase(msgDocModel, cacheModel)
conversationClient := rpcclient.NewConversationRpcClient(client)
userRpcClient := rpcclient.NewUserRpcClient(client)
@@ -106,7 +111,8 @@ func (m *msgServer) initPrometheus() {
}
func (m *msgServer) conversationAndGetRecvID(conversation *conversation.Conversation, userID string) (recvID string) {
- if conversation.ConversationType == constant.SingleChatType || conversation.ConversationType == constant.NotificationChatType {
+ if conversation.ConversationType == constant.SingleChatType ||
+ conversation.ConversationType == constant.NotificationChatType {
if userID == conversation.OwnerUserID {
recvID = conversation.UserID
} else {
diff --git a/internal/rpc/msg/sync_msg.go b/internal/rpc/msg/sync_msg.go
index 052fa5245..b9cfed97c 100644
--- a/internal/rpc/msg/sync_msg.go
+++ b/internal/rpc/msg/sync_msg.go
@@ -9,7 +9,10 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
-func (m *msgServer) PullMessageBySeqs(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
+func (m *msgServer) PullMessageBySeqs(
+ ctx context.Context,
+ req *sdkws.PullMessageBySeqsReq,
+) (*sdkws.PullMessageBySeqsResp, error) {
resp := &sdkws.PullMessageBySeqsResp{}
resp.Msgs = make(map[string]*sdkws.PullMsgs)
resp.NotificationMsgs = make(map[string]*sdkws.PullMsgs)
@@ -20,7 +23,15 @@ func (m *msgServer) PullMessageBySeqs(ctx context.Context, req *sdkws.PullMessag
log.ZError(ctx, "GetConversation error", err, "conversationID", seq.ConversationID)
continue
}
- minSeq, maxSeq, msgs, err := m.MsgDatabase.GetMsgBySeqsRange(ctx, req.UserID, seq.ConversationID, seq.Begin, seq.End, seq.Num, conversation.MaxSeq)
+ minSeq, maxSeq, msgs, err := m.MsgDatabase.GetMsgBySeqsRange(
+ ctx,
+ req.UserID,
+ seq.ConversationID,
+ seq.Begin,
+ seq.End,
+ seq.Num,
+ conversation.MaxSeq,
+ )
if err != nil {
log.ZWarn(ctx, "GetMsgBySeqsRange error", err, "conversationID", seq.ConversationID, "seq", seq)
continue
diff --git a/internal/rpc/msg/utils.go b/internal/rpc/msg/utils.go
index 468b1b617..199f1535f 100644
--- a/internal/rpc/msg/utils.go
+++ b/internal/rpc/msg/utils.go
@@ -1,12 +1,13 @@
package msg
import (
+ "github.com/redis/go-redis/v9"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/redis/go-redis/v9"
- "gorm.io/gorm"
)
func isMessageHasReadEnabled(msgData *sdkws.MsgData) bool {
diff --git a/internal/rpc/msg/verify.go b/internal/rpc/msg/verify.go
index 9d5d05efd..dd5b3436b 100644
--- a/internal/rpc/msg/verify.go
+++ b/internal/rpc/msg/verify.go
@@ -41,7 +41,8 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe
if utils.IsContain(data.MsgData.SendID, config.Config.Manager.UserID) {
return nil
}
- if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin {
+ if data.MsgData.ContentType <= constant.NotificationEnd &&
+ data.MsgData.ContentType >= constant.NotificationBegin {
return nil
}
black, err := m.friend.IsBlocked(ctx, data.MsgData.SendID, data.MsgData.RecvID)
@@ -67,7 +68,8 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe
if err != nil {
return err
}
- if groupInfo.Status == constant.GroupStatusDismissed && data.MsgData.ContentType != constant.GroupDismissedNotification {
+ if groupInfo.Status == constant.GroupStatusDismissed &&
+ data.MsgData.ContentType != constant.GroupDismissedNotification {
return errs.ErrDismissedAlready.Wrap()
}
if groupInfo.GroupType == constant.SuperGroup {
@@ -76,7 +78,8 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe
if utils.IsContain(data.MsgData.SendID, config.Config.Manager.UserID) {
return nil
}
- if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin {
+ if data.MsgData.ContentType <= constant.NotificationEnd &&
+ data.MsgData.ContentType >= constant.NotificationBegin {
return nil
}
// memberIDs, err := m.GroupLocalCache.GetGroupMemberIDs(ctx, data.MsgData.GroupID)
@@ -161,7 +164,12 @@ func GetMsgID(sendID string) string {
return utils.Md5(t + "-" + sendID + "-" + strconv.Itoa(rand.Int()))
}
-func (m *msgServer) modifyMessageByUserMessageReceiveOpt(ctx context.Context, userID, conversationID string, sessionType int, pb *msg.SendMsgReq) (bool, error) {
+func (m *msgServer) modifyMessageByUserMessageReceiveOpt(
+ ctx context.Context,
+ userID, conversationID string,
+ sessionType int,
+ pb *msg.SendMsgReq,
+) (bool, error) {
opt, err := m.User.GetUserGlobalMsgRecvOpt(ctx, userID)
if err != nil {
return false, err
diff --git a/internal/rpc/third/third.go b/internal/rpc/third/third.go
index 33d9b0a82..1ac63c245 100644
--- a/internal/rpc/third/third.go
+++ b/internal/rpc/third/third.go
@@ -4,6 +4,8 @@ import (
"context"
"net/url"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@@ -13,7 +15,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
- "google.golang.org/grpc"
)
func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
@@ -39,7 +40,13 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
third.RegisterThirdServer(server, &thirdServer{
thirdDatabase: controller.NewThirdDatabase(cache.NewMsgCacheModel(rdb)),
userRpcClient: rpcclient.NewUserRpcClient(client),
- s3dataBase: controller.NewS3Database(o, relation.NewObjectHash(db), relation.NewObjectInfo(db), relation.NewObjectPut(db), u),
+ s3dataBase: controller.NewS3Database(
+ o,
+ relation.NewObjectHash(db),
+ relation.NewObjectInfo(db),
+ relation.NewObjectPut(db),
+ u,
+ ),
})
return nil
}
@@ -50,7 +57,10 @@ type thirdServer struct {
userRpcClient rpcclient.UserRpcClient
}
-func (t *thirdServer) FcmUpdateToken(ctx context.Context, req *third.FcmUpdateTokenReq) (resp *third.FcmUpdateTokenResp, err error) {
+func (t *thirdServer) FcmUpdateToken(
+ ctx context.Context,
+ req *third.FcmUpdateTokenReq,
+) (resp *third.FcmUpdateTokenResp, err error) {
err = t.thirdDatabase.FcmUpdateToken(ctx, req.Account, int(req.PlatformID), req.FcmToken, req.ExpireTime)
if err != nil {
return nil, err
@@ -58,7 +68,10 @@ func (t *thirdServer) FcmUpdateToken(ctx context.Context, req *third.FcmUpdateTo
return &third.FcmUpdateTokenResp{}, nil
}
-func (t *thirdServer) SetAppBadge(ctx context.Context, req *third.SetAppBadgeReq) (resp *third.SetAppBadgeResp, err error) {
+func (t *thirdServer) SetAppBadge(
+ ctx context.Context,
+ req *third.SetAppBadgeReq,
+) (resp *third.SetAppBadgeResp, err error) {
err = t.thirdDatabase.SetAppBadge(ctx, req.UserID, int(req.AppUnreadCount))
if err != nil {
return nil, err
diff --git a/internal/rpc/user/statistics.go b/internal/rpc/user/statistics.go
index 12ec0d55f..7cbbcb82d 100644
--- a/internal/rpc/user/statistics.go
+++ b/internal/rpc/user/statistics.go
@@ -8,7 +8,10 @@ import (
pbuser "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
)
-func (s *userServer) UserRegisterCount(ctx context.Context, req *pbuser.UserRegisterCountReq) (*pbuser.UserRegisterCountResp, error) {
+func (s *userServer) UserRegisterCount(
+ ctx context.Context,
+ req *pbuser.UserRegisterCountReq,
+) (*pbuser.UserRegisterCountResp, error) {
if req.Start > req.End {
return nil, errs.ErrArgs.Wrap("start > end")
}
diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go
index 277bf4284..5004dc1f6 100644
--- a/internal/rpc/user/user.go
+++ b/internal/rpc/user/user.go
@@ -23,8 +23,9 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"google.golang.org/grpc"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
type userServer struct {
@@ -59,16 +60,22 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
friendRpcClient := rpcclient.NewFriendRpcClient(client)
msgRpcClient := rpcclient.NewMessageRpcClient(client)
u := &userServer{
- UserDatabase: database,
- RegisterCenter: client,
- friendRpcClient: &friendRpcClient,
- notificationSender: notification.NewFriendNotificationSender(&msgRpcClient, notification.WithDBFunc(database.FindWithError)),
+ UserDatabase: database,
+ RegisterCenter: client,
+ friendRpcClient: &friendRpcClient,
+ notificationSender: notification.NewFriendNotificationSender(
+ &msgRpcClient,
+ notification.WithDBFunc(database.FindWithError),
+ ),
}
pbuser.RegisterUserServer(server, u)
return u.UserDatabase.InitOnce(context.Background(), users)
}
-func (s *userServer) GetDesignateUsers(ctx context.Context, req *pbuser.GetDesignateUsersReq) (resp *pbuser.GetDesignateUsersResp, err error) {
+func (s *userServer) GetDesignateUsers(
+ ctx context.Context,
+ req *pbuser.GetDesignateUsersReq,
+) (resp *pbuser.GetDesignateUsersResp, err error) {
resp = &pbuser.GetDesignateUsersResp{}
users, err := s.FindWithError(ctx, req.UserIDs)
if err != nil {
@@ -81,7 +88,10 @@ func (s *userServer) GetDesignateUsers(ctx context.Context, req *pbuser.GetDesig
return resp, nil
}
-func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserInfoReq) (resp *pbuser.UpdateUserInfoResp, err error) {
+func (s *userServer) UpdateUserInfo(
+ ctx context.Context,
+ req *pbuser.UpdateUserInfoReq,
+) (resp *pbuser.UpdateUserInfoResp, err error) {
resp = &pbuser.UpdateUserInfoResp{}
err = tokenverify.CheckAccessV3(ctx, req.UserInfo.UserID)
if err != nil {
@@ -106,7 +116,10 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
return resp, nil
}
-func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.SetGlobalRecvMessageOptReq) (resp *pbuser.SetGlobalRecvMessageOptResp, err error) {
+func (s *userServer) SetGlobalRecvMessageOpt(
+ ctx context.Context,
+ req *pbuser.SetGlobalRecvMessageOptReq,
+) (resp *pbuser.SetGlobalRecvMessageOptResp, err error) {
resp = &pbuser.SetGlobalRecvMessageOptResp{}
if _, err := s.FindWithError(ctx, []string{req.UserID}); err != nil {
return nil, err
@@ -120,7 +133,10 @@ func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.Se
return resp, nil
}
-func (s *userServer) AccountCheck(ctx context.Context, req *pbuser.AccountCheckReq) (resp *pbuser.AccountCheckResp, err error) {
+func (s *userServer) AccountCheck(
+ ctx context.Context,
+ req *pbuser.AccountCheckReq,
+) (resp *pbuser.AccountCheckResp, err error) {
resp = &pbuser.AccountCheckResp{}
if utils.Duplicate(req.CheckUserIDs) {
return nil, errs.ErrArgs.Wrap("userID repeated")
@@ -149,7 +165,10 @@ func (s *userServer) AccountCheck(ctx context.Context, req *pbuser.AccountCheckR
return resp, nil
}
-func (s *userServer) GetPaginationUsers(ctx context.Context, req *pbuser.GetPaginationUsersReq) (resp *pbuser.GetPaginationUsersResp, err error) {
+func (s *userServer) GetPaginationUsers(
+ ctx context.Context,
+ req *pbuser.GetPaginationUsersReq,
+) (resp *pbuser.GetPaginationUsersResp, err error) {
var pageNumber, showNumber int32
if req.Pagination != nil {
pageNumber = req.Pagination.PageNumber
@@ -162,7 +181,10 @@ func (s *userServer) GetPaginationUsers(ctx context.Context, req *pbuser.GetPagi
return &pbuser.GetPaginationUsersResp{Total: int32(total), Users: convert.UsersDB2Pb(users)}, err
}
-func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterReq) (resp *pbuser.UserRegisterResp, err error) {
+func (s *userServer) UserRegister(
+ ctx context.Context,
+ req *pbuser.UserRegisterReq,
+) (resp *pbuser.UserRegisterResp, err error) {
resp = &pbuser.UserRegisterResp{}
if len(req.Users) == 0 {
return nil, errs.ErrArgs.Wrap("users is empty")
@@ -210,7 +232,10 @@ func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterR
return resp, nil
}
-func (s *userServer) GetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.GetGlobalRecvMessageOptReq) (resp *pbuser.GetGlobalRecvMessageOptResp, err error) {
+func (s *userServer) GetGlobalRecvMessageOpt(
+ ctx context.Context,
+ req *pbuser.GetGlobalRecvMessageOptReq,
+) (resp *pbuser.GetGlobalRecvMessageOptResp, err error) {
user, err := s.FindWithError(ctx, []string{req.UserID})
if err != nil {
return nil, err
@@ -218,7 +243,10 @@ func (s *userServer) GetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.Ge
return &pbuser.GetGlobalRecvMessageOptResp{GlobalRecvMsgOpt: user[0].GlobalRecvMsgOpt}, nil
}
-func (s *userServer) GetAllUserID(ctx context.Context, req *pbuser.GetAllUserIDReq) (resp *pbuser.GetAllUserIDResp, err error) {
+func (s *userServer) GetAllUserID(
+ ctx context.Context,
+ req *pbuser.GetAllUserIDReq,
+) (resp *pbuser.GetAllUserIDResp, err error) {
userIDs, err := s.UserDatabase.GetAllUserID(ctx)
if err != nil {
return nil, err
diff --git a/internal/tools/cron_task.go b/internal/tools/cron_task.go
index debf61a6d..bac433fc5 100644
--- a/internal/tools/cron_task.go
+++ b/internal/tools/cron_task.go
@@ -5,9 +5,10 @@ import (
"fmt"
"sync"
+ "github.com/robfig/cron/v3"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
- "github.com/robfig/cron/v3"
)
func StartCronTask() error {
diff --git a/internal/tools/msg.go b/internal/tools/msg.go
index fc810aa95..0c58791a0 100644
--- a/internal/tools/msg.go
+++ b/internal/tools/msg.go
@@ -26,7 +26,12 @@ type MsgTool struct {
var errSeq = errors.New("cache max seq and mongo max seq is diff > 10")
-func NewMsgTool(msgDatabase controller.CommonMsgDatabase, userDatabase controller.UserDatabase, groupDatabase controller.GroupDatabase, conversationDatabase controller.ConversationDatabase) *MsgTool {
+func NewMsgTool(
+ msgDatabase controller.CommonMsgDatabase,
+ userDatabase controller.UserDatabase,
+ groupDatabase controller.GroupDatabase,
+ conversationDatabase controller.ConversationDatabase,
+) *MsgTool {
return &MsgTool{
msgDatabase: msgDatabase,
userDatabase: userDatabase,
@@ -50,9 +55,17 @@ func InitMsgTool() (*MsgTool, error) {
}
userDB := relation.NewUserGorm(db)
msgDatabase := controller.InitCommonMsgDatabase(rdb, mongo.GetDatabase())
- userDatabase := controller.NewUserDatabase(userDB, cache.NewUserCacheRedis(rdb, relation.NewUserGorm(db), cache.GetDefaultOpt()), tx.NewGorm(db))
+ userDatabase := controller.NewUserDatabase(
+ userDB,
+ cache.NewUserCacheRedis(rdb, relation.NewUserGorm(db), cache.GetDefaultOpt()),
+ tx.NewGorm(db),
+ )
groupDatabase := controller.InitGroupDatabase(db, rdb, mongo.GetDatabase())
- conversationDatabase := controller.NewConversationDatabase(relation.NewConversationGorm(db), cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), relation.NewConversationGorm(db)), tx.NewGorm(db))
+ conversationDatabase := controller.NewConversationDatabase(
+ relation.NewConversationGorm(db),
+ cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), relation.NewConversationGorm(db)),
+ tx.NewGorm(db),
+ )
msgTool := NewMsgTool(msgDatabase, userDatabase, groupDatabase, conversationDatabase)
return msgTool, nil
}
@@ -75,7 +88,15 @@ func (c *MsgTool) AllConversationClearMsgAndFixSeq() {
func (c *MsgTool) ClearConversationsMsg(ctx context.Context, conversationIDs []string) {
for _, conversationID := range conversationIDs {
if err := c.msgDatabase.DeleteConversationMsgsAndSetMinSeq(ctx, conversationID, int64(config.Config.RetainChatRecords*24*60*60)); err != nil {
- log.ZError(ctx, "DeleteUserSuperGroupMsgsAndSetMinSeq failed", err, "conversationID", conversationID, "DBRetainChatRecords", config.Config.RetainChatRecords)
+ log.ZError(
+ ctx,
+ "DeleteUserSuperGroupMsgsAndSetMinSeq failed",
+ err,
+ "conversationID",
+ conversationID,
+ "DBRetainChatRecords",
+ config.Config.RetainChatRecords,
+ )
}
if err := c.checkMaxSeq(ctx, conversationID); err != nil {
log.ZError(ctx, "fixSeq failed", err, "conversationID", conversationID)
diff --git a/internal/tools/msg_test.go b/internal/tools/msg_test.go
index bf548903d..241748f76 100644
--- a/internal/tools/msg_test.go
+++ b/internal/tools/msg_test.go
@@ -4,11 +4,12 @@ import (
"context"
"strconv"
+ "go.mongodb.org/mongo-driver/bson"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "go.mongodb.org/mongo-driver/bson"
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
@@ -89,7 +90,10 @@ func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
return
}
msgTools.ClearConversationsMsg(ctx, []string{conversationID})
- minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err := msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(ctx, conversationID)
+ minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err := msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(
+ ctx,
+ conversationID,
+ )
if err != nil {
t.Error("GetSuperGroupMinMaxSeqInMongoAndCache failed")
return
@@ -132,7 +136,10 @@ func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
}
msgTools.ClearConversationsMsg(ctx, []string{conversationID})
- minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err = msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(ctx, conversationID)
+ minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err = msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(
+ ctx,
+ conversationID,
+ )
if err != nil {
t.Error("GetSuperGroupMinMaxSeqInMongoAndCache failed")
return
@@ -164,7 +171,10 @@ func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
}
msgTools.ClearConversationsMsg(ctx, []string{conversationID})
- minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err = msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(ctx, conversationID)
+ minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err = msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(
+ ctx,
+ conversationID,
+ )
if err != nil {
t.Error("GetSuperGroupMinMaxSeqInMongoAndCache failed")
return
@@ -214,7 +224,10 @@ func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
t.Error("GetSuperGroupMinMaxSeqInMongoAndCache failed")
return
}
- minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err = msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(ctx, conversationID)
+ minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err = msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(
+ ctx,
+ conversationID,
+ )
if err != nil {
t.Error("GetSuperGroupMinMaxSeqInMongoAndCache failed")
return
@@ -255,7 +268,10 @@ func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
t.Error("GetSuperGroupMinMaxSeqInMongoAndCache failed")
return
}
- minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err = msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(ctx, conversationID)
+ minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err = msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(
+ ctx,
+ conversationID,
+ )
if err != nil {
t.Error("GetSuperGroupMinMaxSeqInMongoAndCache failed")
return
@@ -305,7 +321,10 @@ func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
if _, err := mongoClient.InsertOne(ctx, msgDoc4); err != nil {
t.Error("InsertOne failed", testUID4)
}
- minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err = msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(ctx, conversationID)
+ minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache, err = msgTools.msgDatabase.GetConversationMinMaxSeqInMongoAndCache(
+ ctx,
+ conversationID,
+ )
if err != nil {
t.Error("GetSuperGroupMinMaxSeqInMongoAndCache failed")
return
diff --git a/pkg/a2r/api2rpc.go b/pkg/a2r/api2rpc.go
index 39bd70ce4..1a064176c 100644
--- a/pkg/a2r/api2rpc.go
+++ b/pkg/a2r/api2rpc.go
@@ -5,11 +5,12 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/checker"
+ "github.com/gin-gonic/gin"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
- "github.com/gin-gonic/gin"
- "google.golang.org/grpc"
)
func Call[A, B, C any](
diff --git a/pkg/apistruct/auth.go b/pkg/apistruct/auth.go
index 664919876..b760dcd08 100644
--- a/pkg/apistruct/auth.go
+++ b/pkg/apistruct/auth.go
@@ -1,8 +1,8 @@
package apistruct
type UserRegisterReq struct {
- Secret string `json:"secret" binding:"required,max=32"`
- Platform int32 `json:"platform" binding:"required,min=1,max=12"`
+ Secret string `json:"secret" binding:"required,max=32"`
+ Platform int32 `json:"platform" binding:"required,min=1,max=12"`
ApiUserInfo
OperationID string `json:"operationID" binding:"required"`
}
@@ -17,9 +17,9 @@ type UserRegisterResp struct {
}
type UserTokenReq struct {
- Secret string `json:"secret" binding:"required,max=32"`
- Platform int32 `json:"platform" binding:"required,min=1,max=12"`
- UserID string `json:"userID" binding:"required,min=1,max=64"`
+ Secret string `json:"secret" binding:"required,max=32"`
+ Platform int32 `json:"platform" binding:"required,min=1,max=12"`
+ UserID string `json:"userID" binding:"required,min=1,max=64"`
OperationID string `json:"operationID" binding:"required"`
}
@@ -28,8 +28,8 @@ type UserTokenResp struct {
}
type ForceLogoutReq struct {
- Platform int32 `json:"platform" binding:"required,min=1,max=12"`
- FromUserID string `json:"fromUserID" binding:"required,min=1,max=64"`
+ Platform int32 `json:"platform" binding:"required,min=1,max=12"`
+ FromUserID string `json:"fromUserID" binding:"required,min=1,max=64"`
OperationID string `json:"operationID" binding:"required"`
}
@@ -46,7 +46,7 @@ type ParseTokenReq struct {
//}
type ExpireTime struct {
- ExpireTimeSeconds uint32 `json:"expireTimeSeconds" `
+ ExpireTimeSeconds uint32 `json:"expireTimeSeconds"`
}
type ParseTokenResp struct {
diff --git a/pkg/apistruct/conversation.go b/pkg/apistruct/conversation.go
index 2abd566e5..1c6ba6e29 100644
--- a/pkg/apistruct/conversation.go
+++ b/pkg/apistruct/conversation.go
@@ -6,23 +6,23 @@ type OptResult struct {
}
type GetAllConversationMessageOptReq struct {
OperationID string `json:"operationID" binding:"required"`
- FromUserID string `json:"fromUserID" binding:"required"`
+ FromUserID string `json:"fromUserID" binding:"required"`
}
type GetAllConversationMessageOptResp struct {
ConversationOptResultList []*OptResult `json:"data"`
}
type GetReceiveMessageOptReq struct {
ConversationIDList []string `json:"conversationIDList" binding:"required"`
- OperationID string `json:"operationID" binding:"required"`
- FromUserID string `json:"fromUserID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
+ FromUserID string `json:"fromUserID" binding:"required"`
}
type GetReceiveMessageOptResp struct {
ConversationOptResultList []*OptResult `json:"data"`
}
type SetReceiveMessageOptReq struct {
- FromUserID string `json:"fromUserID" binding:"required"`
- OperationID string `json:"operationID" binding:"required"`
- Opt *int32 `json:"opt" binding:"required"`
+ FromUserID string `json:"fromUserID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
+ Opt *int32 `json:"opt" binding:"required"`
ConversationIDList []string `json:"conversationIDList" binding:"required"`
}
type SetReceiveMessageOptResp struct {
@@ -30,15 +30,15 @@ type SetReceiveMessageOptResp struct {
}
type Conversation struct {
- OwnerUserID string `json:"ownerUserID" binding:"required"`
- ConversationID string `json:"conversationID" binding:"required"`
- ConversationType int32 `json:"conversationType" binding:"required"`
+ OwnerUserID string `json:"ownerUserID" binding:"required"`
+ ConversationID string `json:"conversationID" binding:"required"`
+ ConversationType int32 `json:"conversationType" binding:"required"`
UserID string `json:"userID"`
GroupID string `json:"groupID"`
- RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
- UnreadCount int32 `json:"unreadCount" binding:"omitempty"`
+ RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
+ UnreadCount int32 `json:"unreadCount" binding:"omitempty"`
DraftTextTime int64 `json:"draftTextTime"`
- IsPinned bool `json:"isPinned" binding:"omitempty"`
+ IsPinned bool `json:"isPinned" binding:"omitempty"`
IsPrivateChat bool `json:"isPrivateChat"`
BurnDuration int32 `json:"burnDuration"`
GroupAtType int32 `json:"groupAtType"`
@@ -51,25 +51,25 @@ type Conversation struct {
type SetConversationReq struct {
Conversation
NotificationType int32 `json:"notificationType"`
- OperationID string `json:"operationID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
}
type SetConversationResp struct {
}
type ModifyConversationFieldReq struct {
Conversation
- FieldType int32 `json:"fieldType" binding:"required"`
- UserIDList []string `json:"userIDList" binding:"required"`
+ FieldType int32 `json:"fieldType" binding:"required"`
+ UserIDList []string `json:"userIDList" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type ModifyConversationFieldResp struct {
}
type BatchSetConversationsReq struct {
- Conversations []Conversation `json:"conversations" binding:"required"`
+ Conversations []Conversation `json:"conversations" binding:"required"`
NotificationType int32 `json:"notificationType"`
- OwnerUserID string `json:"ownerUserID" binding:"required"`
- OperationID string `json:"operationID" binding:"required"`
+ OwnerUserID string `json:"ownerUserID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
}
type BatchSetConversationsResp struct {
@@ -81,8 +81,8 @@ type BatchSetConversationsResp struct {
type GetConversationReq struct {
ConversationID string `json:"conversationID" binding:"required"`
- OwnerUserID string `json:"ownerUserID" binding:"required"`
- OperationID string `json:"operationID" binding:"required"`
+ OwnerUserID string `json:"ownerUserID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
}
type GetConversationResp struct {
@@ -100,8 +100,8 @@ type GetAllConversationsResp struct {
type GetConversationsReq struct {
ConversationIDs []string `json:"conversationIDs" binding:"required"`
- OwnerUserID string `json:"ownerUserID" binding:"required"`
- OperationID string `json:"operationID" binding:"required"`
+ OwnerUserID string `json:"ownerUserID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
}
type GetConversationsResp struct {
@@ -109,10 +109,10 @@ type GetConversationsResp struct {
}
type SetRecvMsgOptReq struct {
- OwnerUserID string `json:"ownerUserID" binding:"required"`
+ OwnerUserID string `json:"ownerUserID" binding:"required"`
ConversationID string `json:"conversationID"`
- RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
- OperationID string `json:"operationID" binding:"required"`
+ RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
+ OperationID string `json:"operationID" binding:"required"`
NotificationType int32 `json:"notificationType"`
}
diff --git a/pkg/apistruct/friend.go b/pkg/apistruct/friend.go
index 4bfc39a91..14a7438ac 100644
--- a/pkg/apistruct/friend.go
+++ b/pkg/apistruct/friend.go
@@ -168,7 +168,7 @@ type FriendRequest struct {
}
type AddBlacklistReq struct {
- ToUserID string `json:"toUserID" binding:"required"`
+ ToUserID string `json:"toUserID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"`
}
type AddBlacklistResp struct {
@@ -176,7 +176,7 @@ type AddBlacklistResp struct {
type ImportFriendReq struct {
FriendUserIDList []string `json:"friendUserIDList" binding:"required"`
- FromUserID string `json:"fromUserID" binding:"required"`
+ FromUserID string `json:"fromUserID" binding:"required"`
}
type ImportFriendResp struct {
@@ -184,7 +184,7 @@ type ImportFriendResp struct {
}
type AddFriendReq struct {
- ToUserID string `json:"toUserID" binding:"required"`
+ ToUserID string `json:"toUserID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"`
ReqMsg string `json:"reqMsg"`
}
@@ -193,16 +193,16 @@ type AddFriendResp struct {
}
type AddFriendResponseReq struct {
- ToUserID string `json:"toUserID" binding:"required"`
+ ToUserID string `json:"toUserID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"`
- HandleResult int32 `json:"flag" binding:"required,oneof=-1 0 1"`
+ HandleResult int32 `json:"flag" binding:"required,oneof=-1 0 1"`
HandleMsg string `json:"handleMsg"`
}
type AddFriendResponseResp struct {
}
type DeleteFriendReq struct {
- ToUserID string `json:"toUserID" binding:"required"`
+ ToUserID string `json:"toUserID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"`
}
type DeleteFriendResp struct {
@@ -216,7 +216,7 @@ type GetBlackListResp struct {
}
type SetFriendRemarkReq struct {
- ToUserID string `json:"toUserID" binding:"required"`
+ ToUserID string `json:"toUserID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"`
Remark string `json:"remark"`
}
@@ -224,14 +224,14 @@ type SetFriendRemarkResp struct {
}
type RemoveBlacklistReq struct {
- ToUserID string `json:"toUserID" binding:"required"`
+ ToUserID string `json:"toUserID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"`
}
type RemoveBlacklistResp struct {
}
type IsFriendReq struct {
- ToUserID string `json:"toUserID" binding:"required"`
+ ToUserID string `json:"toUserID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"`
}
type Response struct {
@@ -243,7 +243,7 @@ type IsFriendResp struct {
type GetFriendListReq struct {
OperationID string `json:"operationID" binding:"required"`
- FromUserID string `json:"fromUserID" binding:"required"`
+ FromUserID string `json:"fromUserID" binding:"required"`
}
type GetFriendListResp struct {
OwnerUserID string `json:"ownerUserID"`
@@ -257,7 +257,7 @@ type GetFriendListResp struct {
type GetFriendApplyListReq struct {
OperationID string `json:"operationID" binding:"required"`
- FromUserID string `json:"fromUserID" binding:"required"`
+ FromUserID string `json:"fromUserID" binding:"required"`
}
type GetFriendApplyListResp struct {
@@ -266,7 +266,7 @@ type GetFriendApplyListResp struct {
type GetSelfApplyListReq struct {
OperationID string `json:"operationID" binding:"required"`
- FromUserID string `json:"fromUserID" binding:"required"`
+ FromUserID string `json:"fromUserID" binding:"required"`
}
type GetSelfApplyListResp struct {
FriendRequestList []FriendRequest `json:"friendRequestList"`
diff --git a/pkg/apistruct/group.go b/pkg/apistruct/group.go
index 22b628492..32af09551 100644
--- a/pkg/apistruct/group.go
+++ b/pkg/apistruct/group.go
@@ -5,10 +5,10 @@ import (
)
type KickGroupMemberReq struct {
- GroupID string `json:"groupID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
KickedUserIDList []string `json:"kickedUserIDList" binding:"required"`
Reason string `json:"reason"`
- OperationID string `json:"operationID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
}
type KickGroupMemberResp struct {
@@ -16,8 +16,8 @@ type KickGroupMemberResp struct {
}
type GetGroupMembersInfoReq struct {
- GroupID string `json:"groupID" binding:"required"`
- MemberList []string `json:"memberList" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
+ MemberList []string `json:"memberList" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type GetGroupMembersInfoResp struct {
@@ -26,10 +26,10 @@ type GetGroupMembersInfoResp struct {
}
type InviteUserToGroupReq struct {
- GroupID string `json:"groupID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
InvitedUserIDList []string `json:"invitedUserIDList" binding:"required"`
Reason string `json:"reason"`
- OperationID string `json:"operationID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
}
type InviteUserToGroupResp struct {
@@ -38,7 +38,7 @@ type InviteUserToGroupResp struct {
type GetJoinedGroupListReq struct {
OperationID string `json:"operationID" binding:"required"`
- FromUserID string `json:"fromUserID" binding:"required"`
+ FromUserID string `json:"fromUserID" binding:"required"`
}
type GetJoinedGroupListResp struct {
GroupInfoList []*sdkws.GroupInfo `json:"-"`
@@ -54,11 +54,11 @@ type GetGroupMemberListReq struct {
type GetGroupMemberListResp struct {
NextSeq int32 `json:"nextSeq"`
MemberList []*sdkws.GroupMemberFullInfo `json:"-"`
- Data []map[string]interface{} `json:"data" swaggerignore:"true"`
+ Data []map[string]interface{} `json:"data" swaggerignore:"true"`
}
type GetGroupAllMemberReq struct {
- GroupID string `json:"groupID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
Offset int32 `json:"offset"`
Count int32 `json:"count"`
@@ -90,7 +90,7 @@ type CreateGroupReq struct {
Introduction string `json:"introduction"`
FaceURL string `json:"faceURL"`
Ex string `json:"ex"`
- OperationID string `json:"operationID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID"`
}
type CreateGroupResp struct {
@@ -100,7 +100,7 @@ type CreateGroupResp struct {
type GetGroupApplicationListReq struct {
OperationID string `json:"operationID" binding:"required"`
- FromUserID string `json:"fromUserID" binding:"required"` //作为管理员或群主收到的 进群申请
+ FromUserID string `json:"fromUserID" binding:"required"` //作为管理员或群主收到的 进群申请
}
type GetGroupApplicationListResp struct {
GroupRequestList []*sdkws.GroupRequest `json:"-"`
@@ -109,7 +109,7 @@ type GetGroupApplicationListResp struct {
type GetUserReqGroupApplicationListReq struct {
OperationID string `json:"operationID" binding:"required"`
- UserID string `json:"userID" binding:"required"`
+ UserID string `json:"userID" binding:"required"`
}
type GetUserRespGroupApplicationResp struct {
@@ -147,9 +147,9 @@ type GetGroupInfoResp struct {
//}
type ApplicationGroupResponseReq struct {
- OperationID string `json:"operationID" binding:"required"`
- GroupID string `json:"groupID" binding:"required"`
- FromUserID string `json:"fromUserID" binding:"required"` //application from FromUserID
+ OperationID string `json:"operationID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
+ FromUserID string `json:"fromUserID" binding:"required"` //application from FromUserID
HandledMsg string `json:"handledMsg"`
HandleResult int32 `json:"handleResult" binding:"required,oneof=-1 1"`
}
@@ -157,9 +157,9 @@ type ApplicationGroupResponseResp struct {
}
type JoinGroupReq struct {
- GroupID string `json:"groupID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
ReqMessage string `json:"reqMessage"`
- OperationID string `json:"operationID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
JoinSource int32 `json:"joinSource"`
InviterUserID string `json:"inviterUserID"`
}
@@ -168,20 +168,20 @@ type JoinGroupResp struct {
}
type QuitGroupReq struct {
- GroupID string `json:"groupID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type QuitGroupResp struct {
}
type SetGroupInfoReq struct {
- GroupID string `json:"groupID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
GroupName string `json:"groupName"`
Notification string `json:"notification"`
Introduction string `json:"introduction"`
FaceURL string `json:"faceURL"`
Ex string `json:"ex"`
- OperationID string `json:"operationID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
NeedVerification *int32 `json:"needVerification"`
LookMemberInfo *int32 `json:"lookMemberInfo"`
ApplyMemberFriend *int32 `json:"applyMemberFriend"`
@@ -191,25 +191,25 @@ type SetGroupInfoResp struct {
}
type TransferGroupOwnerReq struct {
- GroupID string `json:"groupID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
OldOwnerUserID string `json:"oldOwnerUserID" binding:"required"`
NewOwnerUserID string `json:"newOwnerUserID" binding:"required"`
- OperationID string `json:"operationID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
}
type TransferGroupOwnerResp struct {
}
type DismissGroupReq struct {
- GroupID string `json:"groupID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type DismissGroupResp struct {
}
type MuteGroupMemberReq struct {
- OperationID string `json:"operationID" binding:"required"`
- GroupID string `json:"groupID" binding:"required"`
- UserID string `json:"userID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
+ UserID string `json:"userID" binding:"required"`
MutedSeconds uint32 `json:"mutedSeconds" binding:"required"`
}
type MuteGroupMemberResp struct {
@@ -217,30 +217,30 @@ type MuteGroupMemberResp struct {
type CancelMuteGroupMemberReq struct {
OperationID string `json:"operationID" binding:"required"`
- GroupID string `json:"groupID" binding:"required"`
- UserID string `json:"userID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
+ UserID string `json:"userID" binding:"required"`
}
type CancelMuteGroupMemberResp struct {
}
type MuteGroupReq struct {
OperationID string `json:"operationID" binding:"required"`
- GroupID string `json:"groupID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
}
type MuteGroupResp struct {
}
type CancelMuteGroupReq struct {
OperationID string `json:"operationID" binding:"required"`
- GroupID string `json:"groupID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
}
type CancelMuteGroupResp struct {
}
type SetGroupMemberNicknameReq struct {
OperationID string `json:"operationID" binding:"required"`
- GroupID string `json:"groupID" binding:"required"`
- UserID string `json:"userID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
+ UserID string `json:"userID" binding:"required"`
Nickname string `json:"nickname"`
}
@@ -248,12 +248,12 @@ type SetGroupMemberNicknameResp struct {
}
type SetGroupMemberInfoReq struct {
- OperationID string `json:"operationID" binding:"required"`
- GroupID string `json:"groupID" binding:"required"`
- UserID string `json:"userID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
+ UserID string `json:"userID" binding:"required"`
Nickname *string `json:"nickname"`
FaceURL *string `json:"userGroupFaceUrl"`
- RoleLevel *int32 `json:"roleLevel" validate:"gte=1,lte=3"`
+ RoleLevel *int32 `json:"roleLevel" validate:"gte=1,lte=3"`
Ex *string `json:"ex"`
}
diff --git a/pkg/apistruct/manage.go b/pkg/apistruct/manage.go
index 1aa70fa1d..832597fd0 100644
--- a/pkg/apistruct/manage.go
+++ b/pkg/apistruct/manage.go
@@ -5,7 +5,7 @@ import (
)
type DeleteUsersReq struct {
- OperationID string `json:"operationID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
DeleteUserIDList []string `json:"deleteUserIDList" binding:"required"`
}
type DeleteUsersResp struct {
@@ -19,43 +19,43 @@ type GetAllUsersUidResp struct {
}
type GetUsersOnlineStatusReq struct {
OperationID string `json:"operationID" binding:"required"`
- UserIDList []string `json:"userIDList" binding:"required,lte=200"`
+ UserIDList []string `json:"userIDList" binding:"required,lte=200"`
}
type GetUsersOnlineStatusResp struct {
//SuccessResult []*msggateway.GetUsersOnlineStatusResp_SuccessResult `json:"data"`
}
type AccountCheckReq struct {
- OperationID string `json:"operationID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
CheckUserIDList []string `json:"checkUserIDList" binding:"required,lte=100"`
}
type AccountCheckResp struct {
}
type ManagementSendMsg struct {
- SendID string `json:"sendID" binding:"required"`
- GroupID string `json:"groupID" binding:"required_if=SessionType 2|required_if=SessionType 3"`
- SenderNickname string `json:"senderNickname" `
- SenderFaceURL string `json:"senderFaceURL" `
+ SendID string `json:"sendID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required_if=SessionType 2|required_if=SessionType 3"`
+ SenderNickname string `json:"senderNickname"`
+ SenderFaceURL string `json:"senderFaceURL"`
SenderPlatformID int32 `json:"senderPlatformID"`
- Content map[string]interface{} `json:"content" binding:"required" swaggerignore:"true"`
- ContentType int32 `json:"contentType" binding:"required"`
- SessionType int32 `json:"sessionType" binding:"required"`
+ Content map[string]interface{} `json:"content" binding:"required" swaggerignore:"true"`
+ ContentType int32 `json:"contentType" binding:"required"`
+ SessionType int32 `json:"sessionType" binding:"required"`
IsOnlineOnly bool `json:"isOnlineOnly"`
NotOfflinePush bool `json:"notOfflinePush"`
OfflinePushInfo *sdkws.OfflinePushInfo `json:"offlinePushInfo"`
}
type ManagementSendMsgReq struct {
- SendID string `json:"sendID" binding:"required"`
- RecvID string `json:"recvID" binding:"required_if" message:"recvID is required if sessionType is SingleChatType or NotificationChatType"`
- GroupID string `json:"groupID" binding:"required_if" message:"groupID is required if sessionType is GroupChatType or SuperGroupChatType"`
- SenderNickname string `json:"senderNickname" `
- SenderFaceURL string `json:"senderFaceURL" `
+ SendID string `json:"sendID" binding:"required"`
+ RecvID string `json:"recvID" binding:"required_if" message:"recvID is required if sessionType is SingleChatType or NotificationChatType"`
+ GroupID string `json:"groupID" binding:"required_if" message:"groupID is required if sessionType is GroupChatType or SuperGroupChatType"`
+ SenderNickname string `json:"senderNickname"`
+ SenderFaceURL string `json:"senderFaceURL"`
SenderPlatformID int32 `json:"senderPlatformID"`
- Content map[string]interface{} `json:"content" binding:"required" swaggerignore:"true"`
- ContentType int32 `json:"contentType" binding:"required"`
- SessionType int32 `json:"sessionType" binding:"required"`
+ Content map[string]interface{} `json:"content" binding:"required" swaggerignore:"true"`
+ ContentType int32 `json:"contentType" binding:"required"`
+ SessionType int32 `json:"sessionType" binding:"required"`
IsOnlineOnly bool `json:"isOnlineOnly"`
NotOfflinePush bool `json:"notOfflinePush"`
OfflinePushInfo *sdkws.OfflinePushInfo `json:"offlinePushInfo"`
@@ -81,7 +81,7 @@ type SingleReturnResult struct {
ServerMsgID string `json:"serverMsgID"`
ClientMsgID string `json:"clientMsgID"`
SendTime int64 `json:"sendTime"`
- RecvID string `json:"recvID" `
+ RecvID string `json:"recvID"`
}
type CheckMsgIsSendSuccessReq struct {
diff --git a/pkg/apistruct/msg.go b/pkg/apistruct/msg.go
index 042d760b8..5efa917d1 100644
--- a/pkg/apistruct/msg.go
+++ b/pkg/apistruct/msg.go
@@ -6,8 +6,8 @@ import (
)
type DelMsgReq struct {
- UserID string `json:"userID,omitempty" binding:"required"`
- SeqList []uint32 `json:"seqList,omitempty" binding:"required"`
+ UserID string `json:"userID,omitempty" binding:"required"`
+ SeqList []uint32 `json:"seqList,omitempty" binding:"required"`
OperationID string `json:"operationID,omitempty" binding:"required"`
}
@@ -15,19 +15,19 @@ type DelMsgResp struct {
}
type CleanUpMsgReq struct {
- UserID string `json:"userID" binding:"required"`
- OperationID string `json:"operationID" binding:"required"`
+ UserID string `json:"userID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
}
type CleanUpMsgResp struct {
}
type DelSuperGroupMsgReq struct {
- UserID string `json:"userID" binding:"required"`
- GroupID string `json:"groupID" binding:"required"`
+ UserID string `json:"userID" binding:"required"`
+ GroupID string `json:"groupID" binding:"required"`
SeqList []uint32 `json:"seqList,omitempty"`
IsAllDelete bool `json:"isAllDelete"`
- OperationID string `json:"operationID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
}
type DelSuperGroupMsgResp struct {
@@ -40,21 +40,21 @@ type MsgDeleteNotificationElem struct {
}
type SetMsgMinSeqReq struct {
- UserID string `json:"userID" binding:"required"`
+ UserID string `json:"userID" binding:"required"`
GroupID string `json:"groupID"`
- MinSeq uint32 `json:"minSeq" binding:"required"`
- OperationID string `json:"operationID" binding:"required"`
+ MinSeq uint32 `json:"minSeq" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
}
type SetMsgMinSeqResp struct {
}
type ModifyMessageReactionExtensionsReq struct {
- OperationID string `json:"operationID" binding:"required"`
- conversationID string `json:"conversationID" binding:"required"`
- SessionType int32 `json:"sessionType" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
+ conversationID string `json:"conversationID" binding:"required"`
+ SessionType int32 `json:"sessionType" binding:"required"`
ReactionExtensionList map[string]*sdkws.KeyValue `json:"reactionExtensionList,omitempty" binding:"required"`
- ClientMsgID string `json:"clientMsgID" binding:"required"`
+ ClientMsgID string `json:"clientMsgID" binding:"required"`
Ex *string `json:"ex"`
AttachedInfo *string `json:"attachedInfo"`
IsReact bool `json:"isReact"`
@@ -71,10 +71,11 @@ type ModifyMessageReactionExtensionsResp struct {
}
//type OperateMessageListReactionExtensionsReq struct {
-// OperationID string `json:"operationID" binding:"required"`
-// conversationID string `json:"conversationID" binding:"required"`
-// SessionType string `json:"sessionType" binding:"required"`
-// MessageReactionKeyList []*msg.GetMessageListReactionExtensionsReq_MessageReactionKey `json:"messageReactionKeyList" binding:"required"`
+// OperationID string `json:"operationID"
+// binding:"required"` conversationID string
+// `json:"conversationID" binding:"required"` SessionType string
+// `json:"sessionType" binding:"required"` MessageReactionKeyList
+// []*msg.GetMessageListReactionExtensionsReq_MessageReactionKey `json:"messageReactionKeyList" binding:"required"`
//}
type OperateMessageListReactionExtensionsResp struct {
@@ -99,12 +100,12 @@ type AddMessageReactionExtensionsReq ModifyMessageReactionExtensionsReq
type AddMessageReactionExtensionsResp ModifyMessageReactionExtensionsResp
type DeleteMessageReactionExtensionsReq struct {
- OperationID string `json:"operationID" binding:"required"`
- conversationID string `json:"conversationID" binding:"required"`
- SessionType int32 `json:"sessionType" binding:"required"`
- ClientMsgID string `json:"clientMsgID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
+ conversationID string `json:"conversationID" binding:"required"`
+ SessionType int32 `json:"sessionType" binding:"required"`
+ ClientMsgID string `json:"clientMsgID" binding:"required"`
IsExternalExtensions bool `json:"isExternalExtensions"`
- MsgFirstModifyTime int64 `json:"msgFirstModifyTime" binding:"required"`
+ MsgFirstModifyTime int64 `json:"msgFirstModifyTime" binding:"required"`
ReactionExtensionList []*sdkws.KeyValue `json:"reactionExtensionList" binding:"required"`
}
@@ -114,17 +115,17 @@ type DeleteMessageReactionExtensionsResp struct {
type PictureBaseInfo struct {
UUID string `mapstructure:"uuid"`
- Type string `mapstructure:"type" `
- Size int64 `mapstructure:"size" `
- Width int32 `mapstructure:"width" `
+ Type string `mapstructure:"type"`
+ Size int64 `mapstructure:"size"`
+ Width int32 `mapstructure:"width"`
Height int32 `mapstructure:"height"`
- Url string `mapstructure:"url" `
+ Url string `mapstructure:"url"`
}
type PictureElem struct {
SourcePath string `mapstructure:"sourcePath"`
SourcePicture PictureBaseInfo `mapstructure:"sourcePicture"`
- BigPicture PictureBaseInfo `mapstructure:"bigPicture" `
+ BigPicture PictureBaseInfo `mapstructure:"bigPicture"`
SnapshotPicture PictureBaseInfo `mapstructure:"snapshotPicture"`
}
type SoundElem struct {
@@ -166,7 +167,7 @@ type LocationElem struct {
Latitude float64 `mapstructure:"latitude"`
}
type CustomElem struct {
- Data string `mapstructure:"data" validate:"required"`
+ Data string `mapstructure:"data" validate:"required"`
Description string `mapstructure:"description"`
Extension string `mapstructure:"extension"`
}
@@ -178,23 +179,23 @@ type RevokeElem struct {
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
}
type OANotificationElem struct {
- NotificationName string `mapstructure:"notificationName" json:"notificationName" validate:"required"`
+ NotificationName string `mapstructure:"notificationName" json:"notificationName" validate:"required"`
NotificationFaceURL string `mapstructure:"notificationFaceURL" json:"notificationFaceURL"`
- 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"`
- PictureElem PictureElem `mapstructure:"pictureElem" json:"pictureElem"`
- SoundElem SoundElem `mapstructure:"soundElem" json:"soundElem"`
- VideoElem VideoElem `mapstructure:"videoElem" json:"videoElem"`
- FileElem FileElem `mapstructure:"fileElem" json:"fileElem"`
- Ex string `mapstructure:"ex" json:"ex"`
+ 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"`
+ PictureElem PictureElem `mapstructure:"pictureElem" json:"pictureElem"`
+ SoundElem SoundElem `mapstructure:"soundElem" json:"soundElem"`
+ VideoElem VideoElem `mapstructure:"videoElem" json:"videoElem"`
+ FileElem FileElem `mapstructure:"fileElem" json:"fileElem"`
+ Ex string `mapstructure:"ex" json:"ex"`
}
type MessageRevoked struct {
- RevokerID string `mapstructure:"revokerID" json:"revokerID" validate:"required"`
- RevokerRole int32 `mapstructure:"revokerRole" json:"revokerRole" validate:"required"`
- ClientMsgID string `mapstructure:"clientMsgID" json:"clientMsgID" validate:"required"`
+ RevokerID string `mapstructure:"revokerID" json:"revokerID" validate:"required"`
+ RevokerRole int32 `mapstructure:"revokerRole" json:"revokerRole" validate:"required"`
+ ClientMsgID string `mapstructure:"clientMsgID" json:"clientMsgID" validate:"required"`
RevokerNickname string `mapstructure:"revokerNickname" json:"revokerNickname"`
- SessionType int32 `mapstructure:"sessionType" json:"sessionType" validate:"required"`
- Seq uint32 `mapstructure:"seq" json:"seq" validate:"required"`
+ SessionType int32 `mapstructure:"sessionType" json:"sessionType" validate:"required"`
+ Seq uint32 `mapstructure:"seq" json:"seq" validate:"required"`
}
diff --git a/pkg/apistruct/public.go b/pkg/apistruct/public.go
index e943a4af1..fc3d3e707 100644
--- a/pkg/apistruct/public.go
+++ b/pkg/apistruct/public.go
@@ -1,18 +1,18 @@
package apistruct
type ApiUserInfo struct {
- UserID string `json:"userID" binding:"required,min=1,max=64" swaggo:"true,用户ID,"`
- Nickname string `json:"nickname" binding:"omitempty,min=1,max=64" swaggo:"true,my id,19"`
- FaceURL string `json:"faceURL" binding:"omitempty,max=1024"`
- Gender int32 `json:"gender" binding:"omitempty,oneof=0 1 2"`
+ UserID string `json:"userID" binding:"required,min=1,max=64" swaggo:"true,用户ID,"`
+ Nickname string `json:"nickname" binding:"omitempty,min=1,max=64" swaggo:"true,my id,19"`
+ FaceURL string `json:"faceURL" binding:"omitempty,max=1024"`
+ Gender int32 `json:"gender" binding:"omitempty,oneof=0 1 2"`
PhoneNumber string `json:"phoneNumber" binding:"omitempty,max=32"`
- Birth int64 `json:"birth" binding:"omitempty"`
- Email string `json:"email" binding:"omitempty,max=64"`
+ Birth int64 `json:"birth" binding:"omitempty"`
+ Email string `json:"email" binding:"omitempty,max=64"`
CreateTime int64 `json:"createTime"`
- Ex string `json:"ex" binding:"omitempty,max=1024"`
+ Ex string `json:"ex" binding:"omitempty,max=1024"`
}
type GroupAddMemberInfo struct {
- UserID string `json:"userID" binding:"required"`
+ UserID string `json:"userID" binding:"required"`
RoleLevel int32 `json:"roleLevel" binding:"required,oneof= 1 3"`
}
diff --git a/pkg/apistruct/third.go b/pkg/apistruct/third.go
index 355700fee..80e9d4930 100644
--- a/pkg/apistruct/third.go
+++ b/pkg/apistruct/third.go
@@ -18,7 +18,7 @@ type MiniostorageCredentialResp struct {
type MinioUploadFileReq struct {
OperationID string `form:"operationID" binding:"required"`
- FileType int `form:"fileType" binding:"required"`
+ FileType int `form:"fileType" binding:"required"`
}
type MinioUploadFile struct {
@@ -36,12 +36,12 @@ type MinioUploadFileResp struct {
type UploadUpdateAppReq struct {
OperationID string `form:"operationID" binding:"required"`
- Type int `form:"type" binding:"required"`
- Version string `form:"version" binding:"required"`
- File *multipart.FileHeader `form:"file" binding:"required"`
+ Type int `form:"type" binding:"required"`
+ Version string `form:"version" binding:"required"`
+ File *multipart.FileHeader `form:"file" binding:"required"`
Yaml *multipart.FileHeader `form:"yaml"`
ForceUpdate bool `form:"forceUpdate"`
- UpdateLog string `form:"updateLog" binding:"required"`
+ UpdateLog string `form:"updateLog" binding:"required"`
}
type UploadUpdateAppResp struct {
@@ -49,8 +49,8 @@ type UploadUpdateAppResp struct {
type GetDownloadURLReq struct {
OperationID string `json:"operationID" binding:"required"`
- Type int `json:"type" binding:"required"`
- Version string `json:"version" binding:"required"`
+ Type int `json:"type" binding:"required"`
+ Version string `json:"version" binding:"required"`
}
type GetDownloadURLResp struct {
@@ -101,15 +101,15 @@ type GetRTCInvitationInfoStartAppResp struct {
*/
type FcmUpdateTokenReq struct {
OperationID string `json:"operationID" binding:"required"`
- Platform int `json:"platform" binding:"required,min=1,max=2"` //only for ios + android
- FcmToken string `json:"fcmToken" binding:"required"`
+ Platform int `json:"platform" binding:"required,min=1,max=2"` //only for ios + android
+ FcmToken string `json:"fcmToken" binding:"required"`
}
type FcmUpdateTokenResp struct {
}
type SetAppBadgeReq struct {
- OperationID string `json:"operationID" binding:"required"`
- FromUserID string `json:"fromUserID" binding:"required"`
+ OperationID string `json:"operationID" binding:"required"`
+ FromUserID string `json:"fromUserID" binding:"required"`
AppUnreadCount int32 `json:"appUnreadCount"`
}
diff --git a/pkg/common/cmd/msg_gateway.go b/pkg/common/cmd/msg_gateway.go
index 824e6163e..deea1c106 100644
--- a/pkg/common/cmd/msg_gateway.go
+++ b/pkg/common/cmd/msg_gateway.go
@@ -3,8 +3,9 @@ package cmd
import (
"github.com/OpenIMSDK/Open-IM-Server/internal/msggateway"
//"github.com/OpenIMSDK/Open-IM-Server/internal/msggateway"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/spf13/cobra"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
)
type MsgGatewayCmd struct {
diff --git a/pkg/common/cmd/msg_transfer.go b/pkg/common/cmd/msg_transfer.go
index 433faa5b5..d6d65a1dd 100644
--- a/pkg/common/cmd/msg_transfer.go
+++ b/pkg/common/cmd/msg_transfer.go
@@ -1,8 +1,9 @@
package cmd
import (
- "github.com/OpenIMSDK/Open-IM-Server/internal/msgtransfer"
"github.com/spf13/cobra"
+
+ "github.com/OpenIMSDK/Open-IM-Server/internal/msgtransfer"
)
type MsgTransferCmd struct {
diff --git a/pkg/common/cmd/msg_utils.go b/pkg/common/cmd/msg_utils.go
index f762976e7..00b3f7359 100644
--- a/pkg/common/cmd/msg_utils.go
+++ b/pkg/common/cmd/msg_utils.go
@@ -1,8 +1,9 @@
package cmd
import (
- "github.com/OpenIMSDK/Open-IM-Server/internal/tools"
"github.com/spf13/cobra"
+
+ "github.com/OpenIMSDK/Open-IM-Server/internal/tools"
)
type MsgUtilsCmd struct {
diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go
index be04ac79a..ee586e247 100644
--- a/pkg/common/cmd/root.go
+++ b/pkg/common/cmd/root.go
@@ -3,10 +3,11 @@ package cmd
import (
"fmt"
+ "github.com/spf13/cobra"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
- "github.com/spf13/cobra"
)
type RootCmd struct {
diff --git a/pkg/common/cmd/rpc.go b/pkg/common/cmd/rpc.go
index d24073940..be44f7ce0 100644
--- a/pkg/common/cmd/rpc.go
+++ b/pkg/common/cmd/rpc.go
@@ -3,10 +3,11 @@ package cmd
import (
"errors"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/startrpc"
"github.com/spf13/cobra"
"google.golang.org/grpc"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/startrpc"
)
type RpcCmd struct {
@@ -26,7 +27,10 @@ func (a *RpcCmd) Exec() error {
return a.Execute()
}
-func (a *RpcCmd) StartSvr(name string, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) error {
+func (a *RpcCmd) StartSvr(
+ name string,
+ rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error,
+) error {
if a.GetPortFlag() == 0 {
return errors.New("port is required")
}
diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go
index a49dcec86..40161932b 100644
--- a/pkg/common/config/config.go
+++ b/pkg/common/config/config.go
@@ -303,6 +303,15 @@ type notification struct {
}
func GetServiceNames() []string {
- return []string{Config.RpcRegisterName.OpenImUserName, Config.RpcRegisterName.OpenImFriendName, Config.RpcRegisterName.OpenImMsgName, Config.RpcRegisterName.OpenImPushName, Config.RpcRegisterName.OpenImMessageGatewayName,
- Config.RpcRegisterName.OpenImGroupName, Config.RpcRegisterName.OpenImAuthName, Config.RpcRegisterName.OpenImConversationName, Config.RpcRegisterName.OpenImThirdName}
+ return []string{
+ Config.RpcRegisterName.OpenImUserName,
+ Config.RpcRegisterName.OpenImFriendName,
+ Config.RpcRegisterName.OpenImMsgName,
+ Config.RpcRegisterName.OpenImPushName,
+ Config.RpcRegisterName.OpenImMessageGatewayName,
+ Config.RpcRegisterName.OpenImGroupName,
+ Config.RpcRegisterName.OpenImAuthName,
+ Config.RpcRegisterName.OpenImConversationName,
+ Config.RpcRegisterName.OpenImThirdName,
+ }
}
diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go
index 0a32e81c7..ebd6c49fc 100644
--- a/pkg/common/config/parse.go
+++ b/pkg/common/config/parse.go
@@ -7,10 +7,11 @@ import (
"path/filepath"
"runtime"
+ "gopkg.in/yaml.v3"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gopkg.in/yaml.v3"
)
var (
diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go
index 72cc34af8..1d0a98558 100644
--- a/pkg/common/constant/constant.go
+++ b/pkg/common/constant/constant.go
@@ -125,7 +125,8 @@ const (
SingleTerminalLogin = 2
//The web side can be online at the same time, and the other side can only log in at one end
WebAndOther = 3
- //The PC side is mutually exclusive, and the mobile side is mutually exclusive, but the web side can be online at the same time
+ // The PC side is mutually exclusive, and the mobile side is mutually exclusive, but the web side can be online at
+ // the same time
PcMobileAndWeb = 4
//The PC terminal can be online at the same time,but other terminal only one of the endpoints can login
PCAndOther = 5
diff --git a/pkg/common/convert/black.go b/pkg/common/convert/black.go
index d09c30910..cadd822c8 100644
--- a/pkg/common/convert/black.go
+++ b/pkg/common/convert/black.go
@@ -8,7 +8,11 @@ import (
sdk "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
)
-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) {
+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) {
var userIDs []string
for _, blackDB := range blackDBs {
userIDs = append(userIDs, blackDB.BlockUserID)
diff --git a/pkg/common/convert/friend.go b/pkg/common/convert/friend.go
index d7e2345ae..b907f9ad0 100644
--- a/pkg/common/convert/friend.go
+++ b/pkg/common/convert/friend.go
@@ -16,7 +16,11 @@ func FriendPb2DB(friend *sdkws.FriendInfo) *relation.FriendModel {
return dbFriend
}
-func FriendDB2Pb(ctx context.Context, friendDB *relation.FriendModel, getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error)) (*sdkws.FriendInfo, error) {
+func FriendDB2Pb(
+ ctx context.Context,
+ friendDB *relation.FriendModel,
+ 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)
users, err := getUsers(ctx, []string{friendDB.FriendUserID})
@@ -31,7 +35,11 @@ func FriendDB2Pb(ctx context.Context, friendDB *relation.FriendModel, getUsers f
return pbfriend, nil
}
-func FriendsDB2Pb(ctx context.Context, friendsDB []*relation.FriendModel, getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error)) (friendsPb []*sdkws.FriendInfo, err error) {
+func FriendsDB2Pb(
+ ctx context.Context,
+ friendsDB []*relation.FriendModel,
+ getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error),
+) (friendsPb []*sdkws.FriendInfo, err error) {
var userID []string
for _, friendDB := range friendsDB {
userID = append(userID, friendDB.FriendUserID)
@@ -53,7 +61,11 @@ func FriendsDB2Pb(ctx context.Context, friendsDB []*relation.FriendModel, getUse
return friendsPb, nil
}
-func FriendRequestDB2Pb(ctx context.Context, friendRequests []*relation.FriendRequestModel, getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error)) ([]*sdkws.FriendRequest, error) {
+func FriendRequestDB2Pb(
+ ctx context.Context,
+ friendRequests []*relation.FriendRequestModel,
+ getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error),
+) ([]*sdkws.FriendRequest, error) {
userIDMap := make(map[string]struct{})
for _, friendRequest := range friendRequests {
userIDMap[friendRequest.ToUserID] = struct{}{}
diff --git a/pkg/common/convert/group.go b/pkg/common/convert/group.go
index 74972b6ce..adec0e6f3 100644
--- a/pkg/common/convert/group.go
+++ b/pkg/common/convert/group.go
@@ -41,7 +41,12 @@ func Pb2DbGroupRequest(req *pbGroup.GroupApplicationResponseReq, handleUserID st
}
}
-func Db2PbCMSGroup(m *relation.GroupModel, ownerUserID string, ownerUserName string, memberCount uint32) *pbGroup.CMSGroup {
+func Db2PbCMSGroup(
+ m *relation.GroupModel,
+ ownerUserID string,
+ ownerUserName string,
+ memberCount uint32,
+) *pbGroup.CMSGroup {
return &pbGroup.CMSGroup{
GroupInfo: Db2PbGroupInfo(m, ownerUserID, memberCount),
GroupOwnerUserID: ownerUserID,
@@ -66,7 +71,11 @@ func Db2PbGroupMember(m *relation.GroupMemberModel) *sdkws.GroupMemberFullInfo {
}
}
-func Db2PbGroupRequest(m *relation.GroupRequestModel, user *sdkws.PublicUserInfo, group *sdkws.GroupInfo) *sdkws.GroupRequest {
+func Db2PbGroupRequest(
+ m *relation.GroupRequestModel,
+ user *sdkws.PublicUserInfo,
+ group *sdkws.GroupInfo,
+) *sdkws.GroupRequest {
return &sdkws.GroupRequest{
UserInfo: user,
GroupInfo: group,
@@ -82,7 +91,11 @@ func Db2PbGroupRequest(m *relation.GroupRequestModel, user *sdkws.PublicUserInfo
}
}
-func Db2PbGroupAbstractInfo(groupID string, groupMemberNumber uint32, groupMemberListHash uint64) *pbGroup.GroupAbstractInfo {
+func Db2PbGroupAbstractInfo(
+ groupID string,
+ groupMemberNumber uint32,
+ groupMemberListHash uint64,
+) *pbGroup.GroupAbstractInfo {
return &pbGroup.GroupAbstractInfo{
GroupID: groupID,
GroupMemberNumber: groupMemberNumber,
diff --git a/pkg/common/db/cache/black.go b/pkg/common/db/cache/black.go
index 18928567c..ca2f2ed9a 100644
--- a/pkg/common/db/cache/black.go
+++ b/pkg/common/db/cache/black.go
@@ -4,9 +4,10 @@ import (
"context"
"time"
- relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/dtm-labs/rockscache"
"github.com/redis/go-redis/v9"
+
+ relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
)
const (
@@ -31,7 +32,11 @@ type BlackCacheRedis struct {
blackDB relationTb.BlackModelInterface
}
-func NewBlackCacheRedis(rdb redis.UniversalClient, blackDB relationTb.BlackModelInterface, options rockscache.Options) BlackCache {
+func NewBlackCacheRedis(
+ rdb redis.UniversalClient,
+ blackDB relationTb.BlackModelInterface,
+ options rockscache.Options,
+) BlackCache {
rcClient := rockscache.NewClient(rdb, options)
return &BlackCacheRedis{
expireTime: blackExpireTime,
@@ -55,9 +60,15 @@ func (b *BlackCacheRedis) getBlackIDsKey(ownerUserID string) string {
}
func (b *BlackCacheRedis) GetBlackIDs(ctx context.Context, userID string) (blackIDs []string, err error) {
- return getCache(ctx, b.rcClient, b.getBlackIDsKey(userID), b.expireTime, func(ctx context.Context) ([]string, error) {
- return b.blackDB.FindBlackUserIDs(ctx, userID)
- })
+ return getCache(
+ ctx,
+ b.rcClient,
+ b.getBlackIDsKey(userID),
+ b.expireTime,
+ func(ctx context.Context) ([]string, error) {
+ return b.blackDB.FindBlackUserIDs(ctx, userID)
+ },
+ )
}
func (b *BlackCacheRedis) DelBlackIDs(ctx context.Context, userID string) BlackCache {
diff --git a/pkg/common/db/cache/conversation.go b/pkg/common/db/cache/conversation.go
index bc2f86cae..1005ee325 100644
--- a/pkg/common/db/cache/conversation.go
+++ b/pkg/common/db/cache/conversation.go
@@ -7,11 +7,12 @@ import (
"strings"
"time"
+ "github.com/dtm-labs/rockscache"
+ "github.com/redis/go-redis/v9"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/dtm-labs/rockscache"
- "github.com/redis/go-redis/v9"
)
const (
@@ -42,7 +43,11 @@ type ConversationCache interface {
DelConvsersations(ownerUserID string, conversationIDs ...string) ConversationCache
DelUsersConversation(conversationID string, ownerUserIDs ...string) ConversationCache
// get one conversation from msgCache
- GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error)
+ GetConversations(
+ ctx context.Context,
+ ownerUserID string,
+ conversationIDs []string,
+ ) ([]*relationTb.ConversationModel, error)
// get one user's all conversations from msgCache
GetUserAllConversations(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error)
// get user conversation recv msg from msgCache
@@ -58,13 +63,25 @@ type ConversationCache interface {
GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error)
DelUserAllHasReadSeqs(ownerUserID string, conversationIDs ...string) ConversationCache
- GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*relationTb.ConversationModel, error)
+ GetConversationsByConversationID(
+ ctx context.Context,
+ conversationIDs []string,
+ ) ([]*relationTb.ConversationModel, error)
DelConversationByConversationID(conversationIDs ...string) ConversationCache
}
-func NewConversationRedis(rdb redis.UniversalClient, opts rockscache.Options, db relationTb.ConversationModelInterface) ConversationCache {
+func NewConversationRedis(
+ rdb redis.UniversalClient,
+ opts rockscache.Options,
+ db relationTb.ConversationModelInterface,
+) ConversationCache {
rcClient := rockscache.NewClient(rdb, opts)
- return &ConversationRedisCache{rcClient: rcClient, metaCache: NewMetaCacheRedis(rcClient), conversationDB: db, expireTime: conversationExpireTime}
+ return &ConversationRedisCache{
+ rcClient: rcClient,
+ metaCache: NewMetaCacheRedis(rcClient),
+ conversationDB: db,
+ expireTime: conversationExpireTime,
+ }
}
type ConversationRedisCache struct {
@@ -74,13 +91,27 @@ type ConversationRedisCache struct {
expireTime time.Duration
}
-func NewNewConversationRedis(rdb redis.UniversalClient, conversationDB *relation.ConversationGorm, options rockscache.Options) ConversationCache {
+func NewNewConversationRedis(
+ rdb redis.UniversalClient,
+ conversationDB *relation.ConversationGorm,
+ options rockscache.Options,
+) ConversationCache {
rcClient := rockscache.NewClient(rdb, options)
- return &ConversationRedisCache{rcClient: rcClient, metaCache: NewMetaCacheRedis(rcClient), conversationDB: conversationDB, expireTime: conversationExpireTime}
+ return &ConversationRedisCache{
+ rcClient: rcClient,
+ metaCache: NewMetaCacheRedis(rcClient),
+ conversationDB: conversationDB,
+ expireTime: conversationExpireTime,
+ }
}
func (c *ConversationRedisCache) NewCache() ConversationCache {
- return &ConversationRedisCache{rcClient: c.rcClient, metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDelKeys()...), conversationDB: c.conversationDB, expireTime: c.expireTime}
+ return &ConversationRedisCache{
+ rcClient: c.rcClient,
+ metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDelKeys()...),
+ conversationDB: c.conversationDB,
+ expireTime: c.expireTime,
+ }
}
func (c *ConversationRedisCache) getConversationKey(ownerUserID, conversationID string) string {
@@ -108,9 +139,15 @@ func (c *ConversationRedisCache) getConversationHasReadSeqKey(ownerUserID, conve
}
func (c *ConversationRedisCache) GetUserConversationIDs(ctx context.Context, ownerUserID string) ([]string, error) {
- return getCache(ctx, c.rcClient, c.getConversationIDsKey(ownerUserID), c.expireTime, func(ctx context.Context) ([]string, error) {
- return c.conversationDB.FindUserIDAllConversationID(ctx, ownerUserID)
- })
+ return getCache(
+ ctx,
+ c.rcClient,
+ c.getConversationIDsKey(ownerUserID),
+ c.expireTime,
+ func(ctx context.Context) ([]string, error) {
+ return c.conversationDB.FindUserIDAllConversationID(ctx, ownerUserID)
+ },
+ )
}
func (c *ConversationRedisCache) DelConversationIDs(userIDs ...string) ConversationCache {
@@ -127,17 +164,26 @@ func (c *ConversationRedisCache) getUserConversationIDsHashKey(ownerUserID strin
return conversationIDsHashKey + ownerUserID
}
-func (c *ConversationRedisCache) GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error) {
- return getCache(ctx, c.rcClient, c.getUserConversationIDsHashKey(ownerUserID), c.expireTime, func(ctx context.Context) (uint64, error) {
- conversationIDs, err := c.GetUserConversationIDs(ctx, ownerUserID)
- if err != nil {
- return 0, err
- }
- utils.Sort(conversationIDs, true)
- bi := big.NewInt(0)
- bi.SetString(utils.Md5(strings.Join(conversationIDs, ";"))[0:8], 16)
- return bi.Uint64(), nil
- })
+func (c *ConversationRedisCache) GetUserConversationIDsHash(
+ ctx context.Context,
+ ownerUserID string,
+) (hash uint64, err error) {
+ return getCache(
+ ctx,
+ c.rcClient,
+ c.getUserConversationIDsHashKey(ownerUserID),
+ c.expireTime,
+ func(ctx context.Context) (uint64, error) {
+ conversationIDs, err := c.GetUserConversationIDs(ctx, ownerUserID)
+ if err != nil {
+ return 0, err
+ }
+ utils.Sort(conversationIDs, true)
+ bi := big.NewInt(0)
+ bi.SetString(utils.Md5(strings.Join(conversationIDs, ";"))[0:8], 16)
+ return bi.Uint64(), nil
+ },
+ )
}
func (c *ConversationRedisCache) DelUserConversationIDsHash(ownerUserIDs ...string) ConversationCache {
@@ -150,10 +196,19 @@ func (c *ConversationRedisCache) DelUserConversationIDsHash(ownerUserIDs ...stri
return cache
}
-func (c *ConversationRedisCache) GetConversation(ctx context.Context, ownerUserID, conversationID string) (*relationTb.ConversationModel, error) {
- return getCache(ctx, c.rcClient, c.getConversationKey(ownerUserID, conversationID), c.expireTime, func(ctx context.Context) (*relationTb.ConversationModel, error) {
- return c.conversationDB.Take(ctx, ownerUserID, conversationID)
- })
+func (c *ConversationRedisCache) GetConversation(
+ ctx context.Context,
+ ownerUserID, conversationID string,
+) (*relationTb.ConversationModel, error) {
+ return getCache(
+ ctx,
+ c.rcClient,
+ c.getConversationKey(ownerUserID, conversationID),
+ c.expireTime,
+ func(ctx context.Context) (*relationTb.ConversationModel, error) {
+ return c.conversationDB.Take(ctx, ownerUserID, conversationID)
+ },
+ )
}
func (c *ConversationRedisCache) DelConvsersations(ownerUserID string, convsersationIDs ...string) ConversationCache {
@@ -166,7 +221,10 @@ func (c *ConversationRedisCache) DelConvsersations(ownerUserID string, convsersa
return cache
}
-func (c *ConversationRedisCache) getConversationIndex(convsation *relationTb.ConversationModel, keys []string) (int, error) {
+func (c *ConversationRedisCache) getConversationIndex(
+ convsation *relationTb.ConversationModel,
+ keys []string,
+) (int, error) {
key := c.getConversationKey(convsation.OwnerUserID, convsation.ConversationID)
for _i, _key := range keys {
if _key == key {
@@ -176,17 +234,31 @@ func (c *ConversationRedisCache) getConversationIndex(convsation *relationTb.Con
return 0, errors.New("not found key:" + key + " in keys")
}
-func (c *ConversationRedisCache) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error) {
+func (c *ConversationRedisCache) GetConversations(
+ ctx context.Context,
+ ownerUserID string,
+ conversationIDs []string,
+) ([]*relationTb.ConversationModel, error) {
var keys []string
for _, conversarionID := range conversationIDs {
keys = append(keys, c.getConversationKey(ownerUserID, conversarionID))
}
- return batchGetCache(ctx, c.rcClient, keys, c.expireTime, c.getConversationIndex, func(ctx context.Context) ([]*relationTb.ConversationModel, error) {
- return c.conversationDB.Find(ctx, ownerUserID, conversationIDs)
- })
-}
-
-func (c *ConversationRedisCache) GetUserAllConversations(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) {
+ return batchGetCache(
+ ctx,
+ c.rcClient,
+ keys,
+ c.expireTime,
+ c.getConversationIndex,
+ func(ctx context.Context) ([]*relationTb.ConversationModel, error) {
+ return c.conversationDB.Find(ctx, ownerUserID, conversationIDs)
+ },
+ )
+}
+
+func (c *ConversationRedisCache) GetUserAllConversations(
+ ctx context.Context,
+ ownerUserID string,
+) ([]*relationTb.ConversationModel, error) {
conversationIDs, err := c.GetUserConversationIDs(ctx, ownerUserID)
if err != nil {
return nil, err
@@ -195,21 +267,46 @@ func (c *ConversationRedisCache) GetUserAllConversations(ctx context.Context, ow
for _, conversarionID := range conversationIDs {
keys = append(keys, c.getConversationKey(ownerUserID, conversarionID))
}
- return batchGetCache(ctx, c.rcClient, keys, c.expireTime, c.getConversationIndex, func(ctx context.Context) ([]*relationTb.ConversationModel, error) {
- return c.conversationDB.FindUserIDAllConversations(ctx, ownerUserID)
- })
-}
-
-func (c *ConversationRedisCache) GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error) {
- return getCache(ctx, c.rcClient, c.getRecvMsgOptKey(ownerUserID, conversationID), c.expireTime, func(ctx context.Context) (opt int, err error) {
- return c.conversationDB.GetUserRecvMsgOpt(ctx, ownerUserID, conversationID)
- })
-}
-
-func (c *ConversationRedisCache) GetSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) (userIDs []string, err error) {
- return getCache(ctx, c.rcClient, c.getSuperGroupRecvNotNotifyUserIDsKey(groupID), c.expireTime, func(ctx context.Context) (userIDs []string, err error) {
- return c.conversationDB.FindSuperGroupRecvMsgNotNotifyUserIDs(ctx, groupID)
- })
+ return batchGetCache(
+ ctx,
+ c.rcClient,
+ keys,
+ c.expireTime,
+ c.getConversationIndex,
+ func(ctx context.Context) ([]*relationTb.ConversationModel, error) {
+ return c.conversationDB.FindUserIDAllConversations(ctx, ownerUserID)
+ },
+ )
+}
+
+func (c *ConversationRedisCache) GetUserRecvMsgOpt(
+ ctx context.Context,
+ ownerUserID, conversationID string,
+) (opt int, err error) {
+ return getCache(
+ ctx,
+ c.rcClient,
+ c.getRecvMsgOptKey(ownerUserID, conversationID),
+ c.expireTime,
+ func(ctx context.Context) (opt int, err error) {
+ return c.conversationDB.GetUserRecvMsgOpt(ctx, ownerUserID, conversationID)
+ },
+ )
+}
+
+func (c *ConversationRedisCache) GetSuperGroupRecvMsgNotNotifyUserIDs(
+ ctx context.Context,
+ groupID string,
+) (userIDs []string, err error) {
+ return getCache(
+ ctx,
+ c.rcClient,
+ c.getSuperGroupRecvNotNotifyUserIDsKey(groupID),
+ c.expireTime,
+ func(ctx context.Context) (userIDs []string, err error) {
+ return c.conversationDB.FindSuperGroupRecvMsgNotNotifyUserIDs(ctx, groupID)
+ },
+ )
}
func (c *ConversationRedisCache) DelUsersConversation(conversationID string, ownerUserIDs ...string) ConversationCache {
@@ -234,17 +331,26 @@ func (c *ConversationRedisCache) DelSuperGroupRecvMsgNotNotifyUserIDs(groupID st
return cache
}
-func (c *ConversationRedisCache) GetSuperGroupRecvMsgNotNotifyUserIDsHash(ctx context.Context, groupID string) (hash uint64, err error) {
- return getCache(ctx, c.rcClient, c.getSuperGroupRecvNotNotifyUserIDsHashKey(groupID), c.expireTime, func(ctx context.Context) (hash uint64, err error) {
- userIDs, err := c.GetSuperGroupRecvMsgNotNotifyUserIDs(ctx, groupID)
- if err != nil {
- return 0, err
- }
- utils.Sort(userIDs, true)
- bi := big.NewInt(0)
- bi.SetString(utils.Md5(strings.Join(userIDs, ";"))[0:8], 16)
- return bi.Uint64(), nil
- })
+func (c *ConversationRedisCache) GetSuperGroupRecvMsgNotNotifyUserIDsHash(
+ ctx context.Context,
+ groupID string,
+) (hash uint64, err error) {
+ return getCache(
+ ctx,
+ c.rcClient,
+ c.getSuperGroupRecvNotNotifyUserIDsHashKey(groupID),
+ c.expireTime,
+ func(ctx context.Context) (hash uint64, err error) {
+ userIDs, err := c.GetSuperGroupRecvMsgNotNotifyUserIDs(ctx, groupID)
+ if err != nil {
+ return 0, err
+ }
+ utils.Sort(userIDs, true)
+ bi := big.NewInt(0)
+ bi.SetString(utils.Md5(strings.Join(userIDs, ";"))[0:8], 16)
+ return bi.Uint64(), nil
+ },
+ )
}
func (c *ConversationRedisCache) DelSuperGroupRecvMsgNotNotifyUserIDsHash(groupID string) ConversationCache {
@@ -253,7 +359,10 @@ func (c *ConversationRedisCache) DelSuperGroupRecvMsgNotNotifyUserIDsHash(groupI
return cache
}
-func (c *ConversationRedisCache) getUserAllHasReadSeqsIndex(conversationID string, conversationIDs []string) (int, error) {
+func (c *ConversationRedisCache) getUserAllHasReadSeqsIndex(
+ conversationID string,
+ conversationIDs []string,
+) (int, error) {
for _i, _conversationID := range conversationIDs {
if _conversationID == conversationID {
return _i, nil
@@ -262,7 +371,10 @@ func (c *ConversationRedisCache) getUserAllHasReadSeqsIndex(conversationID strin
return 0, errors.New("not found key:" + conversationID + " in keys")
}
-func (c *ConversationRedisCache) GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error) {
+func (c *ConversationRedisCache) GetUserAllHasReadSeqs(
+ ctx context.Context,
+ ownerUserID string,
+) (map[string]int64, error) {
conversationIDs, err := c.GetUserConversationIDs(ctx, ownerUserID)
if err != nil {
return nil, err
@@ -271,12 +383,23 @@ func (c *ConversationRedisCache) GetUserAllHasReadSeqs(ctx context.Context, owne
for _, conversarionID := range conversationIDs {
keys = append(keys, c.getConversationHasReadSeqKey(ownerUserID, conversarionID))
}
- return batchGetCacheMap(ctx, c.rcClient, keys, conversationIDs, c.expireTime, c.getUserAllHasReadSeqsIndex, func(ctx context.Context) (map[string]int64, error) {
- return c.conversationDB.GetUserAllHasReadSeqs(ctx, ownerUserID)
- })
-}
-
-func (c *ConversationRedisCache) DelUserAllHasReadSeqs(ownerUserID string, conversationIDs ...string) ConversationCache {
+ return batchGetCacheMap(
+ ctx,
+ c.rcClient,
+ keys,
+ conversationIDs,
+ c.expireTime,
+ c.getUserAllHasReadSeqsIndex,
+ func(ctx context.Context) (map[string]int64, error) {
+ return c.conversationDB.GetUserAllHasReadSeqs(ctx, ownerUserID)
+ },
+ )
+}
+
+func (c *ConversationRedisCache) DelUserAllHasReadSeqs(
+ ownerUserID string,
+ conversationIDs ...string,
+) ConversationCache {
cache := c.NewCache()
for _, conversationID := range conversationIDs {
cache.AddKeys(c.getConversationHasReadSeqKey(ownerUserID, conversationID))
@@ -284,7 +407,10 @@ func (c *ConversationRedisCache) DelUserAllHasReadSeqs(ownerUserID string, conve
return cache
}
-func (c *ConversationRedisCache) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*relationTb.ConversationModel, error) {
+func (c *ConversationRedisCache) GetConversationsByConversationID(
+ ctx context.Context,
+ conversationIDs []string,
+) ([]*relationTb.ConversationModel, error) {
panic("implement me")
}
diff --git a/pkg/common/db/cache/extend_msg_set.go b/pkg/common/db/cache/extend_msg_set.go
index c405a7567..a45bf87f8 100644
--- a/pkg/common/db/cache/extend_msg_set.go
+++ b/pkg/common/db/cache/extend_msg_set.go
@@ -4,9 +4,10 @@ import (
"context"
"time"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/dtm-labs/rockscache"
"github.com/redis/go-redis/v9"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
)
const (
@@ -17,7 +18,13 @@ const (
type ExtendMsgSetCache interface {
metaCache
NewCache() ExtendMsgSetCache
- GetExtendMsg(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, firstModifyTime int64) (extendMsg *unrelation.ExtendMsgModel, err error)
+ GetExtendMsg(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ firstModifyTime int64,
+ ) (extendMsg *unrelation.ExtendMsgModel, err error)
DelExtendMsg(clientMsgID string) ExtendMsgSetCache
}
@@ -28,7 +35,11 @@ type ExtendMsgSetCacheRedis struct {
extendMsgSetDB unrelation.ExtendMsgSetModelInterface
}
-func NewExtendMsgSetCacheRedis(rdb redis.UniversalClient, extendMsgSetDB unrelation.ExtendMsgSetModelInterface, options rockscache.Options) ExtendMsgSetCache {
+func NewExtendMsgSetCacheRedis(
+ rdb redis.UniversalClient,
+ extendMsgSetDB unrelation.ExtendMsgSetModelInterface,
+ options rockscache.Options,
+) ExtendMsgSetCache {
rcClient := rockscache.NewClient(rdb, options)
return &ExtendMsgSetCacheRedis{
metaCache: NewMetaCacheRedis(rcClient),
@@ -51,10 +62,22 @@ func (e *ExtendMsgSetCacheRedis) getKey(clientMsgID string) string {
return extendMsgCache + clientMsgID
}
-func (e *ExtendMsgSetCacheRedis) GetExtendMsg(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, firstModifyTime int64) (extendMsg *unrelation.ExtendMsgModel, err error) {
- return getCache(ctx, e.rcClient, e.getKey(clientMsgID), e.expireTime, func(ctx context.Context) (*unrelation.ExtendMsgModel, error) {
- return e.extendMsgSetDB.TakeExtendMsg(ctx, conversationID, sessionType, clientMsgID, firstModifyTime)
- })
+func (e *ExtendMsgSetCacheRedis) GetExtendMsg(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ firstModifyTime int64,
+) (extendMsg *unrelation.ExtendMsgModel, err error) {
+ return getCache(
+ ctx,
+ e.rcClient,
+ e.getKey(clientMsgID),
+ e.expireTime,
+ func(ctx context.Context) (*unrelation.ExtendMsgModel, error) {
+ return e.extendMsgSetDB.TakeExtendMsg(ctx, conversationID, sessionType, clientMsgID, firstModifyTime)
+ },
+ )
}
func (e *ExtendMsgSetCacheRedis) DelExtendMsg(clientMsgID string) ExtendMsgSetCache {
diff --git a/pkg/common/db/cache/friend.go b/pkg/common/db/cache/friend.go
index a3890bb58..c816f6d4f 100644
--- a/pkg/common/db/cache/friend.go
+++ b/pkg/common/db/cache/friend.go
@@ -4,10 +4,11 @@ import (
"context"
"time"
- relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"github.com/dtm-labs/rockscache"
"github.com/redis/go-redis/v9"
+
+ relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
const (
@@ -37,7 +38,11 @@ type FriendCacheRedis struct {
rcClient *rockscache.Client
}
-func NewFriendCacheRedis(rdb redis.UniversalClient, friendDB relationTb.FriendModelInterface, options rockscache.Options) FriendCache {
+func NewFriendCacheRedis(
+ rdb redis.UniversalClient,
+ friendDB relationTb.FriendModelInterface,
+ options rockscache.Options,
+) FriendCache {
rcClient := rockscache.NewClient(rdb, options)
return &FriendCacheRedis{
metaCache: NewMetaCacheRedis(rcClient),
@@ -48,7 +53,12 @@ func NewFriendCacheRedis(rdb redis.UniversalClient, friendDB relationTb.FriendMo
}
func (c *FriendCacheRedis) NewCache() FriendCache {
- return &FriendCacheRedis{rcClient: c.rcClient, metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDelKeys()...), friendDB: c.friendDB, expireTime: c.expireTime}
+ return &FriendCacheRedis{
+ rcClient: c.rcClient,
+ metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDelKeys()...),
+ friendDB: c.friendDB,
+ expireTime: c.expireTime,
+ }
}
func (f *FriendCacheRedis) getFriendIDsKey(ownerUserID string) string {
@@ -64,9 +74,15 @@ func (f *FriendCacheRedis) getFriendKey(ownerUserID, friendUserID string) string
}
func (f *FriendCacheRedis) GetFriendIDs(ctx context.Context, ownerUserID string) (friendIDs []string, err error) {
- return getCache(ctx, f.rcClient, f.getFriendIDsKey(ownerUserID), f.expireTime, func(ctx context.Context) ([]string, error) {
- return f.friendDB.FindFriendUserIDs(ctx, ownerUserID)
- })
+ return getCache(
+ ctx,
+ f.rcClient,
+ f.getFriendIDsKey(ownerUserID),
+ f.expireTime,
+ func(ctx context.Context) ([]string, error) {
+ return f.friendDB.FindFriendUserIDs(ctx, ownerUserID)
+ },
+ )
}
func (f *FriendCacheRedis) DelFriendIDs(ownerUserID ...string) FriendCache {
@@ -80,7 +96,10 @@ func (f *FriendCacheRedis) DelFriendIDs(ownerUserID ...string) FriendCache {
}
// todo
-func (f *FriendCacheRedis) GetTwoWayFriendIDs(ctx context.Context, ownerUserID string) (twoWayFriendIDs []string, err error) {
+func (f *FriendCacheRedis) GetTwoWayFriendIDs(
+ ctx context.Context,
+ ownerUserID string,
+) (twoWayFriendIDs []string, err error) {
friendIDs, err := f.GetFriendIDs(ctx, ownerUserID)
if err != nil {
return nil, err
@@ -103,10 +122,19 @@ func (f *FriendCacheRedis) DelTwoWayFriendIDs(ctx context.Context, ownerUserID s
return new
}
-func (f *FriendCacheRedis) GetFriend(ctx context.Context, ownerUserID, friendUserID string) (friend *relationTb.FriendModel, err error) {
- return getCache(ctx, f.rcClient, f.getFriendKey(ownerUserID, friendUserID), f.expireTime, func(ctx context.Context) (*relationTb.FriendModel, error) {
- return f.friendDB.Take(ctx, ownerUserID, friendUserID)
- })
+func (f *FriendCacheRedis) GetFriend(
+ ctx context.Context,
+ ownerUserID, friendUserID string,
+) (friend *relationTb.FriendModel, err error) {
+ return getCache(
+ ctx,
+ f.rcClient,
+ f.getFriendKey(ownerUserID, friendUserID),
+ f.expireTime,
+ func(ctx context.Context) (*relationTb.FriendModel, error) {
+ return f.friendDB.Take(ctx, ownerUserID, friendUserID)
+ },
+ )
}
func (f *FriendCacheRedis) DelFriend(ownerUserID, friendUserID string) FriendCache {
diff --git a/pkg/common/db/cache/group.go b/pkg/common/db/cache/group.go
index a27cce393..11c733d2b 100644
--- a/pkg/common/db/cache/group.go
+++ b/pkg/common/db/cache/group.go
@@ -6,11 +6,12 @@ import (
"strings"
"time"
+ "github.com/dtm-labs/rockscache"
+ "github.com/redis/go-redis/v9"
+
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
unrelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/dtm-labs/rockscache"
- "github.com/redis/go-redis/v9"
)
const (
@@ -49,10 +50,22 @@ type GroupCache interface {
GetJoinedGroupIDs(ctx context.Context, userID string) (joinedGroupIDs []string, err error)
DelJoinedGroupID(userID ...string) GroupCache
- GetGroupMemberInfo(ctx context.Context, groupID, userID string) (groupMember *relationTb.GroupMemberModel, err error)
- GetGroupMembersInfo(ctx context.Context, groupID string, userID []string) (groupMembers []*relationTb.GroupMemberModel, err error)
+ GetGroupMemberInfo(
+ ctx context.Context,
+ groupID, userID string,
+ ) (groupMember *relationTb.GroupMemberModel, err error)
+ GetGroupMembersInfo(
+ ctx context.Context,
+ groupID string,
+ userID []string,
+ ) (groupMembers []*relationTb.GroupMemberModel, err error)
GetAllGroupMembersInfo(ctx context.Context, groupID string) (groupMembers []*relationTb.GroupMemberModel, err error)
- GetGroupMembersPage(ctx context.Context, groupID string, userID []string, showNumber, pageNumber int32) (total uint32, groupMembers []*relationTb.GroupMemberModel, err error)
+ GetGroupMembersPage(
+ ctx context.Context,
+ groupID string,
+ userID []string,
+ showNumber, pageNumber int32,
+ ) (total uint32, groupMembers []*relationTb.GroupMemberModel, err error)
DelGroupMembersInfo(groupID string, userID ...string) GroupCache
@@ -70,7 +83,14 @@ type GroupCacheRedis struct {
rcClient *rockscache.Client
}
-func NewGroupCacheRedis(rdb redis.UniversalClient, groupDB relationTb.GroupModelInterface, groupMemberDB relationTb.GroupMemberModelInterface, groupRequestDB relationTb.GroupRequestModelInterface, mongoClient unrelationTb.SuperGroupModelInterface, opts rockscache.Options) GroupCache {
+func NewGroupCacheRedis(
+ rdb redis.UniversalClient,
+ groupDB relationTb.GroupModelInterface,
+ groupMemberDB relationTb.GroupMemberModelInterface,
+ groupRequestDB relationTb.GroupRequestModelInterface,
+ mongoClient unrelationTb.SuperGroupModelInterface,
+ opts rockscache.Options,
+) GroupCache {
rcClient := rockscache.NewClient(rdb, opts)
return &GroupCacheRedis{rcClient: rcClient, expireTime: groupExpireTime,
groupDB: groupDB, groupMemberDB: groupMemberDB, groupRequestDB: groupRequestDB,
@@ -79,7 +99,15 @@ func NewGroupCacheRedis(rdb redis.UniversalClient, groupDB relationTb.GroupModel
}
func (g *GroupCacheRedis) NewCache() GroupCache {
- return &GroupCacheRedis{rcClient: g.rcClient, expireTime: g.expireTime, groupDB: g.groupDB, groupMemberDB: g.groupMemberDB, groupRequestDB: g.groupRequestDB, mongoDB: g.mongoDB, metaCache: NewMetaCacheRedis(g.rcClient, g.metaCache.GetPreDelKeys()...)}
+ return &GroupCacheRedis{
+ rcClient: g.rcClient,
+ expireTime: g.expireTime,
+ groupDB: g.groupDB,
+ groupMemberDB: g.groupMemberDB,
+ groupRequestDB: g.groupRequestDB,
+ mongoDB: g.mongoDB,
+ metaCache: NewMetaCacheRedis(g.rcClient, g.metaCache.GetPreDelKeys()...),
+ }
}
func (g *GroupCacheRedis) getGroupInfoKey(groupID string) string {
@@ -135,20 +163,36 @@ func (g *GroupCacheRedis) GetGroupMemberIndex(groupMember *relationTb.GroupMembe
}
// / groupInfo
-func (g *GroupCacheRedis) GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
+func (g *GroupCacheRedis) GetGroupsInfo(
+ ctx context.Context,
+ groupIDs []string,
+) (groups []*relationTb.GroupModel, err error) {
var keys []string
for _, group := range groupIDs {
keys = append(keys, g.getGroupInfoKey(group))
}
- return batchGetCache(ctx, g.rcClient, keys, g.expireTime, g.GetGroupIndex, func(ctx context.Context) ([]*relationTb.GroupModel, error) {
- return g.groupDB.Find(ctx, groupIDs)
- })
+ return batchGetCache(
+ ctx,
+ g.rcClient,
+ keys,
+ g.expireTime,
+ g.GetGroupIndex,
+ func(ctx context.Context) ([]*relationTb.GroupModel, error) {
+ return g.groupDB.Find(ctx, groupIDs)
+ },
+ )
}
func (g *GroupCacheRedis) GetGroupInfo(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
- return getCache(ctx, g.rcClient, g.getGroupInfoKey(groupID), g.expireTime, func(ctx context.Context) (*relationTb.GroupModel, error) {
- return g.groupDB.Take(ctx, groupID)
- })
+ return getCache(
+ ctx,
+ g.rcClient,
+ g.getGroupInfoKey(groupID),
+ g.expireTime,
+ func(ctx context.Context) (*relationTb.GroupModel, error) {
+ return g.groupDB.Take(ctx, groupID)
+ },
+ )
}
func (g *GroupCacheRedis) DelGroupsInfo(groupIDs ...string) GroupCache {
@@ -161,31 +205,50 @@ func (g *GroupCacheRedis) DelGroupsInfo(groupIDs ...string) GroupCache {
return new
}
-func (g *GroupCacheRedis) GetJoinedSuperGroupIDs(ctx context.Context, userID string) (joinedSuperGroupIDs []string, err error) {
- return getCache(ctx, g.rcClient, g.getJoinedSuperGroupsIDKey(userID), g.expireTime, func(ctx context.Context) ([]string, error) {
- userGroup, err := g.mongoDB.GetSuperGroupByUserID(ctx, userID)
- if err != nil {
- return nil, err
- }
- return userGroup.GroupIDs, nil
- })
+func (g *GroupCacheRedis) GetJoinedSuperGroupIDs(
+ ctx context.Context,
+ userID string,
+) (joinedSuperGroupIDs []string, err error) {
+ return getCache(
+ ctx,
+ g.rcClient,
+ g.getJoinedSuperGroupsIDKey(userID),
+ g.expireTime,
+ func(ctx context.Context) ([]string, error) {
+ userGroup, err := g.mongoDB.GetSuperGroupByUserID(ctx, userID)
+ if err != nil {
+ return nil, err
+ }
+ return userGroup.GroupIDs, nil
+ },
+ )
}
-func (g *GroupCacheRedis) GetSuperGroupMemberIDs(ctx context.Context, groupIDs ...string) (models []*unrelationTb.SuperGroupModel, err error) {
+func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
+ ctx context.Context,
+ groupIDs ...string,
+) (models []*unrelationTb.SuperGroupModel, err error) {
var keys []string
for _, group := range groupIDs {
keys = append(keys, g.getSuperGroupMemberIDsKey(group))
}
- return batchGetCache(ctx, g.rcClient, keys, g.expireTime, func(model *unrelationTb.SuperGroupModel, keys []string) (int, error) {
- for i, key := range keys {
- if g.getSuperGroupMemberIDsKey(model.GroupID) == key {
- return i, nil
+ return batchGetCache(
+ ctx,
+ g.rcClient,
+ keys,
+ g.expireTime,
+ func(model *unrelationTb.SuperGroupModel, keys []string) (int, error) {
+ for i, key := range keys {
+ if g.getSuperGroupMemberIDsKey(model.GroupID) == key {
+ return i, nil
+ }
}
- }
- return 0, errIndex
- }, func(ctx context.Context) ([]*unrelationTb.SuperGroupModel, error) {
- return g.mongoDB.FindSuperGroup(ctx, groupIDs)
- })
+ return 0, errIndex
+ },
+ func(ctx context.Context) ([]*unrelationTb.SuperGroupModel, error) {
+ return g.mongoDB.FindSuperGroup(ctx, groupIDs)
+ },
+ )
}
// userJoinSuperGroup
@@ -211,19 +274,28 @@ func (g *GroupCacheRedis) DelSuperGroupMemberIDs(groupIDs ...string) GroupCache
// groupMembersHash
func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID string) (hashCode uint64, err error) {
- return getCache(ctx, g.rcClient, g.getGroupMembersHashKey(groupID), g.expireTime, func(ctx context.Context) (uint64, error) {
- userIDs, err := g.GetGroupMemberIDs(ctx, groupID)
- if err != nil {
- return 0, err
- }
- utils.Sort(userIDs, true)
- bi := big.NewInt(0)
- bi.SetString(utils.Md5(strings.Join(userIDs, ";"))[0:8], 16)
- return bi.Uint64(), nil
- })
-}
-
-func (g *GroupCacheRedis) GetGroupMemberHashMap(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error) {
+ return getCache(
+ ctx,
+ g.rcClient,
+ g.getGroupMembersHashKey(groupID),
+ g.expireTime,
+ func(ctx context.Context) (uint64, error) {
+ userIDs, err := g.GetGroupMemberIDs(ctx, groupID)
+ if err != nil {
+ return 0, err
+ }
+ utils.Sort(userIDs, true)
+ bi := big.NewInt(0)
+ bi.SetString(utils.Md5(strings.Join(userIDs, ";"))[0:8], 16)
+ return bi.Uint64(), nil
+ },
+ )
+}
+
+func (g *GroupCacheRedis) GetGroupMemberHashMap(
+ ctx context.Context,
+ groupIDs []string,
+) (map[string]*relationTb.GroupSimpleUserID, error) {
res := make(map[string]*relationTb.GroupSimpleUserID)
for _, groupID := range groupIDs {
hash, err := g.GetGroupMembersHash(ctx, groupID)
@@ -247,9 +319,15 @@ func (g *GroupCacheRedis) DelGroupMembersHash(groupID string) GroupCache {
// groupMemberIDs
func (g *GroupCacheRedis) GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error) {
- return getCache(ctx, g.rcClient, g.getGroupMemberIDsKey(groupID), g.expireTime, func(ctx context.Context) ([]string, error) {
- return g.groupMemberDB.FindMemberUserID(ctx, groupID)
- })
+ return getCache(
+ ctx,
+ g.rcClient,
+ g.getGroupMemberIDsKey(groupID),
+ g.expireTime,
+ func(ctx context.Context) ([]string, error) {
+ return g.groupMemberDB.FindMemberUserID(ctx, groupID)
+ },
+ )
}
func (g *GroupCacheRedis) GetGroupsMemberIDs(ctx context.Context, groupIDs []string) (map[string][]string, error) {
@@ -271,9 +349,15 @@ func (g *GroupCacheRedis) DelGroupMemberIDs(groupID string) GroupCache {
}
func (g *GroupCacheRedis) GetJoinedGroupIDs(ctx context.Context, userID string) (joinedGroupIDs []string, err error) {
- return getCache(ctx, g.rcClient, g.getJoinedGroupsKey(userID), g.expireTime, func(ctx context.Context) ([]string, error) {
- return g.groupMemberDB.FindUserJoinedGroupID(ctx, userID)
- })
+ return getCache(
+ ctx,
+ g.rcClient,
+ g.getJoinedGroupsKey(userID),
+ g.expireTime,
+ func(ctx context.Context) ([]string, error) {
+ return g.groupMemberDB.FindUserJoinedGroupID(ctx, userID)
+ },
+ )
}
func (g *GroupCacheRedis) DelJoinedGroupID(userIDs ...string) GroupCache {
@@ -286,23 +370,48 @@ func (g *GroupCacheRedis) DelJoinedGroupID(userIDs ...string) GroupCache {
return cache
}
-func (g *GroupCacheRedis) GetGroupMemberInfo(ctx context.Context, groupID, userID string) (groupMember *relationTb.GroupMemberModel, err error) {
- return getCache(ctx, g.rcClient, g.getGroupMemberInfoKey(groupID, userID), g.expireTime, func(ctx context.Context) (*relationTb.GroupMemberModel, error) {
- return g.groupMemberDB.Take(ctx, groupID, userID)
- })
-}
-
-func (g *GroupCacheRedis) GetGroupMembersInfo(ctx context.Context, groupID string, userIDs []string) ([]*relationTb.GroupMemberModel, error) {
+func (g *GroupCacheRedis) GetGroupMemberInfo(
+ ctx context.Context,
+ groupID, userID string,
+) (groupMember *relationTb.GroupMemberModel, err error) {
+ return getCache(
+ ctx,
+ g.rcClient,
+ g.getGroupMemberInfoKey(groupID, userID),
+ g.expireTime,
+ func(ctx context.Context) (*relationTb.GroupMemberModel, error) {
+ return g.groupMemberDB.Take(ctx, groupID, userID)
+ },
+ )
+}
+
+func (g *GroupCacheRedis) GetGroupMembersInfo(
+ ctx context.Context,
+ groupID string,
+ userIDs []string,
+) ([]*relationTb.GroupMemberModel, error) {
var keys []string
for _, userID := range userIDs {
keys = append(keys, g.getGroupMemberInfoKey(groupID, userID))
}
- return batchGetCache(ctx, g.rcClient, keys, g.expireTime, g.GetGroupMemberIndex, func(ctx context.Context) ([]*relationTb.GroupMemberModel, error) {
- return g.groupMemberDB.Find(ctx, []string{groupID}, userIDs, nil)
- })
-}
-
-func (g *GroupCacheRedis) GetGroupMembersPage(ctx context.Context, groupID string, userIDs []string, showNumber, pageNumber int32) (total uint32, groupMembers []*relationTb.GroupMemberModel, err error) {
+ return batchGetCache(
+ ctx,
+ g.rcClient,
+ keys,
+ g.expireTime,
+ g.GetGroupMemberIndex,
+ func(ctx context.Context) ([]*relationTb.GroupMemberModel, error) {
+ return g.groupMemberDB.Find(ctx, []string{groupID}, userIDs, nil)
+ },
+ )
+}
+
+func (g *GroupCacheRedis) GetGroupMembersPage(
+ ctx context.Context,
+ groupID string,
+ userIDs []string,
+ showNumber, pageNumber int32,
+) (total uint32, groupMembers []*relationTb.GroupMemberModel, err error) {
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
if err != nil {
return 0, nil, err
@@ -316,7 +425,10 @@ func (g *GroupCacheRedis) GetGroupMembersPage(ctx context.Context, groupID strin
return uint32(len(userIDs)), groupMembers, err
}
-func (g *GroupCacheRedis) GetAllGroupMembersInfo(ctx context.Context, groupID string) (groupMembers []*relationTb.GroupMemberModel, err error) {
+func (g *GroupCacheRedis) GetAllGroupMembersInfo(
+ ctx context.Context,
+ groupID string,
+) (groupMembers []*relationTb.GroupMemberModel, err error) {
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
if err != nil {
return nil, err
@@ -324,7 +436,10 @@ func (g *GroupCacheRedis) GetAllGroupMembersInfo(ctx context.Context, groupID st
return g.GetGroupMembersInfo(ctx, groupID, groupMemberIDs)
}
-func (g *GroupCacheRedis) GetAllGroupMemberInfo(ctx context.Context, groupID string) ([]*relationTb.GroupMemberModel, error) {
+func (g *GroupCacheRedis) GetAllGroupMemberInfo(
+ ctx context.Context,
+ groupID string,
+) ([]*relationTb.GroupMemberModel, error) {
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
if err != nil {
return nil, err
@@ -333,9 +448,16 @@ func (g *GroupCacheRedis) GetAllGroupMemberInfo(ctx context.Context, groupID str
for _, groupMemberID := range groupMemberIDs {
keys = append(keys, g.getGroupMemberInfoKey(groupID, groupMemberID))
}
- return batchGetCache(ctx, g.rcClient, keys, g.expireTime, g.GetGroupMemberIndex, func(ctx context.Context) ([]*relationTb.GroupMemberModel, error) {
- return g.groupMemberDB.Find(ctx, []string{groupID}, groupMemberIDs, nil)
- })
+ return batchGetCache(
+ ctx,
+ g.rcClient,
+ keys,
+ g.expireTime,
+ g.GetGroupMemberIndex,
+ func(ctx context.Context) ([]*relationTb.GroupMemberModel, error) {
+ return g.groupMemberDB.Find(ctx, []string{groupID}, groupMemberIDs, nil)
+ },
+ )
}
func (g *GroupCacheRedis) DelGroupMembersInfo(groupID string, userIDs ...string) GroupCache {
@@ -349,9 +471,15 @@ func (g *GroupCacheRedis) DelGroupMembersInfo(groupID string, userIDs ...string)
}
func (g *GroupCacheRedis) GetGroupMemberNum(ctx context.Context, groupID string) (memberNum int64, err error) {
- return getCache(ctx, g.rcClient, g.getGroupMemberNumKey(groupID), g.expireTime, func(ctx context.Context) (int64, error) {
- return g.groupMemberDB.TakeGroupMemberNum(ctx, groupID)
- })
+ return getCache(
+ ctx,
+ g.rcClient,
+ g.getGroupMemberNumKey(groupID),
+ g.expireTime,
+ func(ctx context.Context) (int64, error) {
+ return g.groupMemberDB.TakeGroupMemberNum(ctx, groupID)
+ },
+ )
}
func (g *GroupCacheRedis) DelGroupsMemberNum(groupID ...string) GroupCache {
diff --git a/pkg/common/db/cache/init_redis.go b/pkg/common/db/cache/init_redis.go
index c0277c445..e4b950ee1 100644
--- a/pkg/common/db/cache/init_redis.go
+++ b/pkg/common/db/cache/init_redis.go
@@ -6,10 +6,11 @@ import (
"fmt"
"time"
+ "github.com/redis/go-redis/v9"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
- "github.com/redis/go-redis/v9"
)
func NewRedis() (redis.UniversalClient, error) {
diff --git a/pkg/common/db/cache/meta_cache.go b/pkg/common/db/cache/meta_cache.go
index b001fa227..e12f8e93c 100644
--- a/pkg/common/db/cache/meta_cache.go
+++ b/pkg/common/db/cache/meta_cache.go
@@ -7,10 +7,11 @@ import (
"fmt"
"time"
+ "github.com/dtm-labs/rockscache"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/dtm-labs/rockscache"
)
const (
@@ -48,7 +49,14 @@ func (m *metaCacheRedis) ExecDel(ctx context.Context) error {
for {
if err := m.rcClient.TagAsDeletedBatch2(ctx, m.keys); err != nil {
if retryTimes >= m.maxRetryTimes {
- err = errs.ErrInternalServer.Wrap(fmt.Sprintf("delete cache error: %v, keys: %v, retry times %d, please check redis server", err, m.keys, retryTimes))
+ err = errs.ErrInternalServer.Wrap(
+ fmt.Sprintf(
+ "delete cache error: %v, keys: %v, retry times %d, please check redis server",
+ err,
+ m.keys,
+ retryTimes,
+ ),
+ )
log.ZWarn(ctx, "delete cache failed, please handle keys", err, "keys", m.keys)
return err
}
@@ -84,7 +92,13 @@ func GetDefaultOpt() rockscache.Options {
return opts
}
-func getCache[T any](ctx context.Context, rcClient *rockscache.Client, key string, expire time.Duration, fn func(ctx context.Context) (T, error)) (T, error) {
+func getCache[T any](
+ ctx context.Context,
+ rcClient *rockscache.Client,
+ key string,
+ expire time.Duration,
+ fn func(ctx context.Context) (T, error),
+) (T, error) {
var t T
var write bool
v, err := rcClient.Fetch2(ctx, key, expire, func() (s string, err error) {
@@ -116,7 +130,14 @@ func getCache[T any](ctx context.Context, rcClient *rockscache.Client, key strin
return t, nil
}
-func batchGetCache[T any](ctx context.Context, rcClient *rockscache.Client, keys []string, expire time.Duration, keyIndexFn func(t T, keys []string) (int, error), fn func(ctx context.Context) ([]T, error)) ([]T, error) {
+func batchGetCache[T any](
+ ctx context.Context,
+ rcClient *rockscache.Client,
+ keys []string,
+ expire time.Duration,
+ keyIndexFn func(t T, keys []string) (int, error),
+ fn func(ctx context.Context) ([]T, error),
+) ([]T, error) {
batchMap, err := rcClient.FetchBatch2(ctx, keys, expire, func(idxs []int) (m map[int]string, err error) {
values := make(map[int]string)
tArrays, err := fn(ctx)
@@ -153,7 +174,14 @@ func batchGetCache[T any](ctx context.Context, rcClient *rockscache.Client, keys
return tArrays, nil
}
-func batchGetCacheMap[T any](ctx context.Context, rcClient *rockscache.Client, keys, originKeys []string, expire time.Duration, keyIndexFn func(s string, keys []string) (int, error), fn func(ctx context.Context) (map[string]T, error)) (map[string]T, error) {
+func batchGetCacheMap[T any](
+ ctx context.Context,
+ rcClient *rockscache.Client,
+ keys, originKeys []string,
+ expire time.Duration,
+ keyIndexFn func(s string, keys []string) (int, error),
+ fn func(ctx context.Context) (map[string]T, error),
+) (map[string]T, error) {
batchMap, err := rcClient.FetchBatch2(ctx, keys, expire, func(idxs []int) (m map[int]string, err error) {
tArrays, err := fn(ctx)
if err != nil {
diff --git a/pkg/common/db/cache/msg.go b/pkg/common/db/cache/msg.go
index 8baa047c0..e01836118 100644
--- a/pkg/common/db/cache/msg.go
+++ b/pkg/common/db/cache/msg.go
@@ -5,16 +5,18 @@ import (
"strconv"
"time"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/dtm-labs/rockscache"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
+
+ "github.com/gogo/protobuf/jsonpb"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/gogo/protobuf/jsonpb"
"github.com/redis/go-redis/v9"
)
@@ -86,7 +88,11 @@ type MsgModel interface {
GetTokensWithoutError(ctx context.Context, userID string, platformID int) (map[string]int, error)
SetTokenMapByUidPid(ctx context.Context, userID string, platformID int, m map[string]int) error
DeleteTokenByUidPid(ctx context.Context, userID string, platformID int, fields []string) error
- GetMessagesBySeq(ctx context.Context, conversationID string, seqs []int64) (seqMsg []*sdkws.MsgData, failedSeqList []int64, err error)
+ GetMessagesBySeq(
+ ctx context.Context,
+ conversationID string,
+ seqs []int64,
+ ) (seqMsg []*sdkws.MsgData, failedSeqList []int64, err error)
SetMessageToCache(ctx context.Context, conversationID string, msgs []*sdkws.MsgData) (int, error)
UserDeleteMsgs(ctx context.Context, conversationID string, seqs []int64, userID string) error
DelUserDeleteMsgsList(ctx context.Context, conversationID string, seqs []int64)
@@ -99,7 +105,12 @@ type MsgModel interface {
JudgeMessageReactionExist(ctx context.Context, clientMsgID string, sessionType int32) (bool, error)
GetOneMessageAllReactionList(ctx context.Context, clientMsgID string, sessionType int32) (map[string]string, error)
DeleteOneMessageKey(ctx context.Context, clientMsgID string, sessionType int32, subKey string) error
- SetMessageReactionExpire(ctx context.Context, clientMsgID string, sessionType int32, expiration time.Duration) (bool, error)
+ SetMessageReactionExpire(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+ expiration time.Duration,
+ ) (bool, error)
GetMessageTypeKeyValue(ctx context.Context, clientMsgID string, sessionType int32, typeKey string) (string, error)
SetMessageTypeKeyValue(ctx context.Context, clientMsgID string, sessionType int32, typeKey, value string) error
LockMessageTypeKey(ctx context.Context, clientMsgID string, TypeKey string) error
@@ -130,15 +141,28 @@ func (c *msgCache) getHasReadSeqKey(conversationID string, userID string) string
return hasReadSeq + userID + ":" + conversationID
}
-func (c *msgCache) setSeq(ctx context.Context, conversationID string, seq int64, getkey func(conversationID string) string) error {
+func (c *msgCache) setSeq(
+ ctx context.Context,
+ conversationID string,
+ seq int64,
+ getkey func(conversationID string) string,
+) error {
return utils.Wrap1(c.rdb.Set(ctx, getkey(conversationID), seq, 0).Err())
}
-func (c *msgCache) getSeq(ctx context.Context, conversationID string, getkey func(conversationID string) string) (int64, error) {
+func (c *msgCache) getSeq(
+ ctx context.Context,
+ conversationID string,
+ getkey func(conversationID string) string,
+) (int64, error) {
return utils.Wrap2(c.rdb.Get(ctx, getkey(conversationID)).Int64())
}
-func (c *msgCache) getSeqs(ctx context.Context, items []string, getkey func(s string) string) (m map[string]int64, err error) {
+func (c *msgCache) getSeqs(
+ ctx context.Context,
+ items []string,
+ getkey func(s string) string,
+) (m map[string]int64, err error) {
pipe := c.rdb.Pipeline()
for _, v := range items {
if err := pipe.Get(ctx, getkey(v)).Err(); err != nil && err != redis.Nil {
@@ -209,16 +233,30 @@ func (c *msgCache) GetConversationUserMinSeq(ctx context.Context, conversationID
return utils.Wrap2(c.rdb.Get(ctx, c.getConversationUserMinSeqKey(conversationID, userID)).Int64())
}
-func (c *msgCache) GetConversationUserMinSeqs(ctx context.Context, conversationID string, userIDs []string) (m map[string]int64, err error) {
+func (c *msgCache) GetConversationUserMinSeqs(
+ ctx context.Context,
+ conversationID string,
+ userIDs []string,
+) (m map[string]int64, err error) {
return c.getSeqs(ctx, userIDs, func(userID string) string {
return c.getConversationUserMinSeqKey(conversationID, userID)
})
}
-func (c *msgCache) SetConversationUserMinSeq(ctx context.Context, conversationID string, userID string, minSeq int64) error {
+
+func (c *msgCache) SetConversationUserMinSeq(
+ ctx context.Context,
+ conversationID string,
+ userID string,
+ minSeq int64,
+) error {
return utils.Wrap1(c.rdb.Set(ctx, c.getConversationUserMinSeqKey(conversationID, userID), minSeq, 0).Err())
}
-func (c *msgCache) SetConversationUserMinSeqs(ctx context.Context, conversationID string, seqs map[string]int64) (err error) {
+func (c *msgCache) SetConversationUserMinSeqs(
+ ctx context.Context,
+ conversationID string,
+ seqs map[string]int64,
+) (err error) {
return c.setSeqs(ctx, seqs, func(userID string) string {
return c.getConversationUserMinSeqKey(conversationID, userID)
})
@@ -246,7 +284,11 @@ func (c *msgCache) UserSetHasReadSeqs(ctx context.Context, userID string, hasRea
})
}
-func (c *msgCache) GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error) {
+func (c *msgCache) GetHasReadSeqs(
+ ctx context.Context,
+ userID string,
+ conversationIDs []string,
+) (map[string]int64, error) {
return c.getSeqs(ctx, conversationIDs, func(conversationID string) string {
return c.getHasReadSeqKey(conversationID, userID)
})
@@ -296,7 +338,11 @@ func (c *msgCache) allMessageCacheKey(conversationID string) string {
return messageCache + conversationID + "_*"
}
-func (c *msgCache) GetMessagesBySeq(ctx context.Context, conversationID string, seqs []int64) (seqMsgs []*sdkws.MsgData, failedSeqs []int64, err error) {
+func (c *msgCache) GetMessagesBySeq(
+ ctx context.Context,
+ conversationID string,
+ seqs []int64,
+) (seqMsgs []*sdkws.MsgData, failedSeqs []int64, err error) {
pipe := c.rdb.Pipeline()
for _, v := range seqs {
//MESSAGE_CACHE:169.254.225.224_reliability1653387820_0_1
@@ -404,7 +450,17 @@ func (c *msgCache) DelUserDeleteMsgsList(ctx context.Context, conversationID str
err = pipe.SRem(ctx, c.getUserDelList(conversationID, userID), seq).Err()
if err != nil {
failedFlag = true
- log.ZWarn(ctx, "DelUserDeleteMsgsList failed", err, "conversationID", conversationID, "seq", seq, "userID", userID)
+ log.ZWarn(
+ ctx,
+ "DelUserDeleteMsgsList failed",
+ err,
+ "conversationID",
+ conversationID,
+ "seq",
+ seq,
+ "userID",
+ userID,
+ )
}
}
if !failedFlag {
@@ -499,8 +555,17 @@ func (c *msgCache) GetSendMsgStatus(ctx context.Context, id string) (int32, erro
return int32(result), errs.Wrap(err)
}
-func (c *msgCache) SetFcmToken(ctx context.Context, account string, platformID int, fcmToken string, expireTime int64) (err error) {
- return errs.Wrap(c.rdb.Set(ctx, fcmToken+account+":"+strconv.Itoa(platformID), fcmToken, time.Duration(expireTime)*time.Second).Err())
+func (c *msgCache) SetFcmToken(
+ ctx context.Context,
+ account string,
+ platformID int,
+ fcmToken string,
+ expireTime int64,
+) (err error) {
+ return errs.Wrap(
+ c.rdb.Set(ctx, fcmToken+account+":"+strconv.Itoa(platformID), fcmToken, time.Duration(expireTime)*time.Second).
+ Err(),
+ )
}
func (c *msgCache) GetFcmToken(ctx context.Context, account string, platformID int) (string, error) {
@@ -556,22 +621,46 @@ func (c *msgCache) JudgeMessageReactionExist(ctx context.Context, clientMsgID st
return n > 0, nil
}
-func (c *msgCache) SetMessageTypeKeyValue(ctx context.Context, clientMsgID string, sessionType int32, typeKey, value string) error {
+func (c *msgCache) SetMessageTypeKeyValue(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+ typeKey, value string,
+) error {
return errs.Wrap(c.rdb.HSet(ctx, c.getMessageReactionExPrefix(clientMsgID, sessionType), typeKey, value).Err())
}
-func (c *msgCache) SetMessageReactionExpire(ctx context.Context, clientMsgID string, sessionType int32, expiration time.Duration) (bool, error) {
+func (c *msgCache) SetMessageReactionExpire(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+ expiration time.Duration,
+) (bool, error) {
return utils.Wrap2(c.rdb.Expire(ctx, c.getMessageReactionExPrefix(clientMsgID, sessionType), expiration).Result())
}
-func (c *msgCache) GetMessageTypeKeyValue(ctx context.Context, clientMsgID string, sessionType int32, typeKey string) (string, error) {
+func (c *msgCache) GetMessageTypeKeyValue(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+ typeKey string,
+) (string, error) {
return utils.Wrap2(c.rdb.HGet(ctx, c.getMessageReactionExPrefix(clientMsgID, sessionType), typeKey).Result())
}
-func (c *msgCache) GetOneMessageAllReactionList(ctx context.Context, clientMsgID string, sessionType int32) (map[string]string, error) {
+func (c *msgCache) GetOneMessageAllReactionList(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+) (map[string]string, error) {
return utils.Wrap2(c.rdb.HGetAll(ctx, c.getMessageReactionExPrefix(clientMsgID, sessionType)).Result())
}
-func (c *msgCache) DeleteOneMessageKey(ctx context.Context, clientMsgID string, sessionType int32, subKey string) error {
+func (c *msgCache) DeleteOneMessageKey(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+ subKey string,
+) error {
return errs.Wrap(c.rdb.HDel(ctx, c.getMessageReactionExPrefix(clientMsgID, sessionType), subKey).Err())
}
diff --git a/pkg/common/db/cache/user.go b/pkg/common/db/cache/user.go
index a9eae5035..c8e8b1cc5 100644
--- a/pkg/common/db/cache/user.go
+++ b/pkg/common/db/cache/user.go
@@ -4,9 +4,10 @@ import (
"context"
"time"
- relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/dtm-labs/rockscache"
"github.com/redis/go-redis/v9"
+
+ relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
)
const (
@@ -32,7 +33,11 @@ type UserCacheRedis struct {
rcClient *rockscache.Client
}
-func NewUserCacheRedis(rdb redis.UniversalClient, userDB relationTb.UserModelInterface, options rockscache.Options) UserCache {
+func NewUserCacheRedis(
+ rdb redis.UniversalClient,
+ userDB relationTb.UserModelInterface,
+ options rockscache.Options,
+) UserCache {
rcClient := rockscache.NewClient(rdb, options)
return &UserCacheRedis{
metaCache: NewMetaCacheRedis(rcClient),
@@ -60,9 +65,15 @@ func (u *UserCacheRedis) getUserGlobalRecvMsgOptKey(userID string) string {
}
func (u *UserCacheRedis) GetUserInfo(ctx context.Context, userID string) (userInfo *relationTb.UserModel, err error) {
- return getCache(ctx, u.rcClient, u.getUserInfoKey(userID), u.expireTime, func(ctx context.Context) (*relationTb.UserModel, error) {
- return u.userDB.Take(ctx, userID)
- })
+ return getCache(
+ ctx,
+ u.rcClient,
+ u.getUserInfoKey(userID),
+ u.expireTime,
+ func(ctx context.Context) (*relationTb.UserModel, error) {
+ return u.userDB.Take(ctx, userID)
+ },
+ )
}
func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationTb.UserModel, error) {
@@ -70,16 +81,23 @@ func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]
for _, userID := range userIDs {
keys = append(keys, u.getUserInfoKey(userID))
}
- return batchGetCache(ctx, u.rcClient, keys, u.expireTime, func(user *relationTb.UserModel, keys []string) (int, error) {
- for i, key := range keys {
- if key == u.getUserInfoKey(user.UserID) {
- return i, nil
+ return batchGetCache(
+ ctx,
+ u.rcClient,
+ keys,
+ u.expireTime,
+ func(user *relationTb.UserModel, keys []string) (int, error) {
+ for i, key := range keys {
+ if key == u.getUserInfoKey(user.UserID) {
+ return i, nil
+ }
}
- }
- return 0, errIndex
- }, func(ctx context.Context) ([]*relationTb.UserModel, error) {
- return u.userDB.Find(ctx, userIDs)
- })
+ return 0, errIndex
+ },
+ func(ctx context.Context) ([]*relationTb.UserModel, error) {
+ return u.userDB.Find(ctx, userIDs)
+ },
+ )
}
func (u *UserCacheRedis) DelUsersInfo(userIDs ...string) UserCache {
@@ -93,9 +111,15 @@ func (u *UserCacheRedis) DelUsersInfo(userIDs ...string) UserCache {
}
func (u *UserCacheRedis) GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error) {
- return getCache(ctx, u.rcClient, u.getUserGlobalRecvMsgOptKey(userID), u.expireTime, func(ctx context.Context) (int, error) {
- return u.userDB.GetUserGlobalRecvMsgOpt(ctx, userID)
- })
+ return getCache(
+ ctx,
+ u.rcClient,
+ u.getUserGlobalRecvMsgOptKey(userID),
+ u.expireTime,
+ func(ctx context.Context) (int, error) {
+ return u.userDB.GetUserGlobalRecvMsgOpt(ctx, userID)
+ },
+ )
}
func (u *UserCacheRedis) DelUsersGlobalRecvMsgOpt(userIDs ...string) UserCache {
diff --git a/pkg/common/db/controller/auth.go b/pkg/common/db/controller/auth.go
index 6d6add902..46d2eb55a 100644
--- a/pkg/common/db/controller/auth.go
+++ b/pkg/common/db/controller/auth.go
@@ -3,11 +3,12 @@ package controller
import (
"context"
+ "github.com/golang-jwt/jwt/v4"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/golang-jwt/jwt/v4"
)
type AuthDatabase interface {
@@ -29,7 +30,11 @@ func NewAuthDatabase(cache cache.MsgModel, accessSecret string, accessExpire int
}
// 结果为空 不返回错误
-func (a *authDatabase) GetTokensWithoutError(ctx context.Context, userID string, platformID int) (map[string]int, error) {
+func (a *authDatabase) GetTokensWithoutError(
+ ctx context.Context,
+ userID string,
+ platformID int,
+) (map[string]int, error) {
return a.cache.GetTokensWithoutError(ctx, userID, platformID)
}
diff --git a/pkg/common/db/controller/black.go b/pkg/common/db/controller/black.go
index 61fe19c79..fad4d8acb 100644
--- a/pkg/common/db/controller/black.go
+++ b/pkg/common/db/controller/black.go
@@ -15,7 +15,11 @@ type BlackDatabase interface {
// Delete 删除黑名单
Delete(ctx context.Context, blacks []*relation.BlackModel) (err error)
// FindOwnerBlacks 获取黑名单列表
- FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.BlackModel, total int64, err error)
+ FindOwnerBlacks(
+ ctx context.Context,
+ ownerUserID string,
+ pageNumber, showNumber int32,
+ ) (blacks []*relation.BlackModel, total int64, err error)
FindBlackIDs(ctx context.Context, ownerUserID string) (blackIDs []string, err error)
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
@@ -55,12 +59,19 @@ func (b *blackDatabase) deleteBlackIDsCache(ctx context.Context, blacks []*relat
}
// FindOwnerBlacks 获取黑名单列表
-func (b *blackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.BlackModel, total int64, err error) {
+func (b *blackDatabase) FindOwnerBlacks(
+ ctx context.Context,
+ ownerUserID string,
+ pageNumber, showNumber int32,
+) (blacks []*relation.BlackModel, total int64, err error) {
return b.black.FindOwnerBlacks(ctx, ownerUserID, pageNumber, showNumber)
}
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
-func (b *blackDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error) {
+func (b *blackDatabase) CheckIn(
+ ctx context.Context,
+ userID1, userID2 string,
+) (inUser1Blacks bool, inUser2Blacks bool, err error) {
userID1BlackIDs, err := b.cache.GetBlackIDs(ctx, userID1)
if err != nil {
return
diff --git a/pkg/common/db/controller/chatlog.go b/pkg/common/db/controller/chatlog.go
index fc03719f1..cb161699f 100644
--- a/pkg/common/db/controller/chatlog.go
+++ b/pkg/common/db/controller/chatlog.go
@@ -7,7 +7,11 @@ import (
type ChatLogDatabase interface {
CreateChatLog(msg *pbMsg.MsgDataToMQ) error
- GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypes []int32) (int64, []relationTb.ChatLogModel, error)
+ GetChatLog(
+ chatLog *relationTb.ChatLogModel,
+ pageNumber, showNumber int32,
+ contentTypes []int32,
+ ) (int64, []relationTb.ChatLogModel, error)
}
func NewChatLogDatabase(chatLogModelInterface relationTb.ChatLogModelInterface) ChatLogDatabase {
@@ -22,6 +26,10 @@ func (c *chatLogDatabase) CreateChatLog(msg *pbMsg.MsgDataToMQ) error {
return c.chatLogModel.Create(msg)
}
-func (c *chatLogDatabase) GetChatLog(chatLog *relationTb.ChatLogModel, pageNumber, showNumber int32, contentTypes []int32) (int64, []relationTb.ChatLogModel, error) {
+func (c *chatLogDatabase) GetChatLog(
+ chatLog *relationTb.ChatLogModel,
+ pageNumber, showNumber int32,
+ contentTypes []int32,
+) (int64, []relationTb.ChatLogModel, error) {
return c.chatLogModel.GetChatLog(chatLog, pageNumber, showNumber, contentTypes)
}
diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go
index 62c57c0fc..d5bec4376 100644
--- a/pkg/common/db/controller/conversation.go
+++ b/pkg/common/db/controller/conversation.go
@@ -13,13 +13,22 @@ import (
type ConversationDatabase interface {
//UpdateUserConversationFiled 更新用户该会话的属性信息
- UpdateUsersConversationFiled(ctx context.Context, userIDs []string, conversationID string, args map[string]interface{}) error
+ UpdateUsersConversationFiled(
+ ctx context.Context,
+ userIDs []string,
+ conversationID string,
+ args map[string]interface{},
+ ) error
//CreateConversation 创建一批新的会话
CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error
//SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation []*relationTb.ConversationModel) error
//FindConversations 根据会话ID获取某个用户的多个会话
- FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error)
+ FindConversations(
+ ctx context.Context,
+ ownerUserID string,
+ conversationIDs []string,
+ ) ([]*relationTb.ConversationModel, error)
//FindRecvMsgNotNotifyUserIDs 获取超级大群开启免打扰的用户ID
FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
//GetUserAllConversation 获取一个用户在服务器上所有的会话
@@ -27,16 +36,28 @@ type ConversationDatabase interface {
//SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error
//SetUsersConversationFiledTx 设置多个用户会话关于某个字段的更新操作,如果会话不存在则创建,否则更新,内部保证事务操作
- SetUsersConversationFiledTx(ctx context.Context, userIDs []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error
+ SetUsersConversationFiledTx(
+ ctx context.Context,
+ userIDs []string,
+ conversation *relationTb.ConversationModel,
+ filedMap map[string]interface{},
+ ) error
CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error
GetConversationIDs(ctx context.Context, userID string) ([]string, error)
GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error)
GetAllConversationIDs(ctx context.Context) ([]string, error)
GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error)
- GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*relationTb.ConversationModel, error)
+ GetConversationsByConversationID(
+ ctx context.Context,
+ conversationIDs []string,
+ ) ([]*relationTb.ConversationModel, error)
}
-func NewConversationDatabase(conversation relationTb.ConversationModelInterface, cache cache.ConversationCache, tx tx.Tx) ConversationDatabase {
+func NewConversationDatabase(
+ conversation relationTb.ConversationModelInterface,
+ cache cache.ConversationCache,
+ tx tx.Tx,
+) ConversationDatabase {
return &conversationDatabase{
conversationDB: conversation,
cache: cache,
@@ -50,7 +71,12 @@ type conversationDatabase struct {
tx tx.Tx
}
-func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context, userIDs []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) (err error) {
+func (c *conversationDatabase) SetUsersConversationFiledTx(
+ ctx context.Context,
+ userIDs []string,
+ conversation *relationTb.ConversationModel,
+ filedMap map[string]interface{},
+) (err error) {
cache := c.cache.NewCache()
if err := c.tx.Transaction(func(tx any) error {
conversationTx := c.conversationDB.NewTx(tx)
@@ -96,7 +122,12 @@ func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context,
return cache.ExecDel(ctx)
}
-func (c *conversationDatabase) UpdateUsersConversationFiled(ctx context.Context, userIDs []string, conversationID string, args map[string]interface{}) error {
+func (c *conversationDatabase) UpdateUsersConversationFiled(
+ ctx context.Context,
+ userIDs []string,
+ conversationID string,
+ args map[string]interface{},
+) error {
_, err := c.conversationDB.UpdateByMap(ctx, userIDs, conversationID, args)
if err != nil {
return err
@@ -104,7 +135,10 @@ func (c *conversationDatabase) UpdateUsersConversationFiled(ctx context.Context,
return c.cache.DelUsersConversation(conversationID, userIDs...).ExecDel(ctx)
}
-func (c *conversationDatabase) CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error {
+func (c *conversationDatabase) CreateConversation(
+ ctx context.Context,
+ conversations []*relationTb.ConversationModel,
+) error {
if err := c.conversationDB.Create(ctx, conversations); err != nil {
return err
}
@@ -117,7 +151,10 @@ func (c *conversationDatabase) CreateConversation(ctx context.Context, conversat
return cache.DelConversationIDs(userIDs...).DelUserConversationIDsHash(userIDs...).ExecDel(ctx)
}
-func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(ctx context.Context, conversations []*relationTb.ConversationModel) error {
+func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(
+ ctx context.Context,
+ conversations []*relationTb.ConversationModel,
+) error {
cache := c.cache.NewCache()
if err := c.tx.Transaction(func(tx any) error {
conversationTx := c.conversationDB.NewTx(tx)
@@ -153,19 +190,34 @@ func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(ctx context.Con
return c.cache.ExecDel(ctx)
}
-func (c *conversationDatabase) FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error) {
+func (c *conversationDatabase) FindConversations(
+ ctx context.Context,
+ ownerUserID string,
+ conversationIDs []string,
+) ([]*relationTb.ConversationModel, error) {
return c.cache.GetConversations(ctx, ownerUserID, conversationIDs)
}
-func (c *conversationDatabase) GetConversation(ctx context.Context, ownerUserID string, conversationID string) (*relationTb.ConversationModel, error) {
+func (c *conversationDatabase) GetConversation(
+ ctx context.Context,
+ ownerUserID string,
+ conversationID string,
+) (*relationTb.ConversationModel, error) {
return c.cache.GetConversation(ctx, ownerUserID, conversationID)
}
-func (c *conversationDatabase) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) {
+func (c *conversationDatabase) GetUserAllConversation(
+ ctx context.Context,
+ ownerUserID string,
+) ([]*relationTb.ConversationModel, error) {
return c.cache.GetUserAllConversations(ctx, ownerUserID)
}
-func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error {
+func (c *conversationDatabase) SetUserConversations(
+ ctx context.Context,
+ ownerUserID string,
+ conversations []*relationTb.ConversationModel,
+) error {
cache := c.cache.NewCache()
if err := c.tx.Transaction(func(tx any) error {
var conversationIDs []string
@@ -215,7 +267,11 @@ func (c *conversationDatabase) FindRecvMsgNotNotifyUserIDs(ctx context.Context,
return c.cache.GetSuperGroupRecvMsgNotNotifyUserIDs(ctx, groupID)
}
-func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error {
+func (c *conversationDatabase) CreateGroupChatConversation(
+ ctx context.Context,
+ groupID string,
+ userIDs []string,
+) error {
cache := c.cache.NewCache()
conversationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
if err := c.tx.Transaction(func(tx any) error {
@@ -255,7 +311,10 @@ func (c *conversationDatabase) GetConversationIDs(ctx context.Context, userID st
return c.cache.GetUserConversationIDs(ctx, userID)
}
-func (c *conversationDatabase) GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error) {
+func (c *conversationDatabase) GetUserConversationIDsHash(
+ ctx context.Context,
+ ownerUserID string,
+) (hash uint64, err error) {
return c.cache.GetUserConversationIDsHash(ctx, ownerUserID)
}
@@ -263,10 +322,16 @@ func (c *conversationDatabase) GetAllConversationIDs(ctx context.Context) ([]str
return c.conversationDB.GetAllConversationIDs(ctx)
}
-func (c *conversationDatabase) GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error) {
+func (c *conversationDatabase) GetUserAllHasReadSeqs(
+ ctx context.Context,
+ ownerUserID string,
+) (map[string]int64, error) {
return c.cache.GetUserAllHasReadSeqs(ctx, ownerUserID)
}
-func (c *conversationDatabase) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*relationTb.ConversationModel, error) {
+func (c *conversationDatabase) GetConversationsByConversationID(
+ ctx context.Context,
+ conversationIDs []string,
+) ([]*relationTb.ConversationModel, error) {
return c.conversationDB.GetConversationsByConversationID(ctx, conversationIDs)
}
diff --git a/pkg/common/db/controller/extend_msg.go b/pkg/common/db/controller/extend_msg.go
index 9717bd933..b9395db0e 100644
--- a/pkg/common/db/controller/extend_msg.go
+++ b/pkg/common/db/controller/extend_msg.go
@@ -11,12 +11,46 @@ import (
// for mongoDB
type ExtendMsgDatabase interface {
CreateExtendMsgSet(ctx context.Context, set *unRelationTb.ExtendMsgSetModel) error
- GetAllExtendMsgSet(ctx context.Context, ID string, opts *unRelationTb.GetAllExtendMsgSetOpts) (sets []*unRelationTb.ExtendMsgSetModel, err error)
- GetExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, maxMsgUpdateTime int64) (*unRelationTb.ExtendMsgSetModel, error)
- InsertExtendMsg(ctx context.Context, conversationID string, sessionType int32, msg *unRelationTb.ExtendMsgModel) error
- InsertOrUpdateReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*unRelationTb.KeyValueModel) error
- DeleteReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*unRelationTb.KeyValueModel) error
- GetExtendMsg(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, maxMsgUpdateTime int64) (extendMsg *unRelationTb.ExtendMsgModel, err error)
+ GetAllExtendMsgSet(
+ ctx context.Context,
+ ID string,
+ opts *unRelationTb.GetAllExtendMsgSetOpts,
+ ) (sets []*unRelationTb.ExtendMsgSetModel, err error)
+ GetExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ maxMsgUpdateTime int64,
+ ) (*unRelationTb.ExtendMsgSetModel, error)
+ InsertExtendMsg(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ msg *unRelationTb.ExtendMsgModel,
+ ) error
+ InsertOrUpdateReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensionList map[string]*unRelationTb.KeyValueModel,
+ ) error
+ DeleteReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensionList map[string]*unRelationTb.KeyValueModel,
+ ) error
+ GetExtendMsg(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ maxMsgUpdateTime int64,
+ ) (extendMsg *unRelationTb.ExtendMsgModel, err error)
}
type extendMsgDatabase struct {
@@ -25,7 +59,11 @@ type extendMsgDatabase struct {
ctxTx tx.CtxTx
}
-func NewExtendMsgDatabase(extendMsgModel unRelationTb.ExtendMsgSetModelInterface, cache cache.ExtendMsgSetCache, ctxTx tx.CtxTx) ExtendMsgDatabase {
+func NewExtendMsgDatabase(
+ extendMsgModel unRelationTb.ExtendMsgSetModelInterface,
+ cache cache.ExtendMsgSetCache,
+ ctxTx tx.CtxTx,
+) ExtendMsgDatabase {
return &extendMsgDatabase{database: extendMsgModel, cache: cache, ctxTx: ctxTx}
}
@@ -33,26 +71,74 @@ func (e *extendMsgDatabase) CreateExtendMsgSet(ctx context.Context, set *unRelat
return e.database.CreateExtendMsgSet(ctx, set)
}
-func (e *extendMsgDatabase) GetAllExtendMsgSet(ctx context.Context, conversationID string, opts *unRelationTb.GetAllExtendMsgSetOpts) (sets []*unRelationTb.ExtendMsgSetModel, err error) {
+func (e *extendMsgDatabase) GetAllExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ opts *unRelationTb.GetAllExtendMsgSetOpts,
+) (sets []*unRelationTb.ExtendMsgSetModel, err error) {
return e.database.GetAllExtendMsgSet(ctx, conversationID, opts)
}
-func (e *extendMsgDatabase) GetExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, maxMsgUpdateTime int64) (*unRelationTb.ExtendMsgSetModel, error) {
+func (e *extendMsgDatabase) GetExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ maxMsgUpdateTime int64,
+) (*unRelationTb.ExtendMsgSetModel, error) {
return e.database.GetExtendMsgSet(ctx, conversationID, sessionType, maxMsgUpdateTime)
}
-func (e *extendMsgDatabase) InsertExtendMsg(ctx context.Context, conversationID string, sessionType int32, msg *unRelationTb.ExtendMsgModel) error {
+func (e *extendMsgDatabase) InsertExtendMsg(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ msg *unRelationTb.ExtendMsgModel,
+) error {
return e.database.InsertExtendMsg(ctx, conversationID, sessionType, msg)
}
-func (e *extendMsgDatabase) InsertOrUpdateReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*unRelationTb.KeyValueModel) error {
- return e.database.InsertOrUpdateReactionExtendMsgSet(ctx, conversationID, sessionType, clientMsgID, msgFirstModifyTime, reactionExtensionList)
+func (e *extendMsgDatabase) InsertOrUpdateReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensionList map[string]*unRelationTb.KeyValueModel,
+) error {
+ return e.database.InsertOrUpdateReactionExtendMsgSet(
+ ctx,
+ conversationID,
+ sessionType,
+ clientMsgID,
+ msgFirstModifyTime,
+ reactionExtensionList,
+ )
}
-func (e *extendMsgDatabase) DeleteReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*unRelationTb.KeyValueModel) error {
- return e.database.DeleteReactionExtendMsgSet(ctx, conversationID, sessionType, clientMsgID, msgFirstModifyTime, reactionExtensionList)
+func (e *extendMsgDatabase) DeleteReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensionList map[string]*unRelationTb.KeyValueModel,
+) error {
+ return e.database.DeleteReactionExtendMsgSet(
+ ctx,
+ conversationID,
+ sessionType,
+ clientMsgID,
+ msgFirstModifyTime,
+ reactionExtensionList,
+ )
}
-func (e *extendMsgDatabase) GetExtendMsg(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, maxMsgUpdateTime int64) (extendMsg *unRelationTb.ExtendMsgModel, err error) {
+func (e *extendMsgDatabase) GetExtendMsg(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ maxMsgUpdateTime int64,
+) (extendMsg *unRelationTb.ExtendMsgModel, err error) {
return e.cache.GetExtendMsg(ctx, conversationID, sessionType, clientMsgID, maxMsgUpdateTime)
}
diff --git a/pkg/common/db/controller/friend.go b/pkg/common/db/controller/friend.go
index 90985c9ad..3a98bd8ec 100644
--- a/pkg/common/db/controller/friend.go
+++ b/pkg/common/db/controller/friend.go
@@ -4,6 +4,8 @@ import (
"context"
"time"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
@@ -11,7 +13,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
type FriendDatabase interface {
@@ -30,15 +31,35 @@ type FriendDatabase interface {
// 更新好友备注
UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error)
// 获取ownerUserID的好友列表
- PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
+ PageOwnerFriends(
+ ctx context.Context,
+ ownerUserID string,
+ pageNumber, showNumber int32,
+ ) (friends []*relation.FriendModel, total int64, err error)
// friendUserID在哪些人的好友列表中
- PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
+ PageInWhoseFriends(
+ ctx context.Context,
+ friendUserID string,
+ pageNumber, showNumber int32,
+ ) (friends []*relation.FriendModel, total int64, err error)
// 获取我发出去的好友申请
- PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
+ PageFriendRequestFromMe(
+ ctx context.Context,
+ userID string,
+ pageNumber, showNumber int32,
+ ) (friends []*relation.FriendRequestModel, total int64, err error)
// 获取我收到的的好友申请
- PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
+ PageFriendRequestToMe(
+ ctx context.Context,
+ userID string,
+ pageNumber, showNumber int32,
+ ) (friends []*relation.FriendRequestModel, total int64, err error)
// 获取某人指定好友的信息
- FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error)
+ FindFriendsWithError(
+ ctx context.Context,
+ ownerUserID string,
+ friendUserIDs []string,
+ ) (friends []*relation.FriendModel, err error)
FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error)
}
@@ -49,12 +70,20 @@ type friendDatabase struct {
cache cache.FriendCache
}
-func NewFriendDatabase(friend relation.FriendModelInterface, friendRequest relation.FriendRequestModelInterface, cache cache.FriendCache, tx tx.Tx) FriendDatabase {
+func NewFriendDatabase(
+ friend relation.FriendModelInterface,
+ friendRequest relation.FriendRequestModelInterface,
+ cache cache.FriendCache,
+ tx tx.Tx,
+) FriendDatabase {
return &friendDatabase{friend: friend, friendRequest: friendRequest, cache: cache, tx: tx}
}
// ok 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true)
-func (f *friendDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Friends bool, inUser2Friends bool, err error) {
+func (f *friendDatabase) CheckIn(
+ ctx context.Context,
+ userID1, userID2 string,
+) (inUser1Friends bool, inUser2Friends bool, err error) {
userID1FriendIDs, err := f.cache.GetFriendIDs(ctx, userID1)
if err != nil {
return
@@ -67,7 +96,12 @@ func (f *friendDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (
}
// 增加或者更新好友申请 如果之前有记录则更新,没有记录则新增
-func (f *friendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) {
+func (f *friendDatabase) AddFriendRequest(
+ ctx context.Context,
+ fromUserID, toUserID string,
+ reqMsg string,
+ ex string,
+) (err error) {
return f.tx.Transaction(func(tx any) error {
_, err := f.friendRequest.NewTx(tx).Take(ctx, fromUserID, toUserID)
//有db错误
@@ -96,7 +130,12 @@ func (f *friendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUse
}
// (1)先判断是否在好友表 (在不在都不返回错误) (2)对于不在好友列表的 插入即可
-func (f *friendDatabase) BecomeFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, addSource int32) (err error) {
+func (f *friendDatabase) BecomeFriends(
+ ctx context.Context,
+ ownerUserID string,
+ friendUserIDs []string,
+ addSource int32,
+) (err error) {
cache := f.cache.NewCache()
if err := f.tx.Transaction(func(tx any) error {
//先find 找出重复的 去掉重复的
@@ -142,7 +181,10 @@ func (f *friendDatabase) BecomeFriends(ctx context.Context, ownerUserID string,
}
// 拒绝好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)修改申请记录 已拒绝
-func (f *friendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
+func (f *friendDatabase) RefuseFriendRequest(
+ ctx context.Context,
+ friendRequest *relation.FriendRequestModel,
+) (err error) {
fr, err := f.friendRequest.Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID)
if err != nil {
return err
@@ -160,7 +202,10 @@ func (f *friendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest
}
// AgreeFriendRequest 同意好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)检查是否好友(不返回错误) (3) 建立双向好友关系(存在的忽略)
-func (f *friendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
+func (f *friendDatabase) AgreeFriendRequest(
+ ctx context.Context,
+ friendRequest *relation.FriendRequestModel,
+) (err error) {
return f.tx.Transaction(func(tx any) error {
fr, err := f.friendRequest.NewTx(tx).Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID)
if err != nil {
@@ -185,10 +230,26 @@ func (f *friendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *
}))
var adds []*relation.FriendModel
if _, ok := existsMap[[...]string{friendRequest.ToUserID, friendRequest.FromUserID}]; !ok { // 自己 - 好友
- adds = append(adds, &relation.FriendModel{OwnerUserID: friendRequest.ToUserID, FriendUserID: friendRequest.FromUserID, AddSource: int32(constant.BecomeFriendByApply), OperatorUserID: friendRequest.FromUserID})
+ adds = append(
+ adds,
+ &relation.FriendModel{
+ OwnerUserID: friendRequest.ToUserID,
+ FriendUserID: friendRequest.FromUserID,
+ AddSource: int32(constant.BecomeFriendByApply),
+ OperatorUserID: friendRequest.FromUserID,
+ },
+ )
}
if _, ok := existsMap[[...]string{friendRequest.FromUserID, friendRequest.ToUserID}]; !ok { // 好友 - 自己
- adds = append(adds, &relation.FriendModel{OwnerUserID: friendRequest.FromUserID, FriendUserID: friendRequest.ToUserID, AddSource: int32(constant.BecomeFriendByApply), OperatorUserID: friendRequest.FromUserID})
+ adds = append(
+ adds,
+ &relation.FriendModel{
+ OwnerUserID: friendRequest.FromUserID,
+ FriendUserID: friendRequest.ToUserID,
+ AddSource: int32(constant.BecomeFriendByApply),
+ OperatorUserID: friendRequest.FromUserID,
+ },
+ )
}
if len(adds) > 0 {
if err := f.friend.NewTx(tx).Create(ctx, adds); err != nil {
@@ -216,27 +277,47 @@ func (f *friendDatabase) UpdateRemark(ctx context.Context, ownerUserID, friendUs
}
// 获取ownerUserID的好友列表 无结果不返回错误
-func (f *friendDatabase) PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
+func (f *friendDatabase) PageOwnerFriends(
+ ctx context.Context,
+ ownerUserID string,
+ pageNumber, showNumber int32,
+) (friends []*relation.FriendModel, total int64, err error) {
return f.friend.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
}
// friendUserID在哪些人的好友列表中
-func (f *friendDatabase) PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
+func (f *friendDatabase) PageInWhoseFriends(
+ ctx context.Context,
+ friendUserID string,
+ pageNumber, showNumber int32,
+) (friends []*relation.FriendModel, total int64, err error) {
return f.friend.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
}
// 获取我发出去的好友申请 无结果不返回错误
-func (f *friendDatabase) PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
+func (f *friendDatabase) PageFriendRequestFromMe(
+ ctx context.Context,
+ userID string,
+ pageNumber, showNumber int32,
+) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.friendRequest.FindFromUserID(ctx, userID, pageNumber, showNumber)
}
// 获取我收到的的好友申请 无结果不返回错误
-func (f *friendDatabase) PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
+func (f *friendDatabase) PageFriendRequestToMe(
+ ctx context.Context,
+ userID string,
+ pageNumber, showNumber int32,
+) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.friendRequest.FindToUserID(ctx, userID, pageNumber, showNumber)
}
// 获取某人指定好友的信息 如果有好友不存在,也返回错误
-func (f *friendDatabase) FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) {
+func (f *friendDatabase) FindFriendsWithError(
+ ctx context.Context,
+ ownerUserID string,
+ friendUserIDs []string,
+) (friends []*relation.FriendModel, err error) {
friends, err = f.friend.FindFriends(ctx, ownerUserID, friendUserIDs)
if err != nil {
return
@@ -247,6 +328,9 @@ func (f *friendDatabase) FindFriendsWithError(ctx context.Context, ownerUserID s
return
}
-func (f *friendDatabase) FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error) {
+func (f *friendDatabase) FindFriendUserIDs(
+ ctx context.Context,
+ ownerUserID string,
+) (friendUserIDs []string, err error) {
return f.cache.GetFriendIDs(ctx, ownerUserID)
}
diff --git a/pkg/common/db/controller/group.go b/pkg/common/db/controller/group.go
index 19ae3e87e..58ee9394b 100644
--- a/pkg/common/db/controller/group.go
+++ b/pkg/common/db/controller/group.go
@@ -4,6 +4,11 @@ import (
"context"
"fmt"
+ "github.com/dtm-labs/rockscache"
+ "github.com/redis/go-redis/v9"
+ "go.mongodb.org/mongo-driver/mongo"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
@@ -12,10 +17,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/tx"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/dtm-labs/rockscache"
- "github.com/redis/go-redis/v9"
- "go.mongodb.org/mongo-driver/mongo"
- "gorm.io/gorm"
)
type GroupDatabase interface {
@@ -23,33 +24,82 @@ type GroupDatabase interface {
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
- SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupModel, error)
+ SearchGroup(
+ ctx context.Context,
+ keyword string,
+ pageNumber, showNumber int32,
+ ) (uint32, []*relationTb.GroupModel, error)
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
DismissGroup(ctx context.Context, groupID string, deleteMember bool) error // 解散群,并删除群成员
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
// GroupMember
- TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error)
+ TakeGroupMember(
+ ctx context.Context,
+ groupID string,
+ userID string,
+ ) (groupMember *relationTb.GroupMemberModel, err error)
TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error)
- FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error)
+ FindGroupMember(
+ ctx context.Context,
+ groupIDs []string,
+ userIDs []string,
+ roleLevels []int32,
+ ) ([]*relationTb.GroupMemberModel, error)
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
FindGroupMemberNum(ctx context.Context, groupID string) (uint32, error)
FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
- PageGroupRequest(ctx context.Context, groupIDs []string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error)
- //PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
- PageGetJoinGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error)
- PageGetGroupMember(ctx context.Context, groupID string, pageNumber, showNumber int32) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error)
- SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
- HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error
+ PageGroupRequest(
+ ctx context.Context,
+ groupIDs []string,
+ pageNumber, showNumber int32,
+ ) (uint32, []*relationTb.GroupRequestModel, error)
+ // PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber,
+ // showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
+ PageGetJoinGroup(
+ ctx context.Context,
+ userID string,
+ pageNumber, showNumber int32,
+ ) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error)
+ PageGetGroupMember(
+ ctx context.Context,
+ groupID string,
+ pageNumber, showNumber int32,
+ ) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error)
+ SearchGroupMember(
+ ctx context.Context,
+ keyword string,
+ groupIDs []string,
+ userIDs []string,
+ roleLevels []int32,
+ pageNumber, showNumber int32,
+ ) (uint32, []*relationTb.GroupMemberModel, error)
+ HandlerGroupRequest(
+ ctx context.Context,
+ groupID string,
+ userID string,
+ handledMsg string,
+ handleResult int32,
+ member *relationTb.GroupMemberModel,
+ ) error
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error)
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
- TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群
+ TransferGroupOwner(
+ ctx context.Context,
+ groupID string,
+ oldOwnerUserID, newOwnerUserID string,
+ roleLevel int32,
+ ) error // 转让群
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error
// GroupRequest
CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error)
- PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error)
+ PageGroupRequestUser(
+ ctx context.Context,
+ userID string,
+ pageNumber, showNumber int32,
+ ) (uint32, []*relationTb.GroupRequestModel, error)
// SuperGroupModelInterface
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unRelationTb.SuperGroupModel, error)
FindJoinSuperGroup(ctx context.Context, userID string) ([]string, error)
@@ -91,7 +141,14 @@ func InitGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, database *mongo.D
tx.NewGorm(db),
tx.NewMongo(database.Client()),
unrelation.NewSuperGroupMongoDriver(database),
- cache.NewGroupCacheRedis(rdb, relation.NewGroupDB(db), relation.NewGroupMemberDB(db), relation.NewGroupRequest(db), unrelation.NewSuperGroupMongoDriver(database), rcOptions),
+ cache.NewGroupCacheRedis(
+ rdb,
+ relation.NewGroupDB(db),
+ relation.NewGroupMemberDB(db),
+ relation.NewGroupRequest(db),
+ unrelation.NewSuperGroupMongoDriver(database),
+ rcOptions,
+ ),
)
}
@@ -121,7 +178,11 @@ func (g *groupDatabase) FindGroupMemberNum(ctx context.Context, groupID string)
return uint32(num), nil
}
-func (g *groupDatabase) CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error {
+func (g *groupDatabase) CreateGroup(
+ ctx context.Context,
+ groups []*relationTb.GroupModel,
+ groupMembers []*relationTb.GroupMemberModel,
+) error {
var cache = g.cache.NewCache()
if err := g.tx.Transaction(func(tx any) error {
if len(groups) > 0 {
@@ -162,7 +223,11 @@ func (g *groupDatabase) FindGroup(ctx context.Context, groupIDs []string) (group
return g.cache.GetGroupsInfo(ctx, groupIDs)
}
-func (g *groupDatabase) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupModel, error) {
+func (g *groupDatabase) SearchGroup(
+ ctx context.Context,
+ keyword string,
+ pageNumber, showNumber int32,
+) (uint32, []*relationTb.GroupModel, error) {
return g.groupDB.Search(ctx, keyword, pageNumber, showNumber)
}
@@ -197,7 +262,11 @@ func (g *groupDatabase) DismissGroup(ctx context.Context, groupID string, delete
return cache.ExecDel(ctx)
}
-func (g *groupDatabase) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error) {
+func (g *groupDatabase) TakeGroupMember(
+ ctx context.Context,
+ groupID string,
+ userID string,
+) (groupMember *relationTb.GroupMemberModel, err error) {
return g.cache.GetGroupMemberInfo(ctx, groupID, userID)
}
@@ -209,11 +278,20 @@ func (g *groupDatabase) FindUserManagedGroupID(ctx context.Context, userID strin
return g.groupMemberDB.FindUserManagedGroupID(ctx, userID)
}
-func (g *groupDatabase) PageGroupRequest(ctx context.Context, groupIDs []string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error) {
+func (g *groupDatabase) PageGroupRequest(
+ ctx context.Context,
+ groupIDs []string,
+ pageNumber, showNumber int32,
+) (uint32, []*relationTb.GroupRequestModel, error) {
return g.groupRequestDB.PageGroup(ctx, groupIDs, pageNumber, showNumber)
}
-func (g *groupDatabase) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) (totalGroupMembers []*relationTb.GroupMemberModel, err error) {
+func (g *groupDatabase) FindGroupMember(
+ ctx context.Context,
+ groupIDs []string,
+ userIDs []string,
+ roleLevels []int32,
+) (totalGroupMembers []*relationTb.GroupMemberModel, err error) {
if roleLevels == nil {
for _, groupID := range groupIDs {
groupMembers, err := g.cache.GetGroupMembersInfo(ctx, groupID, userIDs)
@@ -227,7 +305,11 @@ func (g *groupDatabase) FindGroupMember(ctx context.Context, groupIDs []string,
return g.groupMemberDB.Find(ctx, groupIDs, userIDs, roleLevels)
}
-func (g *groupDatabase) PageGetJoinGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error) {
+func (g *groupDatabase) PageGetJoinGroup(
+ ctx context.Context,
+ userID string,
+ pageNumber, showNumber int32,
+) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error) {
groupIDs, err := g.cache.GetJoinedGroupIDs(ctx, userID)
if err != nil {
return 0, nil, err
@@ -242,7 +324,11 @@ func (g *groupDatabase) PageGetJoinGroup(ctx context.Context, userID string, pag
return uint32(len(groupIDs)), totalGroupMembers, nil
}
-func (g *groupDatabase) PageGetGroupMember(ctx context.Context, groupID string, pageNumber, showNumber int32) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error) {
+func (g *groupDatabase) PageGetGroupMember(
+ ctx context.Context,
+ groupID string,
+ pageNumber, showNumber int32,
+) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error) {
groupMemberIDs, err := g.cache.GetGroupMemberIDs(ctx, groupID)
if err != nil {
return 0, nil, err
@@ -258,11 +344,25 @@ func (g *groupDatabase) PageGetGroupMember(ctx context.Context, groupID string,
return uint32(len(groupMemberIDs)), members, nil
}
-func (g *groupDatabase) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) {
+func (g *groupDatabase) SearchGroupMember(
+ ctx context.Context,
+ keyword string,
+ groupIDs []string,
+ userIDs []string,
+ roleLevels []int32,
+ pageNumber, showNumber int32,
+) (uint32, []*relationTb.GroupMemberModel, error) {
return g.groupMemberDB.SearchMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
}
-func (g *groupDatabase) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error {
+func (g *groupDatabase) HandlerGroupRequest(
+ ctx context.Context,
+ groupID string,
+ userID string,
+ handledMsg string,
+ handleResult int32,
+ member *relationTb.GroupMemberModel,
+) error {
cache := g.cache.NewCache()
if err := g.tx.Transaction(func(tx any) error {
if err := g.groupRequestDB.NewTx(tx).UpdateHandler(ctx, groupID, userID, handledMsg, handleResult); err != nil {
@@ -285,10 +385,18 @@ func (g *groupDatabase) DeleteGroupMember(ctx context.Context, groupID string, u
if err := g.groupMemberDB.Delete(ctx, groupID, userIDs); err != nil {
return err
}
- return g.cache.DelGroupMembersHash(groupID).DelGroupMemberIDs(groupID).DelGroupsMemberNum(groupID).DelJoinedGroupID(userIDs...).DelGroupMembersInfo(groupID, userIDs...).ExecDel(ctx)
-}
-
-func (g *groupDatabase) MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error) {
+ return g.cache.DelGroupMembersHash(groupID).
+ DelGroupMemberIDs(groupID).
+ DelGroupsMemberNum(groupID).
+ DelJoinedGroupID(userIDs...).
+ DelGroupMembersInfo(groupID, userIDs...).
+ ExecDel(ctx)
+}
+
+func (g *groupDatabase) MapGroupMemberUserID(
+ ctx context.Context,
+ groupIDs []string,
+) (map[string]*relationTb.GroupSimpleUserID, error) {
return g.cache.GetGroupMemberHashMap(ctx, groupIDs)
}
@@ -304,7 +412,12 @@ func (g *groupDatabase) MapGroupMemberNum(ctx context.Context, groupIDs []string
return m, nil
}
-func (g *groupDatabase) TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error {
+func (g *groupDatabase) TransferGroupOwner(
+ ctx context.Context,
+ groupID string,
+ oldOwnerUserID, newOwnerUserID string,
+ roleLevel int32,
+) error {
if err := g.tx.Transaction(func(tx any) error {
rowsAffected, err := g.groupMemberDB.NewTx(tx).UpdateRoleLevel(ctx, groupID, oldOwnerUserID, roleLevel)
if err != nil {
@@ -327,7 +440,12 @@ func (g *groupDatabase) TransferGroupOwner(ctx context.Context, groupID string,
return g.cache.DelGroupMembersInfo(groupID, oldOwnerUserID, newOwnerUserID).ExecDel(ctx)
}
-func (g *groupDatabase) UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error {
+func (g *groupDatabase) UpdateGroupMember(
+ ctx context.Context,
+ groupID string,
+ userID string,
+ data map[string]any,
+) error {
if err := g.groupMemberDB.Update(ctx, groupID, userID, data); err != nil {
return err
}
@@ -362,15 +480,26 @@ func (g *groupDatabase) CreateGroupRequest(ctx context.Context, requests []*rela
})
}
-func (g *groupDatabase) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error) {
+func (g *groupDatabase) TakeGroupRequest(
+ ctx context.Context,
+ groupID string,
+ userID string,
+) (*relationTb.GroupRequestModel, error) {
return g.groupRequestDB.Take(ctx, groupID, userID)
}
-func (g *groupDatabase) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error) {
+func (g *groupDatabase) PageGroupRequestUser(
+ ctx context.Context,
+ userID string,
+ pageNumber, showNumber int32,
+) (uint32, []*relationTb.GroupRequestModel, error) {
return g.groupRequestDB.Page(ctx, userID, pageNumber, showNumber)
}
-func (g *groupDatabase) FindSuperGroup(ctx context.Context, groupIDs []string) (models []*unRelationTb.SuperGroupModel, err error) {
+func (g *groupDatabase) FindSuperGroup(
+ ctx context.Context,
+ groupIDs []string,
+) (models []*unRelationTb.SuperGroupModel, err error) {
return g.cache.GetSuperGroupMemberIDs(ctx, groupIDs...)
}
diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go
index dd62e0e2e..6ce55deae 100644
--- a/pkg/common/db/controller/msg.go
+++ b/pkg/common/db/controller/msg.go
@@ -19,10 +19,11 @@ import (
"context"
"errors"
+ "go.mongodb.org/mongo-driver/mongo"
+
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "go.mongodb.org/mongo-driver/mongo"
)
const (
@@ -41,12 +42,26 @@ type CommonMsgDatabase interface {
DeleteMessagesFromCache(ctx context.Context, conversationID string, seqs []int64) error
DelUserDeleteMsgsList(ctx context.Context, conversationID string, seqs []int64)
// incrSeq然后批量插入缓存
- BatchInsertChat2Cache(ctx context.Context, conversationID string, msgs []*sdkws.MsgData) (seq int64, isNewConversation bool, err error)
+ BatchInsertChat2Cache(
+ ctx context.Context,
+ conversationID string,
+ msgs []*sdkws.MsgData,
+ ) (seq int64, isNewConversation bool, err error)
// 通过seqList获取mongo中写扩散消息
- GetMsgBySeqsRange(ctx context.Context, userID string, conversationID string, begin, end, num, userMaxSeq int64) (minSeq int64, maxSeq int64, seqMsg []*sdkws.MsgData, err error)
+ GetMsgBySeqsRange(
+ ctx context.Context,
+ userID string,
+ conversationID string,
+ begin, end, num, userMaxSeq int64,
+ ) (minSeq int64, maxSeq int64, seqMsg []*sdkws.MsgData, err error)
// 通过seqList获取大群在 mongo里面的消息
- GetMsgBySeqs(ctx context.Context, userID string, conversationID string, seqs []int64) (minSeq int64, maxSeq int64, seqMsg []*sdkws.MsgData, err error)
+ GetMsgBySeqs(
+ ctx context.Context,
+ userID string,
+ conversationID string,
+ seqs []int64,
+ ) (minSeq int64, maxSeq int64, seqMsg []*sdkws.MsgData, err error)
// 删除会话消息重置最小seq, remainTime为消息保留的时间单位秒,超时消息删除, 传0删除所有消息(此方法不删除redis cache)
DeleteConversationMsgsAndSetMinSeq(ctx context.Context, conversationID string, remainTime int64) error
// 用户根据seq删除消息
@@ -73,7 +88,10 @@ type CommonMsgDatabase interface {
UserSetHasReadSeqs(ctx context.Context, userID string, hasReadSeqs map[string]int64) error
GetMongoMaxAndMinSeq(ctx context.Context, conversationID string) (maxSeq, minSeq int64, err error)
- GetConversationMinMaxSeqInMongoAndCache(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error)
+ GetConversationMinMaxSeqInMongoAndCache(
+ ctx context.Context,
+ conversationID string,
+ ) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error)
SetSendMsgStatus(ctx context.Context, id string, status int32) error
GetSendMsgStatus(ctx context.Context, id string) (int32, error)
@@ -86,13 +104,38 @@ type CommonMsgDatabase interface {
// modify
JudgeMessageReactionExist(ctx context.Context, clientMsgID string, sessionType int32) (bool, error)
SetMessageTypeKeyValue(ctx context.Context, clientMsgID string, sessionType int32, typeKey, value string) error
- SetMessageReactionExpire(ctx context.Context, clientMsgID string, sessionType int32, expiration time.Duration) (bool, error)
- GetExtendMsg(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, maxMsgUpdateTime int64) (*pbMsg.ExtendMsg, error)
- InsertOrUpdateReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*sdkws.KeyValue) error
+ SetMessageReactionExpire(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+ expiration time.Duration,
+ ) (bool, error)
+ GetExtendMsg(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ maxMsgUpdateTime int64,
+ ) (*pbMsg.ExtendMsg, error)
+ InsertOrUpdateReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensionList map[string]*sdkws.KeyValue,
+ ) error
GetMessageTypeKeyValue(ctx context.Context, clientMsgID string, sessionType int32, typeKey string) (string, error)
GetOneMessageAllReactionList(ctx context.Context, clientMsgID string, sessionType int32) (map[string]string, error)
DeleteOneMessageKey(ctx context.Context, clientMsgID string, sessionType int32, subKey string) error
- DeleteReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*sdkws.KeyValue) error
+ DeleteReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensionList map[string]*sdkws.KeyValue,
+ ) error
}
func NewCommonMsgDatabase(msgDocModel unRelationTb.MsgDocModelInterface, cacheModel cache.MsgModel) CommonMsgDatabase {
@@ -130,16 +173,32 @@ func (db *commonMsgDatabase) MsgToMQ(ctx context.Context, key string, msg2mq *sd
return err
}
-func (db *commonMsgDatabase) MsgToModifyMQ(ctx context.Context, key, conversationID string, messages []*sdkws.MsgData) error {
+func (db *commonMsgDatabase) MsgToModifyMQ(
+ ctx context.Context,
+ key, conversationID string,
+ messages []*sdkws.MsgData,
+) error {
if len(messages) > 0 {
- _, _, err := db.producerToModify.SendMessage(ctx, key, &pbMsg.MsgDataToModifyByMQ{ConversationID: conversationID, Messages: messages})
+ _, _, err := db.producerToModify.SendMessage(
+ ctx,
+ key,
+ &pbMsg.MsgDataToModifyByMQ{ConversationID: conversationID, Messages: messages},
+ )
return err
}
return nil
}
-func (db *commonMsgDatabase) MsgToPushMQ(ctx context.Context, key, conversationID string, msg2mq *sdkws.MsgData) (int32, int64, error) {
- partition, offset, err := db.producerToPush.SendMessage(ctx, key, &pbMsg.PushMsgDataToMQ{MsgData: msg2mq, ConversationID: conversationID})
+func (db *commonMsgDatabase) MsgToPushMQ(
+ ctx context.Context,
+ key, conversationID string,
+ msg2mq *sdkws.MsgData,
+) (int32, int64, error) {
+ partition, offset, err := db.producerToPush.SendMessage(
+ ctx,
+ key,
+ &pbMsg.PushMsgDataToMQ{MsgData: msg2mq, ConversationID: conversationID},
+ )
if err != nil {
log.ZError(ctx, "MsgToPushMQ", err, "key", key, "msg2mq", msg2mq)
return 0, 0, err
@@ -147,15 +206,30 @@ func (db *commonMsgDatabase) MsgToPushMQ(ctx context.Context, key, conversationI
return partition, offset, nil
}
-func (db *commonMsgDatabase) MsgToMongoMQ(ctx context.Context, key, conversationID string, messages []*sdkws.MsgData, lastSeq int64) error {
+func (db *commonMsgDatabase) MsgToMongoMQ(
+ ctx context.Context,
+ key, conversationID string,
+ messages []*sdkws.MsgData,
+ lastSeq int64,
+) error {
if len(messages) > 0 {
- _, _, err := db.producerToMongo.SendMessage(ctx, key, &pbMsg.MsgDataToMongoByMQ{LastSeq: lastSeq, ConversationID: conversationID, MsgData: messages})
+ _, _, err := db.producerToMongo.SendMessage(
+ ctx,
+ key,
+ &pbMsg.MsgDataToMongoByMQ{LastSeq: lastSeq, ConversationID: conversationID, MsgData: messages},
+ )
return err
}
return nil
}
-func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationID string, fields []any, key int8, firstSeq int64) error {
+func (db *commonMsgDatabase) BatchInsertBlock(
+ ctx context.Context,
+ conversationID string,
+ fields []any,
+ key int8,
+ firstSeq int64,
+) error {
if len(fields) == 0 {
return nil
}
@@ -256,7 +330,12 @@ func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationI
return nil
}
-func (db *commonMsgDatabase) BatchInsertChat2DB(ctx context.Context, conversationID string, msgList []*sdkws.MsgData, currentMaxSeq int64) error {
+func (db *commonMsgDatabase) BatchInsertChat2DB(
+ ctx context.Context,
+ conversationID string,
+ msgList []*sdkws.MsgData,
+ currentMaxSeq int64,
+) error {
if len(msgList) == 0 {
return errs.ErrArgs.Wrap("msgList is empty")
}
@@ -302,11 +381,21 @@ func (db *commonMsgDatabase) BatchInsertChat2DB(ctx context.Context, conversatio
return db.BatchInsertBlock(ctx, conversationID, msgs, updateKeyMsg, msgList[0].Seq)
}
-func (db *commonMsgDatabase) RevokeMsg(ctx context.Context, conversationID string, seq int64, revoke *unRelationTb.RevokeModel) error {
+func (db *commonMsgDatabase) RevokeMsg(
+ ctx context.Context,
+ conversationID string,
+ seq int64,
+ revoke *unRelationTb.RevokeModel,
+) error {
return db.BatchInsertBlock(ctx, conversationID, []any{revoke}, updateKeyRevoke, seq)
}
-func (db *commonMsgDatabase) MarkSingleChatMsgsAsRead(ctx context.Context, userID string, conversationID string, totalSeqs []int64) error {
+func (db *commonMsgDatabase) MarkSingleChatMsgsAsRead(
+ ctx context.Context,
+ userID string,
+ conversationID string,
+ totalSeqs []int64,
+) error {
for docID, seqs := range db.msg.GetDocIDSeqsMap(conversationID, totalSeqs) {
var indexes []int64
for _, seq := range seqs {
@@ -329,7 +418,11 @@ func (db *commonMsgDatabase) DelUserDeleteMsgsList(ctx context.Context, conversa
db.cache.DelUserDeleteMsgsList(ctx, conversationID, seqs)
}
-func (db *commonMsgDatabase) BatchInsertChat2Cache(ctx context.Context, conversationID string, msgs []*sdkws.MsgData) (seq int64, isNew bool, err error) {
+func (db *commonMsgDatabase) BatchInsertChat2Cache(
+ ctx context.Context,
+ conversationID string,
+ msgs []*sdkws.MsgData,
+) (seq int64, isNew bool, err error) {
currentMaxSeq, err := db.cache.GetMaxSeq(ctx, conversationID)
if err != nil && errs.Unwrap(err) != redis.Nil {
prome.Inc(prome.SeqGetFailedCounter)
@@ -376,7 +469,11 @@ func (db *commonMsgDatabase) BatchInsertChat2Cache(ctx context.Context, conversa
return lastMaxSeq, isNew, utils.Wrap(err, "")
}
-func (db *commonMsgDatabase) getMsgBySeqs(ctx context.Context, userID, conversationID string, seqs []int64) (totalMsgs []*sdkws.MsgData, err error) {
+func (db *commonMsgDatabase) getMsgBySeqs(
+ ctx context.Context,
+ userID, conversationID string,
+ seqs []int64,
+) (totalMsgs []*sdkws.MsgData, err error) {
for docID, seqs := range db.msg.GetDocIDSeqsMap(conversationID, seqs) {
//log.ZDebug(ctx, "getMsgBySeqs", "docID", docID, "seqs", seqs)
msgs, err := db.findMsgInfoBySeq(ctx, userID, docID, seqs)
@@ -390,7 +487,8 @@ func (db *commonMsgDatabase) getMsgBySeqs(ctx context.Context, userID, conversat
return totalMsgs, nil
}
-// func (db *commonMsgDatabase) refetchDelSeqsMsgs(ctx context.Context, conversationID string, delNums, rangeBegin, begin int64) (seqMsgs []*unRelationTb.MsgDataModel, err error) {
+// func (db *commonMsgDatabase) refetchDelSeqsMsgs(ctx context.Context, conversationID string, delNums, rangeBegin,
+// begin int64) (seqMsgs []*unRelationTb.MsgDataModel, err error) {
// var reFetchSeqs []int64
// if delNums > 0 {
// newBeginSeq := rangeBegin - delNums
@@ -428,7 +526,11 @@ func (db *commonMsgDatabase) getMsgBySeqs(ctx context.Context, userID, conversat
// return seqMsgs, nil
// }
-func (db *commonMsgDatabase) findMsgInfoBySeq(ctx context.Context, userID, docID string, seqs []int64) (totalMsgs []*unRelationTb.MsgInfoModel, err error) {
+func (db *commonMsgDatabase) findMsgInfoBySeq(
+ ctx context.Context,
+ userID, docID string,
+ seqs []int64,
+) (totalMsgs []*unRelationTb.MsgInfoModel, err error) {
msgs, err := db.msgDocDatabase.GetMsgBySeqIndexIn1Doc(ctx, userID, docID, seqs)
for _, msg := range msgs {
if msg.IsRead {
@@ -438,8 +540,25 @@ func (db *commonMsgDatabase) findMsgInfoBySeq(ctx context.Context, userID, docID
return msgs, err
}
-func (db *commonMsgDatabase) getMsgBySeqsRange(ctx context.Context, userID string, conversationID string, allSeqs []int64, begin, end int64) (seqMsgs []*sdkws.MsgData, err error) {
- log.ZDebug(ctx, "getMsgBySeqsRange", "conversationID", conversationID, "allSeqs", allSeqs, "begin", begin, "end", end)
+func (db *commonMsgDatabase) getMsgBySeqsRange(
+ ctx context.Context,
+ userID string,
+ conversationID string,
+ allSeqs []int64,
+ begin, end int64,
+) (seqMsgs []*sdkws.MsgData, err error) {
+ log.ZDebug(
+ ctx,
+ "getMsgBySeqsRange",
+ "conversationID",
+ conversationID,
+ "allSeqs",
+ allSeqs,
+ "begin",
+ begin,
+ "end",
+ end,
+ )
for docID, seqs := range db.msg.GetDocIDSeqsMap(conversationID, allSeqs) {
log.ZDebug(ctx, "getMsgBySeqsRange", "docID", docID, "seqs", seqs)
msgs, err := db.findMsgInfoBySeq(ctx, userID, docID, seqs)
@@ -456,7 +575,12 @@ func (db *commonMsgDatabase) getMsgBySeqsRange(ctx context.Context, userID strin
return seqMsgs, nil
}
-func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID string, conversationID string, begin, end, num, userMaxSeq int64) (int64, int64, []*sdkws.MsgData, error) {
+func (db *commonMsgDatabase) GetMsgBySeqsRange(
+ ctx context.Context,
+ userID string,
+ conversationID string,
+ begin, end, num, userMaxSeq int64,
+) (int64, int64, []*sdkws.MsgData, error) {
userMinSeq, err := db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
if err != nil && errs.Unwrap(err) != redis.Nil {
return 0, 0, nil, err
@@ -476,7 +600,18 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
if err != nil && errs.Unwrap(err) != redis.Nil {
return 0, 0, nil, err
}
- log.ZDebug(ctx, "GetMsgBySeqsRange", "userMinSeq", userMinSeq, "conMinSeq", minSeq, "conMaxSeq", maxSeq, "userMaxSeq", userMaxSeq)
+ log.ZDebug(
+ ctx,
+ "GetMsgBySeqsRange",
+ "userMinSeq",
+ userMinSeq,
+ "conMinSeq",
+ minSeq,
+ "conMaxSeq",
+ maxSeq,
+ "userMaxSeq",
+ userMaxSeq,
+ )
if userMaxSeq != 0 {
if userMaxSeq < maxSeq {
maxSeq = userMaxSeq
@@ -526,7 +661,18 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
cacheDelNum += 1
}
}
- log.ZDebug(ctx, "get delSeqs from redis", "delSeqs", delSeqs, "userID", userID, "conversationID", conversationID, "cacheDelNum", cacheDelNum)
+ log.ZDebug(
+ ctx,
+ "get delSeqs from redis",
+ "delSeqs",
+ delSeqs,
+ "userID",
+ userID,
+ "conversationID",
+ conversationID,
+ "cacheDelNum",
+ cacheDelNum,
+ )
var reGetSeqsCache []int64
for i := 1; i <= cacheDelNum; {
newSeq := newBegin - int64(i)
@@ -546,7 +692,15 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
if err != nil {
if err != redis.Nil {
prome.Add(prome.MsgPullFromRedisFailedCounter, len(failedSeqs2))
- log.ZError(ctx, "get message from redis exception", err, "conversationID", conversationID, "seqs", reGetSeqsCache)
+ log.ZError(
+ ctx,
+ "get message from redis exception",
+ err,
+ "conversationID",
+ conversationID,
+ "seqs",
+ reGetSeqsCache,
+ )
}
}
failedSeqs = append(failedSeqs, failedSeqs2...)
@@ -572,7 +726,12 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
return minSeq, maxSeq, successMsgs, nil
}
-func (db *commonMsgDatabase) GetMsgBySeqs(ctx context.Context, userID string, conversationID string, seqs []int64) (int64, int64, []*sdkws.MsgData, error) {
+func (db *commonMsgDatabase) GetMsgBySeqs(
+ ctx context.Context,
+ userID string,
+ conversationID string,
+ seqs []int64,
+) (int64, int64, []*sdkws.MsgData, error) {
userMinSeq, err := db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
if err != nil && errs.Unwrap(err) != redis.Nil {
return 0, 0, nil, err
@@ -598,10 +757,33 @@ func (db *commonMsgDatabase) GetMsgBySeqs(ctx context.Context, userID string, co
if err != nil {
if err != redis.Nil {
prome.Add(prome.MsgPullFromRedisFailedCounter, len(failedSeqs))
- log.ZError(ctx, "get message from redis exception", err, "failedSeqs", failedSeqs, "conversationID", conversationID)
+ log.ZError(
+ ctx,
+ "get message from redis exception",
+ err,
+ "failedSeqs",
+ failedSeqs,
+ "conversationID",
+ conversationID,
+ )
}
}
- log.ZInfo(ctx, "db.cache.GetMessagesBySeq", "userID", userID, "conversationID", conversationID, "seqs", seqs, "successMsgs", len(successMsgs), "failedSeqs", failedSeqs, "conversationID", conversationID)
+ log.ZInfo(
+ ctx,
+ "db.cache.GetMessagesBySeq",
+ "userID",
+ userID,
+ "conversationID",
+ conversationID,
+ "seqs",
+ seqs,
+ "successMsgs",
+ len(successMsgs),
+ "failedSeqs",
+ failedSeqs,
+ "conversationID",
+ conversationID,
+ )
prome.Add(prome.MsgPullFromRedisSuccessCounter, len(successMsgs))
if len(failedSeqs) > 0 {
mongoMsgs, err := db.getMsgBySeqs(ctx, userID, conversationID, failedSeqs)
@@ -615,7 +797,11 @@ func (db *commonMsgDatabase) GetMsgBySeqs(ctx context.Context, userID string, co
return minSeq, maxSeq, successMsgs, nil
}
-func (db *commonMsgDatabase) DeleteConversationMsgsAndSetMinSeq(ctx context.Context, conversationID string, remainTime int64) error {
+func (db *commonMsgDatabase) DeleteConversationMsgsAndSetMinSeq(
+ ctx context.Context,
+ conversationID string,
+ remainTime int64,
+) error {
var delStruct delMsgRecursionStruct
var skip int64
minSeq, err := db.deleteMsgRecursion(ctx, conversationID, skip, &delStruct, remainTime)
@@ -649,13 +835,26 @@ func (d *delMsgRecursionStruct) getSetMinSeq() int64 {
// seq 70
// set minSeq 21
// recursion 删除list并且返回设置的最小seq
-func (db *commonMsgDatabase) deleteMsgRecursion(ctx context.Context, conversationID string, index int64, delStruct *delMsgRecursionStruct, remainTime int64) (int64, error) {
+func (db *commonMsgDatabase) deleteMsgRecursion(
+ ctx context.Context,
+ conversationID string,
+ index int64,
+ delStruct *delMsgRecursionStruct,
+ remainTime int64,
+) (int64, error) {
// find from oldest list
msgDocModel, err := db.msgDocDatabase.GetMsgDocModelByIndex(ctx, conversationID, index, 1)
if err != nil || msgDocModel.DocID == "" {
if err != nil {
if err == unrelation.ErrMsgListNotExist {
- log.ZDebug(ctx, "deleteMsgRecursion ErrMsgListNotExist", "conversationID", conversationID, "index:", index)
+ log.ZDebug(
+ ctx,
+ "deleteMsgRecursion ErrMsgListNotExist",
+ "conversationID",
+ conversationID,
+ "index:",
+ index,
+ )
} else {
log.ZError(ctx, "deleteMsgRecursion GetUserMsgListByIndex failed", err, "conversationID", conversationID, "index", index)
}
@@ -667,11 +866,23 @@ func (db *commonMsgDatabase) deleteMsgRecursion(ctx context.Context, conversatio
}
return delStruct.getSetMinSeq() + 1, nil
}
- log.ZDebug(ctx, "doc info", "conversationID", conversationID, "index", index, "docID", msgDocModel.DocID, "len", len(msgDocModel.Msg))
+ log.ZDebug(
+ ctx,
+ "doc info",
+ "conversationID",
+ conversationID,
+ "index",
+ index,
+ "docID",
+ msgDocModel.DocID,
+ "len",
+ len(msgDocModel.Msg),
+ )
if int64(len(msgDocModel.Msg)) > db.msg.GetSingleGocMsgNum() {
log.ZWarn(ctx, "msgs too large", nil, "lenth", len(msgDocModel.Msg), "docID:", msgDocModel.DocID)
}
- if msgDocModel.IsFull() && msgDocModel.Msg[len(msgDocModel.Msg)-1].Msg.SendTime+(remainTime*1000) < utils.GetCurrentTimestampByMill() {
+ if msgDocModel.IsFull() &&
+ msgDocModel.Msg[len(msgDocModel.Msg)-1].Msg.SendTime+(remainTime*1000) < utils.GetCurrentTimestampByMill() {
log.ZDebug(ctx, "doc is full and all msg is expired", "docID", msgDocModel.DocID)
delStruct.delDocIDs = append(delStruct.delDocIDs, msgDocModel.DocID)
delStruct.minSeq = msgDocModel.Msg[len(msgDocModel.Msg)-1].Msg.Seq
@@ -708,7 +919,11 @@ func (db *commonMsgDatabase) deleteMsgRecursion(ctx context.Context, conversatio
return seq, err
}
-func (db *commonMsgDatabase) DeleteMsgsPhysicalBySeqs(ctx context.Context, conversationID string, allSeqs []int64) error {
+func (db *commonMsgDatabase) DeleteMsgsPhysicalBySeqs(
+ ctx context.Context,
+ conversationID string,
+ allSeqs []int64,
+) error {
if err := db.cache.DeleteMessages(ctx, conversationID, allSeqs); err != nil {
return err
}
@@ -724,7 +939,12 @@ func (db *commonMsgDatabase) DeleteMsgsPhysicalBySeqs(ctx context.Context, conve
return nil
}
-func (db *commonMsgDatabase) DeleteUserMsgsBySeqs(ctx context.Context, userID string, conversationID string, seqs []int64) error {
+func (db *commonMsgDatabase) DeleteUserMsgsBySeqs(
+ ctx context.Context,
+ userID string,
+ conversationID string,
+ seqs []int64,
+) error {
cachedMsgs, _, err := db.cache.GetMessagesBySeq(ctx, conversationID, seqs)
if err != nil && errs.Unwrap(err) != redis.Nil {
log.ZWarn(ctx, "DeleteUserMsgsBySeqs", err, "conversationID", conversationID, "seqs", seqs)
@@ -793,31 +1013,70 @@ func (db *commonMsgDatabase) GetMinSeqs(ctx context.Context, conversationIDs []s
func (db *commonMsgDatabase) GetMinSeq(ctx context.Context, conversationID string) (int64, error) {
return db.cache.GetMinSeq(ctx, conversationID)
}
-func (db *commonMsgDatabase) GetConversationUserMinSeq(ctx context.Context, conversationID string, userID string) (int64, error) {
+
+func (db *commonMsgDatabase) GetConversationUserMinSeq(
+ ctx context.Context,
+ conversationID string,
+ userID string,
+) (int64, error) {
return db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
}
-func (db *commonMsgDatabase) GetConversationUserMinSeqs(ctx context.Context, conversationID string, userIDs []string) (map[string]int64, error) {
+
+func (db *commonMsgDatabase) GetConversationUserMinSeqs(
+ ctx context.Context,
+ conversationID string,
+ userIDs []string,
+) (map[string]int64, error) {
return db.cache.GetConversationUserMinSeqs(ctx, conversationID, userIDs)
}
-func (db *commonMsgDatabase) SetConversationUserMinSeq(ctx context.Context, conversationID string, userID string, minSeq int64) error {
+
+func (db *commonMsgDatabase) SetConversationUserMinSeq(
+ ctx context.Context,
+ conversationID string,
+ userID string,
+ minSeq int64,
+) error {
return db.cache.SetConversationUserMinSeq(ctx, conversationID, userID, minSeq)
}
-func (db *commonMsgDatabase) SetConversationUserMinSeqs(ctx context.Context, conversationID string, seqs map[string]int64) (err error) {
+
+func (db *commonMsgDatabase) SetConversationUserMinSeqs(
+ ctx context.Context,
+ conversationID string,
+ seqs map[string]int64,
+) (err error) {
return db.cache.SetConversationUserMinSeqs(ctx, conversationID, seqs)
}
-func (db *commonMsgDatabase) SetUserConversationsMinSeqs(ctx context.Context, userID string, seqs map[string]int64) error {
+func (db *commonMsgDatabase) SetUserConversationsMinSeqs(
+ ctx context.Context,
+ userID string,
+ seqs map[string]int64,
+) error {
return db.cache.SetUserConversationsMinSeqs(ctx, userID, seqs)
}
-func (db *commonMsgDatabase) UserSetHasReadSeqs(ctx context.Context, userID string, hasReadSeqs map[string]int64) error {
+func (db *commonMsgDatabase) UserSetHasReadSeqs(
+ ctx context.Context,
+ userID string,
+ hasReadSeqs map[string]int64,
+) error {
return db.cache.UserSetHasReadSeqs(ctx, userID, hasReadSeqs)
}
-func (db *commonMsgDatabase) SetHasReadSeq(ctx context.Context, userID string, conversationID string, hasReadSeq int64) error {
+func (db *commonMsgDatabase) SetHasReadSeq(
+ ctx context.Context,
+ userID string,
+ conversationID string,
+ hasReadSeq int64,
+) error {
return db.cache.SetHasReadSeq(ctx, userID, conversationID, hasReadSeq)
}
-func (db *commonMsgDatabase) GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error) {
+
+func (db *commonMsgDatabase) GetHasReadSeqs(
+ ctx context.Context,
+ userID string,
+ conversationIDs []string,
+) (map[string]int64, error) {
return db.cache.GetHasReadSeqs(ctx, userID, conversationIDs)
}
@@ -833,7 +1092,10 @@ func (db *commonMsgDatabase) GetSendMsgStatus(ctx context.Context, id string) (i
return db.cache.GetSendMsgStatus(ctx, id)
}
-func (db *commonMsgDatabase) GetConversationMinMaxSeqInMongoAndCache(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error) {
+func (db *commonMsgDatabase) GetConversationMinMaxSeqInMongoAndCache(
+ ctx context.Context,
+ conversationID string,
+) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error) {
minSeqMongo, maxSeqMongo, err = db.GetMinMaxSeqMongo(ctx, conversationID)
if err != nil {
return
@@ -849,11 +1111,17 @@ func (db *commonMsgDatabase) GetConversationMinMaxSeqInMongoAndCache(ctx context
return
}
-func (db *commonMsgDatabase) GetMongoMaxAndMinSeq(ctx context.Context, conversationID string) (maxSeq, minSeq int64, err error) {
+func (db *commonMsgDatabase) GetMongoMaxAndMinSeq(
+ ctx context.Context,
+ conversationID string,
+) (maxSeq, minSeq int64, err error) {
return db.GetMinMaxSeqMongo(ctx, conversationID)
}
-func (db *commonMsgDatabase) GetMinMaxSeqMongo(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo int64, err error) {
+func (db *commonMsgDatabase) GetMinMaxSeqMongo(
+ ctx context.Context,
+ conversationID string,
+) (minSeqMongo, maxSeqMongo int64, err error) {
oldestMsgMongo, err := db.msgDocDatabase.GetOldestMsg(ctx, conversationID)
if err != nil {
return
@@ -867,35 +1135,83 @@ func (db *commonMsgDatabase) GetMinMaxSeqMongo(ctx context.Context, conversation
return
}
-func (db *commonMsgDatabase) JudgeMessageReactionExist(ctx context.Context, clientMsgID string, sessionType int32) (bool, error) {
+func (db *commonMsgDatabase) JudgeMessageReactionExist(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+) (bool, error) {
return db.cache.JudgeMessageReactionExist(ctx, clientMsgID, sessionType)
}
-func (db *commonMsgDatabase) SetMessageTypeKeyValue(ctx context.Context, clientMsgID string, sessionType int32, typeKey, value string) error {
+func (db *commonMsgDatabase) SetMessageTypeKeyValue(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+ typeKey, value string,
+) error {
return db.cache.SetMessageTypeKeyValue(ctx, clientMsgID, sessionType, typeKey, value)
}
-func (db *commonMsgDatabase) SetMessageReactionExpire(ctx context.Context, clientMsgID string, sessionType int32, expiration time.Duration) (bool, error) {
+func (db *commonMsgDatabase) SetMessageReactionExpire(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+ expiration time.Duration,
+) (bool, error) {
return db.cache.SetMessageReactionExpire(ctx, clientMsgID, sessionType, expiration)
}
-func (db *commonMsgDatabase) GetMessageTypeKeyValue(ctx context.Context, clientMsgID string, sessionType int32, typeKey string) (string, error) {
+func (db *commonMsgDatabase) GetMessageTypeKeyValue(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+ typeKey string,
+) (string, error) {
return db.cache.GetMessageTypeKeyValue(ctx, clientMsgID, sessionType, typeKey)
}
-func (db *commonMsgDatabase) GetOneMessageAllReactionList(ctx context.Context, clientMsgID string, sessionType int32) (map[string]string, error) {
+func (db *commonMsgDatabase) GetOneMessageAllReactionList(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+) (map[string]string, error) {
return db.cache.GetOneMessageAllReactionList(ctx, clientMsgID, sessionType)
}
-func (db *commonMsgDatabase) DeleteOneMessageKey(ctx context.Context, clientMsgID string, sessionType int32, subKey string) error {
+func (db *commonMsgDatabase) DeleteOneMessageKey(
+ ctx context.Context,
+ clientMsgID string,
+ sessionType int32,
+ subKey string,
+) error {
return db.cache.DeleteOneMessageKey(ctx, clientMsgID, sessionType, subKey)
}
-func (db *commonMsgDatabase) InsertOrUpdateReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensions map[string]*sdkws.KeyValue) error {
- return db.extendMsgDatabase.InsertOrUpdateReactionExtendMsgSet(ctx, conversationID, sessionType, clientMsgID, msgFirstModifyTime, db.extendMsgSetModel.Pb2Model(reactionExtensions))
+func (db *commonMsgDatabase) InsertOrUpdateReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensions map[string]*sdkws.KeyValue,
+) error {
+ return db.extendMsgDatabase.InsertOrUpdateReactionExtendMsgSet(
+ ctx,
+ conversationID,
+ sessionType,
+ clientMsgID,
+ msgFirstModifyTime,
+ db.extendMsgSetModel.Pb2Model(reactionExtensions),
+ )
}
-func (db *commonMsgDatabase) GetExtendMsg(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, maxMsgUpdateTime int64) (*pbMsg.ExtendMsg, error) {
+func (db *commonMsgDatabase) GetExtendMsg(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ maxMsgUpdateTime int64,
+) (*pbMsg.ExtendMsg, error) {
extendMsgSet, err := db.extendMsgDatabase.GetExtendMsgSet(ctx, conversationID, sessionType, maxMsgUpdateTime)
if err != nil {
return nil, err
@@ -923,6 +1239,20 @@ func (db *commonMsgDatabase) GetExtendMsg(ctx context.Context, conversationID st
}, nil
}
-func (db *commonMsgDatabase) DeleteReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensions map[string]*sdkws.KeyValue) error {
- return db.extendMsgDatabase.DeleteReactionExtendMsgSet(ctx, conversationID, sessionType, clientMsgID, msgFirstModifyTime, db.extendMsgSetModel.Pb2Model(reactionExtensions))
+func (db *commonMsgDatabase) DeleteReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensions map[string]*sdkws.KeyValue,
+) error {
+ return db.extendMsgDatabase.DeleteReactionExtendMsgSet(
+ ctx,
+ conversationID,
+ sessionType,
+ clientMsgID,
+ msgFirstModifyTime,
+ db.extendMsgSetModel.Pb2Model(reactionExtensions),
+ )
}
diff --git a/pkg/common/db/controller/msg_test.go b/pkg/common/db/controller/msg_test.go
index 8310d9d6a..6771bdab4 100644
--- a/pkg/common/db/controller/msg_test.go
+++ b/pkg/common/db/controller/msg_test.go
@@ -11,10 +11,11 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
+ "go.mongodb.org/mongo-driver/bson"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
- "go.mongodb.org/mongo-driver/bson"
)
func Test_BatchInsertChat2DB(t *testing.T) {
@@ -193,7 +194,9 @@ func Test_FindBySeq(t *testing.T) {
}
db := GetDB()
ctx := context.Background()
- fmt.Println(db.msgDocDatabase.(*unrelation.MsgMongoDriver).GetMsgBySeqIndexIn1Doc(ctx, "100", "si_100_101:0", []int64{1}))
+ fmt.Println(
+ db.msgDocDatabase.(*unrelation.MsgMongoDriver).GetMsgBySeqIndexIn1Doc(ctx, "100", "si_100_101:0", []int64{1}),
+ )
//res, err := db.msgDocDatabase.GetMsgBySeqIndexIn1Doc(ctx, "123456", "test:0", []int64{1, 2, 3})
//if err != nil {
// t.Fatal(err)
diff --git a/pkg/common/db/controller/storage.go b/pkg/common/db/controller/storage.go
index 6531c5127..22b2274f3 100644
--- a/pkg/common/db/controller/storage.go
+++ b/pkg/common/db/controller/storage.go
@@ -15,13 +15,14 @@ import (
"strconv"
"time"
+ "github.com/google/uuid"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/obj"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/google/uuid"
)
const (
@@ -40,7 +41,13 @@ type S3Database interface {
CleanExpirationObject(ctx context.Context, t time.Time)
}
-func NewS3Database(obj obj.Interface, hash relation.ObjectHashModelInterface, info relation.ObjectInfoModelInterface, put relation.ObjectPutModelInterface, url *url.URL) S3Database {
+func NewS3Database(
+ obj obj.Interface,
+ hash relation.ObjectHashModelInterface,
+ info relation.ObjectInfoModelInterface,
+ put relation.ObjectPutModelInterface,
+ url *url.URL,
+) S3Database {
return &s3Database{
url: url,
obj: obj,
@@ -207,7 +214,12 @@ func (c *s3Database) ApplyPut(ctx context.Context, req *third.ApplyPutReq) (*thi
}
t := md5.Sum(urlsJsonData)
put.PutURLsHash = hex.EncodeToString(t[:])
- _, err = c.obj.PutObject(ctx, &obj.BucketObject{Bucket: c.obj.TempBucket(), Name: path.Join(put.Path, urlsName)}, bytes.NewReader(urlsJsonData), int64(len(urlsJsonData)))
+ _, err = c.obj.PutObject(
+ ctx,
+ &obj.BucketObject{Bucket: c.obj.TempBucket(), Name: path.Join(put.Path, urlsName)},
+ bytes.NewReader(urlsJsonData),
+ int64(len(urlsJsonData)),
+ )
if err != nil {
return nil, err
}
@@ -228,7 +240,10 @@ func (c *s3Database) GetPut(ctx context.Context, req *third.GetPutReq) (*third.G
if err != nil {
return nil, err
}
- reader, err := c.obj.GetObject(ctx, &obj.BucketObject{Bucket: c.obj.TempBucket(), Name: path.Join(up.Path, urlsName)})
+ reader, err := c.obj.GetObject(
+ ctx,
+ &obj.BucketObject{Bucket: c.obj.TempBucket(), Name: path.Join(up.Path, urlsName)},
+ )
if err != nil {
return nil, err
}
diff --git a/pkg/common/db/controller/third.go b/pkg/common/db/controller/third.go
index 20c8a9102..276084920 100644
--- a/pkg/common/db/controller/third.go
+++ b/pkg/common/db/controller/third.go
@@ -19,7 +19,13 @@ func NewThirdDatabase(cache cache.MsgModel) ThirdDatabase {
return &thirdDatabase{cache: cache}
}
-func (t *thirdDatabase) FcmUpdateToken(ctx context.Context, account string, platformID int, fcmToken string, expireTime int64) error {
+func (t *thirdDatabase) FcmUpdateToken(
+ ctx context.Context,
+ account string,
+ platformID int,
+ fcmToken string,
+ expireTime int64,
+) error {
return t.cache.SetFcmToken(ctx, account, platformID, fcmToken, expireTime)
}
diff --git a/pkg/common/db/controller/user.go b/pkg/common/db/controller/user.go
index d1346d311..9a2e01b47 100644
--- a/pkg/common/db/controller/user.go
+++ b/pkg/common/db/controller/user.go
@@ -114,7 +114,10 @@ func (u *userDatabase) UpdateByMap(ctx context.Context, userID string, args map[
}
// 获取,如果没找到,不返回错误
-func (u *userDatabase) Page(ctx context.Context, pageNumber, showNumber int32) (users []*relation.UserModel, count int64, err error) {
+func (u *userDatabase) Page(
+ ctx context.Context,
+ pageNumber, showNumber int32,
+) (users []*relation.UserModel, count int64, err error) {
return u.userDB.Page(ctx, pageNumber, showNumber)
}
@@ -138,6 +141,10 @@ func (u *userDatabase) CountTotal(ctx context.Context) (count int64, err error)
return u.userDB.CountTotal(ctx)
}
-func (u *userDatabase) CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error) {
+func (u *userDatabase) CountRangeEverydayTotal(
+ ctx context.Context,
+ start time.Time,
+ end time.Time,
+) (map[string]int64, error) {
return u.userDB.CountRangeEverydayTotal(ctx, start, end)
}
diff --git a/pkg/common/db/obj/minio.go b/pkg/common/db/obj/minio.go
index 488775f27..2b39fff8b 100644
--- a/pkg/common/db/obj/minio.go
+++ b/pkg/common/db/obj/minio.go
@@ -9,11 +9,12 @@ import (
"net/url"
"time"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/minio/minio-go/v7/pkg/s3utils"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
func NewMinioInterface() (Interface, error) {
@@ -94,7 +95,13 @@ func (m *minioImpl) DataBucket() string {
return m.dataBucket
}
-func (m *minioImpl) PresignedGetURL(ctx context.Context, bucket string, name string, expires time.Duration, opt *HeaderOption) (string, error) {
+func (m *minioImpl) PresignedGetURL(
+ ctx context.Context,
+ bucket string,
+ name string,
+ expires time.Duration,
+ opt *HeaderOption,
+) (string, error) {
var reqParams url.Values
if opt != nil {
reqParams = make(url.Values)
@@ -204,7 +211,12 @@ func (m *minioImpl) IsNotFound(err error) bool {
}
}
-func (m *minioImpl) PutObject(ctx context.Context, info *BucketObject, reader io.Reader, size int64) (*ObjectInfo, error) {
+func (m *minioImpl) PutObject(
+ ctx context.Context,
+ info *BucketObject,
+ reader io.Reader,
+ size int64,
+) (*ObjectInfo, error) {
update, err := m.client.PutObject(ctx, info.Bucket, info.Name, reader, size, minio.PutObjectOptions{})
if err != nil {
return nil, err
diff --git a/pkg/common/db/obj/obj.go b/pkg/common/db/obj/obj.go
index e32c2479b..00c8b86b1 100644
--- a/pkg/common/db/obj/obj.go
+++ b/pkg/common/db/obj/obj.go
@@ -68,7 +68,13 @@ type Interface interface {
// DataBucket 永久存储的桶名
DataBucket() string
// PresignedGetURL 通过桶名和对象名返回URL
- PresignedGetURL(ctx context.Context, bucket string, name string, expires time.Duration, opt *HeaderOption) (string, error)
+ PresignedGetURL(
+ ctx context.Context,
+ bucket string,
+ name string,
+ expires time.Duration,
+ opt *HeaderOption,
+ ) (string, error)
// PresignedPutURL 申请上传,返回PUT的上传地址
PresignedPutURL(ctx context.Context, args *ApplyPutArgs) (string, error)
// GetObjectInfo 获取对象信息
diff --git a/pkg/common/db/ormutil/utils.go b/pkg/common/db/ormutil/utils.go
index 9c4e19a5b..c92b091ef 100644
--- a/pkg/common/db/ormutil/utils.go
+++ b/pkg/common/db/ormutil/utils.go
@@ -4,8 +4,9 @@ import (
"fmt"
"strings"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"gorm.io/gorm"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
)
func GormPage[E any](db *gorm.DB, pageNumber, showNumber int32) (uint32, []*E, error) {
diff --git a/pkg/common/db/relation/black_model.go b/pkg/common/db/relation/black_model.go
index 2faadda0c..736d9ed01 100644
--- a/pkg/common/db/relation/black_model.go
+++ b/pkg/common/db/relation/black_model.go
@@ -5,9 +5,10 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/ormutil"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
type BlackGorm struct {
@@ -26,37 +27,64 @@ func (b *BlackGorm) Delete(ctx context.Context, blacks []*relation.BlackModel) (
return utils.Wrap(b.db(ctx).Delete(blacks).Error, "")
}
-func (b *BlackGorm) UpdateByMap(ctx context.Context, ownerUserID, blockUserID string, args map[string]interface{}) (err error) {
- return utils.Wrap(b.db(ctx).Where("block_user_id = ? and block_user_id = ?", ownerUserID, blockUserID).Updates(args).Error, "")
+func (b *BlackGorm) UpdateByMap(
+ ctx context.Context,
+ ownerUserID, blockUserID string,
+ args map[string]interface{},
+) (err error) {
+ return utils.Wrap(
+ b.db(ctx).Where("block_user_id = ? and block_user_id = ?", ownerUserID, blockUserID).Updates(args).Error,
+ "",
+ )
}
func (b *BlackGorm) Update(ctx context.Context, blacks []*relation.BlackModel) (err error) {
return utils.Wrap(b.db(ctx).Updates(&blacks).Error, "")
}
-func (b *BlackGorm) Find(ctx context.Context, blacks []*relation.BlackModel) (blackList []*relation.BlackModel, err error) {
+func (b *BlackGorm) Find(
+ ctx context.Context,
+ blacks []*relation.BlackModel,
+) (blackList []*relation.BlackModel, err error) {
var where [][]interface{}
for _, black := range blacks {
where = append(where, []interface{}{black.OwnerUserID, black.BlockUserID})
}
- return blackList, utils.Wrap(b.db(ctx).Where("(owner_user_id, block_user_id) in ?", where).Find(&blackList).Error, "")
+ return blackList, utils.Wrap(
+ b.db(ctx).Where("(owner_user_id, block_user_id) in ?", where).Find(&blackList).Error,
+ "",
+ )
}
func (b *BlackGorm) Take(ctx context.Context, ownerUserID, blockUserID string) (black *relation.BlackModel, err error) {
black = &relation.BlackModel{}
- return black, utils.Wrap(b.db(ctx).Where("owner_user_id = ? and block_user_id = ?", ownerUserID, blockUserID).Take(black).Error, "")
+ return black, utils.Wrap(
+ b.db(ctx).Where("owner_user_id = ? and block_user_id = ?", ownerUserID, blockUserID).Take(black).Error,
+ "",
+ )
}
-func (b *BlackGorm) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.BlackModel, total int64, err error) {
+func (b *BlackGorm) FindOwnerBlacks(
+ ctx context.Context,
+ ownerUserID string,
+ pageNumber, showNumber int32,
+) (blacks []*relation.BlackModel, total int64, err error) {
err = b.db(ctx).Count(&total).Error
if err != nil {
return nil, 0, utils.Wrap(err, "")
}
- totalUint32, blacks, err := ormutil.GormPage[relation.BlackModel](b.db(ctx).Where("owner_user_id = ?", ownerUserID), pageNumber, showNumber)
+ totalUint32, blacks, err := ormutil.GormPage[relation.BlackModel](
+ b.db(ctx).Where("owner_user_id = ?", ownerUserID),
+ pageNumber,
+ showNumber,
+ )
total = int64(totalUint32)
return
}
func (b *BlackGorm) FindBlackUserIDs(ctx context.Context, ownerUserID string) (blackUserIDs []string, err error) {
- return blackUserIDs, utils.Wrap(b.db(ctx).Where("owner_user_id = ?", ownerUserID).Pluck("block_user_id", &blackUserIDs).Error, "")
+ return blackUserIDs, utils.Wrap(
+ b.db(ctx).Where("owner_user_id = ?", ownerUserID).Pluck("block_user_id", &blackUserIDs).Error,
+ "",
+ )
}
diff --git a/pkg/common/db/relation/chat_log_model.go b/pkg/common/db/relation/chat_log_model.go
index f164b146b..ef6dd2a8a 100644
--- a/pkg/common/db/relation/chat_log_model.go
+++ b/pkg/common/db/relation/chat_log_model.go
@@ -3,15 +3,16 @@ package relation
import (
"fmt"
+ "github.com/golang/protobuf/jsonpb"
+ "github.com/jinzhu/copier"
+ "google.golang.org/protobuf/proto"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/golang/protobuf/jsonpb"
- "github.com/jinzhu/copier"
- "google.golang.org/protobuf/proto"
- "gorm.io/gorm"
)
type ChatLogGorm struct {
@@ -48,7 +49,11 @@ func (c *ChatLogGorm) Create(msg *pbMsg.MsgDataToMQ) error {
return c.DB.Create(chatLog).Error
}
-func (c *ChatLogGorm) GetChatLog(chatLog *relation.ChatLogModel, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relation.ChatLogModel, error) {
+func (c *ChatLogGorm) GetChatLog(
+ chatLog *relation.ChatLogModel,
+ pageNumber, showNumber int32,
+ contentTypeList []int32,
+) (int64, []relation.ChatLogModel, error) {
mdb := c.DB.Model(chatLog)
if chatLog.SendTime.Unix() > 0 {
mdb = mdb.Where("send_time > ? and send_time < ?", chatLog.SendTime, chatLog.SendTime.AddDate(0, 0, 1))
diff --git a/pkg/common/db/relation/conversation_model.go b/pkg/common/db/relation/conversation_model.go
index f8522506a..cd67ad165 100644
--- a/pkg/common/db/relation/conversation_model.go
+++ b/pkg/common/db/relation/conversation_model.go
@@ -3,10 +3,11 @@ package relation
import (
"context"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
type ConversationGorm struct {
@@ -29,61 +30,160 @@ func (c *ConversationGorm) Delete(ctx context.Context, groupIDs []string) (err e
return utils.Wrap(c.db(ctx).Where("group_id in (?)", groupIDs).Delete(&relation.ConversationModel{}).Error, "")
}
-func (c *ConversationGorm) UpdateByMap(ctx context.Context, userIDList []string, conversationID string, args map[string]interface{}) (rows int64, err error) {
+func (c *ConversationGorm) UpdateByMap(
+ ctx context.Context,
+ userIDList []string,
+ conversationID string,
+ args map[string]interface{},
+) (rows int64, err error) {
result := c.db(ctx).Where("owner_user_id IN (?) and conversation_id=?", userIDList, conversationID).Updates(args)
return result.RowsAffected, utils.Wrap(result.Error, "")
}
func (c *ConversationGorm) Update(ctx context.Context, conversation *relation.ConversationModel) (err error) {
- return utils.Wrap(c.db(ctx).Where("owner_user_id = ? and conversation_id = ?", conversation.OwnerUserID, conversation.ConversationID).Updates(conversation).Error, "")
-}
-
-func (c *ConversationGorm) Find(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []*relation.ConversationModel, err error) {
- err = utils.Wrap(c.db(ctx).Where("owner_user_id=? and conversation_id IN (?)", ownerUserID, conversationIDs).Find(&conversations).Error, "")
+ return utils.Wrap(
+ c.db(ctx).
+ Where("owner_user_id = ? and conversation_id = ?", conversation.OwnerUserID, conversation.ConversationID).
+ Updates(conversation).
+ Error,
+ "",
+ )
+}
+
+func (c *ConversationGorm) Find(
+ ctx context.Context,
+ ownerUserID string,
+ conversationIDs []string,
+) (conversations []*relation.ConversationModel, err error) {
+ err = utils.Wrap(
+ c.db(ctx).
+ Where("owner_user_id=? and conversation_id IN (?)", ownerUserID, conversationIDs).
+ Find(&conversations).
+ Error,
+ "",
+ )
return conversations, err
}
-func (c *ConversationGorm) Take(ctx context.Context, userID, conversationID string) (conversation *relation.ConversationModel, err error) {
+func (c *ConversationGorm) Take(
+ ctx context.Context,
+ userID, conversationID string,
+) (conversation *relation.ConversationModel, err error) {
cc := &relation.ConversationModel{}
- return cc, utils.Wrap(c.db(ctx).Where("conversation_id = ? And owner_user_id = ?", conversationID, userID).Take(cc).Error, "")
-}
-
-func (c *ConversationGorm) FindUserID(ctx context.Context, userIDs []string, conversationIDs []string) (existUserID []string, err error) {
- return existUserID, utils.Wrap(c.db(ctx).Where(" owner_user_id IN (?) and conversation_id in (?)", userIDs, conversationIDs).Pluck("owner_user_id", &existUserID).Error, "")
-}
-
-func (c *ConversationGorm) FindConversationID(ctx context.Context, userID string, conversationIDList []string) (existConversationID []string, err error) {
- return existConversationID, utils.Wrap(c.db(ctx).Where(" conversation_id IN (?) and owner_user_id=?", conversationIDList, userID).Pluck("conversation_id", &existConversationID).Error, "")
-}
-
-func (c *ConversationGorm) FindUserIDAllConversationID(ctx context.Context, userID string) (conversationIDList []string, err error) {
- return conversationIDList, utils.Wrap(c.db(ctx).Where("owner_user_id=?", userID).Pluck("conversation_id", &conversationIDList).Error, "")
-}
-
-func (c *ConversationGorm) FindUserIDAllConversations(ctx context.Context, userID string) (conversations []*relation.ConversationModel, err error) {
+ return cc, utils.Wrap(
+ c.db(ctx).Where("conversation_id = ? And owner_user_id = ?", conversationID, userID).Take(cc).Error,
+ "",
+ )
+}
+
+func (c *ConversationGorm) FindUserID(
+ ctx context.Context,
+ userIDs []string,
+ conversationIDs []string,
+) (existUserID []string, err error) {
+ return existUserID, utils.Wrap(
+ c.db(ctx).
+ Where(" owner_user_id IN (?) and conversation_id in (?)", userIDs, conversationIDs).
+ Pluck("owner_user_id", &existUserID).
+ Error,
+ "",
+ )
+}
+
+func (c *ConversationGorm) FindConversationID(
+ ctx context.Context,
+ userID string,
+ conversationIDList []string,
+) (existConversationID []string, err error) {
+ return existConversationID, utils.Wrap(
+ c.db(ctx).
+ Where(" conversation_id IN (?) and owner_user_id=?", conversationIDList, userID).
+ Pluck("conversation_id", &existConversationID).
+ Error,
+ "",
+ )
+}
+
+func (c *ConversationGorm) FindUserIDAllConversationID(
+ ctx context.Context,
+ userID string,
+) (conversationIDList []string, err error) {
+ return conversationIDList, utils.Wrap(
+ c.db(ctx).Where("owner_user_id=?", userID).Pluck("conversation_id", &conversationIDList).Error,
+ "",
+ )
+}
+
+func (c *ConversationGorm) FindUserIDAllConversations(
+ ctx context.Context,
+ userID string,
+) (conversations []*relation.ConversationModel, err error) {
return conversations, utils.Wrap(c.db(ctx).Where("owner_user_id=?", userID).Find(&conversations).Error, "")
}
-func (c *ConversationGorm) FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) (userIDs []string, err error) {
- return userIDs, utils.Wrap(c.db(ctx).Where("group_id = ? and recv_msg_opt = ?", groupID, constant.ReceiveNotNotifyMessage).Pluck("user_id", &userIDs).Error, "")
-}
-
-func (c *ConversationGorm) FindSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) (userIDs []string, err error) {
- return userIDs, utils.Wrap(c.db(ctx).Where("group_id = ? and recv_msg_opt = ? and conversation_type = ?", groupID, constant.ReceiveNotNotifyMessage, constant.SuperGroupChatType).Pluck("user_id", &userIDs).Error, "")
-}
-
-func (c *ConversationGorm) GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error) {
+func (c *ConversationGorm) FindRecvMsgNotNotifyUserIDs(
+ ctx context.Context,
+ groupID string,
+) (userIDs []string, err error) {
+ return userIDs, utils.Wrap(
+ c.db(ctx).
+ Where("group_id = ? and recv_msg_opt = ?", groupID, constant.ReceiveNotNotifyMessage).
+ Pluck("user_id", &userIDs).
+ Error,
+ "",
+ )
+}
+
+func (c *ConversationGorm) FindSuperGroupRecvMsgNotNotifyUserIDs(
+ ctx context.Context,
+ groupID string,
+) (userIDs []string, err error) {
+ return userIDs, utils.Wrap(
+ c.db(ctx).
+ Where("group_id = ? and recv_msg_opt = ? and conversation_type = ?", groupID, constant.ReceiveNotNotifyMessage, constant.SuperGroupChatType).
+ Pluck("user_id", &userIDs).
+ Error,
+ "",
+ )
+}
+
+func (c *ConversationGorm) GetUserRecvMsgOpt(
+ ctx context.Context,
+ ownerUserID, conversationID string,
+) (opt int, err error) {
var conversation relation.ConversationModel
- return int(conversation.RecvMsgOpt), utils.Wrap(c.db(ctx).Where("conversation_id = ? And owner_user_id = ?", conversationID, ownerUserID).Select("recv_msg_opt").Find(&conversation).Error, "")
+ return int(
+ conversation.RecvMsgOpt,
+ ), utils.Wrap(
+ c.db(ctx).
+ Where("conversation_id = ? And owner_user_id = ?", conversationID, ownerUserID).
+ Select("recv_msg_opt").
+ Find(&conversation).
+ Error,
+ "",
+ )
}
func (c *ConversationGorm) GetAllConversationIDs(ctx context.Context) (conversationIDs []string, err error) {
- return conversationIDs, utils.Wrap(c.db(ctx).Distinct("conversation_id").Pluck("conversation_id", &conversationIDs).Error, "")
+ return conversationIDs, utils.Wrap(
+ c.db(ctx).Distinct("conversation_id").Pluck("conversation_id", &conversationIDs).Error,
+ "",
+ )
}
-func (c *ConversationGorm) GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (hasReadSeqs map[string]int64, err error) {
+func (c *ConversationGorm) GetUserAllHasReadSeqs(
+ ctx context.Context,
+ ownerUserID string,
+) (hasReadSeqs map[string]int64, err error) {
var conversations []*relation.ConversationModel
- err = utils.Wrap(c.db(ctx).Where("owner_user_id = ?", ownerUserID).Select("conversation_id", "has_read_seq").Find(&conversations).Error, "")
+ err = utils.Wrap(
+ c.db(ctx).
+ Where("owner_user_id = ?", ownerUserID).
+ Select("conversation_id", "has_read_seq").
+ Find(&conversations).
+ Error,
+ "",
+ )
hasReadSeqs = make(map[string]int64, len(conversations))
// for _, conversation := range conversations {
// hasReadSeqs[conversation.ConversationID] = conversation.HasReadSeq
@@ -91,6 +191,12 @@ func (c *ConversationGorm) GetUserAllHasReadSeqs(ctx context.Context, ownerUserI
return hasReadSeqs, err
}
-func (c *ConversationGorm) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) (conversations []*relation.ConversationModel, err error) {
- return conversations, utils.Wrap(c.db(ctx).Where("conversation_id IN (?)", conversationIDs).Find(&conversations).Error, "")
+func (c *ConversationGorm) GetConversationsByConversationID(
+ ctx context.Context,
+ conversationIDs []string,
+) (conversations []*relation.ConversationModel, err error) {
+ return conversations, utils.Wrap(
+ c.db(ctx).Where("conversation_id IN (?)", conversationIDs).Find(&conversations).Error,
+ "",
+ )
}
diff --git a/pkg/common/db/relation/friend_model.go b/pkg/common/db/relation/friend_model.go
index f06bd945a..3baaa50cc 100644
--- a/pkg/common/db/relation/friend_model.go
+++ b/pkg/common/db/relation/friend_model.go
@@ -3,9 +3,10 @@ package relation
import (
"context"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
type FriendGorm struct {
@@ -27,13 +28,27 @@ func (f *FriendGorm) Create(ctx context.Context, friends []*relation.FriendModel
// 删除ownerUserID指定的好友
func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error) {
- err = utils.Wrap(f.db(ctx).Where("owner_user_id = ? AND friend_user_id in ( ?)", ownerUserID, friendUserIDs).Delete(&relation.FriendModel{}).Error, "")
+ err = utils.Wrap(
+ f.db(ctx).
+ Where("owner_user_id = ? AND friend_user_id in ( ?)", ownerUserID, friendUserIDs).
+ Delete(&relation.FriendModel{}).
+ Error,
+ "",
+ )
return err
}
// 更新ownerUserID单个好友信息 更新零值
-func (f *FriendGorm) UpdateByMap(ctx context.Context, ownerUserID string, friendUserID string, args map[string]interface{}) (err error) {
- return utils.Wrap(f.db(ctx).Where("owner_user_id = ? AND friend_user_id = ? ", ownerUserID, friendUserID).Updates(args).Error, "")
+func (f *FriendGorm) UpdateByMap(
+ ctx context.Context,
+ ownerUserID string,
+ friendUserID string,
+ args map[string]interface{},
+) (err error) {
+ return utils.Wrap(
+ f.db(ctx).Where("owner_user_id = ? AND friend_user_id = ? ", ownerUserID, friendUserID).Updates(args).Error,
+ "",
+ )
}
// 更新好友信息的非零值
@@ -44,7 +59,13 @@ func (f *FriendGorm) Update(ctx context.Context, friends []*relation.FriendModel
// 更新好友备注(也支持零值 )
func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) {
if remark != "" {
- return utils.Wrap(f.db(ctx).Where("owner_user_id = ? and friend_user_id = ?", ownerUserID, friendUserID).Update("remark", remark).Error, "")
+ return utils.Wrap(
+ f.db(ctx).
+ Where("owner_user_id = ? and friend_user_id = ?", ownerUserID, friendUserID).
+ Update("remark", remark).
+ Error,
+ "",
+ )
}
m := make(map[string]interface{}, 1)
m["remark"] = ""
@@ -52,46 +73,106 @@ func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID
}
// 获取单个好友信息,如没找到 返回错误
-func (f *FriendGorm) Take(ctx context.Context, ownerUserID, friendUserID string) (friend *relation.FriendModel, err error) {
+func (f *FriendGorm) Take(
+ ctx context.Context,
+ ownerUserID, friendUserID string,
+) (friend *relation.FriendModel, err error) {
friend = &relation.FriendModel{}
- return friend, utils.Wrap(f.db(ctx).Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(friend).Error, "")
+ return friend, utils.Wrap(
+ f.db(ctx).Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(friend).Error,
+ "",
+ )
}
// 查找好友关系,如果是双向关系,则都返回
-func (f *FriendGorm) FindUserState(ctx context.Context, userID1, userID2 string) (friends []*relation.FriendModel, err error) {
- return friends, utils.Wrap(f.db(ctx).Where("(owner_user_id = ? and friend_user_id = ?) or (owner_user_id = ? and friend_user_id = ?)", userID1, userID2, userID2, userID1).Find(&friends).Error, "")
+func (f *FriendGorm) FindUserState(
+ ctx context.Context,
+ userID1, userID2 string,
+) (friends []*relation.FriendModel, err error) {
+ return friends, utils.Wrap(
+ f.db(ctx).
+ Where("(owner_user_id = ? and friend_user_id = ?) or (owner_user_id = ? and friend_user_id = ?)", userID1, userID2, userID2, userID1).
+ Find(&friends).
+ Error,
+ "",
+ )
}
// 获取 owner指定的好友列表 如果有friendUserIDs不存在,也不返回错误
-func (f *FriendGorm) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) {
- return friends, utils.Wrap(f.db(ctx).Where("owner_user_id = ? AND friend_user_id in (?)", ownerUserID, friendUserIDs).Find(&friends).Error, "")
+func (f *FriendGorm) FindFriends(
+ ctx context.Context,
+ ownerUserID string,
+ friendUserIDs []string,
+) (friends []*relation.FriendModel, err error) {
+ return friends, utils.Wrap(
+ f.db(ctx).Where("owner_user_id = ? AND friend_user_id in (?)", ownerUserID, friendUserIDs).Find(&friends).Error,
+ "",
+ )
}
// 获取哪些人添加了friendUserID 如果有ownerUserIDs不存在,也不返回错误
-func (f *FriendGorm) FindReversalFriends(ctx context.Context, friendUserID string, ownerUserIDs []string) (friends []*relation.FriendModel, err error) {
- return friends, utils.Wrap(f.db(ctx).Where("friend_user_id = ? AND owner_user_id in (?)", friendUserID, ownerUserIDs).Find(&friends).Error, "")
+func (f *FriendGorm) FindReversalFriends(
+ ctx context.Context,
+ friendUserID string,
+ ownerUserIDs []string,
+) (friends []*relation.FriendModel, err error) {
+ return friends, utils.Wrap(
+ f.db(ctx).Where("friend_user_id = ? AND owner_user_id in (?)", friendUserID, ownerUserIDs).Find(&friends).Error,
+ "",
+ )
}
// 获取ownerUserID好友列表 支持翻页
-func (f *FriendGorm) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
+func (f *FriendGorm) FindOwnerFriends(
+ ctx context.Context,
+ ownerUserID string,
+ pageNumber, showNumber int32,
+) (friends []*relation.FriendModel, total int64, err error) {
err = f.DB.Model(&relation.FriendModel{}).Where("owner_user_id = ? ", ownerUserID).Count(&total).Error
if err != nil {
return nil, 0, utils.Wrap(err, "")
}
- err = utils.Wrap(f.db(ctx).Where("owner_user_id = ? ", ownerUserID).Limit(int(showNumber)).Offset(int((pageNumber-1)*showNumber)).Find(&friends).Error, "")
+ err = utils.Wrap(
+ f.db(ctx).
+ Where("owner_user_id = ? ", ownerUserID).
+ Limit(int(showNumber)).
+ Offset(int((pageNumber-1)*showNumber)).
+ Find(&friends).
+ Error,
+ "",
+ )
return
}
// 获取哪些人添加了friendUserID 支持翻页
-func (f *FriendGorm) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
+func (f *FriendGorm) FindInWhoseFriends(
+ ctx context.Context,
+ friendUserID string,
+ pageNumber, showNumber int32,
+) (friends []*relation.FriendModel, total int64, err error) {
err = f.DB.Model(&relation.FriendModel{}).Where("friend_user_id = ? ", friendUserID).Count(&total).Error
if err != nil {
return nil, 0, utils.Wrap(err, "")
}
- err = utils.Wrap(f.db(ctx).Where("friend_user_id = ? ", friendUserID).Limit(int(showNumber)).Offset(int((pageNumber-1)*showNumber)).Find(&friends).Error, "")
+ err = utils.Wrap(
+ f.db(ctx).
+ Where("friend_user_id = ? ", friendUserID).
+ Limit(int(showNumber)).
+ Offset(int((pageNumber-1)*showNumber)).
+ Find(&friends).
+ Error,
+ "",
+ )
return
}
func (f *FriendGorm) FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error) {
- return friendUserIDs, utils.Wrap(f.db(ctx).Model(&relation.FriendModel{}).Where("owner_user_id = ? ", ownerUserID).Pluck("friend_user_id", &friendUserIDs).Error, "")
+ return friendUserIDs, utils.Wrap(
+ f.db(ctx).
+ Model(&relation.FriendModel{}).
+ Where("owner_user_id = ? ", ownerUserID).
+ Pluck("friend_user_id", &friendUserIDs).
+ Error,
+ "",
+ )
}
diff --git a/pkg/common/db/relation/friend_request_model.go b/pkg/common/db/relation/friend_request_model.go
index 956f733a7..1673d6dcf 100644
--- a/pkg/common/db/relation/friend_request_model.go
+++ b/pkg/common/db/relation/friend_request_model.go
@@ -3,9 +3,10 @@ package relation
import (
"context"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
type FriendRequestGorm struct {
@@ -27,48 +28,108 @@ func (f *FriendRequestGorm) Create(ctx context.Context, friendRequests []*relati
// 删除记录
func (f *FriendRequestGorm) Delete(ctx context.Context, fromUserID, toUserID string) (err error) {
- return utils.Wrap(f.db(ctx).Where("from_user_id = ? AND to_user_id = ?", fromUserID, toUserID).Delete(&relation.FriendRequestModel{}).Error, "")
+ return utils.Wrap(
+ f.db(ctx).
+ Where("from_user_id = ? AND to_user_id = ?", fromUserID, toUserID).
+ Delete(&relation.FriendRequestModel{}).
+ Error,
+ "",
+ )
}
// 更新零值
-func (f *FriendRequestGorm) UpdateByMap(ctx context.Context, fromUserID string, toUserID string, args map[string]interface{}) (err error) {
- return utils.Wrap(f.db(ctx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? AND to_user_id =?", fromUserID, toUserID).Updates(args).Error, "")
+func (f *FriendRequestGorm) UpdateByMap(
+ ctx context.Context,
+ fromUserID string,
+ toUserID string,
+ args map[string]interface{},
+) (err error) {
+ return utils.Wrap(
+ f.db(ctx).
+ Model(&relation.FriendRequestModel{}).
+ Where("from_user_id = ? AND to_user_id =?", fromUserID, toUserID).
+ Updates(args).
+ Error,
+ "",
+ )
}
// 更新记录 (非零值)
func (f *FriendRequestGorm) Update(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
- return utils.Wrap(f.db(ctx).Where("from_user_id = ? AND to_user_id =?", friendRequest.FromUserID, friendRequest.ToUserID).Updates(friendRequest).Error, "")
+ return utils.Wrap(
+ f.db(ctx).
+ Where("from_user_id = ? AND to_user_id =?", friendRequest.FromUserID, friendRequest.ToUserID).
+ Updates(friendRequest).
+ Error,
+ "",
+ )
}
// 获取来指定用户的好友申请 未找到 不返回错误
-func (f *FriendRequestGorm) Find(ctx context.Context, fromUserID, toUserID string) (friendRequest *relation.FriendRequestModel, err error) {
+func (f *FriendRequestGorm) Find(
+ ctx context.Context,
+ fromUserID, toUserID string,
+) (friendRequest *relation.FriendRequestModel, err error) {
friendRequest = &relation.FriendRequestModel{}
- err = utils.Wrap(f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Find(friendRequest).Error, "")
+ err = utils.Wrap(
+ f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Find(friendRequest).Error,
+ "",
+ )
return friendRequest, err
}
-func (f *FriendRequestGorm) Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *relation.FriendRequestModel, err error) {
+func (f *FriendRequestGorm) Take(
+ ctx context.Context,
+ fromUserID, toUserID string,
+) (friendRequest *relation.FriendRequestModel, err error) {
friendRequest = &relation.FriendRequestModel{}
- err = utils.Wrap(f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Take(friendRequest).Error, "")
+ err = utils.Wrap(
+ f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Take(friendRequest).Error,
+ "",
+ )
return friendRequest, err
}
// 获取toUserID收到的好友申请列表
-func (f *FriendRequestGorm) FindToUserID(ctx context.Context, toUserID string, pageNumber, showNumber int32) (friendRequests []*relation.FriendRequestModel, total int64, err error) {
+func (f *FriendRequestGorm) FindToUserID(
+ ctx context.Context,
+ toUserID string,
+ pageNumber, showNumber int32,
+) (friendRequests []*relation.FriendRequestModel, total int64, err error) {
err = f.db(ctx).Model(&relation.FriendRequestModel{}).Where("to_user_id = ? ", toUserID).Count(&total).Error
if err != nil {
return nil, 0, utils.Wrap(err, "")
}
- err = utils.Wrap(f.db(ctx).Where("to_user_id = ? ", toUserID).Limit(int(showNumber)).Offset(int(pageNumber-1)*int(showNumber)).Find(&friendRequests).Error, "")
+ err = utils.Wrap(
+ f.db(ctx).
+ Where("to_user_id = ? ", toUserID).
+ Limit(int(showNumber)).
+ Offset(int(pageNumber-1)*int(showNumber)).
+ Find(&friendRequests).
+ Error,
+ "",
+ )
return
}
// 获取fromUserID发出去的好友申请列表
-func (f *FriendRequestGorm) FindFromUserID(ctx context.Context, fromUserID string, pageNumber, showNumber int32) (friendRequests []*relation.FriendRequestModel, total int64, err error) {
+func (f *FriendRequestGorm) FindFromUserID(
+ ctx context.Context,
+ fromUserID string,
+ pageNumber, showNumber int32,
+) (friendRequests []*relation.FriendRequestModel, total int64, err error) {
err = f.db(ctx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? ", fromUserID).Count(&total).Error
if err != nil {
return nil, 0, utils.Wrap(err, "")
}
- err = utils.Wrap(f.db(ctx).Where("from_user_id = ? ", fromUserID).Limit(int(showNumber)).Offset(int(pageNumber-1)*int(showNumber)).Find(&friendRequests).Error, "")
+ err = utils.Wrap(
+ f.db(ctx).
+ Where("from_user_id = ? ", fromUserID).
+ Limit(int(showNumber)).
+ Offset(int(pageNumber-1)*int(showNumber)).
+ Find(&friendRequests).
+ Error,
+ "",
+ )
return
}
diff --git a/pkg/common/db/relation/group_member_model.go b/pkg/common/db/relation/group_member_model.go
index 5cbbdf2b3..78ab4357c 100644
--- a/pkg/common/db/relation/group_member_model.go
+++ b/pkg/common/db/relation/group_member_model.go
@@ -3,11 +3,12 @@ package relation
import (
"context"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/ormutil"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
var _ relation.GroupMemberModelInterface = (*GroupMemberGorm)(nil)
@@ -29,7 +30,10 @@ func (g *GroupMemberGorm) Create(ctx context.Context, groupMemberList []*relatio
}
func (g *GroupMemberGorm) Delete(ctx context.Context, groupID string, userIDs []string) (err error) {
- return utils.Wrap(g.db(ctx).Where("group_id = ? and user_id in (?)", groupID, userIDs).Delete(&relation.GroupMemberModel{}).Error, "")
+ return utils.Wrap(
+ g.db(ctx).Where("group_id = ? and user_id in (?)", groupID, userIDs).Delete(&relation.GroupMemberModel{}).Error,
+ "",
+ )
}
func (g *GroupMemberGorm) DeleteGroup(ctx context.Context, groupIDs []string) (err error) {
@@ -40,14 +44,24 @@ func (g *GroupMemberGorm) Update(ctx context.Context, groupID string, userID str
return utils.Wrap(g.db(ctx).Where("group_id = ? and user_id = ?", groupID, userID).Updates(data).Error, "")
}
-func (g *GroupMemberGorm) UpdateRoleLevel(ctx context.Context, groupID string, userID string, roleLevel int32) (rowsAffected int64, err error) {
+func (g *GroupMemberGorm) UpdateRoleLevel(
+ ctx context.Context,
+ groupID string,
+ userID string,
+ roleLevel int32,
+) (rowsAffected int64, err error) {
db := g.db(ctx).Where("group_id = ? and user_id = ?", groupID, userID).Updates(map[string]any{
"role_level": roleLevel,
})
return db.RowsAffected, utils.Wrap(db.Error, "")
}
-func (g *GroupMemberGorm) Find(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) (groupMembers []*relation.GroupMemberModel, err error) {
+func (g *GroupMemberGorm) Find(
+ ctx context.Context,
+ groupIDs []string,
+ userIDs []string,
+ roleLevels []int32,
+) (groupMembers []*relation.GroupMemberModel, err error) {
db := g.db(ctx)
if len(groupIDs) > 0 {
db = db.Where("group_id in (?)", groupIDs)
@@ -61,17 +75,37 @@ func (g *GroupMemberGorm) Find(ctx context.Context, groupIDs []string, userIDs [
return groupMembers, utils.Wrap(db.Find(&groupMembers).Error, "")
}
-func (g *GroupMemberGorm) Take(ctx context.Context, groupID string, userID string) (groupMember *relation.GroupMemberModel, err error) {
+func (g *GroupMemberGorm) Take(
+ ctx context.Context,
+ groupID string,
+ userID string,
+) (groupMember *relation.GroupMemberModel, err error) {
groupMember = &relation.GroupMemberModel{}
- return groupMember, utils.Wrap(g.db(ctx).Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error, "")
+ return groupMember, utils.Wrap(
+ g.db(ctx).Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error,
+ "",
+ )
}
-func (g *GroupMemberGorm) TakeOwner(ctx context.Context, groupID string) (groupMember *relation.GroupMemberModel, err error) {
+func (g *GroupMemberGorm) TakeOwner(
+ ctx context.Context,
+ groupID string,
+) (groupMember *relation.GroupMemberModel, err error) {
groupMember = &relation.GroupMemberModel{}
- return groupMember, utils.Wrap(g.db(ctx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error, "")
-}
-
-func (g *GroupMemberGorm) SearchMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (total uint32, groupList []*relation.GroupMemberModel, err error) {
+ return groupMember, utils.Wrap(
+ g.db(ctx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error,
+ "",
+ )
+}
+
+func (g *GroupMemberGorm) SearchMember(
+ ctx context.Context,
+ keyword string,
+ groupIDs []string,
+ userIDs []string,
+ roleLevels []int32,
+ pageNumber, showNumber int32,
+) (total uint32, groupList []*relation.GroupMemberModel, err error) {
db := g.db(ctx)
ormutil.GormIn(&db, "group_id", groupIDs)
ormutil.GormIn(&db, "user_id", userIDs)
@@ -79,11 +113,17 @@ func (g *GroupMemberGorm) SearchMember(ctx context.Context, keyword string, grou
return ormutil.GormSearch[relation.GroupMemberModel](db, []string{"nickname"}, keyword, pageNumber, showNumber)
}
-func (g *GroupMemberGorm) MapGroupMemberNum(ctx context.Context, groupIDs []string) (count map[string]uint32, err error) {
+func (g *GroupMemberGorm) MapGroupMemberNum(
+ ctx context.Context,
+ groupIDs []string,
+) (count map[string]uint32, err error) {
return ormutil.MapCount(g.db(ctx).Where("group_id in (?)", groupIDs), "group_id")
}
-func (g *GroupMemberGorm) FindJoinUserID(ctx context.Context, groupIDs []string) (groupUsers map[string][]string, err error) {
+func (g *GroupMemberGorm) FindJoinUserID(
+ ctx context.Context,
+ groupIDs []string,
+) (groupUsers map[string][]string, err error) {
var groupMembers []*relation.GroupMemberModel
if err := g.db(ctx).Select("group_id, user_id").Where("group_id in (?)", groupIDs).Find(&groupMembers).Error; err != nil {
return nil, utils.Wrap(err, "")
@@ -131,5 +171,12 @@ func (g *GroupMemberGorm) FindUsersJoinedGroupID(ctx context.Context, userIDs []
}
func (g *GroupMemberGorm) FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error) {
- return groupIDs, utils.Wrap(g.db(ctx).Model(&relation.GroupMemberModel{}).Where("user_id = ? and (role_level = ? or role_level = ?)", userID, constant.GroupOwner, constant.GroupAdmin).Pluck("group_id", &groupIDs).Error, "")
+ return groupIDs, utils.Wrap(
+ g.db(ctx).
+ Model(&relation.GroupMemberModel{}).
+ Where("user_id = ? and (role_level = ? or role_level = ?)", userID, constant.GroupOwner, constant.GroupAdmin).
+ Pluck("group_id", &groupIDs).
+ Error,
+ "",
+ )
}
diff --git a/pkg/common/db/relation/group_model.go b/pkg/common/db/relation/group_model.go
index dd9f59bea..fbcb5763b 100644
--- a/pkg/common/db/relation/group_model.go
+++ b/pkg/common/db/relation/group_model.go
@@ -3,10 +3,11 @@ package relation
import (
"context"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/ormutil"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
var _ relation.GroupModelInterface = (*GroupGorm)(nil)
@@ -32,7 +33,13 @@ func (g *GroupGorm) UpdateMap(ctx context.Context, groupID string, args map[stri
}
func (g *GroupGorm) UpdateStatus(ctx context.Context, groupID string, status int32) (err error) {
- return utils.Wrap(g.DB.Where("group_id = ?", groupID).Model(&relation.GroupModel{}).Updates(map[string]any{"status": status}).Error, "")
+ return utils.Wrap(
+ g.DB.Where("group_id = ?", groupID).
+ Model(&relation.GroupModel{}).
+ Updates(map[string]any{"status": status}).
+ Error,
+ "",
+ )
}
func (g *GroupGorm) Find(ctx context.Context, groupIDs []string) (groups []*relation.GroupModel, err error) {
@@ -44,10 +51,17 @@ func (g *GroupGorm) Take(ctx context.Context, groupID string) (group *relation.G
return group, utils.Wrap(g.DB.Where("group_id = ?", groupID).Take(group).Error, "")
}
-func (g *GroupGorm) Search(ctx context.Context, keyword string, pageNumber, showNumber int32) (total uint32, groups []*relation.GroupModel, err error) {
+func (g *GroupGorm) Search(
+ ctx context.Context,
+ keyword string,
+ pageNumber, showNumber int32,
+) (total uint32, groups []*relation.GroupModel, err error) {
return ormutil.GormSearch[relation.GroupModel](g.DB, []string{"name"}, keyword, pageNumber, showNumber)
}
func (g *GroupGorm) GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error) {
- return groupIDs, utils.Wrap(g.DB.Model(&relation.GroupModel{}).Where("group_type = ? ", groupType).Pluck("group_id", &groupIDs).Error, "")
+ return groupIDs, utils.Wrap(
+ g.DB.Model(&relation.GroupModel{}).Where("group_type = ? ", groupType).Pluck("group_id", &groupIDs).Error,
+ "",
+ )
}
diff --git a/pkg/common/db/relation/group_request_model.go b/pkg/common/db/relation/group_request_model.go
index 407c2b136..9d12005ae 100644
--- a/pkg/common/db/relation/group_request_model.go
+++ b/pkg/common/db/relation/group_request_model.go
@@ -5,9 +5,10 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/ormutil"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
type GroupRequestGorm struct {
@@ -29,25 +30,69 @@ func (g *GroupRequestGorm) Create(ctx context.Context, groupRequests []*relation
}
func (g *GroupRequestGorm) Delete(ctx context.Context, groupID string, userID string) (err error) {
- return utils.Wrap(g.DB.WithContext(ctx).Where("group_id = ? and user_id = ? ", groupID, userID).Delete(&relation.GroupRequestModel{}).Error, utils.GetSelfFuncName())
+ return utils.Wrap(
+ g.DB.WithContext(ctx).
+ Where("group_id = ? and user_id = ? ", groupID, userID).
+ Delete(&relation.GroupRequestModel{}).
+ Error,
+ utils.GetSelfFuncName(),
+ )
}
-func (g *GroupRequestGorm) UpdateHandler(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32) (err error) {
- return utils.Wrap(g.DB.WithContext(ctx).Model(&relation.GroupRequestModel{}).Where("group_id = ? and user_id = ? ", groupID, userID).Updates(map[string]any{
- "handle_msg": handledMsg,
- "handle_result": handleResult,
- }).Error, utils.GetSelfFuncName())
+func (g *GroupRequestGorm) UpdateHandler(
+ ctx context.Context,
+ groupID string,
+ userID string,
+ handledMsg string,
+ handleResult int32,
+) (err error) {
+ return utils.Wrap(
+ g.DB.WithContext(ctx).
+ Model(&relation.GroupRequestModel{}).
+ Where("group_id = ? and user_id = ? ", groupID, userID).
+ Updates(map[string]any{
+ "handle_msg": handledMsg,
+ "handle_result": handleResult,
+ }).
+ Error,
+ utils.GetSelfFuncName(),
+ )
}
-func (g *GroupRequestGorm) Take(ctx context.Context, groupID string, userID string) (groupRequest *relation.GroupRequestModel, err error) {
+func (g *GroupRequestGorm) Take(
+ ctx context.Context,
+ groupID string,
+ userID string,
+) (groupRequest *relation.GroupRequestModel, err error) {
groupRequest = &relation.GroupRequestModel{}
- return groupRequest, utils.Wrap(g.DB.WithContext(ctx).Where("group_id = ? and user_id = ? ", groupID, userID).Take(groupRequest).Error, utils.GetSelfFuncName())
+ return groupRequest, utils.Wrap(
+ g.DB.WithContext(ctx).Where("group_id = ? and user_id = ? ", groupID, userID).Take(groupRequest).Error,
+ utils.GetSelfFuncName(),
+ )
}
-func (g *GroupRequestGorm) Page(ctx context.Context, userID string, pageNumber, showNumber int32) (total uint32, groups []*relation.GroupRequestModel, err error) {
- return ormutil.GormSearch[relation.GroupRequestModel](g.DB.WithContext(ctx).Where("user_id = ?", userID), nil, "", pageNumber, showNumber)
+func (g *GroupRequestGorm) Page(
+ ctx context.Context,
+ userID string,
+ pageNumber, showNumber int32,
+) (total uint32, groups []*relation.GroupRequestModel, err error) {
+ return ormutil.GormSearch[relation.GroupRequestModel](
+ g.DB.WithContext(ctx).Where("user_id = ?", userID),
+ nil,
+ "",
+ pageNumber,
+ showNumber,
+ )
}
-func (g *GroupRequestGorm) PageGroup(ctx context.Context, groupIDs []string, pageNumber, showNumber int32) (total uint32, groups []*relation.GroupRequestModel, err error) {
- return ormutil.GormPage[relation.GroupRequestModel](g.DB.WithContext(ctx).Where("group_id in ?", groupIDs), pageNumber, showNumber)
+func (g *GroupRequestGorm) PageGroup(
+ ctx context.Context,
+ groupIDs []string,
+ pageNumber, showNumber int32,
+) (total uint32, groups []*relation.GroupRequestModel, err error) {
+ return ormutil.GormPage[relation.GroupRequestModel](
+ g.DB.WithContext(ctx).Where("group_id in ?", groupIDs),
+ pageNumber,
+ showNumber,
+ )
}
diff --git a/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go
index 432af214f..89ee8545e 100644
--- a/pkg/common/db/relation/mysql_init.go
+++ b/pkg/common/db/relation/mysql_init.go
@@ -4,12 +4,13 @@ import (
"fmt"
"time"
+ mysqlDriver "github.com/go-sql-driver/mysql"
+ "gorm.io/driver/mysql"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
- mysqlDriver "github.com/go-sql-driver/mysql"
- "gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
@@ -31,14 +32,26 @@ func newMysqlGormDB() (*gorm.DB, error) {
return nil, err
}
defer sqlDB.Close()
- sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s default charset utf8mb4 COLLATE utf8mb4_unicode_ci;", config.Config.Mysql.Database)
+ sql := fmt.Sprintf(
+ "CREATE DATABASE IF NOT EXISTS %s default charset utf8mb4 COLLATE utf8mb4_unicode_ci;",
+ config.Config.Mysql.Database,
+ )
err = db.Exec(sql).Error
if err != nil {
return nil, fmt.Errorf("init db %w", err)
}
- dsn = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
- config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address[0], config.Config.Mysql.Database)
- sqlLogger := log.NewSqlLogger(logger.LogLevel(config.Config.Mysql.LogLevel), true, time.Duration(config.Config.Mysql.SlowThreshold)*time.Millisecond)
+ dsn = fmt.Sprintf(
+ "%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
+ config.Config.Mysql.Username,
+ config.Config.Mysql.Password,
+ config.Config.Mysql.Address[0],
+ config.Config.Mysql.Database,
+ )
+ sqlLogger := log.NewSqlLogger(
+ logger.LogLevel(config.Config.Mysql.LogLevel),
+ true,
+ time.Duration(config.Config.Mysql.SlowThreshold)*time.Millisecond,
+ )
db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{
Logger: sqlLogger,
})
diff --git a/pkg/common/db/relation/object_hash_model.go b/pkg/common/db/relation/object_hash_model.go
index 275d09a4e..789929c5f 100644
--- a/pkg/common/db/relation/object_hash_model.go
+++ b/pkg/common/db/relation/object_hash_model.go
@@ -3,9 +3,10 @@ package relation
import (
"context"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
type ObjectHashGorm struct {
@@ -24,7 +25,11 @@ func (o *ObjectHashGorm) NewTx(tx any) relation.ObjectHashModelInterface {
}
}
-func (o *ObjectHashGorm) Take(ctx context.Context, hash string, engine string) (oh *relation.ObjectHashModel, err error) {
+func (o *ObjectHashGorm) Take(
+ ctx context.Context,
+ hash string,
+ engine string,
+) (oh *relation.ObjectHashModel, err error) {
oh = &relation.ObjectHashModel{}
return oh, utils.Wrap1(o.DB.Where("hash = ? and engine = ?", hash, engine).Take(oh).Error)
}
@@ -33,7 +38,11 @@ func (o *ObjectHashGorm) Create(ctx context.Context, h []*relation.ObjectHashMod
return utils.Wrap1(o.DB.Create(h).Error)
}
-func (o *ObjectHashGorm) DeleteNoCitation(ctx context.Context, engine string, num int) (list []*relation.ObjectHashModel, err error) {
+func (o *ObjectHashGorm) DeleteNoCitation(
+ ctx context.Context,
+ engine string,
+ num int,
+) (list []*relation.ObjectHashModel, err error) {
err = o.DB.Table(relation.ObjectHashModelTableName, "as h").Select("h.*").
Joins("LEFT JOIN "+relation.ObjectInfoModelTableName+" as i ON h.hash = i.hash").
Where("h.engine = ? AND i.hash IS NULL", engine).
diff --git a/pkg/common/db/relation/object_info_model.go b/pkg/common/db/relation/object_info_model.go
index f5b34755f..aa48ae491 100644
--- a/pkg/common/db/relation/object_info_model.go
+++ b/pkg/common/db/relation/object_info_model.go
@@ -4,10 +4,11 @@ import (
"context"
"time"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
type ObjectInfoGorm struct {
@@ -45,5 +46,10 @@ func (o *ObjectInfoGorm) Take(ctx context.Context, name string) (info *relation.
}
func (o *ObjectInfoGorm) DeleteExpiration(ctx context.Context, expiration time.Time) (err error) {
- return utils.Wrap1(o.DB.WithContext(ctx).Where("expiration_time IS NOT NULL AND expiration_time <= ?", expiration).Delete(&relation.ObjectInfoModel{}).Error)
+ return utils.Wrap1(
+ o.DB.WithContext(ctx).
+ Where("expiration_time IS NOT NULL AND expiration_time <= ?", expiration).
+ Delete(&relation.ObjectInfoModel{}).
+ Error,
+ )
}
diff --git a/pkg/common/db/relation/object_put_model.go b/pkg/common/db/relation/object_put_model.go
index 06a9883af..12808c215 100644
--- a/pkg/common/db/relation/object_put_model.go
+++ b/pkg/common/db/relation/object_put_model.go
@@ -4,9 +4,10 @@ import (
"context"
"time"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
type ObjectPutGorm struct {
@@ -38,7 +39,11 @@ func (o *ObjectPutGorm) SetCompleted(ctx context.Context, putID string) (err err
return utils.Wrap1(o.DB.Model(&relation.ObjectPutModel{}).Where("put_id = ?", putID).Update("complete", true).Error)
}
-func (o *ObjectPutGorm) FindExpirationPut(ctx context.Context, expirationTime time.Time, num int) (list []*relation.ObjectPutModel, err error) {
+func (o *ObjectPutGorm) FindExpirationPut(
+ ctx context.Context,
+ expirationTime time.Time,
+ num int,
+) (list []*relation.ObjectPutModel, err error) {
err = o.DB.Where("effective_time <= ?", expirationTime).Limit(num).Find(&list).Error
return list, utils.Wrap1(err)
}
diff --git a/pkg/common/db/relation/user_model.go b/pkg/common/db/relation/user_model.go
index 481393ac0..013666859 100644
--- a/pkg/common/db/relation/user_model.go
+++ b/pkg/common/db/relation/user_model.go
@@ -6,9 +6,10 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
+ "gorm.io/gorm"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "gorm.io/gorm"
)
type UserGorm struct {
@@ -48,12 +49,23 @@ func (u *UserGorm) Take(ctx context.Context, userID string) (user *relation.User
}
// 获取用户信息 不存在,不返回错误
-func (u *UserGorm) Page(ctx context.Context, pageNumber, showNumber int32) (users []*relation.UserModel, count int64, err error) {
+func (u *UserGorm) Page(
+ ctx context.Context,
+ pageNumber, showNumber int32,
+) (users []*relation.UserModel, count int64, err error) {
err = utils.Wrap(u.db(ctx).Count(&count).Error, "")
if err != nil {
return
}
- err = utils.Wrap(u.db(ctx).Limit(int(showNumber)).Offset(int((pageNumber-1)*showNumber)).Find(&users).Order("create_time DESC").Error, "")
+ err = utils.Wrap(
+ u.db(ctx).
+ Limit(int(showNumber)).
+ Offset(int((pageNumber-1)*showNumber)).
+ Find(&users).
+ Order("create_time DESC").
+ Error,
+ "",
+ )
return
}
@@ -73,12 +85,22 @@ func (u *UserGorm) CountTotal(ctx context.Context) (count int64, err error) {
return count, errs.Wrap(err)
}
-func (u *UserGorm) CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error) {
+func (u *UserGorm) CountRangeEverydayTotal(
+ ctx context.Context,
+ start time.Time,
+ end time.Time,
+) (map[string]int64, error) {
var res []struct {
Date time.Time `gorm:"column:date"`
Count int64 `gorm:"column:count"`
}
- err := u.db(ctx).Model(&relation.UserModel{}).Select("DATE(create_time) AS date, count(1) AS count").Where("create_time >= ? and create_time < ?", start, end).Group("date").Find(&res).Error
+ err := u.db(ctx).
+ Model(&relation.UserModel{}).
+ Select("DATE(create_time) AS date, count(1) AS count").
+ Where("create_time >= ? and create_time < ?", start, end).
+ Group("date").
+ Find(&res).
+ Error
if err != nil {
return nil, errs.Wrap(err)
}
diff --git a/pkg/common/db/table/relation/black.go b/pkg/common/db/table/relation/black.go
index fd25cff7f..bcfffc6db 100644
--- a/pkg/common/db/table/relation/black.go
+++ b/pkg/common/db/table/relation/black.go
@@ -29,6 +29,10 @@ type BlackModelInterface interface {
Update(ctx context.Context, blacks []*BlackModel) (err error)
Find(ctx context.Context, blacks []*BlackModel) (blackList []*BlackModel, err error)
Take(ctx context.Context, ownerUserID, blockUserID string) (black *BlackModel, err error)
- FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*BlackModel, total int64, err error)
+ FindOwnerBlacks(
+ ctx context.Context,
+ ownerUserID string,
+ pageNumber, showNumber int32,
+ ) (blacks []*BlackModel, total int64, err error)
FindBlackUserIDs(ctx context.Context, ownerUserID string) (blackUserIDs []string, err error)
}
diff --git a/pkg/common/db/table/relation/chatlog.go b/pkg/common/db/table/relation/chatlog.go
index 8f34f2854..f43d8a43a 100644
--- a/pkg/common/db/table/relation/chatlog.go
+++ b/pkg/common/db/table/relation/chatlog.go
@@ -11,21 +11,21 @@ const (
)
type ChatLogModel struct {
- ServerMsgID string `gorm:"column:server_msg_id;primary_key;type:char(64)" json:"serverMsgID"`
- ClientMsgID string `gorm:"column:client_msg_id;type:char(64)" json:"clientMsgID"`
- SendID string `gorm:"column:send_id;type:char(64);index:send_id,priority:2" json:"sendID"`
- RecvID string `gorm:"column:recv_id;type:char(64);index:recv_id,priority:2" json:"recvID"`
- SenderPlatformID int32 `gorm:"column:sender_platform_id" json:"senderPlatformID"`
- SenderNickname string `gorm:"column:sender_nick_name;type:varchar(255)" json:"senderNickname"`
- SenderFaceURL string `gorm:"column:sender_face_url;type:varchar(255);" json:"senderFaceURL"`
- SessionType int32 `gorm:"column:session_type;index:session_type,priority:2;index:session_type_alone" json:"sessionType"`
- MsgFrom int32 `gorm:"column:msg_from" json:"msgFrom"`
- ContentType int32 `gorm:"column:content_type;index:content_type,priority:2;index:content_type_alone" json:"contentType"`
- Content string `gorm:"column:content;type:varchar(3000)" json:"content"`
- Status int32 `gorm:"column:status" json:"status"`
+ ServerMsgID string `gorm:"column:server_msg_id;primary_key;type:char(64)" json:"serverMsgID"`
+ ClientMsgID string `gorm:"column:client_msg_id;type:char(64)" json:"clientMsgID"`
+ SendID string `gorm:"column:send_id;type:char(64);index:send_id,priority:2" json:"sendID"`
+ RecvID string `gorm:"column:recv_id;type:char(64);index:recv_id,priority:2" json:"recvID"`
+ SenderPlatformID int32 `gorm:"column:sender_platform_id" json:"senderPlatformID"`
+ SenderNickname string `gorm:"column:sender_nick_name;type:varchar(255)" json:"senderNickname"`
+ SenderFaceURL string `gorm:"column:sender_face_url;type:varchar(255);" json:"senderFaceURL"`
+ SessionType int32 `gorm:"column:session_type;index:session_type,priority:2;index:session_type_alone" json:"sessionType"`
+ MsgFrom int32 `gorm:"column:msg_from" json:"msgFrom"`
+ ContentType int32 `gorm:"column:content_type;index:content_type,priority:2;index:content_type_alone" json:"contentType"`
+ Content string `gorm:"column:content;type:varchar(3000)" json:"content"`
+ Status int32 `gorm:"column:status" json:"status"`
SendTime time.Time `gorm:"column:send_time;index:sendTime;index:content_type,priority:1;index:session_type,priority:1;index:recv_id,priority:1;index:send_id,priority:1" json:"sendTime"`
- CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
- Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
+ CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
+ Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
}
func (ChatLogModel) TableName() string {
diff --git a/pkg/common/db/table/relation/conversation.go b/pkg/common/db/table/relation/conversation.go
index ae009a1a1..f08ea90e3 100644
--- a/pkg/common/db/table/relation/conversation.go
+++ b/pkg/common/db/table/relation/conversation.go
@@ -7,20 +7,20 @@ const (
)
type ConversationModel struct {
- OwnerUserID string `gorm:"column:owner_user_id;primary_key;type:char(128)" json:"OwnerUserID"`
+ OwnerUserID string `gorm:"column:owner_user_id;primary_key;type:char(128)" json:"OwnerUserID"`
ConversationID string `gorm:"column:conversation_id;primary_key;type:char(128)" json:"conversationID"`
- ConversationType int32 `gorm:"column:conversation_type" json:"conversationType"`
- UserID string `gorm:"column:user_id;type:char(64)" json:"userID"`
- GroupID string `gorm:"column:group_id;type:char(128)" json:"groupID"`
- RecvMsgOpt int32 `gorm:"column:recv_msg_opt" json:"recvMsgOpt"`
- IsPinned bool `gorm:"column:is_pinned" json:"isPinned"`
- IsPrivateChat bool `gorm:"column:is_private_chat" json:"isPrivateChat"`
- BurnDuration int32 `gorm:"column:burn_duration;default:30" json:"burnDuration"`
- GroupAtType int32 `gorm:"column:group_at_type" json:"groupAtType"`
- AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
- Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
- MaxSeq int64 `gorm:"column:max_seq" json:"maxSeq"`
- MinSeq int64 `gorm:"column:min_seq" json:"minSeq"`
+ ConversationType int32 `gorm:"column:conversation_type" json:"conversationType"`
+ UserID string `gorm:"column:user_id;type:char(64)" json:"userID"`
+ GroupID string `gorm:"column:group_id;type:char(128)" json:"groupID"`
+ RecvMsgOpt int32 `gorm:"column:recv_msg_opt" json:"recvMsgOpt"`
+ IsPinned bool `gorm:"column:is_pinned" json:"isPinned"`
+ IsPrivateChat bool `gorm:"column:is_private_chat" json:"isPrivateChat"`
+ BurnDuration int32 `gorm:"column:burn_duration;default:30" json:"burnDuration"`
+ GroupAtType int32 `gorm:"column:group_at_type" json:"groupAtType"`
+ AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
+ Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
+ MaxSeq int64 `gorm:"column:max_seq" json:"maxSeq"`
+ MinSeq int64 `gorm:"column:min_seq" json:"minSeq"`
}
func (ConversationModel) TableName() string {
@@ -30,13 +30,26 @@ func (ConversationModel) TableName() string {
type ConversationModelInterface interface {
Create(ctx context.Context, conversations []*ConversationModel) (err error)
Delete(ctx context.Context, groupIDs []string) (err error)
- UpdateByMap(ctx context.Context, userIDs []string, conversationID string, args map[string]interface{}) (rows int64, err error)
+ UpdateByMap(
+ ctx context.Context,
+ userIDs []string,
+ conversationID string,
+ args map[string]interface{},
+ ) (rows int64, err error)
Update(ctx context.Context, conversation *ConversationModel) (err error)
- Find(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []*ConversationModel, err error)
+ Find(
+ ctx context.Context,
+ ownerUserID string,
+ conversationIDs []string,
+ ) (conversations []*ConversationModel, err error)
FindUserID(ctx context.Context, userIDs []string, conversationIDs []string) ([]string, error)
FindUserIDAllConversationID(ctx context.Context, userID string) ([]string, error)
Take(ctx context.Context, userID, conversationID string) (conversation *ConversationModel, err error)
- FindConversationID(ctx context.Context, userID string, conversationIDs []string) (existConversationID []string, err error)
+ FindConversationID(
+ ctx context.Context,
+ userID string,
+ conversationIDs []string,
+ ) (existConversationID []string, err error)
FindUserIDAllConversations(ctx context.Context, userID string) (conversations []*ConversationModel, err error)
FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error)
diff --git a/pkg/common/db/table/relation/friend.go b/pkg/common/db/table/relation/friend.go
index af85d55d8..43724141f 100644
--- a/pkg/common/db/table/relation/friend.go
+++ b/pkg/common/db/table/relation/friend.go
@@ -41,11 +41,23 @@ type FriendModelInterface interface {
// 获取 owner指定的好友列表 如果有friendUserIDs不存在,也不返回错误
FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*FriendModel, err error)
// 获取哪些人添加了friendUserID 如果有ownerUserIDs不存在,也不返回错误
- FindReversalFriends(ctx context.Context, friendUserID string, ownerUserIDs []string) (friends []*FriendModel, err error)
+ FindReversalFriends(
+ ctx context.Context,
+ friendUserID string,
+ ownerUserIDs []string,
+ ) (friends []*FriendModel, err error)
// 获取ownerUserID好友列表 支持翻页
- FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*FriendModel, total int64, err error)
+ FindOwnerFriends(
+ ctx context.Context,
+ ownerUserID string,
+ pageNumber, showNumber int32,
+ ) (friends []*FriendModel, total int64, err error)
// 获取哪些人添加了friendUserID 支持翻页
- FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*FriendModel, total int64, err error)
+ FindInWhoseFriends(
+ ctx context.Context,
+ friendUserID string,
+ pageNumber, showNumber int32,
+ ) (friends []*FriendModel, total int64, err error)
// 获取好友UserID列表
FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error)
NewTx(tx any) FriendModelInterface
diff --git a/pkg/common/db/table/relation/friend_request.go b/pkg/common/db/table/relation/friend_request.go
index b14ecb2c2..59160c819 100644
--- a/pkg/common/db/table/relation/friend_request.go
+++ b/pkg/common/db/table/relation/friend_request.go
@@ -36,9 +36,17 @@ type FriendRequestModelInterface interface {
Find(ctx context.Context, fromUserID, toUserID string) (friendRequest *FriendRequestModel, err error)
Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *FriendRequestModel, err error)
// 获取toUserID收到的好友申请列表
- FindToUserID(ctx context.Context, toUserID string, pageNumber, showNumber int32) (friendRequests []*FriendRequestModel, total int64, err error)
+ FindToUserID(
+ ctx context.Context,
+ toUserID string,
+ pageNumber, showNumber int32,
+ ) (friendRequests []*FriendRequestModel, total int64, err error)
// 获取fromUserID发出去的好友申请列表
- FindFromUserID(ctx context.Context, fromUserID string, pageNumber, showNumber int32) (friendRequests []*FriendRequestModel, total int64, err error)
+ FindFromUserID(
+ ctx context.Context,
+ fromUserID string,
+ pageNumber, showNumber int32,
+ ) (friendRequests []*FriendRequestModel, total int64, err error)
NewTx(tx any) FriendRequestModelInterface
}
diff --git a/pkg/common/db/table/relation/group.go b/pkg/common/db/table/relation/group.go
index c011699ae..70ccad9b4 100644
--- a/pkg/common/db/table/relation/group.go
+++ b/pkg/common/db/table/relation/group.go
@@ -10,19 +10,19 @@ const (
)
type GroupModel struct {
- GroupID string `gorm:"column:group_id;primary_key;size:64" json:"groupID" binding:"required"`
- GroupName string `gorm:"column:name;size:255" json:"groupName"`
- Notification string `gorm:"column:notification;size:255" json:"notification"`
- Introduction string `gorm:"column:introduction;size:255" json:"introduction"`
- FaceURL string `gorm:"column:face_url;size:255" json:"faceURL"`
+ GroupID string `gorm:"column:group_id;primary_key;size:64" json:"groupID" binding:"required"`
+ GroupName string `gorm:"column:name;size:255" json:"groupName"`
+ Notification string `gorm:"column:notification;size:255" json:"notification"`
+ Introduction string `gorm:"column:introduction;size:255" json:"introduction"`
+ FaceURL string `gorm:"column:face_url;size:255" json:"faceURL"`
CreateTime time.Time `gorm:"column:create_time;index:create_time;autoCreateTime"`
- Ex string `gorm:"column:ex" json:"ex;size:1024" json:"ex"`
+ Ex string `gorm:"column:ex" json:"ex;size:1024"`
Status int32 `gorm:"column:status"`
CreatorUserID string `gorm:"column:creator_user_id;size:64"`
GroupType int32 `gorm:"column:group_type"`
NeedVerification int32 `gorm:"column:need_verification"`
- LookMemberInfo int32 `gorm:"column:look_member_info" json:"lookMemberInfo"`
- ApplyMemberFriend int32 `gorm:"column:apply_member_friend" json:"applyMemberFriend"`
+ LookMemberInfo int32 `gorm:"column:look_member_info" json:"lookMemberInfo"`
+ ApplyMemberFriend int32 `gorm:"column:apply_member_friend" json:"applyMemberFriend"`
NotificationUpdateTime time.Time `gorm:"column:notification_update_time"`
NotificationUserID string `gorm:"column:notification_user_id;size:64"`
}
@@ -38,6 +38,10 @@ type GroupModelInterface interface {
UpdateStatus(ctx context.Context, groupID string, status int32) (err error)
Find(ctx context.Context, groupIDs []string) (groups []*GroupModel, err error)
Take(ctx context.Context, groupID string) (group *GroupModel, err error)
- Search(ctx context.Context, keyword string, pageNumber, showNumber int32) (total uint32, groups []*GroupModel, err error)
+ Search(
+ ctx context.Context,
+ keyword string,
+ pageNumber, showNumber int32,
+ ) (total uint32, groups []*GroupModel, err error)
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
}
diff --git a/pkg/common/db/table/relation/group_member.go b/pkg/common/db/table/relation/group_member.go
index b430575fe..6640a9402 100644
--- a/pkg/common/db/table/relation/group_member.go
+++ b/pkg/common/db/table/relation/group_member.go
@@ -34,11 +34,23 @@ type GroupMemberModelInterface interface {
DeleteGroup(ctx context.Context, groupIDs []string) (err error)
Update(ctx context.Context, groupID string, userID string, data map[string]any) (err error)
UpdateRoleLevel(ctx context.Context, groupID string, userID string, roleLevel int32) (rowsAffected int64, err error)
- Find(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) (groupMembers []*GroupMemberModel, err error)
+ Find(
+ ctx context.Context,
+ groupIDs []string,
+ userIDs []string,
+ roleLevels []int32,
+ ) (groupMembers []*GroupMemberModel, err error)
FindMemberUserID(ctx context.Context, groupID string) (userIDs []string, err error)
Take(ctx context.Context, groupID string, userID string) (groupMember *GroupMemberModel, err error)
TakeOwner(ctx context.Context, groupID string) (groupMember *GroupMemberModel, err error)
- SearchMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (total uint32, groupList []*GroupMemberModel, err error)
+ SearchMember(
+ ctx context.Context,
+ keyword string,
+ groupIDs []string,
+ userIDs []string,
+ roleLevels []int32,
+ pageNumber, showNumber int32,
+ ) (total uint32, groupList []*GroupMemberModel, err error)
MapGroupMemberNum(ctx context.Context, groupIDs []string) (count map[string]uint32, err error)
FindJoinUserID(ctx context.Context, groupIDs []string) (groupUsers map[string][]string, err error)
FindUserJoinedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
diff --git a/pkg/common/db/table/relation/group_request.go b/pkg/common/db/table/relation/group_request.go
index 62b2a1081..816d3ad35 100644
--- a/pkg/common/db/table/relation/group_request.go
+++ b/pkg/common/db/table/relation/group_request.go
@@ -33,6 +33,14 @@ type GroupRequestModelInterface interface {
Delete(ctx context.Context, groupID string, userID string) (err error)
UpdateHandler(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32) (err error)
Take(ctx context.Context, groupID string, userID string) (groupRequest *GroupRequestModel, err error)
- Page(ctx context.Context, userID string, pageNumber, showNumber int32) (total uint32, groups []*GroupRequestModel, err error)
- PageGroup(ctx context.Context, groupIDs []string, pageNumber, showNumber int32) (total uint32, groups []*GroupRequestModel, err error)
+ Page(
+ ctx context.Context,
+ userID string,
+ pageNumber, showNumber int32,
+ ) (total uint32, groups []*GroupRequestModel, err error)
+ PageGroup(
+ ctx context.Context,
+ groupIDs []string,
+ pageNumber, showNumber int32,
+ ) (total uint32, groups []*GroupRequestModel, err error)
}
diff --git a/pkg/common/db/table/relation/utils.go b/pkg/common/db/table/relation/utils.go
index 329c4648b..d3bd8d312 100644
--- a/pkg/common/db/table/relation/utils.go
+++ b/pkg/common/db/table/relation/utils.go
@@ -1,8 +1,9 @@
package relation
import (
- "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"gorm.io/gorm"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
type BatchUpdateGroupMember struct {
diff --git a/pkg/common/db/table/unrelation/extend_msg_set.go b/pkg/common/db/table/unrelation/extend_msg_set.go
index fcf33af9f..76588e679 100644
--- a/pkg/common/db/table/unrelation/extend_msg_set.go
+++ b/pkg/common/db/table/unrelation/extend_msg_set.go
@@ -15,36 +15,65 @@ const (
)
type ExtendMsgSetModel struct {
- ConversationID string `bson:"source_id" json:"conversationID"`
- SessionType int32 `bson:"session_type" json:"sessionType"`
- ExtendMsgs map[string]ExtendMsgModel `bson:"extend_msgs" json:"extendMsgs"`
- ExtendMsgNum int32 `bson:"extend_msg_num" json:"extendMsgNum"`
- CreateTime int64 `bson:"create_time" json:"createTime"` // this block's create time
+ ConversationID string `bson:"source_id" json:"conversationID"`
+ SessionType int32 `bson:"session_type" json:"sessionType"`
+ ExtendMsgs map[string]ExtendMsgModel `bson:"extend_msgs" json:"extendMsgs"`
+ ExtendMsgNum int32 `bson:"extend_msg_num" json:"extendMsgNum"`
+ CreateTime int64 `bson:"create_time" json:"createTime"` // this block's create time
MaxMsgUpdateTime int64 `bson:"max_msg_update_time" json:"maxMsgUpdateTime"` // index find msg
}
type KeyValueModel struct {
- TypeKey string `bson:"type_key" json:"typeKey"`
- Value string `bson:"value" json:"value"`
+ TypeKey string `bson:"type_key" json:"typeKey"`
+ Value string `bson:"value" json:"value"`
LatestUpdateTime int64 `bson:"latest_update_time" json:"latestUpdateTime"`
}
type ExtendMsgModel struct {
ReactionExtensionList map[string]KeyValueModel `bson:"reaction_extension_list" json:"reactionExtensionList"`
- ClientMsgID string `bson:"client_msg_id" json:"clientMsgID"`
- MsgFirstModifyTime int64 `bson:"msg_first_modify_time" json:"msgFirstModifyTime"` // this extendMsg create time
- AttachedInfo string `bson:"attached_info" json:"attachedInfo"`
- Ex string `bson:"ex" json:"ex"`
+ ClientMsgID string `bson:"client_msg_id" json:"clientMsgID"`
+ MsgFirstModifyTime int64 `bson:"msg_first_modify_time" json:"msgFirstModifyTime"` // this extendMsg create time
+ AttachedInfo string `bson:"attached_info" json:"attachedInfo"`
+ Ex string `bson:"ex" json:"ex"`
}
type ExtendMsgSetModelInterface interface {
CreateExtendMsgSet(ctx context.Context, set *ExtendMsgSetModel) error
- GetAllExtendMsgSet(ctx context.Context, conversationID string, opts *GetAllExtendMsgSetOpts) (sets []*ExtendMsgSetModel, err error)
- GetExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, maxMsgUpdateTime int64) (*ExtendMsgSetModel, error)
+ GetAllExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ opts *GetAllExtendMsgSetOpts,
+ ) (sets []*ExtendMsgSetModel, err error)
+ GetExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ maxMsgUpdateTime int64,
+ ) (*ExtendMsgSetModel, error)
InsertExtendMsg(ctx context.Context, conversationID string, sessionType int32, msg *ExtendMsgModel) error
- InsertOrUpdateReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*KeyValueModel) error
- DeleteReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*KeyValueModel) error
- TakeExtendMsg(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, maxMsgUpdateTime int64) (extendMsg *ExtendMsgModel, err error)
+ InsertOrUpdateReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensionList map[string]*KeyValueModel,
+ ) error
+ DeleteReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensionList map[string]*KeyValueModel,
+ ) error
+ TakeExtendMsg(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ maxMsgUpdateTime int64,
+ ) (extendMsg *ExtendMsgModel, err error)
}
func (ExtendMsgSetModel) TableName() string {
diff --git a/pkg/common/db/table/unrelation/msg.go b/pkg/common/db/table/unrelation/msg.go
index 44fde3318..950a60689 100644
--- a/pkg/common/db/table/unrelation/msg.go
+++ b/pkg/common/db/table/unrelation/msg.go
@@ -4,8 +4,9 @@ import (
"context"
"strconv"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"go.mongodb.org/mongo-driver/mongo"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
)
const (
diff --git a/pkg/common/db/table/unrelation/super_group.go b/pkg/common/db/table/unrelation/super_group.go
index 0c3a0c51c..4875c490d 100644
--- a/pkg/common/db/table/unrelation/super_group.go
+++ b/pkg/common/db/table/unrelation/super_group.go
@@ -10,7 +10,7 @@ const (
)
type SuperGroupModel struct {
- GroupID string `bson:"group_id" json:"groupID"`
+ GroupID string `bson:"group_id" json:"groupID"`
MemberIDs []string `bson:"member_id_list" json:"memberIDList"`
}
@@ -19,7 +19,7 @@ func (SuperGroupModel) TableName() string {
}
type UserToSuperGroupModel struct {
- UserID string `bson:"user_id" json:"userID"`
+ UserID string `bson:"user_id" json:"userID"`
GroupIDs []string `bson:"group_id_list" json:"groupIDList"`
}
diff --git a/pkg/common/db/tx/mongo.go b/pkg/common/db/tx/mongo.go
index c8c4817ac..cd7d24607 100644
--- a/pkg/common/db/tx/mongo.go
+++ b/pkg/common/db/tx/mongo.go
@@ -3,8 +3,9 @@ package tx
import (
"context"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"go.mongodb.org/mongo-driver/mongo"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
func NewMongo(client *mongo.Client) CtxTx {
diff --git a/pkg/common/db/unrelation/extend_msg.go b/pkg/common/db/unrelation/extend_msg.go
index ab2b8b2b3..2abe1d0bd 100644
--- a/pkg/common/db/unrelation/extend_msg.go
+++ b/pkg/common/db/unrelation/extend_msg.go
@@ -5,12 +5,13 @@ import (
"errors"
"fmt"
- unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"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"
+
+ unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
type ExtendMsgSetMongoDriver struct {
@@ -27,7 +28,11 @@ func (e *ExtendMsgSetMongoDriver) CreateExtendMsgSet(ctx context.Context, set *u
return err
}
-func (e *ExtendMsgSetMongoDriver) GetAllExtendMsgSet(ctx context.Context, ID string, opts *unRelationTb.GetAllExtendMsgSetOpts) (sets []*unRelationTb.ExtendMsgSetModel, err error) {
+func (e *ExtendMsgSetMongoDriver) GetAllExtendMsgSet(
+ ctx context.Context,
+ ID string,
+ opts *unRelationTb.GetAllExtendMsgSetOpts,
+) (sets []*unRelationTb.ExtendMsgSetModel, err error) {
regex := fmt.Sprintf("^%s", ID)
var findOpts *options.FindOptions
if opts != nil {
@@ -47,11 +52,23 @@ func (e *ExtendMsgSetMongoDriver) GetAllExtendMsgSet(ctx context.Context, ID str
return sets, nil
}
-func (e *ExtendMsgSetMongoDriver) GetExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, maxMsgUpdateTime int64) (*unRelationTb.ExtendMsgSetModel, error) {
+func (e *ExtendMsgSetMongoDriver) GetExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ maxMsgUpdateTime int64,
+) (*unRelationTb.ExtendMsgSetModel, error) {
var err error
- findOpts := options.Find().SetLimit(1).SetSkip(0).SetSort(bson.M{"source_id": -1}).SetProjection(bson.M{"extend_msgs": 0})
+ findOpts := options.Find().
+ SetLimit(1).
+ SetSkip(0).
+ SetSort(bson.M{"source_id": -1}).
+ SetProjection(bson.M{"extend_msgs": 0})
// update newest
- find := bson.M{"source_id": primitive.Regex{Pattern: fmt.Sprintf("^%s", conversationID)}, "session_type": sessionType}
+ find := bson.M{
+ "source_id": primitive.Regex{Pattern: fmt.Sprintf("^%s", conversationID)},
+ "session_type": sessionType,
+ }
if maxMsgUpdateTime > 0 {
find["max_msg_update_time"] = maxMsgUpdateTime
}
@@ -70,7 +87,12 @@ func (e *ExtendMsgSetMongoDriver) GetExtendMsgSet(ctx context.Context, conversat
}
// first modify msg
-func (e *ExtendMsgSetMongoDriver) InsertExtendMsg(ctx context.Context, conversationID string, sessionType int32, msg *unRelationTb.ExtendMsgModel) error {
+func (e *ExtendMsgSetMongoDriver) InsertExtendMsg(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ msg *unRelationTb.ExtendMsgModel,
+) error {
set, err := e.GetExtendMsgSet(ctx, conversationID, sessionType, 0)
if err != nil {
return utils.Wrap(err, "")
@@ -95,7 +117,14 @@ func (e *ExtendMsgSetMongoDriver) InsertExtendMsg(ctx context.Context, conversat
}
// insert or update
-func (e *ExtendMsgSetMongoDriver) InsertOrUpdateReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*unRelationTb.KeyValueModel) error {
+func (e *ExtendMsgSetMongoDriver) InsertOrUpdateReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensionList map[string]*unRelationTb.KeyValueModel,
+) error {
var updateBson = bson.M{}
for _, v := range reactionExtensionList {
updateBson[fmt.Sprintf("extend_msgs.%s.%s", clientMsgID, v.TypeKey)] = v
@@ -111,12 +140,24 @@ func (e *ExtendMsgSetMongoDriver) InsertOrUpdateReactionExtendMsgSet(ctx context
if set == nil {
return errors.New(fmt.Sprintf("conversationID %s has no set", conversationID))
}
- _, err = e.ExtendMsgSetCollection.UpdateOne(ctx, bson.M{"source_id": set.ConversationID, "session_type": sessionType}, bson.M{"$set": updateBson}, opt)
+ _, err = e.ExtendMsgSetCollection.UpdateOne(
+ ctx,
+ bson.M{"source_id": set.ConversationID, "session_type": sessionType},
+ bson.M{"$set": updateBson},
+ opt,
+ )
return utils.Wrap(err, "")
}
// delete TypeKey
-func (e *ExtendMsgSetMongoDriver) DeleteReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*unRelationTb.KeyValueModel) error {
+func (e *ExtendMsgSetMongoDriver) DeleteReactionExtendMsgSet(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ msgFirstModifyTime int64,
+ reactionExtensionList map[string]*unRelationTb.KeyValueModel,
+) error {
var updateBson = bson.M{}
for _, v := range reactionExtensionList {
updateBson[fmt.Sprintf("extend_msgs.%s.%s", clientMsgID, v.TypeKey)] = ""
@@ -128,14 +169,36 @@ func (e *ExtendMsgSetMongoDriver) DeleteReactionExtendMsgSet(ctx context.Context
if set == nil {
return errors.New(fmt.Sprintf("conversationID %s has no set", conversationID))
}
- _, err = e.ExtendMsgSetCollection.UpdateOne(ctx, bson.M{"source_id": set.ConversationID, "session_type": sessionType}, bson.M{"$unset": updateBson})
+ _, err = e.ExtendMsgSetCollection.UpdateOne(
+ ctx,
+ bson.M{"source_id": set.ConversationID, "session_type": sessionType},
+ bson.M{"$unset": updateBson},
+ )
return err
}
-func (e *ExtendMsgSetMongoDriver) TakeExtendMsg(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, maxMsgUpdateTime int64) (extendMsg *unRelationTb.ExtendMsgModel, err error) {
- findOpts := options.Find().SetLimit(1).SetSkip(0).SetSort(bson.M{"source_id": -1}).SetProjection(bson.M{fmt.Sprintf("extend_msgs.%s", clientMsgID): 1})
+func (e *ExtendMsgSetMongoDriver) TakeExtendMsg(
+ ctx context.Context,
+ conversationID string,
+ sessionType int32,
+ clientMsgID string,
+ maxMsgUpdateTime int64,
+) (extendMsg *unRelationTb.ExtendMsgModel, err error) {
+ findOpts := options.Find().
+ SetLimit(1).
+ SetSkip(0).
+ SetSort(bson.M{"source_id": -1}).
+ SetProjection(bson.M{fmt.Sprintf("extend_msgs.%s", clientMsgID): 1})
regex := fmt.Sprintf("^%s", conversationID)
- result, err := e.ExtendMsgSetCollection.Find(ctx, bson.M{"source_id": primitive.Regex{Pattern: regex}, "session_type": sessionType, "max_msg_update_time": bson.M{"$lte": maxMsgUpdateTime}}, findOpts)
+ result, err := e.ExtendMsgSetCollection.Find(
+ ctx,
+ bson.M{
+ "source_id": primitive.Regex{Pattern: regex},
+ "session_type": sessionType,
+ "max_msg_update_time": bson.M{"$lte": maxMsgUpdateTime},
+ },
+ findOpts,
+ )
if err != nil {
return nil, utils.Wrap(err, "")
}
diff --git a/pkg/common/db/unrelation/mongo.go b/pkg/common/db/unrelation/mongo.go
index 6ca460ef8..8325abff9 100644
--- a/pkg/common/db/unrelation/mongo.go
+++ b/pkg/common/db/unrelation/mongo.go
@@ -6,14 +6,15 @@ import (
"strings"
"time"
+ "go.mongodb.org/mongo-driver/mongo"
+ "go.mongodb.org/mongo-driver/mongo/options"
+ "go.mongodb.org/mongo-driver/x/bsonx"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "go.mongodb.org/mongo-driver/mongo"
- "go.mongodb.org/mongo-driver/mongo/options"
- "go.mongodb.org/mongo-driver/x/bsonx"
)
type Mongo struct {
@@ -24,7 +25,8 @@ func NewMongo() (*Mongo, error) {
specialerror.AddReplace(mongo.ErrNoDocuments, errs.ErrRecordNotFound)
uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
if config.Config.Mongo.Uri != "" {
- // example: mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$DBMaxPoolSize
+ // example:
+ // mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$DBMaxPoolSize
uri = config.Config.Mongo.Uri
} else {
//mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?replicaSet=mySet&authSource=authDB
diff --git a/pkg/common/db/unrelation/msg.go b/pkg/common/db/unrelation/msg.go
index 16275a142..4c48f6eb3 100644
--- a/pkg/common/db/unrelation/msg.go
+++ b/pkg/common/db/unrelation/msg.go
@@ -8,15 +8,16 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
- table "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"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"
"google.golang.org/protobuf/proto"
+
+ table "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
var ErrMsgListNotExist = errors.New("user not have msg in mongoDB")
@@ -32,7 +33,8 @@ func NewMsgMongoDriver(database *mongo.Database) table.MsgDocModelInterface {
}
func (m *MsgMongoDriver) PushMsgsToDoc(ctx context.Context, docID string, msgsToMongo []table.MsgInfoModel) error {
- return m.MsgCollection.FindOneAndUpdate(ctx, bson.M{"doc_id": docID}, bson.M{"$push": bson.M{"msgs": bson.M{"$each": msgsToMongo}}}).Err()
+ return m.MsgCollection.FindOneAndUpdate(ctx, bson.M{"doc_id": docID}, bson.M{"$push": bson.M{"msgs": bson.M{"$each": msgsToMongo}}}).
+ Err()
}
func (m *MsgMongoDriver) Create(ctx context.Context, model *table.MsgDocModel) error {
@@ -40,7 +42,13 @@ func (m *MsgMongoDriver) Create(ctx context.Context, model *table.MsgDocModel) e
return err
}
-func (m *MsgMongoDriver) UpdateMsg(ctx context.Context, docID string, index int64, key string, value any) (*mongo.UpdateResult, error) {
+func (m *MsgMongoDriver) UpdateMsg(
+ ctx context.Context,
+ docID string,
+ index int64,
+ key string,
+ value any,
+) (*mongo.UpdateResult, error) {
var field string
if key == "" {
field = fmt.Sprintf("msgs.%d", index)
@@ -57,7 +65,13 @@ func (m *MsgMongoDriver) UpdateMsg(ctx context.Context, docID string, index int6
}
// PushUnique value must slice
-func (m *MsgMongoDriver) PushUnique(ctx context.Context, docID string, index int64, key string, value any) (*mongo.UpdateResult, error) {
+func (m *MsgMongoDriver) PushUnique(
+ ctx context.Context,
+ docID string,
+ index int64,
+ key string,
+ value any,
+) (*mongo.UpdateResult, error) {
var field string
if key == "" {
field = fmt.Sprintf("msgs.%d", index)
@@ -78,20 +92,34 @@ func (m *MsgMongoDriver) PushUnique(ctx context.Context, docID string, index int
}
func (m *MsgMongoDriver) UpdateMsgContent(ctx context.Context, docID string, index int64, msg []byte) error {
- _, err := m.MsgCollection.UpdateOne(ctx, bson.M{"doc_id": docID}, bson.M{"$set": bson.M{fmt.Sprintf("msgs.%d.msg", index): msg}})
+ _, err := m.MsgCollection.UpdateOne(
+ ctx,
+ bson.M{"doc_id": docID},
+ bson.M{"$set": bson.M{fmt.Sprintf("msgs.%d.msg", index): msg}},
+ )
if err != nil {
return utils.Wrap(err, "")
}
return nil
}
-func (m *MsgMongoDriver) UpdateMsgStatusByIndexInOneDoc(ctx context.Context, docID string, msg *sdkws.MsgData, seqIndex int, status int32) error {
+func (m *MsgMongoDriver) UpdateMsgStatusByIndexInOneDoc(
+ ctx context.Context,
+ docID string,
+ msg *sdkws.MsgData,
+ seqIndex int,
+ status int32,
+) error {
msg.Status = status
bytes, err := proto.Marshal(msg)
if err != nil {
return utils.Wrap(err, "")
}
- _, err = m.MsgCollection.UpdateOne(ctx, bson.M{"doc_id": docID}, bson.M{"$set": bson.M{fmt.Sprintf("msgs.%d.msg", seqIndex): bytes}})
+ _, err = m.MsgCollection.UpdateOne(
+ ctx,
+ bson.M{"doc_id": docID},
+ bson.M{"$set": bson.M{fmt.Sprintf("msgs.%d.msg", seqIndex): bytes}},
+ )
if err != nil {
return utils.Wrap(err, "")
}
@@ -104,12 +132,20 @@ func (m *MsgMongoDriver) FindOneByDocID(ctx context.Context, docID string) (*tab
return doc, err
}
-func (m *MsgMongoDriver) GetMsgDocModelByIndex(ctx context.Context, conversationID string, index, sort int64) (*table.MsgDocModel, error) {
+func (m *MsgMongoDriver) GetMsgDocModelByIndex(
+ ctx context.Context,
+ conversationID string,
+ index, sort int64,
+) (*table.MsgDocModel, error) {
if sort != 1 && sort != -1 {
return nil, errs.ErrArgs.Wrap("mongo sort must be 1 or -1")
}
findOpts := options.Find().SetLimit(1).SetSkip(index).SetSort(bson.M{"doc_id": sort})
- cursor, err := m.MsgCollection.Find(ctx, bson.M{"doc_id": primitive.Regex{Pattern: fmt.Sprintf("^%s:", conversationID)}}, findOpts)
+ cursor, err := m.MsgCollection.Find(
+ ctx,
+ bson.M{"doc_id": primitive.Regex{Pattern: fmt.Sprintf("^%s:", conversationID)}},
+ findOpts,
+ )
if err != nil {
return nil, utils.Wrap(err, "")
}
@@ -180,7 +216,12 @@ func (m *MsgMongoDriver) DeleteDocs(ctx context.Context, docIDs []string) error
return err
}
-func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(ctx context.Context, userID string, docID string, seqs []int64) (msgs []*table.MsgInfoModel, err error) {
+func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(
+ ctx context.Context,
+ userID string,
+ docID string,
+ seqs []int64,
+) (msgs []*table.MsgInfoModel, err error) {
indexs := make([]int64, 0, len(seqs))
for _, seq := range seqs {
indexs = append(indexs, m.model.GetMsgIndex(seq))
@@ -286,7 +327,12 @@ func (m *MsgMongoDriver) IsExistDocID(ctx context.Context, docID string) (bool,
return count > 0, nil
}
-func (m *MsgMongoDriver) MarkSingleChatMsgsAsRead(ctx context.Context, userID string, docID string, indexes []int64) error {
+func (m *MsgMongoDriver) MarkSingleChatMsgsAsRead(
+ ctx context.Context,
+ userID string,
+ docID string,
+ indexes []int64,
+) error {
updates := []mongo.WriteModel{}
for _, index := range indexes {
filter := bson.M{
diff --git a/pkg/common/db/unrelation/super_group.go b/pkg/common/db/unrelation/super_group.go
index 54de697e4..3dc9f61bd 100644
--- a/pkg/common/db/unrelation/super_group.go
+++ b/pkg/common/db/unrelation/super_group.go
@@ -3,15 +3,19 @@ package unrelation
import (
"context"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
func NewSuperGroupMongoDriver(database *mongo.Database) unrelation.SuperGroupModelInterface {
- return &SuperGroupMongoDriver{superGroupCollection: database.Collection(unrelation.CSuperGroup), userToSuperGroupCollection: database.Collection(unrelation.CUserToSuperGroup)}
+ return &SuperGroupMongoDriver{
+ superGroupCollection: database.Collection(unrelation.CSuperGroup),
+ userToSuperGroupCollection: database.Collection(unrelation.CUserToSuperGroup),
+ }
}
type SuperGroupMongoDriver struct {
@@ -28,9 +32,14 @@ func (s *SuperGroupMongoDriver) CreateSuperGroup(ctx context.Context, groupID st
return err
}
for _, userID := range initMemberIDs {
- _, err = s.userToSuperGroupCollection.UpdateOne(ctx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, &options.UpdateOptions{
- Upsert: utils.ToPtr(true),
- })
+ _, err = s.userToSuperGroupCollection.UpdateOne(
+ ctx,
+ bson.M{"user_id": userID},
+ bson.M{"$addToSet": bson.M{"group_id_list": groupID}},
+ &options.UpdateOptions{
+ Upsert: utils.ToPtr(true),
+ },
+ )
if err != nil {
return err
}
@@ -38,14 +47,20 @@ func (s *SuperGroupMongoDriver) CreateSuperGroup(ctx context.Context, groupID st
return nil
}
-func (s *SuperGroupMongoDriver) TakeSuperGroup(ctx context.Context, groupID string) (group *unrelation.SuperGroupModel, err error) {
+func (s *SuperGroupMongoDriver) TakeSuperGroup(
+ ctx context.Context,
+ groupID string,
+) (group *unrelation.SuperGroupModel, err error) {
if err := s.superGroupCollection.FindOne(ctx, bson.M{"group_id": groupID}).Decode(&group); err != nil {
return nil, utils.Wrap(err, "")
}
return group, nil
}
-func (s *SuperGroupMongoDriver) FindSuperGroup(ctx context.Context, groupIDs []string) (groups []*unrelation.SuperGroupModel, err error) {
+func (s *SuperGroupMongoDriver) FindSuperGroup(
+ ctx context.Context,
+ groupIDs []string,
+) (groups []*unrelation.SuperGroupModel, err error) {
cursor, err := s.superGroupCollection.Find(ctx, bson.M{"group_id": bson.M{
"$in": groupIDs,
}})
@@ -60,7 +75,11 @@ func (s *SuperGroupMongoDriver) FindSuperGroup(ctx context.Context, groupIDs []s
}
func (s *SuperGroupMongoDriver) AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error {
- _, err := s.superGroupCollection.UpdateOne(ctx, bson.M{"group_id": groupID}, bson.M{"$addToSet": bson.M{"member_id_list": bson.M{"$each": userIDs}}})
+ _, err := s.superGroupCollection.UpdateOne(
+ ctx,
+ bson.M{"group_id": groupID},
+ bson.M{"$addToSet": bson.M{"member_id_list": bson.M{"$each": userIDs}}},
+ )
if err != nil {
return err
}
@@ -69,7 +88,12 @@ func (s *SuperGroupMongoDriver) AddUserToSuperGroup(ctx context.Context, groupID
Upsert: &upsert,
}
for _, userID := range userIDs {
- _, err = s.userToSuperGroupCollection.UpdateOne(ctx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts)
+ _, err = s.userToSuperGroupCollection.UpdateOne(
+ ctx,
+ bson.M{"user_id": userID},
+ bson.M{"$addToSet": bson.M{"group_id_list": groupID}},
+ opts,
+ )
if err != nil {
return utils.Wrap(err, "transaction failed")
}
@@ -78,7 +102,11 @@ func (s *SuperGroupMongoDriver) AddUserToSuperGroup(ctx context.Context, groupID
}
func (s *SuperGroupMongoDriver) RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDs []string) error {
- _, err := s.superGroupCollection.UpdateOne(ctx, bson.M{"group_id": groupID}, bson.M{"$pull": bson.M{"member_id_list": bson.M{"$in": userIDs}}})
+ _, err := s.superGroupCollection.UpdateOne(
+ ctx,
+ bson.M{"group_id": groupID},
+ bson.M{"$pull": bson.M{"member_id_list": bson.M{"$in": userIDs}}},
+ )
if err != nil {
return err
}
@@ -89,7 +117,10 @@ func (s *SuperGroupMongoDriver) RemoverUserFromSuperGroup(ctx context.Context, g
return nil
}
-func (s *SuperGroupMongoDriver) GetSuperGroupByUserID(ctx context.Context, userID string) (*unrelation.UserToSuperGroupModel, error) {
+func (s *SuperGroupMongoDriver) GetSuperGroupByUserID(
+ ctx context.Context,
+ userID string,
+) (*unrelation.UserToSuperGroupModel, error) {
var user unrelation.UserToSuperGroupModel
err := s.userToSuperGroupCollection.FindOne(ctx, bson.M{"user_id": userID}).Decode(&user)
return &user, utils.Wrap(err, "")
@@ -107,6 +138,10 @@ func (s *SuperGroupMongoDriver) DeleteSuperGroup(ctx context.Context, groupID st
}
func (s *SuperGroupMongoDriver) RemoveGroupFromUser(ctx context.Context, groupID string, userIDs []string) error {
- _, err := s.userToSuperGroupCollection.UpdateOne(ctx, bson.M{"user_id": bson.M{"$in": userIDs}}, bson.M{"$pull": bson.M{"group_id_list": groupID}})
+ _, err := s.userToSuperGroupCollection.UpdateOne(
+ ctx,
+ bson.M{"user_id": bson.M{"$in": userIDs}},
+ bson.M{"$pull": bson.M{"group_id_list": groupID}},
+ )
return utils.Wrap(err, "")
}
diff --git a/pkg/common/http/http_client.go b/pkg/common/http/http_client.go
index 2227a3438..72e3fae62 100644
--- a/pkg/common/http/http_client.go
+++ b/pkg/common/http/http_client.go
@@ -3,8 +3,7 @@
** copyright('open-im,www.open-im.io').
** author("fg,Gordon@tuoyun.net").
** time(2021/5/27 10:31).
- */
-package http
+ */package http
import (
"bytes"
@@ -39,7 +38,13 @@ func Get(url string) (response []byte, err error) {
return body, nil
}
-func Post(ctx context.Context, url string, header map[string]string, data interface{}, timeout int) (content []byte, err error) {
+func Post(
+ ctx context.Context,
+ url string,
+ header map[string]string,
+ data interface{},
+ timeout int,
+) (content []byte, err error) {
if timeout > 0 {
var cancel func()
ctx, cancel = context.WithTimeout(ctx, time.Second*time.Duration(timeout))
@@ -72,7 +77,13 @@ func Post(ctx context.Context, url string, header map[string]string, data interf
return result, nil
}
-func PostReturn(ctx context.Context, url string, header map[string]string, input, output interface{}, timeOutSecond int) error {
+func PostReturn(
+ ctx context.Context,
+ url string,
+ header map[string]string,
+ input, output interface{},
+ timeOutSecond int,
+) error {
b, err := Post(ctx, url, header, input, timeOutSecond)
if err != nil {
return err
@@ -81,7 +92,13 @@ func PostReturn(ctx context.Context, url string, header map[string]string, input
return err
}
-func callBackPostReturn(ctx context.Context, url, command string, input interface{}, output callbackstruct.CallbackResp, callbackConfig config.CallBackConfig) error {
+func callBackPostReturn(
+ ctx context.Context,
+ url, command string,
+ input interface{},
+ output callbackstruct.CallbackResp,
+ callbackConfig config.CallBackConfig,
+) error {
defer log.ZDebug(ctx, "callback", "url", url, "command", command, "input", input, "callbackConfig", callbackConfig)
v := urlLib.Values{}
v.Set(constant.CallbackCommand, command)
@@ -104,6 +121,12 @@ func callBackPostReturn(ctx context.Context, url, command string, input interfac
return output.Parse()
}
-func CallBackPostReturn(ctx context.Context, url string, req callbackstruct.CallbackReq, resp callbackstruct.CallbackResp, callbackConfig config.CallBackConfig) error {
+func CallBackPostReturn(
+ ctx context.Context,
+ url string,
+ req callbackstruct.CallbackReq,
+ resp callbackstruct.CallbackResp,
+ callbackConfig config.CallBackConfig,
+) error {
return callBackPostReturn(ctx, url, req.GetCallbackCommand(), req, resp, callbackConfig)
}
diff --git a/pkg/common/log/sql_logger.go b/pkg/common/log/sql_logger.go
index 30194ac96..1785b211c 100644
--- a/pkg/common/log/sql_logger.go
+++ b/pkg/common/log/sql_logger.go
@@ -17,7 +17,11 @@ type SqlLogger struct {
SlowThreshold time.Duration
}
-func NewSqlLogger(logLevel gormLogger.LogLevel, ignoreRecordNotFoundError bool, slowThreshold time.Duration) *SqlLogger {
+func NewSqlLogger(
+ logLevel gormLogger.LogLevel,
+ ignoreRecordNotFoundError bool,
+ slowThreshold time.Duration,
+) *SqlLogger {
return &SqlLogger{
LogLevel: logLevel,
IgnoreRecordNotFoundError: ignoreRecordNotFoundError,
@@ -52,7 +56,17 @@ func (l *SqlLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql s
case err != nil && l.LogLevel >= gormLogger.Error && (!errors.Is(err, gorm.ErrRecordNotFound) || !l.IgnoreRecordNotFoundError):
sql, rows := fc()
if rows == -1 {
- ZError(ctx, "sql exec detail", err, "gorm", gormUtils.FileWithLineNum(), "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "sql", sql)
+ ZError(
+ ctx,
+ "sql exec detail",
+ err,
+ "gorm",
+ gormUtils.FileWithLineNum(),
+ "elapsed time",
+ fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6),
+ "sql",
+ sql,
+ )
} else {
ZError(ctx, "sql exec detail", err, "gorm", gormUtils.FileWithLineNum(), "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "rows", rows, "sql", sql)
}
@@ -60,14 +74,36 @@ func (l *SqlLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql s
sql, rows := fc()
slowLog := fmt.Sprintf("SLOW SQL >= %v", l.SlowThreshold)
if rows == -1 {
- ZWarn(ctx, "sql exec detail", nil, "gorm", gormUtils.FileWithLineNum(), nil, "slow sql", slowLog, "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "sql", sql)
+ ZWarn(
+ ctx,
+ "sql exec detail",
+ nil,
+ "gorm",
+ gormUtils.FileWithLineNum(),
+ nil,
+ "slow sql",
+ slowLog,
+ "elapsed time",
+ fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6),
+ "sql",
+ sql,
+ )
} else {
ZWarn(ctx, "sql exec detail", nil, "gorm", gormUtils.FileWithLineNum(), nil, "slow sql", slowLog, "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "rows", rows, "sql", sql)
}
case l.LogLevel == gormLogger.Info:
sql, rows := fc()
if rows == -1 {
- ZDebug(ctx, "sql exec detail", "gorm", gormUtils.FileWithLineNum(), "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "sql", sql)
+ ZDebug(
+ ctx,
+ "sql exec detail",
+ "gorm",
+ gormUtils.FileWithLineNum(),
+ "elapsed time",
+ fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6),
+ "sql",
+ sql,
+ )
} else {
ZDebug(ctx, "sql exec detail", "gorm", gormUtils.FileWithLineNum(), "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "rows", rows, "sql", sql)
}
diff --git a/pkg/common/log/zap.go b/pkg/common/log/zap.go
index 8ea3e2dfc..a173ac055 100644
--- a/pkg/common/log/zap.go
+++ b/pkg/common/log/zap.go
@@ -7,10 +7,11 @@ import (
"path/filepath"
"time"
+ rotatelogs "github.com/lestrrat-go/file-rotatelogs"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
- rotatelogs "github.com/lestrrat-go/file-rotatelogs"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
@@ -31,7 +32,14 @@ var (
)
// InitFromConfig initializes a Zap-based logger
-func InitFromConfig(loggerPrefixName, moduleName string, logLevel int, isStdout bool, isJson bool, logLocation string, rotateCount uint) error {
+func InitFromConfig(
+ loggerPrefixName, moduleName string,
+ logLevel int,
+ isStdout bool,
+ isJson bool,
+ logLocation string,
+ rotateCount uint,
+) error {
l, err := NewZapLogger(loggerPrefixName, moduleName, logLevel, isStdout, isJson, logLocation, rotateCount)
if err != nil {
return err
@@ -78,7 +86,14 @@ type ZapLogger struct {
loggerPrefixName string
}
-func NewZapLogger(loggerPrefixName, loggerName string, logLevel int, isStdout bool, isJson bool, logLocation string, rotateCount uint) (*ZapLogger, error) {
+func NewZapLogger(
+ loggerPrefixName, loggerName string,
+ logLevel int,
+ isStdout bool,
+ isJson bool,
+ logLocation string,
+ rotateCount uint,
+) (*ZapLogger, error) {
zapConfig := zap.Config{
Level: zap.NewAtomicLevelAt(logLevelMap[logLevel]),
// EncoderConfig: zap.NewProductionEncoderConfig(),
diff --git a/pkg/common/mw/gin.go b/pkg/common/mw/gin.go
index 10dd4eed9..42798d060 100644
--- a/pkg/common/mw/gin.go
+++ b/pkg/common/mw/gin.go
@@ -4,6 +4,9 @@ import (
"errors"
"net/http"
+ "github.com/gin-gonic/gin"
+ "github.com/redis/go-redis/v9"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
@@ -12,8 +15,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
- "github.com/gin-gonic/gin"
- "github.com/redis/go-redis/v9"
)
func CorsHandler() gin.HandlerFunc {
@@ -21,10 +22,22 @@ func CorsHandler() gin.HandlerFunc {
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
c.Header("Access-Control-Allow-Methods", "*")
c.Header("Access-Control-Allow-Headers", "*")
- c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar") // 跨域关键设置 让浏览器可以解析
- c.Header("Access-Control-Max-Age", "172800") // 缓存请求信息 单位为秒
- c.Header("Access-Control-Allow-Credentials", "false") // 跨域请求是否需要带cookie信息 默认设置为true
- c.Header("content-type", "application/json") // 设置返回格式是json
+ c.Header(
+ "Access-Control-Expose-Headers",
+ "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar",
+ ) // 跨域关键设置 让浏览器可以解析
+ c.Header(
+ "Access-Control-Max-Age",
+ "172800",
+ ) // 缓存请求信息 单位为秒
+ c.Header(
+ "Access-Control-Allow-Credentials",
+ "false",
+ ) // 跨域请求是否需要带cookie信息 默认设置为true
+ c.Header(
+ "content-type",
+ "application/json",
+ ) // 设置返回格式是json
//Release all option pre-requests
if c.Request.Method == http.MethodOptions {
c.JSON(http.StatusOK, "Options Request!")
@@ -52,7 +65,11 @@ func GinParseOperationID() gin.HandlerFunc {
}
func GinParseToken(rdb redis.UniversalClient) gin.HandlerFunc {
- dataBase := controller.NewAuthDatabase(cache.NewMsgCacheModel(rdb), config.Config.Secret, config.Config.TokenPolicy.Expire)
+ dataBase := controller.NewAuthDatabase(
+ cache.NewMsgCacheModel(rdb),
+ config.Config.Secret,
+ config.Config.TokenPolicy.Expire,
+ )
return func(c *gin.Context) {
switch c.Request.Method {
case http.MethodPost:
diff --git a/pkg/common/mw/rpc_client_interceptor.go b/pkg/common/mw/rpc_client_interceptor.go
index e52366ec0..530847280 100644
--- a/pkg/common/mw/rpc_client_interceptor.go
+++ b/pkg/common/mw/rpc_client_interceptor.go
@@ -6,20 +6,28 @@ import (
"fmt"
"strings"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/metadata"
+ "google.golang.org/grpc/status"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/errinfo"
- "google.golang.org/grpc"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
)
func GrpcClient() grpc.DialOption {
return grpc.WithUnaryInterceptor(RpcClientInterceptor)
}
-func RpcClientInterceptor(ctx context.Context, method string, req, resp interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) (err error) {
+func RpcClientInterceptor(
+ ctx context.Context,
+ method string,
+ req, resp interface{},
+ cc *grpc.ClientConn,
+ invoker grpc.UnaryInvoker,
+ opts ...grpc.CallOption,
+) (err error) {
if ctx == nil {
return errs.ErrInternalServer.Wrap("call rpc request context is nil")
}
diff --git a/pkg/common/mw/rpc_server_interceptor.go b/pkg/common/mw/rpc_server_interceptor.go
index be37fc0fb..4dcd4e582 100644
--- a/pkg/common/mw/rpc_server_interceptor.go
+++ b/pkg/common/mw/rpc_server_interceptor.go
@@ -11,16 +11,17 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/errinfo"
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/errinfo"
)
func rpcString(v interface{}) string {
@@ -30,12 +31,17 @@ func rpcString(v interface{}) string {
return fmt.Sprintf("%+v", v)
}
-func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
+func RpcServerInterceptor(
+ ctx context.Context,
+ req interface{},
+ info *grpc.UnaryServerInfo,
+ handler grpc.UnaryHandler,
+) (resp interface{}, err error) {
log.ZDebug(ctx, "rpc server req", "req", rpcString(req))
//defer func() {
// if r := recover(); r != nil {
- // log.ZError(ctx, "rpc panic", nil, "FullMethod", info.FullMethod, "type:", fmt.Sprintf("%T", r), "panic:", r)
+ // log.ZError(ctx, "rpc panic", nil, "FullMethod", info.FullMethod, "type:", fmt.Sprintf("%T", r), "panic:", r)
// fmt.Printf("panic: %+v\nstack info: %s\n", r, string(debug.Stack()))
// pc, file, line, ok := runtime.Caller(4)
// if !ok {
@@ -48,7 +54,8 @@ func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.Unary
// Cause: fmt.Sprintf("%s", r),
// Warp: nil,
// }
- // sta, err_ := status.New(codes.Code(errs.ErrInternalServer.Code()), errs.ErrInternalServer.Msg()).WithDetails(errInfo)
+ // sta, err_ := status.New(codes.Code(errs.ErrInternalServer.Code()),
+ // errs.ErrInternalServer.Msg()).WithDetails(errInfo)
// if err_ != nil {
// panic(err_)
// }
@@ -122,7 +129,17 @@ func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.Unary
if unwrap != err {
sti, ok := err.(interface{ StackTrace() errors.StackTrace })
if ok {
- log.ZWarn(ctx, "rpc server resp", err, "funcName", funcName, "unwrap", unwrap.Error(), "stack", fmt.Sprintf("%+v", err))
+ log.ZWarn(
+ ctx,
+ "rpc server resp",
+ err,
+ "funcName",
+ funcName,
+ "unwrap",
+ unwrap.Error(),
+ "stack",
+ fmt.Sprintf("%+v", err),
+ )
if fs := sti.StackTrace(); len(fs) > 0 {
pc := uintptr(fs[0])
fn := runtime.FuncForPC(pc)
diff --git a/pkg/common/network/ip.go b/pkg/common/network/ip.go
index bbe16e265..2d5a5b09c 100644
--- a/pkg/common/network/ip.go
+++ b/pkg/common/network/ip.go
@@ -1,8 +1,9 @@
package network
import (
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
utils "github.com/OpenIMSDK/open_utils"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
)
func GetRpcRegisterIP(configIP string) (string, error) {
diff --git a/pkg/common/tokenverify/jwt_token.go b/pkg/common/tokenverify/jwt_token.go
index 582a7f68e..9f4088eff 100644
--- a/pkg/common/tokenverify/jwt_token.go
+++ b/pkg/common/tokenverify/jwt_token.go
@@ -5,11 +5,12 @@ import (
"fmt"
"time"
+ "github.com/golang-jwt/jwt/v4"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "github.com/golang-jwt/jwt/v4"
)
type Claims struct {
diff --git a/pkg/common/tokenverify/jwt_token_test.go b/pkg/common/tokenverify/jwt_token_test.go
index ffbac4bca..b8390b45d 100644
--- a/pkg/common/tokenverify/jwt_token_test.go
+++ b/pkg/common/tokenverify/jwt_token_test.go
@@ -3,9 +3,10 @@ package tokenverify
import (
"testing"
+ "github.com/golang-jwt/jwt/v4"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
- "github.com/golang-jwt/jwt/v4"
)
func Test_ParseToken(t *testing.T) {
diff --git a/pkg/discoveryregistry/zookeeper/discover.go b/pkg/discoveryregistry/zookeeper/discover.go
index 65dacd397..912c001d9 100644
--- a/pkg/discoveryregistry/zookeeper/discover.go
+++ b/pkg/discoveryregistry/zookeeper/discover.go
@@ -6,9 +6,10 @@ import (
"io"
"strings"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/pkg/errors"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
+
"github.com/go-zookeeper/zk"
"google.golang.org/grpc"
"google.golang.org/grpc/resolver"
@@ -68,7 +69,11 @@ func (s *ZkClient) GetConnsRemote(serviceName string) (conns []resolver.Address,
return conns, nil
}
-func (s *ZkClient) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]grpc.ClientConnInterface, error) {
+func (s *ZkClient) GetConns(
+ ctx context.Context,
+ serviceName string,
+ opts ...grpc.DialOption,
+) ([]grpc.ClientConnInterface, error) {
s.logger.Printf("get conns from client, serviceName: %s", serviceName)
s.lock.Lock()
opts = append(s.options, opts...)
@@ -82,7 +87,13 @@ func (s *ZkClient) GetConns(ctx context.Context, serviceName string, opts ...grp
return nil, err
}
if len(conns) == 0 {
- return nil, fmt.Errorf("no conn for service %s, grpc server may not exist, local conn is %v, please check zookeeper server %v, path: %s", serviceName, s.localConns, s.zkServers, s.zkRoot)
+ return nil, fmt.Errorf(
+ "no conn for service %s, grpc server may not exist, local conn is %v, please check zookeeper server %v, path: %s",
+ serviceName,
+ s.localConns,
+ s.zkServers,
+ s.zkRoot,
+ )
}
s.localConns[serviceName] = conns
}
@@ -100,8 +111,15 @@ func (s *ZkClient) GetConns(ctx context.Context, serviceName string, opts ...grp
return ret, nil
}
-func (s *ZkClient) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (grpc.ClientConnInterface, error) {
- newOpts := append(s.options, grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, s.balancerName)))
+func (s *ZkClient) GetConn(
+ ctx context.Context,
+ serviceName string,
+ opts ...grpc.DialOption,
+) (grpc.ClientConnInterface, error) {
+ newOpts := append(
+ s.options,
+ grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, s.balancerName)),
+ )
s.logger.Printf("get conn from client, serviceName: %s", serviceName)
return grpc.DialContext(ctx, fmt.Sprintf("%s:///%s", s.scheme, serviceName), append(newOpts, opts...)...)
}
diff --git a/pkg/discoveryregistry/zookeeper/register.go b/pkg/discoveryregistry/zookeeper/register.go
index 8f38f6d8d..ab75f488b 100644
--- a/pkg/discoveryregistry/zookeeper/register.go
+++ b/pkg/discoveryregistry/zookeeper/register.go
@@ -26,7 +26,11 @@ func (s *ZkClient) Register(rpcRegisterName, host string, port int, opts ...grpc
if err != nil {
return err
}
- node, err := s.conn.CreateProtectedEphemeralSequential(s.getPath(rpcRegisterName)+"/"+addr+"_", []byte(addr), zk.WorldACL(zk.PermAll))
+ node, err := s.conn.CreateProtectedEphemeralSequential(
+ s.getPath(rpcRegisterName)+"/"+addr+"_",
+ []byte(addr),
+ zk.WorldACL(zk.PermAll),
+ )
if err != nil {
return err
}
diff --git a/pkg/discoveryregistry/zookeeper/resolver.go b/pkg/discoveryregistry/zookeeper/resolver.go
index ee2a449cb..74ed04455 100644
--- a/pkg/discoveryregistry/zookeeper/resolver.go
+++ b/pkg/discoveryregistry/zookeeper/resolver.go
@@ -18,7 +18,16 @@ type Resolver struct {
}
func (r *Resolver) ResolveNowZK(o resolver.ResolveNowOptions) {
- log.ZDebug(context.Background(), "start resolve now", "target", r.target, "cc", r.cc.UpdateState, "serviceName", strings.TrimLeft(r.target.URL.Path, "/"))
+ log.ZDebug(
+ context.Background(),
+ "start resolve now",
+ "target",
+ r.target,
+ "cc",
+ r.cc.UpdateState,
+ "serviceName",
+ strings.TrimLeft(r.target.URL.Path, "/"),
+ )
newConns, err := r.getConnsRemote(strings.TrimLeft(r.target.URL.Path, "/"))
if err != nil {
log.ZError(context.Background(), "resolve now error", err, "target", r.target)
@@ -26,7 +35,15 @@ func (r *Resolver) ResolveNowZK(o resolver.ResolveNowOptions) {
}
r.addrs = newConns
if err := r.cc.UpdateState(resolver.State{Addresses: newConns}); err != nil {
- log.ZError(context.Background(), "UpdateState error, conns is nil from svr", err, "conns", newConns, "zk path", r.target.URL.Path)
+ log.ZError(
+ context.Background(),
+ "UpdateState error, conns is nil from svr",
+ err,
+ "conns",
+ newConns,
+ "zk path",
+ r.target.URL.Path,
+ )
return
}
log.ZDebug(context.Background(), "resolve now finished", "target", r.target, "conns", r.addrs)
@@ -36,7 +53,11 @@ func (r *Resolver) ResolveNow(o resolver.ResolveNowOptions) {}
func (s *Resolver) Close() {}
-func (s *ZkClient) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
+func (s *ZkClient) Build(
+ target resolver.Target,
+ cc resolver.ClientConn,
+ opts resolver.BuildOptions,
+) (resolver.Resolver, error) {
s.logger.Printf("build resolver: %+v, cc: %+v", target, cc.UpdateState)
// log.ZDebug(context.Background(), "build resolver start", "target", target, "cc", cc.UpdateState)
r := &Resolver{}
@@ -49,7 +70,8 @@ func (s *ZkClient) Build(target resolver.Target, cc resolver.ClientConn, opts re
serviceName := strings.TrimLeft(target.URL.Path, "/")
s.resolvers[serviceName] = r
s.logger.Printf("build resolver finished: %+v, cc: %+v, key: %s", target, cc.UpdateState, serviceName)
- // log.ZDebug(context.Background(), "build resolver finished", "target", target, "cc", cc.UpdateState, "serviceName", serviceName)
+ // log.ZDebug(context.Background(), "build resolver finished", "target", target, "cc", cc.UpdateState,
+ // "serviceName", serviceName)
return r, nil
}
diff --git a/pkg/discoveryregistry/zookeeper/zk.go b/pkg/discoveryregistry/zookeeper/zk.go
index be0fb5bb0..d6287e47b 100644
--- a/pkg/discoveryregistry/zookeeper/zk.go
+++ b/pkg/discoveryregistry/zookeeper/zk.go
@@ -97,7 +97,12 @@ func NewClient(zkServers []string, zkRoot string, options ...ZkOption) (*ZkClien
for _, option := range options {
option(client)
}
- conn, eventChan, err := zk.Connect(zkServers, time.Duration(client.timeout)*time.Second, zk.WithLogInfo(true), zk.WithLogger(client.logger))
+ conn, eventChan, err := zk.Connect(
+ zkServers,
+ time.Duration(client.timeout)*time.Second,
+ zk.WithLogInfo(true),
+ zk.WithLogger(client.logger),
+ )
if err != nil {
return nil, err
}
diff --git a/pkg/proto/conversation/conversation.pb.go b/pkg/proto/conversation/conversation.pb.go
index 8c7451a3d..debced9b9 100644
--- a/pkg/proto/conversation/conversation.pb.go
+++ b/pkg/proto/conversation/conversation.pb.go
@@ -11,12 +11,13 @@ import (
reflect "reflect"
sync "sync"
- wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+
+ wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
)
const (
diff --git a/pkg/proto/friend/friend.pb.go b/pkg/proto/friend/friend.pb.go
index 515ac8128..c49a13999 100644
--- a/pkg/proto/friend/friend.pb.go
+++ b/pkg/proto/friend/friend.pb.go
@@ -11,12 +11,13 @@ import (
reflect "reflect"
sync "sync"
- sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+
+ sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
)
const (
diff --git a/pkg/proto/group/group.pb.go b/pkg/proto/group/group.pb.go
index 5024365cc..f54e54a9e 100644
--- a/pkg/proto/group/group.pb.go
+++ b/pkg/proto/group/group.pb.go
@@ -11,13 +11,14 @@ import (
reflect "reflect"
sync "sync"
- sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
- wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+
+ sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
+ wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
)
const (
diff --git a/pkg/proto/msg/msg.pb.go b/pkg/proto/msg/msg.pb.go
index 4a35ebe4f..f52af2b63 100644
--- a/pkg/proto/msg/msg.pb.go
+++ b/pkg/proto/msg/msg.pb.go
@@ -11,13 +11,14 @@ import (
reflect "reflect"
sync "sync"
- sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
- wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+
+ sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
+ wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
)
const (
diff --git a/pkg/proto/msggateway/msggateway.pb.go b/pkg/proto/msggateway/msggateway.pb.go
index 9b247c65a..51f186c8c 100644
--- a/pkg/proto/msggateway/msggateway.pb.go
+++ b/pkg/proto/msggateway/msggateway.pb.go
@@ -11,12 +11,13 @@ import (
reflect "reflect"
sync "sync"
- sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+
+ sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
)
const (
diff --git a/pkg/proto/push/push.pb.go b/pkg/proto/push/push.pb.go
index 1e6a895f1..f9ef4a08a 100644
--- a/pkg/proto/push/push.pb.go
+++ b/pkg/proto/push/push.pb.go
@@ -11,12 +11,13 @@ import (
reflect "reflect"
sync "sync"
- sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+
+ sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
)
const (
diff --git a/pkg/proto/sdkws/sdkws.pb.go b/pkg/proto/sdkws/sdkws.pb.go
index 13637d3c9..9a5e4d630 100644
--- a/pkg/proto/sdkws/sdkws.pb.go
+++ b/pkg/proto/sdkws/sdkws.pb.go
@@ -10,9 +10,10 @@ import (
reflect "reflect"
sync "sync"
- wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+
+ wrapperspb "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
)
const (
diff --git a/pkg/proto/user/user.pb.go b/pkg/proto/user/user.pb.go
index b55abd968..86113ec05 100644
--- a/pkg/proto/user/user.pb.go
+++ b/pkg/proto/user/user.pb.go
@@ -11,13 +11,14 @@ import (
reflect "reflect"
sync "sync"
- conversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
- sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+
+ conversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
+ sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
)
const (
diff --git a/pkg/rpcclient/auth.go b/pkg/rpcclient/auth.go
index 580e6bcee..fc435aa24 100644
--- a/pkg/rpcclient/auth.go
+++ b/pkg/rpcclient/auth.go
@@ -3,10 +3,11 @@ package rpcclient
import (
"context"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/auth"
- "google.golang.org/grpc"
)
func NewAuth(discov discoveryregistry.SvcDiscoveryRegistry) *Auth {
diff --git a/pkg/rpcclient/conversation.go b/pkg/rpcclient/conversation.go
index 400a7b651..cc781e449 100644
--- a/pkg/rpcclient/conversation.go
+++ b/pkg/rpcclient/conversation.go
@@ -4,11 +4,12 @@ import (
"context"
"fmt"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
- "google.golang.org/grpc"
)
type Conversation struct {
@@ -32,12 +33,18 @@ func NewConversationRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) Con
return ConversationRpcClient(*NewConversation(discov))
}
-func (c *ConversationRpcClient) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) error {
+func (c *ConversationRpcClient) ModifyConversationField(
+ ctx context.Context,
+ req *pbConversation.ModifyConversationFieldReq,
+) error {
_, err := c.Client.ModifyConversationField(ctx, req)
return err
}
-func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
+func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(
+ ctx context.Context,
+ userID, conversationID string,
+) (int32, error) {
var req pbConversation.GetConversationReq
req.OwnerUserID = userID
req.ConversationID = conversationID
@@ -49,21 +56,51 @@ func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Cont
}
func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Context, recvID, sendID string) error {
- _, err := c.Client.CreateSingleChatConversations(ctx, &pbConversation.CreateSingleChatConversationsReq{RecvID: recvID, SendID: sendID})
+ _, err := c.Client.CreateSingleChatConversations(
+ ctx,
+ &pbConversation.CreateSingleChatConversationsReq{RecvID: recvID, SendID: sendID},
+ )
return err
}
-func (c *ConversationRpcClient) GroupChatFirstCreateConversation(ctx context.Context, groupID string, userIDs []string) error {
- _, err := c.Client.CreateGroupChatConversations(ctx, &pbConversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID})
+func (c *ConversationRpcClient) GroupChatFirstCreateConversation(
+ ctx context.Context,
+ groupID string,
+ userIDs []string,
+) error {
+ _, err := c.Client.CreateGroupChatConversations(
+ ctx,
+ &pbConversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID},
+ )
return err
}
-func (c *ConversationRpcClient) SetConversationMaxSeq(ctx context.Context, ownerUserIDs []string, conversationID string, maxSeq int64) error {
- _, err := c.Client.SetConversationMaxSeq(ctx, &pbConversation.SetConversationMaxSeqReq{OwnerUserID: ownerUserIDs, ConversationID: conversationID, MaxSeq: maxSeq})
+func (c *ConversationRpcClient) SetConversationMaxSeq(
+ ctx context.Context,
+ ownerUserIDs []string,
+ conversationID string,
+ maxSeq int64,
+) error {
+ _, err := c.Client.SetConversationMaxSeq(
+ ctx,
+ &pbConversation.SetConversationMaxSeqReq{
+ OwnerUserID: ownerUserIDs,
+ ConversationID: conversationID,
+ MaxSeq: maxSeq,
+ },
+ )
return err
}
-func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbConversation.ConversationReq) error {
- _, err := c.Client.SetConversations(ctx, &pbConversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation})
+
+func (c *ConversationRpcClient) SetConversations(
+ ctx context.Context,
+ userIDs []string,
+ conversation *pbConversation.ConversationReq,
+) error {
+ _, err := c.Client.SetConversations(
+ ctx,
+ &pbConversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation},
+ )
return err
}
@@ -75,16 +112,28 @@ func (c *ConversationRpcClient) GetConversationIDs(ctx context.Context, ownerUse
return resp.ConversationIDs, nil
}
-func (c *ConversationRpcClient) GetConversation(ctx context.Context, ownerUserID, conversationID string) (*pbConversation.Conversation, error) {
- resp, err := c.Client.GetConversation(ctx, &pbConversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID})
+func (c *ConversationRpcClient) GetConversation(
+ ctx context.Context,
+ ownerUserID, conversationID string,
+) (*pbConversation.Conversation, error) {
+ resp, err := c.Client.GetConversation(
+ ctx,
+ &pbConversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID},
+ )
if err != nil {
return nil, err
}
return resp.Conversation, nil
}
-func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*pbConversation.Conversation, error) {
- resp, err := c.Client.GetConversationsByConversationID(ctx, &pbConversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs})
+func (c *ConversationRpcClient) GetConversationsByConversationID(
+ ctx context.Context,
+ conversationIDs []string,
+) ([]*pbConversation.Conversation, error) {
+ resp, err := c.Client.GetConversationsByConversationID(
+ ctx,
+ &pbConversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs},
+ )
if err != nil {
return nil, err
}
@@ -94,8 +143,15 @@ func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Con
return resp.Conversations, nil
}
-func (c *ConversationRpcClient) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*pbConversation.Conversation, error) {
- resp, err := c.Client.GetConversations(ctx, &pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs})
+func (c *ConversationRpcClient) GetConversations(
+ ctx context.Context,
+ ownerUserID string,
+ conversationIDs []string,
+) ([]*pbConversation.Conversation, error) {
+ resp, err := c.Client.GetConversations(
+ ctx,
+ &pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs},
+ )
if err != nil {
return nil, err
}
diff --git a/pkg/rpcclient/friend.go b/pkg/rpcclient/friend.go
index aa7ba0344..56875dc83 100644
--- a/pkg/rpcclient/friend.go
+++ b/pkg/rpcclient/friend.go
@@ -3,11 +3,12 @@ package rpcclient
import (
"context"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
- "google.golang.org/grpc"
)
type Friend struct {
@@ -31,8 +32,14 @@ func NewFriendRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) FriendRpc
return FriendRpcClient(*NewFriend(discov))
}
-func (f *FriendRpcClient) GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (resp *sdkws.FriendInfo, err error) {
- r, err := f.Client.GetDesignatedFriends(ctx, &friend.GetDesignatedFriendsReq{OwnerUserID: ownerUserID, FriendUserIDs: []string{friendUserID}})
+func (f *FriendRpcClient) GetFriendsInfo(
+ ctx context.Context,
+ ownerUserID, friendUserID string,
+) (resp *sdkws.FriendInfo, err error) {
+ r, err := f.Client.GetDesignatedFriends(
+ ctx,
+ &friend.GetDesignatedFriendsReq{OwnerUserID: ownerUserID, FriendUserIDs: []string{friendUserID}},
+ )
if err != nil {
return nil, err
}
diff --git a/pkg/rpcclient/group.go b/pkg/rpcclient/group.go
index 911887dda..399be6a77 100644
--- a/pkg/rpcclient/group.go
+++ b/pkg/rpcclient/group.go
@@ -4,6 +4,8 @@ import (
"context"
"strings"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
@@ -11,7 +13,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "google.golang.org/grpc"
)
type Group struct {
@@ -35,7 +36,11 @@ func NewGroupRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) GroupRpcCl
return GroupRpcClient(*NewGroup(discov))
}
-func (g *GroupRpcClient) GetGroupInfos(ctx context.Context, groupIDs []string, complete bool) ([]*sdkws.GroupInfo, error) {
+func (g *GroupRpcClient) GetGroupInfos(
+ ctx context.Context,
+ groupIDs []string,
+ complete bool,
+) ([]*sdkws.GroupInfo, error) {
resp, err := g.Client.GetGroupsInfo(ctx, &group.GetGroupsInfoReq{
GroupIDs: groupIDs,
})
@@ -60,7 +65,11 @@ func (g *GroupRpcClient) GetGroupInfo(ctx context.Context, groupID string) (*sdk
return groups[0], nil
}
-func (g *GroupRpcClient) GetGroupInfoMap(ctx context.Context, groupIDs []string, complete bool) (map[string]*sdkws.GroupInfo, error) {
+func (g *GroupRpcClient) GetGroupInfoMap(
+ ctx context.Context,
+ groupIDs []string,
+ complete bool,
+) (map[string]*sdkws.GroupInfo, error) {
groups, err := g.GetGroupInfos(ctx, groupIDs, complete)
if err != nil {
return nil, err
@@ -70,7 +79,12 @@ func (g *GroupRpcClient) GetGroupInfoMap(ctx context.Context, groupIDs []string,
}), nil
}
-func (g *GroupRpcClient) GetGroupMemberInfos(ctx context.Context, groupID string, userIDs []string, complete bool) ([]*sdkws.GroupMemberFullInfo, error) {
+func (g *GroupRpcClient) GetGroupMemberInfos(
+ ctx context.Context,
+ groupID string,
+ userIDs []string,
+ complete bool,
+) ([]*sdkws.GroupMemberFullInfo, error) {
resp, err := g.Client.GetGroupMembersInfo(ctx, &group.GetGroupMembersInfoReq{
GroupID: groupID,
UserIDs: userIDs,
@@ -88,7 +102,11 @@ func (g *GroupRpcClient) GetGroupMemberInfos(ctx context.Context, groupID string
return resp.Members, nil
}
-func (g *GroupRpcClient) GetGroupMemberInfo(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) {
+func (g *GroupRpcClient) GetGroupMemberInfo(
+ ctx context.Context,
+ groupID string,
+ userID string,
+) (*sdkws.GroupMemberFullInfo, error) {
members, err := g.GetGroupMemberInfos(ctx, groupID, []string{userID}, true)
if err != nil {
return nil, err
@@ -96,7 +114,12 @@ func (g *GroupRpcClient) GetGroupMemberInfo(ctx context.Context, groupID string,
return members[0], nil
}
-func (g *GroupRpcClient) GetGroupMemberInfoMap(ctx context.Context, groupID string, userIDs []string, complete bool) (map[string]*sdkws.GroupMemberFullInfo, error) {
+func (g *GroupRpcClient) GetGroupMemberInfoMap(
+ ctx context.Context,
+ groupID string,
+ userIDs []string,
+ complete bool,
+) (map[string]*sdkws.GroupMemberFullInfo, error) {
members, err := g.GetGroupMemberInfos(ctx, groupID, userIDs, true)
if err != nil {
return nil, err
@@ -106,7 +129,10 @@ func (g *GroupRpcClient) GetGroupMemberInfoMap(ctx context.Context, groupID stri
}), nil
}
-func (g *GroupRpcClient) GetOwnerAndAdminInfos(ctx context.Context, groupID string) ([]*sdkws.GroupMemberFullInfo, error) {
+func (g *GroupRpcClient) GetOwnerAndAdminInfos(
+ ctx context.Context,
+ groupID string,
+) ([]*sdkws.GroupMemberFullInfo, error) {
resp, err := g.Client.GetGroupMemberRoleLevel(ctx, &group.GetGroupMemberRoleLevelReq{
GroupID: groupID,
RoleLevels: []int32{constant.GroupOwner, constant.GroupAdmin},
@@ -145,7 +171,11 @@ func (g *GroupRpcClient) GetGroupInfoCache(ctx context.Context, groupID string)
return resp.GroupInfo, nil
}
-func (g *GroupRpcClient) GetGroupMemberCache(ctx context.Context, groupID string, groupMemberID string) (*sdkws.GroupMemberFullInfo, error) {
+func (g *GroupRpcClient) GetGroupMemberCache(
+ ctx context.Context,
+ groupID string,
+ groupMemberID string,
+) (*sdkws.GroupMemberFullInfo, error) {
resp, err := g.Client.GetGroupMemberCache(ctx, &group.GetGroupMemberCacheReq{
GroupID: groupID,
GroupMemberID: groupMemberID,
diff --git a/pkg/rpcclient/msg.go b/pkg/rpcclient/msg.go
index 8c08d0db4..43f30361a 100644
--- a/pkg/rpcclient/msg.go
+++ b/pkg/rpcclient/msg.go
@@ -4,6 +4,9 @@ import (
"context"
"encoding/json"
+ "google.golang.org/grpc"
+ "google.golang.org/protobuf/proto"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
@@ -11,8 +14,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "google.golang.org/grpc"
- "google.golang.org/protobuf/proto"
// "google.golang.org/protobuf/proto"
)
@@ -134,7 +135,10 @@ func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqRe
return resp, err
}
-func (m *MessageRpcClient) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
+func (m *MessageRpcClient) PullMessageBySeqList(
+ ctx context.Context,
+ req *sdkws.PullMessageBySeqsReq,
+) (*sdkws.PullMessageBySeqsResp, error) {
resp, err := m.Client.PullMessageBySeqs(ctx, req)
return resp, err
}
@@ -155,7 +159,9 @@ type NotificationSender struct {
type NewNotificationSenderOptions func(*NotificationSender)
-func WithLocalSendMsg(sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error)) NewNotificationSenderOptions {
+func WithLocalSendMsg(
+ sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error),
+) NewNotificationSenderOptions {
return func(s *NotificationSender) {
s.sendMsg = sendMsg
}
@@ -168,18 +174,39 @@ func WithRpcClient(msgRpcClient *MessageRpcClient) NewNotificationSenderOptions
}
func NewNotificationSender(opts ...NewNotificationSenderOptions) *NotificationSender {
- notificationSender := &NotificationSender{contentTypeConf: newContentTypeConf(), sessionTypeConf: newSessionTypeConf()}
+ notificationSender := &NotificationSender{
+ contentTypeConf: newContentTypeConf(),
+ sessionTypeConf: newSessionTypeConf(),
+ }
for _, opt := range opts {
opt(notificationSender)
}
return notificationSender
}
-func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string, contentType, sesstionType int32, m proto.Message, opts ...utils.OptionsOpt) (err error) {
+func (s *NotificationSender) NotificationWithSesstionType(
+ ctx context.Context,
+ sendID, recvID string,
+ contentType, sesstionType int32,
+ m proto.Message,
+ opts ...utils.OptionsOpt,
+) (err error) {
n := sdkws.NotificationElem{Detail: utils.StructToJsonString(m)}
content, err := json.Marshal(&n)
if err != nil {
- log.ZError(ctx, "MsgClient Notification json.Marshal failed", err, "sendID", sendID, "recvID", recvID, "contentType", contentType, "msg", m)
+ log.ZError(
+ ctx,
+ "MsgClient Notification json.Marshal failed",
+ err,
+ "sendID",
+ sendID,
+ "recvID",
+ recvID,
+ "contentType",
+ contentType,
+ "msg",
+ m,
+ )
return err
}
var req msg.SendMsgReq
@@ -214,6 +241,12 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
return err
}
-func (s *NotificationSender) Notification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message, opts ...utils.OptionsOpt) error {
+func (s *NotificationSender) Notification(
+ ctx context.Context,
+ sendID, recvID string,
+ contentType int32,
+ m proto.Message,
+ opts ...utils.OptionsOpt,
+) error {
return s.NotificationWithSesstionType(ctx, sendID, recvID, contentType, s.sessionTypeConf[contentType], m, opts...)
}
diff --git a/pkg/rpcclient/notification/conevrsation.go b/pkg/rpcclient/notification/conevrsation.go
index cc30f46f3..8fb11ba97 100644
--- a/pkg/rpcclient/notification/conevrsation.go
+++ b/pkg/rpcclient/notification/conevrsation.go
@@ -17,7 +17,11 @@ func NewConversationNotificationSender(msgRpcClient *rpcclient.MessageRpcClient)
}
// SetPrivate调用
-func (c *ConversationNotificationSender) ConversationSetPrivateNotification(ctx context.Context, sendID, recvID string, isPrivateChat bool) error {
+func (c *ConversationNotificationSender) ConversationSetPrivateNotification(
+ ctx context.Context,
+ sendID, recvID string,
+ isPrivateChat bool,
+) error {
tips := &sdkws.ConversationSetPrivateTips{
RecvID: recvID,
SendID: sendID,
@@ -35,7 +39,11 @@ func (c *ConversationNotificationSender) ConversationChangeNotification(ctx cont
}
// 会话未读数同步
-func (c *ConversationNotificationSender) ConversationUnreadChangeNotification(ctx context.Context, userID, conversationID string, unreadCountTime, hasReadSeq int64) error {
+func (c *ConversationNotificationSender) ConversationUnreadChangeNotification(
+ ctx context.Context,
+ userID, conversationID string,
+ unreadCountTime, hasReadSeq int64,
+) error {
tips := &sdkws.ConversationHasReadTips{
UserID: userID,
ConversationID: conversationID,
diff --git a/pkg/rpcclient/notification/extend_msg.go b/pkg/rpcclient/notification/extend_msg.go
index e71ada3e1..1bef5c9b4 100644
--- a/pkg/rpcclient/notification/extend_msg.go
+++ b/pkg/rpcclient/notification/extend_msg.go
@@ -4,6 +4,8 @@ import (
"context"
"encoding/json"
+ "google.golang.org/protobuf/proto"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
@@ -12,7 +14,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "google.golang.org/protobuf/proto"
)
type ExtendMsgNotificationSender struct {
@@ -23,8 +24,16 @@ func NewExtendMsgNotificationSender(client discoveryregistry.SvcDiscoveryRegistr
return &ExtendMsgNotificationSender{}
}
-func (e *ExtendMsgNotificationSender) ExtendMessageUpdatedNotification(ctx context.Context, sendID string, conversationID string, sessionType int32,
- req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
+func (e *ExtendMsgNotificationSender) ExtendMessageUpdatedNotification(
+ ctx context.Context,
+ sendID string,
+ conversationID string,
+ sessionType int32,
+ req *msg.SetMessageReactionExtensionsReq,
+ resp *msg.SetMessageReactionExtensionsResp,
+ isHistory bool,
+ isReactionFromCache bool,
+) {
var content sdkws.ReactionMessageModifierNotification
content.ConversationID = req.ConversationID
content.OpUserID = mcontext.GetOpUserID(ctx)
@@ -43,10 +52,28 @@ func (e *ExtendMsgNotificationSender) ExtendMessageUpdatedNotification(ctx conte
content.IsReact = resp.IsReact
content.IsExternalExtensions = req.IsExternalExtensions
content.MsgFirstModifyTime = resp.MsgFirstModifyTime
- e.messageReactionSender(ctx, sendID, conversationID, sessionType, constant.ReactionMessageModifier, &content, isHistory, isReactionFromCache)
+ e.messageReactionSender(
+ ctx,
+ sendID,
+ conversationID,
+ sessionType,
+ constant.ReactionMessageModifier,
+ &content,
+ isHistory,
+ isReactionFromCache,
+ )
}
-func (e *ExtendMsgNotificationSender) ExtendMessageDeleteNotification(ctx context.Context, sendID string, conversationID string, sessionType int32,
- req *msg.DeleteMessagesReactionExtensionsReq, resp *msg.DeleteMessagesReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
+
+func (e *ExtendMsgNotificationSender) ExtendMessageDeleteNotification(
+ ctx context.Context,
+ sendID string,
+ conversationID string,
+ sessionType int32,
+ req *msg.DeleteMessagesReactionExtensionsReq,
+ resp *msg.DeleteMessagesReactionExtensionsResp,
+ isHistory bool,
+ isReactionFromCache bool,
+) {
var content sdkws.ReactionMessageDeleteNotification
content.ConversationID = req.ConversationID
content.OpUserID = req.OpUserID
@@ -63,9 +90,27 @@ func (e *ExtendMsgNotificationSender) ExtendMessageDeleteNotification(ctx contex
content.SuccessReactionExtensions = keyMap
content.ClientMsgID = req.ClientMsgID
content.MsgFirstModifyTime = req.MsgFirstModifyTime
- e.messageReactionSender(ctx, sendID, conversationID, sessionType, constant.ReactionMessageDeleter, &content, isHistory, isReactionFromCache)
+ e.messageReactionSender(
+ ctx,
+ sendID,
+ conversationID,
+ sessionType,
+ constant.ReactionMessageDeleter,
+ &content,
+ isHistory,
+ isReactionFromCache,
+ )
}
-func (e *ExtendMsgNotificationSender) messageReactionSender(ctx context.Context, sendID string, conversationID string, sessionType, contentType int32, m proto.Message, isHistory bool, isReactionFromCache bool) error {
+
+func (e *ExtendMsgNotificationSender) messageReactionSender(
+ ctx context.Context,
+ sendID string,
+ conversationID string,
+ sessionType, contentType int32,
+ m proto.Message,
+ isHistory bool,
+ isReactionFromCache bool,
+) error {
options := make(map[string]bool, 5)
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
diff --git a/pkg/rpcclient/notification/friend.go b/pkg/rpcclient/notification/friend.go
index 18f72203f..495238b03 100644
--- a/pkg/rpcclient/notification/friend.go
+++ b/pkg/rpcclient/notification/friend.go
@@ -30,7 +30,9 @@ func WithFriendDB(db controller.FriendDatabase) friendNotificationSenderOptions
}
}
-func WithDBFunc(fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error)) friendNotificationSenderOptions {
+func WithDBFunc(
+ fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error),
+) friendNotificationSenderOptions {
return func(s *FriendNotificationSender) {
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
users, err := fn(ctx, userIDs)
@@ -46,7 +48,9 @@ func WithDBFunc(fn func(ctx context.Context, userIDs []string) (users []*relatio
}
}
-func WithRpcFunc(fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error)) friendNotificationSenderOptions {
+func WithRpcFunc(
+ fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error),
+) friendNotificationSenderOptions {
return func(s *FriendNotificationSender) {
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
users, err := fn(ctx, userIDs)
@@ -62,7 +66,10 @@ func WithRpcFunc(fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserIn
}
}
-func NewFriendNotificationSender(msgRpcClient *rpcclient.MessageRpcClient, opts ...friendNotificationSenderOptions) *FriendNotificationSender {
+func NewFriendNotificationSender(
+ msgRpcClient *rpcclient.MessageRpcClient,
+ opts ...friendNotificationSenderOptions,
+) *FriendNotificationSender {
f := &FriendNotificationSender{
NotificationSender: rpcclient.NewNotificationSender(rpcclient.WithRpcClient(msgRpcClient)),
}
@@ -72,7 +79,10 @@ func NewFriendNotificationSender(msgRpcClient *rpcclient.MessageRpcClient, opts
return f
}
-func (f *FriendNotificationSender) getUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
+func (f *FriendNotificationSender) getUsersInfoMap(
+ ctx context.Context,
+ userIDs []string,
+) (map[string]*sdkws.UserInfo, error) {
users, err := f.getUsersInfo(ctx, userIDs)
if err != nil {
return nil, err
@@ -84,7 +94,10 @@ func (f *FriendNotificationSender) getUsersInfoMap(ctx context.Context, userIDs
return result, nil
}
-func (f *FriendNotificationSender) getFromToUserNickname(ctx context.Context, fromUserID, toUserID string) (string, string, error) {
+func (f *FriendNotificationSender) getFromToUserNickname(
+ ctx context.Context,
+ fromUserID, toUserID string,
+) (string, string, error) {
users, err := f.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
if err != nil {
return "", "", nil
@@ -97,7 +110,10 @@ func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Conte
return f.Notification(ctx, mcontext.GetOpUserID(ctx), changedUserID, constant.UserInfoUpdatedNotification, &tips)
}
-func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) error {
+func (f *FriendNotificationSender) FriendApplicationAddNotification(
+ ctx context.Context,
+ req *pbFriend.ApplyToAddFriendReq,
+) error {
tips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
@@ -105,7 +121,10 @@ func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.
return f.Notification(ctx, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &tips)
}
-func (c *FriendNotificationSender) FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) error {
+func (c *FriendNotificationSender) FriendApplicationAgreedNotification(
+ ctx context.Context,
+ req *pbFriend.RespondFriendApplyReq,
+) error {
tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
@@ -113,7 +132,10 @@ func (c *FriendNotificationSender) FriendApplicationAgreedNotification(ctx conte
return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips)
}
-func (c *FriendNotificationSender) FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) error {
+func (c *FriendNotificationSender) FriendApplicationRefusedNotification(
+ ctx context.Context,
+ req *pbFriend.RespondFriendApplyReq,
+) error {
tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
@@ -121,7 +143,10 @@ func (c *FriendNotificationSender) FriendApplicationRefusedNotification(ctx cont
return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &tips)
}
-func (c *FriendNotificationSender) FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) error {
+func (c *FriendNotificationSender) FriendAddedNotification(
+ ctx context.Context,
+ operationID, opUserID, fromUserID, toUserID string,
+) error {
tips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}}
user, err := c.getUsersInfo(ctx, []string{opUserID})
if err != nil {
@@ -172,7 +197,11 @@ func (c *FriendNotificationSender) BlackDeletedNotification(ctx context.Context,
c.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
}
-func (c *FriendNotificationSender) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string) {
+func (c *FriendNotificationSender) FriendInfoUpdatedNotification(
+ ctx context.Context,
+ changedUserID string,
+ needNotifiedUserID string,
+) {
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
c.Notification(ctx, mcontext.GetOpUserID(ctx), needNotifiedUserID, constant.FriendInfoUpdatedNotification, &tips)
}
diff --git a/pkg/rpcclient/notification/group.go b/pkg/rpcclient/notification/group.go
index 5175f3740..f93f0786a 100644
--- a/pkg/rpcclient/notification/group.go
+++ b/pkg/rpcclient/notification/group.go
@@ -16,7 +16,11 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
-func NewGroupNotificationSender(db controller.GroupDatabase, msgRpcClient *rpcclient.MessageRpcClient, fn func(ctx context.Context, userIDs []string) ([]CommonUser, error)) *GroupNotificationSender {
+func NewGroupNotificationSender(
+ db controller.GroupDatabase,
+ msgRpcClient *rpcclient.MessageRpcClient,
+ fn func(ctx context.Context, userIDs []string) ([]CommonUser, error),
+) *GroupNotificationSender {
return &GroupNotificationSender{
NotificationSender: rpcclient.NewNotificationSender(rpcclient.WithRpcClient(msgRpcClient)),
getUsersInfo: fn,
@@ -80,7 +84,11 @@ func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID stri
}, nil
}
-func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID string, userIDs []string) ([]*sdkws.GroupMemberFullInfo, error) {
+func (g *GroupNotificationSender) getGroupMembers(
+ ctx context.Context,
+ groupID string,
+ userIDs []string,
+) ([]*sdkws.GroupMemberFullInfo, error) {
members, err := g.db.FindGroupMember(ctx, []string{groupID}, userIDs, nil)
if err != nil {
return nil, err
@@ -95,7 +103,9 @@ func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID s
for _, member := range members {
user, ok := users[member.UserID]
if !ok {
- return nil, errs.ErrUserIDNotFound.Wrap(fmt.Sprintf("group %s member %s not in user", member.GroupID, member.UserID))
+ return nil, errs.ErrUserIDNotFound.Wrap(
+ fmt.Sprintf("group %s member %s not in user", member.GroupID, member.UserID),
+ )
}
if member.Nickname == "" {
member.Nickname = user.Nickname
@@ -117,7 +127,11 @@ func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID s
return res, nil
}
-func (g *GroupNotificationSender) getGroupMemberMap(ctx context.Context, groupID string, userIDs []string) (map[string]*sdkws.GroupMemberFullInfo, error) {
+func (g *GroupNotificationSender) getGroupMemberMap(
+ ctx context.Context,
+ groupID string,
+ userIDs []string,
+) (map[string]*sdkws.GroupMemberFullInfo, error) {
members, err := g.getGroupMembers(ctx, groupID, userIDs)
if err != nil {
return nil, err
@@ -129,7 +143,11 @@ func (g *GroupNotificationSender) getGroupMemberMap(ctx context.Context, groupID
return m, nil
}
-func (g *GroupNotificationSender) getGroupMember(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) {
+func (g *GroupNotificationSender) getGroupMember(
+ ctx context.Context,
+ groupID string,
+ userID string,
+) (*sdkws.GroupMemberFullInfo, error) {
members, err := g.getGroupMembers(ctx, groupID, []string{userID})
if err != nil {
return nil, err
@@ -149,7 +167,11 @@ func (g *GroupNotificationSender) getGroupOwnerAndAdminUserID(ctx context.Contex
return utils.Slice(members, fn), nil
}
-func (g *GroupNotificationSender) groupDB2PB(group *relation.GroupModel, ownerUserID string, memberCount uint32) *sdkws.GroupInfo {
+func (g *GroupNotificationSender) groupDB2PB(
+ group *relation.GroupModel,
+ ownerUserID string,
+ memberCount uint32,
+) *sdkws.GroupInfo {
return &sdkws.GroupInfo{
GroupID: group.GroupID,
GroupName: group.GroupName,
@@ -171,7 +193,10 @@ func (g *GroupNotificationSender) groupDB2PB(group *relation.GroupModel, ownerUs
}
}
-func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberModel, appMangerLevel int32) *sdkws.GroupMemberFullInfo {
+func (g *GroupNotificationSender) groupMemberDB2PB(
+ member *relation.GroupMemberModel,
+ appMangerLevel int32,
+) *sdkws.GroupMemberFullInfo {
return &sdkws.GroupMemberFullInfo{
GroupID: member.GroupID,
UserID: member.UserID,
@@ -188,7 +213,10 @@ func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberM
}
}
-func (g *GroupNotificationSender) getUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
+func (g *GroupNotificationSender) getUsersInfoMap(
+ ctx context.Context,
+ userIDs []string,
+) (map[string]*sdkws.UserInfo, error) {
users, err := g.getUsersInfo(ctx, userIDs)
if err != nil {
return nil, err
@@ -200,7 +228,11 @@ func (g *GroupNotificationSender) getUsersInfoMap(ctx context.Context, userIDs [
return result, nil
}
-func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws.GroupMemberFullInfo, groupID string) error {
+func (g *GroupNotificationSender) fillOpUser(
+ ctx context.Context,
+ opUser **sdkws.GroupMemberFullInfo,
+ groupID string,
+) error {
if opUser == nil {
return errs.ErrInternalServer.Wrap("**sdkws.GroupMemberFullInfo is nil")
}
@@ -239,35 +271,62 @@ func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws
return nil
}
-func (g *GroupNotificationSender) GroupCreatedNotification(ctx context.Context, tips *sdkws.GroupCreatedTips) (err error) {
+func (g *GroupNotificationSender) GroupCreatedNotification(
+ ctx context.Context,
+ tips *sdkws.GroupCreatedTips,
+) (err error) {
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupCreatedNotification, tips)
}
-func (g *GroupNotificationSender) GroupInfoSetNotification(ctx context.Context, tips *sdkws.GroupInfoSetTips) (err error) {
+func (g *GroupNotificationSender) GroupInfoSetNotification(
+ ctx context.Context,
+ tips *sdkws.GroupInfoSetTips,
+) (err error) {
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNotification, tips)
}
-func (g *GroupNotificationSender) GroupInfoSetNameNotification(ctx context.Context, tips *sdkws.GroupInfoSetNameTips) (err error) {
+func (g *GroupNotificationSender) GroupInfoSetNameNotification(
+ ctx context.Context,
+ tips *sdkws.GroupInfoSetNameTips,
+) (err error) {
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
- return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNameNotification, tips)
+ return g.Notification(
+ ctx,
+ mcontext.GetOpUserID(ctx),
+ tips.Group.GroupID,
+ constant.GroupInfoSetNameNotification,
+ tips,
+ )
}
-func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(ctx context.Context, tips *sdkws.GroupInfoSetAnnouncementTips) (err error) {
+func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(
+ ctx context.Context,
+ tips *sdkws.GroupInfoSetAnnouncementTips,
+) (err error) {
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
- return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips)
+ return g.Notification(
+ ctx,
+ mcontext.GetOpUserID(ctx),
+ tips.Group.GroupID,
+ constant.GroupInfoSetAnnouncementNotification,
+ tips,
+ )
}
-func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) (err error) {
+func (g *GroupNotificationSender) JoinGroupApplicationNotification(
+ ctx context.Context,
+ req *pbGroup.JoinGroupReq,
+) (err error) {
group, err := g.getGroupInfo(ctx, req.GroupID)
if err != nil {
return err
@@ -291,7 +350,10 @@ func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.C
return nil
}
-func (g *GroupNotificationSender) MemberQuitNotification(ctx context.Context, member *sdkws.GroupMemberFullInfo) (err error) {
+func (g *GroupNotificationSender) MemberQuitNotification(
+ ctx context.Context,
+ member *sdkws.GroupMemberFullInfo,
+) (err error) {
defer log.ZDebug(ctx, "return")
defer func() {
if err != nil {
@@ -306,7 +368,10 @@ func (g *GroupNotificationSender) MemberQuitNotification(ctx context.Context, me
return g.Notification(ctx, mcontext.GetOpUserID(ctx), member.GroupID, constant.MemberQuitNotification, tips)
}
-func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
+func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(
+ ctx context.Context,
+ req *pbGroup.GroupApplicationResponseReq,
+) (err error) {
defer log.ZDebug(ctx, "return")
defer func() {
if err != nil {
@@ -326,7 +391,13 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
return err
}
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
- err = g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationAcceptedNotification, tips)
+ err = g.Notification(
+ ctx,
+ mcontext.GetOpUserID(ctx),
+ userID,
+ constant.GroupApplicationAcceptedNotification,
+ tips,
+ )
if err != nil {
log.ZError(ctx, "failed", err)
}
@@ -334,7 +405,10 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
return nil
}
-func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
+func (g *GroupNotificationSender) GroupApplicationRejectedNotification(
+ ctx context.Context,
+ req *pbGroup.GroupApplicationResponseReq,
+) (err error) {
group, err := g.getGroupInfo(ctx, req.GroupID)
if err != nil {
return err
@@ -348,7 +422,13 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
return err
}
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
- err = g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationRejectedNotification, tips)
+ err = g.Notification(
+ ctx,
+ mcontext.GetOpUserID(ctx),
+ userID,
+ constant.GroupApplicationRejectedNotification,
+ tips,
+ )
if err != nil {
log.ZError(ctx, "failed", err)
}
@@ -356,7 +436,10 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
return nil
}
-func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) (err error) {
+func (g *GroupNotificationSender) GroupOwnerTransferredNotification(
+ ctx context.Context,
+ req *pbGroup.TransferGroupOwnerReq,
+) (err error) {
group, err := g.getGroupInfo(ctx, req.GroupID)
if err != nil {
return err
@@ -366,21 +449,38 @@ func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.
if err != nil {
return err
}
- tips := &sdkws.GroupOwnerTransferredTips{Group: group, OpUser: member[opUserID], NewGroupOwner: member[req.NewOwnerUserID]}
+ tips := &sdkws.GroupOwnerTransferredTips{
+ Group: group,
+ OpUser: member[opUserID],
+ NewGroupOwner: member[req.NewOwnerUserID],
+ }
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
- return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupOwnerTransferredNotification, tips)
+ return g.Notification(
+ ctx,
+ mcontext.GetOpUserID(ctx),
+ group.GroupID,
+ constant.GroupOwnerTransferredNotification,
+ tips,
+ )
}
-func (g *GroupNotificationSender) MemberKickedNotification(ctx context.Context, tips *sdkws.MemberKickedTips) (err error) {
+func (g *GroupNotificationSender) MemberKickedNotification(
+ ctx context.Context,
+ tips *sdkws.MemberKickedTips,
+) (err error) {
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.MemberKickedNotification, tips)
}
-func (g *GroupNotificationSender) MemberInvitedNotification(ctx context.Context, groupID, reason string, invitedUserIDList []string) (err error) {
+func (g *GroupNotificationSender) MemberInvitedNotification(
+ ctx context.Context,
+ groupID, reason string,
+ invitedUserIDList []string,
+) (err error) {
group, err := g.getGroupInfo(ctx, groupID)
if err != nil {
return err
@@ -399,7 +499,10 @@ func (g *GroupNotificationSender) MemberInvitedNotification(ctx context.Context,
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberInvitedNotification, tips)
}
-func (g *GroupNotificationSender) MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
+func (g *GroupNotificationSender) MemberEnterNotification(
+ ctx context.Context,
+ req *pbGroup.GroupApplicationResponseReq,
+) (err error) {
group, err := g.getGroupInfo(ctx, req.GroupID)
if err != nil {
return err
@@ -412,14 +515,21 @@ func (g *GroupNotificationSender) MemberEnterNotification(ctx context.Context, r
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberEnterNotification, tips)
}
-func (g *GroupNotificationSender) GroupDismissedNotification(ctx context.Context, tips *sdkws.GroupDismissedTips) (err error) {
+func (g *GroupNotificationSender) GroupDismissedNotification(
+ ctx context.Context,
+ tips *sdkws.GroupDismissedTips,
+) (err error) {
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupDismissedNotification, tips)
}
-func (g *GroupNotificationSender) GroupMemberMutedNotification(ctx context.Context, groupID, groupMemberUserID string, mutedSeconds uint32) (err error) {
+func (g *GroupNotificationSender) GroupMemberMutedNotification(
+ ctx context.Context,
+ groupID, groupMemberUserID string,
+ mutedSeconds uint32,
+) (err error) {
group, err := g.getGroupInfo(ctx, groupID)
if err != nil {
return err
@@ -436,7 +546,10 @@ func (g *GroupNotificationSender) GroupMemberMutedNotification(ctx context.Conte
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberMutedNotification, tips)
}
-func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
+func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(
+ ctx context.Context,
+ groupID, groupMemberUserID string,
+) (err error) {
group, err := g.getGroupInfo(ctx, groupID)
if err != nil {
return err
@@ -445,11 +558,21 @@ func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(ctx context
if err != nil {
return err
}
- tips := &sdkws.GroupMemberCancelMutedTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], MutedUser: user[groupMemberUserID]}
+ tips := &sdkws.GroupMemberCancelMutedTips{
+ Group: group,
+ OpUser: user[mcontext.GetOpUserID(ctx)],
+ MutedUser: user[groupMemberUserID],
+ }
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
- return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberCancelMutedNotification, tips)
+ return g.Notification(
+ ctx,
+ mcontext.GetOpUserID(ctx),
+ group.GroupID,
+ constant.GroupMemberCancelMutedNotification,
+ tips,
+ )
}
func (g *GroupNotificationSender) GroupMutedNotification(ctx context.Context, groupID string) (err error) {
@@ -490,7 +613,10 @@ func (g *GroupNotificationSender) GroupCancelMutedNotification(ctx context.Conte
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupCancelMutedNotification, tips)
}
-func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
+func (g *GroupNotificationSender) GroupMemberInfoSetNotification(
+ ctx context.Context,
+ groupID, groupMemberUserID string,
+) (err error) {
group, err := g.getGroupInfo(ctx, groupID)
if err != nil {
return err
@@ -499,14 +625,21 @@ func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Con
if err != nil {
return err
}
- tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
+ tips := &sdkws.GroupMemberInfoSetTips{
+ Group: group,
+ OpUser: user[mcontext.GetOpUserID(ctx)],
+ ChangedUser: user[groupMemberUserID],
+ }
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberInfoSetNotification, tips)
}
-func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
+func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(
+ ctx context.Context,
+ groupID, groupMemberUserID string,
+) (err error) {
group, err := g.getGroupInfo(ctx, groupID)
if err != nil {
return err
@@ -515,14 +648,27 @@ func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(ctx context.
if err != nil {
return err
}
- tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
+ tips := &sdkws.GroupMemberInfoSetTips{
+ Group: group,
+ OpUser: user[mcontext.GetOpUserID(ctx)],
+ ChangedUser: user[groupMemberUserID],
+ }
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
- return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToAdminNotification, tips)
+ return g.Notification(
+ ctx,
+ mcontext.GetOpUserID(ctx),
+ group.GroupID,
+ constant.GroupMemberSetToAdminNotification,
+ tips,
+ )
}
-func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
+func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(
+ ctx context.Context,
+ groupID, groupMemberUserID string,
+) (err error) {
group, err := g.getGroupInfo(ctx, groupID)
if err != nil {
return err
@@ -531,14 +677,28 @@ func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx c
if err != nil {
return err
}
- tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
+ tips := &sdkws.GroupMemberInfoSetTips{
+ Group: group,
+ OpUser: user[mcontext.GetOpUserID(ctx)],
+ ChangedUser: user[groupMemberUserID],
+ }
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
- return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToOrdinaryUserNotification, tips)
+ return g.Notification(
+ ctx,
+ mcontext.GetOpUserID(ctx),
+ group.GroupID,
+ constant.GroupMemberSetToOrdinaryUserNotification,
+ tips,
+ )
}
-func (g *GroupNotificationSender) MemberEnterDirectlyNotification(ctx context.Context, groupID string, entrantUserID string) (err error) {
+func (g *GroupNotificationSender) MemberEnterDirectlyNotification(
+ ctx context.Context,
+ groupID string,
+ entrantUserID string,
+) (err error) {
defer log.ZDebug(ctx, "return")
defer func() {
if err != nil {
diff --git a/pkg/rpcclient/push.go b/pkg/rpcclient/push.go
index 8ac20b943..5359c31ee 100644
--- a/pkg/rpcclient/push.go
+++ b/pkg/rpcclient/push.go
@@ -3,10 +3,11 @@ package rpcclient
import (
"context"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/push"
- "google.golang.org/grpc"
)
type Push struct {
@@ -33,6 +34,9 @@ func NewPushRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) PushRpcClie
return PushRpcClient(*NewPush(discov))
}
-func (p *PushRpcClient) DelUserPushToken(ctx context.Context, req *push.DelUserPushTokenReq) (*push.DelUserPushTokenResp, error) {
+func (p *PushRpcClient) DelUserPushToken(
+ ctx context.Context,
+ req *push.DelUserPushTokenReq,
+) (*push.DelUserPushTokenResp, error) {
return p.Client.DelUserPushToken(ctx, req)
}
diff --git a/pkg/rpcclient/third.go b/pkg/rpcclient/third.go
index 46c5e1b92..c657c02a1 100644
--- a/pkg/rpcclient/third.go
+++ b/pkg/rpcclient/third.go
@@ -3,10 +3,11 @@ package rpcclient
import (
"context"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
- "google.golang.org/grpc"
)
type Third struct {
diff --git a/pkg/rpcclient/user.go b/pkg/rpcclient/user.go
index dabc2bdf4..383d0cc67 100644
--- a/pkg/rpcclient/user.go
+++ b/pkg/rpcclient/user.go
@@ -5,6 +5,8 @@ import (
"strings"
"time"
+ "google.golang.org/grpc"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
@@ -12,7 +14,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- "google.golang.org/grpc"
)
type User struct {
@@ -70,7 +71,11 @@ func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (
}), nil
}
-func (u *UserRpcClient) GetPublicUserInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.PublicUserInfo, error) {
+func (u *UserRpcClient) GetPublicUserInfos(
+ ctx context.Context,
+ userIDs []string,
+ complete bool,
+) ([]*sdkws.PublicUserInfo, error) {
users, err := u.GetUsersInfo(ctx, userIDs)
if err != nil {
return nil, err
@@ -93,7 +98,11 @@ func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*
return users[0], nil
}
-func (u *UserRpcClient) GetPublicUserInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.PublicUserInfo, error) {
+func (u *UserRpcClient) GetPublicUserInfoMap(
+ ctx context.Context,
+ userIDs []string,
+ complete bool,
+) (map[string]*sdkws.PublicUserInfo, error) {
users, err := u.GetPublicUserInfos(ctx, userIDs, complete)
if err != nil {
return nil, err
diff --git a/pkg/startrpc/start.go b/pkg/startrpc/start.go
index c7490f4e0..de5be74e5 100644
--- a/pkg/startrpc/start.go
+++ b/pkg/startrpc/start.go
@@ -6,6 +6,10 @@ import (
"strconv"
"time"
+ grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/credentials/insecure"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw"
@@ -14,21 +18,38 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
- grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
- "google.golang.org/grpc"
- "google.golang.org/grpc/credentials/insecure"
)
-func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error {
- fmt.Println("start", rpcRegisterName, "server, port: ", rpcPort, "prometheusPort:", prometheusPort, ", OpenIM version: ", config.Version)
- listener, err := net.Listen("tcp", net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)))
+func Start(
+ rpcPort int,
+ rpcRegisterName string,
+ prometheusPort int,
+ rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error,
+ options ...grpc.ServerOption,
+) error {
+ fmt.Println(
+ "start",
+ rpcRegisterName,
+ "server, port: ",
+ rpcPort,
+ "prometheusPort:",
+ prometheusPort,
+ ", OpenIM version: ",
+ config.Version,
+ )
+ listener, err := net.Listen(
+ "tcp",
+ net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)),
+ )
if err != nil {
return err
}
defer listener.Close()
zkClient, 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()))
+ 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 {
return utils.Wrap1(err)
}
@@ -57,7 +78,12 @@ func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c
if err != nil {
return utils.Wrap1(err)
}
- err = zkClient.Register(rpcRegisterName, registerIP, rpcPort, grpc.WithTransportCredentials(insecure.NewCredentials()))
+ err = zkClient.Register(
+ rpcRegisterName,
+ registerIP,
+ rpcPort,
+ grpc.WithTransportCredentials(insecure.NewCredentials()),
+ )
if err != nil {
return utils.Wrap1(err)
}
diff --git a/pkg/statistics/statistics.go b/pkg/statistics/statistics.go
index 3ec3c6aa8..87cba474c 100644
--- a/pkg/statistics/statistics.go
+++ b/pkg/statistics/statistics.go
@@ -31,7 +31,21 @@ func (s *Statistics) output() {
intervalCount = *s.AllCount - sum
}
timeIntervalNum++
- log.ZWarn(context.Background(), " system stat ", nil, "args", s.PrintArgs, "intervalCount", intervalCount, "total:", *s.AllCount, "intervalNum", timeIntervalNum, "avg", (*s.AllCount)/(timeIntervalNum)/s.SleepTime)
+ log.ZWarn(
+ context.Background(),
+ " system stat ",
+ nil,
+ "args",
+ s.PrintArgs,
+ "intervalCount",
+ intervalCount,
+ "total:",
+ *s.AllCount,
+ "intervalNum",
+ timeIntervalNum,
+ "avg",
+ (*s.AllCount)/(timeIntervalNum)/s.SleepTime,
+ )
}
}
diff --git a/pkg/utils/callback.go b/pkg/utils/callback.go
index 313619191..139d166c0 100644
--- a/pkg/utils/callback.go
+++ b/pkg/utils/callback.go
@@ -1,9 +1,10 @@
package utils
import (
+ "google.golang.org/protobuf/proto"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
- "google.golang.org/protobuf/proto"
)
func GetContent(msg *sdkws.MsgData) string {
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go
index b15cb025d..1138313d2 100644
--- a/pkg/utils/utils.go
+++ b/pkg/utils/utils.go
@@ -9,12 +9,13 @@ import (
"strings"
"time"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
- sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"google.golang.org/protobuf/proto"
+
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
+ sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
)
// copy a by b b->a
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index b12ad0c93..f9a73b5bd 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -131,8 +131,7 @@ go.build.multiarch: go.build.verify $(foreach p,$(PLATFORMS),$(addprefix go.buil
.PHONY: go.lint
go.lint: tools.verify.golangci-lint
@echo "===========> Run golangci to lint source codes"
- @$(TOOLS_BIN)/golangci-lint run -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/...
-
+ @$(TOOLS_DIR)/golangci-lint run --color always -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/...
## go.test: Run unit test
.PHONY: go.test
go.test:
diff --git a/test/mongo/cmd/main.go b/test/mongo/cmd/main.go
index 3e4017960..7873fee90 100644
--- a/test/mongo/cmd/main.go
+++ b/test/mongo/cmd/main.go
@@ -28,7 +28,8 @@ import (
func init() {
uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
if config.Config.Mongo.DBUri != "" {
- // example: mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$DBMaxPoolSize
+ // example:
+ // mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$DBMaxPoolSize
uri = config.Config.Mongo.DBUri
} else {
if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" {
From cf6f7be56f9c6e7c0288ad7819a7ad3eb010d072 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Mon, 3 Jul 2023 17:24:18 +0800
Subject: [PATCH 04/73] feat: add code ql system
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.github/workflows/codeql-analysis.yml | 105 ++++++++++++++------------
1 file changed, 55 insertions(+), 50 deletions(-)
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 38508b770..6233ffcad 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -1,71 +1,76 @@
-# For most projects, this workflow file will not need changing; you simply need
-# to commit it to your repository.
+# Copyright © 2023 OpenIM open source community. All rights reserved.
#
-# You may wish to alter this file to override the set of languages analyzed,
-# or to provide custom queries or build logic.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
#
-# ******** NOTE ********
-# We have attempted to detect the languages in your repository. Please check
-# the `language` matrix defined below to confirm you have the correct set of
-# supported CodeQL languages.
+# http://www.apache.org/licenses/LICENSE-2.0
#
-name: "CodeQL"
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+name: "Code Scanning - Action"
on:
push:
- branches: [ main ]
+ branches: [main]
pull_request:
- # The branches below must be a subset of the branches above
- branches: "*"
-# schedule:
-# - cron: '23 2 * * 2'
+ branches: [main]
+ schedule:
+ # ┌───────────── minute (0 - 59)
+ # │ ┌───────────── hour (0 - 23)
+ # │ │ ┌───────────── day of the month (1 - 31)
+ # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
+ # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
+ # │ │ │ │ │
+ # │ │ │ │ │
+ # │ │ │ │ │
+ # * * * * *
+ - cron: '30 1 * * 0'
jobs:
- analyze:
- name: Analyze
+ CodeQL-Build:
+ # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest
+
permissions:
- actions: read
- contents: read
+ # required for all workflows
security-events: write
- strategy:
- fail-fast: false
- matrix:
- language: [ 'go' ]
- # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
- # Learn more:
- # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
+ # only required for workflows in private repositories
+ actions: read
+ contents: read
steps:
- - name: Checkout repository
- uses: actions/checkout@v2
+ - name: Checkout repository
+ uses: actions/checkout@v3
- # Initializes the CodeQL tools for scanning.
- - name: Initialize CodeQL
- uses: github/codeql-action/init@v1
- with:
- languages: ${{ matrix.language }}
- # If you wish to specify custom queries, you can do so here or in a config file.
- # By default, queries listed here will override any specified in a config file.
- # Prefix the list here with "+" to use these queries and those in the config file.
- # queries: ./path/to/local/query, your-org/your-repo/queries@main
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ # Override language selection by uncommenting this and choosing your languages
+ # with:
+ # languages: go, javascript, csharp, python, cpp, java, ruby
- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
- # If this step fails, then you should remove it and run the build manually (see below)
- - name: Autobuild
- uses: github/codeql-action/autobuild@v1
+ # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
+ # If this step fails, then you should remove it and run the build manually (see below).
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@v2
- # ℹ️ Command-line programs to run using the OS shell.
- # 📚 https://git.io/JvXDl
+ # ℹ️ Command-line programs to run using the OS shell.
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
- # and modify them (or add more) to build your code if your project
- # uses a compiled language
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following
+ # three lines and modify them (or add more) to build your code if your
+ # project uses a compiled language
- #- run: |
- # make bootstrap
- # make release
+ #- run: |
+ # make bootstrap
+ # make release
- - name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v1
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
\ No newline at end of file
From 3742973e3d215727b79b34e02d5d9ee155a66eea Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Mon, 3 Jul 2023 22:48:52 +0800
Subject: [PATCH 05/73] feat: add feature
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.github/workflows/golangci-link.yml | 51 ++++++++++++++++++
.github/workflows/image.yml | 81 +++++++++++++++++++++++++++++
CONTRIBUTING.md | 36 ++++++++-----
README-zh_CN.md | 2 +-
4 files changed, 156 insertions(+), 14 deletions(-)
create mode 100644 .github/workflows/golangci-link.yml
create mode 100644 .github/workflows/image.yml
diff --git a/.github/workflows/golangci-link.yml b/.github/workflows/golangci-link.yml
new file mode 100644
index 000000000..057dcff74
--- /dev/null
+++ b/.github/workflows/golangci-link.yml
@@ -0,0 +1,51 @@
+# Copyright © 2023 OpenIM open source community. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+name: OpenKF golangci-lint
+on:
+ push:
+ branches: [main]
+ pull_request:
+ branches: [main]
+jobs:
+ golangci:
+ name: lint
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-go@v4
+ with:
+ go-version: '1.20'
+ cache: false
+ - name: golangci-lint
+ uses: golangci/golangci-lint-action@v3
+ with:
+ # Require: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
+ version: v1.53
+
+ # Optional: working directory, useful for monorepos
+ working-directory: server
+
+ # Optional: golangci-lint command line arguments.
+ #
+ # Note: by default the `.golangci.yml` file should be at the root of the repository.
+ # The location of the configuration file can be changed by using `--config=`
+ # args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
+
+ # Optional: show only new issues if it's a pull request. The default value is `false`.
+ only-new-issues: true
+
+ # Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
+ install-mode: "goinstall"
\ No newline at end of file
diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml
new file mode 100644
index 000000000..f6d02cf63
--- /dev/null
+++ b/.github/workflows/image.yml
@@ -0,0 +1,81 @@
+name: Build Image
+
+on:
+ push:
+ branches:
+ - main
+ paths:
+ - "**.go"
+ - "!**_test.go"
+ - "build/**"
+ tags:
+ - v*
+
+jobs:
+ release:
+ strategy:
+ matrix:
+ components: [core, swagger]
+ runs-on: ubuntu-20.04
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 20
+ - uses: dorny/paths-filter@v2
+ if: ${{ !startsWith(github.ref_name, 'v') }}
+ id: changes
+ with:
+ filters: |
+ go:
+ - '**.go'
+ - 'build/core/Dockerfile'
+ api:
+ - 'openapi/**'
+ - 'build/swagger/build.sh'
+ - 'build/swagger/Dockerfile'
+ - name: Docker meta
+ id: meta
+ uses: docker/metadata-action@v4
+ with:
+ flavor: |
+ latest=false
+ images: |
+ ${{ secrets.DOCKERHUB_USERNAME }}/openimsdk-${{ matrix.components }}
+ registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALIREGISTRY_NAMESPACE }}/openimsdk-${{ matrix.components }}
+ tags: |
+ type=ref,event=branch
+ type=sha,prefix={{branch}}-,enable=${{ github.ref_type == 'branch' }}
+ type=ref,event=tag
+ - name: Login to Docker Hub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Login to Ali Container Registry
+ uses: docker/login-action@v2
+ with:
+ registry: registry.cn-hangzhou.aliyuncs.com
+ username: ${{ secrets.ALIREGISTRY_USERNAME }}
+ password: ${{ secrets.ALIREGISTRY_TOKEN }}
+
+ - name: Condition
+ id: condition
+ run: |
+ echo "run=${{ startsWith(github.ref_name, 'v') || ((steps.changes.outputs.go == 'true' && (matrix.components == 'core' || matrix.components == 'job')) || (steps.changes.outputs.api == 'true' && matrix.components == 'swagger')) }}" >> $GITHUB_OUTPUT
+
+ - name: Set up QEMU
+ if: ${{ steps.condition.outputs.run == 'true' }}
+ uses: docker/setup-qemu-action@v2
+ - name: Set up Docker Buildx
+ if: ${{ steps.condition.outputs.run == 'true' }}
+ uses: docker/setup-buildx-action@v2
+ - name: Build and push
+ if: ${{ steps.condition.outputs.run == 'true' }}
+ uses: docker/build-push-action@v3
+ with:
+ context: .
+ file: ./build/${{ matrix.components }}/Dockerfile
+ platforms: linux/amd64
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 215721b19..21359aff6 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -8,13 +8,23 @@ This document provides guidelines and best practices to help you contribute effe
## 📇Topics
-- [What we expect of you](#What-we-expect-of-you)
-- [Code of Conduct](#Code-of-Conduct)
-- [Getting Started](#Getting-Started)
-- [Style and Specification](#Style-and-Specification)
-- [Engage to help anything](#Engage-to-help-anything)
-- [Release version](#Release-version)
-- [Contact Us](#Contact-Us)
+- [Contributing to Open-IM-Server](#contributing-to-open-im-server)
+ - [📇Topics](#topics)
+ - [What we expect of you](#what-we-expect-of-you)
+ - [Code of ConductCode of Conduct](#code-of-conductcode-of-conduct)
+ - [Code and doc contribution](#code-and-doc-contribution)
+ - [Where should I start?](#where-should-i-start)
+ - [Design documents](#design-documents)
+ - [Getting Started](#getting-started)
+ - [Style and Specification](#style-and-specification)
+ - [Reporting security issues](#reporting-security-issues)
+ - [Reporting general issues](#reporting-general-issues)
+ - [Commit Rules](#commit-rules)
+ - [PR Description](#pr-description)
+ - [Docs Contribution](#docs-contribution)
+ - [Engage to help anything](#engage-to-help-anything)
+ - [Release version](#release-version)
+ - [Contact Us](#contact-us)
## What we expect of you
@@ -32,7 +42,7 @@ The [Makefile](./Makefile) is for every developer, even if you don't know how to
#### Code and doc contribution
-Every action to make project Open-IM-Server better is encouraged. On GitHub, every improvement for Open-IM-Server could be via a [PR](https://github.com/Open-IM-Server/pulls) (short for pull request).
+Every action to make project Open-IM-Server better is encouraged. On GitHub, every improvement for Open-IM-Server could be via a [PR](https://github.com/OpenIMSDK/Open-IM-Server/pulls) (short for pull request).
+ If you find a typo, try to fix it!
+ If you find a bug, try to fix it!
@@ -48,7 +58,7 @@ Every action to make project Open-IM-Server better is encouraged. On GitHub, eve
#### Where should I start?
+ If you are new to the project, don't know how to contribute Open-IM-Server, please check out the [good first issue](https://github.com/OpenIMSDK/Open-IM-Server/issues?q=is%3Aopen+label%3A"good+first+issue"+sort%3Aupdated-desc) label.
-+ You should be good at filtering the Open-IM-Server issue tags and finding the ones you like, such as [RFC](https://github.com/OpenIMSDK/Open-IM-Server/issues?q=is%3Aissue+is%3Aopen+RFC+label%3ARFC) for big initiatives, features for [feature](https://github.com/OpenIMSDK/Open-IM-Server/issues?q=is%3Aissue+label%3Afeature) proposals, and [bug](https://github.com/{github/issues?q=is%3Aissue+label%3Abug+) fixes.
++ You should be good at filtering the Open-IM-Server issue tags and finding the ones you like, such as [RFC](https://github.com/OpenIMSDK/Open-IM-Server/issues?q=is%3Aissue+is%3Aopen+RFC+label%3ARFC) for big initiatives, features for [feature](https://github.com/OpenIMSDK/Open-IM-Server/issues?q=is%3Aissue+label%3Afeature) proposals, and [bug](https://github.com/OpenIMSDK/Open-IM-Server/issues?q=is%3Aissue+label%3Abug+) fixes.
+ If you are looking for something to work on, check out our [open issues](https://github.com/OpenIMSDK/Open-IM-Server/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).
+ If you have an idea for a new feature, please [open an issue](https://github.com/OpenIMSDK/Open-IM-Server/issues/new/choose), and we can discuss it.
@@ -180,7 +190,7 @@ To be honest, we regard every user of Open-IM-Serveras a very kind contributor.
Since we collaborate project Open-IM-Server in a distributed way, we appreciate **WELL-WRITTEN**, **DETAILED**, **EXPLICIT** issue reports. To make the communication more efficient, we wish everyone could search if your issue is an existing one in the searching list. If you find it existing, please add your details in comments under the existing issue instead of opening a brand new one.
-To make the issue details as standard as possible, we setup an [ISSUE TEMPLATE](https://github.com/OpenIMSDK/Open-IM-Server/tree/main/.github/ISSUE_TEMPLATE) for issue reporters. You can find three kinds of issue templates there: question, bug report and feature request. Please **BE SURE** to follow the instructions to fill fields in template.
+To make the issue details as standard as possible, we setup an [ISSUE TEMPLATE](https://github.com/OpenIMSDK/.github/tree/main/.github/ISSUE_TEMPLATE) for issue reporters. You can find three kinds of issue templates there: question, bug report and feature request. Please **BE SURE** to follow the instructions to fill fields in template.
**There are a lot of cases when you could open an issue:**
@@ -242,7 +252,7 @@ An example for this could be:
#### PR Description
-PR is the only way to make change to Open-IM-Server project files. To help reviewers better get your purpose, PR description could not be too detailed. We encourage contributors to follow the [PR template](https://github.com/OpenIMSDK/Open-IM-Server/tree/main/.github/PULL_REQUEST_TEMPLATE.md) to finish the pull request.
+PR is the only way to make change to Open-IM-Server project files. To help reviewers better get your purpose, PR description could not be too detailed. We encourage contributors to follow the [PR template](https://github.com/OpenIMSDK/.github/tree/main/.github/PULL_REQUEST_TEMPLATE.md) to finish the pull request.
You can find some very formal PR in [RFC](https://github.com/OpenIMSDK/Open-IM-Server/issues?q=is%3Aissue+is%3Aopen+RFC+label%3ARFC) issues and learn about them.
@@ -295,7 +305,7 @@ The documentation for Open-IM-Server includes:
+ [README.md](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/README.md): This file includes the basic information and instructions for getting started with Open-IM-Server.
+ [CONTRIBUTING.md](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CONTRIBUTING.md): This file contains guidelines for contributing to Open-IM-Server's codebase, such as how to submit issues, pull requests, and code reviews.
-+ [DEVELOPGUIDE.md](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/DEVELOPGUIDE.md): This file provides a more in-depth guide to developing Open-IM-Server, including information on the project's architecture, coding conventions, and testing practices.
++ [DEVELOPGUIDE.md](https://github.com/OpenIMSDK/.github/blob/main/DEVELOPGUIDE.md): This file provides a more in-depth guide to developing Open-IM-Server, including information on the project's architecture, coding conventions, and testing practices.
+ [Official Documentation](https://doc.rentsoft.cn/): This is the official documentation for Open-IM-Server, which includes comprehensive information on all of its features, configuration options, and troubleshooting tips.
Please obey the following rules to better format the docs, which would greatly improve the reading experience.
@@ -315,7 +325,7 @@ We choose GitHub as the primary place for Open-IM-Server to collaborate. So the
+ help solve other user's problems;
+ help review other's [PR](https://github.com/OpenIMSDK/Open-IM-Server/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc) design;
+ discuss about Open-IM-Server to make things clearer;
-+ advocate [Open-IM-Server](google.com/search?q=Open-IM-Server) technology beyond GitHub;
++ advocate [Open-IM-Server](https://google.com/search?q=Open-IM-Server) technology beyond GitHub;
+ write blogs on Open-IM-Server and so on.
In a word, **ANY HELP IS CONTRIBUTION.**
diff --git a/README-zh_CN.md b/README-zh_CN.md
index 1308ef28b..87d675c88 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -19,7 +19,7 @@
English •
- 中文
+ 中文
From d03097108c518cac76c172330de0eb47aef71272 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 09:16:40 +0800
Subject: [PATCH 06/73] feat: add code comment
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
Makefile | 7 ++++---
scripts/coverage.awk | 13 +++++++++++++
scripts/coverage.sh | 16 ++++++++++++++++
scripts/make-rules/golang.mk | 2 +-
4 files changed, 34 insertions(+), 4 deletions(-)
create mode 100644 scripts/coverage.awk
create mode 100644 scripts/coverage.sh
diff --git a/Makefile b/Makefile
index 2dd10fdbd..8e697535e 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,7 @@ include scripts/make-rules/copyright.mk
include scripts/make-rules/gen.mk
include scripts/make-rules/dependencies.mk
include scripts/make-rules/tools.mk
+include scripts/make-rules/release.mk
# ==============================================================================
# Usage
@@ -54,9 +55,9 @@ export USAGE_OPTIONS
build:
@$(MAKE) go.build
-## build-multiarch: Build binaries for multiple platforms. See option PLATFORMS.
-.PHONY: build-multiarch
-build-multiarch:
+## multiarch: Build binaries for multiple platforms. See option PLATFORMS.
+.PHONY: multiarch
+multiarch:
@$(MAKE) go.build.multiarch
## tidy: tidy go.mod
diff --git a/scripts/coverage.awk b/scripts/coverage.awk
new file mode 100644
index 000000000..49389054e
--- /dev/null
+++ b/scripts/coverage.awk
@@ -0,0 +1,13 @@
+#!/usr/bin/env awk
+
+{
+ print $0
+ if (match($0, /^total:/)) {
+ sub(/%/, "", $NF);
+ printf("test coverage is %s%(quality gate is %s%)\n", $NF, target)
+ if (strtonum($NF) < target) {
+ printf("test coverage does not meet expectations: %d%, please add test cases!\n", target)
+ exit 1;
+ }
+ }
+}
diff --git a/scripts/coverage.sh b/scripts/coverage.sh
new file mode 100644
index 000000000..9fb77b59a
--- /dev/null
+++ b/scripts/coverage.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+# http://stackoverflow.com/a/21142256/2055281
+
+echo "mode: atomic" > coverage.txt
+
+for d in $(find ./* -maxdepth 10 -type d); do
+ if ls $d/*.go &> /dev/null; then
+ go test -coverprofile=profile.out -covermode=atomic $d
+ if [ -f profile.out ]; then
+ cat profile.out | grep -v "mode: " >> /tmp/coverage.txt
+ rm profile.out
+ fi
+ fi
+done
+
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index f9a73b5bd..25939b090 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -150,7 +150,7 @@ go.test:
.PHONY: go.test.junit-report
go.test.junit-report: tools.verify.go-junit-report
@echo "===========> Run unit test > $(TMP_DIR)/report.xml"
- @$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(OUTPUT_DIR)/report.xml
+ @$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml
@sed -i '/mock_.*.go/d' $(TMP_DIR)/coverage.out
@echo "===========> Test coverage of Go code is reported to $(TMP_DIR)/coverage.html by generating HTML"
@$(GO) tool cover -html=$(TMP_DIR)/coverage.out -o $(TMP_DIR)/coverage.html
From dc318bbdb594ae5a8fddba7c6780a9861bbc2498 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 10:14:18 +0800
Subject: [PATCH 07/73] cide: fix make file command
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/make-rules/golang.mk | 6 +++---
scripts/release.sh | 25 +++++++++++++++++++++++++
2 files changed, 28 insertions(+), 3 deletions(-)
create mode 100644 scripts/release.sh
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index 25939b090..255306062 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -114,9 +114,9 @@ go.build.%:
@if [ "$(COMMAND)" == "openim-sdk-core" ]; then \
echo "===========> DEBUG: Compilation is not yet supported $(COMMAND)"; \
elif [ "$(COMMAND)" == "rpc" ]; then \
- for d in $(wildcard $(ROOT_DIR)/cmd/rpc/*/); do \
- cd $$d && CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o\
- $(BIN_DIR)/platforms/$(OS)/$(ARCH)/$$(basename $$d)$(GO_OUT_EXT) .; \
+ for d in $(wildcard $(ROOT_DIR)/cmd/rpc/*); do \
+ cd $${d} && CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
+ $(BIN_DIR)/platforms/$(OS)/$(ARCH)/$$(basename $${d})$(GO_OUT_EXT) $${d}/main.go; \
done; \
else \
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
diff --git a/scripts/release.sh b/scripts/release.sh
new file mode 100644
index 000000000..df4022cde
--- /dev/null
+++ b/scripts/release.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+
+# Build a IAM release. This will build the binaries, create the Docker
+# images and other build artifacts.
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+IAM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+source "${IAM_ROOT}/scripts/common.sh"
+source "${IAM_ROOT}/scripts/lib/release.sh"
+
+IAM_RELEASE_RUN_TESTS=${IAM_RELEASE_RUN_TESTS-y}
+
+iam::golang::setup_env
+iam::build::verify_prereqs
+iam::release::verify_prereqs
+#iam::build::build_image
+iam::build::build_command
+iam::release::package_tarballs
+iam::release::updload_tarballs
+git push origin ${VERSION}
+#iam::release::github_release
+#iam::release::generate_changelog
From 91979285ebe562f085fba92a45616a43a97e01fb Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 10:28:19 +0800
Subject: [PATCH 08/73] feat: add scripts lib
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/lib/color.sh | 38 ++
scripts/lib/golang.sh | 193 ++++++++++
scripts/lib/init.sh | 28 ++
scripts/lib/logging.sh | 161 +++++++++
scripts/lib/release.sh | 597 ++++++++++++++++++++++++++++++
scripts/lib/util.sh | 683 +++++++++++++++++++++++++++++++++++
scripts/lib/version.sh | 137 +++++++
scripts/make-rules/golang.mk | 11 +-
8 files changed, 1839 insertions(+), 9 deletions(-)
create mode 100755 scripts/lib/color.sh
create mode 100755 scripts/lib/golang.sh
create mode 100755 scripts/lib/init.sh
create mode 100755 scripts/lib/logging.sh
create mode 100755 scripts/lib/release.sh
create mode 100755 scripts/lib/util.sh
create mode 100755 scripts/lib/version.sh
diff --git a/scripts/lib/color.sh b/scripts/lib/color.sh
new file mode 100755
index 000000000..bdbe0e843
--- /dev/null
+++ b/scripts/lib/color.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+# Copyright 2020 Lingfei Kong . All rights reserved.
+# Use of this source code is governed by a MIT style
+# license that can be found in the LICENSE file.
+
+#Define color variables
+#Feature
+COLOR_NORMAL='\033[0m';COLOR_BOLD='\033[1m';COLOR_DIM='\033[2m';COLOR_UNDER='\033[4m';
+COLOR_ITALIC='\033[3m';COLOR_NOITALIC='\033[23m';COLOR_BLINK='\033[5m';
+COLOR_REVERSE='\033[7m';COLOR_CONCEAL='\033[8m';COLOR_NOBOLD='\033[22m';
+COLOR_NOUNDER='\033[24m';COLOR_NOBLINK='\033[25m';
+
+#Front color
+COLOR_BLACK='\033[30m';COLOR_RED='\033[31m';COLOR_GREEN='\033[32m';COLOR_YELLOW='\033[33m';
+COLOR_BLUE='\033[34m';COLOR_MAGENTA='\033[35m';COLOR_CYAN='\033[36m';COLOR_WHITE='\033[37m';
+
+#background color
+COLOR_BBLACK='\033[40m';COLOR_BRED='\033[41m';
+COLOR_BGREEN='\033[42m';COLOR_BYELLOW='\033[43m';
+COLOR_BBLUE='\033[44m';COLOR_BMAGENTA='\033[45m';
+COLOR_BCYAN='\033[46m';COLOR_BWHITE='\033[47m';
+
+# Print colors you can use
+iam::color::print_color()
+{
+ echo
+ echo -e ${bmagenta}--back-color:${normal}
+ echo "bblack; bgreen; bblue; bcyan; bred; byellow; bmagenta; bwhite"
+ echo
+ echo -e ${red}--font-color:${normal}
+ echo "black; red; green; yellow; blue; magenta; cyan; white"
+ echo
+ echo -e ${bold}--font:${normal}
+ echo "normal; italic; reverse; nounder; bold; noitalic; conceal; noblink;
+ dim; blink; nobold; under"
+ echo
+}
diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh
new file mode 100755
index 000000000..f58e08649
--- /dev/null
+++ b/scripts/lib/golang.sh
@@ -0,0 +1,193 @@
+#!/usr/bin/env bash
+
+# Copyright 2020 Lingfei Kong . All rights reserved.
+# Use of this source code is governed by a MIT style
+# license that can be found in the LICENSE file.
+
+# shellcheck disable=SC2034 # Variables sourced in other scripts.
+
+# The server platform we are building on.
+readonly IAM_SUPPORTED_SERVER_PLATFORMS=(
+ linux/amd64
+ linux/arm64
+)
+
+# If we update this we should also update the set of platforms whose standard
+# library is precompiled for in build/build-image/cross/Dockerfile
+readonly IAM_SUPPORTED_CLIENT_PLATFORMS=(
+ linux/amd64
+ linux/arm64
+)
+
+# The set of server targets that we are only building for Linux
+# If you update this list, please also update build/BUILD.
+iam::golang::server_targets() {
+ local targets=(
+ iam-apiserver
+ iam-authz-server
+ iam-pump
+ iam-watcher
+ )
+ echo "${targets[@]}"
+}
+
+IFS=" " read -ra IAM_SERVER_TARGETS <<< "$(iam::golang::server_targets)"
+readonly IAM_SERVER_TARGETS
+readonly IAM_SERVER_BINARIES=("${IAM_SERVER_TARGETS[@]##*/}")
+
+# The set of server targets we build docker images for
+iam::golang::server_image_targets() {
+ # NOTE: this contains cmd targets for iam::build::get_docker_wrapped_binaries
+ local targets=(
+ cmd/iam-apiserver
+ cmd/iam-authz-server
+ cmd/iam-pump
+ cmd/iam-watcher
+ )
+ echo "${targets[@]}"
+}
+
+IFS=" " read -ra IAM_SERVER_IMAGE_TARGETS <<< "$(iam::golang::server_image_targets)"
+readonly IAM_SERVER_IMAGE_TARGETS
+readonly IAM_SERVER_IMAGE_BINARIES=("${IAM_SERVER_IMAGE_TARGETS[@]##*/}")
+
+# ------------
+# NOTE: All functions that return lists should use newlines.
+# bash functions can't return arrays, and spaces are tricky, so newline
+# separators are the preferred pattern.
+# To transform a string of newline-separated items to an array, use iam::util::read-array:
+# iam::util::read-array FOO < <(iam::golang::dups a b c a)
+#
+# ALWAYS remember to quote your subshells. Not doing so will break in
+# bash 4.3, and potentially cause other issues.
+# ------------
+
+# Returns a sorted newline-separated list containing only duplicated items.
+iam::golang::dups() {
+ # We use printf to insert newlines, which are required by sort.
+ printf "%s\n" "$@" | sort | uniq -d
+}
+
+# Returns a sorted newline-separated list with duplicated items removed.
+iam::golang::dedup() {
+ # We use printf to insert newlines, which are required by sort.
+ printf "%s\n" "$@" | sort -u
+}
+
+# Depends on values of user-facing IAM_BUILD_PLATFORMS, IAM_FASTBUILD,
+# and IAM_BUILDER_OS.
+# Configures IAM_SERVER_PLATFORMS and IAM_CLIENT_PLATFORMS, then sets them
+# to readonly.
+# The configured vars will only contain platforms allowed by the
+# IAM_SUPPORTED* vars at the top of this file.
+declare -a IAM_SERVER_PLATFORMS
+declare -a IAM_CLIENT_PLATFORMS
+iam::golang::setup_platforms() {
+ if [[ -n "${IAM_BUILD_PLATFORMS:-}" ]]; then
+ # IAM_BUILD_PLATFORMS needs to be read into an array before the next
+ # step, or quoting treats it all as one element.
+ local -a platforms
+ IFS=" " read -ra platforms <<< "${IAM_BUILD_PLATFORMS}"
+
+ # Deduplicate to ensure the intersection trick with iam::golang::dups
+ # is not defeated by duplicates in user input.
+ iam::util::read-array platforms < <(iam::golang::dedup "${platforms[@]}")
+
+ # Use iam::golang::dups to restrict the builds to the platforms in
+ # IAM_SUPPORTED_*_PLATFORMS. Items should only appear at most once in each
+ # set, so if they appear twice after the merge they are in the intersection.
+ iam::util::read-array IAM_SERVER_PLATFORMS < <(iam::golang::dups \
+ "${platforms[@]}" \
+ "${IAM_SUPPORTED_SERVER_PLATFORMS[@]}" \
+ )
+ readonly IAM_SERVER_PLATFORMS
+
+ iam::util::read-array IAM_CLIENT_PLATFORMS < <(iam::golang::dups \
+ "${platforms[@]}" \
+ "${IAM_SUPPORTED_CLIENT_PLATFORMS[@]}" \
+ )
+ readonly IAM_CLIENT_PLATFORMS
+
+ elif [[ "${IAM_FASTBUILD:-}" == "true" ]]; then
+ IAM_SERVER_PLATFORMS=(linux/amd64)
+ readonly IAM_SERVER_PLATFORMS
+ IAM_CLIENT_PLATFORMS=(linux/amd64)
+ readonly IAM_CLIENT_PLATFORMS
+ else
+ IAM_SERVER_PLATFORMS=("${IAM_SUPPORTED_SERVER_PLATFORMS[@]}")
+ readonly IAM_SERVER_PLATFORMS
+
+ IAM_CLIENT_PLATFORMS=("${IAM_SUPPORTED_CLIENT_PLATFORMS[@]}")
+ readonly IAM_CLIENT_PLATFORMS
+ fi
+}
+
+iam::golang::setup_platforms
+
+# The set of client targets that we are building for all platforms
+# If you update this list, please also update build/BUILD.
+readonly IAM_CLIENT_TARGETS=(
+ iamctl
+)
+readonly IAM_CLIENT_BINARIES=("${IAM_CLIENT_TARGETS[@]##*/}")
+
+readonly IAM_ALL_TARGETS=(
+ "${IAM_SERVER_TARGETS[@]}"
+ "${IAM_CLIENT_TARGETS[@]}"
+)
+readonly IAM_ALL_BINARIES=("${IAM_ALL_TARGETS[@]##*/}")
+
+# Asks golang what it thinks the host platform is. The go tool chain does some
+# slightly different things when the target platform matches the host platform.
+iam::golang::host_platform() {
+ echo "$(go env GOHOSTOS)/$(go env GOHOSTARCH)"
+}
+
+# Ensure the go tool exists and is a viable version.
+iam::golang::verify_go_version() {
+ if [[ -z "$(command -v go)" ]]; then
+ iam::log::usage_from_stdin <. All rights reserved.
+# Use of this source code is governed by a MIT style
+# license that can be found in the LICENSE file.
+
+set -o errexit
+set +o nounset
+set -o pipefail
+
+# Unset CDPATH so that path interpolation can work correctly
+# https://github.com/iamrnetes/iamrnetes/issues/52255
+unset CDPATH
+
+# Default use go modules
+export GO111MODULE=on
+
+# The root of the build/dist directory
+IAM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
+
+source "${IAM_ROOT}/scripts/lib/util.sh"
+source "${IAM_ROOT}/scripts/lib/logging.sh"
+source "${IAM_ROOT}/scripts/lib/color.sh"
+
+iam::log::install_errexit
+
+source "${IAM_ROOT}/scripts/lib/version.sh"
+source "${IAM_ROOT}/scripts/lib/golang.sh"
diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh
new file mode 100755
index 000000000..39b805c11
--- /dev/null
+++ b/scripts/lib/logging.sh
@@ -0,0 +1,161 @@
+#!/usr/bin/env bash
+
+# Copyright 2020 Lingfei Kong . All rights reserved.
+# Use of this source code is governed by a MIT style
+# license that can be found in the LICENSE file.
+
+# Controls verbosity of the script output and logging.
+IAM_VERBOSE="${IAM_VERBOSE:-5}"
+
+# Handler for when we exit automatically on an error.
+# Borrowed from https://gist.github.com/ahendrix/7030300
+iam::log::errexit() {
+ local err="${PIPESTATUS[*]}"
+
+ # If the shell we are in doesn't have errexit set (common in subshells) then
+ # don't dump stacks.
+ set +o | grep -qe "-o errexit" || return
+
+ set +o xtrace
+ local code="${1:-1}"
+ # Print out the stack trace described by $function_stack
+ if [ ${#FUNCNAME[@]} -gt 2 ]
+ then
+ iam::log::error "Call tree:"
+ for ((i=1;i<${#FUNCNAME[@]}-1;i++))
+ do
+ iam::log::error " ${i}: ${BASH_SOURCE[${i}+1]}:${BASH_LINENO[${i}]} ${FUNCNAME[${i}]}(...)"
+ done
+ fi
+ iam::log::error_exit "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}' exited with status ${err}" "${1:-1}" 1
+}
+
+iam::log::install_errexit() {
+ # trap ERR to provide an error handler whenever a command exits nonzero this
+ # is a more verbose version of set -o errexit
+ trap 'iam::log::errexit' ERR
+
+ # setting errtrace allows our ERR trap handler to be propagated to functions,
+ # expansions and subshells
+ set -o errtrace
+}
+
+# Print out the stack trace
+#
+# Args:
+# $1 The number of stack frames to skip when printing.
+iam::log::stack() {
+ local stack_skip=${1:-0}
+ stack_skip=$((stack_skip + 1))
+ if [[ ${#FUNCNAME[@]} -gt ${stack_skip} ]]; then
+ echo "Call stack:" >&2
+ local i
+ for ((i=1 ; i <= ${#FUNCNAME[@]} - stack_skip ; i++))
+ do
+ local frame_no=$((i - 1 + stack_skip))
+ local source_file=${BASH_SOURCE[${frame_no}]}
+ local source_lineno=${BASH_LINENO[$((frame_no - 1))]}
+ local funcname=${FUNCNAME[${frame_no}]}
+ echo " ${i}: ${source_file}:${source_lineno} ${funcname}(...)" >&2
+ done
+ fi
+}
+
+# Log an error and exit.
+# Args:
+# $1 Message to log with the error
+# $2 The error code to return
+# $3 The number of stack frames to skip when printing.
+iam::log::error_exit() {
+ local message="${1:-}"
+ local code="${2:-1}"
+ local stack_skip="${3:-0}"
+ stack_skip=$((stack_skip + 1))
+
+ if [[ ${IAM_VERBOSE} -ge 4 ]]; then
+ local source_file=${BASH_SOURCE[${stack_skip}]}
+ local source_line=${BASH_LINENO[$((stack_skip - 1))]}
+ echo "!!! Error in ${source_file}:${source_line}" >&2
+ [[ -z ${1-} ]] || {
+ echo " ${1}" >&2
+ }
+
+ iam::log::stack ${stack_skip}
+
+ echo "Exiting with status ${code}" >&2
+ fi
+
+ exit "${code}"
+}
+
+# Log an error but keep going. Don't dump the stack or exit.
+iam::log::error() {
+ timestamp=$(date +"[%m%d %H:%M:%S]")
+ echo "!!! ${timestamp} ${1-}" >&2
+ shift
+ for message; do
+ echo " ${message}" >&2
+ done
+}
+
+# Print an usage message to stderr. The arguments are printed directly.
+iam::log::usage() {
+ echo >&2
+ local message
+ for message; do
+ echo "${message}" >&2
+ done
+ echo >&2
+}
+
+iam::log::usage_from_stdin() {
+ local messages=()
+ while read -r line; do
+ messages+=("${line}")
+ done
+
+ iam::log::usage "${messages[@]}"
+}
+
+# Print out some info that isn't a top level status line
+iam::log::info() {
+ local V="${V:-0}"
+ if [[ ${IAM_VERBOSE} < ${V} ]]; then
+ return
+ fi
+
+ for message; do
+ echo "${message}"
+ done
+}
+
+# Just like iam::log::info, but no \n, so you can make a progress bar
+iam::log::progress() {
+ for message; do
+ echo -e -n "${message}"
+ done
+}
+
+iam::log::info_from_stdin() {
+ local messages=()
+ while read -r line; do
+ messages+=("${line}")
+ done
+
+ iam::log::info "${messages[@]}"
+}
+
+# Print a status line. Formatted to show up in a stream of output.
+iam::log::status() {
+ local V="${V:-0}"
+ if [[ ${IAM_VERBOSE} < ${V} ]]; then
+ return
+ fi
+
+ timestamp=$(date +"[%m%d %H:%M:%S]")
+ echo "+++ ${timestamp} ${1}"
+ shift
+ for message; do
+ echo " ${message}"
+ done
+}
diff --git a/scripts/lib/release.sh b/scripts/lib/release.sh
new file mode 100755
index 000000000..acc3730ef
--- /dev/null
+++ b/scripts/lib/release.sh
@@ -0,0 +1,597 @@
+#!/usr/bin/env bash
+
+# Copyright 2020 Lingfei Kong . All rights reserved.
+# Use of this source code is governed by a MIT style
+# license that can be found in the LICENSE file.
+
+# This file creates release artifacts (tar files, container images) that are
+# ready to distribute to install or distribute to end users.
+
+###############################################################################
+# Most of the ::release:: namespace functions have been moved to
+# github.com/iam/release. Have a look in that repo and specifically in
+# lib/releaselib.sh for ::release::-related functionality.
+###############################################################################
+
+# Tencent cos configuration
+readonly BUCKET="marmotedu-1254073058"
+readonly REGION="ap-beijing"
+readonly COS_RELEASE_DIR="iam-release"
+readonly COSTOOL="coscmd"
+
+# This is where the final release artifacts are created locally
+readonly RELEASE_STAGE="${LOCAL_OUTPUT_ROOT}/release-stage"
+readonly RELEASE_TARS="${LOCAL_OUTPUT_ROOT}/release-tars"
+readonly RELEASE_IMAGES="${LOCAL_OUTPUT_ROOT}/release-images"
+
+# IAM github account info
+readonly IAM_GITHUB_ORG=marmotedu
+readonly IAM_GITHUB_REPO=iam
+
+readonly ARTIFACT=iam.tar.gz
+readonly CHECKSUM=${ARTIFACT}.sha1sum
+
+IAM_BUILD_CONFORMANCE=${IAM_BUILD_CONFORMANCE:-y}
+IAM_BUILD_PULL_LATEST_IMAGES=${IAM_BUILD_PULL_LATEST_IMAGES:-y}
+
+# Validate a ci version
+#
+# Globals:
+# None
+# Arguments:
+# version
+# Returns:
+# If version is a valid ci version
+# Sets: (e.g. for '1.2.3-alpha.4.56+abcdef12345678')
+# VERSION_MAJOR (e.g. '1')
+# VERSION_MINOR (e.g. '2')
+# VERSION_PATCH (e.g. '3')
+# VERSION_PRERELEASE (e.g. 'alpha')
+# VERSION_PRERELEASE_REV (e.g. '4')
+# VERSION_BUILD_INFO (e.g. '.56+abcdef12345678')
+# VERSION_COMMITS (e.g. '56')
+function iam::release::parse_and_validate_ci_version() {
+ # Accept things like "v1.2.3-alpha.4.56+abcdef12345678" or "v1.2.3-beta.4"
+ local -r version_regex="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-([a-zA-Z0-9]+)\\.(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*)\\+[0-9a-f]{7,40})?$"
+ local -r version="${1-}"
+ [[ "${version}" =~ ${version_regex} ]] || {
+ iam::log::error "Invalid ci version: '${version}', must match regex ${version_regex}"
+ return 1
+ }
+
+ # The VERSION variables are used when this file is sourced, hence
+ # the shellcheck SC2034 'appears unused' warning is to be ignored.
+
+ # shellcheck disable=SC2034
+ VERSION_MAJOR="${BASH_REMATCH[1]}"
+ # shellcheck disable=SC2034
+ VERSION_MINOR="${BASH_REMATCH[2]}"
+ # shellcheck disable=SC2034
+ VERSION_PATCH="${BASH_REMATCH[3]}"
+ # shellcheck disable=SC2034
+ VERSION_PRERELEASE="${BASH_REMATCH[4]}"
+ # shellcheck disable=SC2034
+ VERSION_PRERELEASE_REV="${BASH_REMATCH[5]}"
+ # shellcheck disable=SC2034
+ VERSION_BUILD_INFO="${BASH_REMATCH[6]}"
+ # shellcheck disable=SC2034
+ VERSION_COMMITS="${BASH_REMATCH[7]}"
+}
+
+# ---------------------------------------------------------------------------
+# Build final release artifacts
+function iam::release::clean_cruft() {
+ # Clean out cruft
+ find "${RELEASE_STAGE}" -name '*~' -exec rm {} \;
+ find "${RELEASE_STAGE}" -name '#*#' -exec rm {} \;
+ find "${RELEASE_STAGE}" -name '.DS*' -exec rm {} \;
+}
+
+function iam::release::package_tarballs() {
+ # Clean out any old releases
+ rm -rf "${RELEASE_STAGE}" "${RELEASE_TARS}" "${RELEASE_IMAGES}"
+ mkdir -p "${RELEASE_TARS}"
+ iam::release::package_src_tarball &
+ iam::release::package_client_tarballs &
+ iam::release::package_iam_manifests_tarball &
+ iam::release::package_server_tarballs &
+ iam::util::wait-for-jobs || { iam::log::error "previous tarball phase failed"; return 1; }
+
+ iam::release::package_final_tarball & # _final depends on some of the previous phases
+ iam::util::wait-for-jobs || { iam::log::error "previous tarball phase failed"; return 1; }
+}
+
+function iam::release::updload_tarballs() {
+ iam::log::info "upload ${RELEASE_TARS}/* to cos bucket ${BUCKET}."
+ for file in $(ls ${RELEASE_TARS}/*)
+ do
+ if [ "${COSTOOL}" == "coscli" ];then
+ coscli cp "${file}" "cos://${BUCKET}/${COS_RELEASE_DIR}/${IAM_GIT_VERSION}/${file##*/}"
+ coscli cp "${file}" "cos://${BUCKET}/${COS_RELEASE_DIR}/latest/${file##*/}"
+ else
+ coscmd upload "${file}" "${COS_RELEASE_DIR}/${IAM_GIT_VERSION}/"
+ coscmd upload "${file}" "${COS_RELEASE_DIR}/latest/"
+ fi
+ done
+}
+
+# Package the source code we built, for compliance/licensing/audit/yadda.
+function iam::release::package_src_tarball() {
+ local -r src_tarball="${RELEASE_TARS}/iam-src.tar.gz"
+ iam::log::status "Building tarball: src"
+ if [[ "${IAM_GIT_TREE_STATE-}" = 'clean' ]]; then
+ git archive -o "${src_tarball}" HEAD
+ else
+ find "${IAM_ROOT}" -mindepth 1 -maxdepth 1 \
+ ! \( \
+ \( -path "${IAM_ROOT}"/_\* -o \
+ -path "${IAM_ROOT}"/.git\* -o \
+ -path "${IAM_ROOT}"/.gitignore\* -o \
+ -path "${IAM_ROOT}"/.gsemver.yaml\* -o \
+ -path "${IAM_ROOT}"/.config\* -o \
+ -path "${IAM_ROOT}"/.chglog\* -o \
+ -path "${IAM_ROOT}"/.gitlint -o \
+ -path "${IAM_ROOT}"/.golangci.yaml -o \
+ -path "${IAM_ROOT}"/.goreleaser.yml -o \
+ -path "${IAM_ROOT}"/.note.md -o \
+ -path "${IAM_ROOT}"/.todo.md \
+ \) -prune \
+ \) -print0 \
+ | "${TAR}" czf "${src_tarball}" --transform "s|${IAM_ROOT#/*}|iam|" --null -T -
+ fi
+}
+
+# Package up all of the server binaries
+function iam::release::package_server_tarballs() {
+ # Find all of the built client binaries
+ local long_platforms=("${LOCAL_OUTPUT_BINPATH}"/*/*)
+ if [[ -n ${IAM_BUILD_PLATFORMS-} ]]; then
+ read -ra long_platforms <<< "${IAM_BUILD_PLATFORMS}"
+ fi
+
+ for platform_long in "${long_platforms[@]}"; do
+ local platform
+ local platform_tag
+ platform=${platform_long##${LOCAL_OUTPUT_BINPATH}/} # Strip LOCAL_OUTPUT_BINPATH
+ platform_tag=${platform/\//-} # Replace a "/" for a "-"
+ iam::log::status "Starting tarball: server $platform_tag"
+
+ (
+ local release_stage="${RELEASE_STAGE}/server/${platform_tag}/iam"
+ rm -rf "${release_stage}"
+ mkdir -p "${release_stage}/server/bin"
+
+ local server_bins=("${IAM_SERVER_BINARIES[@]}")
+
+ # This fancy expression will expand to prepend a path
+ # (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
+ # server_bins array.
+ cp "${server_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
+ "${release_stage}/server/bin/"
+
+ iam::release::clean_cruft
+
+ local package_name="${RELEASE_TARS}/iam-server-${platform_tag}.tar.gz"
+ iam::release::create_tarball "${package_name}" "${release_stage}/.."
+ ) &
+ done
+
+ iam::log::status "Waiting on tarballs"
+ iam::util::wait-for-jobs || { iam::log::error "server tarball creation failed"; exit 1; }
+ }
+
+# Package up all of the cross compiled clients. Over time this should grow into
+# a full SDK
+function iam::release::package_client_tarballs() {
+ # Find all of the built client binaries
+ local long_platforms=("${LOCAL_OUTPUT_BINPATH}"/*/*)
+ if [[ -n ${IAM_BUILD_PLATFORMS-} ]]; then
+ read -ra long_platforms <<< "${IAM_BUILD_PLATFORMS}"
+ fi
+
+ for platform_long in "${long_platforms[@]}"; do
+ local platform
+ local platform_tag
+ platform=${platform_long##${LOCAL_OUTPUT_BINPATH}/} # Strip LOCAL_OUTPUT_BINPATH
+ platform_tag=${platform/\//-} # Replace a "/" for a "-"
+ iam::log::status "Starting tarball: client $platform_tag"
+
+ (
+ local release_stage="${RELEASE_STAGE}/client/${platform_tag}/iam"
+ rm -rf "${release_stage}"
+ mkdir -p "${release_stage}/client/bin"
+
+ local client_bins=("${IAM_CLIENT_BINARIES[@]}")
+
+ # This fancy expression will expand to prepend a path
+ # (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
+ # client_bins array.
+ cp "${client_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
+ "${release_stage}/client/bin/"
+
+ iam::release::clean_cruft
+
+ local package_name="${RELEASE_TARS}/iam-client-${platform_tag}.tar.gz"
+ iam::release::create_tarball "${package_name}" "${release_stage}/.."
+ ) &
+ done
+
+ iam::log::status "Waiting on tarballs"
+ iam::util::wait-for-jobs || { iam::log::error "client tarball creation failed"; exit 1; }
+}
+
+# Package up all of the server binaries in docker images
+function iam::release::build_server_images() {
+ # Clean out any old images
+ rm -rf "${RELEASE_IMAGES}"
+ local platform
+ for platform in "${IAM_SERVER_PLATFORMS[@]}"; do
+ local platform_tag
+ local arch
+ platform_tag=${platform/\//-} # Replace a "/" for a "-"
+ arch=$(basename "${platform}")
+ iam::log::status "Building images: $platform_tag"
+
+ local release_stage
+ release_stage="${RELEASE_STAGE}/server/${platform_tag}/iam"
+ rm -rf "${release_stage}"
+ mkdir -p "${release_stage}/server/bin"
+
+ # This fancy expression will expand to prepend a path
+ # (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
+ # IAM_SERVER_IMAGE_BINARIES array.
+ cp "${IAM_SERVER_IMAGE_BINARIES[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
+ "${release_stage}/server/bin/"
+
+ iam::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}"
+ done
+}
+
+function iam::release::md5() {
+ if which md5 >/dev/null 2>&1; then
+ md5 -q "$1"
+ else
+ md5sum "$1" | awk '{ print $1 }'
+ fi
+}
+
+function iam::release::sha1() {
+ if which sha1sum >/dev/null 2>&1; then
+ sha1sum "$1" | awk '{ print $1 }'
+ else
+ shasum -a1 "$1" | awk '{ print $1 }'
+ fi
+}
+
+function iam::release::build_conformance_image() {
+ local -r arch="$1"
+ local -r registry="$2"
+ local -r version="$3"
+ local -r save_dir="${4-}"
+ iam::log::status "Building conformance image for arch: ${arch}"
+ ARCH="${arch}" REGISTRY="${registry}" VERSION="${version}" \
+ make -C cluster/images/conformance/ build >/dev/null
+
+ local conformance_tag
+ conformance_tag="${registry}/conformance-${arch}:${version}"
+ if [[ -n "${save_dir}" ]]; then
+ "${DOCKER[@]}" save "${conformance_tag}" > "${save_dir}/conformance-${arch}.tar"
+ fi
+ iam::log::status "Deleting conformance image ${conformance_tag}"
+ "${DOCKER[@]}" rmi "${conformance_tag}" &>/dev/null || true
+}
+
+# This builds all the release docker images (One docker image per binary)
+# Args:
+# $1 - binary_dir, the directory to save the tared images to.
+# $2 - arch, architecture for which we are building docker images.
+function iam::release::create_docker_images_for_server() {
+ # Create a sub-shell so that we don't pollute the outer environment
+ (
+ local binary_dir
+ local arch
+ local binaries
+ local images_dir
+ binary_dir="$1"
+ arch="$2"
+ binaries=$(iam::build::get_docker_wrapped_binaries "${arch}")
+ images_dir="${RELEASE_IMAGES}/${arch}"
+ mkdir -p "${images_dir}"
+
+ # k8s.gcr.io is the constant tag in the docker archives, this is also the default for config scripts in GKE.
+ # We can use IAM_DOCKER_REGISTRY to include and extra registry in the docker archive.
+ # If we use IAM_DOCKER_REGISTRY="k8s.gcr.io", then the extra tag (same) is ignored, see release_docker_image_tag below.
+ local -r docker_registry="k8s.gcr.io"
+ # Docker tags cannot contain '+'
+ local docker_tag="${IAM_GIT_VERSION/+/_}"
+ if [[ -z "${docker_tag}" ]]; then
+ iam::log::error "git version information missing; cannot create Docker tag"
+ return 1
+ fi
+
+ # provide `--pull` argument to `docker build` if `IAM_BUILD_PULL_LATEST_IMAGES`
+ # is set to y or Y; otherwise try to build the image without forcefully
+ # pulling the latest base image.
+ local docker_build_opts
+ docker_build_opts=
+ if [[ "${IAM_BUILD_PULL_LATEST_IMAGES}" =~ [yY] ]]; then
+ docker_build_opts='--pull'
+ fi
+
+ for wrappable in $binaries; do
+
+ local binary_name=${wrappable%%,*}
+ local base_image=${wrappable##*,}
+ local binary_file_path="${binary_dir}/${binary_name}"
+ local docker_build_path="${binary_file_path}.dockerbuild"
+ local docker_file_path="${docker_build_path}/Dockerfile"
+ local docker_image_tag="${docker_registry}/${binary_name}-${arch}:${docker_tag}"
+
+ iam::log::status "Starting docker build for image: ${binary_name}-${arch}"
+ (
+ rm -rf "${docker_build_path}"
+ mkdir -p "${docker_build_path}"
+ ln "${binary_file_path}" "${docker_build_path}/${binary_name}"
+ ln "${IAM_ROOT}/build/nsswitch.conf" "${docker_build_path}/nsswitch.conf"
+ chmod 0644 "${docker_build_path}/nsswitch.conf"
+ cat < "${docker_file_path}"
+FROM ${base_image}
+COPY ${binary_name} /usr/local/bin/${binary_name}
+EOF
+ # ensure /etc/nsswitch.conf exists so go's resolver respects /etc/hosts
+ if [[ "${base_image}" =~ busybox ]]; then
+ echo "COPY nsswitch.conf /etc/" >> "${docker_file_path}"
+ fi
+
+ "${DOCKER[@]}" build ${docker_build_opts:+"${docker_build_opts}"} -q -t "${docker_image_tag}" "${docker_build_path}" >/dev/null
+ # If we are building an official/alpha/beta release we want to keep
+ # docker images and tag them appropriately.
+ local -r release_docker_image_tag="${IAM_DOCKER_REGISTRY-$docker_registry}/${binary_name}-${arch}:${IAM_DOCKER_IMAGE_TAG-$docker_tag}"
+ if [[ "${release_docker_image_tag}" != "${docker_image_tag}" ]]; then
+ iam::log::status "Tagging docker image ${docker_image_tag} as ${release_docker_image_tag}"
+ "${DOCKER[@]}" rmi "${release_docker_image_tag}" 2>/dev/null || true
+ "${DOCKER[@]}" tag "${docker_image_tag}" "${release_docker_image_tag}" 2>/dev/null
+ fi
+ "${DOCKER[@]}" save -o "${binary_file_path}.tar" "${docker_image_tag}" "${release_docker_image_tag}"
+ echo "${docker_tag}" > "${binary_file_path}.docker_tag"
+ rm -rf "${docker_build_path}"
+ ln "${binary_file_path}.tar" "${images_dir}/"
+
+ iam::log::status "Deleting docker image ${docker_image_tag}"
+ "${DOCKER[@]}" rmi "${docker_image_tag}" &>/dev/null || true
+ ) &
+ done
+
+ if [[ "${IAM_BUILD_CONFORMANCE}" =~ [yY] ]]; then
+ iam::release::build_conformance_image "${arch}" "${docker_registry}" \
+ "${docker_tag}" "${images_dir}" &
+ fi
+
+ iam::util::wait-for-jobs || { iam::log::error "previous Docker build failed"; return 1; }
+ iam::log::status "Docker builds done"
+ )
+
+}
+
+# This will pack iam-system manifests files for distros such as COS.
+function iam::release::package_iam_manifests_tarball() {
+ iam::log::status "Building tarball: manifests"
+
+ local src_dir="${IAM_ROOT}/deployments"
+
+ local release_stage="${RELEASE_STAGE}/manifests/iam"
+ rm -rf "${release_stage}"
+
+ local dst_dir="${release_stage}"
+ mkdir -p "${dst_dir}"
+ cp -r ${src_dir}/* "${dst_dir}"
+ #cp "${src_dir}/iam-apiserver.yaml" "${dst_dir}"
+ #cp "${src_dir}/iam-authz-server.yaml" "${dst_dir}"
+ #cp "${src_dir}/iam-pump.yaml" "${dst_dir}"
+ #cp "${src_dir}/iam-watcher.yaml" "${dst_dir}"
+ #cp "${IAM_ROOT}/cluster/gce/gci/health-monitor.sh" "${dst_dir}/health-monitor.sh"
+
+ iam::release::clean_cruft
+
+ local package_name="${RELEASE_TARS}/iam-manifests.tar.gz"
+ iam::release::create_tarball "${package_name}" "${release_stage}/.."
+}
+
+# This is all the platform-independent stuff you need to run/install iam.
+# Arch-specific binaries will need to be downloaded separately (possibly by
+# using the bundled cluster/get-iam-binaries.sh script).
+# Included in this tarball:
+# - Cluster spin up/down scripts and configs for various cloud providers
+# - Tarballs for manifest configs that are ready to be uploaded
+# - Examples (which may or may not still work)
+# - The remnants of the docs/ directory
+function iam::release::package_final_tarball() {
+ iam::log::status "Building tarball: final"
+
+ # This isn't a "full" tarball anymore, but the release lib still expects
+ # artifacts under "full/iam/"
+ local release_stage="${RELEASE_STAGE}/full/iam"
+ rm -rf "${release_stage}"
+ mkdir -p "${release_stage}"
+
+ mkdir -p "${release_stage}/client"
+ cat < "${release_stage}/client/README"
+Client binaries are no longer included in the IAM final tarball.
+
+Run release/get-iam-binaries.sh to download client and server binaries.
+EOF
+
+ # We want everything in /scripts.
+ mkdir -p "${release_stage}/release"
+ cp -R "${IAM_ROOT}/scripts/release" "${release_stage}/"
+ cat < "${release_stage}/release/get-iam-binaries.sh"
+#!/usr/bin/env bash
+
+# Copyright 2020 Lingfei Kong . All rights reserved.
+# Use of this source code is governed by a MIT style
+# license that can be found in the LICENSE file.
+
+# This file download iam client and server binaries from tencent cos bucket.
+
+os=linux arch=amd64 version=${IAM_GIT_VERSION} && wget https://${BUCKET}.cos.${REGION}.myqcloud.com/${COS_RELEASE_DIR}/\$version/{iam-client-\$os-\$arch.tar.gz,iam-server-\$os-\$arch.tar.gz}
+EOF
+ chmod +x ${release_stage}/release/get-iam-binaries.sh
+
+ mkdir -p "${release_stage}/server"
+ cp "${RELEASE_TARS}/iam-manifests.tar.gz" "${release_stage}/server/"
+ cat < "${release_stage}/server/README"
+Server binary tarballs are no longer included in the IAM final tarball.
+
+Run release/get-iam-binaries.sh to download client and server binaries.
+EOF
+
+ # Include hack/lib as a dependency for the cluster/ scripts
+ #mkdir -p "${release_stage}/hack"
+ #cp -R "${IAM_ROOT}/hack/lib" "${release_stage}/hack/"
+
+ cp -R ${IAM_ROOT}/{docs,configs,scripts,deployments,init,README.md,LICENSE} "${release_stage}/"
+
+ echo "${IAM_GIT_VERSION}" > "${release_stage}/version"
+
+ iam::release::clean_cruft
+
+ local package_name="${RELEASE_TARS}/${ARTIFACT}"
+ iam::release::create_tarball "${package_name}" "${release_stage}/.."
+}
+
+# Build a release tarball. $1 is the output tar name. $2 is the base directory
+# of the files to be packaged. This assumes that ${2}/iamis what is
+# being packaged.
+function iam::release::create_tarball() {
+ iam::build::ensure_tar
+
+ local tarfile=$1
+ local stagingdir=$2
+
+ "${TAR}" czf "${tarfile}" -C "${stagingdir}" iam --owner=0 --group=0
+}
+
+function iam::release::install_github_release(){
+ GO111MODULE=on go install github.com/github-release/github-release@latest
+}
+
+# Require the following tools:
+# - github-release
+# - gsemver
+# - git-chglog
+# - coscmd or coscli
+function iam::release::verify_prereqs(){
+ if [ -z "$(which github-release 2>/dev/null)" ]; then
+ iam::log::info "'github-release' tool not installed, try to install it."
+
+ if ! iam::release::install_github_release; then
+ iam::log::error "failed to install 'github-release'"
+ return 1
+ fi
+ fi
+
+ if [ -z "$(which git-chglog 2>/dev/null)" ]; then
+ iam::log::info "'git-chglog' tool not installed, try to install it."
+
+ if ! go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest &>/dev/null; then
+ iam::log::error "failed to install 'git-chglog'"
+ return 1
+ fi
+ fi
+
+ if [ -z "$(which gsemver 2>/dev/null)" ]; then
+ iam::log::info "'gsemver' tool not installed, try to install it."
+
+ if ! go install github.com/arnaud-deprez/gsemver@latest &>/dev/null; then
+ iam::log::error "failed to install 'gsemver'"
+ return 1
+ fi
+ fi
+
+
+ if [ -z "$(which ${COSTOOL} 2>/dev/null)" ]; then
+ iam::log::info "${COSTOOL} tool not installed, try to install it."
+
+ if ! make -C "${IAM_ROOT}" tools.install.${COSTOOL}; then
+ iam::log::error "failed to install ${COSTOOL}"
+ return 1
+ fi
+ fi
+
+ if [ -z "${TENCENT_SECRET_ID}" -o -z "${TENCENT_SECRET_KEY}" ];then
+ iam::log::error "can not find env: TENCENT_SECRET_ID and TENCENT_SECRET_KEY"
+ return 1
+ fi
+
+ if [ "${COSTOOL}" == "coscli" ];then
+ if [ ! -f "${HOME}/.cos.yaml" ];then
+ cat << EOF > "${HOME}/.cos.yaml"
+cos:
+ base:
+ secretid: ${TENCENT_SECRET_ID}
+ secretkey: ${TENCENT_SECRET_KEY}
+ sessiontoken: ""
+ buckets:
+ - name: ${BUCKET}
+ alias: ${BUCKET}
+ region: ${REGION}
+EOF
+ fi
+ else
+ if [ ! -f "${HOME}/.cos.conf" ];then
+ cat << EOF > "${HOME}/.cos.conf"
+[common]
+secret_id = ${TENCENT_SECRET_ID}
+secret_key = ${TENCENT_SECRET_KEY}
+bucket = ${BUCKET}
+region =${REGION}
+max_thread = 5
+part_size = 1
+schema = https
+EOF
+ fi
+ fi
+}
+
+# Create a github release with specified tarballs.
+# NOTICE: Must export 'GITHUB_TOKEN' env in the shell, details:
+# https://github.com/github-release/github-release
+function iam::release::github_release() {
+ # create a github release
+ iam::log::info "create a new github release with tag ${IAM_GIT_VERSION}"
+ github-release release \
+ --user ${IAM_GITHUB_ORG} \
+ --repo ${IAM_GITHUB_REPO} \
+ --tag ${IAM_GIT_VERSION} \
+ --description "" \
+ --pre-release
+
+ # update iam tarballs
+ iam::log::info "upload ${ARTIFACT} to release ${IAM_GIT_VERSION}"
+ github-release upload \
+ --user ${IAM_GITHUB_ORG} \
+ --repo ${IAM_GITHUB_REPO} \
+ --tag ${IAM_GIT_VERSION} \
+ --name ${ARTIFACT} \
+ --file ${RELEASE_TARS}/${ARTIFACT}
+
+ iam::log::info "upload iam-src.tar.gz to release ${IAM_GIT_VERSION}"
+ github-release upload \
+ --user ${IAM_GITHUB_ORG} \
+ --repo ${IAM_GITHUB_REPO} \
+ --tag ${IAM_GIT_VERSION} \
+ --name "iam-src.tar.gz" \
+ --file ${RELEASE_TARS}/iam-src.tar.gz
+}
+
+function iam::release::generate_changelog() {
+ iam::log::info "generate CHANGELOG-${IAM_GIT_VERSION#v}.md and commit it"
+
+ git-chglog ${IAM_GIT_VERSION} > ${IAM_ROOT}/CHANGELOG/CHANGELOG-${IAM_GIT_VERSION#v}.md
+
+ set +o errexit
+ git add ${IAM_ROOT}/CHANGELOG/CHANGELOG-${IAM_GIT_VERSION#v}.md
+ git commit -a -m "docs(changelog): add CHANGELOG-${IAM_GIT_VERSION#v}.md"
+ git push -f origin master # 最后将 CHANGELOG 也 push 上去
+}
+
diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh
new file mode 100755
index 000000000..86c32a69e
--- /dev/null
+++ b/scripts/lib/util.sh
@@ -0,0 +1,683 @@
+#!/usr/bin/env bash
+
+# Copyright 2020 Lingfei Kong . All rights reserved.
+# Use of this source code is governed by a MIT style
+# license that can be found in the LICENSE file.
+
+function iam::util::sourced_variable {
+ # Call this function to tell shellcheck that a variable is supposed to
+ # be used from other calling context. This helps quiet an "unused
+ # variable" warning from shellcheck and also document your code.
+ true
+}
+
+iam::util::sortable_date() {
+ date "+%Y%m%d-%H%M%S"
+}
+
+# arguments: target, item1, item2, item3, ...
+# returns 0 if target is in the given items, 1 otherwise.
+iam::util::array_contains() {
+ local search="$1"
+ local element
+ shift
+ for element; do
+ if [[ "${element}" == "${search}" ]]; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+iam::util::wait_for_url() {
+ local url=$1
+ local prefix=${2:-}
+ local wait=${3:-1}
+ local times=${4:-30}
+ local maxtime=${5:-1}
+
+ command -v curl >/dev/null || {
+ iam::log::usage "curl must be installed"
+ exit 1
+ }
+
+ local i
+ for i in $(seq 1 "${times}"); do
+ local out
+ if out=$(curl --max-time "${maxtime}" -gkfs "${url}" 2>/dev/null); then
+ iam::log::status "On try ${i}, ${prefix}: ${out}"
+ return 0
+ fi
+ sleep "${wait}"
+ done
+ iam::log::error "Timed out waiting for ${prefix} to answer at ${url}; tried ${times} waiting ${wait} between each"
+ return 1
+}
+
+# Example: iam::util::wait_for_success 120 5 "iamctl get nodes|grep localhost"
+# arguments: wait time, sleep time, shell command
+# returns 0 if the shell command get output, 1 otherwise.
+iam::util::wait_for_success(){
+ local wait_time="$1"
+ local sleep_time="$2"
+ local cmd="$3"
+ while [ "$wait_time" -gt 0 ]; do
+ if eval "$cmd"; then
+ return 0
+ else
+ sleep "$sleep_time"
+ wait_time=$((wait_time-sleep_time))
+ fi
+ done
+ return 1
+}
+
+# Example: iam::util::trap_add 'echo "in trap DEBUG"' DEBUG
+# See: http://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal
+iam::util::trap_add() {
+ local trap_add_cmd
+ trap_add_cmd=$1
+ shift
+
+ for trap_add_name in "$@"; do
+ local existing_cmd
+ local new_cmd
+
+ # Grab the currently defined trap commands for this trap
+ existing_cmd=$(trap -p "${trap_add_name}" | awk -F"'" '{print $2}')
+
+ if [[ -z "${existing_cmd}" ]]; then
+ new_cmd="${trap_add_cmd}"
+ else
+ new_cmd="${trap_add_cmd};${existing_cmd}"
+ fi
+
+ # Assign the test. Disable the shellcheck warning telling that trap
+ # commands should be single quoted to avoid evaluating them at this
+ # point instead evaluating them at run time. The logic of adding new
+ # commands to a single trap requires them to be evaluated right away.
+ # shellcheck disable=SC2064
+ trap "${new_cmd}" "${trap_add_name}"
+ done
+}
+
+# Opposite of iam::util::ensure-temp-dir()
+iam::util::cleanup-temp-dir() {
+ rm -rf "${IAM_TEMP}"
+}
+
+# Create a temp dir that'll be deleted at the end of this bash session.
+#
+# Vars set:
+# IAM_TEMP
+iam::util::ensure-temp-dir() {
+ if [[ -z ${IAM_TEMP-} ]]; then
+ IAM_TEMP=$(mktemp -d 2>/dev/null || mktemp -d -t iamrnetes.XXXXXX)
+ iam::util::trap_add iam::util::cleanup-temp-dir EXIT
+ fi
+}
+
+iam::util::host_os() {
+ local host_os
+ case "$(uname -s)" in
+ Darwin)
+ host_os=darwin
+ ;;
+ Linux)
+ host_os=linux
+ ;;
+ *)
+ iam::log::error "Unsupported host OS. Must be Linux or Mac OS X."
+ exit 1
+ ;;
+ esac
+ echo "${host_os}"
+}
+
+iam::util::host_arch() {
+ local host_arch
+ case "$(uname -m)" in
+ x86_64*)
+ host_arch=amd64
+ ;;
+ i?86_64*)
+ host_arch=amd64
+ ;;
+ amd64*)
+ host_arch=amd64
+ ;;
+ aarch64*)
+ host_arch=arm64
+ ;;
+ arm64*)
+ host_arch=arm64
+ ;;
+ arm*)
+ host_arch=arm
+ ;;
+ i?86*)
+ host_arch=x86
+ ;;
+ s390x*)
+ host_arch=s390x
+ ;;
+ ppc64le*)
+ host_arch=ppc64le
+ ;;
+ *)
+ iam::log::error "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x or ppc64le."
+ exit 1
+ ;;
+ esac
+ echo "${host_arch}"
+}
+
+# This figures out the host platform without relying on golang. We need this as
+# we don't want a golang install to be a prerequisite to building yet we need
+# this info to figure out where the final binaries are placed.
+iam::util::host_platform() {
+ echo "$(iam::util::host_os)/$(iam::util::host_arch)"
+}
+
+# looks for $1 in well-known output locations for the platform ($2)
+# $IAM_ROOT must be set
+iam::util::find-binary-for-platform() {
+ local -r lookfor="$1"
+ local -r platform="$2"
+ local locations=(
+ "${IAM_ROOT}/_output/bin/${lookfor}"
+ "${IAM_ROOT}/_output/${platform}/${lookfor}"
+ "${IAM_ROOT}/_output/local/bin/${platform}/${lookfor}"
+ "${IAM_ROOT}/_output/platforms/${platform}/${lookfor}"
+ )
+
+ # List most recently-updated location.
+ local -r bin=$( (ls -t "${locations[@]}" 2>/dev/null || true) | head -1 )
+ echo -n "${bin}"
+}
+
+# looks for $1 in well-known output locations for the host platform
+# $IAM_ROOT must be set
+iam::util::find-binary() {
+ iam::util::find-binary-for-platform "$1" "$(iam::util::host_platform)"
+}
+
+# Run all known doc generators (today gendocs and genman for iamctl)
+# $1 is the directory to put those generated documents
+iam::util::gen-docs() {
+ local dest="$1"
+
+ # Find binary
+ gendocs=$(iam::util::find-binary "gendocs")
+ geniamdocs=$(iam::util::find-binary "geniamdocs")
+ genman=$(iam::util::find-binary "genman")
+ genyaml=$(iam::util::find-binary "genyaml")
+ genfeddocs=$(iam::util::find-binary "genfeddocs")
+
+ # TODO: If ${genfeddocs} is not used from anywhere (it isn't used at
+ # least from k/k tree), remove it completely.
+ iam::util::sourced_variable "${genfeddocs}"
+
+ mkdir -p "${dest}/docs/guide/en-US/cmd/iamctl/"
+ "${gendocs}" "${dest}/docs/guide/en-US/cmd/iamctl/"
+
+ mkdir -p "${dest}/docs/guide/en-US/cmd/"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-apiserver"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-authz-server"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-pump"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-watcher"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/iamctl" "iamctl"
+
+ mkdir -p "${dest}/docs/man/man1/"
+ "${genman}" "${dest}/docs/man/man1/" "iam-apiserver"
+ "${genman}" "${dest}/docs/man/man1/" "iam-authz-server"
+ "${genman}" "${dest}/docs/man/man1/" "iam-pump"
+ "${genman}" "${dest}/docs/man/man1/" "iam-watcher"
+ "${genman}" "${dest}/docs/man/man1/" "iamctl"
+
+ mkdir -p "${dest}/docs/guide/en-US/yaml/iamctl/"
+ "${genyaml}" "${dest}/docs/guide/en-US/yaml/iamctl/"
+
+ # create the list of generated files
+ pushd "${dest}" > /dev/null || return 1
+ touch docs/.generated_docs
+ find . -type f | cut -sd / -f 2- | LC_ALL=C sort > docs/.generated_docs
+ popd > /dev/null || return 1
+}
+
+# Removes previously generated docs-- we don't want to check them in. $IAM_ROOT
+# must be set.
+iam::util::remove-gen-docs() {
+ if [ -e "${IAM_ROOT}/docs/.generated_docs" ]; then
+ # remove all of the old docs; we don't want to check them in.
+ while read -r file; do
+ rm "${IAM_ROOT}/${file}" 2>/dev/null || true
+ done <"${IAM_ROOT}/docs/.generated_docs"
+ # The docs/.generated_docs file lists itself, so we don't need to explicitly
+ # delete it.
+ fi
+}
+
+# Returns the name of the upstream remote repository name for the local git
+# repo, e.g. "upstream" or "origin".
+iam::util::git_upstream_remote_name() {
+ git remote -v | grep fetch |\
+ grep -E 'github.com[/:]marmotedu/iam|marmotedu.io/iam' |\
+ head -n 1 | awk '{print $1}'
+}
+
+# Exits script if working directory is dirty. If it's run interactively in the terminal
+# the user can commit changes in a second terminal. This script will wait.
+iam::util::ensure_clean_working_dir() {
+ while ! git diff HEAD --exit-code &>/dev/null; do
+ echo -e "\nUnexpected dirty working directory:\n"
+ if tty -s; then
+ git status -s
+ else
+ git diff -a # be more verbose in log files without tty
+ exit 1
+ fi | sed 's/^/ /'
+ echo -e "\nCommit your changes in another terminal and then continue here by pressing enter."
+ read -r
+ done 1>&2
+}
+
+# Find the base commit using:
+# $PULL_BASE_SHA if set (from Prow)
+# current ref from the remote upstream branch
+iam::util::base_ref() {
+ local -r git_branch=$1
+
+ if [[ -n ${PULL_BASE_SHA:-} ]]; then
+ echo "${PULL_BASE_SHA}"
+ return
+ fi
+
+ full_branch="$(iam::util::git_upstream_remote_name)/${git_branch}"
+
+ # make sure the branch is valid, otherwise the check will pass erroneously.
+ if ! git describe "${full_branch}" >/dev/null; then
+ # abort!
+ exit 1
+ fi
+
+ echo "${full_branch}"
+}
+
+# Checks whether there are any files matching pattern $2 changed between the
+# current branch and upstream branch named by $1.
+# Returns 1 (false) if there are no changes
+# 0 (true) if there are changes detected.
+iam::util::has_changes() {
+ local -r git_branch=$1
+ local -r pattern=$2
+ local -r not_pattern=${3:-totallyimpossiblepattern}
+
+ local base_ref
+ base_ref=$(iam::util::base_ref "${git_branch}")
+ echo "Checking for '${pattern}' changes against '${base_ref}'"
+
+ # notice this uses ... to find the first shared ancestor
+ if git diff --name-only "${base_ref}...HEAD" | grep -v -E "${not_pattern}" | grep "${pattern}" > /dev/null; then
+ return 0
+ fi
+ # also check for pending changes
+ if git status --porcelain | grep -v -E "${not_pattern}" | grep "${pattern}" > /dev/null; then
+ echo "Detected '${pattern}' uncommitted changes."
+ return 0
+ fi
+ echo "No '${pattern}' changes detected."
+ return 1
+}
+
+iam::util::download_file() {
+ local -r url=$1
+ local -r destination_file=$2
+
+ rm "${destination_file}" 2&> /dev/null || true
+
+ for i in $(seq 5)
+ do
+ if ! curl -fsSL --retry 3 --keepalive-time 2 "${url}" -o "${destination_file}"; then
+ echo "Downloading ${url} failed. $((5-i)) retries left."
+ sleep 1
+ else
+ echo "Downloading ${url} succeed"
+ return 0
+ fi
+ done
+ return 1
+}
+
+# Test whether openssl is installed.
+# Sets:
+# OPENSSL_BIN: The path to the openssl binary to use
+function iam::util::test_openssl_installed {
+ if ! openssl version >& /dev/null; then
+ echo "Failed to run openssl. Please ensure openssl is installed"
+ exit 1
+ fi
+
+ OPENSSL_BIN=$(command -v openssl)
+}
+
+# creates a client CA, args are sudo, dest-dir, ca-id, purpose
+# purpose is dropped in after "key encipherment", you usually want
+# '"client auth"'
+# '"server auth"'
+# '"client auth","server auth"'
+function iam::util::create_signing_certkey {
+ local sudo=$1
+ local dest_dir=$2
+ local id=$3
+ local purpose=$4
+ # Create client ca
+ ${sudo} /usr/bin/env bash -e < "${dest_dir}/${id}-ca-config.json"
+EOF
+}
+
+# signs a client certificate: args are sudo, dest-dir, CA, filename (roughly), username, groups...
+function iam::util::create_client_certkey {
+ local sudo=$1
+ local dest_dir=$2
+ local ca=$3
+ local id=$4
+ local cn=${5:-$4}
+ local groups=""
+ local SEP=""
+ shift 5
+ while [ -n "${1:-}" ]; do
+ groups+="${SEP}{\"O\":\"$1\"}"
+ SEP=","
+ shift 1
+ done
+ ${sudo} /usr/bin/env bash -e < /dev/null
+apiVersion: v1
+kind: Config
+clusters:
+ - cluster:
+ certificate-authority: ${ca_file}
+ server: https://${api_host}:${api_port}/
+ name: local-up-cluster
+users:
+ - user:
+ token: ${token}
+ client-certificate: ${dest_dir}/client-${client_id}.crt
+ client-key: ${dest_dir}/client-${client_id}.key
+ name: local-up-cluster
+contexts:
+ - context:
+ cluster: local-up-cluster
+ user: local-up-cluster
+ name: local-up-cluster
+current-context: local-up-cluster
+EOF
+
+ # flatten the iamconfig files to make them self contained
+ username=$(whoami)
+ ${sudo} /usr/bin/env bash -e < "/tmp/${client_id}.iamconfig"
+ mv -f "/tmp/${client_id}.iamconfig" "${dest_dir}/${client_id}.iamconfig"
+ chown ${username} "${dest_dir}/${client_id}.iamconfig"
+EOF
+}
+
+# Determines if docker can be run, failures may simply require that the user be added to the docker group.
+function iam::util::ensure_docker_daemon_connectivity {
+ IFS=" " read -ra DOCKER <<< "${DOCKER_OPTS}"
+ # Expand ${DOCKER[@]} only if it's not unset. This is to work around
+ # Bash 3 issue with unbound variable.
+ DOCKER=(docker ${DOCKER[@]:+"${DOCKER[@]}"})
+ if ! "${DOCKER[@]}" info > /dev/null 2>&1 ; then
+ cat <<'EOF' >&2
+Can't connect to 'docker' daemon. please fix and retry.
+
+Possible causes:
+ - Docker Daemon not started
+ - Linux: confirm via your init system
+ - macOS w/ docker-machine: run `docker-machine ls` and `docker-machine start `
+ - macOS w/ Docker for Mac: Check the menu bar and start the Docker application
+ - DOCKER_HOST hasn't been set or is set incorrectly
+ - Linux: domain socket is used, DOCKER_* should be unset. In Bash run `unset ${!DOCKER_*}`
+ - macOS w/ docker-machine: run `eval "$(docker-machine env )"`
+ - macOS w/ Docker for Mac: domain socket is used, DOCKER_* should be unset. In Bash run `unset ${!DOCKER_*}`
+ - Other things to check:
+ - Linux: User isn't in 'docker' group. Add and relogin.
+ - Something like 'sudo usermod -a -G docker ${USER}'
+ - RHEL7 bug and workaround: https://bugzilla.redhat.com/show_bug.cgi?id=1119282#c8
+EOF
+ return 1
+ fi
+}
+
+# Wait for background jobs to finish. Return with
+# an error status if any of the jobs failed.
+iam::util::wait-for-jobs() {
+ local fail=0
+ local job
+ for job in $(jobs -p); do
+ wait "${job}" || fail=$((fail + 1))
+ done
+ return ${fail}
+}
+
+# iam::util::join
+# Concatenates the list elements with the delimiter passed as first parameter
+#
+# Ex: iam::util::join , a b c
+# -> a,b,c
+function iam::util::join {
+ local IFS="$1"
+ shift
+ echo "$*"
+}
+
+# Downloads cfssl/cfssljson/cfssl-certinfo into $1 directory if they do not already exist in PATH
+#
+# Assumed vars:
+# $1 (cfssl directory) (optional)
+#
+# Sets:
+# CFSSL_BIN: The path of the installed cfssl binary
+# CFSSLJSON_BIN: The path of the installed cfssljson binary
+# CFSSLCERTINFO_BIN: The path of the installed cfssl-certinfo binary
+#
+function iam::util::ensure-cfssl {
+ if command -v cfssl &>/dev/null && command -v cfssljson &>/dev/null && command -v cfssl-certinfo &>/dev/null; then
+ CFSSL_BIN=$(command -v cfssl)
+ CFSSLJSON_BIN=$(command -v cfssljson)
+ CFSSLCERTINFO_BIN=$(command -v cfssl-certinfo)
+ return 0
+ fi
+
+ host_arch=$(iam::util::host_arch)
+
+ if [[ "${host_arch}" != "amd64" ]]; then
+ echo "Cannot download cfssl on non-amd64 hosts and cfssl does not appear to be installed."
+ echo "Please install cfssl, cfssljson and cfssl-certinfo and verify they are in \$PATH."
+ echo "Hint: export PATH=\$PATH:\$GOPATH/bin; go get -u github.com/cloudflare/cfssl/cmd/..."
+ exit 1
+ fi
+
+ # Create a temp dir for cfssl if no directory was given
+ local cfssldir=${1:-}
+ if [[ -z "${cfssldir}" ]]; then
+ cfssldir="$HOME/bin"
+ fi
+
+ mkdir -p "${cfssldir}"
+ pushd "${cfssldir}" > /dev/null || return 1
+
+ echo "Unable to successfully run 'cfssl' from ${PATH}; downloading instead..."
+ kernel=$(uname -s)
+ case "${kernel}" in
+ Linux)
+ curl --retry 10 -L -o cfssl https://pkg.cfssl.org/R1.2/cfssl_linux-amd64
+ curl --retry 10 -L -o cfssljson https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
+ curl --retry 10 -L -o cfssl-certinfo https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64
+ ;;
+ Darwin)
+ curl --retry 10 -L -o cfssl https://pkg.cfssl.org/R1.2/cfssl_darwin-amd64
+ curl --retry 10 -L -o cfssljson https://pkg.cfssl.org/R1.2/cfssljson_darwin-amd64
+ curl --retry 10 -L -o cfssl-certinfo https://pkg.cfssl.org/R1.2/cfssl-certinfo_darwin-amd64
+ ;;
+ *)
+ echo "Unknown, unsupported platform: ${kernel}." >&2
+ echo "Supported platforms: Linux, Darwin." >&2
+ exit 2
+ esac
+
+ chmod +x cfssl || true
+ chmod +x cfssljson || true
+ chmod +x cfssl-certinfo || true
+
+ CFSSL_BIN="${cfssldir}/cfssl"
+ CFSSLJSON_BIN="${cfssldir}/cfssljson"
+ CFSSLCERTINFO_BIN="${cfssldir}/cfssl-certinfo"
+ if [[ ! -x ${CFSSL_BIN} || ! -x ${CFSSLJSON_BIN} || ! -x ${CFSSLCERTINFO_BIN} ]]; then
+ echo "Failed to download 'cfssl'."
+ echo "Please install cfssl, cfssljson and cfssl-certinfo and verify they are in \$PATH."
+ echo "Hint: export PATH=\$PATH:\$GOPATH/bin; go get -u github.com/cloudflare/cfssl/cmd/..."
+ exit 1
+ fi
+ popd > /dev/null || return 1
+}
+
+# iam::util::ensure-gnu-sed
+# Determines which sed binary is gnu-sed on linux/darwin
+#
+# Sets:
+# SED: The name of the gnu-sed binary
+#
+function iam::util::ensure-gnu-sed {
+ # NOTE: the echo below is a workaround to ensure sed is executed before the grep.
+ # see: https://github.com/iamrnetes/iamrnetes/issues/87251
+ sed_help="$(LANG=C sed --help 2>&1 || true)"
+ if echo "${sed_help}" | grep -q "GNU\|BusyBox"; then
+ SED="sed"
+ elif command -v gsed &>/dev/null; then
+ SED="gsed"
+ else
+ iam::log::error "Failed to find GNU sed as sed or gsed. If you are on Mac: brew install gnu-sed." >&2
+ return 1
+ fi
+ iam::util::sourced_variable "${SED}"
+}
+
+# iam::util::check-file-in-alphabetical-order
+# Check that the file is in alphabetical order
+#
+function iam::util::check-file-in-alphabetical-order {
+ local failure_file="$1"
+ if ! diff -u "${failure_file}" <(LC_ALL=C sort "${failure_file}"); then
+ {
+ echo
+ echo "${failure_file} is not in alphabetical order. Please sort it:"
+ echo
+ echo " LC_ALL=C sort -o ${failure_file} ${failure_file}"
+ echo
+ } >&2
+ false
+ fi
+}
+
+# iam::util::require-jq
+# Checks whether jq is installed.
+function iam::util::require-jq {
+ if ! command -v jq &>/dev/null; then
+ echo "jq not found. Please install." 1>&2
+ return 1
+ fi
+}
+
+# outputs md5 hash of $1, works on macOS and Linux
+function iam::util::md5() {
+ if which md5 >/dev/null 2>&1; then
+ md5 -q "$1"
+ else
+ md5sum "$1" | awk '{ print $1 }'
+ fi
+}
+
+# iam::util::read-array
+# Reads in stdin and adds it line by line to the array provided. This can be
+# used instead of "mapfile -t", and is bash 3 compatible.
+#
+# Assumed vars:
+# $1 (name of array to create/modify)
+#
+# Example usage:
+# iam::util::read-array files < <(ls -1)
+#
+function iam::util::read-array {
+ local i=0
+ unset -v "$1"
+ while IFS= read -r "$1[i++]"; do :; done
+ eval "[[ \${$1[--i]} ]]" || unset "$1[i]" # ensures last element isn't empty
+}
+
+# Some useful colors.
+if [[ -z "${color_start-}" ]]; then
+ declare -r color_start="\033["
+ declare -r color_red="${color_start}0;31m"
+ declare -r color_yellow="${color_start}0;33m"
+ declare -r color_green="${color_start}0;32m"
+ declare -r color_blue="${color_start}1;34m"
+ declare -r color_cyan="${color_start}1;36m"
+ declare -r color_norm="${color_start}0m"
+
+ iam::util::sourced_variable "${color_start}"
+ iam::util::sourced_variable "${color_red}"
+ iam::util::sourced_variable "${color_yellow}"
+ iam::util::sourced_variable "${color_green}"
+ iam::util::sourced_variable "${color_blue}"
+ iam::util::sourced_variable "${color_cyan}"
+ iam::util::sourced_variable "${color_norm}"
+fi
+
+# ex: ts=2 sw=2 et filetype=sh
diff --git a/scripts/lib/version.sh b/scripts/lib/version.sh
new file mode 100755
index 000000000..0edeac114
--- /dev/null
+++ b/scripts/lib/version.sh
@@ -0,0 +1,137 @@
+#!/usr/bin/env bash
+
+# Copyright 2020 Lingfei Kong . All rights reserved.
+# Use of this source code is governed by a MIT style
+# license that can be found in the LICENSE file.
+
+# -----------------------------------------------------------------------------
+# Version management helpers. These functions help to set, save and load the
+# following variables:
+#
+# IAM_GIT_COMMIT - The git commit id corresponding to this
+# source code.
+# IAM_GIT_TREE_STATE - "clean" indicates no changes since the git commit id
+# "dirty" indicates source code changes after the git commit id
+# "archive" indicates the tree was produced by 'git archive'
+# IAM_GIT_VERSION - "vX.Y" used to indicate the last release version.
+# IAM_GIT_MAJOR - The major part of the version
+# IAM_GIT_MINOR - The minor component of the version
+
+# Grovels through git to set a set of env variables.
+#
+# If IAM_GIT_VERSION_FILE, this function will load from that file instead of
+# querying git.
+iam::version::get_version_vars() {
+ if [[ -n ${IAM_GIT_VERSION_FILE-} ]]; then
+ iam::version::load_version_vars "${IAM_GIT_VERSION_FILE}"
+ return
+ fi
+
+ # If the iamrnetes source was exported through git archive, then
+ # we likely don't have a git tree, but these magic values may be filled in.
+ # shellcheck disable=SC2016,SC2050
+ # Disabled as we're not expanding these at runtime, but rather expecting
+ # that another tool may have expanded these and rewritten the source (!)
+ if [[ '$Format:%%$' == "%" ]]; then
+ IAM_GIT_COMMIT='$Format:%H$'
+ IAM_GIT_TREE_STATE="archive"
+ # When a 'git archive' is exported, the '$Format:%D$' below will look
+ # something like 'HEAD -> release-1.8, tag: v1.8.3' where then 'tag: '
+ # can be extracted from it.
+ if [[ '$Format:%D$' =~ tag:\ (v[^ ,]+) ]]; then
+ IAM_GIT_VERSION="${BASH_REMATCH[1]}"
+ fi
+ fi
+
+ local git=(git --work-tree "${IAM_ROOT}")
+
+ if [[ -n ${IAM_GIT_COMMIT-} ]] || IAM_GIT_COMMIT=$("${git[@]}" rev-parse "HEAD^{commit}" 2>/dev/null); then
+ if [[ -z ${IAM_GIT_TREE_STATE-} ]]; then
+ # Check if the tree is dirty. default to dirty
+ if git_status=$("${git[@]}" status --porcelain 2>/dev/null) && [[ -z ${git_status} ]]; then
+ IAM_GIT_TREE_STATE="clean"
+ else
+ IAM_GIT_TREE_STATE="dirty"
+ fi
+ fi
+
+ # Use git describe to find the version based on tags.
+ if [[ -n ${IAM_GIT_VERSION-} ]] || IAM_GIT_VERSION=$("${git[@]}" describe --tags --always --match='v*' 2>/dev/null); then
+ # This translates the "git describe" to an actual semver.org
+ # compatible semantic version that looks something like this:
+ # v1.1.0-alpha.0.6+84c76d1142ea4d
+ #
+ # TODO: We continue calling this "git version" because so many
+ # downstream consumers are expecting it there.
+ #
+ # These regexes are painful enough in sed...
+ # We don't want to do them in pure shell, so disable SC2001
+ # shellcheck disable=SC2001
+ DASHES_IN_VERSION=$(echo "${IAM_GIT_VERSION}" | sed "s/[^-]//g")
+ if [[ "${DASHES_IN_VERSION}" == "---" ]] ; then
+ # shellcheck disable=SC2001
+ # We have distance to subversion (v1.1.0-subversion-1-gCommitHash)
+ IAM_GIT_VERSION=$(echo "${IAM_GIT_VERSION}" | sed "s/-\([0-9]\{1,\}\)-g\([0-9a-f]\{14\}\)$/.\1\+\2/")
+ elif [[ "${DASHES_IN_VERSION}" == "--" ]] ; then
+ # shellcheck disable=SC2001
+ # We have distance to base tag (v1.1.0-1-gCommitHash)
+ IAM_GIT_VERSION=$(echo "${IAM_GIT_VERSION}" | sed "s/-g\([0-9a-f]\{14\}\)$/+\1/")
+ fi
+ if [[ "${IAM_GIT_TREE_STATE}" == "dirty" ]]; then
+ # git describe --dirty only considers changes to existing files, but
+ # that is problematic since new untracked .go files affect the build,
+ # so use our idea of "dirty" from git status instead.
+ # TODO?
+ #IAM_GIT_VERSION+="-dirty"
+ :
+ fi
+
+
+ # Try to match the "git describe" output to a regex to try to extract
+ # the "major" and "minor" versions and whether this is the exact tagged
+ # version or whether the tree is between two tagged versions.
+ if [[ "${IAM_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?([-].*)?([+].*)?$ ]]; then
+ IAM_GIT_MAJOR=${BASH_REMATCH[1]}
+ IAM_GIT_MINOR=${BASH_REMATCH[2]}
+ if [[ -n "${BASH_REMATCH[4]}" ]]; then
+ IAM_GIT_MINOR+="+"
+ fi
+ fi
+
+ # If IAM_GIT_VERSION is not a valid Semantic Version, then refuse to build.
+ if ! [[ "${IAM_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
+ echo "IAM_GIT_VERSION should be a valid Semantic Version. Current value: ${IAM_GIT_VERSION}"
+ echo "Please see more details here: https://semver.org"
+ exit 1
+ fi
+ fi
+ fi
+}
+
+# Saves the environment flags to $1
+iam::version::save_version_vars() {
+ local version_file=${1-}
+ [[ -n ${version_file} ]] || {
+ echo "!!! Internal error. No file specified in iam::version::save_version_vars"
+ return 1
+ }
+
+ cat <"${version_file}"
+IAM_GIT_COMMIT='${IAM_GIT_COMMIT-}'
+IAM_GIT_TREE_STATE='${IAM_GIT_TREE_STATE-}'
+IAM_GIT_VERSION='${IAM_GIT_VERSION-}'
+IAM_GIT_MAJOR='${IAM_GIT_MAJOR-}'
+IAM_GIT_MINOR='${IAM_GIT_MINOR-}'
+EOF
+}
+
+# Loads up the version variables from file $1
+iam::version::load_version_vars() {
+ local version_file=${1-}
+ [[ -n ${version_file} ]] || {
+ echo "!!! Internal error. No file specified in iam::version::load_version_vars"
+ return 1
+ }
+
+ source "${version_file}"
+}
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index 255306062..bf503db63 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -132,24 +132,17 @@ go.build.multiarch: go.build.verify $(foreach p,$(PLATFORMS),$(addprefix go.buil
go.lint: tools.verify.golangci-lint
@echo "===========> Run golangci to lint source codes"
@$(TOOLS_DIR)/golangci-lint run --color always -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/...
+
## go.test: Run unit test
.PHONY: go.test
go.test:
@$(GO) test ./...
-# ## go.test.junit-report: Run unit test
-# .PHONY: go.test.junit-report
-# go.test.junit-report: tools.verify.go-junit-report
-# @echo "===========> Run unit test > $(TMP_DIR)/report.xml"
-# @$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 $(GO_BUILD_FLAGS) ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml
-# @sed -i '/mock_.*.go/d' $(TMP_DIR)/coverage.out
-# @echo "===========> Test coverage of Go code is reported to $(TMP_DIR)/coverage.html by generating HTML"
-# @$(GO) tool cover -html=$(TMP_DIR)/coverage.out -o $(TMP_DIR)/coverage.html
-
## go.test.junit-report: Run unit test
.PHONY: go.test.junit-report
go.test.junit-report: tools.verify.go-junit-report
@echo "===========> Run unit test > $(TMP_DIR)/report.xml"
+# @$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 $(GO_BUILD_FLAGS) ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml
@$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml
@sed -i '/mock_.*.go/d' $(TMP_DIR)/coverage.out
@echo "===========> Test coverage of Go code is reported to $(TMP_DIR)/coverage.html by generating HTML"
From 21789bd7ac8cea24fd660fd8468f6c3c50dbab4d Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 11:15:20 +0800
Subject: [PATCH 09/73] feat: add copyright
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.docker-compose_cfg/grafana.ini | 2 +-
cmd/api/deploy.Dockerfile | 14 +
cmd/api/main.go | 14 +
cmd/cmdutils/main.go | 14 +
cmd/crontask/deploy.Dockerfile | 14 +
cmd/crontask/main.go | 14 +
cmd/msggateway/deploy.Dockerfile | 14 +
cmd/msggateway/main.go | 14 +
cmd/msgtransfer/deploy.Dockerfile | 14 +
cmd/msgtransfer/main.go | 14 +
cmd/push/deploy.Dockerfile | 14 +
cmd/push/main.go | 14 +
cmd/rpc/auth/deploy.Dockerfile | 14 +
cmd/rpc/auth/main.go | 14 +
cmd/rpc/conversation/deploy.Dockerfile | 14 +
cmd/rpc/conversation/main.go | 14 +
cmd/rpc/friend/deploy.Dockerfile | 14 +
cmd/rpc/friend/main.go | 14 +
cmd/rpc/group/deploy.Dockerfile | 14 +
cmd/rpc/group/main.go | 14 +
cmd/rpc/msg/deploy.Dockerfile | 14 +
cmd/rpc/msg/main.go | 14 +
cmd/rpc/third/deploy.Dockerfile | 14 +
cmd/rpc/third/main.go | 14 +
cmd/rpc/user/deploy.Dockerfile | 14 +
cmd/rpc/user/main.go | 14 +
config/config.yaml | 14 +
config/notification.yaml | 14 +
internal/api/auth.go | 14 +
internal/api/conversation.go | 14 +
internal/api/custom_validator.go | 14 +
internal/api/friend.go | 14 +
internal/api/group.go | 14 +
internal/api/msg.go | 14 +
internal/api/route.go | 14 +
internal/api/statistics.go | 14 +
internal/api/third.go | 14 +
internal/api/user.go | 14 +
internal/msggateway/callback.go | 14 +
internal/msggateway/client.go | 14 +
internal/msggateway/compressor.go | 14 +
internal/msggateway/constant.go | 14 +
internal/msggateway/context.go | 14 +
internal/msggateway/encoder.go | 14 +
internal/msggateway/http_error.go | 14 +
internal/msggateway/hub_server.go | 14 +
internal/msggateway/init.go | 14 +
internal/msggateway/long_conn.go | 14 +
internal/msggateway/message_handler.go | 14 +
internal/msggateway/n_ws_server.go | 14 +
internal/msggateway/options.go | 14 +
internal/msggateway/user_map.go | 14 +
internal/msgtransfer/init.go | 14 +
internal/msgtransfer/modify_msg_handler.go | 14 +
.../msgtransfer/online_history_msg_handler.go | 14 +
.../online_msg_to_mongo_handler.go | 14 +
internal/push/callback.go | 14 +
internal/push/consumer_init.go | 14 +
internal/push/offlinepush/fcm/push.go | 14 +
internal/push/offlinepush/fcm/push_test.go | 14 +
internal/push/offlinepush/getui/body.go | 14 +
internal/push/offlinepush/getui/push.go | 14 +
.../push/offlinepush/jpush/body/audience.go | 14 +
.../push/offlinepush/jpush/body/message.go | 14 +
.../offlinepush/jpush/body/notification.go | 14 +
.../push/offlinepush/jpush/body/options.go | 14 +
.../push/offlinepush/jpush/body/platform.go | 14 +
.../push/offlinepush/jpush/body/pushobj.go | 14 +
internal/push/offlinepush/jpush/push.go | 14 +
.../push/offlinepush/offlinepush_interface.go | 14 +
internal/push/push_handler.go | 14 +
internal/push/push_rpc_server.go | 14 +
internal/push/push_to_client.go | 14 +
internal/rpc/auth/auth.go | 14 +
internal/rpc/conversation/conversaion.go | 14 +
internal/rpc/friend/black.go | 14 +
internal/rpc/friend/callback.go | 14 +
internal/rpc/friend/friend.go | 14 +
internal/rpc/group/cache.go | 14 +
internal/rpc/group/callback.go | 14 +
internal/rpc/group/convert.go | 14 +
internal/rpc/group/db_map.go | 14 +
internal/rpc/group/fill.go | 14 +
internal/rpc/group/group.go | 14 +
internal/rpc/group/super_group.go | 14 +
internal/rpc/msg/as_read.go | 14 +
internal/rpc/msg/callback.go | 14 +
internal/rpc/msg/delete.go | 14 +
internal/rpc/msg/extend_msg.go | 14 +
internal/rpc/msg/extend_msg_callback.go | 14 +
internal/rpc/msg/lock.go | 14 +
internal/rpc/msg/message_interceptor.go | 14 +
internal/rpc/msg/msg_status.go | 14 +
internal/rpc/msg/revoke.go | 14 +
internal/rpc/msg/send.go | 14 +
internal/rpc/msg/seq.go | 14 +
internal/rpc/msg/server.go | 14 +
internal/rpc/msg/sync_msg.go | 14 +
internal/rpc/msg/utils.go | 14 +
internal/rpc/msg/verify.go | 14 +
internal/rpc/statistics/statistics.go | 14 +
internal/rpc/third/s3.go | 14 +
internal/rpc/third/third.go | 14 +
internal/rpc/user/statistics.go | 14 +
internal/rpc/user/user.go | 14 +
internal/tools/cron_task.go | 14 +
internal/tools/msg.go | 14 +
internal/tools/msg_test.go | 14 +
pkg/a2r/api2rpc.go | 14 +
pkg/apiresp/gin.go | 14 +
pkg/apiresp/http.go | 14 +
pkg/apiresp/resp.go | 14 +
pkg/apistruct/auth.go | 14 +
pkg/apistruct/aws.go | 14 +
pkg/apistruct/conversation.go | 14 +
pkg/apistruct/cos.go | 14 +
pkg/apistruct/friend.go | 14 +
pkg/apistruct/group.go | 14 +
pkg/apistruct/manage.go | 14 +
pkg/apistruct/msg.go | 14 +
pkg/apistruct/oss.go | 14 +
pkg/apistruct/pagination.go | 14 +
pkg/apistruct/public.go | 14 +
pkg/apistruct/super_group.go | 14 +
pkg/apistruct/third.go | 14 +
pkg/callbackstruct/common.go | 14 +
pkg/callbackstruct/friend.go | 14 +
pkg/callbackstruct/group.go | 14 +
pkg/callbackstruct/message.go | 14 +
pkg/callbackstruct/msg_gateway.go | 14 +
pkg/callbackstruct/push.go | 14 +
pkg/checker/check.go | 14 +
pkg/common/cmd/api.go | 14 +
pkg/common/cmd/cron_task.go | 14 +
pkg/common/cmd/msg_gateway.go | 14 +
pkg/common/cmd/msg_transfer.go | 14 +
pkg/common/cmd/msg_utils.go | 14 +
pkg/common/cmd/root.go | 14 +
pkg/common/cmd/rpc.go | 14 +
pkg/common/config/config.go | 14 +
pkg/common/config/parse.go | 14 +
pkg/common/constant/constant.go | 14 +
pkg/common/constant/limit.go | 14 +
pkg/common/constant/platform_id_to_name.go | 14 +
pkg/common/convert/black.go | 14 +
pkg/common/convert/conversation.go | 14 +
pkg/common/convert/friend.go | 14 +
pkg/common/convert/group.go | 14 +
pkg/common/convert/msg.go | 14 +
pkg/common/convert/user.go | 14 +
pkg/common/db/cache/black.go | 14 +
pkg/common/db/cache/conversation.go | 14 +
pkg/common/db/cache/extend_msg_set.go | 14 +
pkg/common/db/cache/friend.go | 14 +
pkg/common/db/cache/group.go | 14 +
pkg/common/db/cache/init_redis.go | 14 +
pkg/common/db/cache/meta_cache.go | 14 +
pkg/common/db/cache/msg.go | 14 +
pkg/common/db/cache/user.go | 14 +
pkg/common/db/controller/auth.go | 14 +
pkg/common/db/controller/black.go | 14 +
pkg/common/db/controller/chatlog.go | 14 +
pkg/common/db/controller/conversation.go | 14 +
pkg/common/db/controller/extend_msg.go | 14 +
pkg/common/db/controller/friend.go | 14 +
pkg/common/db/controller/group.go | 14 +
pkg/common/db/controller/msg.go | 14 +
pkg/common/db/controller/msg_test.go | 14 +
pkg/common/db/controller/push.go | 14 +
pkg/common/db/controller/storage.go | 14 +
pkg/common/db/controller/third.go | 14 +
pkg/common/db/controller/user.go | 14 +
pkg/common/db/localcache/conversation.go | 14 +
pkg/common/db/localcache/group.go | 14 +
pkg/common/db/localcache/meta_local_cache.go | 14 +
pkg/common/db/obj/minio.go | 14 +
pkg/common/db/obj/obj.go | 14 +
pkg/common/db/ormutil/utils.go | 14 +
pkg/common/db/relation/black_model.go | 14 +
pkg/common/db/relation/chat_log_model.go | 14 +
pkg/common/db/relation/conversation_model.go | 14 +
pkg/common/db/relation/friend_model.go | 14 +
.../db/relation/friend_request_model.go | 14 +
pkg/common/db/relation/group_member_model.go | 14 +
pkg/common/db/relation/group_model.go | 14 +
pkg/common/db/relation/group_request_model.go | 14 +
pkg/common/db/relation/meta_db.go | 14 +
pkg/common/db/relation/mysql_init.go | 14 +
pkg/common/db/relation/object_hash_model.go | 14 +
pkg/common/db/relation/object_info_model.go | 14 +
pkg/common/db/relation/object_put_model.go | 14 +
pkg/common/db/relation/user_model.go | 14 +
pkg/common/db/table/relation/black.go | 14 +
pkg/common/db/table/relation/chatlog.go | 14 +
pkg/common/db/table/relation/conversation.go | 14 +
pkg/common/db/table/relation/friend.go | 14 +
.../db/table/relation/friend_request.go | 14 +
pkg/common/db/table/relation/group.go | 14 +
pkg/common/db/table/relation/group_member.go | 14 +
pkg/common/db/table/relation/group_request.go | 14 +
pkg/common/db/table/relation/object_hash.go | 14 +
pkg/common/db/table/relation/object_info.go | 14 +
pkg/common/db/table/relation/object_put.go | 14 +
pkg/common/db/table/relation/user.go | 14 +
pkg/common/db/table/relation/utils.go | 14 +
pkg/common/db/table/unrelation/common.go | 14 +
.../db/table/unrelation/extend_msg_set.go | 14 +
pkg/common/db/table/unrelation/msg.go | 14 +
pkg/common/db/table/unrelation/super_group.go | 14 +
pkg/common/db/tx/gorm.go | 14 +
pkg/common/db/tx/mongo.go | 14 +
pkg/common/db/tx/tx.go | 14 +
pkg/common/db/unrelation/extend_msg.go | 14 +
pkg/common/db/unrelation/mongo.go | 14 +
pkg/common/db/unrelation/msg.go | 14 +
pkg/common/db/unrelation/super_group.go | 14 +
pkg/common/kafka/consumer.go | 14 +
pkg/common/kafka/producer.go | 14 +
pkg/common/log/color.go | 14 +
pkg/common/log/logger.go | 14 +
pkg/common/log/sql_logger.go | 14 +
pkg/common/log/zap.go | 14 +
pkg/common/log/zk_logger.go | 14 +
pkg/common/mcontext/ctx.go | 14 +
pkg/common/mw/check.go | 14 +
pkg/common/mw/check_test.go | 14 +
pkg/common/mw/gin.go | 14 +
pkg/common/mw/intercept_chain.go | 14 +
pkg/common/mw/rpc_client_interceptor.go | 14 +
pkg/common/mw/rpc_server_interceptor.go | 14 +
pkg/common/mw/specialerror/error.go | 14 +
pkg/common/network/ip.go | 14 +
pkg/common/prome/gather.go | 14 +
pkg/common/prome/prometheus.go | 14 +
pkg/common/tokenverify/jwt_token.go | 14 +
pkg/common/tokenverify/jwt_token_test.go | 14 +
pkg/discoveryregistry/discovery_register.go | 14 +
pkg/discoveryregistry/zookeeper/conf.go | 14 +
pkg/discoveryregistry/zookeeper/discover.go | 14 +
pkg/discoveryregistry/zookeeper/register.go | 14 +
pkg/discoveryregistry/zookeeper/resolver.go | 14 +
pkg/discoveryregistry/zookeeper/zk.go | 14 +
pkg/errs/code.go | 14 +
pkg/errs/coderr.go | 14 +
pkg/errs/predefine.go | 14 +
pkg/errs/relation.go | 14 +
pkg/proto/auth/auth.go | 14 +
pkg/proto/auth/auth.proto | 14 +
pkg/proto/conversation/conversation.go | 14 +
pkg/proto/conversation/conversation.proto | 14 +
pkg/proto/errinfo/errinfo.proto | 14 +
pkg/proto/friend/friend.go | 14 +
pkg/proto/friend/friend.proto | 14 +
pkg/proto/gen.sh | 14 +
pkg/proto/group/group.go | 14 +
pkg/proto/group/group.proto | 14 +
pkg/proto/msg/msg.go | 14 +
pkg/proto/msg/msg.proto | 14 +
pkg/proto/msggateway/msggateway.go | 14 +
pkg/proto/msggateway/msggateway.proto | 14 +
pkg/proto/push/push.go | 14 +
pkg/proto/push/push.proto | 14 +
pkg/proto/sdkws/sdkws.go | 14 +
pkg/proto/sdkws/sdkws.proto | 14 +
pkg/proto/statistics/statistics.proto | 14 +
pkg/proto/third/third.go | 14 +
pkg/proto/third/third.proto | 14 +
pkg/proto/user/user.go | 14 +
pkg/proto/user/user.proto | 14 +
pkg/proto/wrapperspb/wrapperspb.go | 14 +
pkg/proto/wrapperspb/wrapperspb.proto | 14 +
pkg/rpcclient/auth.go | 14 +
pkg/rpcclient/conversation.go | 14 +
pkg/rpcclient/friend.go | 14 +
pkg/rpcclient/group.go | 14 +
pkg/rpcclient/msg.go | 14 +
pkg/rpcclient/notification/common.go | 14 +
pkg/rpcclient/notification/conevrsation.go | 14 +
pkg/rpcclient/notification/extend_msg.go | 14 +
pkg/rpcclient/notification/friend.go | 14 +
pkg/rpcclient/notification/group.go | 14 +
pkg/rpcclient/push.go | 14 +
pkg/rpcclient/third.go | 14 +
pkg/rpcclient/user.go | 14 +
pkg/startrpc/start.go | 14 +
pkg/statistics/statistics.go | 14 +
pkg/utils/base64.go | 14 +
pkg/utils/callback.go | 14 +
pkg/utils/encryption.go | 14 +
pkg/utils/file.go | 14 +
pkg/utils/get_server_ip.go | 14 +
pkg/utils/id.go | 14 +
pkg/utils/id_test.go | 14 +
pkg/utils/image.go | 14 +
pkg/utils/image_test.go | 14 +
pkg/utils/map.go | 14 +
pkg/utils/md5_test.go | 14 +
pkg/utils/options.go | 14 +
pkg/utils/page.go | 14 +
pkg/utils/platform_number_id_to_name_test.go | 14 +
pkg/utils/retry/retry.go | 14 +
pkg/utils/retry/stratey.go | 14 +
pkg/utils/splitter/tools.go | 14 +
pkg/utils/utils.go | 14 +
pkg/utils/utils_v2.go | 14 +
pkg/utils/utils_v2_test.go | 14 +
scripts/batch_build_all_service.sh | 14 +
scripts/batch_start_all.sh | 14 +
scripts/build_all_service.sh | 14 +
scripts/build_images.sh | 14 +
scripts/build_push_k8s_images.sh | 14 +
scripts/check_all.sh | 14 +
scripts/coverage.sh | 14 +
scripts/docker_check_service.sh | 14 +
scripts/docker_start_all.sh | 14 +
scripts/ensure_tag.sh | 23 ++
scripts/enterprise/check_all.sh | 14 +
scripts/enterprise/function.sh | 14 +
scripts/env_check.sh | 14 +
scripts/function.sh | 14 +
scripts/githooks/pre-commit | 1 -
scripts/init_pwd.sh | 14 +
scripts/lib/color.sh | 18 +-
scripts/lib/golang.sh | 152 ++++----
scripts/lib/init.sh | 30 +-
scripts/lib/logging.sh | 62 +--
scripts/lib/release.sh | 352 +++++++++---------
scripts/lib/util.sh | 204 +++++-----
scripts/lib/version.sh | 94 ++---
scripts/make-rules/gen.mk | 4 +-
scripts/make-rules/tools.mk | 2 +-
scripts/mongo-init.sh | 14 +
scripts/msg_gateway_start.sh | 14 +
scripts/msg_transfer_start.sh | 14 +
scripts/push_start.sh | 14 +
scripts/release.sh | 42 ++-
scripts/sdk_svr_start.sh | 14 +
scripts/start_all.sh | 14 +
scripts/start_cron.sh | 14 +
scripts/start_rpc_service.sh | 14 +
scripts/stop_all.sh | 14 +
341 files changed, 5138 insertions(+), 440 deletions(-)
create mode 100644 scripts/ensure_tag.sh
diff --git a/.docker-compose_cfg/grafana.ini b/.docker-compose_cfg/grafana.ini
index b9380d7f1..8c1d9dd11 100644
--- a/.docker-compose_cfg/grafana.ini
+++ b/.docker-compose_cfg/grafana.ini
@@ -633,7 +633,7 @@ active_sync_enabled = true
#################################### AWS ###########################
[aws]
# Enter a comma-separated list of allowed AWS authentication providers.
-# Options are: default (AWS SDK Default), keys (Access && secret key), credentials (Credentials field), ec2_iam_role (EC2 IAM Role)
+# Options are: default (AWS SDK Default), keys (Access && secret key), credentials (Credentials field), ec2_iam_role (EC2 OpenIM Role)
allowed_auth_providers = default,keys,credentials
# Allow AWS users to assume a role using temporary security credentials.
diff --git a/cmd/api/deploy.Dockerfile b/cmd/api/deploy.Dockerfile
index ad397ca23..a236c02f0 100644
--- a/cmd/api/deploy.Dockerfile
+++ b/cmd/api/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/api/main.go b/cmd/api/main.go
index fb613b4da..aac83a805 100644
--- a/cmd/api/main.go
+++ b/cmd/api/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/cmdutils/main.go b/cmd/cmdutils/main.go
index 8c68fca6d..64079c7e1 100644
--- a/cmd/cmdutils/main.go
+++ b/cmd/cmdutils/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/crontask/deploy.Dockerfile b/cmd/crontask/deploy.Dockerfile
index 80ba5abf0..e80006def 100644
--- a/cmd/crontask/deploy.Dockerfile
+++ b/cmd/crontask/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/crontask/main.go b/cmd/crontask/main.go
index 21a1cdff1..73deb8c66 100644
--- a/cmd/crontask/main.go
+++ b/cmd/crontask/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/msggateway/deploy.Dockerfile b/cmd/msggateway/deploy.Dockerfile
index bacb37b74..7310fe0dc 100644
--- a/cmd/msggateway/deploy.Dockerfile
+++ b/cmd/msggateway/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/msggateway/main.go b/cmd/msggateway/main.go
index 695e45e1c..2782e4fd3 100644
--- a/cmd/msggateway/main.go
+++ b/cmd/msggateway/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/msgtransfer/deploy.Dockerfile b/cmd/msgtransfer/deploy.Dockerfile
index 4e48f8e3d..0c9485694 100644
--- a/cmd/msgtransfer/deploy.Dockerfile
+++ b/cmd/msgtransfer/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/msgtransfer/main.go b/cmd/msgtransfer/main.go
index 7f8d1ce80..aef347793 100644
--- a/cmd/msgtransfer/main.go
+++ b/cmd/msgtransfer/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/push/deploy.Dockerfile b/cmd/push/deploy.Dockerfile
index f474b9ab2..79b8cb4f1 100644
--- a/cmd/push/deploy.Dockerfile
+++ b/cmd/push/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/push/main.go b/cmd/push/main.go
index 05d8e70b4..03db8ae03 100644
--- a/cmd/push/main.go
+++ b/cmd/push/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/rpc/auth/deploy.Dockerfile b/cmd/rpc/auth/deploy.Dockerfile
index 700e85d4f..a7b69cc0a 100644
--- a/cmd/rpc/auth/deploy.Dockerfile
+++ b/cmd/rpc/auth/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/rpc/auth/main.go b/cmd/rpc/auth/main.go
index 4d6986f84..524804988 100644
--- a/cmd/rpc/auth/main.go
+++ b/cmd/rpc/auth/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/rpc/conversation/deploy.Dockerfile b/cmd/rpc/conversation/deploy.Dockerfile
index 6b3a8ad40..4e7591499 100644
--- a/cmd/rpc/conversation/deploy.Dockerfile
+++ b/cmd/rpc/conversation/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/rpc/conversation/main.go b/cmd/rpc/conversation/main.go
index 9f227fe17..fec8226f8 100644
--- a/cmd/rpc/conversation/main.go
+++ b/cmd/rpc/conversation/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/rpc/friend/deploy.Dockerfile b/cmd/rpc/friend/deploy.Dockerfile
index a57f9ccdc..d159ee0dd 100644
--- a/cmd/rpc/friend/deploy.Dockerfile
+++ b/cmd/rpc/friend/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/rpc/friend/main.go b/cmd/rpc/friend/main.go
index 0838eaf5b..fbd44038e 100644
--- a/cmd/rpc/friend/main.go
+++ b/cmd/rpc/friend/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/rpc/group/deploy.Dockerfile b/cmd/rpc/group/deploy.Dockerfile
index 1d083c927..e676708d5 100644
--- a/cmd/rpc/group/deploy.Dockerfile
+++ b/cmd/rpc/group/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/rpc/group/main.go b/cmd/rpc/group/main.go
index b73dd73c9..06baac155 100644
--- a/cmd/rpc/group/main.go
+++ b/cmd/rpc/group/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/rpc/msg/deploy.Dockerfile b/cmd/rpc/msg/deploy.Dockerfile
index 9b5f4194d..8e6307ccb 100644
--- a/cmd/rpc/msg/deploy.Dockerfile
+++ b/cmd/rpc/msg/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/rpc/msg/main.go b/cmd/rpc/msg/main.go
index 7b9756680..356081d33 100644
--- a/cmd/rpc/msg/main.go
+++ b/cmd/rpc/msg/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/rpc/third/deploy.Dockerfile b/cmd/rpc/third/deploy.Dockerfile
index 3c5b23120..462798b00 100644
--- a/cmd/rpc/third/deploy.Dockerfile
+++ b/cmd/rpc/third/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/rpc/third/main.go b/cmd/rpc/third/main.go
index 7705852d7..c070e6811 100644
--- a/cmd/rpc/third/main.go
+++ b/cmd/rpc/third/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/cmd/rpc/user/deploy.Dockerfile b/cmd/rpc/user/deploy.Dockerfile
index c0f0956e8..047698788 100644
--- a/cmd/rpc/user/deploy.Dockerfile
+++ b/cmd/rpc/user/deploy.Dockerfile
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
FROM ubuntu
WORKDIR /Open-IM-Server/bin
diff --git a/cmd/rpc/user/main.go b/cmd/rpc/user/main.go
index dfebb307d..6d6d9008d 100644
--- a/cmd/rpc/user/main.go
+++ b/cmd/rpc/user/main.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
diff --git a/config/config.yaml b/config/config.yaml
index 90e8a6913..def91d2b5 100644
--- a/config/config.yaml
+++ b/config/config.yaml
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
#OpenIM config
diff --git a/config/notification.yaml b/config/notification.yaml
index 4b0f3a180..c25c58ee3 100644
--- a/config/notification.yaml
+++ b/config/notification.yaml
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
groupCreated:
isSendMsg: true #是否发送消息,false不发消息为无声的触发同步。true发消息需要触发会话,rpc notification直接发两次,一次消息一次通知, options字段isNotification是否为通知
reliabilityLevel: 1 # 1为online才发送 2为必达
diff --git a/internal/api/auth.go b/internal/api/auth.go
index a9cf17707..531b39622 100644
--- a/internal/api/auth.go
+++ b/internal/api/auth.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package api
import (
diff --git a/internal/api/conversation.go b/internal/api/conversation.go
index 767cc8517..7f1732fec 100644
--- a/internal/api/conversation.go
+++ b/internal/api/conversation.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package api
import (
diff --git a/internal/api/custom_validator.go b/internal/api/custom_validator.go
index b434c792e..42e50647f 100644
--- a/internal/api/custom_validator.go
+++ b/internal/api/custom_validator.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package api
import (
diff --git a/internal/api/friend.go b/internal/api/friend.go
index 8fe9033d5..60a08a8e7 100644
--- a/internal/api/friend.go
+++ b/internal/api/friend.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package api
import (
diff --git a/internal/api/group.go b/internal/api/group.go
index c165f8aab..432645caa 100644
--- a/internal/api/group.go
+++ b/internal/api/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package api
import (
diff --git a/internal/api/msg.go b/internal/api/msg.go
index 6f0cf7033..a4da4ea7e 100644
--- a/internal/api/msg.go
+++ b/internal/api/msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package api
import (
diff --git a/internal/api/route.go b/internal/api/route.go
index 8a786dc6f..b014f66ab 100644
--- a/internal/api/route.go
+++ b/internal/api/route.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package api
import (
diff --git a/internal/api/statistics.go b/internal/api/statistics.go
index 4a85dd5ef..5b5de01d9 100644
--- a/internal/api/statistics.go
+++ b/internal/api/statistics.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package api
import (
diff --git a/internal/api/third.go b/internal/api/third.go
index 559869f1e..79be58a46 100644
--- a/internal/api/third.go
+++ b/internal/api/third.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package api
import (
diff --git a/internal/api/user.go b/internal/api/user.go
index d3b7bae0e..e99e17b00 100644
--- a/internal/api/user.go
+++ b/internal/api/user.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package api
import (
diff --git a/internal/msggateway/callback.go b/internal/msggateway/callback.go
index 79bcdac97..d705e25f0 100644
--- a/internal/msggateway/callback.go
+++ b/internal/msggateway/callback.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import (
diff --git a/internal/msggateway/client.go b/internal/msggateway/client.go
index ef92438e6..439a98fee 100644
--- a/internal/msggateway/client.go
+++ b/internal/msggateway/client.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import (
diff --git a/internal/msggateway/compressor.go b/internal/msggateway/compressor.go
index a37c74ccd..97a9b1eff 100644
--- a/internal/msggateway/compressor.go
+++ b/internal/msggateway/compressor.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import (
diff --git a/internal/msggateway/constant.go b/internal/msggateway/constant.go
index 58ee6e940..043c9d688 100644
--- a/internal/msggateway/constant.go
+++ b/internal/msggateway/constant.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import "time"
diff --git a/internal/msggateway/context.go b/internal/msggateway/context.go
index 61f4d7970..e5ccc00f4 100644
--- a/internal/msggateway/context.go
+++ b/internal/msggateway/context.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import (
diff --git a/internal/msggateway/encoder.go b/internal/msggateway/encoder.go
index 6915766c6..a34a66e66 100644
--- a/internal/msggateway/encoder.go
+++ b/internal/msggateway/encoder.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import (
diff --git a/internal/msggateway/http_error.go b/internal/msggateway/http_error.go
index fd00276fb..03121aba3 100644
--- a/internal/msggateway/http_error.go
+++ b/internal/msggateway/http_error.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import "github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
diff --git a/internal/msggateway/hub_server.go b/internal/msggateway/hub_server.go
index 6916f5309..a7d571e20 100644
--- a/internal/msggateway/hub_server.go
+++ b/internal/msggateway/hub_server.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import (
diff --git a/internal/msggateway/init.go b/internal/msggateway/init.go
index c21ac02ce..3ec2a56ac 100644
--- a/internal/msggateway/init.go
+++ b/internal/msggateway/init.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import (
diff --git a/internal/msggateway/long_conn.go b/internal/msggateway/long_conn.go
index 911e9a4a1..309ec2d8b 100644
--- a/internal/msggateway/long_conn.go
+++ b/internal/msggateway/long_conn.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import (
diff --git a/internal/msggateway/message_handler.go b/internal/msggateway/message_handler.go
index 73b22b83d..874101a05 100644
--- a/internal/msggateway/message_handler.go
+++ b/internal/msggateway/message_handler.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import (
diff --git a/internal/msggateway/n_ws_server.go b/internal/msggateway/n_ws_server.go
index c1ec5d076..53469fca8 100644
--- a/internal/msggateway/n_ws_server.go
+++ b/internal/msggateway/n_ws_server.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import (
diff --git a/internal/msggateway/options.go b/internal/msggateway/options.go
index a54ffe880..cee415f99 100644
--- a/internal/msggateway/options.go
+++ b/internal/msggateway/options.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import "time"
diff --git a/internal/msggateway/user_map.go b/internal/msggateway/user_map.go
index 46bdb16a4..9e6757731 100644
--- a/internal/msggateway/user_map.go
+++ b/internal/msggateway/user_map.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import (
diff --git a/internal/msgtransfer/init.go b/internal/msgtransfer/init.go
index 5b82a7d30..946048f0c 100644
--- a/internal/msgtransfer/init.go
+++ b/internal/msgtransfer/init.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msgtransfer
import (
diff --git a/internal/msgtransfer/modify_msg_handler.go b/internal/msgtransfer/modify_msg_handler.go
index e4130addb..38a2f5fce 100644
--- a/internal/msgtransfer/modify_msg_handler.go
+++ b/internal/msgtransfer/modify_msg_handler.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msgtransfer
import (
diff --git a/internal/msgtransfer/online_history_msg_handler.go b/internal/msgtransfer/online_history_msg_handler.go
index ee7c3bd95..574288de0 100644
--- a/internal/msgtransfer/online_history_msg_handler.go
+++ b/internal/msgtransfer/online_history_msg_handler.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msgtransfer
import (
diff --git a/internal/msgtransfer/online_msg_to_mongo_handler.go b/internal/msgtransfer/online_msg_to_mongo_handler.go
index 7a4799fac..a7bfa3c8f 100644
--- a/internal/msgtransfer/online_msg_to_mongo_handler.go
+++ b/internal/msgtransfer/online_msg_to_mongo_handler.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msgtransfer
import (
diff --git a/internal/push/callback.go b/internal/push/callback.go
index 854d27fc2..a3387905e 100644
--- a/internal/push/callback.go
+++ b/internal/push/callback.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package push
import (
diff --git a/internal/push/consumer_init.go b/internal/push/consumer_init.go
index a76de754f..3c07ab284 100644
--- a/internal/push/consumer_init.go
+++ b/internal/push/consumer_init.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package push
import (
diff --git a/internal/push/offlinepush/fcm/push.go b/internal/push/offlinepush/fcm/push.go
index 63e945d98..8b880ae1f 100644
--- a/internal/push/offlinepush/fcm/push.go
+++ b/internal/push/offlinepush/fcm/push.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package fcm
import (
diff --git a/internal/push/offlinepush/fcm/push_test.go b/internal/push/offlinepush/fcm/push_test.go
index 5cef4ef2b..856b75e0b 100644
--- a/internal/push/offlinepush/fcm/push_test.go
+++ b/internal/push/offlinepush/fcm/push_test.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package fcm
import (
diff --git a/internal/push/offlinepush/getui/body.go b/internal/push/offlinepush/getui/body.go
index b7a4bc082..bd0f7b07f 100644
--- a/internal/push/offlinepush/getui/body.go
+++ b/internal/push/offlinepush/getui/body.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package getui
import (
diff --git a/internal/push/offlinepush/getui/push.go b/internal/push/offlinepush/getui/push.go
index 17278a4ff..2681aede6 100644
--- a/internal/push/offlinepush/getui/push.go
+++ b/internal/push/offlinepush/getui/push.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package getui
import (
diff --git a/internal/push/offlinepush/jpush/body/audience.go b/internal/push/offlinepush/jpush/body/audience.go
index 124c1072a..f29930886 100644
--- a/internal/push/offlinepush/jpush/body/audience.go
+++ b/internal/push/offlinepush/jpush/body/audience.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package body
const (
diff --git a/internal/push/offlinepush/jpush/body/message.go b/internal/push/offlinepush/jpush/body/message.go
index 955a0fffb..670cd4c78 100644
--- a/internal/push/offlinepush/jpush/body/message.go
+++ b/internal/push/offlinepush/jpush/body/message.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package body
type Message struct {
diff --git a/internal/push/offlinepush/jpush/body/notification.go b/internal/push/offlinepush/jpush/body/notification.go
index 004730906..cec725784 100644
--- a/internal/push/offlinepush/jpush/body/notification.go
+++ b/internal/push/offlinepush/jpush/body/notification.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package body
import (
diff --git a/internal/push/offlinepush/jpush/body/options.go b/internal/push/offlinepush/jpush/body/options.go
index 323637414..2edf80cf0 100644
--- a/internal/push/offlinepush/jpush/body/options.go
+++ b/internal/push/offlinepush/jpush/body/options.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package body
type Options struct {
diff --git a/internal/push/offlinepush/jpush/body/platform.go b/internal/push/offlinepush/jpush/body/platform.go
index 68264fea0..eae782c63 100644
--- a/internal/push/offlinepush/jpush/body/platform.go
+++ b/internal/push/offlinepush/jpush/body/platform.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package body
import (
diff --git a/internal/push/offlinepush/jpush/body/pushobj.go b/internal/push/offlinepush/jpush/body/pushobj.go
index e91faf25a..950f93777 100644
--- a/internal/push/offlinepush/jpush/body/pushobj.go
+++ b/internal/push/offlinepush/jpush/body/pushobj.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package body
type PushObj struct {
diff --git a/internal/push/offlinepush/jpush/push.go b/internal/push/offlinepush/jpush/push.go
index e22e97df4..64933db50 100644
--- a/internal/push/offlinepush/jpush/push.go
+++ b/internal/push/offlinepush/jpush/push.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package jpush
import (
diff --git a/internal/push/offlinepush/offlinepush_interface.go b/internal/push/offlinepush/offlinepush_interface.go
index 0060b3e30..44dfce2b8 100644
--- a/internal/push/offlinepush/offlinepush_interface.go
+++ b/internal/push/offlinepush/offlinepush_interface.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package offlinepush
import (
diff --git a/internal/push/push_handler.go b/internal/push/push_handler.go
index 2d0694088..86db1c762 100644
--- a/internal/push/push_handler.go
+++ b/internal/push/push_handler.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package push
import (
diff --git a/internal/push/push_rpc_server.go b/internal/push/push_rpc_server.go
index 08edc738e..1b84a1b82 100644
--- a/internal/push/push_rpc_server.go
+++ b/internal/push/push_rpc_server.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package push
import (
diff --git a/internal/push/push_to_client.go b/internal/push/push_to_client.go
index 3cc91d20f..7cc5b1ea4 100644
--- a/internal/push/push_to_client.go
+++ b/internal/push/push_to_client.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package push
import (
diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go
index 2e0b7fe53..9376a5ccc 100644
--- a/internal/rpc/auth/auth.go
+++ b/internal/rpc/auth/auth.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package auth
import (
diff --git a/internal/rpc/conversation/conversaion.go b/internal/rpc/conversation/conversaion.go
index 11859136f..640c09991 100644
--- a/internal/rpc/conversation/conversaion.go
+++ b/internal/rpc/conversation/conversaion.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package conversation
import (
diff --git a/internal/rpc/friend/black.go b/internal/rpc/friend/black.go
index 784e32d20..23aa8efa3 100644
--- a/internal/rpc/friend/black.go
+++ b/internal/rpc/friend/black.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package friend
import (
diff --git a/internal/rpc/friend/callback.go b/internal/rpc/friend/callback.go
index c36e743c5..478988f11 100644
--- a/internal/rpc/friend/callback.go
+++ b/internal/rpc/friend/callback.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package friend
import (
diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go
index da99fd34c..c07b1423c 100644
--- a/internal/rpc/friend/friend.go
+++ b/internal/rpc/friend/friend.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package friend
import (
diff --git a/internal/rpc/group/cache.go b/internal/rpc/group/cache.go
index 0a13a45e5..3c71eb2a9 100644
--- a/internal/rpc/group/cache.go
+++ b/internal/rpc/group/cache.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package group
import (
diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go
index f61413f30..acab0ea0d 100644
--- a/internal/rpc/group/callback.go
+++ b/internal/rpc/group/callback.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package group
import (
diff --git a/internal/rpc/group/convert.go b/internal/rpc/group/convert.go
index 48e70357b..c0a03aa4e 100644
--- a/internal/rpc/group/convert.go
+++ b/internal/rpc/group/convert.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package group
import (
diff --git a/internal/rpc/group/db_map.go b/internal/rpc/group/db_map.go
index 7eb9ff650..2ab1a75ea 100644
--- a/internal/rpc/group/db_map.go
+++ b/internal/rpc/group/db_map.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package group
import (
diff --git a/internal/rpc/group/fill.go b/internal/rpc/group/fill.go
index 64092eeab..47b536301 100644
--- a/internal/rpc/group/fill.go
+++ b/internal/rpc/group/fill.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package group
import (
diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go
index 56bc6cfad..8daf45454 100644
--- a/internal/rpc/group/group.go
+++ b/internal/rpc/group/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package group
import (
diff --git a/internal/rpc/group/super_group.go b/internal/rpc/group/super_group.go
index ab4cbd5ff..2e174f956 100644
--- a/internal/rpc/group/super_group.go
+++ b/internal/rpc/group/super_group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package group
import (
diff --git a/internal/rpc/msg/as_read.go b/internal/rpc/msg/as_read.go
index c4707c489..91915c647 100644
--- a/internal/rpc/msg/as_read.go
+++ b/internal/rpc/msg/as_read.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/callback.go b/internal/rpc/msg/callback.go
index aac96f75c..2d4988adf 100644
--- a/internal/rpc/msg/callback.go
+++ b/internal/rpc/msg/callback.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/delete.go b/internal/rpc/msg/delete.go
index 97efff41b..d2ead459e 100644
--- a/internal/rpc/msg/delete.go
+++ b/internal/rpc/msg/delete.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/extend_msg.go b/internal/rpc/msg/extend_msg.go
index 7ae56c71e..6f82d980f 100644
--- a/internal/rpc/msg/extend_msg.go
+++ b/internal/rpc/msg/extend_msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/extend_msg_callback.go b/internal/rpc/msg/extend_msg_callback.go
index 09fa40735..d510afd0c 100644
--- a/internal/rpc/msg/extend_msg_callback.go
+++ b/internal/rpc/msg/extend_msg_callback.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/lock.go b/internal/rpc/msg/lock.go
index 64744263f..50224c6a3 100644
--- a/internal/rpc/msg/lock.go
+++ b/internal/rpc/msg/lock.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/message_interceptor.go b/internal/rpc/msg/message_interceptor.go
index 702cdc764..49a330d5e 100644
--- a/internal/rpc/msg/message_interceptor.go
+++ b/internal/rpc/msg/message_interceptor.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/msg_status.go b/internal/rpc/msg/msg_status.go
index b867e3065..f9ab0d09c 100644
--- a/internal/rpc/msg/msg_status.go
+++ b/internal/rpc/msg/msg_status.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/revoke.go b/internal/rpc/msg/revoke.go
index 2ea89ee87..c4b64aa46 100644
--- a/internal/rpc/msg/revoke.go
+++ b/internal/rpc/msg/revoke.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/send.go b/internal/rpc/msg/send.go
index c7450fd00..2c27b869d 100644
--- a/internal/rpc/msg/send.go
+++ b/internal/rpc/msg/send.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/seq.go b/internal/rpc/msg/seq.go
index 892d39bfe..ac771d3ee 100644
--- a/internal/rpc/msg/seq.go
+++ b/internal/rpc/msg/seq.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go
index a077adb83..4702eb5f9 100644
--- a/internal/rpc/msg/server.go
+++ b/internal/rpc/msg/server.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/sync_msg.go b/internal/rpc/msg/sync_msg.go
index b9cfed97c..7ac30ff1a 100644
--- a/internal/rpc/msg/sync_msg.go
+++ b/internal/rpc/msg/sync_msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/utils.go b/internal/rpc/msg/utils.go
index 199f1535f..10eccbcff 100644
--- a/internal/rpc/msg/utils.go
+++ b/internal/rpc/msg/utils.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/msg/verify.go b/internal/rpc/msg/verify.go
index dd5b3436b..be2945182 100644
--- a/internal/rpc/msg/verify.go
+++ b/internal/rpc/msg/verify.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import (
diff --git a/internal/rpc/statistics/statistics.go b/internal/rpc/statistics/statistics.go
index 12c0dbc25..2f81301a1 100644
--- a/internal/rpc/statistics/statistics.go
+++ b/internal/rpc/statistics/statistics.go
@@ -1 +1,15 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package statistics
diff --git a/internal/rpc/third/s3.go b/internal/rpc/third/s3.go
index e0a3a99da..4ff9a3ce8 100644
--- a/internal/rpc/third/s3.go
+++ b/internal/rpc/third/s3.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package third
import (
diff --git a/internal/rpc/third/third.go b/internal/rpc/third/third.go
index 1ac63c245..ebf2c60d1 100644
--- a/internal/rpc/third/third.go
+++ b/internal/rpc/third/third.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package third
import (
diff --git a/internal/rpc/user/statistics.go b/internal/rpc/user/statistics.go
index 7cbbcb82d..7da40bb1e 100644
--- a/internal/rpc/user/statistics.go
+++ b/internal/rpc/user/statistics.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package user
import (
diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go
index 5004dc1f6..d2368ceb3 100644
--- a/internal/rpc/user/user.go
+++ b/internal/rpc/user/user.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package user
import (
diff --git a/internal/tools/cron_task.go b/internal/tools/cron_task.go
index bac433fc5..365c6cbf4 100644
--- a/internal/tools/cron_task.go
+++ b/internal/tools/cron_task.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package tools
import (
diff --git a/internal/tools/msg.go b/internal/tools/msg.go
index 0c58791a0..8389352a8 100644
--- a/internal/tools/msg.go
+++ b/internal/tools/msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package tools
import (
diff --git a/internal/tools/msg_test.go b/internal/tools/msg_test.go
index 241748f76..4b1ea0384 100644
--- a/internal/tools/msg_test.go
+++ b/internal/tools/msg_test.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package tools
import (
diff --git a/pkg/a2r/api2rpc.go b/pkg/a2r/api2rpc.go
index 1a064176c..6a1651a3c 100644
--- a/pkg/a2r/api2rpc.go
+++ b/pkg/a2r/api2rpc.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package a2r
import (
diff --git a/pkg/apiresp/gin.go b/pkg/apiresp/gin.go
index b2bfaf4f9..9d5637bfd 100644
--- a/pkg/apiresp/gin.go
+++ b/pkg/apiresp/gin.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apiresp
import (
diff --git a/pkg/apiresp/http.go b/pkg/apiresp/http.go
index f079fae6a..db1c847cf 100644
--- a/pkg/apiresp/http.go
+++ b/pkg/apiresp/http.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apiresp
import (
diff --git a/pkg/apiresp/resp.go b/pkg/apiresp/resp.go
index 29dc33996..a7bd271a3 100644
--- a/pkg/apiresp/resp.go
+++ b/pkg/apiresp/resp.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apiresp
import (
diff --git a/pkg/apistruct/auth.go b/pkg/apistruct/auth.go
index b760dcd08..119cbac77 100644
--- a/pkg/apistruct/auth.go
+++ b/pkg/apistruct/auth.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
type UserRegisterReq struct {
diff --git a/pkg/apistruct/aws.go b/pkg/apistruct/aws.go
index 0ef2640c5..3518baea0 100644
--- a/pkg/apistruct/aws.go
+++ b/pkg/apistruct/aws.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
type AwsStorageCredentialReq struct {
diff --git a/pkg/apistruct/conversation.go b/pkg/apistruct/conversation.go
index 1c6ba6e29..c58daa634 100644
--- a/pkg/apistruct/conversation.go
+++ b/pkg/apistruct/conversation.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
type OptResult struct {
diff --git a/pkg/apistruct/cos.go b/pkg/apistruct/cos.go
index 2695b6bbf..bd2611553 100644
--- a/pkg/apistruct/cos.go
+++ b/pkg/apistruct/cos.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
import sts "github.com/tencentyun/qcloud-cos-sts-sdk/go"
diff --git a/pkg/apistruct/friend.go b/pkg/apistruct/friend.go
index 14a7438ac..3b1ab919d 100644
--- a/pkg/apistruct/friend.go
+++ b/pkg/apistruct/friend.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
//type ParamsCommFriend struct {
diff --git a/pkg/apistruct/group.go b/pkg/apistruct/group.go
index 32af09551..45be76cf9 100644
--- a/pkg/apistruct/group.go
+++ b/pkg/apistruct/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
import (
diff --git a/pkg/apistruct/manage.go b/pkg/apistruct/manage.go
index 832597fd0..455b2fe4c 100644
--- a/pkg/apistruct/manage.go
+++ b/pkg/apistruct/manage.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
import (
diff --git a/pkg/apistruct/msg.go b/pkg/apistruct/msg.go
index 5efa917d1..4b776cb48 100644
--- a/pkg/apistruct/msg.go
+++ b/pkg/apistruct/msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
import (
diff --git a/pkg/apistruct/oss.go b/pkg/apistruct/oss.go
index 55370d50c..4f1e6c00a 100644
--- a/pkg/apistruct/oss.go
+++ b/pkg/apistruct/oss.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
type OSSCredentialReq struct {
diff --git a/pkg/apistruct/pagination.go b/pkg/apistruct/pagination.go
index 9b64ad8c1..02de39967 100644
--- a/pkg/apistruct/pagination.go
+++ b/pkg/apistruct/pagination.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
type Pagination struct {
diff --git a/pkg/apistruct/public.go b/pkg/apistruct/public.go
index fc3d3e707..ff3a115ae 100644
--- a/pkg/apistruct/public.go
+++ b/pkg/apistruct/public.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
type ApiUserInfo struct {
diff --git a/pkg/apistruct/super_group.go b/pkg/apistruct/super_group.go
index 6c8bf9515..92275eabf 100644
--- a/pkg/apistruct/super_group.go
+++ b/pkg/apistruct/super_group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
type GetJoinedSuperGroupListReq struct {
diff --git a/pkg/apistruct/third.go b/pkg/apistruct/third.go
index 80e9d4930..76ff89f62 100644
--- a/pkg/apistruct/third.go
+++ b/pkg/apistruct/third.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package apistruct
import "mime/multipart"
diff --git a/pkg/callbackstruct/common.go b/pkg/callbackstruct/common.go
index 11ff51deb..4a83bb09f 100644
--- a/pkg/callbackstruct/common.go
+++ b/pkg/callbackstruct/common.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package callbackstruct
import (
diff --git a/pkg/callbackstruct/friend.go b/pkg/callbackstruct/friend.go
index ebb661a18..7e89824e2 100644
--- a/pkg/callbackstruct/friend.go
+++ b/pkg/callbackstruct/friend.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package callbackstruct
type CallbackBeforeAddFriendReq struct {
diff --git a/pkg/callbackstruct/group.go b/pkg/callbackstruct/group.go
index 1ae59e658..558ad4d23 100644
--- a/pkg/callbackstruct/group.go
+++ b/pkg/callbackstruct/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package callbackstruct
import (
diff --git a/pkg/callbackstruct/message.go b/pkg/callbackstruct/message.go
index 965d91df2..677e70f27 100644
--- a/pkg/callbackstruct/message.go
+++ b/pkg/callbackstruct/message.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package callbackstruct
import (
diff --git a/pkg/callbackstruct/msg_gateway.go b/pkg/callbackstruct/msg_gateway.go
index 48605e791..a70f724ce 100644
--- a/pkg/callbackstruct/msg_gateway.go
+++ b/pkg/callbackstruct/msg_gateway.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package callbackstruct
type CallbackUserOnlineReq struct {
diff --git a/pkg/callbackstruct/push.go b/pkg/callbackstruct/push.go
index a1a0f890c..cac37330a 100644
--- a/pkg/callbackstruct/push.go
+++ b/pkg/callbackstruct/push.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package callbackstruct
import common "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
diff --git a/pkg/checker/check.go b/pkg/checker/check.go
index f5913682d..f3f3811a4 100644
--- a/pkg/checker/check.go
+++ b/pkg/checker/check.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package checker
type Checker interface {
diff --git a/pkg/common/cmd/api.go b/pkg/common/cmd/api.go
index 22534c39d..4cb5e34fc 100644
--- a/pkg/common/cmd/api.go
+++ b/pkg/common/cmd/api.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cmd
import "github.com/spf13/cobra"
diff --git a/pkg/common/cmd/cron_task.go b/pkg/common/cmd/cron_task.go
index 7795e5e3d..c26cf2e4f 100644
--- a/pkg/common/cmd/cron_task.go
+++ b/pkg/common/cmd/cron_task.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cmd
import "github.com/spf13/cobra"
diff --git a/pkg/common/cmd/msg_gateway.go b/pkg/common/cmd/msg_gateway.go
index deea1c106..f3547d649 100644
--- a/pkg/common/cmd/msg_gateway.go
+++ b/pkg/common/cmd/msg_gateway.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cmd
import (
diff --git a/pkg/common/cmd/msg_transfer.go b/pkg/common/cmd/msg_transfer.go
index d6d65a1dd..5c9c3d0cb 100644
--- a/pkg/common/cmd/msg_transfer.go
+++ b/pkg/common/cmd/msg_transfer.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cmd
import (
diff --git a/pkg/common/cmd/msg_utils.go b/pkg/common/cmd/msg_utils.go
index 00b3f7359..c4f202d2b 100644
--- a/pkg/common/cmd/msg_utils.go
+++ b/pkg/common/cmd/msg_utils.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cmd
import (
diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go
index ee586e247..4a5744033 100644
--- a/pkg/common/cmd/root.go
+++ b/pkg/common/cmd/root.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cmd
import (
diff --git a/pkg/common/cmd/rpc.go b/pkg/common/cmd/rpc.go
index be44f7ce0..bfaef5305 100644
--- a/pkg/common/cmd/rpc.go
+++ b/pkg/common/cmd/rpc.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cmd
import (
diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go
index 40161932b..eef803e12 100644
--- a/pkg/common/config/config.go
+++ b/pkg/common/config/config.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package config
import (
diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go
index ebd6c49fc..38f033ab4 100644
--- a/pkg/common/config/parse.go
+++ b/pkg/common/config/parse.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package config
import (
diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go
index 1d0a98558..55ef31acf 100644
--- a/pkg/common/constant/constant.go
+++ b/pkg/common/constant/constant.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package constant
const (
diff --git a/pkg/common/constant/limit.go b/pkg/common/constant/limit.go
index 57e764eef..fd1551b34 100644
--- a/pkg/common/constant/limit.go
+++ b/pkg/common/constant/limit.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package constant
const (
diff --git a/pkg/common/constant/platform_id_to_name.go b/pkg/common/constant/platform_id_to_name.go
index e8bb129eb..31b1fcdd9 100644
--- a/pkg/common/constant/platform_id_to_name.go
+++ b/pkg/common/constant/platform_id_to_name.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package constant
// fixme 1<--->IOS 2<--->Android 3<--->Windows
diff --git a/pkg/common/convert/black.go b/pkg/common/convert/black.go
index cadd822c8..684a40d0d 100644
--- a/pkg/common/convert/black.go
+++ b/pkg/common/convert/black.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package convert
import (
diff --git a/pkg/common/convert/conversation.go b/pkg/common/convert/conversation.go
index 66d1d771c..f00cae58f 100644
--- a/pkg/common/convert/conversation.go
+++ b/pkg/common/convert/conversation.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package convert
import (
diff --git a/pkg/common/convert/friend.go b/pkg/common/convert/friend.go
index b907f9ad0..018aee42f 100644
--- a/pkg/common/convert/friend.go
+++ b/pkg/common/convert/friend.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package convert
import (
diff --git a/pkg/common/convert/group.go b/pkg/common/convert/group.go
index adec0e6f3..e8808d199 100644
--- a/pkg/common/convert/group.go
+++ b/pkg/common/convert/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package convert
import (
diff --git a/pkg/common/convert/msg.go b/pkg/common/convert/msg.go
index c8b8a6625..59215bb86 100644
--- a/pkg/common/convert/msg.go
+++ b/pkg/common/convert/msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package convert
import (
diff --git a/pkg/common/convert/user.go b/pkg/common/convert/user.go
index 625bfef7d..d8d4c488c 100644
--- a/pkg/common/convert/user.go
+++ b/pkg/common/convert/user.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package convert
import (
diff --git a/pkg/common/db/cache/black.go b/pkg/common/db/cache/black.go
index ca2f2ed9a..d6b82ef33 100644
--- a/pkg/common/db/cache/black.go
+++ b/pkg/common/db/cache/black.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cache
import (
diff --git a/pkg/common/db/cache/conversation.go b/pkg/common/db/cache/conversation.go
index 1005ee325..c35f0c240 100644
--- a/pkg/common/db/cache/conversation.go
+++ b/pkg/common/db/cache/conversation.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cache
import (
diff --git a/pkg/common/db/cache/extend_msg_set.go b/pkg/common/db/cache/extend_msg_set.go
index a45bf87f8..d7750e66b 100644
--- a/pkg/common/db/cache/extend_msg_set.go
+++ b/pkg/common/db/cache/extend_msg_set.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cache
import (
diff --git a/pkg/common/db/cache/friend.go b/pkg/common/db/cache/friend.go
index c816f6d4f..4695987dd 100644
--- a/pkg/common/db/cache/friend.go
+++ b/pkg/common/db/cache/friend.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cache
import (
diff --git a/pkg/common/db/cache/group.go b/pkg/common/db/cache/group.go
index 11c733d2b..86adc2d0a 100644
--- a/pkg/common/db/cache/group.go
+++ b/pkg/common/db/cache/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cache
import (
diff --git a/pkg/common/db/cache/init_redis.go b/pkg/common/db/cache/init_redis.go
index e4b950ee1..72dfc8caf 100644
--- a/pkg/common/db/cache/init_redis.go
+++ b/pkg/common/db/cache/init_redis.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cache
import (
diff --git a/pkg/common/db/cache/meta_cache.go b/pkg/common/db/cache/meta_cache.go
index e12f8e93c..86a47f04b 100644
--- a/pkg/common/db/cache/meta_cache.go
+++ b/pkg/common/db/cache/meta_cache.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cache
import (
diff --git a/pkg/common/db/cache/msg.go b/pkg/common/db/cache/msg.go
index e01836118..5f57103b0 100644
--- a/pkg/common/db/cache/msg.go
+++ b/pkg/common/db/cache/msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cache
import (
diff --git a/pkg/common/db/cache/user.go b/pkg/common/db/cache/user.go
index c8e8b1cc5..455bc9ebe 100644
--- a/pkg/common/db/cache/user.go
+++ b/pkg/common/db/cache/user.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package cache
import (
diff --git a/pkg/common/db/controller/auth.go b/pkg/common/db/controller/auth.go
index 46d2eb55a..454d9707f 100644
--- a/pkg/common/db/controller/auth.go
+++ b/pkg/common/db/controller/auth.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/controller/black.go b/pkg/common/db/controller/black.go
index fad4d8acb..13b375787 100644
--- a/pkg/common/db/controller/black.go
+++ b/pkg/common/db/controller/black.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/controller/chatlog.go b/pkg/common/db/controller/chatlog.go
index cb161699f..5385fdfec 100644
--- a/pkg/common/db/controller/chatlog.go
+++ b/pkg/common/db/controller/chatlog.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go
index d5bec4376..8e7b7a350 100644
--- a/pkg/common/db/controller/conversation.go
+++ b/pkg/common/db/controller/conversation.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/controller/extend_msg.go b/pkg/common/db/controller/extend_msg.go
index b9395db0e..73b6d9330 100644
--- a/pkg/common/db/controller/extend_msg.go
+++ b/pkg/common/db/controller/extend_msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/controller/friend.go b/pkg/common/db/controller/friend.go
index 3a98bd8ec..116345219 100644
--- a/pkg/common/db/controller/friend.go
+++ b/pkg/common/db/controller/friend.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/controller/group.go b/pkg/common/db/controller/group.go
index 58ee9394b..18b10aca5 100644
--- a/pkg/common/db/controller/group.go
+++ b/pkg/common/db/controller/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go
index 6ce55deae..435e3e70b 100644
--- a/pkg/common/db/controller/msg.go
+++ b/pkg/common/db/controller/msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/controller/msg_test.go b/pkg/common/db/controller/msg_test.go
index 6771bdab4..7e50b8489 100644
--- a/pkg/common/db/controller/msg_test.go
+++ b/pkg/common/db/controller/msg_test.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/controller/push.go b/pkg/common/db/controller/push.go
index e0e5d4845..c4c761457 100644
--- a/pkg/common/db/controller/push.go
+++ b/pkg/common/db/controller/push.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/controller/storage.go b/pkg/common/db/controller/storage.go
index 22b2274f3..ab20e7da8 100644
--- a/pkg/common/db/controller/storage.go
+++ b/pkg/common/db/controller/storage.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import "C"
diff --git a/pkg/common/db/controller/third.go b/pkg/common/db/controller/third.go
index 276084920..906b9b2e4 100644
--- a/pkg/common/db/controller/third.go
+++ b/pkg/common/db/controller/third.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/controller/user.go b/pkg/common/db/controller/user.go
index 9a2e01b47..03224b61e 100644
--- a/pkg/common/db/controller/user.go
+++ b/pkg/common/db/controller/user.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package controller
import (
diff --git a/pkg/common/db/localcache/conversation.go b/pkg/common/db/localcache/conversation.go
index 3c188c90e..de9f0401d 100644
--- a/pkg/common/db/localcache/conversation.go
+++ b/pkg/common/db/localcache/conversation.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package localcache
import (
diff --git a/pkg/common/db/localcache/group.go b/pkg/common/db/localcache/group.go
index ea66d122c..d58d0a8eb 100644
--- a/pkg/common/db/localcache/group.go
+++ b/pkg/common/db/localcache/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package localcache
import (
diff --git a/pkg/common/db/localcache/meta_local_cache.go b/pkg/common/db/localcache/meta_local_cache.go
index e0c30e523..ed9389c27 100644
--- a/pkg/common/db/localcache/meta_local_cache.go
+++ b/pkg/common/db/localcache/meta_local_cache.go
@@ -1 +1,15 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package localcache
diff --git a/pkg/common/db/obj/minio.go b/pkg/common/db/obj/minio.go
index 2b39fff8b..ffd8684c9 100644
--- a/pkg/common/db/obj/minio.go
+++ b/pkg/common/db/obj/minio.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package obj
import (
diff --git a/pkg/common/db/obj/obj.go b/pkg/common/db/obj/obj.go
index 00c8b86b1..d8f5d9390 100644
--- a/pkg/common/db/obj/obj.go
+++ b/pkg/common/db/obj/obj.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package obj
import (
diff --git a/pkg/common/db/ormutil/utils.go b/pkg/common/db/ormutil/utils.go
index c92b091ef..7e4bd4f71 100644
--- a/pkg/common/db/ormutil/utils.go
+++ b/pkg/common/db/ormutil/utils.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package ormutil
import (
diff --git a/pkg/common/db/relation/black_model.go b/pkg/common/db/relation/black_model.go
index 736d9ed01..ca90f43a7 100644
--- a/pkg/common/db/relation/black_model.go
+++ b/pkg/common/db/relation/black_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/chat_log_model.go b/pkg/common/db/relation/chat_log_model.go
index ef6dd2a8a..c4068e3f7 100644
--- a/pkg/common/db/relation/chat_log_model.go
+++ b/pkg/common/db/relation/chat_log_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/conversation_model.go b/pkg/common/db/relation/conversation_model.go
index cd67ad165..47be971c0 100644
--- a/pkg/common/db/relation/conversation_model.go
+++ b/pkg/common/db/relation/conversation_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/friend_model.go b/pkg/common/db/relation/friend_model.go
index 3baaa50cc..5a54f9b7c 100644
--- a/pkg/common/db/relation/friend_model.go
+++ b/pkg/common/db/relation/friend_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/friend_request_model.go b/pkg/common/db/relation/friend_request_model.go
index 1673d6dcf..06fd08ff6 100644
--- a/pkg/common/db/relation/friend_request_model.go
+++ b/pkg/common/db/relation/friend_request_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/group_member_model.go b/pkg/common/db/relation/group_member_model.go
index 78ab4357c..8f5aa937d 100644
--- a/pkg/common/db/relation/group_member_model.go
+++ b/pkg/common/db/relation/group_member_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/group_model.go b/pkg/common/db/relation/group_model.go
index fbcb5763b..8e3431c83 100644
--- a/pkg/common/db/relation/group_model.go
+++ b/pkg/common/db/relation/group_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/group_request_model.go b/pkg/common/db/relation/group_request_model.go
index 9d12005ae..0220f308e 100644
--- a/pkg/common/db/relation/group_request_model.go
+++ b/pkg/common/db/relation/group_request_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/meta_db.go b/pkg/common/db/relation/meta_db.go
index 2c937f0cb..60e4a5464 100644
--- a/pkg/common/db/relation/meta_db.go
+++ b/pkg/common/db/relation/meta_db.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go
index 89ee8545e..67419c7bf 100644
--- a/pkg/common/db/relation/mysql_init.go
+++ b/pkg/common/db/relation/mysql_init.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/object_hash_model.go b/pkg/common/db/relation/object_hash_model.go
index 789929c5f..5ff8cd47a 100644
--- a/pkg/common/db/relation/object_hash_model.go
+++ b/pkg/common/db/relation/object_hash_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/object_info_model.go b/pkg/common/db/relation/object_info_model.go
index aa48ae491..642ae8ef2 100644
--- a/pkg/common/db/relation/object_info_model.go
+++ b/pkg/common/db/relation/object_info_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/object_put_model.go b/pkg/common/db/relation/object_put_model.go
index 12808c215..d2df2636d 100644
--- a/pkg/common/db/relation/object_put_model.go
+++ b/pkg/common/db/relation/object_put_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/relation/user_model.go b/pkg/common/db/relation/user_model.go
index 013666859..89a1773d4 100644
--- a/pkg/common/db/relation/user_model.go
+++ b/pkg/common/db/relation/user_model.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/black.go b/pkg/common/db/table/relation/black.go
index bcfffc6db..ec7ca7a56 100644
--- a/pkg/common/db/table/relation/black.go
+++ b/pkg/common/db/table/relation/black.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/chatlog.go b/pkg/common/db/table/relation/chatlog.go
index f43d8a43a..c67edb1fe 100644
--- a/pkg/common/db/table/relation/chatlog.go
+++ b/pkg/common/db/table/relation/chatlog.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/conversation.go b/pkg/common/db/table/relation/conversation.go
index f08ea90e3..5d6d061b1 100644
--- a/pkg/common/db/table/relation/conversation.go
+++ b/pkg/common/db/table/relation/conversation.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import "context"
diff --git a/pkg/common/db/table/relation/friend.go b/pkg/common/db/table/relation/friend.go
index 43724141f..58d8d1d34 100644
--- a/pkg/common/db/table/relation/friend.go
+++ b/pkg/common/db/table/relation/friend.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/friend_request.go b/pkg/common/db/table/relation/friend_request.go
index 59160c819..794f33aaf 100644
--- a/pkg/common/db/table/relation/friend_request.go
+++ b/pkg/common/db/table/relation/friend_request.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/group.go b/pkg/common/db/table/relation/group.go
index 70ccad9b4..be0afbcc3 100644
--- a/pkg/common/db/table/relation/group.go
+++ b/pkg/common/db/table/relation/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/group_member.go b/pkg/common/db/table/relation/group_member.go
index 6640a9402..bfde72834 100644
--- a/pkg/common/db/table/relation/group_member.go
+++ b/pkg/common/db/table/relation/group_member.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/group_request.go b/pkg/common/db/table/relation/group_request.go
index 816d3ad35..ba68bcd7b 100644
--- a/pkg/common/db/table/relation/group_request.go
+++ b/pkg/common/db/table/relation/group_request.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/object_hash.go b/pkg/common/db/table/relation/object_hash.go
index 86d038fc4..231f21a81 100644
--- a/pkg/common/db/table/relation/object_hash.go
+++ b/pkg/common/db/table/relation/object_hash.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/object_info.go b/pkg/common/db/table/relation/object_info.go
index 60d8d3c63..e7b7fb57c 100644
--- a/pkg/common/db/table/relation/object_info.go
+++ b/pkg/common/db/table/relation/object_info.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/object_put.go b/pkg/common/db/table/relation/object_put.go
index 62ffe61e7..49b37826c 100644
--- a/pkg/common/db/table/relation/object_put.go
+++ b/pkg/common/db/table/relation/object_put.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/user.go b/pkg/common/db/table/relation/user.go
index 35b52602f..7d2bf0cf5 100644
--- a/pkg/common/db/table/relation/user.go
+++ b/pkg/common/db/table/relation/user.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/relation/utils.go b/pkg/common/db/table/relation/utils.go
index d3bd8d312..c8c59b390 100644
--- a/pkg/common/db/table/relation/utils.go
+++ b/pkg/common/db/table/relation/utils.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package relation
import (
diff --git a/pkg/common/db/table/unrelation/common.go b/pkg/common/db/table/unrelation/common.go
index 9834628a9..bd46ccc2a 100644
--- a/pkg/common/db/table/unrelation/common.go
+++ b/pkg/common/db/table/unrelation/common.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package unrelation
type CommonUserModel struct {
diff --git a/pkg/common/db/table/unrelation/extend_msg_set.go b/pkg/common/db/table/unrelation/extend_msg_set.go
index 76588e679..472daf5fa 100644
--- a/pkg/common/db/table/unrelation/extend_msg_set.go
+++ b/pkg/common/db/table/unrelation/extend_msg_set.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package unrelation
import (
diff --git a/pkg/common/db/table/unrelation/msg.go b/pkg/common/db/table/unrelation/msg.go
index 950a60689..57f9b4cca 100644
--- a/pkg/common/db/table/unrelation/msg.go
+++ b/pkg/common/db/table/unrelation/msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package unrelation
import (
diff --git a/pkg/common/db/table/unrelation/super_group.go b/pkg/common/db/table/unrelation/super_group.go
index 4875c490d..80c3ef9c7 100644
--- a/pkg/common/db/table/unrelation/super_group.go
+++ b/pkg/common/db/table/unrelation/super_group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package unrelation
import (
diff --git a/pkg/common/db/tx/gorm.go b/pkg/common/db/tx/gorm.go
index 4d5ccd5be..98e71cb9f 100644
--- a/pkg/common/db/tx/gorm.go
+++ b/pkg/common/db/tx/gorm.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package tx
import (
diff --git a/pkg/common/db/tx/mongo.go b/pkg/common/db/tx/mongo.go
index cd7d24607..a0c38e372 100644
--- a/pkg/common/db/tx/mongo.go
+++ b/pkg/common/db/tx/mongo.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package tx
import (
diff --git a/pkg/common/db/tx/tx.go b/pkg/common/db/tx/tx.go
index e182271ff..9a6fe02ef 100644
--- a/pkg/common/db/tx/tx.go
+++ b/pkg/common/db/tx/tx.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package tx
import "context"
diff --git a/pkg/common/db/unrelation/extend_msg.go b/pkg/common/db/unrelation/extend_msg.go
index 2abe1d0bd..17e0b2e19 100644
--- a/pkg/common/db/unrelation/extend_msg.go
+++ b/pkg/common/db/unrelation/extend_msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package unrelation
import (
diff --git a/pkg/common/db/unrelation/mongo.go b/pkg/common/db/unrelation/mongo.go
index 8325abff9..51b9e4b7e 100644
--- a/pkg/common/db/unrelation/mongo.go
+++ b/pkg/common/db/unrelation/mongo.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package unrelation
import (
diff --git a/pkg/common/db/unrelation/msg.go b/pkg/common/db/unrelation/msg.go
index 4c48f6eb3..cecbf2301 100644
--- a/pkg/common/db/unrelation/msg.go
+++ b/pkg/common/db/unrelation/msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package unrelation
import (
diff --git a/pkg/common/db/unrelation/super_group.go b/pkg/common/db/unrelation/super_group.go
index 3dc9f61bd..f2f867c49 100644
--- a/pkg/common/db/unrelation/super_group.go
+++ b/pkg/common/db/unrelation/super_group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package unrelation
import (
diff --git a/pkg/common/kafka/consumer.go b/pkg/common/kafka/consumer.go
index 8a21a14d6..67bc3977b 100644
--- a/pkg/common/kafka/consumer.go
+++ b/pkg/common/kafka/consumer.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package kafka
import (
diff --git a/pkg/common/kafka/producer.go b/pkg/common/kafka/producer.go
index 6e5868f24..4c4ebc460 100644
--- a/pkg/common/kafka/producer.go
+++ b/pkg/common/kafka/producer.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package kafka
import (
diff --git a/pkg/common/log/color.go b/pkg/common/log/color.go
index 2cb4fe078..9d1121d61 100644
--- a/pkg/common/log/color.go
+++ b/pkg/common/log/color.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package log
import (
diff --git a/pkg/common/log/logger.go b/pkg/common/log/logger.go
index 221c0ded5..cfbb91bdd 100644
--- a/pkg/common/log/logger.go
+++ b/pkg/common/log/logger.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package log
import "context"
diff --git a/pkg/common/log/sql_logger.go b/pkg/common/log/sql_logger.go
index 1785b211c..40b483474 100644
--- a/pkg/common/log/sql_logger.go
+++ b/pkg/common/log/sql_logger.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package log
import (
diff --git a/pkg/common/log/zap.go b/pkg/common/log/zap.go
index a173ac055..9cf3fe144 100644
--- a/pkg/common/log/zap.go
+++ b/pkg/common/log/zap.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package log
import (
diff --git a/pkg/common/log/zk_logger.go b/pkg/common/log/zk_logger.go
index d69077d73..3579e2022 100644
--- a/pkg/common/log/zk_logger.go
+++ b/pkg/common/log/zk_logger.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package log
import (
diff --git a/pkg/common/mcontext/ctx.go b/pkg/common/mcontext/ctx.go
index 5dee1341a..bbca660b9 100644
--- a/pkg/common/mcontext/ctx.go
+++ b/pkg/common/mcontext/ctx.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package mcontext
import (
diff --git a/pkg/common/mw/check.go b/pkg/common/mw/check.go
index 5c8a3ee0c..81ea7e017 100644
--- a/pkg/common/mw/check.go
+++ b/pkg/common/mw/check.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package mw
import (
diff --git a/pkg/common/mw/check_test.go b/pkg/common/mw/check_test.go
index 091942550..b893d7e4e 100644
--- a/pkg/common/mw/check_test.go
+++ b/pkg/common/mw/check_test.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package mw
import (
diff --git a/pkg/common/mw/gin.go b/pkg/common/mw/gin.go
index 42798d060..65f98dca3 100644
--- a/pkg/common/mw/gin.go
+++ b/pkg/common/mw/gin.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package mw
import (
diff --git a/pkg/common/mw/intercept_chain.go b/pkg/common/mw/intercept_chain.go
index 8feebab90..ae5361631 100644
--- a/pkg/common/mw/intercept_chain.go
+++ b/pkg/common/mw/intercept_chain.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package mw
import (
diff --git a/pkg/common/mw/rpc_client_interceptor.go b/pkg/common/mw/rpc_client_interceptor.go
index 530847280..40933810c 100644
--- a/pkg/common/mw/rpc_client_interceptor.go
+++ b/pkg/common/mw/rpc_client_interceptor.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package mw
import (
diff --git a/pkg/common/mw/rpc_server_interceptor.go b/pkg/common/mw/rpc_server_interceptor.go
index 4dcd4e582..01eb77b89 100644
--- a/pkg/common/mw/rpc_server_interceptor.go
+++ b/pkg/common/mw/rpc_server_interceptor.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package mw
import (
diff --git a/pkg/common/mw/specialerror/error.go b/pkg/common/mw/specialerror/error.go
index a29ea505a..b8b8d27ae 100644
--- a/pkg/common/mw/specialerror/error.go
+++ b/pkg/common/mw/specialerror/error.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package specialerror
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
diff --git a/pkg/common/network/ip.go b/pkg/common/network/ip.go
index 2d5a5b09c..bf062429d 100644
--- a/pkg/common/network/ip.go
+++ b/pkg/common/network/ip.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package network
import (
diff --git a/pkg/common/prome/gather.go b/pkg/common/prome/gather.go
index 271488966..910df71d9 100644
--- a/pkg/common/prome/gather.go
+++ b/pkg/common/prome/gather.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package prome
import (
diff --git a/pkg/common/prome/prometheus.go b/pkg/common/prome/prometheus.go
index 299f07d43..d66b1df70 100644
--- a/pkg/common/prome/prometheus.go
+++ b/pkg/common/prome/prometheus.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package prome
import (
diff --git a/pkg/common/tokenverify/jwt_token.go b/pkg/common/tokenverify/jwt_token.go
index 9f4088eff..30e9ac9d1 100644
--- a/pkg/common/tokenverify/jwt_token.go
+++ b/pkg/common/tokenverify/jwt_token.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package tokenverify
import (
diff --git a/pkg/common/tokenverify/jwt_token_test.go b/pkg/common/tokenverify/jwt_token_test.go
index b8390b45d..4e8e98c41 100644
--- a/pkg/common/tokenverify/jwt_token_test.go
+++ b/pkg/common/tokenverify/jwt_token_test.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package tokenverify
import (
diff --git a/pkg/discoveryregistry/discovery_register.go b/pkg/discoveryregistry/discovery_register.go
index 01ed88d5b..50e720f97 100644
--- a/pkg/discoveryregistry/discovery_register.go
+++ b/pkg/discoveryregistry/discovery_register.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package discoveryregistry
import (
diff --git a/pkg/discoveryregistry/zookeeper/conf.go b/pkg/discoveryregistry/zookeeper/conf.go
index 55532a370..034c525ba 100644
--- a/pkg/discoveryregistry/zookeeper/conf.go
+++ b/pkg/discoveryregistry/zookeeper/conf.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package zookeeper
import (
diff --git a/pkg/discoveryregistry/zookeeper/discover.go b/pkg/discoveryregistry/zookeeper/discover.go
index 912c001d9..3966d315c 100644
--- a/pkg/discoveryregistry/zookeeper/discover.go
+++ b/pkg/discoveryregistry/zookeeper/discover.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package zookeeper
import (
diff --git a/pkg/discoveryregistry/zookeeper/register.go b/pkg/discoveryregistry/zookeeper/register.go
index ab75f488b..1531980bb 100644
--- a/pkg/discoveryregistry/zookeeper/register.go
+++ b/pkg/discoveryregistry/zookeeper/register.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package zookeeper
import (
diff --git a/pkg/discoveryregistry/zookeeper/resolver.go b/pkg/discoveryregistry/zookeeper/resolver.go
index 74ed04455..e395a8f34 100644
--- a/pkg/discoveryregistry/zookeeper/resolver.go
+++ b/pkg/discoveryregistry/zookeeper/resolver.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package zookeeper
import (
diff --git a/pkg/discoveryregistry/zookeeper/zk.go b/pkg/discoveryregistry/zookeeper/zk.go
index d6287e47b..b9b68c528 100644
--- a/pkg/discoveryregistry/zookeeper/zk.go
+++ b/pkg/discoveryregistry/zookeeper/zk.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package zookeeper
import (
diff --git a/pkg/errs/code.go b/pkg/errs/code.go
index 3104ed729..b153e4e40 100644
--- a/pkg/errs/code.go
+++ b/pkg/errs/code.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package errs
// UnknownCode 没有解析到code或解析的code=0
diff --git a/pkg/errs/coderr.go b/pkg/errs/coderr.go
index 506a0ddcc..af88a6353 100644
--- a/pkg/errs/coderr.go
+++ b/pkg/errs/coderr.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package errs
import (
diff --git a/pkg/errs/predefine.go b/pkg/errs/predefine.go
index 740875c6f..4890a0996 100644
--- a/pkg/errs/predefine.go
+++ b/pkg/errs/predefine.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package errs
var (
diff --git a/pkg/errs/relation.go b/pkg/errs/relation.go
index 5d87ab59e..76578f4bb 100644
--- a/pkg/errs/relation.go
+++ b/pkg/errs/relation.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package errs
var Relation = &relation{m: make(map[int]map[int]struct{})}
diff --git a/pkg/proto/auth/auth.go b/pkg/proto/auth/auth.go
index e7189afab..45e935558 100644
--- a/pkg/proto/auth/auth.go
+++ b/pkg/proto/auth/auth.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package auth
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
diff --git a/pkg/proto/auth/auth.proto b/pkg/proto/auth/auth.proto
index 6894db8db..29c008cbe 100644
--- a/pkg/proto/auth/auth.proto
+++ b/pkg/proto/auth/auth.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.auth;
option go_package = "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/auth";
diff --git a/pkg/proto/conversation/conversation.go b/pkg/proto/conversation/conversation.go
index 7b4d8e242..64b467ddb 100644
--- a/pkg/proto/conversation/conversation.go
+++ b/pkg/proto/conversation/conversation.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package conversation
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
diff --git a/pkg/proto/conversation/conversation.proto b/pkg/proto/conversation/conversation.proto
index 967109520..b08366af7 100644
--- a/pkg/proto/conversation/conversation.proto
+++ b/pkg/proto/conversation/conversation.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.conversation;
import "wrapperspb/wrapperspb.proto";
diff --git a/pkg/proto/errinfo/errinfo.proto b/pkg/proto/errinfo/errinfo.proto
index 77182d1d5..11fddec34 100644
--- a/pkg/proto/errinfo/errinfo.proto
+++ b/pkg/proto/errinfo/errinfo.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.protobuf;
diff --git a/pkg/proto/friend/friend.go b/pkg/proto/friend/friend.go
index 8b9879406..f2ad6a7a4 100644
--- a/pkg/proto/friend/friend.go
+++ b/pkg/proto/friend/friend.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package friend
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
diff --git a/pkg/proto/friend/friend.proto b/pkg/proto/friend/friend.proto
index 30b30f752..98a9e81e9 100644
--- a/pkg/proto/friend/friend.proto
+++ b/pkg/proto/friend/friend.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.friend;
import "sdkws/sdkws.proto";
diff --git a/pkg/proto/gen.sh b/pkg/proto/gen.sh
index 930a636ec..3c06bbfa7 100644
--- a/pkg/proto/gen.sh
+++ b/pkg/proto/gen.sh
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
protoc --go_out=plugins=grpc:./auth --go_opt=module=github.com/OpenIMSDK/Open-IM-Server/pkg/proto/auth auth/auth.proto
protoc --go_out=plugins=grpc:./conversation --go_opt=module=github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation conversation/conversation.proto
protoc --go_out=plugins=grpc:./errinfo --go_opt=module=github.com/OpenIMSDK/Open-IM-Server/pkg/proto/errinfo errinfo/errinfo.proto
diff --git a/pkg/proto/group/group.go b/pkg/proto/group/group.go
index 24e4a47c7..64e7f0f61 100644
--- a/pkg/proto/group/group.go
+++ b/pkg/proto/group/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package group
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
diff --git a/pkg/proto/group/group.proto b/pkg/proto/group/group.proto
index 432da16db..9d02f58f7 100644
--- a/pkg/proto/group/group.proto
+++ b/pkg/proto/group/group.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.group;
import "sdkws/sdkws.proto";
diff --git a/pkg/proto/msg/msg.go b/pkg/proto/msg/msg.go
index 38f503321..a221639ee 100644
--- a/pkg/proto/msg/msg.go
+++ b/pkg/proto/msg/msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msg
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
diff --git a/pkg/proto/msg/msg.proto b/pkg/proto/msg/msg.proto
index fc623e1b6..9fa093edf 100644
--- a/pkg/proto/msg/msg.proto
+++ b/pkg/proto/msg/msg.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.msg;
import "sdkws/sdkws.proto";
diff --git a/pkg/proto/msggateway/msggateway.go b/pkg/proto/msggateway/msggateway.go
index 3d638d5d8..5e0c85b45 100644
--- a/pkg/proto/msggateway/msggateway.go
+++ b/pkg/proto/msggateway/msggateway.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package msggateway
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
diff --git a/pkg/proto/msggateway/msggateway.proto b/pkg/proto/msggateway/msggateway.proto
index 2127daeba..0f6c0bd5f 100644
--- a/pkg/proto/msggateway/msggateway.proto
+++ b/pkg/proto/msggateway/msggateway.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.msggateway;
import "sdkws/sdkws.proto";
diff --git a/pkg/proto/push/push.go b/pkg/proto/push/push.go
index d7c1b5b5a..2f117acda 100644
--- a/pkg/proto/push/push.go
+++ b/pkg/proto/push/push.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package push
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
diff --git a/pkg/proto/push/push.proto b/pkg/proto/push/push.proto
index a5c0ad8a7..1f511b225 100644
--- a/pkg/proto/push/push.proto
+++ b/pkg/proto/push/push.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.push;
import "sdkws/sdkws.proto";
diff --git a/pkg/proto/sdkws/sdkws.go b/pkg/proto/sdkws/sdkws.go
index 094cb823b..1c0888745 100644
--- a/pkg/proto/sdkws/sdkws.go
+++ b/pkg/proto/sdkws/sdkws.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package sdkws
import (
diff --git a/pkg/proto/sdkws/sdkws.proto b/pkg/proto/sdkws/sdkws.proto
index 4db0b1648..4e81502d3 100644
--- a/pkg/proto/sdkws/sdkws.proto
+++ b/pkg/proto/sdkws/sdkws.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.sdkws;
import "wrapperspb/wrapperspb.proto";
diff --git a/pkg/proto/statistics/statistics.proto b/pkg/proto/statistics/statistics.proto
index 70980edd3..160ad1dcd 100644
--- a/pkg/proto/statistics/statistics.proto
+++ b/pkg/proto/statistics/statistics.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.statistics;
option go_package = "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/statistics";
diff --git a/pkg/proto/third/third.go b/pkg/proto/third/third.go
index 88ee316bd..9562255fc 100644
--- a/pkg/proto/third/third.go
+++ b/pkg/proto/third/third.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package third
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
diff --git a/pkg/proto/third/third.proto b/pkg/proto/third/third.proto
index 7021dfaef..8cdad7562 100644
--- a/pkg/proto/third/third.proto
+++ b/pkg/proto/third/third.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.third;
option go_package = "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third";
diff --git a/pkg/proto/user/user.go b/pkg/proto/user/user.go
index 26b0b1b31..09ae39c7e 100644
--- a/pkg/proto/user/user.go
+++ b/pkg/proto/user/user.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package user
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
diff --git a/pkg/proto/user/user.proto b/pkg/proto/user/user.proto
index 6cdbf53d9..e63959aff 100644
--- a/pkg/proto/user/user.proto
+++ b/pkg/proto/user/user.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.user;
import "sdkws/sdkws.proto";
diff --git a/pkg/proto/wrapperspb/wrapperspb.go b/pkg/proto/wrapperspb/wrapperspb.go
index 229d07ede..7579c64f0 100644
--- a/pkg/proto/wrapperspb/wrapperspb.go
+++ b/pkg/proto/wrapperspb/wrapperspb.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package wrapperspb
import (
diff --git a/pkg/proto/wrapperspb/wrapperspb.proto b/pkg/proto/wrapperspb/wrapperspb.proto
index 768b9fe86..ec1bdca20 100644
--- a/pkg/proto/wrapperspb/wrapperspb.proto
+++ b/pkg/proto/wrapperspb/wrapperspb.proto
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
syntax = "proto3";
package OpenIMServer.protobuf;
diff --git a/pkg/rpcclient/auth.go b/pkg/rpcclient/auth.go
index fc435aa24..aa13ed898 100644
--- a/pkg/rpcclient/auth.go
+++ b/pkg/rpcclient/auth.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package rpcclient
import (
diff --git a/pkg/rpcclient/conversation.go b/pkg/rpcclient/conversation.go
index cc781e449..5cab1d689 100644
--- a/pkg/rpcclient/conversation.go
+++ b/pkg/rpcclient/conversation.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package rpcclient
import (
diff --git a/pkg/rpcclient/friend.go b/pkg/rpcclient/friend.go
index 56875dc83..51b63700c 100644
--- a/pkg/rpcclient/friend.go
+++ b/pkg/rpcclient/friend.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package rpcclient
import (
diff --git a/pkg/rpcclient/group.go b/pkg/rpcclient/group.go
index 399be6a77..06333234f 100644
--- a/pkg/rpcclient/group.go
+++ b/pkg/rpcclient/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package rpcclient
import (
diff --git a/pkg/rpcclient/msg.go b/pkg/rpcclient/msg.go
index 43f30361a..aabc3768a 100644
--- a/pkg/rpcclient/msg.go
+++ b/pkg/rpcclient/msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package rpcclient
import (
diff --git a/pkg/rpcclient/notification/common.go b/pkg/rpcclient/notification/common.go
index ea0174000..09d8b8798 100644
--- a/pkg/rpcclient/notification/common.go
+++ b/pkg/rpcclient/notification/common.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package notification
type CommonUser interface {
diff --git a/pkg/rpcclient/notification/conevrsation.go b/pkg/rpcclient/notification/conevrsation.go
index 8fb11ba97..12e851375 100644
--- a/pkg/rpcclient/notification/conevrsation.go
+++ b/pkg/rpcclient/notification/conevrsation.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package notification
import (
diff --git a/pkg/rpcclient/notification/extend_msg.go b/pkg/rpcclient/notification/extend_msg.go
index 1bef5c9b4..85e5b1903 100644
--- a/pkg/rpcclient/notification/extend_msg.go
+++ b/pkg/rpcclient/notification/extend_msg.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package notification
import (
diff --git a/pkg/rpcclient/notification/friend.go b/pkg/rpcclient/notification/friend.go
index 495238b03..e7df2e6cd 100644
--- a/pkg/rpcclient/notification/friend.go
+++ b/pkg/rpcclient/notification/friend.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package notification
import (
diff --git a/pkg/rpcclient/notification/group.go b/pkg/rpcclient/notification/group.go
index f93f0786a..fcc32b092 100644
--- a/pkg/rpcclient/notification/group.go
+++ b/pkg/rpcclient/notification/group.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package notification
import (
diff --git a/pkg/rpcclient/push.go b/pkg/rpcclient/push.go
index 5359c31ee..8e19782bd 100644
--- a/pkg/rpcclient/push.go
+++ b/pkg/rpcclient/push.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package rpcclient
import (
diff --git a/pkg/rpcclient/third.go b/pkg/rpcclient/third.go
index c657c02a1..4f57cbd69 100644
--- a/pkg/rpcclient/third.go
+++ b/pkg/rpcclient/third.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package rpcclient
import (
diff --git a/pkg/rpcclient/user.go b/pkg/rpcclient/user.go
index 383d0cc67..17dec167c 100644
--- a/pkg/rpcclient/user.go
+++ b/pkg/rpcclient/user.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package rpcclient
import (
diff --git a/pkg/startrpc/start.go b/pkg/startrpc/start.go
index de5be74e5..3eeaaa3a2 100644
--- a/pkg/startrpc/start.go
+++ b/pkg/startrpc/start.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package startrpc
import (
diff --git a/pkg/statistics/statistics.go b/pkg/statistics/statistics.go
index 87cba474c..2a6ae01ae 100644
--- a/pkg/statistics/statistics.go
+++ b/pkg/statistics/statistics.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package statistics
import (
diff --git a/pkg/utils/base64.go b/pkg/utils/base64.go
index 3f01c1488..9502dcde8 100644
--- a/pkg/utils/base64.go
+++ b/pkg/utils/base64.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import "encoding/base64"
diff --git a/pkg/utils/callback.go b/pkg/utils/callback.go
index 139d166c0..7eed52409 100644
--- a/pkg/utils/callback.go
+++ b/pkg/utils/callback.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/encryption.go b/pkg/utils/encryption.go
index a4862de2e..23266d8f7 100644
--- a/pkg/utils/encryption.go
+++ b/pkg/utils/encryption.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/file.go b/pkg/utils/file.go
index 7aa7719bd..79528661d 100644
--- a/pkg/utils/file.go
+++ b/pkg/utils/file.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/get_server_ip.go b/pkg/utils/get_server_ip.go
index b8056af9d..aad0bf2cc 100644
--- a/pkg/utils/get_server_ip.go
+++ b/pkg/utils/get_server_ip.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/id.go b/pkg/utils/id.go
index 509578df7..25e942f36 100644
--- a/pkg/utils/id.go
+++ b/pkg/utils/id.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/id_test.go b/pkg/utils/id_test.go
index 3c0d5938e..d6ab3e665 100644
--- a/pkg/utils/id_test.go
+++ b/pkg/utils/id_test.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import "testing"
diff --git a/pkg/utils/image.go b/pkg/utils/image.go
index 26060f1de..f93591f9e 100644
--- a/pkg/utils/image.go
+++ b/pkg/utils/image.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/image_test.go b/pkg/utils/image_test.go
index f28cfc89d..87d78620f 100644
--- a/pkg/utils/image_test.go
+++ b/pkg/utils/image_test.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/map.go b/pkg/utils/map.go
index 7a5fb2d6b..cd7f3f1de 100644
--- a/pkg/utils/map.go
+++ b/pkg/utils/map.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/md5_test.go b/pkg/utils/md5_test.go
index 63eec8077..1add67f32 100644
--- a/pkg/utils/md5_test.go
+++ b/pkg/utils/md5_test.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/options.go b/pkg/utils/options.go
index a3b265e14..0ade70dfe 100644
--- a/pkg/utils/options.go
+++ b/pkg/utils/options.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
diff --git a/pkg/utils/page.go b/pkg/utils/page.go
index 61942a5d7..ad19decb0 100644
--- a/pkg/utils/page.go
+++ b/pkg/utils/page.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
diff --git a/pkg/utils/platform_number_id_to_name_test.go b/pkg/utils/platform_number_id_to_name_test.go
index 78569aed4..47c4016ed 100644
--- a/pkg/utils/platform_number_id_to_name_test.go
+++ b/pkg/utils/platform_number_id_to_name_test.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/retry/retry.go b/pkg/utils/retry/retry.go
index 8877dd0a5..eb2a387cb 100644
--- a/pkg/utils/retry/retry.go
+++ b/pkg/utils/retry/retry.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package retry
import (
diff --git a/pkg/utils/retry/stratey.go b/pkg/utils/retry/stratey.go
index e045684e8..8dca54161 100644
--- a/pkg/utils/retry/stratey.go
+++ b/pkg/utils/retry/stratey.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package retry
import "time"
diff --git a/pkg/utils/splitter/tools.go b/pkg/utils/splitter/tools.go
index 40bd7dee2..d36b9c3be 100644
--- a/pkg/utils/splitter/tools.go
+++ b/pkg/utils/splitter/tools.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package splitter
type SplitResult struct {
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go
index 1138313d2..418e65d34 100644
--- a/pkg/utils/utils.go
+++ b/pkg/utils/utils.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/utils_v2.go b/pkg/utils/utils_v2.go
index 777308fd7..f4cc44871 100644
--- a/pkg/utils/utils_v2.go
+++ b/pkg/utils/utils_v2.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/pkg/utils/utils_v2_test.go b/pkg/utils/utils_v2_test.go
index f5aeef538..ba55b8941 100644
--- a/pkg/utils/utils_v2_test.go
+++ b/pkg/utils/utils_v2_test.go
@@ -1,3 +1,17 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package utils
import (
diff --git a/scripts/batch_build_all_service.sh b/scripts/batch_build_all_service.sh
index bf780008f..6c74e1957 100755
--- a/scripts/batch_build_all_service.sh
+++ b/scripts/batch_build_all_service.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
source ./style_info.cfg
source ./path_info.cfg
diff --git a/scripts/batch_start_all.sh b/scripts/batch_start_all.sh
index eebf96796..e917d7003 100755
--- a/scripts/batch_start_all.sh
+++ b/scripts/batch_start_all.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
#fixme This scripts is the total startup scripts
#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
diff --git a/scripts/build_all_service.sh b/scripts/build_all_service.sh
index 0d9814bec..a6495939d 100755
--- a/scripts/build_all_service.sh
+++ b/scripts/build_all_service.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
source ./style_info.cfg
source ./path_info.cfg
diff --git a/scripts/build_images.sh b/scripts/build_images.sh
index ad37e24e4..ad47cdb24 100755
--- a/scripts/build_images.sh
+++ b/scripts/build_images.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
image=openim/open_im_server:v1.0.5
rm Open-IM-Server -rf
git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive
diff --git a/scripts/build_push_k8s_images.sh b/scripts/build_push_k8s_images.sh
index 432457298..ff9887c56 100755
--- a/scripts/build_push_k8s_images.sh
+++ b/scripts/build_push_k8s_images.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
version=errcode
repository=${1}
if [[ -z ${repository} ]]
diff --git a/scripts/check_all.sh b/scripts/check_all.sh
index e4feb7f93..16fec32ff 100755
--- a/scripts/check_all.sh
+++ b/scripts/check_all.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
source ./style_info.cfg
source ./path_info.cfg
diff --git a/scripts/coverage.sh b/scripts/coverage.sh
index 9fb77b59a..d4605ee3f 100644
--- a/scripts/coverage.sh
+++ b/scripts/coverage.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# http://stackoverflow.com/a/21142256/2055281
diff --git a/scripts/docker_check_service.sh b/scripts/docker_check_service.sh
index 4e7d52af3..4acbde407 100755
--- a/scripts/docker_check_service.sh
+++ b/scripts/docker_check_service.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
echo "docker-compose ps..........................."
cd ..
diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh
index d4ded7121..8ed198cae 100755
--- a/scripts/docker_start_all.sh
+++ b/scripts/docker_start_all.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
#fixme This scripts is the total startup scripts
#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
diff --git a/scripts/ensure_tag.sh b/scripts/ensure_tag.sh
new file mode 100644
index 000000000..2da3c404f
--- /dev/null
+++ b/scripts/ensure_tag.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+version="${VERSION}"
+if [ "${version}" == "" ];then
+ version=v`gsemver bump`
+fi
+
+if [ -z "`git tag -l ${version}`" ];then
+ git tag -a -m "release version ${version}" ${version}
+fi
diff --git a/scripts/enterprise/check_all.sh b/scripts/enterprise/check_all.sh
index 0f6cb0d5c..f439404f1 100755
--- a/scripts/enterprise/check_all.sh
+++ b/scripts/enterprise/check_all.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
source ./style_info.cfg
source ./enterprise/path_info.cfg
diff --git a/scripts/enterprise/function.sh b/scripts/enterprise/function.sh
index 97f19187a..e2dc96a25 100755
--- a/scripts/enterprise/function.sh
+++ b/scripts/enterprise/function.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
#input:[10023,2323,3434]
#output:10023 2323 3434
list_to_string(){
diff --git a/scripts/env_check.sh b/scripts/env_check.sh
index f51dca451..c6cfaf4bb 100755
--- a/scripts/env_check.sh
+++ b/scripts/env_check.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
source ./style_info.cfg
echo -e "check time synchronize.................................."
diff --git a/scripts/function.sh b/scripts/function.sh
index 97f19187a..e2dc96a25 100755
--- a/scripts/function.sh
+++ b/scripts/function.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
#input:[10023,2323,3434]
#output:10023 2323 3434
list_to_string(){
diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit
index db9d7cf17..dbd84edef 100644
--- a/scripts/githooks/pre-commit
+++ b/scripts/githooks/pre-commit
@@ -28,7 +28,6 @@ LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)"
valid_branch_regex="^(main|master|develop)$|(feature|feat|release|hotfix|test|bug|ci|style|)\/[a-z0-9._-]+$|^HEAD$"
-
YELLOW="\e[93m"
GREEN="\e[32m"
RED="\e[31m"
diff --git a/scripts/init_pwd.sh b/scripts/init_pwd.sh
index d4b1caf48..fa8296724 100755
--- a/scripts/init_pwd.sh
+++ b/scripts/init_pwd.sh
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
source ../.env
diff --git a/scripts/lib/color.sh b/scripts/lib/color.sh
index bdbe0e843..52caa78f8 100755
--- a/scripts/lib/color.sh
+++ b/scripts/lib/color.sh
@@ -1,8 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-# Copyright 2020 Lingfei Kong . All rights reserved.
-# Use of this source code is governed by a MIT style
-# license that can be found in the LICENSE file.
#Define color variables
#Feature
@@ -22,7 +32,7 @@ COLOR_BBLUE='\033[44m';COLOR_BMAGENTA='\033[45m';
COLOR_BCYAN='\033[46m';COLOR_BWHITE='\033[47m';
# Print colors you can use
-iam::color::print_color()
+openim::color::print_color()
{
echo
echo -e ${bmagenta}--back-color:${normal}
diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh
index f58e08649..1353ec2d2 100755
--- a/scripts/lib/golang.sh
+++ b/scripts/lib/golang.sh
@@ -1,152 +1,162 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-# Copyright 2020 Lingfei Kong . All rights reserved.
-# Use of this source code is governed by a MIT style
-# license that can be found in the LICENSE file.
# shellcheck disable=SC2034 # Variables sourced in other scripts.
# The server platform we are building on.
-readonly IAM_SUPPORTED_SERVER_PLATFORMS=(
+readonly OPENIM_SUPPORTED_SERVER_PLATFORMS=(
linux/amd64
linux/arm64
)
# If we update this we should also update the set of platforms whose standard
# library is precompiled for in build/build-image/cross/Dockerfile
-readonly IAM_SUPPORTED_CLIENT_PLATFORMS=(
+readonly OPENIM_SUPPORTED_CLIENT_PLATFORMS=(
linux/amd64
linux/arm64
)
# The set of server targets that we are only building for Linux
# If you update this list, please also update build/BUILD.
-iam::golang::server_targets() {
+openim::golang::server_targets() {
local targets=(
- iam-apiserver
- iam-authz-server
- iam-pump
- iam-watcher
+ openim-apiserver
+ openim-authz-server
+ openim-pump
+ openim-watcher
)
echo "${targets[@]}"
}
-IFS=" " read -ra IAM_SERVER_TARGETS <<< "$(iam::golang::server_targets)"
-readonly IAM_SERVER_TARGETS
-readonly IAM_SERVER_BINARIES=("${IAM_SERVER_TARGETS[@]##*/}")
+IFS=" " read -ra OPENIM_SERVER_TARGETS <<< "$(openim::golang::server_targets)"
+readonly OPENIM_SERVER_TARGETS
+readonly OPENIM_SERVER_BINARIES=("${OPENIM_SERVER_TARGETS[@]##*/}")
# The set of server targets we build docker images for
-iam::golang::server_image_targets() {
- # NOTE: this contains cmd targets for iam::build::get_docker_wrapped_binaries
+openim::golang::server_image_targets() {
+ # NOTE: this contains cmd targets for openim::build::get_docker_wrapped_binaries
local targets=(
- cmd/iam-apiserver
- cmd/iam-authz-server
- cmd/iam-pump
- cmd/iam-watcher
+ cmd/openim-apiserver
+ cmd/openim-authz-server
+ cmd/openim-pump
+ cmd/openim-watcher
)
echo "${targets[@]}"
}
-IFS=" " read -ra IAM_SERVER_IMAGE_TARGETS <<< "$(iam::golang::server_image_targets)"
-readonly IAM_SERVER_IMAGE_TARGETS
-readonly IAM_SERVER_IMAGE_BINARIES=("${IAM_SERVER_IMAGE_TARGETS[@]##*/}")
+IFS=" " read -ra OPENIM_SERVER_IMAGE_TARGETS <<< "$(openim::golang::server_image_targets)"
+readonly OPENIM_SERVER_IMAGE_TARGETS
+readonly OPENIM_SERVER_IMAGE_BINARIES=("${OPENIM_SERVER_IMAGE_TARGETS[@]##*/}")
# ------------
# NOTE: All functions that return lists should use newlines.
# bash functions can't return arrays, and spaces are tricky, so newline
# separators are the preferred pattern.
-# To transform a string of newline-separated items to an array, use iam::util::read-array:
-# iam::util::read-array FOO < <(iam::golang::dups a b c a)
+# To transform a string of newline-separated items to an array, use openim::util::read-array:
+# openim::util::read-array FOO < <(openim::golang::dups a b c a)
#
# ALWAYS remember to quote your subshells. Not doing so will break in
# bash 4.3, and potentially cause other issues.
# ------------
# Returns a sorted newline-separated list containing only duplicated items.
-iam::golang::dups() {
+openim::golang::dups() {
# We use printf to insert newlines, which are required by sort.
printf "%s\n" "$@" | sort | uniq -d
}
# Returns a sorted newline-separated list with duplicated items removed.
-iam::golang::dedup() {
+openim::golang::dedup() {
# We use printf to insert newlines, which are required by sort.
printf "%s\n" "$@" | sort -u
}
-# Depends on values of user-facing IAM_BUILD_PLATFORMS, IAM_FASTBUILD,
-# and IAM_BUILDER_OS.
-# Configures IAM_SERVER_PLATFORMS and IAM_CLIENT_PLATFORMS, then sets them
+# Depends on values of user-facing OPENIM_BUILD_PLATFORMS, OPENIM_FASTBUILD,
+# and OPENIM_BUILDER_OS.
+# Configures OPENIM_SERVER_PLATFORMS and OPENIM_CLIENT_PLATFORMS, then sets them
# to readonly.
# The configured vars will only contain platforms allowed by the
-# IAM_SUPPORTED* vars at the top of this file.
-declare -a IAM_SERVER_PLATFORMS
-declare -a IAM_CLIENT_PLATFORMS
-iam::golang::setup_platforms() {
- if [[ -n "${IAM_BUILD_PLATFORMS:-}" ]]; then
- # IAM_BUILD_PLATFORMS needs to be read into an array before the next
+# OPENIM_SUPPORTED* vars at the top of this file.
+declare -a OPENIM_SERVER_PLATFORMS
+declare -a OPENIM_CLIENT_PLATFORMS
+openim::golang::setup_platforms() {
+ if [[ -n "${OPENIM_BUILD_PLATFORMS:-}" ]]; then
+ # OPENIM_BUILD_PLATFORMS needs to be read into an array before the next
# step, or quoting treats it all as one element.
local -a platforms
- IFS=" " read -ra platforms <<< "${IAM_BUILD_PLATFORMS}"
+ IFS=" " read -ra platforms <<< "${OPENIM_BUILD_PLATFORMS}"
- # Deduplicate to ensure the intersection trick with iam::golang::dups
+ # Deduplicate to ensure the intersection trick with openim::golang::dups
# is not defeated by duplicates in user input.
- iam::util::read-array platforms < <(iam::golang::dedup "${platforms[@]}")
+ openim::util::read-array platforms < <(openim::golang::dedup "${platforms[@]}")
- # Use iam::golang::dups to restrict the builds to the platforms in
- # IAM_SUPPORTED_*_PLATFORMS. Items should only appear at most once in each
+ # Use openim::golang::dups to restrict the builds to the platforms in
+ # OPENIM_SUPPORTED_*_PLATFORMS. Items should only appear at most once in each
# set, so if they appear twice after the merge they are in the intersection.
- iam::util::read-array IAM_SERVER_PLATFORMS < <(iam::golang::dups \
+ openim::util::read-array OPENIM_SERVER_PLATFORMS < <(openim::golang::dups \
"${platforms[@]}" \
- "${IAM_SUPPORTED_SERVER_PLATFORMS[@]}" \
+ "${OPENIM_SUPPORTED_SERVER_PLATFORMS[@]}" \
)
- readonly IAM_SERVER_PLATFORMS
+ readonly OPENIM_SERVER_PLATFORMS
- iam::util::read-array IAM_CLIENT_PLATFORMS < <(iam::golang::dups \
+ openim::util::read-array OPENIM_CLIENT_PLATFORMS < <(openim::golang::dups \
"${platforms[@]}" \
- "${IAM_SUPPORTED_CLIENT_PLATFORMS[@]}" \
+ "${OPENIM_SUPPORTED_CLIENT_PLATFORMS[@]}" \
)
- readonly IAM_CLIENT_PLATFORMS
+ readonly OPENIM_CLIENT_PLATFORMS
- elif [[ "${IAM_FASTBUILD:-}" == "true" ]]; then
- IAM_SERVER_PLATFORMS=(linux/amd64)
- readonly IAM_SERVER_PLATFORMS
- IAM_CLIENT_PLATFORMS=(linux/amd64)
- readonly IAM_CLIENT_PLATFORMS
+ elif [[ "${OPENIM_FASTBUILD:-}" == "true" ]]; then
+ OPENIM_SERVER_PLATFORMS=(linux/amd64)
+ readonly OPENIM_SERVER_PLATFORMS
+ OPENIM_CLIENT_PLATFORMS=(linux/amd64)
+ readonly OPENIM_CLIENT_PLATFORMS
else
- IAM_SERVER_PLATFORMS=("${IAM_SUPPORTED_SERVER_PLATFORMS[@]}")
- readonly IAM_SERVER_PLATFORMS
+ OPENIM_SERVER_PLATFORMS=("${OPENIM_SUPPORTED_SERVER_PLATFORMS[@]}")
+ readonly OPENIM_SERVER_PLATFORMS
- IAM_CLIENT_PLATFORMS=("${IAM_SUPPORTED_CLIENT_PLATFORMS[@]}")
- readonly IAM_CLIENT_PLATFORMS
+ OPENIM_CLIENT_PLATFORMS=("${OPENIM_SUPPORTED_CLIENT_PLATFORMS[@]}")
+ readonly OPENIM_CLIENT_PLATFORMS
fi
}
-iam::golang::setup_platforms
+openim::golang::setup_platforms
# The set of client targets that we are building for all platforms
# If you update this list, please also update build/BUILD.
-readonly IAM_CLIENT_TARGETS=(
+readonly OPENIM_CLIENT_TARGETS=(
iamctl
)
-readonly IAM_CLIENT_BINARIES=("${IAM_CLIENT_TARGETS[@]##*/}")
+readonly OPENIM_CLIENT_BINARIES=("${OPENIM_CLIENT_TARGETS[@]##*/}")
-readonly IAM_ALL_TARGETS=(
- "${IAM_SERVER_TARGETS[@]}"
- "${IAM_CLIENT_TARGETS[@]}"
+readonly OPENIM_ALL_TARGETS=(
+ "${OPENIM_SERVER_TARGETS[@]}"
+ "${OPENIM_CLIENT_TARGETS[@]}"
)
-readonly IAM_ALL_BINARIES=("${IAM_ALL_TARGETS[@]##*/}")
+readonly OPENIM_ALL_BINARIES=("${OPENIM_ALL_TARGETS[@]##*/}")
# Asks golang what it thinks the host platform is. The go tool chain does some
# slightly different things when the target platform matches the host platform.
-iam::golang::host_platform() {
+openim::golang::host_platform() {
echo "$(go env GOHOSTOS)/$(go env GOHOSTARCH)"
}
# Ensure the go tool exists and is a viable version.
-iam::golang::verify_go_version() {
+openim::golang::verify_go_version() {
if [[ -z "$(command -v go)" ]]; then
- iam::log::usage_from_stdin <. All rights reserved.
-# Use of this source code is governed by a MIT style
-# license that can be found in the LICENSE file.
set -o errexit
set +o nounset
@@ -16,13 +26,13 @@ unset CDPATH
export GO111MODULE=on
# The root of the build/dist directory
-IAM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
+OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
-source "${IAM_ROOT}/scripts/lib/util.sh"
-source "${IAM_ROOT}/scripts/lib/logging.sh"
-source "${IAM_ROOT}/scripts/lib/color.sh"
+source "${OPENIM_ROOT}/scripts/lib/util.sh"
+source "${OPENIM_ROOT}/scripts/lib/logging.sh"
+source "${OPENIM_ROOT}/scripts/lib/color.sh"
-iam::log::install_errexit
+openim::log::install_errexit
-source "${IAM_ROOT}/scripts/lib/version.sh"
-source "${IAM_ROOT}/scripts/lib/golang.sh"
+source "${OPENIM_ROOT}/scripts/lib/version.sh"
+source "${OPENIM_ROOT}/scripts/lib/golang.sh"
diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh
index 39b805c11..092db5513 100755
--- a/scripts/lib/logging.sh
+++ b/scripts/lib/logging.sh
@@ -1,15 +1,25 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-# Copyright 2020 Lingfei Kong . All rights reserved.
-# Use of this source code is governed by a MIT style
-# license that can be found in the LICENSE file.
# Controls verbosity of the script output and logging.
-IAM_VERBOSE="${IAM_VERBOSE:-5}"
+OPENIM_VERBOSE="${OPENIM_VERBOSE:-5}"
# Handler for when we exit automatically on an error.
# Borrowed from https://gist.github.com/ahendrix/7030300
-iam::log::errexit() {
+openim::log::errexit() {
local err="${PIPESTATUS[*]}"
# If the shell we are in doesn't have errexit set (common in subshells) then
@@ -21,19 +31,19 @@ iam::log::errexit() {
# Print out the stack trace described by $function_stack
if [ ${#FUNCNAME[@]} -gt 2 ]
then
- iam::log::error "Call tree:"
+ openim::log::error "Call tree:"
for ((i=1;i<${#FUNCNAME[@]}-1;i++))
do
- iam::log::error " ${i}: ${BASH_SOURCE[${i}+1]}:${BASH_LINENO[${i}]} ${FUNCNAME[${i}]}(...)"
+ openim::log::error " ${i}: ${BASH_SOURCE[${i}+1]}:${BASH_LINENO[${i}]} ${FUNCNAME[${i}]}(...)"
done
fi
- iam::log::error_exit "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}' exited with status ${err}" "${1:-1}" 1
+ openim::log::error_exit "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}' exited with status ${err}" "${1:-1}" 1
}
-iam::log::install_errexit() {
+openim::log::install_errexit() {
# trap ERR to provide an error handler whenever a command exits nonzero this
# is a more verbose version of set -o errexit
- trap 'iam::log::errexit' ERR
+ trap 'openim::log::errexit' ERR
# setting errtrace allows our ERR trap handler to be propagated to functions,
# expansions and subshells
@@ -44,7 +54,7 @@ iam::log::install_errexit() {
#
# Args:
# $1 The number of stack frames to skip when printing.
-iam::log::stack() {
+openim::log::stack() {
local stack_skip=${1:-0}
stack_skip=$((stack_skip + 1))
if [[ ${#FUNCNAME[@]} -gt ${stack_skip} ]]; then
@@ -66,13 +76,13 @@ iam::log::stack() {
# $1 Message to log with the error
# $2 The error code to return
# $3 The number of stack frames to skip when printing.
-iam::log::error_exit() {
+openim::log::error_exit() {
local message="${1:-}"
local code="${2:-1}"
local stack_skip="${3:-0}"
stack_skip=$((stack_skip + 1))
- if [[ ${IAM_VERBOSE} -ge 4 ]]; then
+ if [[ ${OPENIM_VERBOSE} -ge 4 ]]; then
local source_file=${BASH_SOURCE[${stack_skip}]}
local source_line=${BASH_LINENO[$((stack_skip - 1))]}
echo "!!! Error in ${source_file}:${source_line}" >&2
@@ -80,7 +90,7 @@ iam::log::error_exit() {
echo " ${1}" >&2
}
- iam::log::stack ${stack_skip}
+ openim::log::stack ${stack_skip}
echo "Exiting with status ${code}" >&2
fi
@@ -89,7 +99,7 @@ iam::log::error_exit() {
}
# Log an error but keep going. Don't dump the stack or exit.
-iam::log::error() {
+openim::log::error() {
timestamp=$(date +"[%m%d %H:%M:%S]")
echo "!!! ${timestamp} ${1-}" >&2
shift
@@ -99,7 +109,7 @@ iam::log::error() {
}
# Print an usage message to stderr. The arguments are printed directly.
-iam::log::usage() {
+openim::log::usage() {
echo >&2
local message
for message; do
@@ -108,19 +118,19 @@ iam::log::usage() {
echo >&2
}
-iam::log::usage_from_stdin() {
+openim::log::usage_from_stdin() {
local messages=()
while read -r line; do
messages+=("${line}")
done
- iam::log::usage "${messages[@]}"
+ openim::log::usage "${messages[@]}"
}
# Print out some info that isn't a top level status line
-iam::log::info() {
+openim::log::info() {
local V="${V:-0}"
- if [[ ${IAM_VERBOSE} < ${V} ]]; then
+ if [[ ${OPENIM_VERBOSE} < ${V} ]]; then
return
fi
@@ -129,26 +139,26 @@ iam::log::info() {
done
}
-# Just like iam::log::info, but no \n, so you can make a progress bar
-iam::log::progress() {
+# Just like openim::log::info, but no \n, so you can make a progress bar
+openim::log::progress() {
for message; do
echo -e -n "${message}"
done
}
-iam::log::info_from_stdin() {
+openim::log::info_from_stdin() {
local messages=()
while read -r line; do
messages+=("${line}")
done
- iam::log::info "${messages[@]}"
+ openim::log::info "${messages[@]}"
}
# Print a status line. Formatted to show up in a stream of output.
-iam::log::status() {
+openim::log::status() {
local V="${V:-0}"
- if [[ ${IAM_VERBOSE} < ${V} ]]; then
+ if [[ ${OPENIM_VERBOSE} < ${V} ]]; then
return
fi
diff --git a/scripts/lib/release.sh b/scripts/lib/release.sh
index acc3730ef..1817e4ff2 100755
--- a/scripts/lib/release.sh
+++ b/scripts/lib/release.sh
@@ -1,22 +1,33 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-# Copyright 2020 Lingfei Kong . All rights reserved.
-# Use of this source code is governed by a MIT style
-# license that can be found in the LICENSE file.
-
-# This file creates release artifacts (tar files, container images) that are
-# ready to distribute to install or distribute to end users.
###############################################################################
# Most of the ::release:: namespace functions have been moved to
-# github.com/iam/release. Have a look in that repo and specifically in
+# github.com/openim/release. Have a look in that repo and specifically in
# lib/releaselib.sh for ::release::-related functionality.
###############################################################################
+# example: ./coscli cp/sync -r /home/off-line/docker-off-line/ cos://openim-1306374445/openim/image/amd/off-line/off-line/ -e cos.ap-guangzhou.myqcloud.com
+# https://cloud.tencent.com/document/product/436/71763
# Tencent cos configuration
-readonly BUCKET="marmotedu-1254073058"
+readonly BUCKET="openim-1306374445"
readonly REGION="ap-beijing"
-readonly COS_RELEASE_DIR="iam-release"
+readonly COS_RELEASE_DIR="openim-release"
+
+# default cos command tool
readonly COSTOOL="coscmd"
# This is where the final release artifacts are created locally
@@ -24,15 +35,15 @@ readonly RELEASE_STAGE="${LOCAL_OUTPUT_ROOT}/release-stage"
readonly RELEASE_TARS="${LOCAL_OUTPUT_ROOT}/release-tars"
readonly RELEASE_IMAGES="${LOCAL_OUTPUT_ROOT}/release-images"
-# IAM github account info
-readonly IAM_GITHUB_ORG=marmotedu
-readonly IAM_GITHUB_REPO=iam
+# OpenIM github account info
+readonly OPENIM_GITHUB_ORG=OpenIMSDK
+readonly OPENIM_GITHUB_REPO=openim
-readonly ARTIFACT=iam.tar.gz
+readonly ARTIFACT=openim.tar.gz
readonly CHECKSUM=${ARTIFACT}.sha1sum
-IAM_BUILD_CONFORMANCE=${IAM_BUILD_CONFORMANCE:-y}
-IAM_BUILD_PULL_LATEST_IMAGES=${IAM_BUILD_PULL_LATEST_IMAGES:-y}
+OPENIM_BUILD_CONFORMANCE=${OPENIM_BUILD_CONFORMANCE:-y}
+OPENIM_BUILD_PULL_LATEST_IMAGES=${OPENIM_BUILD_PULL_LATEST_IMAGES:-y}
# Validate a ci version
#
@@ -50,12 +61,12 @@ IAM_BUILD_PULL_LATEST_IMAGES=${IAM_BUILD_PULL_LATEST_IMAGES:-y}
# VERSION_PRERELEASE_REV (e.g. '4')
# VERSION_BUILD_INFO (e.g. '.56+abcdef12345678')
# VERSION_COMMITS (e.g. '56')
-function iam::release::parse_and_validate_ci_version() {
+function openim::release::parse_and_validate_ci_version() {
# Accept things like "v1.2.3-alpha.4.56+abcdef12345678" or "v1.2.3-beta.4"
local -r version_regex="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-([a-zA-Z0-9]+)\\.(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*)\\+[0-9a-f]{7,40})?$"
local -r version="${1-}"
[[ "${version}" =~ ${version_regex} ]] || {
- iam::log::error "Invalid ci version: '${version}', must match regex ${version_regex}"
+ openim::log::error "Invalid ci version: '${version}', must match regex ${version_regex}"
return 1
}
@@ -80,73 +91,73 @@ function iam::release::parse_and_validate_ci_version() {
# ---------------------------------------------------------------------------
# Build final release artifacts
-function iam::release::clean_cruft() {
+function openim::release::clean_cruft() {
# Clean out cruft
find "${RELEASE_STAGE}" -name '*~' -exec rm {} \;
find "${RELEASE_STAGE}" -name '#*#' -exec rm {} \;
find "${RELEASE_STAGE}" -name '.DS*' -exec rm {} \;
}
-function iam::release::package_tarballs() {
+function openim::release::package_tarballs() {
# Clean out any old releases
rm -rf "${RELEASE_STAGE}" "${RELEASE_TARS}" "${RELEASE_IMAGES}"
mkdir -p "${RELEASE_TARS}"
- iam::release::package_src_tarball &
- iam::release::package_client_tarballs &
- iam::release::package_iam_manifests_tarball &
- iam::release::package_server_tarballs &
- iam::util::wait-for-jobs || { iam::log::error "previous tarball phase failed"; return 1; }
-
- iam::release::package_final_tarball & # _final depends on some of the previous phases
- iam::util::wait-for-jobs || { iam::log::error "previous tarball phase failed"; return 1; }
+ openim::release::package_src_tarball &
+ openim::release::package_client_tarballs &
+ openim::release::package_iam_manifests_tarball &
+ openim::release::package_server_tarballs &
+ openim::util::wait-for-jobs || { openim::log::error "previous tarball phase failed"; return 1; }
+
+ openim::release::package_final_tarball & # _final depends on some of the previous phases
+ openim::util::wait-for-jobs || { openim::log::error "previous tarball phase failed"; return 1; }
}
-function iam::release::updload_tarballs() {
- iam::log::info "upload ${RELEASE_TARS}/* to cos bucket ${BUCKET}."
+function openim::release::updload_tarballs() {
+ openim::log::info "upload ${RELEASE_TARS}/* to cos bucket ${BUCKET}."
for file in $(ls ${RELEASE_TARS}/*)
do
if [ "${COSTOOL}" == "coscli" ];then
- coscli cp "${file}" "cos://${BUCKET}/${COS_RELEASE_DIR}/${IAM_GIT_VERSION}/${file##*/}"
+ coscli cp "${file}" "cos://${BUCKET}/${COS_RELEASE_DIR}/${OPENIM_GIT_VERSION}/${file##*/}"
coscli cp "${file}" "cos://${BUCKET}/${COS_RELEASE_DIR}/latest/${file##*/}"
else
- coscmd upload "${file}" "${COS_RELEASE_DIR}/${IAM_GIT_VERSION}/"
+ coscmd upload "${file}" "${COS_RELEASE_DIR}/${OPENIM_GIT_VERSION}/"
coscmd upload "${file}" "${COS_RELEASE_DIR}/latest/"
fi
done
}
# Package the source code we built, for compliance/licensing/audit/yadda.
-function iam::release::package_src_tarball() {
- local -r src_tarball="${RELEASE_TARS}/iam-src.tar.gz"
- iam::log::status "Building tarball: src"
- if [[ "${IAM_GIT_TREE_STATE-}" = 'clean' ]]; then
+function openim::release::package_src_tarball() {
+ local -r src_tarball="${RELEASE_TARS}/openim-src.tar.gz"
+ openim::log::status "Building tarball: src"
+ if [[ "${OPENIM_GIT_TREE_STATE-}" = 'clean' ]]; then
git archive -o "${src_tarball}" HEAD
else
- find "${IAM_ROOT}" -mindepth 1 -maxdepth 1 \
+ find "${OPENIM_ROOT}" -mindepth 1 -maxdepth 1 \
! \( \
- \( -path "${IAM_ROOT}"/_\* -o \
- -path "${IAM_ROOT}"/.git\* -o \
- -path "${IAM_ROOT}"/.gitignore\* -o \
- -path "${IAM_ROOT}"/.gsemver.yaml\* -o \
- -path "${IAM_ROOT}"/.config\* -o \
- -path "${IAM_ROOT}"/.chglog\* -o \
- -path "${IAM_ROOT}"/.gitlint -o \
- -path "${IAM_ROOT}"/.golangci.yaml -o \
- -path "${IAM_ROOT}"/.goreleaser.yml -o \
- -path "${IAM_ROOT}"/.note.md -o \
- -path "${IAM_ROOT}"/.todo.md \
+ \( -path "${OPENIM_ROOT}"/_\* -o \
+ -path "${OPENIM_ROOT}"/.git\* -o \
+ -path "${OPENIM_ROOT}"/.gitignore\* -o \
+ -path "${OPENIM_ROOT}"/.gsemver.yaml\* -o \
+ -path "${OPENIM_ROOT}"/.config\* -o \
+ -path "${OPENIM_ROOT}"/.chglog\* -o \
+ -path "${OPENIM_ROOT}"/.gitlint -o \
+ -path "${OPENIM_ROOT}"/.golangci.yaml -o \
+ -path "${OPENIM_ROOT}"/.goreleaser.yml -o \
+ -path "${OPENIM_ROOT}"/.note.md -o \
+ -path "${OPENIM_ROOT}"/.todo.md \
\) -prune \
\) -print0 \
- | "${TAR}" czf "${src_tarball}" --transform "s|${IAM_ROOT#/*}|iam|" --null -T -
+ | "${TAR}" czf "${src_tarball}" --transform "s|${OPENIM_ROOT#/*}|openim|" --null -T -
fi
}
# Package up all of the server binaries
-function iam::release::package_server_tarballs() {
+function openim::release::package_server_tarballs() {
# Find all of the built client binaries
local long_platforms=("${LOCAL_OUTPUT_BINPATH}"/*/*)
- if [[ -n ${IAM_BUILD_PLATFORMS-} ]]; then
- read -ra long_platforms <<< "${IAM_BUILD_PLATFORMS}"
+ if [[ -n ${OPENIM_BUILD_PLATFORMS-} ]]; then
+ read -ra long_platforms <<< "${OPENIM_BUILD_PLATFORMS}"
fi
for platform_long in "${long_platforms[@]}"; do
@@ -154,14 +165,14 @@ function iam::release::package_server_tarballs() {
local platform_tag
platform=${platform_long##${LOCAL_OUTPUT_BINPATH}/} # Strip LOCAL_OUTPUT_BINPATH
platform_tag=${platform/\//-} # Replace a "/" for a "-"
- iam::log::status "Starting tarball: server $platform_tag"
+ openim::log::status "Starting tarball: server $platform_tag"
(
- local release_stage="${RELEASE_STAGE}/server/${platform_tag}/iam"
+ local release_stage="${RELEASE_STAGE}/server/${platform_tag}/openim"
rm -rf "${release_stage}"
mkdir -p "${release_stage}/server/bin"
- local server_bins=("${IAM_SERVER_BINARIES[@]}")
+ local server_bins=("${OPENIM_SERVER_BINARIES[@]}")
# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
@@ -169,24 +180,24 @@ function iam::release::package_server_tarballs() {
cp "${server_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/server/bin/"
- iam::release::clean_cruft
+ openim::release::clean_cruft
- local package_name="${RELEASE_TARS}/iam-server-${platform_tag}.tar.gz"
- iam::release::create_tarball "${package_name}" "${release_stage}/.."
+ local package_name="${RELEASE_TARS}/openim-server-${platform_tag}.tar.gz"
+ openim::release::create_tarball "${package_name}" "${release_stage}/.."
) &
done
- iam::log::status "Waiting on tarballs"
- iam::util::wait-for-jobs || { iam::log::error "server tarball creation failed"; exit 1; }
+ openim::log::status "Waiting on tarballs"
+ openim::util::wait-for-jobs || { openim::log::error "server tarball creation failed"; exit 1; }
}
# Package up all of the cross compiled clients. Over time this should grow into
# a full SDK
-function iam::release::package_client_tarballs() {
+function openim::release::package_client_tarballs() {
# Find all of the built client binaries
local long_platforms=("${LOCAL_OUTPUT_BINPATH}"/*/*)
- if [[ -n ${IAM_BUILD_PLATFORMS-} ]]; then
- read -ra long_platforms <<< "${IAM_BUILD_PLATFORMS}"
+ if [[ -n ${OPENIM_BUILD_PLATFORMS-} ]]; then
+ read -ra long_platforms <<< "${OPENIM_BUILD_PLATFORMS}"
fi
for platform_long in "${long_platforms[@]}"; do
@@ -194,14 +205,14 @@ function iam::release::package_client_tarballs() {
local platform_tag
platform=${platform_long##${LOCAL_OUTPUT_BINPATH}/} # Strip LOCAL_OUTPUT_BINPATH
platform_tag=${platform/\//-} # Replace a "/" for a "-"
- iam::log::status "Starting tarball: client $platform_tag"
+ openim::log::status "Starting tarball: client $platform_tag"
(
- local release_stage="${RELEASE_STAGE}/client/${platform_tag}/iam"
+ local release_stage="${RELEASE_STAGE}/client/${platform_tag}/openim"
rm -rf "${release_stage}"
mkdir -p "${release_stage}/client/bin"
- local client_bins=("${IAM_CLIENT_BINARIES[@]}")
+ local client_bins=("${OPENIM_CLIENT_BINARIES[@]}")
# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
@@ -209,45 +220,45 @@ function iam::release::package_client_tarballs() {
cp "${client_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/client/bin/"
- iam::release::clean_cruft
+ openim::release::clean_cruft
- local package_name="${RELEASE_TARS}/iam-client-${platform_tag}.tar.gz"
- iam::release::create_tarball "${package_name}" "${release_stage}/.."
+ local package_name="${RELEASE_TARS}/openim-client-${platform_tag}.tar.gz"
+ openim::release::create_tarball "${package_name}" "${release_stage}/.."
) &
done
- iam::log::status "Waiting on tarballs"
- iam::util::wait-for-jobs || { iam::log::error "client tarball creation failed"; exit 1; }
+ openim::log::status "Waiting on tarballs"
+ openim::util::wait-for-jobs || { openim::log::error "client tarball creation failed"; exit 1; }
}
# Package up all of the server binaries in docker images
-function iam::release::build_server_images() {
+function openim::release::build_server_images() {
# Clean out any old images
rm -rf "${RELEASE_IMAGES}"
local platform
- for platform in "${IAM_SERVER_PLATFORMS[@]}"; do
+ for platform in "${OPENIM_SERVER_PLATFORMS[@]}"; do
local platform_tag
local arch
platform_tag=${platform/\//-} # Replace a "/" for a "-"
arch=$(basename "${platform}")
- iam::log::status "Building images: $platform_tag"
+ openim::log::status "Building images: $platform_tag"
local release_stage
- release_stage="${RELEASE_STAGE}/server/${platform_tag}/iam"
+ release_stage="${RELEASE_STAGE}/server/${platform_tag}/openim"
rm -rf "${release_stage}"
mkdir -p "${release_stage}/server/bin"
# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
- # IAM_SERVER_IMAGE_BINARIES array.
- cp "${IAM_SERVER_IMAGE_BINARIES[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
+ # OPENIM_SERVER_IMAGE_BINARIES array.
+ cp "${OPENIM_SERVER_IMAGE_BINARIES[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/server/bin/"
- iam::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}"
+ openim::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}"
done
}
-function iam::release::md5() {
+function openim::release::md5() {
if which md5 >/dev/null 2>&1; then
md5 -q "$1"
else
@@ -255,7 +266,7 @@ function iam::release::md5() {
fi
}
-function iam::release::sha1() {
+function openim::release::sha1() {
if which sha1sum >/dev/null 2>&1; then
sha1sum "$1" | awk '{ print $1 }'
else
@@ -263,12 +274,12 @@ function iam::release::sha1() {
fi
}
-function iam::release::build_conformance_image() {
+function openim::release::build_conformance_image() {
local -r arch="$1"
local -r registry="$2"
local -r version="$3"
local -r save_dir="${4-}"
- iam::log::status "Building conformance image for arch: ${arch}"
+ openim::log::status "Building conformance image for arch: ${arch}"
ARCH="${arch}" REGISTRY="${registry}" VERSION="${version}" \
make -C cluster/images/conformance/ build >/dev/null
@@ -277,7 +288,7 @@ function iam::release::build_conformance_image() {
if [[ -n "${save_dir}" ]]; then
"${DOCKER[@]}" save "${conformance_tag}" > "${save_dir}/conformance-${arch}.tar"
fi
- iam::log::status "Deleting conformance image ${conformance_tag}"
+ openim::log::status "Deleting conformance image ${conformance_tag}"
"${DOCKER[@]}" rmi "${conformance_tag}" &>/dev/null || true
}
@@ -285,7 +296,7 @@ function iam::release::build_conformance_image() {
# Args:
# $1 - binary_dir, the directory to save the tared images to.
# $2 - arch, architecture for which we are building docker images.
-function iam::release::create_docker_images_for_server() {
+function openim::release::create_docker_images_for_server() {
# Create a sub-shell so that we don't pollute the outer environment
(
local binary_dir
@@ -294,27 +305,27 @@ function iam::release::create_docker_images_for_server() {
local images_dir
binary_dir="$1"
arch="$2"
- binaries=$(iam::build::get_docker_wrapped_binaries "${arch}")
+ binaries=$(openim::build::get_docker_wrapped_binaries "${arch}")
images_dir="${RELEASE_IMAGES}/${arch}"
mkdir -p "${images_dir}"
# k8s.gcr.io is the constant tag in the docker archives, this is also the default for config scripts in GKE.
- # We can use IAM_DOCKER_REGISTRY to include and extra registry in the docker archive.
- # If we use IAM_DOCKER_REGISTRY="k8s.gcr.io", then the extra tag (same) is ignored, see release_docker_image_tag below.
+ # We can use OPENIM_DOCKER_REGISTRY to include and extra registry in the docker archive.
+ # If we use OPENIM_DOCKER_REGISTRY="k8s.gcr.io", then the extra tag (same) is ignored, see release_docker_image_tag below.
local -r docker_registry="k8s.gcr.io"
# Docker tags cannot contain '+'
- local docker_tag="${IAM_GIT_VERSION/+/_}"
+ local docker_tag="${OPENIM_GIT_VERSION/+/_}"
if [[ -z "${docker_tag}" ]]; then
- iam::log::error "git version information missing; cannot create Docker tag"
+ openim::log::error "git version information missing; cannot create Docker tag"
return 1
fi
- # provide `--pull` argument to `docker build` if `IAM_BUILD_PULL_LATEST_IMAGES`
+ # provide `--pull` argument to `docker build` if `OPENIM_BUILD_PULL_LATEST_IMAGES`
# is set to y or Y; otherwise try to build the image without forcefully
# pulling the latest base image.
local docker_build_opts
docker_build_opts=
- if [[ "${IAM_BUILD_PULL_LATEST_IMAGES}" =~ [yY] ]]; then
+ if [[ "${OPENIM_BUILD_PULL_LATEST_IMAGES}" =~ [yY] ]]; then
docker_build_opts='--pull'
fi
@@ -327,12 +338,12 @@ function iam::release::create_docker_images_for_server() {
local docker_file_path="${docker_build_path}/Dockerfile"
local docker_image_tag="${docker_registry}/${binary_name}-${arch}:${docker_tag}"
- iam::log::status "Starting docker build for image: ${binary_name}-${arch}"
+ openim::log::status "Starting docker build for image: ${binary_name}-${arch}"
(
rm -rf "${docker_build_path}"
mkdir -p "${docker_build_path}"
ln "${binary_file_path}" "${docker_build_path}/${binary_name}"
- ln "${IAM_ROOT}/build/nsswitch.conf" "${docker_build_path}/nsswitch.conf"
+ ln "${OPENIM_ROOT}/build/nsswitch.conf" "${docker_build_path}/nsswitch.conf"
chmod 0644 "${docker_build_path}/nsswitch.conf"
cat < "${docker_file_path}"
FROM ${base_image}
@@ -346,9 +357,9 @@ EOF
"${DOCKER[@]}" build ${docker_build_opts:+"${docker_build_opts}"} -q -t "${docker_image_tag}" "${docker_build_path}" >/dev/null
# If we are building an official/alpha/beta release we want to keep
# docker images and tag them appropriately.
- local -r release_docker_image_tag="${IAM_DOCKER_REGISTRY-$docker_registry}/${binary_name}-${arch}:${IAM_DOCKER_IMAGE_TAG-$docker_tag}"
+ local -r release_docker_image_tag="${OPENIM_DOCKER_REGISTRY-$docker_registry}/${binary_name}-${arch}:${OPENIM_DOCKER_IMAGE_TAG-$docker_tag}"
if [[ "${release_docker_image_tag}" != "${docker_image_tag}" ]]; then
- iam::log::status "Tagging docker image ${docker_image_tag} as ${release_docker_image_tag}"
+ openim::log::status "Tagging docker image ${docker_image_tag} as ${release_docker_image_tag}"
"${DOCKER[@]}" rmi "${release_docker_image_tag}" 2>/dev/null || true
"${DOCKER[@]}" tag "${docker_image_tag}" "${release_docker_image_tag}" 2>/dev/null
fi
@@ -357,121 +368,121 @@ EOF
rm -rf "${docker_build_path}"
ln "${binary_file_path}.tar" "${images_dir}/"
- iam::log::status "Deleting docker image ${docker_image_tag}"
+ openim::log::status "Deleting docker image ${docker_image_tag}"
"${DOCKER[@]}" rmi "${docker_image_tag}" &>/dev/null || true
) &
done
- if [[ "${IAM_BUILD_CONFORMANCE}" =~ [yY] ]]; then
- iam::release::build_conformance_image "${arch}" "${docker_registry}" \
+ if [[ "${OPENIM_BUILD_CONFORMANCE}" =~ [yY] ]]; then
+ openim::release::build_conformance_image "${arch}" "${docker_registry}" \
"${docker_tag}" "${images_dir}" &
fi
- iam::util::wait-for-jobs || { iam::log::error "previous Docker build failed"; return 1; }
- iam::log::status "Docker builds done"
+ openim::util::wait-for-jobs || { openim::log::error "previous Docker build failed"; return 1; }
+ openim::log::status "Docker builds done"
)
}
-# This will pack iam-system manifests files for distros such as COS.
-function iam::release::package_iam_manifests_tarball() {
- iam::log::status "Building tarball: manifests"
+# This will pack openim-system manifests files for distros such as COS.
+function openim::release::package_iam_manifests_tarball() {
+ openim::log::status "Building tarball: manifests"
- local src_dir="${IAM_ROOT}/deployments"
+ local src_dir="${OPENIM_ROOT}/deployments"
- local release_stage="${RELEASE_STAGE}/manifests/iam"
+ local release_stage="${RELEASE_STAGE}/manifests/openim"
rm -rf "${release_stage}"
local dst_dir="${release_stage}"
mkdir -p "${dst_dir}"
cp -r ${src_dir}/* "${dst_dir}"
- #cp "${src_dir}/iam-apiserver.yaml" "${dst_dir}"
- #cp "${src_dir}/iam-authz-server.yaml" "${dst_dir}"
- #cp "${src_dir}/iam-pump.yaml" "${dst_dir}"
- #cp "${src_dir}/iam-watcher.yaml" "${dst_dir}"
- #cp "${IAM_ROOT}/cluster/gce/gci/health-monitor.sh" "${dst_dir}/health-monitor.sh"
+ #cp "${src_dir}/openim-apiserver.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-authz-server.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-pump.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-watcher.yaml" "${dst_dir}"
+ #cp "${OPENIM_ROOT}/cluster/gce/gci/health-monitor.sh" "${dst_dir}/health-monitor.sh"
- iam::release::clean_cruft
+ openim::release::clean_cruft
- local package_name="${RELEASE_TARS}/iam-manifests.tar.gz"
- iam::release::create_tarball "${package_name}" "${release_stage}/.."
+ local package_name="${RELEASE_TARS}/openim-manifests.tar.gz"
+ openim::release::create_tarball "${package_name}" "${release_stage}/.."
}
-# This is all the platform-independent stuff you need to run/install iam.
+# This is all the platform-independent stuff you need to run/install openim.
# Arch-specific binaries will need to be downloaded separately (possibly by
-# using the bundled cluster/get-iam-binaries.sh script).
+# using the bundled cluster/get-openim-binaries.sh script).
# Included in this tarball:
# - Cluster spin up/down scripts and configs for various cloud providers
# - Tarballs for manifest configs that are ready to be uploaded
# - Examples (which may or may not still work)
# - The remnants of the docs/ directory
-function iam::release::package_final_tarball() {
- iam::log::status "Building tarball: final"
+function openim::release::package_final_tarball() {
+ openim::log::status "Building tarball: final"
# This isn't a "full" tarball anymore, but the release lib still expects
- # artifacts under "full/iam/"
- local release_stage="${RELEASE_STAGE}/full/iam"
+ # artifacts under "full/openim/"
+ local release_stage="${RELEASE_STAGE}/full/openim"
rm -rf "${release_stage}"
mkdir -p "${release_stage}"
mkdir -p "${release_stage}/client"
cat < "${release_stage}/client/README"
-Client binaries are no longer included in the IAM final tarball.
+Client binaries are no longer included in the OpenIM final tarball.
-Run release/get-iam-binaries.sh to download client and server binaries.
+Run release/get-openim-binaries.sh to download client and server binaries.
EOF
# We want everything in /scripts.
mkdir -p "${release_stage}/release"
- cp -R "${IAM_ROOT}/scripts/release" "${release_stage}/"
- cat < "${release_stage}/release/get-iam-binaries.sh"
+ cp -R "${OPENIM_ROOT}/scripts/release" "${release_stage}/"
+ cat < "${release_stage}/release/get-openim-binaries.sh"
#!/usr/bin/env bash
# Copyright 2020 Lingfei Kong . All rights reserved.
# Use of this source code is governed by a MIT style
# license that can be found in the LICENSE file.
-# This file download iam client and server binaries from tencent cos bucket.
+# This file download openim client and server binaries from tencent cos bucket.
-os=linux arch=amd64 version=${IAM_GIT_VERSION} && wget https://${BUCKET}.cos.${REGION}.myqcloud.com/${COS_RELEASE_DIR}/\$version/{iam-client-\$os-\$arch.tar.gz,iam-server-\$os-\$arch.tar.gz}
+os=linux arch=amd64 version=${OPENIM_GIT_VERSION} && wget https://${BUCKET}.cos.${REGION}.myqcloud.com/${COS_RELEASE_DIR}/\$version/{openim-client-\$os-\$arch.tar.gz,openim-server-\$os-\$arch.tar.gz}
EOF
- chmod +x ${release_stage}/release/get-iam-binaries.sh
+ chmod +x ${release_stage}/release/get-openim-binaries.sh
mkdir -p "${release_stage}/server"
- cp "${RELEASE_TARS}/iam-manifests.tar.gz" "${release_stage}/server/"
+ cp "${RELEASE_TARS}/openim-manifests.tar.gz" "${release_stage}/server/"
cat < "${release_stage}/server/README"
-Server binary tarballs are no longer included in the IAM final tarball.
+Server binary tarballs are no longer included in the OpenIM final tarball.
-Run release/get-iam-binaries.sh to download client and server binaries.
+Run release/get-openim-binaries.sh to download client and server binaries.
EOF
# Include hack/lib as a dependency for the cluster/ scripts
#mkdir -p "${release_stage}/hack"
- #cp -R "${IAM_ROOT}/hack/lib" "${release_stage}/hack/"
+ #cp -R "${OPENIM_ROOT}/hack/lib" "${release_stage}/hack/"
- cp -R ${IAM_ROOT}/{docs,configs,scripts,deployments,init,README.md,LICENSE} "${release_stage}/"
+ cp -R ${OPENIM_ROOT}/{docs,configs,scripts,deployments,init,README.md,LICENSE} "${release_stage}/"
- echo "${IAM_GIT_VERSION}" > "${release_stage}/version"
+ echo "${OPENIM_GIT_VERSION}" > "${release_stage}/version"
- iam::release::clean_cruft
+ openim::release::clean_cruft
local package_name="${RELEASE_TARS}/${ARTIFACT}"
- iam::release::create_tarball "${package_name}" "${release_stage}/.."
+ openim::release::create_tarball "${package_name}" "${release_stage}/.."
}
# Build a release tarball. $1 is the output tar name. $2 is the base directory
# of the files to be packaged. This assumes that ${2}/iamis what is
# being packaged.
-function iam::release::create_tarball() {
- iam::build::ensure_tar
+function openim::release::create_tarball() {
+ openim::build::ensure_tar
local tarfile=$1
local stagingdir=$2
- "${TAR}" czf "${tarfile}" -C "${stagingdir}" iam --owner=0 --group=0
+ "${TAR}" czf "${tarfile}" -C "${stagingdir}" openim --owner=0 --group=0
}
-function iam::release::install_github_release(){
+function openim::release::install_github_release(){
GO111MODULE=on go install github.com/github-release/github-release@latest
}
@@ -480,46 +491,46 @@ function iam::release::install_github_release(){
# - gsemver
# - git-chglog
# - coscmd or coscli
-function iam::release::verify_prereqs(){
+function openim::release::verify_prereqs(){
if [ -z "$(which github-release 2>/dev/null)" ]; then
- iam::log::info "'github-release' tool not installed, try to install it."
+ openim::log::info "'github-release' tool not installed, try to install it."
- if ! iam::release::install_github_release; then
- iam::log::error "failed to install 'github-release'"
+ if ! openim::release::install_github_release; then
+ openim::log::error "failed to install 'github-release'"
return 1
fi
fi
if [ -z "$(which git-chglog 2>/dev/null)" ]; then
- iam::log::info "'git-chglog' tool not installed, try to install it."
+ openim::log::info "'git-chglog' tool not installed, try to install it."
if ! go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest &>/dev/null; then
- iam::log::error "failed to install 'git-chglog'"
+ openim::log::error "failed to install 'git-chglog'"
return 1
fi
fi
if [ -z "$(which gsemver 2>/dev/null)" ]; then
- iam::log::info "'gsemver' tool not installed, try to install it."
+ openim::log::info "'gsemver' tool not installed, try to install it."
if ! go install github.com/arnaud-deprez/gsemver@latest &>/dev/null; then
- iam::log::error "failed to install 'gsemver'"
+ openim::log::error "failed to install 'gsemver'"
return 1
fi
fi
if [ -z "$(which ${COSTOOL} 2>/dev/null)" ]; then
- iam::log::info "${COSTOOL} tool not installed, try to install it."
+ openim::log::info "${COSTOOL} tool not installed, try to install it."
- if ! make -C "${IAM_ROOT}" tools.install.${COSTOOL}; then
- iam::log::error "failed to install ${COSTOOL}"
+ if ! make -C "${OPENIM_ROOT}" tools.install.${COSTOOL}; then
+ openim::log::error "failed to install ${COSTOOL}"
return 1
fi
fi
if [ -z "${TENCENT_SECRET_ID}" -o -z "${TENCENT_SECRET_KEY}" ];then
- iam::log::error "can not find env: TENCENT_SECRET_ID and TENCENT_SECRET_KEY"
+ openim::log::error "can not find env: TENCENT_SECRET_ID and TENCENT_SECRET_KEY"
return 1
fi
@@ -556,42 +567,41 @@ EOF
# Create a github release with specified tarballs.
# NOTICE: Must export 'GITHUB_TOKEN' env in the shell, details:
# https://github.com/github-release/github-release
-function iam::release::github_release() {
+function openim::release::github_release() {
# create a github release
- iam::log::info "create a new github release with tag ${IAM_GIT_VERSION}"
+ openim::log::info "create a new github release with tag ${OPENIM_GIT_VERSION}"
github-release release \
- --user ${IAM_GITHUB_ORG} \
- --repo ${IAM_GITHUB_REPO} \
- --tag ${IAM_GIT_VERSION} \
+ --user ${OPENIM_GITHUB_ORG} \
+ --repo ${OPENIM_GITHUB_REPO} \
+ --tag ${OPENIM_GIT_VERSION} \
--description "" \
--pre-release
- # update iam tarballs
- iam::log::info "upload ${ARTIFACT} to release ${IAM_GIT_VERSION}"
+ # update openim tarballs
+ openim::log::info "upload ${ARTIFACT} to release ${OPENIM_GIT_VERSION}"
github-release upload \
- --user ${IAM_GITHUB_ORG} \
- --repo ${IAM_GITHUB_REPO} \
- --tag ${IAM_GIT_VERSION} \
+ --user ${OPENIM_GITHUB_ORG} \
+ --repo ${OPENIM_GITHUB_REPO} \
+ --tag ${OPENIM_GIT_VERSION} \
--name ${ARTIFACT} \
--file ${RELEASE_TARS}/${ARTIFACT}
- iam::log::info "upload iam-src.tar.gz to release ${IAM_GIT_VERSION}"
+ openim::log::info "upload openim-src.tar.gz to release ${OPENIM_GIT_VERSION}"
github-release upload \
- --user ${IAM_GITHUB_ORG} \
- --repo ${IAM_GITHUB_REPO} \
- --tag ${IAM_GIT_VERSION} \
- --name "iam-src.tar.gz" \
- --file ${RELEASE_TARS}/iam-src.tar.gz
+ --user ${OPENIM_GITHUB_ORG} \
+ --repo ${OPENIM_GITHUB_REPO} \
+ --tag ${OPENIM_GIT_VERSION} \
+ --name "openim-src.tar.gz" \
+ --file ${RELEASE_TARS}/openim-src.tar.gz
}
-function iam::release::generate_changelog() {
- iam::log::info "generate CHANGELOG-${IAM_GIT_VERSION#v}.md and commit it"
+function openim::release::generate_changelog() {
+ openim::log::info "generate CHANGELOG-${OPENIM_GIT_VERSION#v}.md and commit it"
- git-chglog ${IAM_GIT_VERSION} > ${IAM_ROOT}/CHANGELOG/CHANGELOG-${IAM_GIT_VERSION#v}.md
+ git-chglog ${OPENIM_GIT_VERSION} > ${OPENIM_ROOT}/CHANGELOG/CHANGELOG-${OPENIM_GIT_VERSION#v}.md
set +o errexit
- git add ${IAM_ROOT}/CHANGELOG/CHANGELOG-${IAM_GIT_VERSION#v}.md
- git commit -a -m "docs(changelog): add CHANGELOG-${IAM_GIT_VERSION#v}.md"
+ git add ${OPENIM_ROOT}/CHANGELOG/CHANGELOG-${OPENIM_GIT_VERSION#v}.md
+ git commit -a -m "docs(changelog): add CHANGELOG-${OPENIM_GIT_VERSION#v}.md"
git push -f origin master # 最后将 CHANGELOG 也 push 上去
}
-
diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh
index 86c32a69e..2f32dac99 100755
--- a/scripts/lib/util.sh
+++ b/scripts/lib/util.sh
@@ -1,23 +1,33 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-# Copyright 2020 Lingfei Kong . All rights reserved.
-# Use of this source code is governed by a MIT style
-# license that can be found in the LICENSE file.
-function iam::util::sourced_variable {
+function openim::util::sourced_variable {
# Call this function to tell shellcheck that a variable is supposed to
# be used from other calling context. This helps quiet an "unused
# variable" warning from shellcheck and also document your code.
true
}
-iam::util::sortable_date() {
+openim::util::sortable_date() {
date "+%Y%m%d-%H%M%S"
}
# arguments: target, item1, item2, item3, ...
# returns 0 if target is in the given items, 1 otherwise.
-iam::util::array_contains() {
+openim::util::array_contains() {
local search="$1"
local element
shift
@@ -29,7 +39,7 @@ iam::util::array_contains() {
return 1
}
-iam::util::wait_for_url() {
+openim::util::wait_for_url() {
local url=$1
local prefix=${2:-}
local wait=${3:-1}
@@ -37,7 +47,7 @@ iam::util::wait_for_url() {
local maxtime=${5:-1}
command -v curl >/dev/null || {
- iam::log::usage "curl must be installed"
+ openim::log::usage "curl must be installed"
exit 1
}
@@ -45,19 +55,19 @@ iam::util::wait_for_url() {
for i in $(seq 1 "${times}"); do
local out
if out=$(curl --max-time "${maxtime}" -gkfs "${url}" 2>/dev/null); then
- iam::log::status "On try ${i}, ${prefix}: ${out}"
+ openim::log::status "On try ${i}, ${prefix}: ${out}"
return 0
fi
sleep "${wait}"
done
- iam::log::error "Timed out waiting for ${prefix} to answer at ${url}; tried ${times} waiting ${wait} between each"
+ openim::log::error "Timed out waiting for ${prefix} to answer at ${url}; tried ${times} waiting ${wait} between each"
return 1
}
-# Example: iam::util::wait_for_success 120 5 "iamctl get nodes|grep localhost"
+# Example: openim::util::wait_for_success 120 5 "iamctl get nodes|grep localhost"
# arguments: wait time, sleep time, shell command
# returns 0 if the shell command get output, 1 otherwise.
-iam::util::wait_for_success(){
+openim::util::wait_for_success(){
local wait_time="$1"
local sleep_time="$2"
local cmd="$3"
@@ -72,9 +82,9 @@ iam::util::wait_for_success(){
return 1
}
-# Example: iam::util::trap_add 'echo "in trap DEBUG"' DEBUG
+# Example: openim::util::trap_add 'echo "in trap DEBUG"' DEBUG
# See: http://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal
-iam::util::trap_add() {
+openim::util::trap_add() {
local trap_add_cmd
trap_add_cmd=$1
shift
@@ -101,23 +111,23 @@ iam::util::trap_add() {
done
}
-# Opposite of iam::util::ensure-temp-dir()
-iam::util::cleanup-temp-dir() {
- rm -rf "${IAM_TEMP}"
+# Opposite of openim::util::ensure-temp-dir()
+openim::util::cleanup-temp-dir() {
+ rm -rf "${OPENIM_TEMP}"
}
# Create a temp dir that'll be deleted at the end of this bash session.
#
# Vars set:
-# IAM_TEMP
-iam::util::ensure-temp-dir() {
- if [[ -z ${IAM_TEMP-} ]]; then
- IAM_TEMP=$(mktemp -d 2>/dev/null || mktemp -d -t iamrnetes.XXXXXX)
- iam::util::trap_add iam::util::cleanup-temp-dir EXIT
+# OPENIM_TEMP
+openim::util::ensure-temp-dir() {
+ if [[ -z ${OPENIM_TEMP-} ]]; then
+ OPENIM_TEMP=$(mktemp -d 2>/dev/null || mktemp -d -t iamrnetes.XXXXXX)
+ openim::util::trap_add openim::util::cleanup-temp-dir EXIT
fi
}
-iam::util::host_os() {
+openim::util::host_os() {
local host_os
case "$(uname -s)" in
Darwin)
@@ -127,14 +137,14 @@ iam::util::host_os() {
host_os=linux
;;
*)
- iam::log::error "Unsupported host OS. Must be Linux or Mac OS X."
+ openim::log::error "Unsupported host OS. Must be Linux or Mac OS X."
exit 1
;;
esac
echo "${host_os}"
}
-iam::util::host_arch() {
+openim::util::host_arch() {
local host_arch
case "$(uname -m)" in
x86_64*)
@@ -165,7 +175,7 @@ iam::util::host_arch() {
host_arch=ppc64le
;;
*)
- iam::log::error "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x or ppc64le."
+ openim::log::error "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x or ppc64le."
exit 1
;;
esac
@@ -175,20 +185,20 @@ iam::util::host_arch() {
# This figures out the host platform without relying on golang. We need this as
# we don't want a golang install to be a prerequisite to building yet we need
# this info to figure out where the final binaries are placed.
-iam::util::host_platform() {
- echo "$(iam::util::host_os)/$(iam::util::host_arch)"
+openim::util::host_platform() {
+ echo "$(openim::util::host_os)/$(openim::util::host_arch)"
}
# looks for $1 in well-known output locations for the platform ($2)
-# $IAM_ROOT must be set
-iam::util::find-binary-for-platform() {
+# $OPENIM_ROOT must be set
+openim::util::find-binary-for-platform() {
local -r lookfor="$1"
local -r platform="$2"
local locations=(
- "${IAM_ROOT}/_output/bin/${lookfor}"
- "${IAM_ROOT}/_output/${platform}/${lookfor}"
- "${IAM_ROOT}/_output/local/bin/${platform}/${lookfor}"
- "${IAM_ROOT}/_output/platforms/${platform}/${lookfor}"
+ "${OPENIM_ROOT}/_output/bin/${lookfor}"
+ "${OPENIM_ROOT}/_output/${platform}/${lookfor}"
+ "${OPENIM_ROOT}/_output/local/bin/${platform}/${lookfor}"
+ "${OPENIM_ROOT}/_output/platforms/${platform}/${lookfor}"
)
# List most recently-updated location.
@@ -197,42 +207,42 @@ iam::util::find-binary-for-platform() {
}
# looks for $1 in well-known output locations for the host platform
-# $IAM_ROOT must be set
-iam::util::find-binary() {
- iam::util::find-binary-for-platform "$1" "$(iam::util::host_platform)"
+# $OPENIM_ROOT must be set
+openim::util::find-binary() {
+ openim::util::find-binary-for-platform "$1" "$(openim::util::host_platform)"
}
# Run all known doc generators (today gendocs and genman for iamctl)
# $1 is the directory to put those generated documents
-iam::util::gen-docs() {
+openim::util::gen-docs() {
local dest="$1"
# Find binary
- gendocs=$(iam::util::find-binary "gendocs")
- geniamdocs=$(iam::util::find-binary "geniamdocs")
- genman=$(iam::util::find-binary "genman")
- genyaml=$(iam::util::find-binary "genyaml")
- genfeddocs=$(iam::util::find-binary "genfeddocs")
+ gendocs=$(openim::util::find-binary "gendocs")
+ geniamdocs=$(openim::util::find-binary "geniamdocs")
+ genman=$(openim::util::find-binary "genman")
+ genyaml=$(openim::util::find-binary "genyaml")
+ genfeddocs=$(openim::util::find-binary "genfeddocs")
# TODO: If ${genfeddocs} is not used from anywhere (it isn't used at
# least from k/k tree), remove it completely.
- iam::util::sourced_variable "${genfeddocs}"
+ openim::util::sourced_variable "${genfeddocs}"
mkdir -p "${dest}/docs/guide/en-US/cmd/iamctl/"
"${gendocs}" "${dest}/docs/guide/en-US/cmd/iamctl/"
mkdir -p "${dest}/docs/guide/en-US/cmd/"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-apiserver"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-authz-server"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-pump"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-watcher"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-apiserver"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-authz-server"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-pump"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-watcher"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/iamctl" "iamctl"
mkdir -p "${dest}/docs/man/man1/"
- "${genman}" "${dest}/docs/man/man1/" "iam-apiserver"
- "${genman}" "${dest}/docs/man/man1/" "iam-authz-server"
- "${genman}" "${dest}/docs/man/man1/" "iam-pump"
- "${genman}" "${dest}/docs/man/man1/" "iam-watcher"
+ "${genman}" "${dest}/docs/man/man1/" "openim-apiserver"
+ "${genman}" "${dest}/docs/man/man1/" "openim-authz-server"
+ "${genman}" "${dest}/docs/man/man1/" "openim-pump"
+ "${genman}" "${dest}/docs/man/man1/" "openim-watcher"
"${genman}" "${dest}/docs/man/man1/" "iamctl"
mkdir -p "${dest}/docs/guide/en-US/yaml/iamctl/"
@@ -245,14 +255,14 @@ iam::util::gen-docs() {
popd > /dev/null || return 1
}
-# Removes previously generated docs-- we don't want to check them in. $IAM_ROOT
+# Removes previously generated docs-- we don't want to check them in. $OPENIM_ROOT
# must be set.
-iam::util::remove-gen-docs() {
- if [ -e "${IAM_ROOT}/docs/.generated_docs" ]; then
+openim::util::remove-gen-docs() {
+ if [ -e "${OPENIM_ROOT}/docs/.generated_docs" ]; then
# remove all of the old docs; we don't want to check them in.
while read -r file; do
- rm "${IAM_ROOT}/${file}" 2>/dev/null || true
- done <"${IAM_ROOT}/docs/.generated_docs"
+ rm "${OPENIM_ROOT}/${file}" 2>/dev/null || true
+ done <"${OPENIM_ROOT}/docs/.generated_docs"
# The docs/.generated_docs file lists itself, so we don't need to explicitly
# delete it.
fi
@@ -260,15 +270,15 @@ iam::util::remove-gen-docs() {
# Returns the name of the upstream remote repository name for the local git
# repo, e.g. "upstream" or "origin".
-iam::util::git_upstream_remote_name() {
+openim::util::git_upstream_remote_name() {
git remote -v | grep fetch |\
- grep -E 'github.com[/:]marmotedu/iam|marmotedu.io/iam' |\
+ grep -E 'github.com[/:]marmotedu/openim|marmotedu.io/openim' |\
head -n 1 | awk '{print $1}'
}
# Exits script if working directory is dirty. If it's run interactively in the terminal
# the user can commit changes in a second terminal. This script will wait.
-iam::util::ensure_clean_working_dir() {
+openim::util::ensure_clean_working_dir() {
while ! git diff HEAD --exit-code &>/dev/null; do
echo -e "\nUnexpected dirty working directory:\n"
if tty -s; then
@@ -285,7 +295,7 @@ iam::util::ensure_clean_working_dir() {
# Find the base commit using:
# $PULL_BASE_SHA if set (from Prow)
# current ref from the remote upstream branch
-iam::util::base_ref() {
+openim::util::base_ref() {
local -r git_branch=$1
if [[ -n ${PULL_BASE_SHA:-} ]]; then
@@ -293,7 +303,7 @@ iam::util::base_ref() {
return
fi
- full_branch="$(iam::util::git_upstream_remote_name)/${git_branch}"
+ full_branch="$(openim::util::git_upstream_remote_name)/${git_branch}"
# make sure the branch is valid, otherwise the check will pass erroneously.
if ! git describe "${full_branch}" >/dev/null; then
@@ -308,13 +318,13 @@ iam::util::base_ref() {
# current branch and upstream branch named by $1.
# Returns 1 (false) if there are no changes
# 0 (true) if there are changes detected.
-iam::util::has_changes() {
+openim::util::has_changes() {
local -r git_branch=$1
local -r pattern=$2
local -r not_pattern=${3:-totallyimpossiblepattern}
local base_ref
- base_ref=$(iam::util::base_ref "${git_branch}")
+ base_ref=$(openim::util::base_ref "${git_branch}")
echo "Checking for '${pattern}' changes against '${base_ref}'"
# notice this uses ... to find the first shared ancestor
@@ -330,7 +340,7 @@ iam::util::has_changes() {
return 1
}
-iam::util::download_file() {
+openim::util::download_file() {
local -r url=$1
local -r destination_file=$2
@@ -352,7 +362,7 @@ iam::util::download_file() {
# Test whether openssl is installed.
# Sets:
# OPENSSL_BIN: The path to the openssl binary to use
-function iam::util::test_openssl_installed {
+function openim::util::test_openssl_installed {
if ! openssl version >& /dev/null; then
echo "Failed to run openssl. Please ensure openssl is installed"
exit 1
@@ -366,7 +376,7 @@ function iam::util::test_openssl_installed {
# '"client auth"'
# '"server auth"'
# '"client auth","server auth"'
-function iam::util::create_signing_certkey {
+function openim::util::create_signing_certkey {
local sudo=$1
local dest_dir=$2
local id=$3
@@ -380,7 +390,7 @@ EOF
}
# signs a client certificate: args are sudo, dest-dir, CA, filename (roughly), username, groups...
-function iam::util::create_client_certkey {
+function openim::util::create_client_certkey {
local sudo=$1
local dest_dir=$2
local ca=$3
@@ -404,7 +414,7 @@ EOF
}
# signs a serving certificate: args are sudo, dest-dir, ca, filename (roughly), subject, hosts...
-function iam::util::create_serving_certkey {
+function openim::util::create_serving_certkey {
local sudo=$1
local dest_dir=$2
local ca=$3
@@ -428,7 +438,7 @@ EOF
}
# creates a self-contained iamconfig: args are sudo, dest-dir, ca file, host, port, client id, token(optional)
-function iam::util::write_client_iamconfig {
+function openim::util::write_client_iamconfig {
local sudo=$1
local dest_dir=$2
local ca_file=$3
@@ -461,14 +471,14 @@ EOF
# flatten the iamconfig files to make them self contained
username=$(whoami)
${sudo} /usr/bin/env bash -e < "/tmp/${client_id}.iamconfig"
+ $(openim::util::find-binary iamctl) --iamconfig="${dest_dir}/${client_id}.iamconfig" config view --minify --flatten > "/tmp/${client_id}.iamconfig"
mv -f "/tmp/${client_id}.iamconfig" "${dest_dir}/${client_id}.iamconfig"
chown ${username} "${dest_dir}/${client_id}.iamconfig"
EOF
}
# Determines if docker can be run, failures may simply require that the user be added to the docker group.
-function iam::util::ensure_docker_daemon_connectivity {
+function openim::util::ensure_docker_daemon_connectivity {
IFS=" " read -ra DOCKER <<< "${DOCKER_OPTS}"
# Expand ${DOCKER[@]} only if it's not unset. This is to work around
# Bash 3 issue with unbound variable.
@@ -497,7 +507,7 @@ EOF
# Wait for background jobs to finish. Return with
# an error status if any of the jobs failed.
-iam::util::wait-for-jobs() {
+openim::util::wait-for-jobs() {
local fail=0
local job
for job in $(jobs -p); do
@@ -506,12 +516,12 @@ iam::util::wait-for-jobs() {
return ${fail}
}
-# iam::util::join
+# openim::util::join
# Concatenates the list elements with the delimiter passed as first parameter
#
-# Ex: iam::util::join , a b c
+# Ex: openim::util::join , a b c
# -> a,b,c
-function iam::util::join {
+function openim::util::join {
local IFS="$1"
shift
echo "$*"
@@ -527,7 +537,7 @@ function iam::util::join {
# CFSSLJSON_BIN: The path of the installed cfssljson binary
# CFSSLCERTINFO_BIN: The path of the installed cfssl-certinfo binary
#
-function iam::util::ensure-cfssl {
+function openim::util::ensure-cfssl {
if command -v cfssl &>/dev/null && command -v cfssljson &>/dev/null && command -v cfssl-certinfo &>/dev/null; then
CFSSL_BIN=$(command -v cfssl)
CFSSLJSON_BIN=$(command -v cfssljson)
@@ -535,7 +545,7 @@ function iam::util::ensure-cfssl {
return 0
fi
- host_arch=$(iam::util::host_arch)
+ host_arch=$(openim::util::host_arch)
if [[ "${host_arch}" != "amd64" ]]; then
echo "Cannot download cfssl on non-amd64 hosts and cfssl does not appear to be installed."
@@ -588,13 +598,13 @@ function iam::util::ensure-cfssl {
popd > /dev/null || return 1
}
-# iam::util::ensure-gnu-sed
+# openim::util::ensure-gnu-sed
# Determines which sed binary is gnu-sed on linux/darwin
#
# Sets:
# SED: The name of the gnu-sed binary
#
-function iam::util::ensure-gnu-sed {
+function openim::util::ensure-gnu-sed {
# NOTE: the echo below is a workaround to ensure sed is executed before the grep.
# see: https://github.com/iamrnetes/iamrnetes/issues/87251
sed_help="$(LANG=C sed --help 2>&1 || true)"
@@ -603,16 +613,16 @@ function iam::util::ensure-gnu-sed {
elif command -v gsed &>/dev/null; then
SED="gsed"
else
- iam::log::error "Failed to find GNU sed as sed or gsed. If you are on Mac: brew install gnu-sed." >&2
+ openim::log::error "Failed to find GNU sed as sed or gsed. If you are on Mac: brew install gnu-sed." >&2
return 1
fi
- iam::util::sourced_variable "${SED}"
+ openim::util::sourced_variable "${SED}"
}
-# iam::util::check-file-in-alphabetical-order
+# openim::util::check-file-in-alphabetical-order
# Check that the file is in alphabetical order
#
-function iam::util::check-file-in-alphabetical-order {
+function openim::util::check-file-in-alphabetical-order {
local failure_file="$1"
if ! diff -u "${failure_file}" <(LC_ALL=C sort "${failure_file}"); then
{
@@ -626,9 +636,9 @@ function iam::util::check-file-in-alphabetical-order {
fi
}
-# iam::util::require-jq
+# openim::util::require-jq
# Checks whether jq is installed.
-function iam::util::require-jq {
+function openim::util::require-jq {
if ! command -v jq &>/dev/null; then
echo "jq not found. Please install." 1>&2
return 1
@@ -636,7 +646,7 @@ function iam::util::require-jq {
}
# outputs md5 hash of $1, works on macOS and Linux
-function iam::util::md5() {
+function openim::util::md5() {
if which md5 >/dev/null 2>&1; then
md5 -q "$1"
else
@@ -644,7 +654,7 @@ function iam::util::md5() {
fi
}
-# iam::util::read-array
+# openim::util::read-array
# Reads in stdin and adds it line by line to the array provided. This can be
# used instead of "mapfile -t", and is bash 3 compatible.
#
@@ -652,9 +662,9 @@ function iam::util::md5() {
# $1 (name of array to create/modify)
#
# Example usage:
-# iam::util::read-array files < <(ls -1)
+# openim::util::read-array files < <(ls -1)
#
-function iam::util::read-array {
+function openim::util::read-array {
local i=0
unset -v "$1"
while IFS= read -r "$1[i++]"; do :; done
@@ -671,13 +681,13 @@ if [[ -z "${color_start-}" ]]; then
declare -r color_cyan="${color_start}1;36m"
declare -r color_norm="${color_start}0m"
- iam::util::sourced_variable "${color_start}"
- iam::util::sourced_variable "${color_red}"
- iam::util::sourced_variable "${color_yellow}"
- iam::util::sourced_variable "${color_green}"
- iam::util::sourced_variable "${color_blue}"
- iam::util::sourced_variable "${color_cyan}"
- iam::util::sourced_variable "${color_norm}"
+ openim::util::sourced_variable "${color_start}"
+ openim::util::sourced_variable "${color_red}"
+ openim::util::sourced_variable "${color_yellow}"
+ openim::util::sourced_variable "${color_green}"
+ openim::util::sourced_variable "${color_blue}"
+ openim::util::sourced_variable "${color_cyan}"
+ openim::util::sourced_variable "${color_norm}"
fi
# ex: ts=2 sw=2 et filetype=sh
diff --git a/scripts/lib/version.sh b/scripts/lib/version.sh
index 0edeac114..2a59bf63a 100755
--- a/scripts/lib/version.sh
+++ b/scripts/lib/version.sh
@@ -1,29 +1,39 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-# Copyright 2020 Lingfei Kong . All rights reserved.
-# Use of this source code is governed by a MIT style
-# license that can be found in the LICENSE file.
# -----------------------------------------------------------------------------
# Version management helpers. These functions help to set, save and load the
# following variables:
#
-# IAM_GIT_COMMIT - The git commit id corresponding to this
+# OPENIM_GIT_COMMIT - The git commit id corresponding to this
# source code.
-# IAM_GIT_TREE_STATE - "clean" indicates no changes since the git commit id
+# OPENIM_GIT_TREE_STATE - "clean" indicates no changes since the git commit id
# "dirty" indicates source code changes after the git commit id
# "archive" indicates the tree was produced by 'git archive'
-# IAM_GIT_VERSION - "vX.Y" used to indicate the last release version.
-# IAM_GIT_MAJOR - The major part of the version
-# IAM_GIT_MINOR - The minor component of the version
+# OPENIM_GIT_VERSION - "vX.Y" used to indicate the last release version.
+# OPENIM_GIT_MAJOR - The major part of the version
+# OPENIM_GIT_MINOR - The minor component of the version
# Grovels through git to set a set of env variables.
#
-# If IAM_GIT_VERSION_FILE, this function will load from that file instead of
+# If OPENIM_GIT_VERSION_FILE, this function will load from that file instead of
# querying git.
-iam::version::get_version_vars() {
- if [[ -n ${IAM_GIT_VERSION_FILE-} ]]; then
- iam::version::load_version_vars "${IAM_GIT_VERSION_FILE}"
+openim::version::get_version_vars() {
+ if [[ -n ${OPENIM_GIT_VERSION_FILE-} ]]; then
+ openim::version::load_version_vars "${OPENIM_GIT_VERSION_FILE}"
return
fi
@@ -33,30 +43,30 @@ iam::version::get_version_vars() {
# Disabled as we're not expanding these at runtime, but rather expecting
# that another tool may have expanded these and rewritten the source (!)
if [[ '$Format:%%$' == "%" ]]; then
- IAM_GIT_COMMIT='$Format:%H$'
- IAM_GIT_TREE_STATE="archive"
+ OPENIM_GIT_COMMIT='$Format:%H$'
+ OPENIM_GIT_TREE_STATE="archive"
# When a 'git archive' is exported, the '$Format:%D$' below will look
# something like 'HEAD -> release-1.8, tag: v1.8.3' where then 'tag: '
# can be extracted from it.
if [[ '$Format:%D$' =~ tag:\ (v[^ ,]+) ]]; then
- IAM_GIT_VERSION="${BASH_REMATCH[1]}"
+ OPENIM_GIT_VERSION="${BASH_REMATCH[1]}"
fi
fi
- local git=(git --work-tree "${IAM_ROOT}")
+ local git=(git --work-tree "${OPENIM_ROOT}")
- if [[ -n ${IAM_GIT_COMMIT-} ]] || IAM_GIT_COMMIT=$("${git[@]}" rev-parse "HEAD^{commit}" 2>/dev/null); then
- if [[ -z ${IAM_GIT_TREE_STATE-} ]]; then
+ if [[ -n ${OPENIM_GIT_COMMIT-} ]] || OPENIM_GIT_COMMIT=$("${git[@]}" rev-parse "HEAD^{commit}" 2>/dev/null); then
+ if [[ -z ${OPENIM_GIT_TREE_STATE-} ]]; then
# Check if the tree is dirty. default to dirty
if git_status=$("${git[@]}" status --porcelain 2>/dev/null) && [[ -z ${git_status} ]]; then
- IAM_GIT_TREE_STATE="clean"
+ OPENIM_GIT_TREE_STATE="clean"
else
- IAM_GIT_TREE_STATE="dirty"
+ OPENIM_GIT_TREE_STATE="dirty"
fi
fi
# Use git describe to find the version based on tags.
- if [[ -n ${IAM_GIT_VERSION-} ]] || IAM_GIT_VERSION=$("${git[@]}" describe --tags --always --match='v*' 2>/dev/null); then
+ if [[ -n ${OPENIM_GIT_VERSION-} ]] || OPENIM_GIT_VERSION=$("${git[@]}" describe --tags --always --match='v*' 2>/dev/null); then
# This translates the "git describe" to an actual semver.org
# compatible semantic version that looks something like this:
# v1.1.0-alpha.0.6+84c76d1142ea4d
@@ -67,22 +77,22 @@ iam::version::get_version_vars() {
# These regexes are painful enough in sed...
# We don't want to do them in pure shell, so disable SC2001
# shellcheck disable=SC2001
- DASHES_IN_VERSION=$(echo "${IAM_GIT_VERSION}" | sed "s/[^-]//g")
+ DASHES_IN_VERSION=$(echo "${OPENIM_GIT_VERSION}" | sed "s/[^-]//g")
if [[ "${DASHES_IN_VERSION}" == "---" ]] ; then
# shellcheck disable=SC2001
# We have distance to subversion (v1.1.0-subversion-1-gCommitHash)
- IAM_GIT_VERSION=$(echo "${IAM_GIT_VERSION}" | sed "s/-\([0-9]\{1,\}\)-g\([0-9a-f]\{14\}\)$/.\1\+\2/")
+ OPENIM_GIT_VERSION=$(echo "${OPENIM_GIT_VERSION}" | sed "s/-\([0-9]\{1,\}\)-g\([0-9a-f]\{14\}\)$/.\1\+\2/")
elif [[ "${DASHES_IN_VERSION}" == "--" ]] ; then
# shellcheck disable=SC2001
# We have distance to base tag (v1.1.0-1-gCommitHash)
- IAM_GIT_VERSION=$(echo "${IAM_GIT_VERSION}" | sed "s/-g\([0-9a-f]\{14\}\)$/+\1/")
+ OPENIM_GIT_VERSION=$(echo "${OPENIM_GIT_VERSION}" | sed "s/-g\([0-9a-f]\{14\}\)$/+\1/")
fi
- if [[ "${IAM_GIT_TREE_STATE}" == "dirty" ]]; then
+ if [[ "${OPENIM_GIT_TREE_STATE}" == "dirty" ]]; then
# git describe --dirty only considers changes to existing files, but
# that is problematic since new untracked .go files affect the build,
# so use our idea of "dirty" from git status instead.
# TODO?
- #IAM_GIT_VERSION+="-dirty"
+ #OPENIM_GIT_VERSION+="-dirty"
:
fi
@@ -90,17 +100,17 @@ iam::version::get_version_vars() {
# Try to match the "git describe" output to a regex to try to extract
# the "major" and "minor" versions and whether this is the exact tagged
# version or whether the tree is between two tagged versions.
- if [[ "${IAM_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?([-].*)?([+].*)?$ ]]; then
- IAM_GIT_MAJOR=${BASH_REMATCH[1]}
- IAM_GIT_MINOR=${BASH_REMATCH[2]}
+ if [[ "${OPENIM_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?([-].*)?([+].*)?$ ]]; then
+ OPENIM_GIT_MAJOR=${BASH_REMATCH[1]}
+ OPENIM_GIT_MINOR=${BASH_REMATCH[2]}
if [[ -n "${BASH_REMATCH[4]}" ]]; then
- IAM_GIT_MINOR+="+"
+ OPENIM_GIT_MINOR+="+"
fi
fi
- # If IAM_GIT_VERSION is not a valid Semantic Version, then refuse to build.
- if ! [[ "${IAM_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
- echo "IAM_GIT_VERSION should be a valid Semantic Version. Current value: ${IAM_GIT_VERSION}"
+ # If OPENIM_GIT_VERSION is not a valid Semantic Version, then refuse to build.
+ if ! [[ "${OPENIM_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
+ echo "OPENIM_GIT_VERSION should be a valid Semantic Version. Current value: ${OPENIM_GIT_VERSION}"
echo "Please see more details here: https://semver.org"
exit 1
fi
@@ -109,27 +119,27 @@ iam::version::get_version_vars() {
}
# Saves the environment flags to $1
-iam::version::save_version_vars() {
+openim::version::save_version_vars() {
local version_file=${1-}
[[ -n ${version_file} ]] || {
- echo "!!! Internal error. No file specified in iam::version::save_version_vars"
+ echo "!!! Internal error. No file specified in openim::version::save_version_vars"
return 1
}
cat <"${version_file}"
-IAM_GIT_COMMIT='${IAM_GIT_COMMIT-}'
-IAM_GIT_TREE_STATE='${IAM_GIT_TREE_STATE-}'
-IAM_GIT_VERSION='${IAM_GIT_VERSION-}'
-IAM_GIT_MAJOR='${IAM_GIT_MAJOR-}'
-IAM_GIT_MINOR='${IAM_GIT_MINOR-}'
+OPENIM_GIT_COMMIT='${OPENIM_GIT_COMMIT-}'
+OPENIM_GIT_TREE_STATE='${OPENIM_GIT_TREE_STATE-}'
+OPENIM_GIT_VERSION='${OPENIM_GIT_VERSION-}'
+OPENIM_GIT_MAJOR='${OPENIM_GIT_MAJOR-}'
+OPENIM_GIT_MINOR='${OPENIM_GIT_MINOR-}'
EOF
}
# Loads up the version variables from file $1
-iam::version::load_version_vars() {
+openim::version::load_version_vars() {
local version_file=${1-}
[[ -n ${version_file} ]] || {
- echo "!!! Internal error. No file specified in iam::version::load_version_vars"
+ echo "!!! Internal error. No file specified in openim::version::load_version_vars"
return 1
}
diff --git a/scripts/make-rules/gen.mk b/scripts/make-rules/gen.mk
index a0d44befa..8306c1756 100644
--- a/scripts/make-rules/gen.mk
+++ b/scripts/make-rules/gen.mk
@@ -31,7 +31,7 @@ gen.errcode: gen.errcode.code gen.errcode.doc
.PHONY: gen.errcode.code
gen.errcode.code: tools.verify.codegen
- @echo "===========> Generating iam error code go source files"
+ @echo "===========> Generating openim error code go source files"
@codegen -type=int ${ROOT_DIR}/internal/pkg/code
.PHONY: gen.errcode.doc
@@ -44,7 +44,7 @@ gen.errcode.doc: tools.verify.codegen
gen.ca.%:
$(eval CA := $(word 1,$(subst ., ,$*)))
@echo "===========> Generating CA files for $(CA)"
- @${ROOT_DIR}/scripts/gencerts.sh generate-iam-cert $(OUTPUT_DIR)/cert $(CA)
+ @${ROOT_DIR}/scripts/gencerts.sh generate-openim-cert $(OUTPUT_DIR)/cert $(CA)
.PHONY: gen.ca
gen.ca: $(addprefix gen.ca., $(CERTIFICATES))
diff --git a/scripts/make-rules/tools.mk b/scripts/make-rules/tools.mk
index f91ef2231..c0e65ff94 100644
--- a/scripts/make-rules/tools.mk
+++ b/scripts/make-rules/tools.mk
@@ -189,7 +189,7 @@ install.protoc-gen-go:
## install.cfssl: Install cfssl, used to generate certificates
.PHONY: install.cfssl
install.cfssl:
- @$(ROOT_DIR)/scripts/install/install.sh iam::install::install_cfssl
+ @$(ROOT_DIR)/scripts/install/install.sh openim::install::install_cfssl
## install.depth: Install depth, used to check dependency tree
.PHONY: install.depth
diff --git a/scripts/mongo-init.sh b/scripts/mongo-init.sh
index 3d1faa60b..07d0e3d03 100755
--- a/scripts/mongo-init.sh
+++ b/scripts/mongo-init.sh
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
mongo -- "$MONGO_INITDB_DATABASE" <
Date: Tue, 4 Jul 2023 11:44:47 +0800
Subject: [PATCH 10/73] fix: fix scripts
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/githooks/commit-msg | 3 ++-
scripts/lib/init.sh | 1 -
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/githooks/commit-msg b/scripts/githooks/commit-msg
index 66b40d016..bf00bfc31 100644
--- a/scripts/githooks/commit-msg
+++ b/scripts/githooks/commit-msg
@@ -56,7 +56,8 @@ test "" = "$(grep '^Signed-off-by: ' "$1" |
}
# TODO: go-gitlint dir set
-GITLINT_DIR="./_output/tools/go-gitlint"
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
+GITLINT_DIR="$OPENIM_ROOT/_output/tools/go-gitlint"
$GITLINT_DIR \
--msg-file=$1 \
diff --git a/scripts/lib/init.sh b/scripts/lib/init.sh
index edaca357d..294696087 100755
--- a/scripts/lib/init.sh
+++ b/scripts/lib/init.sh
@@ -19,7 +19,6 @@ set +o nounset
set -o pipefail
# Unset CDPATH so that path interpolation can work correctly
-# https://github.com/iamrnetes/iamrnetes/issues/52255
unset CDPATH
# Default use go modules
From 2dcbfde3bff3834fd01adcf0f0cc42d0f8c806e6 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 12:16:42 +0800
Subject: [PATCH 11/73] test: add chmod file in scripts
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/coverage.awk | 0
scripts/coverage.sh | 0
scripts/ensure_tag.sh | 0
scripts/release.sh | 0
4 files changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 scripts/coverage.awk
mode change 100644 => 100755 scripts/coverage.sh
mode change 100644 => 100755 scripts/ensure_tag.sh
mode change 100644 => 100755 scripts/release.sh
diff --git a/scripts/coverage.awk b/scripts/coverage.awk
old mode 100644
new mode 100755
diff --git a/scripts/coverage.sh b/scripts/coverage.sh
old mode 100644
new mode 100755
diff --git a/scripts/ensure_tag.sh b/scripts/ensure_tag.sh
old mode 100644
new mode 100755
diff --git a/scripts/release.sh b/scripts/release.sh
old mode 100644
new mode 100755
From edcb065636483af9126f51a145ebc00d5e381576 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 12:29:31 +0800
Subject: [PATCH 12/73] feat: add common scripts
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/common.sh | 493 +++++++++++++++++++++++++++++++++++++++++
scripts/lib/version.sh | 2 +-
2 files changed, 494 insertions(+), 1 deletion(-)
create mode 100755 scripts/common.sh
diff --git a/scripts/common.sh b/scripts/common.sh
new file mode 100755
index 000000000..a254412de
--- /dev/null
+++ b/scripts/common.sh
@@ -0,0 +1,493 @@
+#!/usr/bin/env bash
+
+# shellcheck disable=SC2034 # Variables sourced in other scripts.
+
+# Common utilities, variables and checks for all build scripts.
+set -o errexit
+set -o nounset
+set -o pipefail
+
+# Unset CDPATH, having it set messes up with script import paths
+unset CDPATH
+
+USER_ID=$(id -u)
+GROUP_ID=$(id -g)
+
+DOCKER_OPTS=${DOCKER_OPTS:-""}
+IFS=" " read -r -a DOCKER <<< "docker ${DOCKER_OPTS}"
+DOCKER_HOST=${DOCKER_HOST:-""}
+DOCKER_MACHINE_NAME=${DOCKER_MACHINE_NAME:-"openim-dev"}
+readonly DOCKER_MACHINE_DRIVER=${DOCKER_MACHINE_DRIVER:-"virtualbox --virtualbox-cpu-count -1"}
+
+# This will canonicalize the path
+OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd -P)
+
+source "${OPENIM_ROOT}/scripts/lib/init.sh"
+
+# Constants
+readonly OPENIM_BUILD_IMAGE_REPO=openim-build
+#readonly OPENIM_BUILD_IMAGE_CROSS_TAG="$(cat "${OPENIM_ROOT}/build/build-image/cross/VERSION")"
+
+readonly OPENIM_DOCKER_REGISTRY="${OPENIM_DOCKER_REGISTRY:-k8s.gcr.io}"
+readonly OPENIM_BASE_IMAGE_REGISTRY="${OPENIM_BASE_IMAGE_REGISTRY:-us.gcr.io/k8s-artifacts-prod/build-image}"
+
+# This version number is used to cause everyone to rebuild their data containers
+# and build image. This is especially useful for automated build systems like
+# Jenkins.
+#
+# Increment/change this number if you change the build image (anything under
+# build/build-image) or change the set of volumes in the data container.
+#readonly OPENIM_BUILD_IMAGE_VERSION_BASE="$(cat "${OPENIM_ROOT}/build/build-image/VERSION")"
+#readonly OPENIM_BUILD_IMAGE_VERSION="${OPENIM_BUILD_IMAGE_VERSION_BASE}-${OPENIM_BUILD_IMAGE_CROSS_TAG}"
+
+# Here we map the output directories across both the local and remote _output
+# directories:
+#
+# *_OUTPUT_ROOT - the base of all output in that environment.
+# *_OUTPUT_SUBPATH - location where golang stuff is built/cached. Also
+# persisted across docker runs with a volume mount.
+# *_OUTPUT_BINPATH - location where final binaries are placed. If the remote
+# is really remote, this is the stuff that has to be copied
+# back.
+# OUT_DIR can come in from the Makefile, so honor it.
+readonly LOCAL_OUTPUT_ROOT="${OPENIM_ROOT}/${OUT_DIR:-_output}"
+readonly LOCAL_OUTPUT_SUBPATH="${LOCAL_OUTPUT_ROOT}/platforms"
+readonly LOCAL_OUTPUT_BINPATH="${LOCAL_OUTPUT_SUBPATH}"
+readonly LOCAL_OUTPUT_GOPATH="${LOCAL_OUTPUT_SUBPATH}/go"
+readonly LOCAL_OUTPUT_IMAGE_STAGING="${LOCAL_OUTPUT_ROOT}/images"
+
+# This is the port on the workstation host to expose RSYNC on. Set this if you
+# are doing something fancy with ssh tunneling.
+readonly OPENIM_RSYNC_PORT="${OPENIM_RSYNC_PORT:-}"
+
+# This is the port that rsync is running on *inside* the container. This may be
+# mapped to OPENIM_RSYNC_PORT via docker networking.
+readonly OPENIM_CONTAINER_RSYNC_PORT=8730
+
+# Get the set of master binaries that run in Docker (on Linux)
+# Entry format is ",".
+# Binaries are placed in /usr/local/bin inside the image.
+#
+# $1 - server architecture
+openim::build::get_docker_wrapped_binaries() {
+ local arch=$1
+ local debian_base_version=v2.1.0
+ local debian_iptables_version=v12.1.0
+ ### If you change any of these lists, please also update DOCKERIZED_BINARIES
+ ### in build/BUILD. And openim::golang::server_image_targets
+ local targets=(
+ "openim-apiserver,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-controller-manager,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-scheduler,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-proxy,${OPENIM_BASE_IMAGE_REGISTRY}/debian-iptables-${arch}:${debian_iptables_version}"
+ )
+
+ echo "${targets[@]}"
+}
+
+# ---------------------------------------------------------------------------
+# Basic setup functions
+
+# Verify that the right utilities and such are installed for building openim. Set
+# up some dynamic constants.
+# Args:
+# $1 - boolean of whether to require functioning docker (default true)
+#
+# Vars set:
+# OPENIM_ROOT_HASH
+# OPENIM_BUILD_IMAGE_TAG_BASE
+# OPENIM_BUILD_IMAGE_TAG
+# OPENIM_BUILD_IMAGE
+# OPENIM_BUILD_CONTAINER_NAME_BASE
+# OPENIM_BUILD_CONTAINER_NAME
+# OPENIM_DATA_CONTAINER_NAME_BASE
+# OPENIM_DATA_CONTAINER_NAME
+# OPENIM_RSYNC_CONTAINER_NAME_BASE
+# OPENIM_RSYNC_CONTAINER_NAME
+# DOCKER_MOUNT_ARGS
+# LOCAL_OUTPUT_BUILD_CONTEXT
+function openim::build::verify_prereqs() {
+ local -r require_docker=${1:-true}
+ openim::log::status "Verifying Prerequisites...."
+ openim::build::ensure_tar || return 1
+ openim::build::ensure_rsync || return 1
+ if ${require_docker}; then
+ openim::build::ensure_docker_in_path || return 1
+ openim::util::ensure_docker_daemon_connectivity || return 1
+
+ if (( OPENIM_VERBOSE > 6 )); then
+ openim::log::status "Docker Version:"
+ "${DOCKER[@]}" version | openim::log::info_from_stdin
+ fi
+ fi
+
+ OPENIM_GIT_BRANCH=$(git symbolic-ref --short -q HEAD 2>/dev/null || true)
+ OPENIM_ROOT_HASH=$(openim::build::short_hash "${HOSTNAME:-}:${OPENIM_ROOT}:${OPENIM_GIT_BRANCH}")
+ OPENIM_BUILD_IMAGE_TAG_BASE="build-${OPENIM_ROOT_HASH}"
+ #OPENIM_BUILD_IMAGE_TAG="${OPENIM_BUILD_IMAGE_TAG_BASE}-${OPENIM_BUILD_IMAGE_VERSION}"
+ #OPENIM_BUILD_IMAGE="${OPENIM_BUILD_IMAGE_REPO}:${OPENIM_BUILD_IMAGE_TAG}"
+ OPENIM_BUILD_CONTAINER_NAME_BASE="openim-build-${OPENIM_ROOT_HASH}"
+ #OPENIM_BUILD_CONTAINER_NAME="${OPENIM_BUILD_CONTAINER_NAME_BASE}-${OPENIM_BUILD_IMAGE_VERSION}"
+ OPENIM_RSYNC_CONTAINER_NAME_BASE="openim-rsync-${OPENIM_ROOT_HASH}"
+ #OPENIM_RSYNC_CONTAINER_NAME="${OPENIM_RSYNC_CONTAINER_NAME_BASE}-${OPENIM_BUILD_IMAGE_VERSION}"
+ OPENIM_DATA_CONTAINER_NAME_BASE="openim-build-data-${OPENIM_ROOT_HASH}"
+ #OPENIM_DATA_CONTAINER_NAME="${OPENIM_DATA_CONTAINER_NAME_BASE}-${OPENIM_BUILD_IMAGE_VERSION}"
+ #DOCKER_MOUNT_ARGS=(--volumes-from "${OPENIM_DATA_CONTAINER_NAME}")
+ #LOCAL_OUTPUT_BUILD_CONTEXT="${LOCAL_OUTPUT_IMAGE_STAGING}/${OPENIM_BUILD_IMAGE}"
+
+ openim::version::get_version_vars
+ #openim::version::save_version_vars "${OPENIM_ROOT}/.dockerized-openim-version-defs"
+}
+
+# ---------------------------------------------------------------------------
+# Utility functions
+
+function openim::build::docker_available_on_osx() {
+ if [[ -z "${DOCKER_HOST}" ]]; then
+ if [[ -S "/var/run/docker.sock" ]]; then
+ openim::log::status "Using Docker for MacOS"
+ return 0
+ fi
+
+ openim::log::status "No docker host is set. Checking options for setting one..."
+ if [[ -z "$(which docker-machine)" ]]; then
+ openim::log::status "It looks like you're running Mac OS X, yet neither Docker for Mac nor docker-machine can be found."
+ openim::log::status "See: https://docs.docker.com/engine/installation/mac/ for installation instructions."
+ return 1
+ elif [[ -n "$(which docker-machine)" ]]; then
+ openim::build::prepare_docker_machine
+ fi
+ fi
+}
+
+function openim::build::prepare_docker_machine() {
+ openim::log::status "docker-machine was found."
+
+ local available_memory_bytes
+ available_memory_bytes=$(sysctl -n hw.memsize 2>/dev/null)
+
+ local bytes_in_mb=1048576
+
+ # Give virtualbox 1/2 the system memory. Its necessary to divide by 2, instead
+ # of multiple by .5, because bash can only multiply by ints.
+ local memory_divisor=2
+
+ local virtualbox_memory_mb=$(( available_memory_bytes / (bytes_in_mb * memory_divisor) ))
+
+ docker-machine inspect "${DOCKER_MACHINE_NAME}" &> /dev/null || {
+ openim::log::status "Creating a machine to build IAM"
+ docker-machine create --driver "${DOCKER_MACHINE_DRIVER}" \
+ --virtualbox-memory "${virtualbox_memory_mb}" \
+ --engine-env HTTP_PROXY="${IAMRNETES_HTTP_PROXY:-}" \
+ --engine-env HTTPS_PROXY="${IAMRNETES_HTTPS_PROXY:-}" \
+ --engine-env NO_PROXY="${IAMRNETES_NO_PROXY:-127.0.0.1}" \
+ "${DOCKER_MACHINE_NAME}" > /dev/null || {
+ openim::log::error "Something went wrong creating a machine."
+ openim::log::error "Try the following: "
+ openim::log::error "docker-machine create -d ${DOCKER_MACHINE_DRIVER} --virtualbox-memory ${virtualbox_memory_mb} ${DOCKER_MACHINE_NAME}"
+ return 1
+ }
+ }
+ docker-machine start "${DOCKER_MACHINE_NAME}" &> /dev/null
+ # it takes `docker-machine env` a few seconds to work if the machine was just started
+ local docker_machine_out
+ while ! docker_machine_out=$(docker-machine env "${DOCKER_MACHINE_NAME}" 2>&1); do
+ if [[ ${docker_machine_out} =~ "Error checking TLS connection" ]]; then
+ echo "${docker_machine_out}"
+ docker-machine regenerate-certs "${DOCKER_MACHINE_NAME}"
+ else
+ sleep 1
+ fi
+ done
+ eval "$(docker-machine env "${DOCKER_MACHINE_NAME}")"
+ openim::log::status "A Docker host using docker-machine named '${DOCKER_MACHINE_NAME}' is ready to go!"
+ return 0
+}
+
+function openim::build::is_gnu_sed() {
+ [[ $(sed --version 2>&1) == *GNU* ]]
+}
+
+function openim::build::ensure_rsync() {
+ if [[ -z "$(which rsync)" ]]; then
+ openim::log::error "Can't find 'rsync' in PATH, please fix and retry."
+ return 1
+ fi
+}
+
+function openim::build::update_dockerfile() {
+ if openim::build::is_gnu_sed; then
+ sed_opts=(-i)
+ else
+ sed_opts=(-i '')
+ fi
+ sed "${sed_opts[@]}" "s/OPENIM_BUILD_IMAGE_CROSS_TAG/${OPENIM_BUILD_IMAGE_CROSS_TAG}/" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
+}
+
+function openim::build::set_proxy() {
+ if [[ -n "${IAMRNETES_HTTPS_PROXY:-}" ]]; then
+ echo "ENV https_proxy $IAMRNETES_HTTPS_PROXY" >> "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
+ fi
+ if [[ -n "${IAMRNETES_HTTP_PROXY:-}" ]]; then
+ echo "ENV http_proxy $IAMRNETES_HTTP_PROXY" >> "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
+ fi
+ if [[ -n "${IAMRNETES_NO_PROXY:-}" ]]; then
+ echo "ENV no_proxy $IAMRNETES_NO_PROXY" >> "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
+ fi
+}
+
+function openim::build::ensure_docker_in_path() {
+ if [[ -z "$(which docker)" ]]; then
+ openim::log::error "Can't find 'docker' in PATH, please fix and retry."
+ openim::log::error "See https://docs.docker.com/installation/#installation for installation instructions."
+ return 1
+ fi
+}
+
+function openim::build::ensure_tar() {
+ if [[ -n "${TAR:-}" ]]; then
+ return
+ fi
+
+ # Find gnu tar if it is available, bomb out if not.
+ TAR=tar
+ if which gtar &>/dev/null; then
+ TAR=gtar
+ else
+ if which gnutar &>/dev/null; then
+ TAR=gnutar
+ fi
+ fi
+ if ! "${TAR}" --version | grep -q GNU; then
+ echo " !!! Cannot find GNU tar. Build on Linux or install GNU tar"
+ echo " on Mac OS X (brew install gnu-tar)."
+ return 1
+ fi
+}
+
+function openim::build::has_docker() {
+ which docker &> /dev/null
+}
+
+function openim::build::has_ip() {
+ which ip &> /dev/null && ip -Version | grep 'iproute2' &> /dev/null
+}
+
+# Detect if a specific image exists
+#
+# $1 - image repo name
+# $2 - image tag
+function openim::build::docker_image_exists() {
+ [[ -n $1 && -n $2 ]] || {
+ openim::log::error "Internal error. Image not specified in docker_image_exists."
+ exit 2
+ }
+
+ [[ $("${DOCKER[@]}" images -q "${1}:${2}") ]]
+}
+
+# Delete all images that match a tag prefix except for the "current" version
+#
+# $1: The image repo/name
+# $2: The tag base. We consider any image that matches $2*
+# $3: The current image not to delete if provided
+function openim::build::docker_delete_old_images() {
+ # In Docker 1.12, we can replace this with
+ # docker images "$1" --format "{{.Tag}}"
+ for tag in $("${DOCKER[@]}" images "${1}" | tail -n +2 | awk '{print $2}') ; do
+ if [[ "${tag}" != "${2}"* ]] ; then
+ V=3 openim::log::status "Keeping image ${1}:${tag}"
+ continue
+ fi
+
+ if [[ -z "${3:-}" || "${tag}" != "${3}" ]] ; then
+ V=2 openim::log::status "Deleting image ${1}:${tag}"
+ "${DOCKER[@]}" rmi "${1}:${tag}" >/dev/null
+ else
+ V=3 openim::log::status "Keeping image ${1}:${tag}"
+ fi
+ done
+}
+
+# Stop and delete all containers that match a pattern
+#
+# $1: The base container prefix
+# $2: The current container to keep, if provided
+function openim::build::docker_delete_old_containers() {
+ # In Docker 1.12 we can replace this line with
+ # docker ps -a --format="{{.Names}}"
+ for container in $("${DOCKER[@]}" ps -a | tail -n +2 | awk '{print $NF}') ; do
+ if [[ "${container}" != "${1}"* ]] ; then
+ V=3 openim::log::status "Keeping container ${container}"
+ continue
+ fi
+ if [[ -z "${2:-}" || "${container}" != "${2}" ]] ; then
+ V=2 openim::log::status "Deleting container ${container}"
+ openim::build::destroy_container "${container}"
+ else
+ V=3 openim::log::status "Keeping container ${container}"
+ fi
+ done
+}
+
+# Takes $1 and computes a short has for it. Useful for unique tag generation
+function openim::build::short_hash() {
+ [[ $# -eq 1 ]] || {
+ openim::log::error "Internal error. No data based to short_hash."
+ exit 2
+ }
+
+ local short_hash
+ if which md5 >/dev/null 2>&1; then
+ short_hash=$(md5 -q -s "$1")
+ else
+ short_hash=$(echo -n "$1" | md5sum)
+ fi
+ echo "${short_hash:0:10}"
+}
+
+# Pedantically kill, wait-on and remove a container. The -f -v options
+# to rm don't actually seem to get the job done, so force kill the
+# container, wait to ensure it's stopped, then try the remove. This is
+# a workaround for bug https://github.com/docker/docker/issues/3968.
+function openim::build::destroy_container() {
+ "${DOCKER[@]}" kill "$1" >/dev/null 2>&1 || true
+ if [[ $("${DOCKER[@]}" version --format '{{.Server.Version}}') = 17.06.0* ]]; then
+ # Workaround https://github.com/moby/moby/issues/33948.
+ # TODO: remove when 17.06.0 is not relevant anymore
+ DOCKER_API_VERSION=v1.29 "${DOCKER[@]}" wait "$1" >/dev/null 2>&1 || true
+ else
+ "${DOCKER[@]}" wait "$1" >/dev/null 2>&1 || true
+ fi
+ "${DOCKER[@]}" rm -f -v "$1" >/dev/null 2>&1 || true
+}
+
+# ---------------------------------------------------------------------------
+# Building
+
+
+function openim::build::clean() {
+ if openim::build::has_docker ; then
+ openim::build::docker_delete_old_containers "${OPENIM_BUILD_CONTAINER_NAME_BASE}"
+ openim::build::docker_delete_old_containers "${OPENIM_RSYNC_CONTAINER_NAME_BASE}"
+ openim::build::docker_delete_old_containers "${OPENIM_DATA_CONTAINER_NAME_BASE}"
+ openim::build::docker_delete_old_images "${OPENIM_BUILD_IMAGE_REPO}" "${OPENIM_BUILD_IMAGE_TAG_BASE}"
+
+ V=2 openim::log::status "Cleaning all untagged docker images"
+ "${DOCKER[@]}" rmi "$("${DOCKER[@]}" images -q --filter 'dangling=true')" 2> /dev/null || true
+ fi
+
+ if [[ -d "${LOCAL_OUTPUT_ROOT}" ]]; then
+ openim::log::status "Removing _output directory"
+ rm -rf "${LOCAL_OUTPUT_ROOT}"
+ fi
+}
+
+# Set up the context directory for the openim-build image and build it.
+function openim::build::build_image() {
+ mkdir -p "${LOCAL_OUTPUT_BUILD_CONTEXT}"
+ # Make sure the context directory owned by the right user for syncing sources to container.
+ chown -R "${USER_ID}":"${GROUP_ID}" "${LOCAL_OUTPUT_BUILD_CONTEXT}"
+
+ cp /etc/localtime "${LOCAL_OUTPUT_BUILD_CONTEXT}/"
+
+ cp "${OPENIM_ROOT}/build/build-image/Dockerfile" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
+ cp "${OPENIM_ROOT}/build/build-image/rsyncd.sh" "${LOCAL_OUTPUT_BUILD_CONTEXT}/"
+ dd if=/dev/urandom bs=512 count=1 2>/dev/null | LC_ALL=C tr -dc 'A-Za-z0-9' | dd bs=32 count=1 2>/dev/null > "${LOCAL_OUTPUT_BUILD_CONTEXT}/rsyncd.password"
+ chmod go= "${LOCAL_OUTPUT_BUILD_CONTEXT}/rsyncd.password"
+
+ openim::build::update_dockerfile
+ openim::build::set_proxy
+ openim::build::docker_build "${OPENIM_BUILD_IMAGE}" "${LOCAL_OUTPUT_BUILD_CONTEXT}" 'false'
+
+ # Clean up old versions of everything
+ openim::build::docker_delete_old_containers "${OPENIM_BUILD_CONTAINER_NAME_BASE}" "${OPENIM_BUILD_CONTAINER_NAME}"
+ openim::build::docker_delete_old_containers "${OPENIM_RSYNC_CONTAINER_NAME_BASE}" "${OPENIM_RSYNC_CONTAINER_NAME}"
+ openim::build::docker_delete_old_containers "${OPENIM_DATA_CONTAINER_NAME_BASE}" "${OPENIM_DATA_CONTAINER_NAME}"
+ openim::build::docker_delete_old_images "${OPENIM_BUILD_IMAGE_REPO}" "${OPENIM_BUILD_IMAGE_TAG_BASE}" "${OPENIM_BUILD_IMAGE_TAG}"
+
+ openim::build::ensure_data_container
+ openim::build::sync_to_container
+}
+
+# Build a docker image from a Dockerfile.
+# $1 is the name of the image to build
+# $2 is the location of the "context" directory, with the Dockerfile at the root.
+# $3 is the value to set the --pull flag for docker build; true by default
+function openim::build::docker_build() {
+ local -r image=$1
+ local -r context_dir=$2
+ local -r pull="${3:-true}"
+ local -ra build_cmd=("${DOCKER[@]}" build -t "${image}" "--pull=${pull}" "${context_dir}")
+
+ openim::log::status "Building Docker image ${image}"
+ local docker_output
+ docker_output=$("${build_cmd[@]}" 2>&1) || {
+ cat <&2
++++ Docker build command failed for ${image}
+
+${docker_output}
+
+To retry manually, run:
+
+${build_cmd[*]}
+
+EOF
+ return 1
+ }
+}
+
+function openim::build::ensure_data_container() {
+ # If the data container exists AND exited successfully, we can use it.
+ # Otherwise nuke it and start over.
+ local ret=0
+ local code=0
+
+ code=$(docker inspect \
+ -f '{{.State.ExitCode}}' \
+ "${OPENIM_DATA_CONTAINER_NAME}" 2>/dev/null) || ret=$?
+ if [[ "${ret}" == 0 && "${code}" != 0 ]]; then
+ openim::build::destroy_container "${OPENIM_DATA_CONTAINER_NAME}"
+ ret=1
+ fi
+ if [[ "${ret}" != 0 ]]; then
+ openim::log::status "Creating data container ${OPENIM_DATA_CONTAINER_NAME}"
+ # We have to ensure the directory exists, or else the docker run will
+ # create it as root.
+ mkdir -p "${LOCAL_OUTPUT_GOPATH}"
+ # We want this to run as root to be able to chown, so non-root users can
+ # later use the result as a data container. This run both creates the data
+ # container and chowns the GOPATH.
+ #
+ # The data container creates volumes for all of the directories that store
+ # intermediates for the Go build. This enables incremental builds across
+ # Docker sessions. The *_cgo paths are re-compiled versions of the go std
+ # libraries for true static building.
+ local -ra docker_cmd=(
+ "${DOCKER[@]}" run
+ --volume "${REMOTE_ROOT}" # white-out the whole output dir
+ --volume /usr/local/go/pkg/linux_386_cgo
+ --volume /usr/local/go/pkg/linux_amd64_cgo
+ --volume /usr/local/go/pkg/linux_arm_cgo
+ --volume /usr/local/go/pkg/linux_arm64_cgo
+ --volume /usr/local/go/pkg/linux_ppc64le_cgo
+ --volume /usr/local/go/pkg/darwin_amd64_cgo
+ --volume /usr/local/go/pkg/darwin_386_cgo
+ --volume /usr/local/go/pkg/windows_amd64_cgo
+ --volume /usr/local/go/pkg/windows_386_cgo
+ --name "${OPENIM_DATA_CONTAINER_NAME}"
+ --hostname "${HOSTNAME}"
+ "${OPENIM_BUILD_IMAGE}"
+ chown -R "${USER_ID}":"${GROUP_ID}"
+ "${REMOTE_ROOT}"
+ /usr/local/go/pkg/
+ )
+ "${docker_cmd[@]}"
+ fi
+}
+
+# Build all openim commands.
+function openim::build::build_command() {
+ openim::log::status "Running build command..."
+ make -C "${OPENIM_ROOT}" build.multiarch BINS="openimctl openim-apiserver openim-authz-server openim-pump openim-watcher"
+}
diff --git a/scripts/lib/version.sh b/scripts/lib/version.sh
index 2a59bf63a..9e3e055fd 100755
--- a/scripts/lib/version.sh
+++ b/scripts/lib/version.sh
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
+
# -----------------------------------------------------------------------------
# Version management helpers. These functions help to set, save and load the
# following variables:
From 4d8fafe029380af09f1bdf7b88b4c134ee5ea81b Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 14:26:24 +0800
Subject: [PATCH 13/73] feat: add release
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
Makefile | 5 +++++
scripts/coverage.sh | 2 --
scripts/ensure_tag.sh | 1 +
scripts/lib/version.sh | 1 -
scripts/make-rules/release.mk | 4 ++--
5 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 8e697535e..c210edbe3 100644
--- a/Makefile
+++ b/Makefile
@@ -158,6 +158,11 @@ verify-copyright:
add-copyright:
@$(MAKE) copyright.add
+## release: release the project
+.PHONY: release
+release: release.verify release.ensure-tag
+ @scripts/release.sh
+
## help: Show this help info.
.PHONY: help
help: Makefile
diff --git a/scripts/coverage.sh b/scripts/coverage.sh
index d4605ee3f..fbb2b36fc 100755
--- a/scripts/coverage.sh
+++ b/scripts/coverage.sh
@@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
# http://stackoverflow.com/a/21142256/2055281
echo "mode: atomic" > coverage.txt
@@ -27,4 +26,3 @@ for d in $(find ./* -maxdepth 10 -type d); do
fi
fi
done
-
diff --git a/scripts/ensure_tag.sh b/scripts/ensure_tag.sh
index 2da3c404f..c6fea7ca0 100755
--- a/scripts/ensure_tag.sh
+++ b/scripts/ensure_tag.sh
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
+
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/scripts/lib/version.sh b/scripts/lib/version.sh
index 9e3e055fd..65f9bb353 100755
--- a/scripts/lib/version.sh
+++ b/scripts/lib/version.sh
@@ -96,7 +96,6 @@ openim::version::get_version_vars() {
:
fi
-
# Try to match the "git describe" output to a regex to try to extract
# the "major" and "minor" versions and whether this is the exact tagged
# version or whether the tree is between two tagged versions.
diff --git a/scripts/make-rules/release.mk b/scripts/make-rules/release.mk
index 06b7b7e47..f3fd3d5f3 100644
--- a/scripts/make-rules/release.mk
+++ b/scripts/make-rules/release.mk
@@ -17,7 +17,7 @@
# Versions are used after merging
#
-## release: release the project
+## release.run: release the project
.PHONY: release.run
release.run: release.verify release.ensure-tag
@scripts/release.sh
@@ -39,4 +39,4 @@ release.ensure-tag: tools.verify.gsemver
## release.help: Display help information about the release package
.PHONY: release.help
release.help: scripts/make-rules/release.mk
- $(call smallhelp)
\ No newline at end of file
+ $(call smallhelp)
From 667d9e33d7cf2bcbc60006aa38349bec374d789c Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 14:44:30 +0800
Subject: [PATCH 14/73] feat: add codeowners file
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
docs/CODEOWNERS | 88 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
create mode 100644 docs/CODEOWNERS
diff --git a/docs/CODEOWNERS b/docs/CODEOWNERS
new file mode 100644
index 000000000..3cfc940e3
--- /dev/null
+++ b/docs/CODEOWNERS
@@ -0,0 +1,88 @@
+# This is a comment.
+# Each line is a file pattern followed by one or more owners.
+
+# README files
+README.md @cubxxw @kubbot @Bloomingg @FGadvancer @hrxiang @Oliver-WJ @skiffer-git @std-s @wangchuxiao-dev @withchao
+
+# Contributing guidelines
+CONTRIBUTING.md @cubxxw @kubbot @Bloomingg @FGadvancer @hrxiang @Oliver-WJ @skiffer-git @std-s @wangchuxiao-dev @withchao
+
+# License files
+LICENSE @cubxxw @kubbot @Bloomingg @FGadvancer @hrxiang @Oliver-WJ @skiffer-git @std-s @wangchuxiao-dev @withchao
+
+# Makefile
+Makefile @cubxxw @kubbot @Bloomingg @FGadvancer @hrxiang @Oliver-WJ @skiffer-git @std-s @wangchuxiao-dev @withchao
+
+# These owners will be the default owners for everything in
+# the repo. Unless a later match takes precedence,
+# @cubxxw and @kubbot will be requested for
+# review when someone opens a pull request.
+* @cubxxw @kubbot @Bloomingg @FGadvancer @hrxiang @Oliver-WJ @skiffer-git @std-s @wangchuxiao-dev @withchao
+
+# Order is important; the last matching pattern takes the most
+# precedence. When someone opens a pull request that only
+# modifies JS files, only @js-owner and not the global
+# owner(s) will be requested for a review.
+*.js @cubxxw @kubbot @Bloomingg @FGadvancer @hrxiang @Oliver-WJ @skiffer-git @std-s @wangchuxiao-dev @withchao
+
+# You can also use email addresses if you prefer. They'll be
+# used to look up users just like we do for commit author
+# emails.
+*.go 3293172751nss@gmail.com
+*.py 3293172751nss@gmail.com
+
+# Teams can be specified as code owners as well. Teams should
+# be identified in the format @org/team-name. Teams must have
+# explicit write access to the repository. In this example,
+# the OpenIMSDK team in the github organization owns all .txt files.
+*.txt @cubxxw @kubbot @Bloomingg @FGadvancer @hrxiang @Oliver-WJ @skiffer-git @std-s @wangchuxiao-dev @withchao
+
+# The `docs/*` pattern will match files like
+# `docs/getting-started.md` but not further nested files like
+# `docs/build-app/troubleshooting.md`.
+docs/* 3293172751nss@gmail.com @kubbot @skiffer-git
+
+# In this example, @octocat owns any file in an apps directory
+# anywhere in your repository.
+api/ @cubxxw @IRONICBo @skiffer-git
+
+# This is a comment.
+# Each line is a file pattern followed by one or more owners.
+
+# CHANGELOG file
+CHANGELOG/* @cubxxw @skiffer-git
+
+# _output directory
+_output/* @skiffer-git
+
+# bin directory
+bin/* @skiffer-git @FGadvancer
+
+# cmd directory
+cmd/*
+
+# config directory
+config/* @skiffer-git
+
+# db directory
+db/sdk @77caleb @BanTanger @cubxxw @Gordon
+
+# internal directory
+internal/ @skiffer-git @FGadvancer
+
+# logs directory
+logs/* @skiffer-git @FGadvancer
+
+# pkg directory
+pkg/a2r @skiffer-git
+
+# scripts directory
+scripts/LICENSE/* @cubxxw @skiffer-git @FGadvancer
+scripts/enterprise/* @FGadvancer @cubxxw @skiffer-git @kubbot
+scripts/githooks/* @cubxxw @skiffer-git @FGadvancer
+scripts/lib/* @FGadvancer @cubxxw @skiffer-git @kubbot
+scripts/make-rules/* @FGadvancer @cubxxw @skiffer-git @kubbot
+
+# test directory
+test/mongo @FGadvancer @cubxxw @skiffer-git @kubbot
+test/mysql @FGadvancer @cubxxw @skiffer-git @kubbot
From ada9acf21870e81a9d72e9046e07089227eb85c9 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 16:17:18 +0800
Subject: [PATCH 15/73] feat: add git hook sign
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.github/workflows/openim-ci.yml | 2 +-
scripts/githooks/commit-msg | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/openim-ci.yml b/.github/workflows/openim-ci.yml
index e063c6e3b..d58211444 100644
--- a/.github/workflows/openim-ci.yml
+++ b/.github/workflows/openim-ci.yml
@@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
- go_version: [1.18, 1.19, 1.20]
+ go_version: ['1.18', '1.19', '1.20']
os: [ubuntu-latest, macOS-latest]
steps:
diff --git a/scripts/githooks/commit-msg b/scripts/githooks/commit-msg
index bf00bfc31..99f4067b9 100644
--- a/scripts/githooks/commit-msg
+++ b/scripts/githooks/commit-msg
@@ -75,4 +75,18 @@ then
printError "Please fix your commit message to match kubecub coding standards"
printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md"
exit 1
+fi
+
+### Add Sign-off-by line to the end of the commit message
+# Get local git config
+NAME=$(git config user.name)
+EMAIL=$(git config user.email)
+
+# Check if the commit message contains a sign-off line
+grep -qs "^Signed-off-by: " "$1"
+SIGNED_OFF_BY_EXISTS=$?
+
+# Add "Signed-off-by" line if it doesn't exist
+if [ $SIGNED_OFF_BY_EXISTS -ne 0 ]; then
+ echo -e "\nSigned-off-by: $NAME <$EMAIL>" >> "$1"
fi
\ No newline at end of file
From 12695337e9099eb0379dd300fb1f2555b46366fb Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 17:09:49 +0800
Subject: [PATCH 16/73] feat: add more feature in scripts
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.github/weekly-digest.yml | 7 +++++++
.github/workflows/openim-ci.yml | 4 ++--
scripts/lib/release.sh | 6 +++---
scripts/make-rules/release.mk | 2 +-
scripts/make-rules/tools.mk | 1 +
5 files changed, 14 insertions(+), 6 deletions(-)
create mode 100644 .github/weekly-digest.yml
diff --git a/.github/weekly-digest.yml b/.github/weekly-digest.yml
new file mode 100644
index 000000000..9deb72e7b
--- /dev/null
+++ b/.github/weekly-digest.yml
@@ -0,0 +1,7 @@
+# https://github.com/apps/weekly-digest/installations/new
+publishDay: sun
+canPublishIssues: true
+canPublishPullRequests: true
+canPublishContributors: true
+canPublishStargazers: true
+canPublishCommits: true
\ No newline at end of file
diff --git a/.github/workflows/openim-ci.yml b/.github/workflows/openim-ci.yml
index d58211444..c8b95eb8e 100644
--- a/.github/workflows/openim-ci.yml
+++ b/.github/workflows/openim-ci.yml
@@ -1,4 +1,4 @@
-name: OpenIMCI
+name: OpenIM CI
on:
# main branch
@@ -64,7 +64,7 @@ jobs:
- name: Login to DockerHub
uses: docker/login-action@v1
with:
- username: ${{ secrets.DOCKERHUB_USERNAME }}
+ username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build docker images for host arch and push images to registry
diff --git a/scripts/lib/release.sh b/scripts/lib/release.sh
index 1817e4ff2..e596afaff 100755
--- a/scripts/lib/release.sh
+++ b/scripts/lib/release.sh
@@ -27,8 +27,8 @@ readonly BUCKET="openim-1306374445"
readonly REGION="ap-beijing"
readonly COS_RELEASE_DIR="openim-release"
-# default cos command tool
-readonly COSTOOL="coscmd"
+# default cos command tool coscli or coscmd
+readonly COSTOOL="coscli"
# This is where the final release artifacts are created locally
readonly RELEASE_STAGE="${LOCAL_OUTPUT_ROOT}/release-stage"
@@ -37,7 +37,7 @@ readonly RELEASE_IMAGES="${LOCAL_OUTPUT_ROOT}/release-images"
# OpenIM github account info
readonly OPENIM_GITHUB_ORG=OpenIMSDK
-readonly OPENIM_GITHUB_REPO=openim
+readonly OPENIM_GITHUB_REPO=Open-IM-Server
readonly ARTIFACT=openim.tar.gz
readonly CHECKSUM=${ARTIFACT}.sha1sum
diff --git a/scripts/make-rules/release.mk b/scripts/make-rules/release.mk
index f3fd3d5f3..862aa3065 100644
--- a/scripts/make-rules/release.mk
+++ b/scripts/make-rules/release.mk
@@ -24,7 +24,7 @@ release.run: release.verify release.ensure-tag
## release.verify: Check if a tool is installed and install it
.PHONY: release.verify
-release.verify: tools.verify.git-chglog tools.verify.github-release tools.verify.coscmd
+release.verify: tools.verify.git-chglog tools.verify.github-release tools.verify.coscmd tools.verify.coscli
## release.tag: release the project
.PHONY: release.tag
diff --git a/scripts/make-rules/tools.mk b/scripts/make-rules/tools.mk
index c0e65ff94..468cf109f 100644
--- a/scripts/make-rules/tools.mk
+++ b/scripts/make-rules/tools.mk
@@ -133,6 +133,7 @@ install.github-release:
## install.coscli: Install coscli, used to upload files to cos
# example: ./coscli cp/sync -r /home/off-line/docker-off-line/ cos://openim-1306374445/openim/image/amd/off-line/off-line/ -e cos.ap-guangzhou.myqcloud.com
# https://cloud.tencent.com/document/product/436/71763
+# amd64
.PHONY: install.coscli
install.coscli:
@wget -q https://ghproxy.com/https://github.com/tencentyun/coscli/releases/download/v0.13.0-beta/coscli-linux -O ${TOOLS_DIR}/coscli
From aedd16a33adce824dfedbba579ac8c92f3f33de5 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 18:02:46 +0800
Subject: [PATCH 17/73] fix: fix cmd filename
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
cmd/{api => openim_api}/Makefile | 0
cmd/{api => openim_api}/deploy.Dockerfile | 0
cmd/{api => openim_api}/main.go | 0
cmd/{cmdutils => openim_cmdutils}/Makefile | 0
cmd/{cmdutils => openim_cmdutils}/main.go | 0
cmd/{crontask => openim_crontask}/Makefile | 0
cmd/{crontask => openim_crontask}/deploy.Dockerfile | 0
cmd/{crontask => openim_crontask}/main.go | 0
cmd/{msggateway => openim_msggateway}/Makefile | 0
cmd/{msggateway => openim_msggateway}/deploy.Dockerfile | 0
cmd/{msggateway => openim_msggateway}/main.go | 0
cmd/{msgtransfer => openim_msgtransfer}/Makefile | 0
cmd/{msgtransfer => openim_msgtransfer}/deploy.Dockerfile | 0
cmd/{msgtransfer => openim_msgtransfer}/main.go | 0
cmd/{push => openim_push}/Makefile | 0
cmd/{push => openim_push}/deploy.Dockerfile | 0
cmd/{push => openim_push}/main.go | 0
cmd/{rpc/auth => openim_rpc/openim_rpc_auth}/Makefile | 0
.../auth => openim_rpc/openim_rpc_auth}/deploy.Dockerfile | 0
cmd/{rpc/auth => openim_rpc/openim_rpc_auth}/main.go | 0
.../openim_rpc_conversation}/Makefile | 0
.../openim_rpc_conversation}/deploy.Dockerfile | 0
.../openim_rpc_conversation}/main.go | 0
cmd/{rpc/friend => openim_rpc/openim_rpc_friend}/Makefile | 0
.../friend => openim_rpc/openim_rpc_friend}/deploy.Dockerfile | 0
cmd/{rpc/friend => openim_rpc/openim_rpc_friend}/main.go | 0
cmd/{rpc/group => openim_rpc/openim_rpc_group}/Makefile | 0
.../group => openim_rpc/openim_rpc_group}/deploy.Dockerfile | 0
cmd/{rpc/group => openim_rpc/openim_rpc_group}/main.go | 0
cmd/{rpc/msg => openim_rpc/openim_rpc_msg}/Makefile | 0
cmd/{rpc/msg => openim_rpc/openim_rpc_msg}/deploy.Dockerfile | 0
cmd/{rpc/msg => openim_rpc/openim_rpc_msg}/main.go | 0
cmd/{rpc/third => openim_rpc/openim_rpc_third}/Makefile | 0
.../third => openim_rpc/openim_rpc_third}/deploy.Dockerfile | 0
cmd/{rpc/third => openim_rpc/openim_rpc_third}/main.go | 0
cmd/{rpc/user => openim_rpc/openim_rpc_user}/Makefile | 0
.../user => openim_rpc/openim_rpc_user}/deploy.Dockerfile | 0
cmd/{rpc/user => openim_rpc/openim_rpc_user}/main.go | 0
scripts/make-rules/common.mk | 4 ++--
scripts/make-rules/golang.mk | 4 ++--
40 files changed, 4 insertions(+), 4 deletions(-)
rename cmd/{api => openim_api}/Makefile (100%)
rename cmd/{api => openim_api}/deploy.Dockerfile (100%)
rename cmd/{api => openim_api}/main.go (100%)
rename cmd/{cmdutils => openim_cmdutils}/Makefile (100%)
rename cmd/{cmdutils => openim_cmdutils}/main.go (100%)
rename cmd/{crontask => openim_crontask}/Makefile (100%)
rename cmd/{crontask => openim_crontask}/deploy.Dockerfile (100%)
rename cmd/{crontask => openim_crontask}/main.go (100%)
rename cmd/{msggateway => openim_msggateway}/Makefile (100%)
rename cmd/{msggateway => openim_msggateway}/deploy.Dockerfile (100%)
rename cmd/{msggateway => openim_msggateway}/main.go (100%)
rename cmd/{msgtransfer => openim_msgtransfer}/Makefile (100%)
rename cmd/{msgtransfer => openim_msgtransfer}/deploy.Dockerfile (100%)
rename cmd/{msgtransfer => openim_msgtransfer}/main.go (100%)
rename cmd/{push => openim_push}/Makefile (100%)
rename cmd/{push => openim_push}/deploy.Dockerfile (100%)
rename cmd/{push => openim_push}/main.go (100%)
rename cmd/{rpc/auth => openim_rpc/openim_rpc_auth}/Makefile (100%)
rename cmd/{rpc/auth => openim_rpc/openim_rpc_auth}/deploy.Dockerfile (100%)
rename cmd/{rpc/auth => openim_rpc/openim_rpc_auth}/main.go (100%)
rename cmd/{rpc/conversation => openim_rpc/openim_rpc_conversation}/Makefile (100%)
rename cmd/{rpc/conversation => openim_rpc/openim_rpc_conversation}/deploy.Dockerfile (100%)
rename cmd/{rpc/conversation => openim_rpc/openim_rpc_conversation}/main.go (100%)
rename cmd/{rpc/friend => openim_rpc/openim_rpc_friend}/Makefile (100%)
rename cmd/{rpc/friend => openim_rpc/openim_rpc_friend}/deploy.Dockerfile (100%)
rename cmd/{rpc/friend => openim_rpc/openim_rpc_friend}/main.go (100%)
rename cmd/{rpc/group => openim_rpc/openim_rpc_group}/Makefile (100%)
rename cmd/{rpc/group => openim_rpc/openim_rpc_group}/deploy.Dockerfile (100%)
rename cmd/{rpc/group => openim_rpc/openim_rpc_group}/main.go (100%)
rename cmd/{rpc/msg => openim_rpc/openim_rpc_msg}/Makefile (100%)
rename cmd/{rpc/msg => openim_rpc/openim_rpc_msg}/deploy.Dockerfile (100%)
rename cmd/{rpc/msg => openim_rpc/openim_rpc_msg}/main.go (100%)
rename cmd/{rpc/third => openim_rpc/openim_rpc_third}/Makefile (100%)
rename cmd/{rpc/third => openim_rpc/openim_rpc_third}/deploy.Dockerfile (100%)
rename cmd/{rpc/third => openim_rpc/openim_rpc_third}/main.go (100%)
rename cmd/{rpc/user => openim_rpc/openim_rpc_user}/Makefile (100%)
rename cmd/{rpc/user => openim_rpc/openim_rpc_user}/deploy.Dockerfile (100%)
rename cmd/{rpc/user => openim_rpc/openim_rpc_user}/main.go (100%)
diff --git a/cmd/api/Makefile b/cmd/openim_api/Makefile
similarity index 100%
rename from cmd/api/Makefile
rename to cmd/openim_api/Makefile
diff --git a/cmd/api/deploy.Dockerfile b/cmd/openim_api/deploy.Dockerfile
similarity index 100%
rename from cmd/api/deploy.Dockerfile
rename to cmd/openim_api/deploy.Dockerfile
diff --git a/cmd/api/main.go b/cmd/openim_api/main.go
similarity index 100%
rename from cmd/api/main.go
rename to cmd/openim_api/main.go
diff --git a/cmd/cmdutils/Makefile b/cmd/openim_cmdutils/Makefile
similarity index 100%
rename from cmd/cmdutils/Makefile
rename to cmd/openim_cmdutils/Makefile
diff --git a/cmd/cmdutils/main.go b/cmd/openim_cmdutils/main.go
similarity index 100%
rename from cmd/cmdutils/main.go
rename to cmd/openim_cmdutils/main.go
diff --git a/cmd/crontask/Makefile b/cmd/openim_crontask/Makefile
similarity index 100%
rename from cmd/crontask/Makefile
rename to cmd/openim_crontask/Makefile
diff --git a/cmd/crontask/deploy.Dockerfile b/cmd/openim_crontask/deploy.Dockerfile
similarity index 100%
rename from cmd/crontask/deploy.Dockerfile
rename to cmd/openim_crontask/deploy.Dockerfile
diff --git a/cmd/crontask/main.go b/cmd/openim_crontask/main.go
similarity index 100%
rename from cmd/crontask/main.go
rename to cmd/openim_crontask/main.go
diff --git a/cmd/msggateway/Makefile b/cmd/openim_msggateway/Makefile
similarity index 100%
rename from cmd/msggateway/Makefile
rename to cmd/openim_msggateway/Makefile
diff --git a/cmd/msggateway/deploy.Dockerfile b/cmd/openim_msggateway/deploy.Dockerfile
similarity index 100%
rename from cmd/msggateway/deploy.Dockerfile
rename to cmd/openim_msggateway/deploy.Dockerfile
diff --git a/cmd/msggateway/main.go b/cmd/openim_msggateway/main.go
similarity index 100%
rename from cmd/msggateway/main.go
rename to cmd/openim_msggateway/main.go
diff --git a/cmd/msgtransfer/Makefile b/cmd/openim_msgtransfer/Makefile
similarity index 100%
rename from cmd/msgtransfer/Makefile
rename to cmd/openim_msgtransfer/Makefile
diff --git a/cmd/msgtransfer/deploy.Dockerfile b/cmd/openim_msgtransfer/deploy.Dockerfile
similarity index 100%
rename from cmd/msgtransfer/deploy.Dockerfile
rename to cmd/openim_msgtransfer/deploy.Dockerfile
diff --git a/cmd/msgtransfer/main.go b/cmd/openim_msgtransfer/main.go
similarity index 100%
rename from cmd/msgtransfer/main.go
rename to cmd/openim_msgtransfer/main.go
diff --git a/cmd/push/Makefile b/cmd/openim_push/Makefile
similarity index 100%
rename from cmd/push/Makefile
rename to cmd/openim_push/Makefile
diff --git a/cmd/push/deploy.Dockerfile b/cmd/openim_push/deploy.Dockerfile
similarity index 100%
rename from cmd/push/deploy.Dockerfile
rename to cmd/openim_push/deploy.Dockerfile
diff --git a/cmd/push/main.go b/cmd/openim_push/main.go
similarity index 100%
rename from cmd/push/main.go
rename to cmd/openim_push/main.go
diff --git a/cmd/rpc/auth/Makefile b/cmd/openim_rpc/openim_rpc_auth/Makefile
similarity index 100%
rename from cmd/rpc/auth/Makefile
rename to cmd/openim_rpc/openim_rpc_auth/Makefile
diff --git a/cmd/rpc/auth/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_auth/deploy.Dockerfile
similarity index 100%
rename from cmd/rpc/auth/deploy.Dockerfile
rename to cmd/openim_rpc/openim_rpc_auth/deploy.Dockerfile
diff --git a/cmd/rpc/auth/main.go b/cmd/openim_rpc/openim_rpc_auth/main.go
similarity index 100%
rename from cmd/rpc/auth/main.go
rename to cmd/openim_rpc/openim_rpc_auth/main.go
diff --git a/cmd/rpc/conversation/Makefile b/cmd/openim_rpc/openim_rpc_conversation/Makefile
similarity index 100%
rename from cmd/rpc/conversation/Makefile
rename to cmd/openim_rpc/openim_rpc_conversation/Makefile
diff --git a/cmd/rpc/conversation/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_conversation/deploy.Dockerfile
similarity index 100%
rename from cmd/rpc/conversation/deploy.Dockerfile
rename to cmd/openim_rpc/openim_rpc_conversation/deploy.Dockerfile
diff --git a/cmd/rpc/conversation/main.go b/cmd/openim_rpc/openim_rpc_conversation/main.go
similarity index 100%
rename from cmd/rpc/conversation/main.go
rename to cmd/openim_rpc/openim_rpc_conversation/main.go
diff --git a/cmd/rpc/friend/Makefile b/cmd/openim_rpc/openim_rpc_friend/Makefile
similarity index 100%
rename from cmd/rpc/friend/Makefile
rename to cmd/openim_rpc/openim_rpc_friend/Makefile
diff --git a/cmd/rpc/friend/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_friend/deploy.Dockerfile
similarity index 100%
rename from cmd/rpc/friend/deploy.Dockerfile
rename to cmd/openim_rpc/openim_rpc_friend/deploy.Dockerfile
diff --git a/cmd/rpc/friend/main.go b/cmd/openim_rpc/openim_rpc_friend/main.go
similarity index 100%
rename from cmd/rpc/friend/main.go
rename to cmd/openim_rpc/openim_rpc_friend/main.go
diff --git a/cmd/rpc/group/Makefile b/cmd/openim_rpc/openim_rpc_group/Makefile
similarity index 100%
rename from cmd/rpc/group/Makefile
rename to cmd/openim_rpc/openim_rpc_group/Makefile
diff --git a/cmd/rpc/group/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_group/deploy.Dockerfile
similarity index 100%
rename from cmd/rpc/group/deploy.Dockerfile
rename to cmd/openim_rpc/openim_rpc_group/deploy.Dockerfile
diff --git a/cmd/rpc/group/main.go b/cmd/openim_rpc/openim_rpc_group/main.go
similarity index 100%
rename from cmd/rpc/group/main.go
rename to cmd/openim_rpc/openim_rpc_group/main.go
diff --git a/cmd/rpc/msg/Makefile b/cmd/openim_rpc/openim_rpc_msg/Makefile
similarity index 100%
rename from cmd/rpc/msg/Makefile
rename to cmd/openim_rpc/openim_rpc_msg/Makefile
diff --git a/cmd/rpc/msg/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_msg/deploy.Dockerfile
similarity index 100%
rename from cmd/rpc/msg/deploy.Dockerfile
rename to cmd/openim_rpc/openim_rpc_msg/deploy.Dockerfile
diff --git a/cmd/rpc/msg/main.go b/cmd/openim_rpc/openim_rpc_msg/main.go
similarity index 100%
rename from cmd/rpc/msg/main.go
rename to cmd/openim_rpc/openim_rpc_msg/main.go
diff --git a/cmd/rpc/third/Makefile b/cmd/openim_rpc/openim_rpc_third/Makefile
similarity index 100%
rename from cmd/rpc/third/Makefile
rename to cmd/openim_rpc/openim_rpc_third/Makefile
diff --git a/cmd/rpc/third/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_third/deploy.Dockerfile
similarity index 100%
rename from cmd/rpc/third/deploy.Dockerfile
rename to cmd/openim_rpc/openim_rpc_third/deploy.Dockerfile
diff --git a/cmd/rpc/third/main.go b/cmd/openim_rpc/openim_rpc_third/main.go
similarity index 100%
rename from cmd/rpc/third/main.go
rename to cmd/openim_rpc/openim_rpc_third/main.go
diff --git a/cmd/rpc/user/Makefile b/cmd/openim_rpc/openim_rpc_user/Makefile
similarity index 100%
rename from cmd/rpc/user/Makefile
rename to cmd/openim_rpc/openim_rpc_user/Makefile
diff --git a/cmd/rpc/user/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_user/deploy.Dockerfile
similarity index 100%
rename from cmd/rpc/user/deploy.Dockerfile
rename to cmd/openim_rpc/openim_rpc_user/deploy.Dockerfile
diff --git a/cmd/rpc/user/main.go b/cmd/openim_rpc/openim_rpc_user/main.go
similarity index 100%
rename from cmd/rpc/user/main.go
rename to cmd/openim_rpc/openim_rpc_user/main.go
diff --git a/scripts/make-rules/common.mk b/scripts/make-rules/common.mk
index 568b019ca..72b395e28 100644
--- a/scripts/make-rules/common.mk
+++ b/scripts/make-rules/common.mk
@@ -85,9 +85,9 @@ GOBIN=$(shell go env GOBIN)
endif
# The OS must be linux when building docker images
-PLATFORMS ?= linux_amd64 linux_arm64
+# PLATFORMS ?= linux_amd64 linux_arm64
# The OS can be linux/windows/darwin when building binaries
-# PLATFORMS ?= darwin_amd64 windows_amd64 linux_amd64 linux_arm64
+PLATFORMS ?= linux_s390x linux_mips64 linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64
# only support linux
GOOS=linux
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index bf503db63..03be95a91 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -113,8 +113,8 @@ go.build.%:
@mkdir -p $(BIN_DIR)/platforms/$(OS)/$(ARCH)
@if [ "$(COMMAND)" == "openim-sdk-core" ]; then \
echo "===========> DEBUG: Compilation is not yet supported $(COMMAND)"; \
- elif [ "$(COMMAND)" == "rpc" ]; then \
- for d in $(wildcard $(ROOT_DIR)/cmd/rpc/*); do \
+ elif [ "$(COMMAND)" == "openim_rpc" ]; then \
+ for d in $(wildcard $(ROOT_DIR)/cmd/openim_rpc/*); do \
cd $${d} && CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
$(BIN_DIR)/platforms/$(OS)/$(ARCH)/$$(basename $${d})$(GO_OUT_EXT) $${d}/main.go; \
done; \
From 859d82fcd176a0cbb7f172795b59530b72b496dc Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 18:25:51 +0800
Subject: [PATCH 18/73] feat: add makefile bug
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
pkg/common/db/controller/storage.go | 1 -
scripts/common.sh | 14 ++++++++++++++
scripts/make-rules/swagger.mk | 12 ++++++++++++
3 files changed, 26 insertions(+), 1 deletion(-)
create mode 100644 scripts/make-rules/swagger.mk
diff --git a/pkg/common/db/controller/storage.go b/pkg/common/db/controller/storage.go
index ab20e7da8..c383eb8ec 100644
--- a/pkg/common/db/controller/storage.go
+++ b/pkg/common/db/controller/storage.go
@@ -14,7 +14,6 @@
package controller
-import "C"
import (
"bytes"
"context"
diff --git a/scripts/common.sh b/scripts/common.sh
index a254412de..3a2090b6f 100755
--- a/scripts/common.sh
+++ b/scripts/common.sh
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# shellcheck disable=SC2034 # Variables sourced in other scripts.
diff --git a/scripts/make-rules/swagger.mk b/scripts/make-rules/swagger.mk
new file mode 100644
index 000000000..0598813c3
--- /dev/null
+++ b/scripts/make-rules/swagger.mk
@@ -0,0 +1,12 @@
+# ==============================================================================
+# Makefile helper functions for swagger
+#
+
+.PHONY: swagger.run
+swagger.run: tools.verify.swagger
+ @echo "===========> Generating swagger API docs"
+ @swagger generate spec --scan-models -w $(ROOT_DIR)/cmd/genswaggertypedocs -o $(ROOT_DIR)/api/swagger/swagger.yaml
+
+.PHONY: swagger.serve
+swagger.serve: tools.verify.swagger
+ @swagger serve -F=redoc --no-open --port 36666 $(ROOT_DIR)/api/swagger/swagger.yaml
From dae7849393960c51ff5718ef2936797595fb6b4b Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 18:35:10 +0800
Subject: [PATCH 19/73] feat: add license
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.docker-compose_cfg/config.yaml | 14 ++++++++++++++
.docker-compose_cfg/datasource-compose.yaml | 14 ++++++++++++++
.docker-compose_cfg/prometheus-compose.yml | 14 ++++++++++++++
scripts/make-rules/common.mk | 2 +-
scripts/make-rules/golang.mk | 2 +-
5 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/.docker-compose_cfg/config.yaml b/.docker-compose_cfg/config.yaml
index 4ea03d854..b3b7d73d5 100644
--- a/.docker-compose_cfg/config.yaml
+++ b/.docker-compose_cfg/config.yaml
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
#---------------Infrastructure configuration---------------------#
etcd:
etcdSchema: openim #默认即可
diff --git a/.docker-compose_cfg/datasource-compose.yaml b/.docker-compose_cfg/datasource-compose.yaml
index ef9824eb0..2be73952d 100644
--- a/.docker-compose_cfg/datasource-compose.yaml
+++ b/.docker-compose_cfg/datasource-compose.yaml
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
#more datasource-compose.yaml
apiVersion: 1
diff --git a/.docker-compose_cfg/prometheus-compose.yml b/.docker-compose_cfg/prometheus-compose.yml
index 55a439644..37a8c547e 100644
--- a/.docker-compose_cfg/prometheus-compose.yml
+++ b/.docker-compose_cfg/prometheus-compose.yml
@@ -1,3 +1,17 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
#more prometheus-compose.yml
global:
scrape_interval: 15s
diff --git a/scripts/make-rules/common.mk b/scripts/make-rules/common.mk
index 72b395e28..5019ebc77 100644
--- a/scripts/make-rules/common.mk
+++ b/scripts/make-rules/common.mk
@@ -116,7 +116,7 @@ FIND := find . ! -path './utils/*' ! -path './vendor/*'
XARGS := xargs -r
# Linux command settings-CODE DIRS Copyright
-CODE_DIRS := $(ROOT_DIR)/pkg $(ROOT_DIR)/cmd $(ROOT_DIR)/config $(ROOT_DIR)/db $(ROOT_DIR)/deploy $(ROOT_DIR)/deploy_k8s $(ROOT_DIR)/docker-compose_cfg $(ROOT_DIR)/internal $(ROOT_DIR)/scripts $(ROOT_DIR)/test
+CODE_DIRS := $(ROOT_DIR)/pkg $(ROOT_DIR)/cmd $(ROOT_DIR)/config $(ROOT_DIR)/db $(ROOT_DIR)/.docker-compose_cfg $(ROOT_DIR)/internal $(ROOT_DIR)/scripts $(ROOT_DIR)/test
FINDS := find $(CODE_DIRS)
# Makefile settings: Select different behaviors by determining whether V option is set
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index 03be95a91..81ff49f14 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -65,7 +65,7 @@ ifeq (${BINS},)
endif
# TODO: EXCLUDE_TESTS variable, which contains the name of the package to be excluded from the test
-EXCLUDE_TESTS=github.com/OpenIMSDK/Open-IM-Server/test github.com/OpenIMSDK/Open-IM-Server/pkg/log github.com/OpenIMSDK/Open-IM-Server/db github.com/OpenIMSDK/Open-IM-Server/scripts github.com/OpenIMSDK/Open-IM-Server/deploy_k8s github.com/OpenIMSDK/Open-IM-Server/deploy github.com/OpenIMSDK/Open-IM-Server/config
+EXCLUDE_TESTS=github.com/OpenIMSDK/Open-IM-Server/test github.com/OpenIMSDK/Open-IM-Server/pkg/log github.com/OpenIMSDK/Open-IM-Server/db github.com/OpenIMSDK/Open-IM-Server/scripts github.com/OpenIMSDK/Open-IM-Server/config
# ==============================================================================
# ❯ tree -L 1 cmd
From 02a24aebfe3dd4ab370561503bcb5b6ac1daa1ff Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 20:18:39 +0800
Subject: [PATCH 20/73] style: migrate image locations
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
Makefile | 11 +++++++
README.md | 6 ++--
docs/{ => images}/Architecture.jpg | Bin
.../Open-IM-Servers-on-System.png | Bin
.../Open-IM-Servers-on-docker.png | Bin
docs/{ => images}/Open-IM.png | Bin
docs/{ => images}/Wechat.jpg | Bin
docs/{ => images}/open-im-logo.png | Bin
docs/{ => images}/open-im-server.png | Bin
scripts/make-rules/golang.mk | 2 +-
scripts/make-rules/swagger.mk | 11 +++++--
scripts/make-rules/tools.mk | 5 ++++
scripts/start_all.sh | 27 +++++++++---------
13 files changed, 43 insertions(+), 19 deletions(-)
rename docs/{ => images}/Architecture.jpg (100%)
rename docs/{ => images}/Open-IM-Servers-on-System.png (100%)
rename docs/{ => images}/Open-IM-Servers-on-docker.png (100%)
rename docs/{ => images}/Open-IM.png (100%)
rename docs/{ => images}/Wechat.jpg (100%)
rename docs/{ => images}/open-im-logo.png (100%)
rename docs/{ => images}/open-im-server.png (100%)
diff --git a/Makefile b/Makefile
index c210edbe3..ceffba205 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,7 @@ include scripts/make-rules/gen.mk
include scripts/make-rules/dependencies.mk
include scripts/make-rules/tools.mk
include scripts/make-rules/release.mk
+include scripts/make-rules/swagger.mk
# ==============================================================================
# Usage
@@ -148,6 +149,16 @@ tools:
gen:
@$(MAKE) gen.run
+## swagger: Generate swagger document.
+.PHONY: swagger
+swagger:
+ @$(MAKE) swagger.run
+
+## serve-swagger: Serve swagger spec and docs.
+.PHONY: swagger.serve
+serve-swagger:
+ @$(MAKE) swagger.serve
+
## verify-copyright: Verify the license headers for all files.
.PHONY: verify-copyright
verify-copyright:
diff --git a/README.md b/README.md
index 8f2713ccb..d3d880d41 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ By deployment of the Open-IM-Server on the customer's server, developers can int
./docker_check_service.sh./check_all.sh
```
- ![OpenIMServersonSystempng](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/Open-IM-Servers-on-System.png)
+ ![OpenIMServersonSystempng](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/Open-IM-Servers-on-System.png)
#### Deploy using source code
@@ -157,11 +157,11 @@ all services build success
## Authentication Clow Chart
-![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/open-im-server.png)
+![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/open-im-server.png)
## Architecture
-![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/Architecture.jpg)
+![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/Architecture.jpg)
## To start developing OpenIM
The [community repository](https://github.com/OpenIMSDK/community) hosts all information about building Kubernetes from source, how to contribute code and documentation, who to contact about what, etc.
diff --git a/docs/Architecture.jpg b/docs/images/Architecture.jpg
similarity index 100%
rename from docs/Architecture.jpg
rename to docs/images/Architecture.jpg
diff --git a/docs/Open-IM-Servers-on-System.png b/docs/images/Open-IM-Servers-on-System.png
similarity index 100%
rename from docs/Open-IM-Servers-on-System.png
rename to docs/images/Open-IM-Servers-on-System.png
diff --git a/docs/Open-IM-Servers-on-docker.png b/docs/images/Open-IM-Servers-on-docker.png
similarity index 100%
rename from docs/Open-IM-Servers-on-docker.png
rename to docs/images/Open-IM-Servers-on-docker.png
diff --git a/docs/Open-IM.png b/docs/images/Open-IM.png
similarity index 100%
rename from docs/Open-IM.png
rename to docs/images/Open-IM.png
diff --git a/docs/Wechat.jpg b/docs/images/Wechat.jpg
similarity index 100%
rename from docs/Wechat.jpg
rename to docs/images/Wechat.jpg
diff --git a/docs/open-im-logo.png b/docs/images/open-im-logo.png
similarity index 100%
rename from docs/open-im-logo.png
rename to docs/images/open-im-logo.png
diff --git a/docs/open-im-server.png b/docs/images/open-im-server.png
similarity index 100%
rename from docs/open-im-server.png
rename to docs/images/open-im-server.png
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index 81ff49f14..de1e6b74e 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -141,6 +141,7 @@ go.test:
## go.test.junit-report: Run unit test
.PHONY: go.test.junit-report
go.test.junit-report: tools.verify.go-junit-report
+ @touch $(TMP_DIR)/coverage.out
@echo "===========> Run unit test > $(TMP_DIR)/report.xml"
# @$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 $(GO_BUILD_FLAGS) ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml
@$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml
@@ -151,7 +152,6 @@ go.test.junit-report: tools.verify.go-junit-report
## go.test.cover: Run unit test with coverage
.PHONY: go.test.cover
go.test.cover: go.test.junit-report
- @touch $(TMP_DIR)/coverage.out
@$(GO) tool cover -func=$(TMP_DIR)/coverage.out | \
awk -v target=$(COVERAGE) -f $(ROOT_DIR)/scripts/coverage.awk
diff --git a/scripts/make-rules/swagger.mk b/scripts/make-rules/swagger.mk
index 0598813c3..991de43c6 100644
--- a/scripts/make-rules/swagger.mk
+++ b/scripts/make-rules/swagger.mk
@@ -2,11 +2,18 @@
# Makefile helper functions for swagger
#
+## swagger.run: Generate swagger document.
.PHONY: swagger.run
swagger.run: tools.verify.swagger
@echo "===========> Generating swagger API docs"
- @swagger generate spec --scan-models -w $(ROOT_DIR)/cmd/genswaggertypedocs -o $(ROOT_DIR)/api/swagger/swagger.yaml
+ @$(TOOLS_DIR)/swagger generate spec --scan-models -w $(ROOT_DIR)/cmd/genswaggertypedocs -o $(ROOT_DIR)/api/swagger/swagger.yaml
+## swagger.serve: Serve swagger spec and docs.
.PHONY: swagger.serve
swagger.serve: tools.verify.swagger
- @swagger serve -F=redoc --no-open --port 36666 $(ROOT_DIR)/api/swagger/swagger.yaml
+ @$(TOOLS_DIR)/swagger serve -F=redoc --no-open --port 36666 $(ROOT_DIR)/api/swagger/swagger.yaml
+
+## swagger.help: Display help information about the release package
+.PHONY: swagger.help
+swagger.help: scripts/make-rules/swagger.mk
+ $(call smallhelp)
\ No newline at end of file
diff --git a/scripts/make-rules/tools.mk b/scripts/make-rules/tools.mk
index 468cf109f..e268cb264 100644
--- a/scripts/make-rules/tools.mk
+++ b/scripts/make-rules/tools.mk
@@ -101,6 +101,11 @@ install.go-gitlint:
install.go-junit-report:
@$(GO) install github.com/jstemmer/go-junit-report@latest
+## install.gotests: Install gotests, used to generate go tests
+.PHONY: install.swagger
+install.swagger:
+ @$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@latest
+
# ==============================================================================
# Tools that might be used include go gvm
#
diff --git a/scripts/start_all.sh b/scripts/start_all.sh
index eba94c4b7..1a86db7f3 100755
--- a/scripts/start_all.sh
+++ b/scripts/start_all.sh
@@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#fixme This scripts is the total startup scripts
-#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
+#FIXME This script is the startup script for multiple servers.
+#FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array.
-#fixme Put the shell scripts name here
+#FIXME Put the shell script names here
need_to_start_server_shell=(
start_rpc_service.sh
push_start.sh
@@ -25,20 +25,21 @@ need_to_start_server_shell=(
msg_gateway_start.sh
start_cron.sh
)
+
time=`date +"%Y-%m-%d %H:%M:%S"`
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========server start time:${time}===========">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
+echo "==========================================================" >> ../logs/openIM.log 2>&1 &
+echo "==========================================================" >> ../logs/openIM.log 2>&1 &
+echo "==========================================================" >> ../logs/openIM.log 2>&1 &
+echo "==========server start time:${time}===========" >> ../logs/openIM.log 2>&1 &
+echo "==========================================================" >> ../logs/openIM.log 2>&1 &
+echo "==========================================================" >> ../logs/openIM.log 2>&1 &
+echo "==========================================================" >> ../logs/openIM.log 2>&1 &
for i in ${need_to_start_server_shell[*]}; do
chmod +x $i
- echo "=====================exec ${i}======================">>../logs/openIM.log
+ echo "=====================exec ${i}======================" >> ../logs/openIM.log
./$i
- if [ $? -ne 0 ]; then
- exit -1
+ if [ $? -ne 0 ]; then
+ exit -1
fi
done
From 57fe05631617cd71484c9b503b8e1b39e0abe731 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 20:22:26 +0800
Subject: [PATCH 21/73] feat: add deployments readme file
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
deployments/README.md | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100644 deployments/README.md
diff --git a/deployments/README.md b/deployments/README.md
new file mode 100644
index 000000000..9c3cff05e
--- /dev/null
+++ b/deployments/README.md
@@ -0,0 +1,26 @@
+# OpenIM 应用容器化部署指南
+
+OpenIM 支持很多种集群化部署方式,包括但不限于 helm, sealos, kubeam, kubesphere, kubeflow, kuboard, kubespray, k3s, k3d, k3c, k3sup, k3v, k3x
+
+### 依赖检查
+
+```bash
+Kubernetes: >= 1.16.0-0
+Helm: >= 3.0
+```
+
+假设 OpenIM 项目根目录路径为 `OpenIM_ROOT`
+
+进入 OpenIM 项目根目录
+
+$ cd ${OpenIM_ROOT}
+
+
+
+### 容器化安装
+
+具体安装步骤如下:
+
+
+
+### Helm安装
\ No newline at end of file
From 1158de9f35133715a4044fcbcc1cab84d79e10b5 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Tue, 4 Jul 2023 22:16:20 +0800
Subject: [PATCH 22/73] fix: details optimize
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.gitmodules | 4 ----
install_guide.sh | 3 +--
2 files changed, 1 insertion(+), 6 deletions(-)
delete mode 100644 .gitmodules
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index be3279250..000000000
--- a/.gitmodules
+++ /dev/null
@@ -1,4 +0,0 @@
-
-[submodule "cmd/Open-IM-SDK-Core"]
- path = cmd/Open-IM-SDK-Core
- url = https://github.com/OpenIMSDK/Open-IM-SDK-Core.git
diff --git a/install_guide.sh b/install_guide.sh
index 57fad73dd..1c5f06fb9 100644
--- a/install_guide.sh
+++ b/install_guide.sh
@@ -43,7 +43,7 @@ edit_config() {
vi config/config.yaml
;;
2)
- echo "do not edit config"
+ echo "do not edit config"
;;
esac
}
@@ -174,4 +174,3 @@ case $choice in
echo "Invalid option, please try again."
;;
esac
-
From 98fe83b62d88618781cc2b4dee3b193296e277e4 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Wed, 5 Jul 2023 10:21:38 +0800
Subject: [PATCH 23/73] feat: add make
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index ceffba205..dffb32ae4 100644
--- a/Makefile
+++ b/Makefile
@@ -42,7 +42,8 @@ Options:
PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64.
This option is available when using: make {build}.multiarch
- Example: make build.multiarch PLATFORMS="linux_arm64 linux_amd64".
+ Example: make build.multiarch PLATFORMS="linux_s390x linux_mips64
+ linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64".
V Set to 1 enable verbose build. Default is 0.
endef
From fe16385c9b76b814383fa0d93801867ad14e65f8 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Wed, 5 Jul 2023 15:26:07 +0800
Subject: [PATCH 24/73] fix: rename open_im to openim
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.gitignore | 22 +++++++-------
CHANGELOG/CHANGELOG-0.0.0.md | 5 ++--
Makefile | 2 +-
cmd/openim_api/Makefile | 2 +-
cmd/openim_api/deploy.Dockerfile | 4 +--
cmd/openim_cmdutils/Makefile | 2 +-
cmd/openim_crontask/Makefile | 2 +-
cmd/openim_crontask/deploy.Dockerfile | 4 +--
cmd/openim_msggateway/Makefile | 3 +-
cmd/openim_msggateway/deploy.Dockerfile | 4 +--
cmd/openim_msgtransfer/Makefile | 2 +-
cmd/openim_msgtransfer/deploy.Dockerfile | 4 +--
cmd/openim_push/Makefile | 2 +-
cmd/openim_push/deploy.Dockerfile | 4 +--
cmd/openim_rpc/openim_rpc_auth/Makefile | 2 +-
.../openim_rpc_auth/deploy.Dockerfile | 4 +--
.../openim_rpc_conversation/Makefile | 2 +-
.../openim_rpc_conversation/deploy.Dockerfile | 4 +--
cmd/openim_rpc/openim_rpc_friend/Makefile | 4 +--
.../openim_rpc_friend/deploy.Dockerfile | 4 +--
cmd/openim_rpc/openim_rpc_group/Makefile | 7 +----
.../openim_rpc_group/deploy.Dockerfile | 4 +--
cmd/openim_rpc/openim_rpc_msg/Makefile | 4 +--
.../openim_rpc_msg/deploy.Dockerfile | 4 +--
cmd/openim_rpc/openim_rpc_third/Makefile | 7 +----
.../openim_rpc_third/deploy.Dockerfile | 4 +--
cmd/openim_rpc/openim_rpc_user/Makefile | 7 +----
.../openim_rpc_user/deploy.Dockerfile | 4 +--
docker-compose.yaml | 10 +++----
scripts/build_images.sh | 2 +-
scripts/check_all.sh | 2 +-
scripts/enterprise/check_all.sh | 3 +-
scripts/enterprise/path_info.cfg | 10 +++----
scripts/make-rules/golang.mk | 18 +++++------
scripts/path_info.cfg | 30 +++++++++----------
scripts/start_rpc_service.sh | 14 ++++-----
36 files changed, 95 insertions(+), 117 deletions(-)
diff --git a/.gitignore b/.gitignore
index 17e4853a3..9cea0d86f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,17 +30,17 @@ output/
_output/
### OpenIM deploy ###
-deploy/open_im_demo
-deploy/open_im_api
-deploy/open_im_msg_gateway
-deploy/open_im_msg_transfer
-deploy/open_im_push
-deploy/open_im_timer_task
-deploy/open_im_rpc_user
-deploy/open_im_rpc_friend
-deploy/open_im_rpc_group
-deploy/open_im_rpc_msg
-deploy/open_im_rpc_auth
+deploy/openim_demo
+deploy/openim_api
+deploy/openim_msg_gateway
+deploy/openim_msg_transfer
+deploy/openim_push
+deploy/openim_timer_task
+deploy/openim_rpc_user
+deploy/openim_rpc_friend
+deploy/openim_rpc_group
+deploy/openim_rpc_msg
+deploy/openim_rpc_auth
deploy/Open-IM-SDK-Core
# files used by the developer
diff --git a/CHANGELOG/CHANGELOG-0.0.0.md b/CHANGELOG/CHANGELOG-0.0.0.md
index ab21e1729..65a0ab1b1 100644
--- a/CHANGELOG/CHANGELOG-0.0.0.md
+++ b/CHANGELOG/CHANGELOG-0.0.0.md
@@ -142,7 +142,7 @@
### Pb
-* open_im_sdk.OfflinePushInfo
+* openim_sdk.OfflinePushInfo
### Pull Requests
@@ -162,7 +162,7 @@
### Pb
-* open_im_sdk.OfflinePushInfo
+* openim_sdk.OfflinePushInfo
@@ -225,4 +225,3 @@
* Merge pull request [#7](https://github.com/OpenIMSDK/Open-IM-Server/issues/7) from memory-qianxiao/docker-compose_update
* Merge pull request [#4](https://github.com/OpenIMSDK/Open-IM-Server/issues/4) from wujingke/patch-1
-
diff --git a/Makefile b/Makefile
index dffb32ae4..7c59f6027 100644
--- a/Makefile
+++ b/Makefile
@@ -38,7 +38,7 @@ Options:
BINS Binaries to build. Default is all binaries under cmd.
This option is available when using: make {build}(.multiarch)
- Example: make build BINS="open_im_api open_im_cms_api".
+ Example: make build BINS="openim_api openim_cms_api".
PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64.
This option is available when using: make {build}.multiarch
diff --git a/cmd/openim_api/Makefile b/cmd/openim_api/Makefile
index 480c9c298..4fe47f51f 100644
--- a/cmd/openim_api/Makefile
+++ b/cmd/openim_api/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_api
+NAME=openim_api
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim_api/deploy.Dockerfile b/cmd/openim_api/deploy.Dockerfile
index a236c02f0..24a17af37 100644
--- a/cmd/openim_api/deploy.Dockerfile
+++ b/cmd/openim_api/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_api ./
+COPY ./openim_api ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_api","--port", "10002"]
+CMD ["./openim_api","--port", "10002"]
diff --git a/cmd/openim_cmdutils/Makefile b/cmd/openim_cmdutils/Makefile
index 1ed0829fd..9c51aee84 100644
--- a/cmd/openim_cmdutils/Makefile
+++ b/cmd/openim_cmdutils/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_cmd_utils
+NAME=openim_cmd_utils
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim_crontask/Makefile b/cmd/openim_crontask/Makefile
index 4103d7cd5..1f09bf396 100644
--- a/cmd/openim_crontask/Makefile
+++ b/cmd/openim_crontask/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_cron_task
+NAME=openim_cron_task
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim_crontask/deploy.Dockerfile b/cmd/openim_crontask/deploy.Dockerfile
index e80006def..07d328474 100644
--- a/cmd/openim_crontask/deploy.Dockerfile
+++ b/cmd/openim_crontask/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_cron_task ./
+COPY ./openim_cron_task ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_cron_task"]
+CMD ["./openim_cron_task"]
diff --git a/cmd/openim_msggateway/Makefile b/cmd/openim_msggateway/Makefile
index 0bb3b41f5..07cad40a9 100644
--- a/cmd/openim_msggateway/Makefile
+++ b/cmd/openim_msggateway/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_msg_gateway
+NAME=openim_msg_gateway
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
@@ -32,4 +32,3 @@ install:build
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
-
diff --git a/cmd/openim_msggateway/deploy.Dockerfile b/cmd/openim_msggateway/deploy.Dockerfile
index 7310fe0dc..9ecc83e95 100644
--- a/cmd/openim_msggateway/deploy.Dockerfile
+++ b/cmd/openim_msggateway/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_msg_gateway ./
+COPY ./openim_msg_gateway ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_msg_gateway","--port", "10140" "--ws_port", "10001", "--prometheus_port", "20240"]
+CMD ["./openim_msg_gateway","--port", "10140" "--ws_port", "10001", "--prometheus_port", "20240"]
diff --git a/cmd/openim_msgtransfer/Makefile b/cmd/openim_msgtransfer/Makefile
index ca6355aa4..dc22834de 100644
--- a/cmd/openim_msgtransfer/Makefile
+++ b/cmd/openim_msgtransfer/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_msg_transfer
+NAME=openim_msg_transfer
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim_msgtransfer/deploy.Dockerfile b/cmd/openim_msgtransfer/deploy.Dockerfile
index 0c9485694..91767adf4 100644
--- a/cmd/openim_msgtransfer/deploy.Dockerfile
+++ b/cmd/openim_msgtransfer/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_msg_transfer ./
+COPY ./openim_msg_transfer ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_msg_transfer","--prometheus_port", "21400"]
+CMD ["./openim_msg_transfer","--prometheus_port", "21400"]
diff --git a/cmd/openim_push/Makefile b/cmd/openim_push/Makefile
index 064dd2df1..c67882553 100644
--- a/cmd/openim_push/Makefile
+++ b/cmd/openim_push/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_push
+NAME=openim_push
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim_push/deploy.Dockerfile b/cmd/openim_push/deploy.Dockerfile
index 79b8cb4f1..9b9a542c3 100644
--- a/cmd/openim_push/deploy.Dockerfile
+++ b/cmd/openim_push/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_push ./
+COPY ./openim_push ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_push", "--port", "10170", "--prometheus_port", "20170"]
+CMD ["./openim_push", "--port", "10170", "--prometheus_port", "20170"]
diff --git a/cmd/openim_rpc/openim_rpc_auth/Makefile b/cmd/openim_rpc/openim_rpc_auth/Makefile
index 4c3f622a7..f702786ae 100644
--- a/cmd/openim_rpc/openim_rpc_auth/Makefile
+++ b/cmd/openim_rpc/openim_rpc_auth/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_auth
+NAME=openim_auth
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim_rpc/openim_rpc_auth/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_auth/deploy.Dockerfile
index a7b69cc0a..1fc1682dd 100644
--- a/cmd/openim_rpc/openim_rpc_auth/deploy.Dockerfile
+++ b/cmd/openim_rpc/openim_rpc_auth/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_auth ./
+COPY ./openim_auth ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_auth", "--port", "10160"]
+CMD ["./openim_auth", "--port", "10160"]
diff --git a/cmd/openim_rpc/openim_rpc_conversation/Makefile b/cmd/openim_rpc/openim_rpc_conversation/Makefile
index 833e9f651..fa973060e 100644
--- a/cmd/openim_rpc/openim_rpc_conversation/Makefile
+++ b/cmd/openim_rpc/openim_rpc_conversation/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_conversation
+NAME=openim_conversation
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim_rpc/openim_rpc_conversation/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_conversation/deploy.Dockerfile
index 4e7591499..5aab79104 100644
--- a/cmd/openim_rpc/openim_rpc_conversation/deploy.Dockerfile
+++ b/cmd/openim_rpc/openim_rpc_conversation/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_conversation ./
+COPY ./openim_conversation ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_conversation", "--port", "10230", "--prometheus_port","20230"]
+CMD ["./openim_conversation", "--port", "10230", "--prometheus_port","20230"]
diff --git a/cmd/openim_rpc/openim_rpc_friend/Makefile b/cmd/openim_rpc/openim_rpc_friend/Makefile
index bf04b74e1..8cbb39c2b 100644
--- a/cmd/openim_rpc/openim_rpc_friend/Makefile
+++ b/cmd/openim_rpc/openim_rpc_friend/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_friend
+NAME=openim_friend
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
@@ -32,5 +32,3 @@ install:build
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
-
-
diff --git a/cmd/openim_rpc/openim_rpc_friend/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_friend/deploy.Dockerfile
index d159ee0dd..3aaf86885 100644
--- a/cmd/openim_rpc/openim_rpc_friend/deploy.Dockerfile
+++ b/cmd/openim_rpc/openim_rpc_friend/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_friend ./
+COPY ./openim_friend ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_friend", "--port", "10120", "--prometheus_port","20120"]
+CMD ["./openim_friend", "--port", "10120", "--prometheus_port","20120"]
diff --git a/cmd/openim_rpc/openim_rpc_group/Makefile b/cmd/openim_rpc/openim_rpc_group/Makefile
index 123d50945..b33dbb259 100644
--- a/cmd/openim_rpc/openim_rpc_group/Makefile
+++ b/cmd/openim_rpc/openim_rpc_group/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_group
+NAME=openim_group
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
@@ -32,8 +32,3 @@ install:build
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
-
-
-
-
-
diff --git a/cmd/openim_rpc/openim_rpc_group/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_group/deploy.Dockerfile
index e676708d5..1adb00bc5 100644
--- a/cmd/openim_rpc/openim_rpc_group/deploy.Dockerfile
+++ b/cmd/openim_rpc/openim_rpc_group/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_group ./
+COPY ./openim_group ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_group", "--port", "10150", "--prometheus_port","20150"]
+CMD ["./openim_group", "--port", "10150", "--prometheus_port","20150"]
diff --git a/cmd/openim_rpc/openim_rpc_msg/Makefile b/cmd/openim_rpc/openim_rpc_msg/Makefile
index 6270183f8..b27c5c420 100644
--- a/cmd/openim_rpc/openim_rpc_msg/Makefile
+++ b/cmd/openim_rpc/openim_rpc_msg/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_msg
+NAME=openim_msg
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
@@ -32,5 +32,3 @@ install:build
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
-
-
diff --git a/cmd/openim_rpc/openim_rpc_msg/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_msg/deploy.Dockerfile
index 8e6307ccb..10fd29f0a 100644
--- a/cmd/openim_rpc/openim_rpc_msg/deploy.Dockerfile
+++ b/cmd/openim_rpc/openim_rpc_msg/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_msg ./
+COPY ./openim_msg ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_msg", "--port", "10130", "--prometheus_port","20130"]
+CMD ["./openim_msg", "--port", "10130", "--prometheus_port","20130"]
diff --git a/cmd/openim_rpc/openim_rpc_third/Makefile b/cmd/openim_rpc/openim_rpc_third/Makefile
index fe44c27ef..b5a7c546a 100644
--- a/cmd/openim_rpc/openim_rpc_third/Makefile
+++ b/cmd/openim_rpc/openim_rpc_third/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_third
+NAME=openim_third
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
@@ -32,8 +32,3 @@ install:build
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
-
-
-
-
-
diff --git a/cmd/openim_rpc/openim_rpc_third/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_third/deploy.Dockerfile
index 462798b00..7b6a1dfaf 100644
--- a/cmd/openim_rpc/openim_rpc_third/deploy.Dockerfile
+++ b/cmd/openim_rpc/openim_rpc_third/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_third ./
+COPY ./openim_third ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_third", "--port", "10200"]
+CMD ["./openim_third", "--port", "10200"]
diff --git a/cmd/openim_rpc/openim_rpc_user/Makefile b/cmd/openim_rpc/openim_rpc_user/Makefile
index 9c7f03d5d..aef2d605a 100644
--- a/cmd/openim_rpc/openim_rpc_user/Makefile
+++ b/cmd/openim_rpc/openim_rpc_user/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=open_im_user
+NAME=openim_user
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
@@ -32,8 +32,3 @@ install:build
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
-
-
-
-
-
diff --git a/cmd/openim_rpc/openim_rpc_user/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_user/deploy.Dockerfile
index 047698788..0977dd634 100644
--- a/cmd/openim_rpc/openim_rpc_user/deploy.Dockerfile
+++ b/cmd/openim_rpc/openim_rpc_user/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./open_im_user ./
+COPY ./openim_user ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./open_im_user", "--port", "10110"]
+CMD ["./openim_user", "--port", "10110"]
diff --git a/docker-compose.yaml b/docker-compose.yaml
index cbf361de1..db3ba4bcc 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -99,9 +99,9 @@ services:
command: minio server /data --console-address ':9090'
- open_im_server:
- image: openim/open_im_server:v3.0.1
- container_name: open_im_server
+ openim_server:
+ image: openim/openim_server:v3.0.1
+ container_name: openim_server
volumes:
- ./logs:/Open-IM-Server/logs
- ./config/config.yaml:/Open-IM-Server/config/config.yaml
@@ -131,7 +131,7 @@ services:
- mongodb
- redis
- minio
- - open_im_server
+ - openim_server
network_mode: "host"
logging:
driver: json-file
@@ -147,7 +147,7 @@ services:
# ports:
# - 9091:9091
depends_on:
- - open_im_server
+ - openim_server
command: --web.listen-address=:9091 --config.file="/etc/prometheus/prometheus.yml"
network_mode: "host"
diff --git a/scripts/build_images.sh b/scripts/build_images.sh
index ad47cdb24..a94bc91d6 100755
--- a/scripts/build_images.sh
+++ b/scripts/build_images.sh
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-image=openim/open_im_server:v1.0.5
+image=openim/openim_server:v1.0.5
rm Open-IM-Server -rf
git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive
cd Open-IM-Server
diff --git a/scripts/check_all.sh b/scripts/check_all.sh
index 16fec32ff..15507102a 100755
--- a/scripts/check_all.sh
+++ b/scripts/check_all.sh
@@ -34,7 +34,7 @@ for i in ${service_port_name[*]}; do
list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}')
list_to_string $list
for j in ${ports_array}; do
- port=$(ss -tunlp| grep open_im | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
+ port=$(ss -tunlp| grep openim | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
if [[ ${port} -ne ${j} ]]; then
echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX}
echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX}
diff --git a/scripts/enterprise/check_all.sh b/scripts/enterprise/check_all.sh
index f439404f1..893e1bf32 100755
--- a/scripts/enterprise/check_all.sh
+++ b/scripts/enterprise/check_all.sh
@@ -29,7 +29,7 @@ for i in ${service_port_name[*]}; do
list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}')
list_to_string $list
for j in ${ports_array}; do
- port=$(ss -tunlp| grep open_im | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
+ port=$(ss -tunlp| grep openim | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
if [[ ${port} -ne ${j} ]]; then
echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX}
echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX}
@@ -39,4 +39,3 @@ for i in ${service_port_name[*]}; do
fi
done
done
-
diff --git a/scripts/enterprise/path_info.cfg b/scripts/enterprise/path_info.cfg
index 7106ac5d5..29d3112c1 100644
--- a/scripts/enterprise/path_info.cfg
+++ b/scripts/enterprise/path_info.cfg
@@ -1,7 +1,7 @@
#Don't put the space between "="
-demo_server_name="open_im_chat_api"
+demo_server_name="openim_chat_api"
demo_server_binary_root="../bin/"
@@ -21,9 +21,9 @@ service_source_root=(
#service filename
service_names=(
#api service filename
- open_im_chat_api
- open_im_admin_api
+ openim_chat_api
+ openim_admin_api
#rpc service filename
- open_im_admin
- open_im_chat
+ openim_admin
+ openim_chat
)
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index de1e6b74e..f0042e043 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -71,20 +71,20 @@ EXCLUDE_TESTS=github.com/OpenIMSDK/Open-IM-Server/test github.com/OpenIMSDK/Open
# ❯ tree -L 1 cmd
# cmd
# ├── openim-sdk-core/ - main.go
-# ├── open_im_api
-# ├── open_im_cms_api
-# ├── open_im_cron_task
-# ├── open_im_demo
-# ├── open_im_msg_gateway
-# ├── open_im_msg_transfer
-# ├── open_im_push
-# ├── rpc/open_im_admin_cms/ - main.go
+# ├── openim_api
+# ├── openim_cms_api
+# ├── openim_cron_task
+# ├── openim_demo
+# ├── openim_msg_gateway
+# ├── openim_msg_transfer
+# ├── openim_push
+# ├── rpc/openim_admin_cms/ - main.go
# └── test/ - main.go
# COMMAND=openim
# PLATFORM=linux_amd64
# OS=linux
# ARCH=amd64
-# BINS=open_im_api open_im_cms_api open_im_cron_task open_im_demo open_im_msg_gateway open_im_msg_transfer open_im_push
+# BINS=openim_api openim_cms_api openim_cron_task openim_demo openim_msg_gateway openim_msg_transfer openim_push
# BIN_DIR=/root/workspaces/OpenIM/_output/bin
# ==============================================================================
diff --git a/scripts/path_info.cfg b/scripts/path_info.cfg
index f406d11fe..530455f36 100644
--- a/scripts/path_info.cfg
+++ b/scripts/path_info.cfg
@@ -1,35 +1,35 @@
#Don't put the space between "="
-msg_gateway_name="open_im_msg_gateway"
+msg_gateway_name="openim_msg_gateway"
msg_gateway_binary_root="../bin/"
msg_gateway_source_root="../cmd/msggateway/"
-msg_name="open_im_msg"
+msg_name="openim_msg"
msg_binary_root="../bin/"
msg_source_root="../cmd/rpc/msg/"
-push_name="open_im_push"
+push_name="openim_push"
push_binary_root="../bin/"
push_source_root="../cmd/push/"
-msg_transfer_name="open_im_msg_transfer"
+msg_transfer_name="openim_msg_transfer"
msg_transfer_binary_root="../bin/"
msg_transfer_source_root="../cmd/msgtransfer/"
msg_transfer_service_num=4
-sdk_server_name="open_im_sdk_server"
+sdk_server_name="openim_sdk_server"
sdk_server_binary_root="../bin/"
sdk_server_source_root="../cmd/Open-IM-SDK-Core/"
-cron_task_name="open_im_cron_task"
+cron_task_name="openim_cron_task"
cron_task_binary_root="../bin/"
cron_task_source_root="../cmd/crontask/"
-cmd_utils_name="open_im_cmd_utils"
+cmd_utils_name="openim_cmd_utils"
cmd_utils_binary_root="../bin/"
cmd_utils_source_root="../cmd/cmduitls/"
@@ -57,15 +57,15 @@ service_source_root=(
#service filename
service_names=(
#api service filename
- open_im_api
+ openim_api
#rpc service filename
- open_im_user
- open_im_friend
- open_im_group
- open_im_auth
- open_im_conversation
- open_im_third
- open_im_cron_task
+ openim_user
+ openim_friend
+ openim_group
+ openim_auth
+ openim_conversation
+ openim_third
+ openim_cron_task
${msg_gateway_name}
${msg_transfer_name}
${msg_name}
diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh
index f6bafe58b..d0c2f721d 100755
--- a/scripts/start_rpc_service.sh
+++ b/scripts/start_rpc_service.sh
@@ -21,15 +21,15 @@ source ./function.sh
#service filename
service_filename=(
#api
- open_im_api
+ openim_api
#rpc
- open_im_user
- open_im_friend
- open_im_group
- open_im_auth
+ openim_user
+ openim_friend
+ openim_group
+ openim_auth
${msg_name}
- open_im_conversation
- open_im_third
+ openim_conversation
+ openim_third
)
#service config port name
From 80a4e35c0f71abacb1fa649529cb61fd1c37c7ce Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Wed, 5 Jul 2023 15:32:47 +0800
Subject: [PATCH 25/73] fix: remove test file
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
test/mongo/cmd/main.go | 61 --------------------------------
test/mongo/mongo_utils.go | 74 ---------------------------------------
test/mysql/cmd/main.go | 23 ------------
test/mysql/importuser.go | 70 ------------------------------------
4 files changed, 228 deletions(-)
delete mode 100644 test/mongo/cmd/main.go
delete mode 100644 test/mongo/mongo_utils.go
delete mode 100644 test/mysql/cmd/main.go
delete mode 100644 test/mysql/importuser.go
diff --git a/test/mongo/cmd/main.go b/test/mongo/cmd/main.go
deleted file mode 100644
index 7873fee90..000000000
--- a/test/mongo/cmd/main.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "Open_IM/pkg/common/config"
- mongo2 "Open_IM/test/mongo"
- "context"
- "flag"
- "fmt"
-
- "go.mongodb.org/mongo-driver/mongo"
- "go.mongodb.org/mongo-driver/mongo/options"
-)
-
-func init() {
- uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
- if config.Config.Mongo.DBUri != "" {
- // example:
- // mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$DBMaxPoolSize
- uri = config.Config.Mongo.DBUri
- } else {
- if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" {
- uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress[0],
- config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize)
- } else {
- uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
- config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
- config.Config.Mongo.DBMaxPoolSize)
- }
- }
- var err error
- mongo2.Client, err = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
- if err != nil {
- panic(err)
- }
- err = mongo2.Client.Ping(context.TODO(), nil)
- if err != nil {
- panic(err)
- }
- fmt.Println("Connected to MongoDB!")
-}
-
-func main() {
- userID := flag.String("userID", "", "userID")
- flag.Parse()
- fmt.Println("userID:", *userID)
- mongo2.GetUserAllChat(*userID)
-}
diff --git a/test/mongo/mongo_utils.go b/test/mongo/mongo_utils.go
deleted file mode 100644
index 18cdcbea3..000000000
--- a/test/mongo/mongo_utils.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package mongo
-
-import (
- "Open_IM/pkg/common/config"
- server_api_params "Open_IM/pkg/proto/sdk_ws"
- "context"
- "fmt"
- "time"
-
- "github.com/golang/protobuf/proto"
- "go.mongodb.org/mongo-driver/mongo"
- "gopkg.in/mgo.v2/bson"
-)
-
-var (
- Client *mongo.Client
-)
-
-type MsgInfo struct {
- SendTime int64
- Msg []byte
-}
-
-type UserChat struct {
- UID string
- Msg []MsgInfo
-}
-
-func GetUserAllChat(uid string) {
- ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
- collection := Client.Database(config.Config.Mongo.DBDatabase).Collection("msg")
- var userChatList []UserChat
- uid = uid + ":"
- filter := bson.M{"uid": bson.M{"$regex": uid}}
- //filter := bson.M{"uid": "17726378428:0"}
- result, err := collection.Find(context.Background(), filter)
- if err != nil {
- fmt.Println("find error", err.Error())
- return
- }
- if err := result.All(ctx, &userChatList); err != nil {
- fmt.Println(err.Error())
- }
- for _, userChat := range userChatList {
- for _, msg := range userChat.Msg {
- msgData := &server_api_params.MsgData{}
- err := proto.Unmarshal(msg.Msg, msgData)
- if err != nil {
- fmt.Println(err.Error(), msg)
- continue
- }
- fmt.Println("seq: ", msgData.Seq, "status: ", msgData.Status,
- "sendID: ", msgData.SendID, "recvID: ", msgData.RecvID,
- "sendTime: ", msgData.SendTime,
- "clientMsgID: ", msgData.ClientMsgID,
- "serverMsgID: ", msgData.ServerMsgID,
- "content: ", string(msgData.Content))
- }
- }
-}
diff --git a/test/mysql/cmd/main.go b/test/mysql/cmd/main.go
deleted file mode 100644
index b3d73b8db..000000000
--- a/test/mysql/cmd/main.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "Open_IM/test/mysql"
-)
-
-func main() {
- mysql.ImportUserToSuperGroup()
-}
diff --git a/test/mysql/importuser.go b/test/mysql/importuser.go
deleted file mode 100644
index 07d97340d..000000000
--- a/test/mysql/importuser.go
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package mysql
-
-import (
- "Open_IM/pkg/common/db"
- "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
- "Open_IM/pkg/common/log"
- "strconv"
- "time"
-)
-
-func ImportUserToSuperGroup() {
- for i := 18000000700; i <= 18000000800; i++ {
- user := db.User{
- UserID: strconv.Itoa(i),
- Nickname: strconv.Itoa(i),
- FaceURL: "",
- Gender: 0,
- PhoneNumber: strconv.Itoa(i),
- Birth: time.Time{},
- Email: "",
- Ex: "",
- CreateTime: time.Time{},
- AppMangerLevel: 0,
- GlobalRecvMsgOpt: 0,
- }
- err := im_mysql_model.UserRegister(user)
- if err != nil {
- log.NewError("", err.Error(), user)
- continue
- }
-
- groupMember := db.GroupMember{
- GroupID: "3907826375",
- UserID: strconv.Itoa(i),
- Nickname: strconv.Itoa(i),
- FaceURL: "",
- RoleLevel: 0,
- JoinTime: time.Time{},
- JoinSource: 0,
- InviterUserID: "openIMAdmin",
- OperatorUserID: "openIMAdmin",
- MuteEndTime: time.Time{},
- Ex: "",
- }
-
- err = im_mysql_model.InsertIntoGroupMember(groupMember)
- if err != nil {
- log.NewError("", err.Error(), user)
- continue
- }
-
- log.NewInfo("success", i)
-
- }
-
-}
From 74b849f4bc20c407b8c2cd2f0f2ebbf40fe662fb Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Wed, 5 Jul 2023 15:35:33 +0800
Subject: [PATCH 26/73] feat: add code comment
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
cmd/openim_msggateway/deploy.Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/openim_msggateway/deploy.Dockerfile b/cmd/openim_msggateway/deploy.Dockerfile
index 9ecc83e95..eab3d16db 100644
--- a/cmd/openim_msggateway/deploy.Dockerfile
+++ b/cmd/openim_msggateway/deploy.Dockerfile
@@ -29,4 +29,4 @@ COPY ./openim_msg_gateway ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim_msg_gateway","--port", "10140" "--ws_port", "10001", "--prometheus_port", "20240"]
+CMD ["./openim_msg_gateway","--port", "10140" "--ws_port", "10001", "--prometheus_port", "20240"]
From ae2369c3a93a5a2298c3ce88e5874906a3cd8e3e Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Wed, 5 Jul 2023 17:11:51 +0800
Subject: [PATCH 27/73] feat: add scripts
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
CONTRIBUTING.md | 2 +-
Makefile | 2 +-
docs/.generated_docs | 84 ++++++++++++++++++++++++++++++++++++
scripts/README.md | 30 +++++++++++++
scripts/common.sh | 23 +++++++---
scripts/githooks/pre-commit | 2 +-
scripts/lib/golang.sh | 20 ++++++---
scripts/lib/release.sh | 33 +++++++++++---
scripts/lib/util.sh | 53 +++++++++++++++--------
scripts/make-rules/common.mk | 10 ++---
10 files changed, 215 insertions(+), 44 deletions(-)
create mode 100644 docs/.generated_docs
create mode 100644 scripts/README.md
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 21359aff6..b29008183 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -89,7 +89,7 @@ To propose PR for the Open-IM-Server item, we assume you have registered a GitHu
1. Fork the repository(Open-IM-Server)
-2. **CLONE** your own repository to master locally. Use `git clone https://github.com//Open-IM-Server.git` to clone repository to your local machine. Then you can create new branches to finish the change you wish to make.
+2. **CLONE** your own repository to main locally. Use `git clone https://github.com//Open-IM-Server.git` to clone repository to your local machine. Then you can create new branches to finish the change you wish to make.
3. **Set Remote** upstream to be `https://github.com/OpenIMSDK/Open-IM-Server.git` using the following two commands:
diff --git a/Makefile b/Makefile
index 7c59f6027..179f986dc 100644
--- a/Makefile
+++ b/Makefile
@@ -42,7 +42,7 @@ Options:
PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64.
This option is available when using: make {build}.multiarch
- Example: make build.multiarch PLATFORMS="linux_s390x linux_mips64
+ Example: make multiarch PLATFORMS="linux_s390x linux_mips64
linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64".
V Set to 1 enable verbose build. Default is 0.
diff --git a/docs/.generated_docs b/docs/.generated_docs
new file mode 100644
index 000000000..380e2878d
--- /dev/null
+++ b/docs/.generated_docs
@@ -0,0 +1,84 @@
+docs/.generated_docs
+docs/guide/en-US/cmd/iam-apiserver.md
+docs/guide/en-US/cmd/iam-authz-server.md
+docs/guide/en-US/cmd/iam-pump.md
+docs/guide/en-US/cmd/iam-watcher.md
+docs/guide/en-US/cmd/iamctl/iamctl.md
+docs/guide/en-US/cmd/iamctl/iamctl_color.md
+docs/guide/en-US/cmd/iamctl/iamctl_completion.md
+docs/guide/en-US/cmd/iamctl/iamctl_info.md
+docs/guide/en-US/cmd/iamctl/iamctl_jwt.md
+docs/guide/en-US/cmd/iamctl/iamctl_jwt_show.md
+docs/guide/en-US/cmd/iamctl/iamctl_jwt_sign.md
+docs/guide/en-US/cmd/iamctl/iamctl_jwt_verify.md
+docs/guide/en-US/cmd/iamctl/iamctl_new.md
+docs/guide/en-US/cmd/iamctl/iamctl_options.md
+docs/guide/en-US/cmd/iamctl/iamctl_policy.md
+docs/guide/en-US/cmd/iamctl/iamctl_policy_create.md
+docs/guide/en-US/cmd/iamctl/iamctl_policy_delete.md
+docs/guide/en-US/cmd/iamctl/iamctl_policy_get.md
+docs/guide/en-US/cmd/iamctl/iamctl_policy_list.md
+docs/guide/en-US/cmd/iamctl/iamctl_policy_update.md
+docs/guide/en-US/cmd/iamctl/iamctl_secret.md
+docs/guide/en-US/cmd/iamctl/iamctl_secret_create.md
+docs/guide/en-US/cmd/iamctl/iamctl_secret_delete.md
+docs/guide/en-US/cmd/iamctl/iamctl_secret_get.md
+docs/guide/en-US/cmd/iamctl/iamctl_secret_list.md
+docs/guide/en-US/cmd/iamctl/iamctl_secret_update.md
+docs/guide/en-US/cmd/iamctl/iamctl_set.md
+docs/guide/en-US/cmd/iamctl/iamctl_user.md
+docs/guide/en-US/cmd/iamctl/iamctl_user_create.md
+docs/guide/en-US/cmd/iamctl/iamctl_user_delete.md
+docs/guide/en-US/cmd/iamctl/iamctl_user_get.md
+docs/guide/en-US/cmd/iamctl/iamctl_user_list.md
+docs/guide/en-US/cmd/iamctl/iamctl_user_update.md
+docs/guide/en-US/cmd/iamctl/iamctl_validate.md
+docs/guide/en-US/cmd/iamctl/iamctl_version.md
+docs/guide/en-US/yaml/iamctl/iamctl.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_color.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_completion.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_info.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_jwt.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_new.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_options.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_policy.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_secret.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_set.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_user.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_validate.yaml
+docs/guide/en-US/yaml/iamctl/iamctl_version.yaml
+docs/man/man1/iam-apiserver.1
+docs/man/man1/iam-authz-server.1
+docs/man/man1/iam-pump.1
+docs/man/man1/iam-watcher.1
+docs/man/man1/iamctl-color.1
+docs/man/man1/iamctl-completion.1
+docs/man/man1/iamctl-info.1
+docs/man/man1/iamctl-jwt-show.1
+docs/man/man1/iamctl-jwt-sign.1
+docs/man/man1/iamctl-jwt-verify.1
+docs/man/man1/iamctl-jwt.1
+docs/man/man1/iamctl-new.1
+docs/man/man1/iamctl-options.1
+docs/man/man1/iamctl-policy-create.1
+docs/man/man1/iamctl-policy-delete.1
+docs/man/man1/iamctl-policy-get.1
+docs/man/man1/iamctl-policy-list.1
+docs/man/man1/iamctl-policy-update.1
+docs/man/man1/iamctl-policy.1
+docs/man/man1/iamctl-secret-create.1
+docs/man/man1/iamctl-secret-delete.1
+docs/man/man1/iamctl-secret-get.1
+docs/man/man1/iamctl-secret-list.1
+docs/man/man1/iamctl-secret-update.1
+docs/man/man1/iamctl-secret.1
+docs/man/man1/iamctl-set.1
+docs/man/man1/iamctl-user-create.1
+docs/man/man1/iamctl-user-delete.1
+docs/man/man1/iamctl-user-get.1
+docs/man/man1/iamctl-user-list.1
+docs/man/man1/iamctl-user-update.1
+docs/man/man1/iamctl-user.1
+docs/man/man1/iamctl-validate.1
+docs/man/man1/iamctl-version.1
+docs/man/man1/iamctl.1
diff --git a/scripts/README.md b/scripts/README.md
new file mode 100644
index 000000000..04bda00ae
--- /dev/null
+++ b/scripts/README.md
@@ -0,0 +1,30 @@
+# `/scripts`
+
+## Supported platforms
+
+- Linux x86_64 (linux_amd64) : 64-bit Linux for most desktop and server systems.
+
+- Windows x86_64 (windows_amd64) : 64-bit version for most Windows operating systems.
+
+- macOS x86_64 (darwin_amd64) : 64-bit version for Apple Macintosh computers.
+
+- Linux ARM64 (linux_arm64) : For ARM-based 64-bit Linux systems such as Raspberry Pi 4 and Jetson Nano.
+
+- Linux s390x (linux_s390x) : 64-bit Linux for IBM System z hosts.
+
+- Linux MIPS64 (linux_mips64) : 64-bit Linux for MIPS architecture.
+
+- Linux MIPS64LE (linux_mips64le) : Suitable for 64-bit Linux systems with little endian MIPS architecture.
+
+
+
+## examples
+Scripts to perform various build, install, analysis, etc operations.
+
+These scripts keep the root level Makefile small and simple.
+
+Examples:
+
+* https://github.com/kubernetes/helm/tree/master/scripts
+* https://github.com/cockroachdb/cockroach/tree/master/scripts
+* https://github.com/hashicorp/terraform/tree/master/scripts
\ No newline at end of file
diff --git a/scripts/common.sh b/scripts/common.sh
index 3a2090b6f..396f1c4a2 100755
--- a/scripts/common.sh
+++ b/scripts/common.sh
@@ -89,11 +89,22 @@ openim::build::get_docker_wrapped_binaries() {
local debian_iptables_version=v12.1.0
### If you change any of these lists, please also update DOCKERIZED_BINARIES
### in build/BUILD. And openim::golang::server_image_targets
+
local targets=(
- "openim-apiserver,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
- "openim-controller-manager,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
- "openim-scheduler,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
- "openim-proxy,${OPENIM_BASE_IMAGE_REGISTRY}/debian-iptables-${arch}:${debian_iptables_version}"
+ "openim-api,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-cmdutils,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-crontask,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-msggateway,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-msgtransfer,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-push,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-rpc-auth,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-rpc-conversation,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-rpc-friend,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-rpc-group,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-rpc-msg,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-rpc-third,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+ "openim-rpc-user,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
+
)
echo "${targets[@]}"
@@ -189,7 +200,7 @@ function openim::build::prepare_docker_machine() {
local virtualbox_memory_mb=$(( available_memory_bytes / (bytes_in_mb * memory_divisor) ))
docker-machine inspect "${DOCKER_MACHINE_NAME}" &> /dev/null || {
- openim::log::status "Creating a machine to build IAM"
+ openim::log::status "Creating a machine to build OPENIM"
docker-machine create --driver "${DOCKER_MACHINE_DRIVER}" \
--virtualbox-memory "${virtualbox_memory_mb}" \
--engine-env HTTP_PROXY="${IAMRNETES_HTTP_PROXY:-}" \
@@ -503,5 +514,5 @@ function openim::build::ensure_data_container() {
# Build all openim commands.
function openim::build::build_command() {
openim::log::status "Running build command..."
- make -C "${OPENIM_ROOT}" build.multiarch BINS="openimctl openim-apiserver openim-authz-server openim-pump openim-watcher"
+ make -C "${OPENIM_ROOT}" multiarch
}
diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit
index dbd84edef..8fbee166c 100644
--- a/scripts/githooks/pre-commit
+++ b/scripts/githooks/pre-commit
@@ -26,7 +26,7 @@
LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)"
-valid_branch_regex="^(main|master|develop)$|(feature|feat|release|hotfix|test|bug|ci|style|)\/[a-z0-9._-]+$|^HEAD$"
+valid_branch_regex="^(main|master|develop)$|(feature|feat|openim|release|hotfix|test|bug|ci|cicd|style|)\/[a-z0-9._-]+$|^HEAD$"
YELLOW="\e[93m"
GREEN="\e[32m"
diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh
index 1353ec2d2..56e34703b 100755
--- a/scripts/lib/golang.sh
+++ b/scripts/lib/golang.sh
@@ -33,10 +33,20 @@ readonly OPENIM_SUPPORTED_CLIENT_PLATFORMS=(
# If you update this list, please also update build/BUILD.
openim::golang::server_targets() {
local targets=(
- openim-apiserver
- openim-authz-server
- openim-pump
- openim-watcher
+ openim_api
+ openim_cmdutils
+ openim_cmdutils
+ openim_crontask
+ openim_msggateway
+ openim_msgtransfer
+ openim_push
+ openim_rpc_auth
+ openim_rpc_conversation
+ openim_rpc_friend
+ openim_rpc_group
+ openim_rpc_msg
+ openim_rpc_third
+ openim_rpc_user
)
echo "${targets[@]}"
}
@@ -137,7 +147,7 @@ openim::golang::setup_platforms
# The set of client targets that we are building for all platforms
# If you update this list, please also update build/BUILD.
readonly OPENIM_CLIENT_TARGETS=(
- iamctl
+ imctl
)
readonly OPENIM_CLIENT_BINARIES=("${OPENIM_CLIENT_TARGETS[@]##*/}")
diff --git a/scripts/lib/release.sh b/scripts/lib/release.sh
index e596afaff..a299a8943 100755
--- a/scripts/lib/release.sh
+++ b/scripts/lib/release.sh
@@ -137,12 +137,13 @@ function openim::release::package_src_tarball() {
! \( \
\( -path "${OPENIM_ROOT}"/_\* -o \
-path "${OPENIM_ROOT}"/.git\* -o \
+ -path "${OPENIM_ROOT}"/.github\* -o \
-path "${OPENIM_ROOT}"/.gitignore\* -o \
- -path "${OPENIM_ROOT}"/.gsemver.yaml\* -o \
+ -path "${OPENIM_ROOT}"/.gsemver.yml\* -o \
-path "${OPENIM_ROOT}"/.config\* -o \
-path "${OPENIM_ROOT}"/.chglog\* -o \
-path "${OPENIM_ROOT}"/.gitlint -o \
- -path "${OPENIM_ROOT}"/.golangci.yaml -o \
+ -path "${OPENIM_ROOT}"/.golangci.yml -o \
-path "${OPENIM_ROOT}"/.goreleaser.yml -o \
-path "${OPENIM_ROOT}"/.note.md -o \
-path "${OPENIM_ROOT}"/.todo.md \
@@ -274,6 +275,15 @@ function openim::release::sha1() {
fi
}
+function openim::release::sha256() {
+ if which sha256sum >/dev/null 2>&1; then
+ sha256sum "$1" | awk '{ print $1 }'
+ else
+ shasum -a256 "$1" | awk '{ print $1 }'
+ fi
+}
+
+
function openim::release::build_conformance_image() {
local -r arch="$1"
local -r registry="$2"
@@ -396,10 +406,19 @@ function openim::release::package_iam_manifests_tarball() {
local dst_dir="${release_stage}"
mkdir -p "${dst_dir}"
cp -r ${src_dir}/* "${dst_dir}"
- #cp "${src_dir}/openim-apiserver.yaml" "${dst_dir}"
- #cp "${src_dir}/openim-authz-server.yaml" "${dst_dir}"
- #cp "${src_dir}/openim-pump.yaml" "${dst_dir}"
- #cp "${src_dir}/openim-watcher.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-api.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_cmdutils.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_crontask.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_msggateway.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_msgtransfer.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_push.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_rpc_auth.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_rpc_conversation.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_rpc_friend.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_rpc_group.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_rpc_msg.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_rpc_third.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim_rpc_user.yaml" "${dst_dir}"
#cp "${OPENIM_ROOT}/cluster/gce/gci/health-monitor.sh" "${dst_dir}/health-monitor.sh"
openim::release::clean_cruft
@@ -603,5 +622,5 @@ function openim::release::generate_changelog() {
set +o errexit
git add ${OPENIM_ROOT}/CHANGELOG/CHANGELOG-${OPENIM_GIT_VERSION#v}.md
git commit -a -m "docs(changelog): add CHANGELOG-${OPENIM_GIT_VERSION#v}.md"
- git push -f origin master # 最后将 CHANGELOG 也 push 上去
+ git push -f origin main # 最后将 CHANGELOG 也 push 上去
}
diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh
index 2f32dac99..dee1cad74 100755
--- a/scripts/lib/util.sh
+++ b/scripts/lib/util.sh
@@ -64,7 +64,7 @@ openim::util::wait_for_url() {
return 1
}
-# Example: openim::util::wait_for_success 120 5 "iamctl get nodes|grep localhost"
+# Example: openim::util::wait_for_success 120 5 "imctl get nodes|grep localhost"
# arguments: wait time, sleep time, shell command
# returns 0 if the shell command get output, 1 otherwise.
openim::util::wait_for_success(){
@@ -212,7 +212,7 @@ openim::util::find-binary() {
openim::util::find-binary-for-platform "$1" "$(openim::util::host_platform)"
}
-# Run all known doc generators (today gendocs and genman for iamctl)
+# Run all known doc generators (today gendocs and genman for imctl)
# $1 is the directory to put those generated documents
openim::util::gen-docs() {
local dest="$1"
@@ -228,25 +228,42 @@ openim::util::gen-docs() {
# least from k/k tree), remove it completely.
openim::util::sourced_variable "${genfeddocs}"
- mkdir -p "${dest}/docs/guide/en-US/cmd/iamctl/"
- "${gendocs}" "${dest}/docs/guide/en-US/cmd/iamctl/"
+ mkdir -p "${dest}/docs/guide/en-US/cmd/imctl/"
+ "${gendocs}" "${dest}/docs/guide/en-US/cmd/imctl/"
mkdir -p "${dest}/docs/guide/en-US/cmd/"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-apiserver"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-authz-server"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-pump"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-watcher"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/iamctl" "iamctl"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_api"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_cmdutils"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_crontask"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_msggateway"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_msgtransfer"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_push"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_auth"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_conversation"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_friend"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_group"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_msg"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_third"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_user"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/imctl" "imctl"
mkdir -p "${dest}/docs/man/man1/"
- "${genman}" "${dest}/docs/man/man1/" "openim-apiserver"
- "${genman}" "${dest}/docs/man/man1/" "openim-authz-server"
- "${genman}" "${dest}/docs/man/man1/" "openim-pump"
- "${genman}" "${dest}/docs/man/man1/" "openim-watcher"
- "${genman}" "${dest}/docs/man/man1/" "iamctl"
-
- mkdir -p "${dest}/docs/guide/en-US/yaml/iamctl/"
- "${genyaml}" "${dest}/docs/guide/en-US/yaml/iamctl/"
+"${genman}" "${dest}/docs/man/man1/" "openim_api"
+"${genman}" "${dest}/docs/man/man1/" "openim_cmdutils"
+"${genman}" "${dest}/docs/man/man1/" "openim_crontask"
+"${genman}" "${dest}/docs/man/man1/" "openim_msggateway"
+"${genman}" "${dest}/docs/man/man1/" "openim_msgtransfer"
+"${genman}" "${dest}/docs/man/man1/" "openim_push"
+"${genman}" "${dest}/docs/man/man1/" "openim_rpc_auth"
+"${genman}" "${dest}/docs/man/man1/" "openim_rpc_conversation"
+"${genman}" "${dest}/docs/man/man1/" "openim_rpc_friend"
+"${genman}" "${dest}/docs/man/man1/" "openim_rpc_group"
+"${genman}" "${dest}/docs/man/man1/" "openim_rpc_msg"
+"${genman}" "${dest}/docs/man/man1/" "openim_rpc_third"
+"${genman}" "${dest}/docs/man/man1/" "openim_rpc_user"
+
+ mkdir -p "${dest}/docs/guide/en-US/yaml/imctl/"
+ "${genyaml}" "${dest}/docs/guide/en-US/yaml/imct/"
# create the list of generated files
pushd "${dest}" > /dev/null || return 1
@@ -471,7 +488,7 @@ EOF
# flatten the iamconfig files to make them self contained
username=$(whoami)
${sudo} /usr/bin/env bash -e < "/tmp/${client_id}.iamconfig"
+ $(openim::util::find-binary imct) --iamconfig="${dest_dir}/${client_id}.iamconfig" config view --minify --flatten > "/tmp/${client_id}.iamconfig"
mv -f "/tmp/${client_id}.iamconfig" "${dest_dir}/${client_id}.iamconfig"
chown ${username} "${dest_dir}/${client_id}.iamconfig"
EOF
diff --git a/scripts/make-rules/common.mk b/scripts/make-rules/common.mk
index 5019ebc77..179643b12 100644
--- a/scripts/make-rules/common.mk
+++ b/scripts/make-rules/common.mk
@@ -147,18 +147,18 @@ endef
# Here are some examples of builds
define MAKEFILE_EXAMPLE
-# make build BINS=imctl Only a single imctl binary is built.
+# make build BINS=openim_api Only a single openim_api binary is built.
# make -j (nproc) all Run tidy gen add-copyright format lint cover build concurrently.
# make gen Generate all necessary files.
-# make linux.arm64 imctl is compiled on arm64 platform.
+# make release Build release binaries for all platforms.
# make verify-copyright Verify the license headers for all files.
# make install-deepcopy-gen Install deepcopy-gen tools if the license is missing.
-# make build BINS=imctl V=1 DEBUG=1 Build debug binaries for only imctl.
-# make multiarch PLATFORMS="linux_arm64 linux_amd64" V=1 Build binaries for both platforms.
+# make build BINS=openim_api V=1 DEBUG=1 Build debug binaries for only openim_api.
+# make multiarch -j PLATFORMS="linux_arm64 linux_amd64" V=1 Build binaries for both platforms.
endef
export MAKEFILE_EXAMPLE
-# Define all help functions @printf "\n\033[1mCurrent imctl version information: $(shell imctl version):\033[0m\n\n"
+# Define all help functions @printf "\n\033[1mCurrent openim_api version information: $(shell openim_api version):\033[0m\n\n"
define makeallhelp
@printf "\n\033[1mMake example:\033[0m\n\n"
$(call MAKEFILE_EXAMPLE)
From d30131166db208ee6d507267a48e265d75d43190 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Wed, 5 Jul 2023 22:12:48 +0800
Subject: [PATCH 28/73] feat: add make file
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.github/sync.yml | 12 +++
Makefile | 61 +++++++--------
docs/contrib/cicd-actions.md | 127 +++++++++++++++++++++++++++++++
docs/contrib/code_conventions.md | 38 +++++++++
scripts/common.sh | 18 ++---
scripts/lib/release.sh | 8 +-
scripts/lib/util.sh | 1 +
scripts/make-rules/common.mk | 2 +-
scripts/make-rules/image.mk | 7 ++
9 files changed, 230 insertions(+), 44 deletions(-)
create mode 100644 docs/contrib/cicd-actions.md
create mode 100644 docs/contrib/code_conventions.md
diff --git a/.github/sync.yml b/.github/sync.yml
index 859096c6f..fdc003a0f 100644
--- a/.github/sync.yml
+++ b/.github/sync.yml
@@ -28,6 +28,9 @@ OpenIMSDK/openim-sdk-core:
- source: .github/workflows/stale.yml
dest: .github/workflows/stale.yml
replace: false
+ - source: .github/.codecov.yml
+ dest: .github/.codecov.yml
+ replace: false
OpenIMSDK/OpenIM-Docs:
- source: .github/workflows/
@@ -38,6 +41,9 @@ OpenIMSDK/OpenIM-Docs:
- source: scripts/githooks/
dest: scripts/githooks/
replace: true
+ - source: .github/.codecov.yml
+ dest: .github/.codecov.yml
+ replace: false
OpenIMSDK/OpenKF:
- source: LICENSE
@@ -51,6 +57,9 @@ OpenIMSDK/OpenKF:
- source: .github/workflows/stale.yml
dest: .github/workflows/stale.yml
replace: false
+ - source: .github/.codecov.yml
+ dest: .github/.codecov.yml
+ replace: false
group:
# first group:common to all warehouses
@@ -75,6 +84,9 @@ group:
- source: .github/workflows/help-comment-issue.yml
dest: .github/workflows/help-comment-issue.yml
replace: false
+ - source: .github/.codecov.yml
+ dest: .github/.codecov.yml
+ replace: false
- source: ./scripts/githooks/
dest: ./scripts/githooks/
replace: true
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 179f986dc..8b827e91b 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@
.DEFAULT_GOAL := help
+## all: Run tidy, gen, add-copyright, format, lint, cover, build ✨
.PHONY: all
all: tidy gen add-copyright format lint cover build
@@ -52,135 +53,135 @@ export USAGE_OPTIONS
# ==============================================================================
# Targets
-## build: Build binaries by default
+## build: Build binaries by default ✨
.PHONY: build
build:
@$(MAKE) go.build
-## multiarch: Build binaries for multiple platforms. See option PLATFORMS.
+## multiarch: Build binaries for multiple platforms. See option PLATFORMS. ✨
.PHONY: multiarch
multiarch:
@$(MAKE) go.build.multiarch
-## tidy: tidy go.mod
+## tidy: tidy go.mod ✨
.PHONY: tidy
tidy:
@$(GO) mod tidy
-## vendor: vendor go.mod
+## vendor: vendor go.mod ✨
.PHONY: vendor
vendor:
@$(GO) mod vendor
-## style: code style -> fmt,vet,lint
+## style: code style -> fmt,vet,lint ✨
.PHONY: style
style: fmt vet lint
-## fmt: Run go fmt against code.
+## fmt: Run go fmt against code. ✨
.PHONY: fmt
fmt:
@$(GO) fmt ./...
-## vet: Run go vet against code.
+## vet: Run go vet against code. ✨
.PHONY: vet
vet:
@$(GO) vet ./...
-## lint: Check syntax and styling of go sources.
+lint: Check syntax and styling of go sources. ✨
.PHONY: lint
lint:
@$(MAKE) go.lint
-## format: Gofmt (reformat) package sources (exclude vendor dir if existed).
+## format: Gofmt (reformat) package sources (exclude vendor dir if existed). ✨
.PHONY: format
format:
@$(MAKE) go.format
-## test: Run unit test.
+## test: Run unit test. ✨
.PHONY: test
test:
@$(MAKE) go.test
-## cover: Run unit test and get test coverage.
-.PHONY: cover
+## cover: Run unit test and get test coverage. ✨
+.PHONY: cover
cover:
@$(MAKE) go.test.cover
-## updates: Check for updates to go.mod dependencies
+## updates: Check for updates to go.mod dependencies ✨
.PHONY: updates
@$(MAKE) go.updates
-## imports: task to automatically handle import packages in Go files using goimports tool
+## imports: task to automatically handle import packages in Go files using goimports tool ✨
.PHONY: imports
imports:
@$(MAKE) go.imports
-## clean: Remove all files that are created by building.
+## clean: Remove all files that are created by building. ✨
.PHONY: clean
clean:
@$(MAKE) go.clean
-## image: Build docker images for host arch.
+## image: Build docker images for host arch. ✨
.PHONY: image
image:
@$(MAKE) image.build
-## image.multiarch: Build docker images for multiple platforms. See option PLATFORMS.
+## image.multiarch: Build docker images for multiple platforms. See option PLATFORMS. ✨
.PHONY: image.multiarch
image.multiarch:
@$(MAKE) image.build.multiarch
-## push: Build docker images for host arch and push images to registry.
+## push: Build docker images for host arch and push images to registry. ✨
.PHONY: push
push:
@$(MAKE) image.push
-## push.multiarch: Build docker images for multiple platforms and push images to registry.
+## push.multiarch: Build docker images for multiple platforms and push images to registry. ✨
.PHONY: push.multiarch
push.multiarch:
@$(MAKE) image.push.multiarch
-## tools: Install dependent tools.
+## tools: Install dependent tools. ✨
.PHONY: tools
tools:
@$(MAKE) tools.install
-## gen: Generate all necessary files.
+## gen: Generate all necessary files. ✨
.PHONY: gen
gen:
@$(MAKE) gen.run
-## swagger: Generate swagger document.
+## swagger: Generate swagger document. ✨
.PHONY: swagger
swagger:
@$(MAKE) swagger.run
-## serve-swagger: Serve swagger spec and docs.
+## serve-swagger: Serve swagger spec and docs. ✨
.PHONY: swagger.serve
serve-swagger:
@$(MAKE) swagger.serve
-## verify-copyright: Verify the license headers for all files.
+## verify-copyright: Verify the license headers for all files. ✨
.PHONY: verify-copyright
verify-copyright:
@$(MAKE) copyright.verify
-## add-copyright: Add copyright ensure source code files have license headers.
+## add-copyright: Add copyright ensure source code files have license headers. ✨
.PHONY: add-copyright
add-copyright:
@$(MAKE) copyright.add
-## release: release the project
+## release: release the project ✨
.PHONY: release
release: release.verify release.ensure-tag
@scripts/release.sh
-## help: Show this help info.
+## help: Show this help info. ✨
.PHONY: help
help: Makefile
$(call makehelp)
-## help-all: Show all help details info.
+## help-all: Show all help details info. ✨
.PHONY: help-all
-help-all: go.help copyright.help tools.help image.help help
- $(call makeallhelp)
+help-all: go.help copyright.help tools.help image.help dependencies.help gen.help release.help swagger.help help
+ $(call makeallhelp)
\ No newline at end of file
diff --git a/docs/contrib/cicd-actions.md b/docs/contrib/cicd-actions.md
new file mode 100644
index 000000000..7a581d3fa
--- /dev/null
+++ b/docs/contrib/cicd-actions.md
@@ -0,0 +1,127 @@
+# Continuous Integration and Automation
+
+Every change on the K3s repository, either made through a pull request or direct push, triggers the continuous integration pipelines defined within the same repository. Needless to say, all the K3s contributions can be merged until all the checks pass (AKA having green builds).
+
+- [Continuous Integration and Automation](#continuous-integration-and-automation)
+ - [CI Platforms](#ci-platforms)
+ - [GitHub Actions](#github-actions)
+ - [Running locally](#running-locally)
+
+## CI Platforms
+
+Currently, there are two different platforms involved in running the CI processes:
+
+- GitHub actions
+- Drone pipelines on CNCF infrastructure
+
+### GitHub Actions
+
+All the existing GitHub Actions are defined as YAML files under the `.github/workflows` directory. These can be grouped into:
+
+- **PR Checks**. These actions run all the required validations upon PR creation and update. Covering the DCO compliance check, `x86_64` test batteries (unit, integration, smoke), and code coverage.
+- **Repository automation**. Currently, it only covers issues and epic grooming.
+
+Everything runs on GitHub's provided runners; thus, the tests are limited to run in `x86_64` architectures.
+
+
+## Running locally
+
+A contributor should verify their changes locally to speed up the pull request process. Fortunately, all the CI steps can be on local environments, except for the publishing ones, through either of the following methods:
+
+**User Makefile:**
+```bash
+root@PS2023EVRHNCXG:~/workspaces/openim/Open-IM-Server# make help 😊
+
+Usage: make ...
+
+Targets:
+
+all Run tidy, gen, add-copyright, format, lint, cover, build 🚀
+build Build binaries by default 🛠️
+multiarch Build binaries for multiple platforms. See option PLATFORMS. 🌍
+tidy tidy go.mod ✨
+vendor vendor go.mod 📦
+style code style -> fmt,vet,lint 💅
+fmt Run go fmt against code. ✨
+vet Run go vet against code. ✅
+lint Check syntax and styling of go sources. ✔️
+format Gofmt (reformat) package sources (exclude vendor dir if existed). 🔄
+test Run unit test. 🧪
+cover Run unit test and get test coverage. 📊
+updates Check for updates to go.mod dependencies 🆕
+imports task to automatically handle import packages in Go files using goimports tool 📥
+clean Remove all files that are created by building. 🗑️
+image Build docker images for host arch. 🐳
+image.multiarch Build docker images for multiple platforms. See option PLATFORMS. 🌍🐳
+push Build docker images for host arch and push images to registry. 📤🐳
+push.multiarch Build docker images for multiple platforms and push images to registry. 🌍📤🐳
+tools Install dependent tools. 🧰
+gen Generate all necessary files. 🧩
+swagger Generate swagger document. 📖
+serve-swagger Serve swagger spec and docs. 🚀📚
+verify-copyright Verify the license headers for all files. ✅
+add-copyright Add copyright ensure source code files have license headers. 📄
+release release the project 🎉
+help Show this help info. ℹ️
+help-all Show all help details info. ℹ️📚
+
+Options:
+
+DEBUG Whether or not to generate debug symbols. Default is 0. ❓
+
+BINS Binaries to build. Default is all binaries under cmd. 🛠️
+This option is available when using: make {build}(.multiarch) 🧰
+Example: make build BINS="openim_api openim_cms_api".
+
+PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64. 🌍
+This option is available when using: make {build}.multiarch 🌍
+Example: make multiarch PLATFORMS="linux_s390x linux_mips64
+linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64".
+
+V Set to 1 enable verbose build. Default is 0. 📝
+```
+How to Use Makefile to Help Contributors Build Projects Quickly 😊
+
+The `make help` command is a handy tool that provides useful information on how to utilize the Makefile effectively. By running this command, contributors will gain insights into various targets and options available for building projects swiftly.
+
+Here's a breakdown of the targets and options provided by the Makefile:
+
+Targets 😃
+
+1. `all`: This target runs multiple tasks like `tidy`, `gen`, `add-copyright`, `format`, `lint`, `cover`, and `build`. It ensures comprehensive project building.
+2. `build`: The primary target that compiles binaries by default. It is particularly useful for creating the necessary executable files.
+3. `multiarch`: A target that builds binaries for multiple platforms. Contributors can specify the desired platforms using the `PLATFORMS` option.
+4. `tidy`: This target cleans up the `go.mod` file, ensuring its consistency.
+5. `vendor`: A target that updates the project dependencies based on the `go.mod` file.
+6. `style`: Checks the code style using tools like `fmt`, `vet`, and `lint`. It ensures a consistent coding style throughout the project.
+7. `fmt`: Formats the code using the `go fmt` command, ensuring proper indentation and formatting.
+8. `vet`: Runs the `go vet` command to identify common errors in the code.
+9. `lint`: Validates the syntax and styling of Go source files using a linter.
+10. `format`: Reformats the package sources using `gofmt`. It excludes the vendor directory if it exists.
+11. `test`: Executes unit tests to ensure the functionality and stability of the code.
+12. `cover`: Performs unit tests and calculates the test coverage of the code.
+13. `updates`: Checks for updates to the project's dependencies specified in the `go.mod` file.
+14. `imports`: Automatically handles import packages in Go files using the `goimports` tool.
+15. `clean`: Removes all files generated during the build process, effectively cleaning up the project directory.
+16. `image`: Builds Docker images for the host architecture.
+17. `image.multiarch`: Similar to the `image` target, but it builds Docker images for multiple platforms. Contributors can specify the desired platforms using the `PLATFORMS` option.
+18. `push`: Builds Docker images for the host architecture and pushes them to a registry.
+19. `push.multiarch`: Builds Docker images for multiple platforms and pushes them to a registry. Contributors can specify the desired platforms using the `PLATFORMS` option.
+20. `tools`: Installs the necessary tools or dependencies required by the project.
+21. `gen`: Generates all the required files automatically.
+22. `swagger`: Generates the swagger document for the project.
+23. `serve-swagger`: Serves the swagger specification and documentation.
+24. `verify-copyright`: Verifies the license headers for all project files.
+25. `add-copyright`: Adds copyright headers to the source code files.
+26. `release`: Releases the project, presumably for distribution.
+27. `help`: Displays information about available targets and options.
+28. `help-all`: Shows detailed information about all available targets and options.
+
+Options 😄
+
+1. `DEBUG`: A boolean option that determines whether or not to generate debug symbols. The default value is 0 (false).
+2. `BINS`: Specifies the binaries to build. By default, it builds all binaries under the `cmd` directory. Contributors can provide a list of specific binaries using this option.
+3. `PLATFORMS`: Specifies the platforms to build for. The default platforms are `linux_arm64` and `linux_amd64`. Contributors can specify multiple platforms by providing a space-separated list of platform names.
+4. `V`: A boolean option that enables verbose build output when set to 1 (true). The default value is 0 (false).
+
+With these targets and options in place, contributors can efficiently build projects using the Makefile. Happy coding! 🚀😊
diff --git a/docs/contrib/code_conventions.md b/docs/contrib/code_conventions.md
new file mode 100644
index 000000000..1387da2f7
--- /dev/null
+++ b/docs/contrib/code_conventions.md
@@ -0,0 +1,38 @@
+# Code conventions
+
+- [Code conventions](#code-conventions)
+ - [POSIX shell](#posix-shell)
+ - [Go](#go)
+ - [Directory and file conventions](#directory-and-file-conventions)
+ - [Testing conventions](#testing-conventions)
+
+## POSIX shell
+
+- [Style guide](https://google.github.io/styleguide/shell.xml)
+
+## Go
+
+- [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments)
+- [Effective Go](https://golang.org/doc/effective_go.html)
+- Know and avoid [Go landmines](https://gist.github.com/lavalamp/4bd23295a9f32706a48f)
+- Comment your code.
+ - [Go's commenting conventions](http://blog.golang.org/godoc-documenting-go-code)
+ - If reviewers ask questions about why the code is the way it is, that's a sign that comments might be helpful.
+- Command-line flags should use dashes, not underscores
+- Naming
+ - Please consider package name when selecting an interface name, and avoid redundancy. For example, `storage.Interface` is better than `storage.StorageInterface`.
+ - Do not use uppercase characters, underscores, or dashes in package names.
+ - Please consider parent directory name when choosing a package name. For example, `pkg/controllers/autoscaler/foo.go` should say `package autoscaler` not `package autoscalercontroller`.
+ - Unless there's a good reason, the `package foo` line should match the name of the directory in which the `.go` file exists.
+ - Importers can use a different name if they need to disambiguate.
+
+## Directory and file conventions
+
+- Avoid general utility packages. Packages called "util" are suspect. Instead, derive a name that describes your desired function. For example, the utility functions dealing with waiting for operations are in the `wait` package and include functionality like `Poll`. The full name is `wait.Poll`.
+- All filenames should be lowercase.
+- All source files and directories should use underscores, not dashes.
+ - Package directories should generally avoid using separators as much as possible. When package names are multiple words, they usually should be in nested subdirectories.
+
+## Testing conventions
+
+Please refer to [TESTING.md](../../tests/TESTING.md) document.
diff --git a/scripts/common.sh b/scripts/common.sh
index 396f1c4a2..8ae2abfa5 100755
--- a/scripts/common.sh
+++ b/scripts/common.sh
@@ -203,9 +203,9 @@ function openim::build::prepare_docker_machine() {
openim::log::status "Creating a machine to build OPENIM"
docker-machine create --driver "${DOCKER_MACHINE_DRIVER}" \
--virtualbox-memory "${virtualbox_memory_mb}" \
- --engine-env HTTP_PROXY="${IAMRNETES_HTTP_PROXY:-}" \
- --engine-env HTTPS_PROXY="${IAMRNETES_HTTPS_PROXY:-}" \
- --engine-env NO_PROXY="${IAMRNETES_NO_PROXY:-127.0.0.1}" \
+ --engine-env HTTP_PROXY="${OPENIMRNETES_HTTP_PROXY:-}" \
+ --engine-env HTTPS_PROXY="${OPENIMRNETES_HTTPS_PROXY:-}" \
+ --engine-env NO_PROXY="${OPENIMRNETES_NO_PROXY:-127.0.0.1}" \
"${DOCKER_MACHINE_NAME}" > /dev/null || {
openim::log::error "Something went wrong creating a machine."
openim::log::error "Try the following: "
@@ -250,14 +250,14 @@ function openim::build::update_dockerfile() {
}
function openim::build::set_proxy() {
- if [[ -n "${IAMRNETES_HTTPS_PROXY:-}" ]]; then
- echo "ENV https_proxy $IAMRNETES_HTTPS_PROXY" >> "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
+ if [[ -n "${OPENIMRNETES_HTTPS_PROXY:-}" ]]; then
+ echo "ENV https_proxy $OPENIMRNETES_HTTPS_PROXY" >> "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
fi
- if [[ -n "${IAMRNETES_HTTP_PROXY:-}" ]]; then
- echo "ENV http_proxy $IAMRNETES_HTTP_PROXY" >> "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
+ if [[ -n "${OPENIMRNETES_HTTP_PROXY:-}" ]]; then
+ echo "ENV http_proxy $OPENIMRNETES_HTTP_PROXY" >> "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
fi
- if [[ -n "${IAMRNETES_NO_PROXY:-}" ]]; then
- echo "ENV no_proxy $IAMRNETES_NO_PROXY" >> "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
+ if [[ -n "${OPENIMRNETES_NO_PROXY:-}" ]]; then
+ echo "ENV no_proxy $OPENIMRNETES_NO_PROXY" >> "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
fi
}
diff --git a/scripts/lib/release.sh b/scripts/lib/release.sh
index a299a8943..d6cdcdfcb 100755
--- a/scripts/lib/release.sh
+++ b/scripts/lib/release.sh
@@ -24,7 +24,7 @@
# Tencent cos configuration
readonly BUCKET="openim-1306374445"
-readonly REGION="ap-beijing"
+readonly REGION="ap-guangzhou"
readonly COS_RELEASE_DIR="openim-release"
# default cos command tool coscli or coscmd
@@ -178,7 +178,7 @@ function openim::release::package_server_tarballs() {
# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
# server_bins array.
- cp "${server_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
+ cp "${server_bins[@]/bin/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/server/bin/"
openim::release::clean_cruft
@@ -218,7 +218,7 @@ function openim::release::package_client_tarballs() {
# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
# client_bins array.
- cp "${client_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
+ cp "${client_bins[@]/bin/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/client/bin/"
openim::release::clean_cruft
@@ -252,7 +252,7 @@ function openim::release::build_server_images() {
# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
# OPENIM_SERVER_IMAGE_BINARIES array.
- cp "${OPENIM_SERVER_IMAGE_BINARIES[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
+ cp "${OPENIM_SERVER_IMAGE_BINARIES[@]/bin/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/server/bin/"
openim::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}"
diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh
index dee1cad74..63d32eb79 100755
--- a/scripts/lib/util.sh
+++ b/scripts/lib/util.sh
@@ -199,6 +199,7 @@ openim::util::find-binary-for-platform() {
"${OPENIM_ROOT}/_output/${platform}/${lookfor}"
"${OPENIM_ROOT}/_output/local/bin/${platform}/${lookfor}"
"${OPENIM_ROOT}/_output/platforms/${platform}/${lookfor}"
+ "${OPENIM_ROOT}/_output/platforms/bin/${platform}/${lookfor}"
)
# List most recently-updated location.
diff --git a/scripts/make-rules/common.mk b/scripts/make-rules/common.mk
index 179643b12..e99585a76 100644
--- a/scripts/make-rules/common.mk
+++ b/scripts/make-rules/common.mk
@@ -87,7 +87,7 @@ endif
# The OS must be linux when building docker images
# PLATFORMS ?= linux_amd64 linux_arm64
# The OS can be linux/windows/darwin when building binaries
-PLATFORMS ?= linux_s390x linux_mips64 linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64
+PLATFORMS ?= linux_s390x linux_mips64 linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64 linux_ppc64le
# only support linux
GOOS=linux
diff --git a/scripts/make-rules/image.mk b/scripts/make-rules/image.mk
index adcffa1cc..e70583c34 100644
--- a/scripts/make-rules/image.mk
+++ b/scripts/make-rules/image.mk
@@ -98,6 +98,13 @@ image.build.%: go.build.%
fi
@rm -rf $(TMP_DIR)/$(IMAGE)
+## image.buildx.%: Build docker images with buildx
+.PHONY: image.buildx.%
+image.buildx.%:
+ $(eval IMAGE := $(word 1,$(subst ., ,$*)))
+ echo "===========> Building docker image $(IMAGE) $(VERSION)"
+ $(DOCKER) buildx build -f $(ROOT_DIR)/Dockerfile --pull --no-cache --platform=$(PLATFORMS) --push . -t $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION)
+
## image.push: Push docker images
.PHONY: image.push
image.push: image.verify go.build.verify $(addprefix image.push., $(addprefix $(IMAGE_PLAT)., $(IMAGES)))
From 6484c32e2628ea72e43c6bffe13e958c091acf18 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Wed, 5 Jul 2023 22:36:15 +0800
Subject: [PATCH 29/73] docs: add more docs help deployer
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
docs/contrib/cicd-actions.md | 8 +--
docs/contrib/development.md | 80 +++++++++++++++++++++++++++
docs/contrib/git_workflow.md | 102 +++++++++++++++++++++++++++++++++++
3 files changed, 187 insertions(+), 3 deletions(-)
create mode 100644 docs/contrib/development.md
create mode 100644 docs/contrib/git_workflow.md
diff --git a/docs/contrib/cicd-actions.md b/docs/contrib/cicd-actions.md
index 7a581d3fa..2a95860be 100644
--- a/docs/contrib/cicd-actions.md
+++ b/docs/contrib/cicd-actions.md
@@ -1,6 +1,6 @@
# Continuous Integration and Automation
-Every change on the K3s repository, either made through a pull request or direct push, triggers the continuous integration pipelines defined within the same repository. Needless to say, all the K3s contributions can be merged until all the checks pass (AKA having green builds).
+Every change on the OpenIM repository, either made through a pull request or direct push, triggers the continuous integration pipelines defined within the same repository. Needless to say, all the OpenIM contributions can be merged until all the checks pass (AKA having green builds).
- [Continuous Integration and Automation](#continuous-integration-and-automation)
- [CI Platforms](#ci-platforms)
@@ -80,13 +80,15 @@ linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64".
V Set to 1 enable verbose build. Default is 0. 📝
```
+
+
How to Use Makefile to Help Contributors Build Projects Quickly 😊
The `make help` command is a handy tool that provides useful information on how to utilize the Makefile effectively. By running this command, contributors will gain insights into various targets and options available for building projects swiftly.
Here's a breakdown of the targets and options provided by the Makefile:
-Targets 😃
+**Targets 😃**
1. `all`: This target runs multiple tasks like `tidy`, `gen`, `add-copyright`, `format`, `lint`, `cover`, and `build`. It ensures comprehensive project building.
2. `build`: The primary target that compiles binaries by default. It is particularly useful for creating the necessary executable files.
@@ -117,7 +119,7 @@ Targets 😃
27. `help`: Displays information about available targets and options.
28. `help-all`: Shows detailed information about all available targets and options.
-Options 😄
+**Options 😄**
1. `DEBUG`: A boolean option that determines whether or not to generate debug symbols. The default value is 0 (false).
2. `BINS`: Specifies the binaries to build. By default, it builds all binaries under the `cmd` directory. Contributors can provide a list of specific binaries using this option.
diff --git a/docs/contrib/development.md b/docs/contrib/development.md
new file mode 100644
index 000000000..64aa08cda
--- /dev/null
+++ b/docs/contrib/development.md
@@ -0,0 +1,80 @@
+# Development Guide
+
+Since OpenIM is written in Go, it is fair to assume that the Go tools are all one needs to contribute to this project. Unfortunately, there is a point where this no longer holds true when required to test or build local changes. This document elaborates on the required tooling for OpenIM development.
+
+- [Development Guide](#development-guide)
+ - [Non-Linux environment prerequisites](#non-linux-environment-prerequisites)
+ - [Windows Setup](#windows-setup)
+ - [macOS Setup](#macos-setup)
+ - [Installing Required Software](#installing-required-software)
+ - [Go](#go)
+ - [Docker](#docker)
+ - [Vagrant](#vagrant)
+ - [Cloning, Building and Testing OpenIM](#cloning-building-and-testing-openim)
+ - [Dependency management](#dependency-management)
+
+## Non-Linux environment prerequisites
+
+All the test and build scripts within this repository were created to be run on GNU Linux development environments. Due to this, it is suggested to use the virtual machine defined on this repository's [Vagrantfile](../../Vagrantfile) to use them.
+
+Either way, if one still wants to build and test OpenIM on non-Linux environments, specific setups are to be followed.
+
+### Windows Setup
+
+To build OpenIM on Windows is only possible for versions that support Windows Subsystem for Linux (WSL). If the development environment in question has Windows 10, Version 2004, Build 19041 or higher, [follow these instructions to install WSL2](https://docs.microsoft.com/en-us/windows/wsl/install-win10); otherwise, use a Linux Virtual machine instead.
+
+### macOS Setup
+
+The shell scripts in charge of the build and test processes rely on GNU utils (i.e. `sed`), [which slightly differ on macOS](https://unix.stackexchange.com/a/79357), meaning that one must make some adjustments before using them.
+
+First, install the GNU utils:
+
+```sh
+brew install coreutils findutils gawk gnu-sed gnu-tar grep make
+```
+
+Then update the shell init script (i.e. `.bashrc`) to prepend the GNU Utils to the `$PATH` variable
+
+```sh
+GNUBINS="$(find /usr/local/opt -type d -follow -name gnubin -print)"
+
+for bindir in ${GNUBINS[@]}; do
+ PATH=$bindir:$PATH
+done
+
+export PATH
+```
+
+## Installing Required Software
+
+### Go
+
+It is well known that OpenIM is written in [Go](http://golang.org). Please follow the [Go Getting Started guide](https://golang.org/doc/install) to install and set up the Go tools used to compile and run the test batteries.
+
+| OpenIM | requires Go |
+|----------------|-------------|
+| 2.24 - 3.00 | 1.15 + |
+| 3.30 + | 1.18 + |
+
+### Docker
+
+OpenIM build and test processes development require Docker to run certain steps. [Follow the Docker website instructions to install Docker](https://docs.docker.com/get-docker/) in the development environment.
+
+### Vagrant
+
+As described in the [Testing documentation](../../tests/TESTING.md), all the smoke tests are run in virtual machines managed by Vagrant. To install Vagrant in the development environment, [follow the instructions from the Hashicorp website](https://www.vagrantup.com/downloads), alongside any of the following hypervisors:
+
+- [VirtualBox](https://www.virtualbox.org/)
+- [libvirt](https://libvirt.org/) and the [vagrant-libvirt plugin](https://github.com/vagrant-libvirt/vagrant-libvirt#installation)
+
+## Cloning, Building and Testing OpenIM
+
+These topics already have been addressed on their respective documents:
+
+- [Git Workflow](./git-workflow.md)
+- [Building](../../BUILDING.md)
+- [Testing](../../tests/TESTING.md)
+
+## Dependency management
+
+OpenIM uses [go modules](https://github.com/golang/go/wiki/Modules) to manage dependencies.
diff --git a/docs/contrib/git_workflow.md b/docs/contrib/git_workflow.md
new file mode 100644
index 000000000..1d21f9cdd
--- /dev/null
+++ b/docs/contrib/git_workflow.md
@@ -0,0 +1,102 @@
+# Git workflows
+
+This document is an overview of OpenIM git workflow. It includes conventions, tips, and how to maintain good repository hygiene.
+
+- [Git workflows](#git-workflows)
+ - [Branching model](#branching-model)
+ - [Branch naming conventions](#branch-naming-conventions)
+ - [Backport policy](#backport-policy)
+ - [Git operations](#git-operations)
+ - [Setting up](#setting-up)
+ - [Branching out](#branching-out)
+ - [Keeping local branches in sync](#keeping-local-branches-in-sync)
+ - [Pushing changes](#pushing-changes)
+
+## Branching model
+
+OpenIM project uses the [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow) as its branching model, where most of the changes come from repositories forks instead of branches within the same one.
+
+### Branch naming conventions
+
+Every forked repository works independently, meaning that any contributor can create branches with the name they see fit. However, it is worth noting that OpenIM mirrors [OpenIM version skew policy](https://github.com/OpenIMSDK/Open-IM-Server/releases) by maintaining release branches for the most recent three minor releases. The only exception is that the main branch mirrors the latest OpenIM release (3.10) instead of using a `release-` prefixed one.
+
+```text
+main -------------------------------------------. (OpenIM 3.10)
+release-3.0.0 \---------------|---------------. (OpenIM 3.00)
+release-2.4.0 \---------------. (OpenIM 2.40)
+```
+
+
+### Backport policy
+
+All new work happens on the main branch, which means that for most cases, one should branch out from there and create the pull request against it. If the change involves adding a feature or patching OpenIM, the maintainers will backport it into the supported release branches.
+
+## Git operations
+
+There are everyday tasks related to git that every contributor needs to perform, and this section elaborates on them.
+
+### Setting up
+
+Creating a OpenIM fork, cloning it, and setting its upstream remote can be summarized on:
+
+1. Visit
+2. Click the `Fork` button (top right) to establish a cloud-based fork
+3. Clone fork to local storage
+4. Add to your fork OpenIM remote as upstream
+
+Once cloned, in code it would look this way:
+
+```sh
+## Clone fork to local storage
+export user="your github profile name"
+git clone https://github.com/$user/OpenIM.git
+# or: git clone git@github.com:$user/OpenIM.git
+
+## Add OpenIM as upstream to your fork
+cd OpenIM
+git remote add upstream https://github.com/OpenIMSDK/Open-IM-Server.git
+# or: git remote add upstream git@github.com:OpenIMSDK/Open-IM-Server.git
+
+## Ensure to never push to upstream directly
+git remote set-url --push upstream no_push
+
+## Confirm that your remotes make sense:
+git remote -v
+```
+
+### Branching out
+
+Every time one wants to work on a new OpenIM feature, we do:
+
+1. Get local main branch up to date
+2. Create a new branch from the main one (i.e.: myfeature branch )
+
+In code it would look this way:
+
+```sh
+## Get local main up to date
+# Assuming the OpenIM clone is the current working directory
+git fetch upstream
+git checkout main
+git rebase upstream/main
+
+## Create a new branch from main
+git checkout -b myfeature
+```
+
+### Keeping local branches in sync
+
+Either when branching out from main or a release one, keep in mind it is worth checking if any change has been pushed upstream by doing:
+
+```sh
+git fetch upstream
+git rebase upstream/main
+```
+
+It is suggested to `fetch` then `rebase` instead of `pull` since the latter does a merge, which leaves merge commits. For this, one can consider changing the local repository configuration by doing `git config branch.autoSetupRebase always` to change the behavior of `git pull`, or another non-merge option such as `git pull --rebase`.
+
+### Pushing changes
+
+For commit messages and signatures please refer to the [CONTRIBUTING.md](../../CONTRIBUTING.md) document.
+
+Nobody should push directly to upstream, even if one has such contributor access; instead, prefer [Github's pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) mechanism to contribute back into OpenIM. For expectations and guidelines about pull requests, consult the [CONTRIBUTING.md](../../CONTRIBUTING.md) document.
From f7bd391ed75e266108b17f12f8b5155609ac7528 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 12:03:20 +0800
Subject: [PATCH 30/73] fix: optimization details
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
CONTRIBUTING.md | 1 -
Makefile | 8 +--
docs/.generated_docs | 150 +++++++++++++++++++++----------------------
scripts/lib/color.sh | 8 +--
4 files changed, 83 insertions(+), 84 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b29008183..24793b187 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -305,7 +305,6 @@ The documentation for Open-IM-Server includes:
+ [README.md](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/README.md): This file includes the basic information and instructions for getting started with Open-IM-Server.
+ [CONTRIBUTING.md](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CONTRIBUTING.md): This file contains guidelines for contributing to Open-IM-Server's codebase, such as how to submit issues, pull requests, and code reviews.
-+ [DEVELOPGUIDE.md](https://github.com/OpenIMSDK/.github/blob/main/DEVELOPGUIDE.md): This file provides a more in-depth guide to developing Open-IM-Server, including information on the project's architecture, coding conventions, and testing practices.
+ [Official Documentation](https://doc.rentsoft.cn/): This is the official documentation for Open-IM-Server, which includes comprehensive information on all of its features, configuration options, and troubleshooting tips.
Please obey the following rules to better format the docs, which would greatly improve the reading experience.
diff --git a/Makefile b/Makefile
index 8b827e91b..8d5c66eb5 100644
--- a/Makefile
+++ b/Makefile
@@ -39,11 +39,11 @@ Options:
BINS Binaries to build. Default is all binaries under cmd.
This option is available when using: make {build}(.multiarch)
- Example: make build BINS="openim_api openim_cms_api".
+ Example: make build BINS="openim_api openim_cmdutils".
PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64.
This option is available when using: make {build}.multiarch
- Example: make multiarch PLATFORMS="linux_s390x linux_mips64
+ Example: make multiarch PLATFORMS="linux_s390x linux_mips64
linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64".
V Set to 1 enable verbose build. Default is 0.
@@ -107,11 +107,11 @@ test:
cover:
@$(MAKE) go.test.cover
-## updates: Check for updates to go.mod dependencies ✨
+## updates: Check for updates to go.mod dependencies. ✨
.PHONY: updates
@$(MAKE) go.updates
-## imports: task to automatically handle import packages in Go files using goimports tool ✨
+## imports: task to automatically handle import packages in Go files using goimports tool. ✨
.PHONY: imports
imports:
@$(MAKE) go.imports
diff --git a/docs/.generated_docs b/docs/.generated_docs
index 380e2878d..d46d40d88 100644
--- a/docs/.generated_docs
+++ b/docs/.generated_docs
@@ -3,82 +3,82 @@ docs/guide/en-US/cmd/iam-apiserver.md
docs/guide/en-US/cmd/iam-authz-server.md
docs/guide/en-US/cmd/iam-pump.md
docs/guide/en-US/cmd/iam-watcher.md
-docs/guide/en-US/cmd/iamctl/iamctl.md
-docs/guide/en-US/cmd/iamctl/iamctl_color.md
-docs/guide/en-US/cmd/iamctl/iamctl_completion.md
-docs/guide/en-US/cmd/iamctl/iamctl_info.md
-docs/guide/en-US/cmd/iamctl/iamctl_jwt.md
-docs/guide/en-US/cmd/iamctl/iamctl_jwt_show.md
-docs/guide/en-US/cmd/iamctl/iamctl_jwt_sign.md
-docs/guide/en-US/cmd/iamctl/iamctl_jwt_verify.md
-docs/guide/en-US/cmd/iamctl/iamctl_new.md
-docs/guide/en-US/cmd/iamctl/iamctl_options.md
-docs/guide/en-US/cmd/iamctl/iamctl_policy.md
-docs/guide/en-US/cmd/iamctl/iamctl_policy_create.md
-docs/guide/en-US/cmd/iamctl/iamctl_policy_delete.md
-docs/guide/en-US/cmd/iamctl/iamctl_policy_get.md
-docs/guide/en-US/cmd/iamctl/iamctl_policy_list.md
-docs/guide/en-US/cmd/iamctl/iamctl_policy_update.md
-docs/guide/en-US/cmd/iamctl/iamctl_secret.md
-docs/guide/en-US/cmd/iamctl/iamctl_secret_create.md
-docs/guide/en-US/cmd/iamctl/iamctl_secret_delete.md
-docs/guide/en-US/cmd/iamctl/iamctl_secret_get.md
-docs/guide/en-US/cmd/iamctl/iamctl_secret_list.md
-docs/guide/en-US/cmd/iamctl/iamctl_secret_update.md
-docs/guide/en-US/cmd/iamctl/iamctl_set.md
-docs/guide/en-US/cmd/iamctl/iamctl_user.md
-docs/guide/en-US/cmd/iamctl/iamctl_user_create.md
-docs/guide/en-US/cmd/iamctl/iamctl_user_delete.md
-docs/guide/en-US/cmd/iamctl/iamctl_user_get.md
-docs/guide/en-US/cmd/iamctl/iamctl_user_list.md
-docs/guide/en-US/cmd/iamctl/iamctl_user_update.md
-docs/guide/en-US/cmd/iamctl/iamctl_validate.md
-docs/guide/en-US/cmd/iamctl/iamctl_version.md
-docs/guide/en-US/yaml/iamctl/iamctl.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_color.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_completion.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_info.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_jwt.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_new.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_options.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_policy.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_secret.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_set.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_user.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_validate.yaml
-docs/guide/en-US/yaml/iamctl/iamctl_version.yaml
+docs/guide/en-US/cmd/openim/openim.md
+docs/guide/en-US/cmd/openim/openim_color.md
+docs/guide/en-US/cmd/openim/openim_completion.md
+docs/guide/en-US/cmd/openim/openim_info.md
+docs/guide/en-US/cmd/openim/openim_jwt.md
+docs/guide/en-US/cmd/openim/openim_jwt_show.md
+docs/guide/en-US/cmd/openim/openim_jwt_sign.md
+docs/guide/en-US/cmd/openim/openim_jwt_verify.md
+docs/guide/en-US/cmd/openim/openim_new.md
+docs/guide/en-US/cmd/openim/openim_options.md
+docs/guide/en-US/cmd/openim/openim_policy.md
+docs/guide/en-US/cmd/openim/openim_policy_create.md
+docs/guide/en-US/cmd/openim/openim_policy_delete.md
+docs/guide/en-US/cmd/openim/openim_policy_get.md
+docs/guide/en-US/cmd/openim/openim_policy_list.md
+docs/guide/en-US/cmd/openim/openim_policy_update.md
+docs/guide/en-US/cmd/openim/openim_secret.md
+docs/guide/en-US/cmd/openim/openim_secret_create.md
+docs/guide/en-US/cmd/openim/openim_secret_delete.md
+docs/guide/en-US/cmd/openim/openim_secret_get.md
+docs/guide/en-US/cmd/openim/openim_secret_list.md
+docs/guide/en-US/cmd/openim/openim_secret_update.md
+docs/guide/en-US/cmd/openim/openim_set.md
+docs/guide/en-US/cmd/openim/openim_user.md
+docs/guide/en-US/cmd/openim/openim_user_create.md
+docs/guide/en-US/cmd/openim/openim_user_delete.md
+docs/guide/en-US/cmd/openim/openim_user_get.md
+docs/guide/en-US/cmd/openim/openim_user_list.md
+docs/guide/en-US/cmd/openim/openim_user_update.md
+docs/guide/en-US/cmd/openim/openim_validate.md
+docs/guide/en-US/cmd/openim/openim_version.md
+docs/guide/en-US/yaml/openim/openim.yaml
+docs/guide/en-US/yaml/openim/openim_color.yaml
+docs/guide/en-US/yaml/openim/openim_completion.yaml
+docs/guide/en-US/yaml/openim/openim_info.yaml
+docs/guide/en-US/yaml/openim/openim_jwt.yaml
+docs/guide/en-US/yaml/openim/openim_new.yaml
+docs/guide/en-US/yaml/openim/openim_options.yaml
+docs/guide/en-US/yaml/openim/openim_policy.yaml
+docs/guide/en-US/yaml/openim/openim_secret.yaml
+docs/guide/en-US/yaml/openim/openim_set.yaml
+docs/guide/en-US/yaml/openim/openim_user.yaml
+docs/guide/en-US/yaml/openim/openim_validate.yaml
+docs/guide/en-US/yaml/openim/openim_version.yaml
docs/man/man1/iam-apiserver.1
docs/man/man1/iam-authz-server.1
docs/man/man1/iam-pump.1
docs/man/man1/iam-watcher.1
-docs/man/man1/iamctl-color.1
-docs/man/man1/iamctl-completion.1
-docs/man/man1/iamctl-info.1
-docs/man/man1/iamctl-jwt-show.1
-docs/man/man1/iamctl-jwt-sign.1
-docs/man/man1/iamctl-jwt-verify.1
-docs/man/man1/iamctl-jwt.1
-docs/man/man1/iamctl-new.1
-docs/man/man1/iamctl-options.1
-docs/man/man1/iamctl-policy-create.1
-docs/man/man1/iamctl-policy-delete.1
-docs/man/man1/iamctl-policy-get.1
-docs/man/man1/iamctl-policy-list.1
-docs/man/man1/iamctl-policy-update.1
-docs/man/man1/iamctl-policy.1
-docs/man/man1/iamctl-secret-create.1
-docs/man/man1/iamctl-secret-delete.1
-docs/man/man1/iamctl-secret-get.1
-docs/man/man1/iamctl-secret-list.1
-docs/man/man1/iamctl-secret-update.1
-docs/man/man1/iamctl-secret.1
-docs/man/man1/iamctl-set.1
-docs/man/man1/iamctl-user-create.1
-docs/man/man1/iamctl-user-delete.1
-docs/man/man1/iamctl-user-get.1
-docs/man/man1/iamctl-user-list.1
-docs/man/man1/iamctl-user-update.1
-docs/man/man1/iamctl-user.1
-docs/man/man1/iamctl-validate.1
-docs/man/man1/iamctl-version.1
-docs/man/man1/iamctl.1
+docs/man/man1/openim-color.1
+docs/man/man1/openim-completion.1
+docs/man/man1/openim-info.1
+docs/man/man1/openim-jwt-show.1
+docs/man/man1/openim-jwt-sign.1
+docs/man/man1/openim-jwt-verify.1
+docs/man/man1/openim-jwt.1
+docs/man/man1/openim-new.1
+docs/man/man1/openim-options.1
+docs/man/man1/openim-policy-create.1
+docs/man/man1/openim-policy-delete.1
+docs/man/man1/openim-policy-get.1
+docs/man/man1/openim-policy-list.1
+docs/man/man1/openim-policy-update.1
+docs/man/man1/openim-policy.1
+docs/man/man1/openim-secret-create.1
+docs/man/man1/openim-secret-delete.1
+docs/man/man1/openim-secret-get.1
+docs/man/man1/openim-secret-list.1
+docs/man/man1/openim-secret-update.1
+docs/man/man1/openim-secret.1
+docs/man/man1/openim-set.1
+docs/man/man1/openim-user-create.1
+docs/man/man1/openim-user-delete.1
+docs/man/man1/openim-user-get.1
+docs/man/man1/openim-user-list.1
+docs/man/man1/openim-user-update.1
+docs/man/man1/openim-user.1
+docs/man/man1/openim-validate.1
+docs/man/man1/openim-version.1
+docs/man/man1/openim.1
diff --git a/scripts/lib/color.sh b/scripts/lib/color.sh
index 52caa78f8..c4bdefe25 100755
--- a/scripts/lib/color.sh
+++ b/scripts/lib/color.sh
@@ -14,18 +14,18 @@
# limitations under the License.
-#Define color variables
-#Feature
+# Define color variables
+# Feature
COLOR_NORMAL='\033[0m';COLOR_BOLD='\033[1m';COLOR_DIM='\033[2m';COLOR_UNDER='\033[4m';
COLOR_ITALIC='\033[3m';COLOR_NOITALIC='\033[23m';COLOR_BLINK='\033[5m';
COLOR_REVERSE='\033[7m';COLOR_CONCEAL='\033[8m';COLOR_NOBOLD='\033[22m';
COLOR_NOUNDER='\033[24m';COLOR_NOBLINK='\033[25m';
-#Front color
+# Front color
COLOR_BLACK='\033[30m';COLOR_RED='\033[31m';COLOR_GREEN='\033[32m';COLOR_YELLOW='\033[33m';
COLOR_BLUE='\033[34m';COLOR_MAGENTA='\033[35m';COLOR_CYAN='\033[36m';COLOR_WHITE='\033[37m';
-#background color
+# background color
COLOR_BBLACK='\033[40m';COLOR_BRED='\033[41m';
COLOR_BGREEN='\033[42m';COLOR_BYELLOW='\033[43m';
COLOR_BBLUE='\033[44m';COLOR_BMAGENTA='\033[45m';
From d6a89567e5190bc0dc3d7389c5f504306e63ce5f Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 18:20:08 +0800
Subject: [PATCH 31/73] feat: add all page
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/batch_start_all.sh | 3 -
scripts/build_all_service.sh | 106 +++++++++++++++++++++++++++++------
scripts/check_all.sh | 1 +
scripts/push_start.sh | 2 -
scripts/sdk_svr_start.sh | 60 --------------------
scripts/start_all.sh | 48 ++++++++++++----
scripts/style_info.cfg | 53 +++++++++++++++---
7 files changed, 172 insertions(+), 101 deletions(-)
delete mode 100755 scripts/sdk_svr_start.sh
diff --git a/scripts/batch_start_all.sh b/scripts/batch_start_all.sh
index e917d7003..119e85f65 100755
--- a/scripts/batch_start_all.sh
+++ b/scripts/batch_start_all.sh
@@ -22,7 +22,6 @@ need_to_start_server_shell=(
msg_gateway_start.sh
push_start.sh
msg_transfer_start.sh
- sdk_svr_start.sh
)
time=`date +"%Y-%m-%d %H:%M:%S"`
echo "==========================================================">>../logs/openIM.log 2>&1 &
@@ -70,5 +69,3 @@ if [ $success_num == ${#need_to_start_server_shell[*]} ]
then
echo -e ${YELLOW_PREFIX}"all services build success"${COLOR_SUFFIX}
fi
-
-
diff --git a/scripts/build_all_service.sh b/scripts/build_all_service.sh
index a6495939d..7359b39b3 100755
--- a/scripts/build_all_service.sh
+++ b/scripts/build_all_service.sh
@@ -17,11 +17,18 @@
source ./style_info.cfg
source ./path_info.cfg
source ./function.sh
+echo -e "\n"
+
+echo -e "${BACKGROUND_BLUE}===============> Building all using make build binary files ${COLOR_SUFFIX}"
+
+echo -e "\n"
+echo -e "${BOLD_PREFIX}_____ _ _ _____ _____ _____ _____ _____ _____ _____ _____ _____ ${COLOR_SUFFIX}"
+
bin_dir="../bin"
logs_dir="../logs"
sdk_db_dir="../db/sdk/"
-#Automatically created when there is no bin, logs folder
+# Automatically created when there is no bin, logs folder
if [ ! -d $bin_dir ]; then
mkdir -p $bin_dir
fi
@@ -32,19 +39,86 @@ if [ ! -d $sdk_db_dir ]; then
mkdir -p $sdk_db_dir
fi
-#begin path
-begin_path=$PWD
-
-for ((i = 0; i < ${#service_source_root[*]}; i++)); do
- cd $begin_path
- service_path=${service_source_root[$i]}
- cd $service_path
- make install
- if [ $? -ne 0 ]; then
- echo -e "${RED_PREFIX}${service_names[$i]} build failed ${COLOR_SUFFIX}\n"
- exit -1
- else
- echo -e "${GREEN_PREFIX}${service_names[$i]} successfully be built ${COLOR_SUFFIX}\n"
- fi
+# OpenIM root path
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+
+source ./style_info.cfg
+source ./path_info.cfg
+source ./function.sh
+
+#!/bin/bash
+
+cd $OPENIM_ROOT
+
+# Execute 'make build'
+make build
+
+# Get the current operating system and architecture
+OS=$(uname -s | tr '[:upper:]' '[:lower:]')
+ARCH=$(uname -m)
+
+# Select the repository home directory based on the operating system and architecture
+if [[ "$OS" == "darwin" ]]; then
+ if [[ "$ARCH" == "x86_64" ]]; then
+ REPO_DIR="darwin/amd64"
+ else
+ REPO_DIR="darwin/386"
+ fi
+elif [[ "$OS" == "linux" ]]; then
+ if [[ "$ARCH" == "x86_64" ]]; then
+ REPO_DIR="linux/amd64"
+ elif [[ "$ARCH" == "arm64" ]]; then
+ REPO_DIR="linux/arm64"
+ elif [[ "$ARCH" == "mips64" ]]; then
+ REPO_DIR="linux/mips64"
+ elif [[ "$ARCH" == "mips64le" ]]; then
+ REPO_DIR="linux/mips64le"
+ elif [[ "$ARCH" == "ppc64le" ]]; then
+ REPO_DIR="linux/ppc64le"
+ elif [[ "$ARCH" == "s390x" ]]; then
+ REPO_DIR="linux/s390x"
+ else
+ REPO_DIR="linux/386"
+ fi
+elif [[ "$OS" == "windows" ]]; then
+ if [[ "$ARCH" == "x86_64" ]]; then
+ REPO_DIR="windows/amd64"
+ else
+ REPO_DIR="windows/386"
+ fi
+else
+ echo -e "${RED_PREFIX}Unsupported OS: $OS${COLOR_SUFFIX}"
+ exit 1
+fi
+
+# Determine if all scripts were successfully built
+BUILD_SUCCESS=true
+FAILED_SCRIPTS=()
+
+for binary in $(find _output/bin/platforms/$REPO_DIR -type f); do
+ if [[ ! -x $binary ]]; then
+ FAILED_SCRIPTS+=("$binary")
+ BUILD_SUCCESS=false
+ fi
done
-echo -e ${YELLOW_PREFIX}"all services build success"${COLOR_SUFFIX}
+
+echo -e " \n"
+
+echo -e "${BOLD_PREFIX}=====================> Build Results <=====================${COLOR_SUFFIX}"
+
+echo -e " \n"
+
+if [[ "$BUILD_SUCCESS" == true ]]; then
+ echo -e "${GREEN_PREFIX}All binaries built successfully.${COLOR_SUFFIX}"
+else
+ echo -e "${RED_PREFIX}Some binary builds failed. Please check the following binary files:${COLOR_SUFFIX}"
+ for script in "${FAILED_SCRIPTS[@]}"; do
+ echo -e "${RED_PREFIX}$script${COLOR_SUFFIX}"
+ done
+fi
+
+echo -e " \n"
+
+echo -e "${BOLD_PREFIX}============================================================${COLOR_SUFFIX}"
+
+echo -e " \n"
diff --git a/scripts/check_all.sh b/scripts/check_all.sh
index 15507102a..65f51c0cf 100755
--- a/scripts/check_all.sh
+++ b/scripts/check_all.sh
@@ -17,6 +17,7 @@
source ./style_info.cfg
source ./path_info.cfg
source ./function.sh
+
service_port_name=(
openImWsPort
openImApiPort
diff --git a/scripts/push_start.sh b/scripts/push_start.sh
index d38936a2e..80da0f575 100755
--- a/scripts/push_start.sh
+++ b/scripts/push_start.sh
@@ -18,8 +18,6 @@ source ./style_info.cfg
source ./path_info.cfg
source ./function.sh
-
-
list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}')
list2=$(cat $config_path | grep pushPrometheusPort | awk -F '[:]' '{print $NF}')
list_to_string $list1
diff --git a/scripts/sdk_svr_start.sh b/scripts/sdk_svr_start.sh
deleted file mode 100755
index 29212887a..000000000
--- a/scripts/sdk_svr_start.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env bash
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#Include shell font styles and some basic information
-source ./style_info.cfg
-source ./path_info.cfg
-source ./function.sh
-ulimit -n 200000
-
-ws_address=$(cat $config_path | grep openImWsAddress | awk -F '[ ]' '{print $NF}')
-api_address=$(cat $config_path | grep openImApiAddress | awk -F '[ ]' '{print $NF}')
-list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}')
-logLevel=$(cat $config_path | grep remainLogLevel | awk -F '[:]' '{print $NF}')
-list_to_string $list3
-sdkws_ports=($ports_array)
-
-
-
-#Check if the service exists
-#If it is exists,kill this process
-check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l)
-if [ $check -ge 1 ]; then
- oldPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}')
- kill -9 ${oldPid}
-fi
-#Waiting port recycling
-sleep 1
-cd ${sdk_server_binary_root}
- echo "==========================start js sdk server===========================">>../logs/openIM.log
- nohup ./${sdk_server_name} -openIM_ws_address ${ws_address} -sdk_ws_port ${sdkws_ports[0]} -openIM_api_address ${api_address} -openIM_log_level ${logLevel} >>../logs/openIM.log 2>&1 &
-
-#Check launched service process
-sleep 3
-check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l)
-allPorts=""
-if [ $check -ge 1 ]; then
- allNewPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}')
- for i in $allNewPid; do
- ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}')
- allPorts=${allPorts}"$ports "
- done
- echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
-else
- echo -e ${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR PLEASE CHECK openIM.log"${COLOR_SUFFIX}
-fi
diff --git a/scripts/start_all.sh b/scripts/start_all.sh
index 1a86db7f3..c16ae3a11 100755
--- a/scripts/start_all.sh
+++ b/scripts/start_all.sh
@@ -16,30 +16,56 @@
#FIXME This script is the startup script for multiple servers.
#FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array.
-#FIXME Put the shell script names here
+#Include shell font styles and some basic information
+source ./style_info.cfg
+source ./path_info.cfg
+
+# Print title
+echo -e "${BOLD_PREFIX}${BLUE_PREFIX}OpenIM Server Start${COLOR_SUFFIX}"
+
+# Get current time
+time=$(date +"%Y-%m-%d %H:%M:%S")
+
+# Print section separator
+echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
+
+# Print server start time
+echo -e "${BOLD_PREFIX}${CYAN_PREFIX}Server Start Time: ${time}${COLOR_SUFFIX}"
+
+# Print section separator
+echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
+
+# FIXME Put the shell script names here
need_to_start_server_shell=(
start_rpc_service.sh
push_start.sh
msg_transfer_start.sh
-# sdk_svr_start.sh
msg_gateway_start.sh
start_cron.sh
)
-time=`date +"%Y-%m-%d %H:%M:%S"`
-echo "==========================================================" >> ../logs/openIM.log 2>&1 &
-echo "==========================================================" >> ../logs/openIM.log 2>&1 &
-echo "==========================================================" >> ../logs/openIM.log 2>&1 &
-echo "==========server start time:${time}===========" >> ../logs/openIM.log 2>&1 &
-echo "==========================================================" >> ../logs/openIM.log 2>&1 &
-echo "==========================================================" >> ../logs/openIM.log 2>&1 &
-echo "==========================================================" >> ../logs/openIM.log 2>&1 &
+# Loop through the script names and execute them
for i in ${need_to_start_server_shell[*]}; do
chmod +x $i
- echo "=====================exec ${i}======================" >> ../logs/openIM.log
+
+ echo -e ""
+ # Print script execution message
+ echo -e "=========> ${YELLOW_PREFIX}Executing ${i}...${COLOR_SUFFIX}"
+ echo -e ""
+
./$i
+
+ # Check if the script executed successfully
if [ $? -ne 0 ]; then
+ # Print error message and exit
+ echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${i}. Exiting...${COLOR_SUFFIX}"
exit -1
fi
done
+
+# Print section separator
+echo "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
+
+# Print completion message
+echo "${GREEN_PREFIX}${BOLD_PREFIX}OpenIM Server has been started successfully!${COLOR_SUFFIX}"
\ No newline at end of file
diff --git a/scripts/style_info.cfg b/scripts/style_info.cfg
index ff28dcb88..f0b6a32db 100644
--- a/scripts/style_info.cfg
+++ b/scripts/style_info.cfg
@@ -1,9 +1,44 @@
-#Shell font formatting information
-COLOR_SUFFIX="\033[0m"
-BLACK_PREFIX="\033[30m"
-RED_PREFIX="\033[31m"
-GREEN_PREFIX="\033[32m"
-YELLOW_PREFIX="\033[33m"
-BLUE_PREFIX="\033[34m"
-PURPLE_PREFIX="\033[35m"
-SKY_BLUE_PREFIX="\033[36m"
+COLOR_SUFFIX="\033[0m" # End all colors and special effects
+
+BLACK_PREFIX="\033[30m" # Black prefix
+RED_PREFIX="\033[31m" # Red prefix
+GREEN_PREFIX="\033[32m" # Green prefix
+YELLOW_PREFIX="\033[33m" # Yellow prefix
+BLUE_PREFIX="\033[34m" # Blue prefix
+PURPLE_PREFIX="\033[35m" # Purple prefix
+SKY_BLUE_PREFIX="\033[36m" # Sky blue prefix
+WHITE_PREFIX="\033[37m" # White prefix
+BOLD_PREFIX="\033[1m" # Bold prefix
+UNDERLINE_PREFIX="\033[4m" # Underline prefix
+ITALIC_PREFIX="\033[3m" # Italic prefix
+
+BACKGROUND_BLACK="\033[40m" # Black background
+BACKGROUND_RED="\033[41m" # Red background
+BACKGROUND_GREEN="\033[42m" # Green background
+BACKGROUND_YELLOW="\033[43m" # Yellow background
+BACKGROUND_BLUE="\033[44m" # Blue background
+BACKGROUND_PURPLE="\033[45m" # Purple background
+BACKGROUND_SKY_BLUE="\033[46m" # Sky blue background
+BACKGROUND_WHITE="\033[47m" # White background
+
+BLINK="\033[5m" # Blinking effect
+INVERT="\033[7m" # Invert color
+HIDE="\033[8m" # Hide text
+
+GRAY_PREFIX="\033[90m" # Gray prefix
+LIGHT_RED_PREFIX="\033[91m" # Light red prefix
+LIGHT_GREEN_PREFIX="\033[92m" # Light green prefix
+LIGHT_YELLOW_PREFIX="\033[93m" # Light yellow prefix
+LIGHT_BLUE_PREFIX="\033[94m" # Light blue prefix
+LIGHT_PURPLE_PREFIX="\033[95m" # Light purple prefix
+LIGHT_SKY_BLUE_PREFIX="\033[96m" # Light sky blue prefix
+LIGHT_WHITE_PREFIX="\033[97m" # Light white prefix
+
+BACKGROUND_GRAY="\033[100m" # Gray background
+BACKGROUND_LIGHT_RED="\033[101m" # Light red background
+BACKGROUND_LIGHT_GREEN="\033[102m" # Light green background
+BACKGROUND_LIGHT_YELLOW="\033[103m" # Light yellow background
+BACKGROUND_LIGHT_BLUE="\033[104m" # Light blue background
+BACKGROUND_LIGHT_PURPLE="\033[105m" # Light purple background
+BACKGROUND_LIGHT_SKY_BLUE="\033[106m" # Light sky blue background
+BACKGROUND_LIGHT_WHITE="\033[107m" # Light white background
From 3e7989c2e7bc36a245735621f0402cf9f85df2ef Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 19:45:32 +0800
Subject: [PATCH 32/73] fix: binary name modification
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.gitignore | 14 +-
Makefile | 2 +-
cmd/openim_api/Makefile | 34 -----
cmd/openim_api/deploy.Dockerfile | 32 ----
cmd/openim_api/main.go | 102 -------------
cmd/openim_cmdutils/Makefile | 34 -----
cmd/openim_cmdutils/main.go | 59 --------
cmd/openim_crontask/Makefile | 34 -----
cmd/openim_crontask/deploy.Dockerfile | 32 ----
cmd/openim_crontask/main.go | 27 ----
cmd/openim_msggateway/Makefile | 34 -----
cmd/openim_msggateway/deploy.Dockerfile | 32 ----
cmd/openim_msggateway/main.go | 29 ----
cmd/openim_msgtransfer/Makefile | 34 -----
cmd/openim_msgtransfer/deploy.Dockerfile | 32 ----
cmd/openim_msgtransfer/main.go | 27 ----
cmd/openim_push/Makefile | 34 -----
cmd/openim_push/deploy.Dockerfile | 32 ----
cmd/openim_push/main.go | 33 ----
cmd/openim_rpc/openim_rpc_auth/Makefile | 34 -----
.../openim_rpc_auth/deploy.Dockerfile | 32 ----
cmd/openim_rpc/openim_rpc_auth/main.go | 33 ----
.../openim_rpc_conversation/Makefile | 34 -----
.../openim_rpc_conversation/deploy.Dockerfile | 32 ----
.../openim_rpc_conversation/main.go | 33 ----
cmd/openim_rpc/openim_rpc_friend/Makefile | 34 -----
.../openim_rpc_friend/deploy.Dockerfile | 32 ----
cmd/openim_rpc/openim_rpc_friend/main.go | 33 ----
cmd/openim_rpc/openim_rpc_group/Makefile | 34 -----
.../openim_rpc_group/deploy.Dockerfile | 32 ----
cmd/openim_rpc/openim_rpc_group/main.go | 33 ----
cmd/openim_rpc/openim_rpc_msg/Makefile | 34 -----
.../openim_rpc_msg/deploy.Dockerfile | 32 ----
cmd/openim_rpc/openim_rpc_msg/main.go | 33 ----
cmd/openim_rpc/openim_rpc_third/Makefile | 34 -----
.../openim_rpc_third/deploy.Dockerfile | 32 ----
cmd/openim_rpc/openim_rpc_third/main.go | 33 ----
cmd/openim_rpc/openim_rpc_user/Makefile | 34 -----
.../openim_rpc_user/deploy.Dockerfile | 32 ----
cmd/openim_rpc/openim_rpc_user/main.go | 33 ----
docs/contrib/cicd-actions.md | 2 +-
scripts/lib/golang.sh | 28 ++--
scripts/lib/release.sh | 24 +--
scripts/lib/util.sh | 52 +++----
scripts/make-rules/common.mk | 6 +-
scripts/make-rules/golang.mk | 6 +-
scripts/path_info.cfg | 142 +++++++++---------
scripts/start_rpc_service.sh | 2 +-
48 files changed, 141 insertions(+), 1471 deletions(-)
delete mode 100644 cmd/openim_api/Makefile
delete mode 100644 cmd/openim_api/deploy.Dockerfile
delete mode 100644 cmd/openim_api/main.go
delete mode 100644 cmd/openim_cmdutils/Makefile
delete mode 100644 cmd/openim_cmdutils/main.go
delete mode 100644 cmd/openim_crontask/Makefile
delete mode 100644 cmd/openim_crontask/deploy.Dockerfile
delete mode 100644 cmd/openim_crontask/main.go
delete mode 100644 cmd/openim_msggateway/Makefile
delete mode 100644 cmd/openim_msggateway/deploy.Dockerfile
delete mode 100644 cmd/openim_msggateway/main.go
delete mode 100644 cmd/openim_msgtransfer/Makefile
delete mode 100644 cmd/openim_msgtransfer/deploy.Dockerfile
delete mode 100644 cmd/openim_msgtransfer/main.go
delete mode 100644 cmd/openim_push/Makefile
delete mode 100644 cmd/openim_push/deploy.Dockerfile
delete mode 100644 cmd/openim_push/main.go
delete mode 100644 cmd/openim_rpc/openim_rpc_auth/Makefile
delete mode 100644 cmd/openim_rpc/openim_rpc_auth/deploy.Dockerfile
delete mode 100644 cmd/openim_rpc/openim_rpc_auth/main.go
delete mode 100644 cmd/openim_rpc/openim_rpc_conversation/Makefile
delete mode 100644 cmd/openim_rpc/openim_rpc_conversation/deploy.Dockerfile
delete mode 100644 cmd/openim_rpc/openim_rpc_conversation/main.go
delete mode 100644 cmd/openim_rpc/openim_rpc_friend/Makefile
delete mode 100644 cmd/openim_rpc/openim_rpc_friend/deploy.Dockerfile
delete mode 100644 cmd/openim_rpc/openim_rpc_friend/main.go
delete mode 100644 cmd/openim_rpc/openim_rpc_group/Makefile
delete mode 100644 cmd/openim_rpc/openim_rpc_group/deploy.Dockerfile
delete mode 100644 cmd/openim_rpc/openim_rpc_group/main.go
delete mode 100644 cmd/openim_rpc/openim_rpc_msg/Makefile
delete mode 100644 cmd/openim_rpc/openim_rpc_msg/deploy.Dockerfile
delete mode 100644 cmd/openim_rpc/openim_rpc_msg/main.go
delete mode 100644 cmd/openim_rpc/openim_rpc_third/Makefile
delete mode 100644 cmd/openim_rpc/openim_rpc_third/deploy.Dockerfile
delete mode 100644 cmd/openim_rpc/openim_rpc_third/main.go
delete mode 100644 cmd/openim_rpc/openim_rpc_user/Makefile
delete mode 100644 cmd/openim_rpc/openim_rpc_user/deploy.Dockerfile
delete mode 100644 cmd/openim_rpc/openim_rpc_user/main.go
diff --git a/.gitignore b/.gitignore
index 9cea0d86f..7ca2fe3fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,16 +31,16 @@ _output/
### OpenIM deploy ###
deploy/openim_demo
-deploy/openim_api
+deploy/openim-api
deploy/openim_msg_gateway
deploy/openim_msg_transfer
-deploy/openim_push
+deploy/openim-push
deploy/openim_timer_task
-deploy/openim_rpc_user
-deploy/openim_rpc_friend
-deploy/openim_rpc_group
-deploy/openim_rpc_msg
-deploy/openim_rpc_auth
+deploy/openim-rpc-user
+deploy/openim-rpc-friend
+deploy/openim-rpc-group
+deploy/openim-rpc-msg
+deploy/openim-rpc-auth
deploy/Open-IM-SDK-Core
# files used by the developer
diff --git a/Makefile b/Makefile
index 8d5c66eb5..5fcc3b8c3 100644
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,7 @@ Options:
BINS Binaries to build. Default is all binaries under cmd.
This option is available when using: make {build}(.multiarch)
- Example: make build BINS="openim_api openim_cmdutils".
+ Example: make build BINS="openim-api openim-cmdutils".
PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64.
This option is available when using: make {build}.multiarch
diff --git a/cmd/openim_api/Makefile b/cmd/openim_api/Makefile
deleted file mode 100644
index 4fe47f51f..000000000
--- a/cmd/openim_api/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_api
-BIN_DIR=../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_api/deploy.Dockerfile b/cmd/openim_api/deploy.Dockerfile
deleted file mode 100644
index 24a17af37..000000000
--- a/cmd/openim_api/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_api ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_api","--port", "10002"]
diff --git a/cmd/openim_api/main.go b/cmd/openim_api/main.go
deleted file mode 100644
index aac83a805..000000000
--- a/cmd/openim_api/main.go
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "context"
- "fmt"
- "net"
- "os"
- "runtime"
- "strconv"
- "time"
-
- "net/http"
- _ "net/http/pprof"
-
- "github.com/OpenIMSDK/Open-IM-Server/internal/api"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
- openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
-)
-
-func main() {
- apiCmd := cmd.NewApiCmd()
- apiCmd.AddPortFlag()
- apiCmd.AddApi(run)
- if err := apiCmd.Execute(); err != nil {
- panic(err.Error())
- }
-}
-
-func startPprof() {
- runtime.GOMAXPROCS(1)
- runtime.SetMutexProfileFraction(1)
- runtime.SetBlockProfileRate(1)
- if err := http.ListenAndServe(":6060", nil); err != nil {
- panic(err)
- }
- os.Exit(0)
-}
-
-func run(port int) error {
- if port == 0 {
- return fmt.Errorf("port is empty")
- }
- rdb, err := cache.NewRedis()
- if err != nil {
- return err
- }
- fmt.Println("api start init discov client")
- var client discoveryregistry.SvcDiscoveryRegistry
- client, 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 {
- return err
- }
- if client.CreateRpcRootNodes(config.GetServiceNames()); err != nil {
- return err
- }
- fmt.Println("api init discov client success")
- fmt.Println("api register public config to discov")
- if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.EncodeConfig()); err != nil {
- return err
- }
- fmt.Println("api register public config to discov success")
- router := api.NewGinRouter(client, rdb)
- fmt.Println("api init router success")
- var address string
- if config.Config.Api.ListenIP != "" {
- address = net.JoinHostPort(config.Config.Api.ListenIP, strconv.Itoa(port))
- } else {
- address = net.JoinHostPort("0.0.0.0", strconv.Itoa(port))
- }
- fmt.Println("start api server, address: ", address, ", OpenIM version: ", config.Version)
- log.ZInfo(context.Background(), "start server success", "address", address, "version", config.Version)
- go startPprof()
- err = router.Run(address)
- if err != nil {
- log.ZError(context.Background(), "api run failed ", err, "address", address)
- return err
- }
- return nil
-}
diff --git a/cmd/openim_cmdutils/Makefile b/cmd/openim_cmdutils/Makefile
deleted file mode 100644
index 9c51aee84..000000000
--- a/cmd/openim_cmdutils/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_cmd_utils
-BIN_DIR=../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_cmdutils/main.go b/cmd/openim_cmdutils/main.go
deleted file mode 100644
index 64079c7e1..000000000
--- a/cmd/openim_cmdutils/main.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
-)
-
-func main() {
- msgUtilsCmd := cmd.NewMsgUtilsCmd("openIMCmdUtils", "openIM cmd utils", nil)
- getCmd := cmd.NewGetCmd()
- fixCmd := cmd.NewFixCmd()
- clearCmd := cmd.NewClearCmd()
- seqCmd := cmd.NewSeqCmd()
- msgCmd := cmd.NewMsgCmd()
- getCmd.AddCommand(seqCmd.GetSeqCmd(), msgCmd.GetMsgCmd())
- getCmd.AddSuperGroupIDFlag()
- getCmd.AddUserIDFlag()
- getCmd.AddBeginSeqFlag()
- getCmd.AddLimitFlag()
- // openIM get seq --userID=xxx
- // openIM get seq --superGroupID=xxx
- // openIM get msg --userID=xxx --beginSeq=100 --limit=10
- // openIM get msg --superGroupID=xxx --beginSeq=100 --limit=10
-
- fixCmd.AddCommand(seqCmd.FixSeqCmd())
- fixCmd.AddSuperGroupIDFlag()
- fixCmd.AddUserIDFlag()
- fixCmd.AddFixAllFlag()
- // openIM fix seq --userID=xxx
- // openIM fix seq --superGroupID=xxx
- // openIM fix seq --fixAll
-
- clearCmd.AddCommand(msgCmd.ClearMsgCmd())
- clearCmd.AddSuperGroupIDFlag()
- clearCmd.AddUserIDFlag()
- clearCmd.AddClearAllFlag()
- clearCmd.AddBeginSeqFlag()
- clearCmd.AddLimitFlag()
- // openIM clear msg --userID=xxx --beginSeq=100 --limit=10
- // openIM clear msg --superGroupID=xxx --beginSeq=100 --limit=10
- // openIM clear msg --clearAll
- msgUtilsCmd.AddCommand(&getCmd.Command, &fixCmd.Command, &clearCmd.Command)
- if err := msgUtilsCmd.Execute(); err != nil {
- panic(err)
- }
-}
diff --git a/cmd/openim_crontask/Makefile b/cmd/openim_crontask/Makefile
deleted file mode 100644
index 1f09bf396..000000000
--- a/cmd/openim_crontask/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_cron_task
-BIN_DIR=../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_crontask/deploy.Dockerfile b/cmd/openim_crontask/deploy.Dockerfile
deleted file mode 100644
index 07d328474..000000000
--- a/cmd/openim_crontask/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_cron_task ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_cron_task"]
diff --git a/cmd/openim_crontask/main.go b/cmd/openim_crontask/main.go
deleted file mode 100644
index 73deb8c66..000000000
--- a/cmd/openim_crontask/main.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/internal/tools"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
-)
-
-func main() {
- cronTaskCmd := cmd.NewCronTaskCmd()
- if err := cronTaskCmd.Exec(tools.StartCronTask); err != nil {
- panic(err.Error())
- }
-}
diff --git a/cmd/openim_msggateway/Makefile b/cmd/openim_msggateway/Makefile
deleted file mode 100644
index 07cad40a9..000000000
--- a/cmd/openim_msggateway/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_msg_gateway
-BIN_DIR=../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_msggateway/deploy.Dockerfile b/cmd/openim_msggateway/deploy.Dockerfile
deleted file mode 100644
index eab3d16db..000000000
--- a/cmd/openim_msggateway/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_msg_gateway ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_msg_gateway","--port", "10140" "--ws_port", "10001", "--prometheus_port", "20240"]
diff --git a/cmd/openim_msggateway/main.go b/cmd/openim_msggateway/main.go
deleted file mode 100644
index 2782e4fd3..000000000
--- a/cmd/openim_msggateway/main.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
-)
-
-func main() {
- msgGatewayCmd := cmd.NewMsgGatewayCmd()
- msgGatewayCmd.AddWsPortFlag()
- msgGatewayCmd.AddPortFlag()
- msgGatewayCmd.AddPrometheusPortFlag()
- if err := msgGatewayCmd.Exec(); err != nil {
- panic(err.Error())
- }
-}
diff --git a/cmd/openim_msgtransfer/Makefile b/cmd/openim_msgtransfer/Makefile
deleted file mode 100644
index dc22834de..000000000
--- a/cmd/openim_msgtransfer/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_msg_transfer
-BIN_DIR=../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_msgtransfer/deploy.Dockerfile b/cmd/openim_msgtransfer/deploy.Dockerfile
deleted file mode 100644
index 91767adf4..000000000
--- a/cmd/openim_msgtransfer/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_msg_transfer ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_msg_transfer","--prometheus_port", "21400"]
diff --git a/cmd/openim_msgtransfer/main.go b/cmd/openim_msgtransfer/main.go
deleted file mode 100644
index aef347793..000000000
--- a/cmd/openim_msgtransfer/main.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
-)
-
-func main() {
- msgTransferCmd := cmd.NewMsgTransferCmd()
- msgTransferCmd.AddPrometheusPortFlag()
- if err := msgTransferCmd.Exec(); err != nil {
- panic(err.Error())
- }
-}
diff --git a/cmd/openim_push/Makefile b/cmd/openim_push/Makefile
deleted file mode 100644
index c67882553..000000000
--- a/cmd/openim_push/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_push
-BIN_DIR=../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_push/deploy.Dockerfile b/cmd/openim_push/deploy.Dockerfile
deleted file mode 100644
index 9b9a542c3..000000000
--- a/cmd/openim_push/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_push ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_push", "--port", "10170", "--prometheus_port", "20170"]
diff --git a/cmd/openim_push/main.go b/cmd/openim_push/main.go
deleted file mode 100644
index 03db8ae03..000000000
--- a/cmd/openim_push/main.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/internal/push"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
-)
-
-func main() {
- pushCmd := cmd.NewRpcCmd("push")
- pushCmd.AddPortFlag()
- pushCmd.AddPrometheusPortFlag()
- if err := pushCmd.Exec(); err != nil {
- panic(err.Error())
- }
- if err := pushCmd.StartSvr(config.Config.RpcRegisterName.OpenImPushName, push.Start); err != nil {
- panic(err.Error())
- }
-}
diff --git a/cmd/openim_rpc/openim_rpc_auth/Makefile b/cmd/openim_rpc/openim_rpc_auth/Makefile
deleted file mode 100644
index f702786ae..000000000
--- a/cmd/openim_rpc/openim_rpc_auth/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_auth
-BIN_DIR=../../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_rpc/openim_rpc_auth/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_auth/deploy.Dockerfile
deleted file mode 100644
index 1fc1682dd..000000000
--- a/cmd/openim_rpc/openim_rpc_auth/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_auth ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_auth", "--port", "10160"]
diff --git a/cmd/openim_rpc/openim_rpc_auth/main.go b/cmd/openim_rpc/openim_rpc_auth/main.go
deleted file mode 100644
index 524804988..000000000
--- a/cmd/openim_rpc/openim_rpc_auth/main.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/auth"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
-)
-
-func main() {
- authCmd := cmd.NewRpcCmd("auth")
- authCmd.AddPortFlag()
- authCmd.AddPrometheusPortFlag()
- if err := authCmd.Exec(); err != nil {
- panic(err.Error())
- }
- if err := authCmd.StartSvr(config.Config.RpcRegisterName.OpenImAuthName, auth.Start); err != nil {
- panic(err.Error())
- }
-}
diff --git a/cmd/openim_rpc/openim_rpc_conversation/Makefile b/cmd/openim_rpc/openim_rpc_conversation/Makefile
deleted file mode 100644
index fa973060e..000000000
--- a/cmd/openim_rpc/openim_rpc_conversation/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_conversation
-BIN_DIR=../../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_rpc/openim_rpc_conversation/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_conversation/deploy.Dockerfile
deleted file mode 100644
index 5aab79104..000000000
--- a/cmd/openim_rpc/openim_rpc_conversation/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_conversation ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_conversation", "--port", "10230", "--prometheus_port","20230"]
diff --git a/cmd/openim_rpc/openim_rpc_conversation/main.go b/cmd/openim_rpc/openim_rpc_conversation/main.go
deleted file mode 100644
index fec8226f8..000000000
--- a/cmd/openim_rpc/openim_rpc_conversation/main.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/conversation"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
-)
-
-func main() {
- rpcCmd := cmd.NewRpcCmd("conversation")
- rpcCmd.AddPortFlag()
- rpcCmd.AddPrometheusPortFlag()
- if err := rpcCmd.Exec(); err != nil {
- panic(err.Error())
- }
- if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImConversationName, conversation.Start); err != nil {
- panic(err.Error())
- }
-}
diff --git a/cmd/openim_rpc/openim_rpc_friend/Makefile b/cmd/openim_rpc/openim_rpc_friend/Makefile
deleted file mode 100644
index 8cbb39c2b..000000000
--- a/cmd/openim_rpc/openim_rpc_friend/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_friend
-BIN_DIR=../../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_rpc/openim_rpc_friend/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_friend/deploy.Dockerfile
deleted file mode 100644
index 3aaf86885..000000000
--- a/cmd/openim_rpc/openim_rpc_friend/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_friend ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_friend", "--port", "10120", "--prometheus_port","20120"]
diff --git a/cmd/openim_rpc/openim_rpc_friend/main.go b/cmd/openim_rpc/openim_rpc_friend/main.go
deleted file mode 100644
index fbd44038e..000000000
--- a/cmd/openim_rpc/openim_rpc_friend/main.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/friend"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
-)
-
-func main() {
- rpcCmd := cmd.NewRpcCmd("friend")
- rpcCmd.AddPortFlag()
- rpcCmd.AddPrometheusPortFlag()
- if err := rpcCmd.Exec(); err != nil {
- panic(err.Error())
- }
- if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImFriendName, friend.Start); err != nil {
- panic(err.Error())
- }
-}
diff --git a/cmd/openim_rpc/openim_rpc_group/Makefile b/cmd/openim_rpc/openim_rpc_group/Makefile
deleted file mode 100644
index b33dbb259..000000000
--- a/cmd/openim_rpc/openim_rpc_group/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_group
-BIN_DIR=../../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_rpc/openim_rpc_group/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_group/deploy.Dockerfile
deleted file mode 100644
index 1adb00bc5..000000000
--- a/cmd/openim_rpc/openim_rpc_group/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_group ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_group", "--port", "10150", "--prometheus_port","20150"]
diff --git a/cmd/openim_rpc/openim_rpc_group/main.go b/cmd/openim_rpc/openim_rpc_group/main.go
deleted file mode 100644
index 06baac155..000000000
--- a/cmd/openim_rpc/openim_rpc_group/main.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/group"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
-)
-
-func main() {
- rpcCmd := cmd.NewRpcCmd("group")
- rpcCmd.AddPortFlag()
- rpcCmd.AddPrometheusPortFlag()
- if err := rpcCmd.Exec(); err != nil {
- panic(err.Error())
- }
- if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImGroupName, group.Start); err != nil {
- panic(err.Error())
- }
-}
diff --git a/cmd/openim_rpc/openim_rpc_msg/Makefile b/cmd/openim_rpc/openim_rpc_msg/Makefile
deleted file mode 100644
index b27c5c420..000000000
--- a/cmd/openim_rpc/openim_rpc_msg/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_msg
-BIN_DIR=../../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_rpc/openim_rpc_msg/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_msg/deploy.Dockerfile
deleted file mode 100644
index 10fd29f0a..000000000
--- a/cmd/openim_rpc/openim_rpc_msg/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_msg ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_msg", "--port", "10130", "--prometheus_port","20130"]
diff --git a/cmd/openim_rpc/openim_rpc_msg/main.go b/cmd/openim_rpc/openim_rpc_msg/main.go
deleted file mode 100644
index 356081d33..000000000
--- a/cmd/openim_rpc/openim_rpc_msg/main.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/msg"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
-)
-
-func main() {
- rpcCmd := cmd.NewRpcCmd("msg")
- rpcCmd.AddPortFlag()
- rpcCmd.AddPrometheusPortFlag()
- if err := rpcCmd.Exec(); err != nil {
- panic(err.Error())
- }
- if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImMsgName, msg.Start); err != nil {
- panic(err.Error())
- }
-}
diff --git a/cmd/openim_rpc/openim_rpc_third/Makefile b/cmd/openim_rpc/openim_rpc_third/Makefile
deleted file mode 100644
index b5a7c546a..000000000
--- a/cmd/openim_rpc/openim_rpc_third/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_third
-BIN_DIR=../../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_rpc/openim_rpc_third/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_third/deploy.Dockerfile
deleted file mode 100644
index 7b6a1dfaf..000000000
--- a/cmd/openim_rpc/openim_rpc_third/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_third ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_third", "--port", "10200"]
diff --git a/cmd/openim_rpc/openim_rpc_third/main.go b/cmd/openim_rpc/openim_rpc_third/main.go
deleted file mode 100644
index c070e6811..000000000
--- a/cmd/openim_rpc/openim_rpc_third/main.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/third"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
-)
-
-func main() {
- rpcCmd := cmd.NewRpcCmd("third")
- rpcCmd.AddPortFlag()
- rpcCmd.AddPrometheusPortFlag()
- if err := rpcCmd.Exec(); err != nil {
- panic(err.Error())
- }
- if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImThirdName, third.Start); err != nil {
- panic(err.Error())
- }
-}
diff --git a/cmd/openim_rpc/openim_rpc_user/Makefile b/cmd/openim_rpc/openim_rpc_user/Makefile
deleted file mode 100644
index aef2d605a..000000000
--- a/cmd/openim_rpc/openim_rpc_user/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: all build run gotool install clean help
-
-NAME=openim_user
-BIN_DIR=../../../bin/
-
-OS:= $(or $(os),linux)
-ARCH:=$(or $(arch),amd64)
-all: gotool build
-
-ifeq ($(OS),windows)
-
-BINARY_NAME=${NAME}.exe
-
-else
-
-BINARY_NAME=${NAME}
-
-endif
-
-build:
- CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
-
-run:
- @go run ./
-
-gotool:
- go fmt ./
- go vet ./
-
-install:build
- mv ${BINARY_NAME} ${BIN_DIR}
-
-clean:
- @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim_rpc/openim_rpc_user/deploy.Dockerfile b/cmd/openim_rpc/openim_rpc_user/deploy.Dockerfile
deleted file mode 100644
index 0977dd634..000000000
--- a/cmd/openim_rpc/openim_rpc_user/deploy.Dockerfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu
-
-WORKDIR /Open-IM-Server/bin
-
-RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
-&&apt-get install net-tools
-#Non-interactive operation
-ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get install -y vim curl tzdata gawk
-#Time zone adjusted to East eighth District
-RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
-RUN apt-get -qq update \
- && apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_user ./
-
-VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-
-CMD ["./openim_user", "--port", "10110"]
diff --git a/cmd/openim_rpc/openim_rpc_user/main.go b/cmd/openim_rpc/openim_rpc_user/main.go
deleted file mode 100644
index 6d6d9008d..000000000
--- a/cmd/openim_rpc/openim_rpc_user/main.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/user"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
-)
-
-func main() {
- rpcCmd := cmd.NewRpcCmd("user")
- rpcCmd.AddPortFlag()
- rpcCmd.AddPrometheusPortFlag()
- if err := rpcCmd.Exec(); err != nil {
- panic(err.Error())
- }
- if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImUserName, user.Start); err != nil {
- panic(err.Error())
- }
-}
diff --git a/docs/contrib/cicd-actions.md b/docs/contrib/cicd-actions.md
index 2a95860be..99072f369 100644
--- a/docs/contrib/cicd-actions.md
+++ b/docs/contrib/cicd-actions.md
@@ -71,7 +71,7 @@ DEBUG Whether or not to generate debug symbols. Default is 0. ❓
BINS Binaries to build. Default is all binaries under cmd. 🛠️
This option is available when using: make {build}(.multiarch) 🧰
-Example: make build BINS="openim_api openim_cms_api".
+Example: make build BINS="openim-api openim_cms_api".
PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64. 🌍
This option is available when using: make {build}.multiarch 🌍
diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh
index 56e34703b..b442e1160 100755
--- a/scripts/lib/golang.sh
+++ b/scripts/lib/golang.sh
@@ -33,20 +33,20 @@ readonly OPENIM_SUPPORTED_CLIENT_PLATFORMS=(
# If you update this list, please also update build/BUILD.
openim::golang::server_targets() {
local targets=(
- openim_api
- openim_cmdutils
- openim_cmdutils
- openim_crontask
- openim_msggateway
- openim_msgtransfer
- openim_push
- openim_rpc_auth
- openim_rpc_conversation
- openim_rpc_friend
- openim_rpc_group
- openim_rpc_msg
- openim_rpc_third
- openim_rpc_user
+ openim-api
+ openim-cmdutils
+ openim-cmdutils
+ openim-crontask
+ openim-msggateway
+ openim-msgtransfer
+ openim-push
+ openim-rpc-auth
+ openim-rpc-conversation
+ openim-rpc-friend
+ openim-rpc-group
+ openim-rpc-msg
+ openim-rpc-third
+ openim-rpc-user
)
echo "${targets[@]}"
}
diff --git a/scripts/lib/release.sh b/scripts/lib/release.sh
index d6cdcdfcb..a198e1ae6 100755
--- a/scripts/lib/release.sh
+++ b/scripts/lib/release.sh
@@ -407,18 +407,18 @@ function openim::release::package_iam_manifests_tarball() {
mkdir -p "${dst_dir}"
cp -r ${src_dir}/* "${dst_dir}"
#cp "${src_dir}/openim-api.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_cmdutils.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_crontask.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_msggateway.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_msgtransfer.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_push.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_rpc_auth.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_rpc_conversation.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_rpc_friend.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_rpc_group.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_rpc_msg.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_rpc_third.yaml" "${dst_dir}"
- #cp "${src_dir}/openim_rpc_user.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-cmdutils.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-crontask.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-msggateway.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-msgtransfer.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-push.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-rpc-auth.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-rpc-conversation.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-rpc-friend.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-rpc-group.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-rpc-msg.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-rpc-third.yaml" "${dst_dir}"
+ #cp "${src_dir}/openim-rpc-user.yaml" "${dst_dir}"
#cp "${OPENIM_ROOT}/cluster/gce/gci/health-monitor.sh" "${dst_dir}/health-monitor.sh"
openim::release::clean_cruft
diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh
index 63d32eb79..04eb21de7 100755
--- a/scripts/lib/util.sh
+++ b/scripts/lib/util.sh
@@ -233,35 +233,35 @@ openim::util::gen-docs() {
"${gendocs}" "${dest}/docs/guide/en-US/cmd/imctl/"
mkdir -p "${dest}/docs/guide/en-US/cmd/"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_api"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_cmdutils"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_crontask"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_msggateway"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_msgtransfer"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_push"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_auth"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_conversation"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_friend"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_group"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_msg"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_third"
- "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_user"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-api"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-cmdutils"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-crontask"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-msggateway"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-msgtransfer"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-push"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-rpc-auth"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-rpc-conversation"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-rpc-friend"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-rpc-group"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-rpc-msg"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-rpc-third"
+ "${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-rpc-user"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/imctl" "imctl"
mkdir -p "${dest}/docs/man/man1/"
-"${genman}" "${dest}/docs/man/man1/" "openim_api"
-"${genman}" "${dest}/docs/man/man1/" "openim_cmdutils"
-"${genman}" "${dest}/docs/man/man1/" "openim_crontask"
-"${genman}" "${dest}/docs/man/man1/" "openim_msggateway"
-"${genman}" "${dest}/docs/man/man1/" "openim_msgtransfer"
-"${genman}" "${dest}/docs/man/man1/" "openim_push"
-"${genman}" "${dest}/docs/man/man1/" "openim_rpc_auth"
-"${genman}" "${dest}/docs/man/man1/" "openim_rpc_conversation"
-"${genman}" "${dest}/docs/man/man1/" "openim_rpc_friend"
-"${genman}" "${dest}/docs/man/man1/" "openim_rpc_group"
-"${genman}" "${dest}/docs/man/man1/" "openim_rpc_msg"
-"${genman}" "${dest}/docs/man/man1/" "openim_rpc_third"
-"${genman}" "${dest}/docs/man/man1/" "openim_rpc_user"
+"${genman}" "${dest}/docs/man/man1/" "openim-api"
+"${genman}" "${dest}/docs/man/man1/" "openim-cmdutils"
+"${genman}" "${dest}/docs/man/man1/" "openim-crontask"
+"${genman}" "${dest}/docs/man/man1/" "openim-msggateway"
+"${genman}" "${dest}/docs/man/man1/" "openim-msgtransfer"
+"${genman}" "${dest}/docs/man/man1/" "openim-push"
+"${genman}" "${dest}/docs/man/man1/" "openim-rpc-auth"
+"${genman}" "${dest}/docs/man/man1/" "openim-rpc-conversation"
+"${genman}" "${dest}/docs/man/man1/" "openim-rpc-friend"
+"${genman}" "${dest}/docs/man/man1/" "openim-rpc-group"
+"${genman}" "${dest}/docs/man/man1/" "openim-rpc-msg"
+"${genman}" "${dest}/docs/man/man1/" "openim-rpc-third"
+"${genman}" "${dest}/docs/man/man1/" "openim-rpc-user"
mkdir -p "${dest}/docs/guide/en-US/yaml/imctl/"
"${genyaml}" "${dest}/docs/guide/en-US/yaml/imct/"
diff --git a/scripts/make-rules/common.mk b/scripts/make-rules/common.mk
index e99585a76..d471ec112 100644
--- a/scripts/make-rules/common.mk
+++ b/scripts/make-rules/common.mk
@@ -147,18 +147,18 @@ endef
# Here are some examples of builds
define MAKEFILE_EXAMPLE
-# make build BINS=openim_api Only a single openim_api binary is built.
+# make build BINS=openim-api Only a single openim-api binary is built.
# make -j (nproc) all Run tidy gen add-copyright format lint cover build concurrently.
# make gen Generate all necessary files.
# make release Build release binaries for all platforms.
# make verify-copyright Verify the license headers for all files.
# make install-deepcopy-gen Install deepcopy-gen tools if the license is missing.
-# make build BINS=openim_api V=1 DEBUG=1 Build debug binaries for only openim_api.
+# make build BINS=openim-api V=1 DEBUG=1 Build debug binaries for only openim-api.
# make multiarch -j PLATFORMS="linux_arm64 linux_amd64" V=1 Build binaries for both platforms.
endef
export MAKEFILE_EXAMPLE
-# Define all help functions @printf "\n\033[1mCurrent openim_api version information: $(shell openim_api version):\033[0m\n\n"
+# Define all help functions @printf "\n\033[1mCurrent openim-api version information: $(shell openim-api version):\033[0m\n\n"
define makeallhelp
@printf "\n\033[1mMake example:\033[0m\n\n"
$(call MAKEFILE_EXAMPLE)
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index f0042e043..9602dbbbd 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -71,20 +71,20 @@ EXCLUDE_TESTS=github.com/OpenIMSDK/Open-IM-Server/test github.com/OpenIMSDK/Open
# ❯ tree -L 1 cmd
# cmd
# ├── openim-sdk-core/ - main.go
-# ├── openim_api
+# ├── openim-api
# ├── openim_cms_api
# ├── openim_cron_task
# ├── openim_demo
# ├── openim_msg_gateway
# ├── openim_msg_transfer
-# ├── openim_push
+# ├── openim-push
# ├── rpc/openim_admin_cms/ - main.go
# └── test/ - main.go
# COMMAND=openim
# PLATFORM=linux_amd64
# OS=linux
# ARCH=amd64
-# BINS=openim_api openim_cms_api openim_cron_task openim_demo openim_msg_gateway openim_msg_transfer openim_push
+# BINS=openim-api openim_cms_api openim_cron_task openim_demo openim_msg_gateway openim_msg_transfer openim-push
# BIN_DIR=/root/workspaces/OpenIM/_output/bin
# ==============================================================================
diff --git a/scripts/path_info.cfg b/scripts/path_info.cfg
index 530455f36..aa36164ae 100644
--- a/scripts/path_info.cfg
+++ b/scripts/path_info.cfg
@@ -1,92 +1,96 @@
-#Don't put the space between "="
-msg_gateway_name="openim_msg_gateway"
-msg_gateway_binary_root="../bin/"
+# Determine the architecture and version
+architecture=$(uname -m)
+version=$(uname -s | tr '[:upper:]' '[:lower:]')
+
+# Define the supported architectures and corresponding bin directories
+declare -A supported_architectures=(
+ ["linux-amd64"]="_output/bin/platforms/linux/amd64"
+ ["linux-arm64"]="_output/bin/platforms/linux/arm64"
+ ["linux-mips64"]="_output/bin/platforms/linux/mips64"
+ ["linux-mips64le"]="_output/bin/platforms/linux/mips64le"
+ ["linux-ppc64le"]="_output/bin/platforms/linux/ppc64le"
+ ["linux-s390x"]="_output/bin/platforms/linux/s390x"
+ ["darwin-amd64"]="_output/bin/platforms/darwin/amd64"
+ ["windows-amd64"]="_output/bin/platforms/windows/amd64"
+ ["linux-x86_64"]="_output/bin/platforms/linux/amd64" # Alias for linux-amd64
+ ["darwin-x86_64"]="_output/bin/platforms/darwin/amd64" # Alias for darwin-amd64
+)
+
+# Check if the architecture and version are supported
+if [[ -z ${supported_architectures["$version-$architecture"]} ]]; then
+ echo "Unsupported architecture: $architecture or version: $version"
+ exit 1
+fi
+
+# Set the BIN_DIR based on the architecture and version
+BIN_DIR=${supported_architectures["$version-$architecture"]}
+
+echo "BIN_DIR: $BIN_DIR"
+
+# Don't put the space between "="
+msg_gateway_name="openim-msggateway"
+msg_gateway_binary_root= $BIN_DIR
msg_gateway_source_root="../cmd/msggateway/"
msg_name="openim_msg"
-msg_binary_root="../bin/"
+msg_binary_root=$BIN_DIR
msg_source_root="../cmd/rpc/msg/"
-push_name="openim_push"
-push_binary_root="../bin/"
+push_name="openim-push"
+push_binary_root=$BIN_DIR
push_source_root="../cmd/push/"
-
-
msg_transfer_name="openim_msg_transfer"
-msg_transfer_binary_root="../bin/"
+msg_transfer_binary_root=$BIN_DIR
msg_transfer_source_root="../cmd/msgtransfer/"
msg_transfer_service_num=4
-
-sdk_server_name="openim_sdk_server"
-sdk_server_binary_root="../bin/"
-sdk_server_source_root="../cmd/Open-IM-SDK-Core/"
-
-
cron_task_name="openim_cron_task"
-cron_task_binary_root="../bin/"
+cron_task_binary_root=$BIN_DIR
cron_task_source_root="../cmd/crontask/"
cmd_utils_name="openim_cmd_utils"
-cmd_utils_binary_root="../bin/"
+cmd_utils_binary_root=$BIN_DIR
cmd_utils_source_root="../cmd/cmduitls/"
-#Global configuration file default dir
+# Global configuration file default dir
config_path="../config/config.yaml"
-#servicefile dir path
+# servicefile dir path
service_source_root=(
- #api service file
- ../cmd/api/
- #rpc service file
- ../cmd/rpc/user/
- ../cmd/rpc/friend/
- ../cmd/rpc/group/
- ../cmd/rpc/auth/
- ../cmd/rpc/conversation/
- ../cmd/rpc/third/
- ../cmd/crontask
- ${msg_gateway_source_root}
- ${msg_transfer_source_root}
- ${msg_source_root}
- ${push_source_root}
- # ${sdk_server_source_root}
-)
-#service filename
-service_names=(
- #api service filename
- openim_api
- #rpc service filename
- openim_user
- openim_friend
- openim_group
- openim_auth
- openim_conversation
- openim_third
- openim_cron_task
- ${msg_gateway_name}
- ${msg_transfer_name}
- ${msg_name}
- ${push_name}
- # ${sdk_server_name}
+ # api service file
+ "../cmd/api/"
+ # rpc service file
+ "../cmd/rpc/user/"
+ "../cmd/rpc/friend/"
+ "../cmd/rpc/group/"
+ "../cmd/rpc/auth/"
+ "../cmd/rpc/conversation/"
+ "../cmd/rpc/third/"
+ "../cmd/crontask"
+ "${msg_gateway_source_root}"
+ "${msg_transfer_source_root}"
+ "${msg_source_root}"
+ "${push_source_root}"
+ # "${sdk_server_source_root}"
)
-image_names=(
- #api service file
- api
- #rpc service file
- user
- friend
- group
- auth
- conversation
- third
- cron_task
- msg_gateway
- msg_transfer
- msg
- push
- # sdk_server
-)
+# service filename
+service_names=(
+ # api service filename
+ "openim-api"
+ # rpc service filename
+ "openim_user"
+ "openim_friend"
+ "openim_group"
+ "openim_auth"
+ "openim_conversation"
+ "openim_third"
+ "openim_cron_task"
+ "${msg_gateway_name}"
+ "${msg_transfer_name}"
+ "${msg_name}"
+ "${push_name}"
+ # "${sdk_server_name}"
+)
\ No newline at end of file
diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh
index d0c2f721d..379dba474 100755
--- a/scripts/start_rpc_service.sh
+++ b/scripts/start_rpc_service.sh
@@ -21,7 +21,7 @@ source ./function.sh
#service filename
service_filename=(
#api
- openim_api
+ openim-api
#rpc
openim_user
openim_friend
From 905c55caadedd7c3c7a4408d7eb59df95dfa33a4 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 19:48:34 +0800
Subject: [PATCH 33/73] fix: binary name modification
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
cmd/openim-api/Makefile | 34 ++++++
cmd/openim-api/deploy.Dockerfile | 32 ++++++
cmd/openim-api/main.go | 102 ++++++++++++++++++
cmd/openim-cmdutils/Makefile | 34 ++++++
cmd/openim-cmdutils/main.go | 59 ++++++++++
cmd/openim-crontask/Makefile | 34 ++++++
cmd/openim-crontask/deploy.Dockerfile | 32 ++++++
cmd/openim-crontask/main.go | 27 +++++
cmd/openim-msggateway/Makefile | 34 ++++++
cmd/openim-msggateway/deploy.Dockerfile | 32 ++++++
cmd/openim-msggateway/main.go | 29 +++++
cmd/openim-msgtransfer/Makefile | 34 ++++++
cmd/openim-msgtransfer/deploy.Dockerfile | 32 ++++++
cmd/openim-msgtransfer/main.go | 27 +++++
cmd/openim-push/Makefile | 34 ++++++
cmd/openim-push/deploy.Dockerfile | 32 ++++++
cmd/openim-push/main.go | 33 ++++++
cmd/openim-rpc/openim-rpc-auth/Makefile | 34 ++++++
.../openim-rpc-auth/deploy.Dockerfile | 32 ++++++
cmd/openim-rpc/openim-rpc-auth/main.go | 33 ++++++
.../openim-rpc-conversation/Makefile | 34 ++++++
.../openim-rpc-conversation/deploy.Dockerfile | 32 ++++++
.../openim-rpc-conversation/main.go | 33 ++++++
cmd/openim-rpc/openim-rpc-friend/Makefile | 34 ++++++
.../openim-rpc-friend/deploy.Dockerfile | 32 ++++++
cmd/openim-rpc/openim-rpc-friend/main.go | 33 ++++++
cmd/openim-rpc/openim-rpc-group/Makefile | 34 ++++++
.../openim-rpc-group/deploy.Dockerfile | 32 ++++++
cmd/openim-rpc/openim-rpc-group/main.go | 33 ++++++
cmd/openim-rpc/openim-rpc-msg/Makefile | 34 ++++++
.../openim-rpc-msg/deploy.Dockerfile | 32 ++++++
cmd/openim-rpc/openim-rpc-msg/main.go | 33 ++++++
cmd/openim-rpc/openim-rpc-third/Makefile | 34 ++++++
.../openim-rpc-third/deploy.Dockerfile | 32 ++++++
cmd/openim-rpc/openim-rpc-third/main.go | 33 ++++++
cmd/openim-rpc/openim-rpc-user/Makefile | 34 ++++++
.../openim-rpc-user/deploy.Dockerfile | 32 ++++++
cmd/openim-rpc/openim-rpc-user/main.go | 33 ++++++
38 files changed, 1334 insertions(+)
create mode 100644 cmd/openim-api/Makefile
create mode 100644 cmd/openim-api/deploy.Dockerfile
create mode 100644 cmd/openim-api/main.go
create mode 100644 cmd/openim-cmdutils/Makefile
create mode 100644 cmd/openim-cmdutils/main.go
create mode 100644 cmd/openim-crontask/Makefile
create mode 100644 cmd/openim-crontask/deploy.Dockerfile
create mode 100644 cmd/openim-crontask/main.go
create mode 100644 cmd/openim-msggateway/Makefile
create mode 100644 cmd/openim-msggateway/deploy.Dockerfile
create mode 100644 cmd/openim-msggateway/main.go
create mode 100644 cmd/openim-msgtransfer/Makefile
create mode 100644 cmd/openim-msgtransfer/deploy.Dockerfile
create mode 100644 cmd/openim-msgtransfer/main.go
create mode 100644 cmd/openim-push/Makefile
create mode 100644 cmd/openim-push/deploy.Dockerfile
create mode 100644 cmd/openim-push/main.go
create mode 100644 cmd/openim-rpc/openim-rpc-auth/Makefile
create mode 100644 cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile
create mode 100644 cmd/openim-rpc/openim-rpc-auth/main.go
create mode 100644 cmd/openim-rpc/openim-rpc-conversation/Makefile
create mode 100644 cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile
create mode 100644 cmd/openim-rpc/openim-rpc-conversation/main.go
create mode 100644 cmd/openim-rpc/openim-rpc-friend/Makefile
create mode 100644 cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile
create mode 100644 cmd/openim-rpc/openim-rpc-friend/main.go
create mode 100644 cmd/openim-rpc/openim-rpc-group/Makefile
create mode 100644 cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile
create mode 100644 cmd/openim-rpc/openim-rpc-group/main.go
create mode 100644 cmd/openim-rpc/openim-rpc-msg/Makefile
create mode 100644 cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile
create mode 100644 cmd/openim-rpc/openim-rpc-msg/main.go
create mode 100644 cmd/openim-rpc/openim-rpc-third/Makefile
create mode 100644 cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile
create mode 100644 cmd/openim-rpc/openim-rpc-third/main.go
create mode 100644 cmd/openim-rpc/openim-rpc-user/Makefile
create mode 100644 cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile
create mode 100644 cmd/openim-rpc/openim-rpc-user/main.go
diff --git a/cmd/openim-api/Makefile b/cmd/openim-api/Makefile
new file mode 100644
index 000000000..b72c6c717
--- /dev/null
+++ b/cmd/openim-api/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim-api
+BIN_DIR=../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-api/deploy.Dockerfile b/cmd/openim-api/deploy.Dockerfile
new file mode 100644
index 000000000..3479e0cd3
--- /dev/null
+++ b/cmd/openim-api/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim-api ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim-api","--port", "10002"]
diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go
new file mode 100644
index 000000000..aac83a805
--- /dev/null
+++ b/cmd/openim-api/main.go
@@ -0,0 +1,102 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "context"
+ "fmt"
+ "net"
+ "os"
+ "runtime"
+ "strconv"
+ "time"
+
+ "net/http"
+ _ "net/http/pprof"
+
+ "github.com/OpenIMSDK/Open-IM-Server/internal/api"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
+ openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
+)
+
+func main() {
+ apiCmd := cmd.NewApiCmd()
+ apiCmd.AddPortFlag()
+ apiCmd.AddApi(run)
+ if err := apiCmd.Execute(); err != nil {
+ panic(err.Error())
+ }
+}
+
+func startPprof() {
+ runtime.GOMAXPROCS(1)
+ runtime.SetMutexProfileFraction(1)
+ runtime.SetBlockProfileRate(1)
+ if err := http.ListenAndServe(":6060", nil); err != nil {
+ panic(err)
+ }
+ os.Exit(0)
+}
+
+func run(port int) error {
+ if port == 0 {
+ return fmt.Errorf("port is empty")
+ }
+ rdb, err := cache.NewRedis()
+ if err != nil {
+ return err
+ }
+ fmt.Println("api start init discov client")
+ var client discoveryregistry.SvcDiscoveryRegistry
+ client, 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 {
+ return err
+ }
+ if client.CreateRpcRootNodes(config.GetServiceNames()); err != nil {
+ return err
+ }
+ fmt.Println("api init discov client success")
+ fmt.Println("api register public config to discov")
+ if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.EncodeConfig()); err != nil {
+ return err
+ }
+ fmt.Println("api register public config to discov success")
+ router := api.NewGinRouter(client, rdb)
+ fmt.Println("api init router success")
+ var address string
+ if config.Config.Api.ListenIP != "" {
+ address = net.JoinHostPort(config.Config.Api.ListenIP, strconv.Itoa(port))
+ } else {
+ address = net.JoinHostPort("0.0.0.0", strconv.Itoa(port))
+ }
+ fmt.Println("start api server, address: ", address, ", OpenIM version: ", config.Version)
+ log.ZInfo(context.Background(), "start server success", "address", address, "version", config.Version)
+ go startPprof()
+ err = router.Run(address)
+ if err != nil {
+ log.ZError(context.Background(), "api run failed ", err, "address", address)
+ return err
+ }
+ return nil
+}
diff --git a/cmd/openim-cmdutils/Makefile b/cmd/openim-cmdutils/Makefile
new file mode 100644
index 000000000..9c51aee84
--- /dev/null
+++ b/cmd/openim-cmdutils/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim_cmd_utils
+BIN_DIR=../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-cmdutils/main.go b/cmd/openim-cmdutils/main.go
new file mode 100644
index 000000000..64079c7e1
--- /dev/null
+++ b/cmd/openim-cmdutils/main.go
@@ -0,0 +1,59 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+)
+
+func main() {
+ msgUtilsCmd := cmd.NewMsgUtilsCmd("openIMCmdUtils", "openIM cmd utils", nil)
+ getCmd := cmd.NewGetCmd()
+ fixCmd := cmd.NewFixCmd()
+ clearCmd := cmd.NewClearCmd()
+ seqCmd := cmd.NewSeqCmd()
+ msgCmd := cmd.NewMsgCmd()
+ getCmd.AddCommand(seqCmd.GetSeqCmd(), msgCmd.GetMsgCmd())
+ getCmd.AddSuperGroupIDFlag()
+ getCmd.AddUserIDFlag()
+ getCmd.AddBeginSeqFlag()
+ getCmd.AddLimitFlag()
+ // openIM get seq --userID=xxx
+ // openIM get seq --superGroupID=xxx
+ // openIM get msg --userID=xxx --beginSeq=100 --limit=10
+ // openIM get msg --superGroupID=xxx --beginSeq=100 --limit=10
+
+ fixCmd.AddCommand(seqCmd.FixSeqCmd())
+ fixCmd.AddSuperGroupIDFlag()
+ fixCmd.AddUserIDFlag()
+ fixCmd.AddFixAllFlag()
+ // openIM fix seq --userID=xxx
+ // openIM fix seq --superGroupID=xxx
+ // openIM fix seq --fixAll
+
+ clearCmd.AddCommand(msgCmd.ClearMsgCmd())
+ clearCmd.AddSuperGroupIDFlag()
+ clearCmd.AddUserIDFlag()
+ clearCmd.AddClearAllFlag()
+ clearCmd.AddBeginSeqFlag()
+ clearCmd.AddLimitFlag()
+ // openIM clear msg --userID=xxx --beginSeq=100 --limit=10
+ // openIM clear msg --superGroupID=xxx --beginSeq=100 --limit=10
+ // openIM clear msg --clearAll
+ msgUtilsCmd.AddCommand(&getCmd.Command, &fixCmd.Command, &clearCmd.Command)
+ if err := msgUtilsCmd.Execute(); err != nil {
+ panic(err)
+ }
+}
diff --git a/cmd/openim-crontask/Makefile b/cmd/openim-crontask/Makefile
new file mode 100644
index 000000000..1f09bf396
--- /dev/null
+++ b/cmd/openim-crontask/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim_cron_task
+BIN_DIR=../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-crontask/deploy.Dockerfile b/cmd/openim-crontask/deploy.Dockerfile
new file mode 100644
index 000000000..07d328474
--- /dev/null
+++ b/cmd/openim-crontask/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim_cron_task ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim_cron_task"]
diff --git a/cmd/openim-crontask/main.go b/cmd/openim-crontask/main.go
new file mode 100644
index 000000000..73deb8c66
--- /dev/null
+++ b/cmd/openim-crontask/main.go
@@ -0,0 +1,27 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/internal/tools"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+)
+
+func main() {
+ cronTaskCmd := cmd.NewCronTaskCmd()
+ if err := cronTaskCmd.Exec(tools.StartCronTask); err != nil {
+ panic(err.Error())
+ }
+}
diff --git a/cmd/openim-msggateway/Makefile b/cmd/openim-msggateway/Makefile
new file mode 100644
index 000000000..07cad40a9
--- /dev/null
+++ b/cmd/openim-msggateway/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim_msg_gateway
+BIN_DIR=../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-msggateway/deploy.Dockerfile b/cmd/openim-msggateway/deploy.Dockerfile
new file mode 100644
index 000000000..eab3d16db
--- /dev/null
+++ b/cmd/openim-msggateway/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim_msg_gateway ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim_msg_gateway","--port", "10140" "--ws_port", "10001", "--prometheus_port", "20240"]
diff --git a/cmd/openim-msggateway/main.go b/cmd/openim-msggateway/main.go
new file mode 100644
index 000000000..2782e4fd3
--- /dev/null
+++ b/cmd/openim-msggateway/main.go
@@ -0,0 +1,29 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+)
+
+func main() {
+ msgGatewayCmd := cmd.NewMsgGatewayCmd()
+ msgGatewayCmd.AddWsPortFlag()
+ msgGatewayCmd.AddPortFlag()
+ msgGatewayCmd.AddPrometheusPortFlag()
+ if err := msgGatewayCmd.Exec(); err != nil {
+ panic(err.Error())
+ }
+}
diff --git a/cmd/openim-msgtransfer/Makefile b/cmd/openim-msgtransfer/Makefile
new file mode 100644
index 000000000..dc22834de
--- /dev/null
+++ b/cmd/openim-msgtransfer/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim_msg_transfer
+BIN_DIR=../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-msgtransfer/deploy.Dockerfile b/cmd/openim-msgtransfer/deploy.Dockerfile
new file mode 100644
index 000000000..91767adf4
--- /dev/null
+++ b/cmd/openim-msgtransfer/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim_msg_transfer ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim_msg_transfer","--prometheus_port", "21400"]
diff --git a/cmd/openim-msgtransfer/main.go b/cmd/openim-msgtransfer/main.go
new file mode 100644
index 000000000..aef347793
--- /dev/null
+++ b/cmd/openim-msgtransfer/main.go
@@ -0,0 +1,27 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+)
+
+func main() {
+ msgTransferCmd := cmd.NewMsgTransferCmd()
+ msgTransferCmd.AddPrometheusPortFlag()
+ if err := msgTransferCmd.Exec(); err != nil {
+ panic(err.Error())
+ }
+}
diff --git a/cmd/openim-push/Makefile b/cmd/openim-push/Makefile
new file mode 100644
index 000000000..b417faecf
--- /dev/null
+++ b/cmd/openim-push/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim-push
+BIN_DIR=../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-push/deploy.Dockerfile b/cmd/openim-push/deploy.Dockerfile
new file mode 100644
index 000000000..67774a6f7
--- /dev/null
+++ b/cmd/openim-push/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim-push ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim-push", "--port", "10170", "--prometheus_port", "20170"]
diff --git a/cmd/openim-push/main.go b/cmd/openim-push/main.go
new file mode 100644
index 000000000..03db8ae03
--- /dev/null
+++ b/cmd/openim-push/main.go
@@ -0,0 +1,33 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/internal/push"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+)
+
+func main() {
+ pushCmd := cmd.NewRpcCmd("push")
+ pushCmd.AddPortFlag()
+ pushCmd.AddPrometheusPortFlag()
+ if err := pushCmd.Exec(); err != nil {
+ panic(err.Error())
+ }
+ if err := pushCmd.StartSvr(config.Config.RpcRegisterName.OpenImPushName, push.Start); err != nil {
+ panic(err.Error())
+ }
+}
diff --git a/cmd/openim-rpc/openim-rpc-auth/Makefile b/cmd/openim-rpc/openim-rpc-auth/Makefile
new file mode 100644
index 000000000..f702786ae
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-auth/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim_auth
+BIN_DIR=../../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile
new file mode 100644
index 000000000..1fc1682dd
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim_auth ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim_auth", "--port", "10160"]
diff --git a/cmd/openim-rpc/openim-rpc-auth/main.go b/cmd/openim-rpc/openim-rpc-auth/main.go
new file mode 100644
index 000000000..524804988
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-auth/main.go
@@ -0,0 +1,33 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/auth"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+)
+
+func main() {
+ authCmd := cmd.NewRpcCmd("auth")
+ authCmd.AddPortFlag()
+ authCmd.AddPrometheusPortFlag()
+ if err := authCmd.Exec(); err != nil {
+ panic(err.Error())
+ }
+ if err := authCmd.StartSvr(config.Config.RpcRegisterName.OpenImAuthName, auth.Start); err != nil {
+ panic(err.Error())
+ }
+}
diff --git a/cmd/openim-rpc/openim-rpc-conversation/Makefile b/cmd/openim-rpc/openim-rpc-conversation/Makefile
new file mode 100644
index 000000000..fa973060e
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-conversation/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim_conversation
+BIN_DIR=../../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile
new file mode 100644
index 000000000..5aab79104
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim_conversation ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim_conversation", "--port", "10230", "--prometheus_port","20230"]
diff --git a/cmd/openim-rpc/openim-rpc-conversation/main.go b/cmd/openim-rpc/openim-rpc-conversation/main.go
new file mode 100644
index 000000000..fec8226f8
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-conversation/main.go
@@ -0,0 +1,33 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/conversation"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+)
+
+func main() {
+ rpcCmd := cmd.NewRpcCmd("conversation")
+ rpcCmd.AddPortFlag()
+ rpcCmd.AddPrometheusPortFlag()
+ if err := rpcCmd.Exec(); err != nil {
+ panic(err.Error())
+ }
+ if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImConversationName, conversation.Start); err != nil {
+ panic(err.Error())
+ }
+}
diff --git a/cmd/openim-rpc/openim-rpc-friend/Makefile b/cmd/openim-rpc/openim-rpc-friend/Makefile
new file mode 100644
index 000000000..8cbb39c2b
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-friend/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim_friend
+BIN_DIR=../../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile
new file mode 100644
index 000000000..3aaf86885
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim_friend ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim_friend", "--port", "10120", "--prometheus_port","20120"]
diff --git a/cmd/openim-rpc/openim-rpc-friend/main.go b/cmd/openim-rpc/openim-rpc-friend/main.go
new file mode 100644
index 000000000..fbd44038e
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-friend/main.go
@@ -0,0 +1,33 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/friend"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+)
+
+func main() {
+ rpcCmd := cmd.NewRpcCmd("friend")
+ rpcCmd.AddPortFlag()
+ rpcCmd.AddPrometheusPortFlag()
+ if err := rpcCmd.Exec(); err != nil {
+ panic(err.Error())
+ }
+ if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImFriendName, friend.Start); err != nil {
+ panic(err.Error())
+ }
+}
diff --git a/cmd/openim-rpc/openim-rpc-group/Makefile b/cmd/openim-rpc/openim-rpc-group/Makefile
new file mode 100644
index 000000000..b33dbb259
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-group/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim_group
+BIN_DIR=../../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile
new file mode 100644
index 000000000..1adb00bc5
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim_group ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim_group", "--port", "10150", "--prometheus_port","20150"]
diff --git a/cmd/openim-rpc/openim-rpc-group/main.go b/cmd/openim-rpc/openim-rpc-group/main.go
new file mode 100644
index 000000000..06baac155
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-group/main.go
@@ -0,0 +1,33 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/group"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+)
+
+func main() {
+ rpcCmd := cmd.NewRpcCmd("group")
+ rpcCmd.AddPortFlag()
+ rpcCmd.AddPrometheusPortFlag()
+ if err := rpcCmd.Exec(); err != nil {
+ panic(err.Error())
+ }
+ if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImGroupName, group.Start); err != nil {
+ panic(err.Error())
+ }
+}
diff --git a/cmd/openim-rpc/openim-rpc-msg/Makefile b/cmd/openim-rpc/openim-rpc-msg/Makefile
new file mode 100644
index 000000000..b27c5c420
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-msg/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim_msg
+BIN_DIR=../../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile
new file mode 100644
index 000000000..10fd29f0a
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim_msg ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim_msg", "--port", "10130", "--prometheus_port","20130"]
diff --git a/cmd/openim-rpc/openim-rpc-msg/main.go b/cmd/openim-rpc/openim-rpc-msg/main.go
new file mode 100644
index 000000000..356081d33
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-msg/main.go
@@ -0,0 +1,33 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/msg"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+)
+
+func main() {
+ rpcCmd := cmd.NewRpcCmd("msg")
+ rpcCmd.AddPortFlag()
+ rpcCmd.AddPrometheusPortFlag()
+ if err := rpcCmd.Exec(); err != nil {
+ panic(err.Error())
+ }
+ if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImMsgName, msg.Start); err != nil {
+ panic(err.Error())
+ }
+}
diff --git a/cmd/openim-rpc/openim-rpc-third/Makefile b/cmd/openim-rpc/openim-rpc-third/Makefile
new file mode 100644
index 000000000..b5a7c546a
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-third/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim_third
+BIN_DIR=../../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile
new file mode 100644
index 000000000..7b6a1dfaf
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim_third ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim_third", "--port", "10200"]
diff --git a/cmd/openim-rpc/openim-rpc-third/main.go b/cmd/openim-rpc/openim-rpc-third/main.go
new file mode 100644
index 000000000..c070e6811
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-third/main.go
@@ -0,0 +1,33 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/third"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+)
+
+func main() {
+ rpcCmd := cmd.NewRpcCmd("third")
+ rpcCmd.AddPortFlag()
+ rpcCmd.AddPrometheusPortFlag()
+ if err := rpcCmd.Exec(); err != nil {
+ panic(err.Error())
+ }
+ if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImThirdName, third.Start); err != nil {
+ panic(err.Error())
+ }
+}
diff --git a/cmd/openim-rpc/openim-rpc-user/Makefile b/cmd/openim-rpc/openim-rpc-user/Makefile
new file mode 100644
index 000000000..aef2d605a
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-user/Makefile
@@ -0,0 +1,34 @@
+.PHONY: all build run gotool install clean help
+
+NAME=openim_user
+BIN_DIR=../../../bin/
+
+OS:= $(or $(os),linux)
+ARCH:=$(or $(arch),amd64)
+all: gotool build
+
+ifeq ($(OS),windows)
+
+BINARY_NAME=${NAME}.exe
+
+else
+
+BINARY_NAME=${NAME}
+
+endif
+
+build:
+ CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
+
+run:
+ @go run ./
+
+gotool:
+ go fmt ./
+ go vet ./
+
+install:build
+ mv ${BINARY_NAME} ${BIN_DIR}
+
+clean:
+ @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
diff --git a/cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile
new file mode 100644
index 000000000..0977dd634
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile
@@ -0,0 +1,32 @@
+# Copyright © 2023 OpenIM. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu
+
+WORKDIR /Open-IM-Server/bin
+
+RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
+&&apt-get install net-tools
+#Non-interactive operation
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get install -y vim curl tzdata gawk
+#Time zone adjusted to East eighth District
+RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
+RUN apt-get -qq update \
+ && apt-get -qq install -y --no-install-recommends ca-certificates curl
+COPY ./openim_user ./
+
+VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
+
+CMD ["./openim_user", "--port", "10110"]
diff --git a/cmd/openim-rpc/openim-rpc-user/main.go b/cmd/openim-rpc/openim-rpc-user/main.go
new file mode 100644
index 000000000..6d6d9008d
--- /dev/null
+++ b/cmd/openim-rpc/openim-rpc-user/main.go
@@ -0,0 +1,33 @@
+// Copyright © 2023 OpenIM. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "github.com/OpenIMSDK/Open-IM-Server/internal/rpc/user"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
+)
+
+func main() {
+ rpcCmd := cmd.NewRpcCmd("user")
+ rpcCmd.AddPortFlag()
+ rpcCmd.AddPrometheusPortFlag()
+ if err := rpcCmd.Exec(); err != nil {
+ panic(err.Error())
+ }
+ if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImUserName, user.Start); err != nil {
+ panic(err.Error())
+ }
+}
From 049ae6eb803e1d61a488845b6b2f92380fc00b31 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 21:27:07 +0800
Subject: [PATCH 34/73] feat: add chmod
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.gitignore | 4 +-
cmd/openim-crontask/Makefile | 2 +-
cmd/openim-crontask/deploy.Dockerfile | 4 +-
cmd/openim-msggateway/Makefile | 2 +-
cmd/openim-msggateway/deploy.Dockerfile | 4 +-
cmd/openim-msgtransfer/Makefile | 2 +-
cmd/openim-msgtransfer/deploy.Dockerfile | 4 +-
cmd/openim-rpc/openim-rpc-auth/Makefile | 2 +-
.../openim-rpc-auth/deploy.Dockerfile | 4 +-
.../openim-rpc-conversation/Makefile | 2 +-
.../openim-rpc-conversation/deploy.Dockerfile | 4 +-
cmd/openim-rpc/openim-rpc-friend/Makefile | 2 +-
.../openim-rpc-friend/deploy.Dockerfile | 4 +-
cmd/openim-rpc/openim-rpc-group/Makefile | 2 +-
.../openim-rpc-group/deploy.Dockerfile | 4 +-
cmd/openim-rpc/openim-rpc-msg/Makefile | 2 +-
.../openim-rpc-msg/deploy.Dockerfile | 4 +-
cmd/openim-rpc/openim-rpc-third/Makefile | 2 +-
.../openim-rpc-third/deploy.Dockerfile | 4 +-
cmd/openim-rpc/openim-rpc-user/Makefile | 2 +-
.../openim-rpc-user/deploy.Dockerfile | 4 +-
docs/.generated_docs | 14 +++---
scripts/batch_build_all_service.sh | 18 ++++---
scripts/batch_start_all.sh | 33 ++++++++-----
scripts/build_images.sh | 25 ----------
scripts/check_all.sh | 2 +-
scripts/make-rules/golang.mk | 12 ++---
scripts/msg_gateway_start.sh | 14 +++---
scripts/msg_transfer_start.sh | 30 +++++++-----
scripts/path_info.cfg | 47 ++++++++++---------
scripts/start_all.sh | 7 ++-
scripts/start_cron.sh | 8 ++--
scripts/start_rpc_service.sh | 26 ++++++----
scripts/style_info.cfg | 0
34 files changed, 156 insertions(+), 144 deletions(-)
delete mode 100755 scripts/build_images.sh
mode change 100644 => 100755 scripts/path_info.cfg
mode change 100644 => 100755 scripts/style_info.cfg
diff --git a/.gitignore b/.gitignore
index 7ca2fe3fd..a547540a7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,8 +32,8 @@ _output/
### OpenIM deploy ###
deploy/openim_demo
deploy/openim-api
-deploy/openim_msg_gateway
-deploy/openim_msg_transfer
+deploy/openim-rpc-msg_gateway
+deploy/openim-rpc-msg_transfer
deploy/openim-push
deploy/openim_timer_task
deploy/openim-rpc-user
diff --git a/cmd/openim-crontask/Makefile b/cmd/openim-crontask/Makefile
index 1f09bf396..58528ccb5 100644
--- a/cmd/openim-crontask/Makefile
+++ b/cmd/openim-crontask/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim_cron_task
+NAME=openim-crontask
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim-crontask/deploy.Dockerfile b/cmd/openim-crontask/deploy.Dockerfile
index 07d328474..ba5230c42 100644
--- a/cmd/openim-crontask/deploy.Dockerfile
+++ b/cmd/openim-crontask/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_cron_task ./
+COPY ./openim-crontask ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim_cron_task"]
+CMD ["./openim-crontask"]
diff --git a/cmd/openim-msggateway/Makefile b/cmd/openim-msggateway/Makefile
index 07cad40a9..d5238beae 100644
--- a/cmd/openim-msggateway/Makefile
+++ b/cmd/openim-msggateway/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim_msg_gateway
+NAME=openim-rpc-msg_gateway
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim-msggateway/deploy.Dockerfile b/cmd/openim-msggateway/deploy.Dockerfile
index eab3d16db..7ba0d2235 100644
--- a/cmd/openim-msggateway/deploy.Dockerfile
+++ b/cmd/openim-msggateway/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_msg_gateway ./
+COPY ./openim-rpc-msg_gateway ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim_msg_gateway","--port", "10140" "--ws_port", "10001", "--prometheus_port", "20240"]
+CMD ["./openim-rpc-msg_gateway","--port", "10140" "--ws_port", "10001", "--prometheus_port", "20240"]
diff --git a/cmd/openim-msgtransfer/Makefile b/cmd/openim-msgtransfer/Makefile
index dc22834de..9d4aa7dec 100644
--- a/cmd/openim-msgtransfer/Makefile
+++ b/cmd/openim-msgtransfer/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim_msg_transfer
+NAME=openim-rpc-msg_transfer
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim-msgtransfer/deploy.Dockerfile b/cmd/openim-msgtransfer/deploy.Dockerfile
index 91767adf4..747b7f422 100644
--- a/cmd/openim-msgtransfer/deploy.Dockerfile
+++ b/cmd/openim-msgtransfer/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_msg_transfer ./
+COPY ./openim-rpc-msg_transfer ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim_msg_transfer","--prometheus_port", "21400"]
+CMD ["./openim-rpc-msg_transfer","--prometheus_port", "21400"]
diff --git a/cmd/openim-rpc/openim-rpc-auth/Makefile b/cmd/openim-rpc/openim-rpc-auth/Makefile
index f702786ae..068d50fd8 100644
--- a/cmd/openim-rpc/openim-rpc-auth/Makefile
+++ b/cmd/openim-rpc/openim-rpc-auth/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim_auth
+NAME=openim-rpc-auth
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile
index 1fc1682dd..b529860f9 100644
--- a/cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile
+++ b/cmd/openim-rpc/openim-rpc-auth/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_auth ./
+COPY ./openim-rpc-auth ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim_auth", "--port", "10160"]
+CMD ["./openim-rpc-auth", "--port", "10160"]
diff --git a/cmd/openim-rpc/openim-rpc-conversation/Makefile b/cmd/openim-rpc/openim-rpc-conversation/Makefile
index fa973060e..4c9726011 100644
--- a/cmd/openim-rpc/openim-rpc-conversation/Makefile
+++ b/cmd/openim-rpc/openim-rpc-conversation/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim_conversation
+NAME=openim-rpc-conversation
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile
index 5aab79104..33e5c93c1 100644
--- a/cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile
+++ b/cmd/openim-rpc/openim-rpc-conversation/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_conversation ./
+COPY ./openim-rpc-conversation ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim_conversation", "--port", "10230", "--prometheus_port","20230"]
+CMD ["./openim-rpc-conversation", "--port", "10230", "--prometheus_port","20230"]
diff --git a/cmd/openim-rpc/openim-rpc-friend/Makefile b/cmd/openim-rpc/openim-rpc-friend/Makefile
index 8cbb39c2b..e0068e97d 100644
--- a/cmd/openim-rpc/openim-rpc-friend/Makefile
+++ b/cmd/openim-rpc/openim-rpc-friend/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim_friend
+NAME=openim-rpc-friend
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile
index 3aaf86885..f306a7938 100644
--- a/cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile
+++ b/cmd/openim-rpc/openim-rpc-friend/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_friend ./
+COPY ./openim-rpc-friend ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim_friend", "--port", "10120", "--prometheus_port","20120"]
+CMD ["./openim-rpc-friend", "--port", "10120", "--prometheus_port","20120"]
diff --git a/cmd/openim-rpc/openim-rpc-group/Makefile b/cmd/openim-rpc/openim-rpc-group/Makefile
index b33dbb259..8ba79043d 100644
--- a/cmd/openim-rpc/openim-rpc-group/Makefile
+++ b/cmd/openim-rpc/openim-rpc-group/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim_group
+NAME=openim-rpc-group
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile
index 1adb00bc5..ed46edcf7 100644
--- a/cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile
+++ b/cmd/openim-rpc/openim-rpc-group/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_group ./
+COPY ./openim-rpc-group ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim_group", "--port", "10150", "--prometheus_port","20150"]
+CMD ["./openim-rpc-group", "--port", "10150", "--prometheus_port","20150"]
diff --git a/cmd/openim-rpc/openim-rpc-msg/Makefile b/cmd/openim-rpc/openim-rpc-msg/Makefile
index b27c5c420..872fbfbba 100644
--- a/cmd/openim-rpc/openim-rpc-msg/Makefile
+++ b/cmd/openim-rpc/openim-rpc-msg/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim_msg
+NAME=openim-rpc-msg
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile
index 10fd29f0a..61737417e 100644
--- a/cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile
+++ b/cmd/openim-rpc/openim-rpc-msg/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_msg ./
+COPY ./openim-rpc-msg ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim_msg", "--port", "10130", "--prometheus_port","20130"]
+CMD ["./openim-rpc-msg", "--port", "10130", "--prometheus_port","20130"]
diff --git a/cmd/openim-rpc/openim-rpc-third/Makefile b/cmd/openim-rpc/openim-rpc-third/Makefile
index b5a7c546a..28059b2c4 100644
--- a/cmd/openim-rpc/openim-rpc-third/Makefile
+++ b/cmd/openim-rpc/openim-rpc-third/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim_third
+NAME=openim-rpc-third
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile
index 7b6a1dfaf..29bc2d068 100644
--- a/cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile
+++ b/cmd/openim-rpc/openim-rpc-third/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_third ./
+COPY ./openim-rpc-third ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim_third", "--port", "10200"]
+CMD ["./openim-rpc-third", "--port", "10200"]
diff --git a/cmd/openim-rpc/openim-rpc-user/Makefile b/cmd/openim-rpc/openim-rpc-user/Makefile
index aef2d605a..1a7eed913 100644
--- a/cmd/openim-rpc/openim-rpc-user/Makefile
+++ b/cmd/openim-rpc/openim-rpc-user/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim_user
+NAME=openim-rpc-user
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile b/cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile
index 0977dd634..8ab7df1e7 100644
--- a/cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile
+++ b/cmd/openim-rpc/openim-rpc-user/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim_user ./
+COPY ./openim-rpc-user ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim_user", "--port", "10110"]
+CMD ["./openim-rpc-user", "--port", "10110"]
diff --git a/docs/.generated_docs b/docs/.generated_docs
index d46d40d88..4145ed52c 100644
--- a/docs/.generated_docs
+++ b/docs/.generated_docs
@@ -26,12 +26,12 @@ docs/guide/en-US/cmd/openim/openim_secret_get.md
docs/guide/en-US/cmd/openim/openim_secret_list.md
docs/guide/en-US/cmd/openim/openim_secret_update.md
docs/guide/en-US/cmd/openim/openim_set.md
-docs/guide/en-US/cmd/openim/openim_user.md
-docs/guide/en-US/cmd/openim/openim_user_create.md
-docs/guide/en-US/cmd/openim/openim_user_delete.md
-docs/guide/en-US/cmd/openim/openim_user_get.md
-docs/guide/en-US/cmd/openim/openim_user_list.md
-docs/guide/en-US/cmd/openim/openim_user_update.md
+docs/guide/en-US/cmd/openim/openim-rpc-user.md
+docs/guide/en-US/cmd/openim/openim-rpc-user_create.md
+docs/guide/en-US/cmd/openim/openim-rpc-user_delete.md
+docs/guide/en-US/cmd/openim/openim-rpc-user_get.md
+docs/guide/en-US/cmd/openim/openim-rpc-user_list.md
+docs/guide/en-US/cmd/openim/openim-rpc-user_update.md
docs/guide/en-US/cmd/openim/openim_validate.md
docs/guide/en-US/cmd/openim/openim_version.md
docs/guide/en-US/yaml/openim/openim.yaml
@@ -44,7 +44,7 @@ docs/guide/en-US/yaml/openim/openim_options.yaml
docs/guide/en-US/yaml/openim/openim_policy.yaml
docs/guide/en-US/yaml/openim/openim_secret.yaml
docs/guide/en-US/yaml/openim/openim_set.yaml
-docs/guide/en-US/yaml/openim/openim_user.yaml
+docs/guide/en-US/yaml/openim/openim-rpc-user.yaml
docs/guide/en-US/yaml/openim/openim_validate.yaml
docs/guide/en-US/yaml/openim/openim_version.yaml
docs/man/man1/iam-apiserver.1
diff --git a/scripts/batch_build_all_service.sh b/scripts/batch_build_all_service.sh
index 6c74e1957..79cbb6c64 100755
--- a/scripts/batch_build_all_service.sh
+++ b/scripts/batch_build_all_service.sh
@@ -13,14 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+#Include shell font styles and some basic information
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
-source ./style_info.cfg
-source ./path_info.cfg
-source ./function.sh
+# Include necessary files
+source "$(dirname "${BASH_SOURCE[0]}")/../scripts/function"
+
+# Include specific functions and variables
+source "$(dirname "${BASH_SOURCE[0]}")/../scripts/style_info.cfg" \
+ "$OPENIM_ROOT/scripts/path_info.cfg"
+
+bin_dir="$OPENIM_ROOT/bin"
+logs_dir="$OPENIM_ROOT/logs"
+sdk_db_dir="$OPENIM_ROOT/sdk/db/"
-bin_dir="../bin"
-logs_dir="../logs"
-sdk_db_dir="../db/sdk/"
#Automatically created when there is no bin, logs folder
if [ ! -d $bin_dir ]; then
mkdir -p $bin_dir
diff --git a/scripts/batch_start_all.sh b/scripts/batch_start_all.sh
index 119e85f65..aa7713280 100755
--- a/scripts/batch_start_all.sh
+++ b/scripts/batch_start_all.sh
@@ -16,21 +16,28 @@
#fixme This scripts is the total startup scripts
#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
-#fixme Put the shell scripts name here
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+
+cd "$OPENIM_ROOT/scripts/"
+
need_to_start_server_shell=(
- start_rpc_service.sh
- msg_gateway_start.sh
- push_start.sh
- msg_transfer_start.sh
+ "start_rpc_service.sh"
+ "msg_gateway_start.sh"
+ "push_start.sh"
+ "msg_transfer_start.sh"
)
-time=`date +"%Y-%m-%d %H:%M:%S"`
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========server start time:${time}===========">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
+
+time=$(date +"%Y-%m-%d %H:%M:%S")
+
+for _ in {1..3}; do
+ echo "==========================================================" >> ../logs/openIM.log 2>&1
+done
+
+echo "==========server start time:${time}===========" >> ../logs/openIM.log 2>&1
+
+for _ in {1..3}; do
+ echo "==========================================================" >> ../logs/openIM.log 2>&1
+done
build_pid_array=()
idx=0
diff --git a/scripts/build_images.sh b/scripts/build_images.sh
deleted file mode 100755
index a94bc91d6..000000000
--- a/scripts/build_images.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env bash
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-image=openim/openim_server:v1.0.5
-rm Open-IM-Server -rf
-git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive
-cd Open-IM-Server
-git checkout tuoyun
-cd cmd/Open-IM-SDK-Core/
-git checkout tuoyun
-cd ../../
-docker build -t $image . -f deploy.Dockerfile
-docker push $image
\ No newline at end of file
diff --git a/scripts/check_all.sh b/scripts/check_all.sh
index 65f51c0cf..0bcb782dd 100755
--- a/scripts/check_all.sh
+++ b/scripts/check_all.sh
@@ -47,7 +47,7 @@ for i in ${service_port_name[*]}; do
done
#Check launched service process
-check=$(ps aux | grep -w ./${msg_transfer_name} | grep -v grep | wc -l)
+check=$(ps aux | grep -w ./${openim-msgtransfer} | grep -v grep | wc -l)
if [ $check -eq ${msg_transfer_service_num} ]; then
echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImMsgTransfer"${COLOR_SUFFIX}
else
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index 9602dbbbd..1b6c92ed3 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -73,10 +73,10 @@ EXCLUDE_TESTS=github.com/OpenIMSDK/Open-IM-Server/test github.com/OpenIMSDK/Open
# ├── openim-sdk-core/ - main.go
# ├── openim-api
# ├── openim_cms_api
-# ├── openim_cron_task
+# ├── openim-crontask
# ├── openim_demo
-# ├── openim_msg_gateway
-# ├── openim_msg_transfer
+# ├── openim-rpc-msg_gateway
+# ├── openim-rpc-msg_transfer
# ├── openim-push
# ├── rpc/openim_admin_cms/ - main.go
# └── test/ - main.go
@@ -84,7 +84,7 @@ EXCLUDE_TESTS=github.com/OpenIMSDK/Open-IM-Server/test github.com/OpenIMSDK/Open
# PLATFORM=linux_amd64
# OS=linux
# ARCH=amd64
-# BINS=openim-api openim_cms_api openim_cron_task openim_demo openim_msg_gateway openim_msg_transfer openim-push
+# BINS=openim-api openim_cms_api openim-crontask openim_demo openim-rpc-msg_gateway openim-rpc-msg_transfer openim-push
# BIN_DIR=/root/workspaces/OpenIM/_output/bin
# ==============================================================================
@@ -113,8 +113,8 @@ go.build.%:
@mkdir -p $(BIN_DIR)/platforms/$(OS)/$(ARCH)
@if [ "$(COMMAND)" == "openim-sdk-core" ]; then \
echo "===========> DEBUG: Compilation is not yet supported $(COMMAND)"; \
- elif [ "$(COMMAND)" == "openim_rpc" ]; then \
- for d in $(wildcard $(ROOT_DIR)/cmd/openim_rpc/*); do \
+ elif [ "$(COMMAND)" == "openim-rpc" ]; then \
+ for d in $(wildcard $(ROOT_DIR)/cmd/openim-rpc/*); do \
cd $${d} && CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
$(BIN_DIR)/platforms/$(OS)/$(ARCH)/$$(basename $${d})$(GO_OUT_EXT) $${d}/main.go; \
done; \
diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh
index c7cbc4823..9f2016be7 100755
--- a/scripts/msg_gateway_start.sh
+++ b/scripts/msg_gateway_start.sh
@@ -36,9 +36,9 @@ if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then
fi
#Check if the service exists
#If it is exists,kill this process
-check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l)
+check=$(ps aux | grep -w ./${openim-msggateway} | grep -v grep | wc -l)
if [ $check -ge 1 ]; then
- oldPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}')
+ oldPid=$(ps aux | grep -w ./${openim-msggateway} | grep -v grep | awk '{print $2}')
kill -9 ${oldPid}
fi
#Waiting port recycling
@@ -46,23 +46,23 @@ sleep 1
cd ${msg_gateway_binary_root}
for ((i = 0; i < ${#ws_ports[@]}; i++)); do
echo "==========================start msg_gateway server===========================">>../logs/openIM.log
- nohup ./${msg_gateway_name} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} >>../logs/openIM.log 2>&1 &
+ nohup ./${openim-msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} >>../logs/openIM.log 2>&1 &
done
#Check launched service process
sleep 3
-check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l)
+check=$(ps aux | grep -w ./${openim-msggateway} | grep -v grep | wc -l)
allPorts=""
if [ $check -ge 1 ]; then
- allNewPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}')
+ allNewPid=$(ps aux | grep -w ./${openim-msggateway} | grep -v grep | awk '{print $2}')
for i in $allNewPid; do
ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}')
allPorts=${allPorts}"$ports "
done
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS"${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${openim-msggateway}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${YELLOW_PREFIX}${openim-msggateway}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh
index 460d2e1c8..01118af32 100755
--- a/scripts/msg_transfer_start.sh
+++ b/scripts/msg_transfer_start.sh
@@ -14,21 +14,29 @@
# limitations under the License.
#Include shell font styles and some basic information
-source ./style_info.cfg
-source ./path_info.cfg
-source ./function.sh
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+
+#Include shell font styles and some basic information
+source $OPENIM_ROOT/scripts/style_info.cfg
+source $OPENIM_ROOT/scripts/path_info.cfg
+source $OPENIM_ROOT/scripts/function
+
+bin_dir="$OPENIM_ROOT/bin"
+logs_dir="$OPENIM_ROOT/logs"
+sdk_db_dir="$OPENIM_ROOT/sdk/db/"
+
+cd $OPENIM_ROOT
list1=$(cat $config_path | grep messageTransferPrometheusPort | awk -F '[:]' '{print $NF}')
list_to_string $list1
prome_ports=($ports_array)
-
#Check if the service exists
#If it is exists,kill this process
-check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l`
+check=`ps aux | grep -w ./${openim-msgtransfer} | grep -v grep| wc -l`
if [ $check -ge 1 ]
then
-oldPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'`
+oldPid=`ps aux | grep -w ./${openim-msgtransfer} | grep -v grep|awk '{print $2}'`
kill -9 $oldPid
fi
#Waiting port recycling
@@ -37,7 +45,7 @@ sleep 1
cd ${msg_transfer_binary_root}
for ((i = 0; i < ${msg_transfer_service_num}; i++)); do
prome_port=${prome_ports[$i]}
- cmd="nohup ./${msg_transfer_name}"
+ cmd="nohup ./${openim-msgtransfer}"
if [ $prome_port != "" ]; then
cmd="$cmd --prometheus_port $prome_port"
fi
@@ -46,15 +54,15 @@ for ((i = 0; i < ${msg_transfer_service_num}; i++)); do
done
#Check launched service process
-check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l`
+check=`ps aux | grep -w ./${openim-msgtransfer} | grep -v grep| wc -l`
if [ $check -ge 1 ]
then
-newPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'`
+newPid=`ps aux | grep -w ./${openim-msgtransfer} | grep -v grep|awk '{print $2}'`
allPorts=""
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${openim-msgtransfer}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${YELLOW_PREFIX}${openim-msgtransfer}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
diff --git a/scripts/path_info.cfg b/scripts/path_info.cfg
old mode 100644
new mode 100755
index aa36164ae..72759b2a4
--- a/scripts/path_info.cfg
+++ b/scripts/path_info.cfg
@@ -2,6 +2,8 @@
architecture=$(uname -m)
version=$(uname -s | tr '[:upper:]' '[:lower:]')
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+
# Define the supported architectures and corresponding bin directories
declare -A supported_architectures=(
["linux-amd64"]="_output/bin/platforms/linux/amd64"
@@ -18,40 +20,43 @@ declare -A supported_architectures=(
# Check if the architecture and version are supported
if [[ -z ${supported_architectures["$version-$architecture"]} ]]; then
- echo "Unsupported architecture: $architecture or version: $version"
+ echo "================> Unsupported architecture: $architecture or version: $version"
exit 1
fi
+echo "================> Architecture: $architecture"
+
# Set the BIN_DIR based on the architecture and version
BIN_DIR=${supported_architectures["$version-$architecture"]}
-echo "BIN_DIR: $BIN_DIR"
+echo "================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR"
+
# Don't put the space between "="
-msg_gateway_name="openim-msggateway"
-msg_gateway_binary_root= $BIN_DIR
+openim_msggateway="openim-msggateway"
+msg_gateway_binary_root= $OPENIM_ROOT/$BIN_DIR/
msg_gateway_source_root="../cmd/msggateway/"
-msg_name="openim_msg"
-msg_binary_root=$BIN_DIR
+msg_name="openim-rpc-msg"
+msg_binary_root=$OPENIM_ROOT/$BIN_DIR
msg_source_root="../cmd/rpc/msg/"
push_name="openim-push"
-push_binary_root=$BIN_DIR
+push_binary_root=$OPENIM_ROOT/$BIN_DIR
push_source_root="../cmd/push/"
-msg_transfer_name="openim_msg_transfer"
-msg_transfer_binary_root=$BIN_DIR
+openim_msgtransfer="openim-rpc-msg_transfer"
+msg_transfer_binary_root=$OPENIM_ROOT/$BIN_DIR
msg_transfer_source_root="../cmd/msgtransfer/"
msg_transfer_service_num=4
-cron_task_name="openim_cron_task"
-cron_task_binary_root=$BIN_DIR
+cron_task_name="openim-crontask"
+cron_task_binary_root=$OPENIM_ROOT/$BIN_DIR
cron_task_source_root="../cmd/crontask/"
cmd_utils_name="openim_cmd_utils"
-cmd_utils_binary_root=$BIN_DIR
+cmd_utils_binary_root=$OPENIM_ROOT/$BIN_DIR
cmd_utils_source_root="../cmd/cmduitls/"
# Global configuration file default dir
@@ -81,15 +86,15 @@ service_names=(
# api service filename
"openim-api"
# rpc service filename
- "openim_user"
- "openim_friend"
- "openim_group"
- "openim_auth"
- "openim_conversation"
- "openim_third"
- "openim_cron_task"
- "${msg_gateway_name}"
- "${msg_transfer_name}"
+ "openim-rpc-user"
+ "openim-rpc-friend"
+ "openim-rpc-group"
+ "openim-rpc-auth"
+ "openim-rpc-conversation"
+ "openim-rpc-third"
+ "openim-crontask"
+ "${openim_msggateway}"
+ "${openim_msgtransfer}"
"${msg_name}"
"${push_name}"
# "${sdk_server_name}"
diff --git a/scripts/start_all.sh b/scripts/start_all.sh
index c16ae3a11..b847ef89b 100755
--- a/scripts/start_all.sh
+++ b/scripts/start_all.sh
@@ -20,6 +20,8 @@
source ./style_info.cfg
source ./path_info.cfg
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+
# Print title
echo -e "${BOLD_PREFIX}${BLUE_PREFIX}OpenIM Server Start${COLOR_SUFFIX}"
@@ -35,6 +37,7 @@ echo -e "${BOLD_PREFIX}${CYAN_PREFIX}Server Start Time: ${time}${COLOR_SUFFIX}"
# Print section separator
echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
+cd $OPENIM_ROOT/scripts
# FIXME Put the shell script names here
need_to_start_server_shell=(
start_rpc_service.sh
@@ -65,7 +68,7 @@ for i in ${need_to_start_server_shell[*]}; do
done
# Print section separator
-echo "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
+echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
# Print completion message
-echo "${GREEN_PREFIX}${BOLD_PREFIX}OpenIM Server has been started successfully!${COLOR_SUFFIX}"
\ No newline at end of file
+echo -e "${GREEN_PREFIX}${BOLD_PREFIX}OpenIM Server has been started successfully!${COLOR_SUFFIX}"
\ No newline at end of file
diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh
index 5aa29c1c7..efe06d8f7 100755
--- a/scripts/start_cron.sh
+++ b/scripts/start_cron.sh
@@ -13,11 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#Include shell font styles and some basic information
-source ./style_info.cfg
-source ./path_info.cfg
-
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+#Include shell font styles and some basic information
+source $OPENIM_ROOT/scripts/style_info.cfg
+source $OPENIM_ROOT/scripts/path_info.cfg
#Check if the service exists
#If it is exists,kill this process
diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh
index 379dba474..940bf57c6 100755
--- a/scripts/start_rpc_service.sh
+++ b/scripts/start_rpc_service.sh
@@ -13,23 +13,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
-source ./style_info.cfg
-source ./path_info.cfg
-source ./function.sh
+#Include shell font styles and some basic information
+source $OPENIM_ROOT/scripts/style_info.cfg
+source $OPENIM_ROOT/scripts/path_info.cfg
+source $OPENIM_ROOT/scripts/function
+
+bin_dir="$OPENIM_ROOT/bin"
+logs_dir="$OPENIM_ROOT/logs"
+sdk_db_dir="$OPENIM_ROOT/sdk/db/"
+
+cd $OPENIM_ROOT
#service filename
service_filename=(
#api
openim-api
#rpc
- openim_user
- openim_friend
- openim_group
- openim_auth
+ openim-rpc-user
+ openim-rpc-friend
+ openim-rpc-group
+ openim-rpc-auth
${msg_name}
- openim_conversation
- openim_third
+ openim-rpc-conversation
+ openim-rpc-third
)
#service config port name
diff --git a/scripts/style_info.cfg b/scripts/style_info.cfg
old mode 100644
new mode 100755
From 396f455c778e32c1d58c0bb192959b05d160da33 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 21:59:28 +0800
Subject: [PATCH 35/73] feat: fix scripts
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/build_all_service.sh | 2 +-
scripts/enterprise/path_info.cfg | 2 +-
scripts/githooks/pre-push | 15 +++++++++++++++
scripts/msg_gateway_start.sh | 14 +++++++++++---
scripts/path_info.cfg | 2 +-
scripts/push_start.sh | 15 ++++++++++++---
scripts/start_all.sh | 14 +++++++++++---
scripts/start_cron.sh | 8 ++++++++
scripts/start_rpc_service.sh | 4 ++--
scripts/stop_all.sh | 14 +++++++++++---
10 files changed, 73 insertions(+), 17 deletions(-)
diff --git a/scripts/build_all_service.sh b/scripts/build_all_service.sh
index 7359b39b3..7a583c970 100755
--- a/scripts/build_all_service.sh
+++ b/scripts/build_all_service.sh
@@ -25,7 +25,7 @@ echo -e "\n"
echo -e "${BOLD_PREFIX}_____ _ _ _____ _____ _____ _____ _____ _____ _____ _____ _____ ${COLOR_SUFFIX}"
-bin_dir="../bin"
+bin_dir="$BIN_DIR"
logs_dir="../logs"
sdk_db_dir="../db/sdk/"
# Automatically created when there is no bin, logs folder
diff --git a/scripts/enterprise/path_info.cfg b/scripts/enterprise/path_info.cfg
index 29d3112c1..168d46049 100644
--- a/scripts/enterprise/path_info.cfg
+++ b/scripts/enterprise/path_info.cfg
@@ -2,7 +2,7 @@
demo_server_name="openim_chat_api"
-demo_server_binary_root="../bin/"
+demo_server_binary_root="$BIN_DIR/"
diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push
index c8ad61a60..39c42832c 100644
--- a/scripts/githooks/pre-push
+++ b/scripts/githooks/pre-push
@@ -40,6 +40,21 @@ if [[ `git status --porcelain` ]]; then
exit 1
fi
+PURPLE_PREFIX="\033[35m" # Purple prefix
+BOLD_PREFIX="\033[1m" # Bold prefix
+
+# Get current time
+time=$(date +"%Y-%m-%d %H:%M:%S")
+
+# Print section separator
+echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
+
+# Print time of submission
+echo -e "${BOLD_PREFIX}${CYAN_PREFIX}Time of submission: ${time}${COLOR_SUFFIX}"
+
+# Print section separator
+echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
+
#
#printMessage "Running the Flutter analyzer"
#flutter analyze
diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh
index 9f2016be7..9f4fb5e5f 100755
--- a/scripts/msg_gateway_start.sh
+++ b/scripts/msg_gateway_start.sh
@@ -14,9 +14,17 @@
# limitations under the License.
#Include shell font styles and some basic information
-source ./style_info.cfg
-source ./path_info.cfg
-source ./function.sh
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+
+#Include shell font styles and some basic information
+source $OPENIM_ROOT/scripts/style_info.cfg
+source $OPENIM_ROOT/scripts/path_info.cfg
+source $OPENIM_ROOT/scripts/function
+
+bin_dir="$OPENIM_ROOT/bin"
+logs_dir="$OPENIM_ROOT/logs"
+sdk_db_dir="$OPENIM_ROOT/sdk/db/"
+
ulimit -n 200000
list1=$(cat $config_path | grep openImMessageGatewayPort | awk -F '[:]' '{print $NF}')
diff --git a/scripts/path_info.cfg b/scripts/path_info.cfg
index 72759b2a4..a86add786 100755
--- a/scripts/path_info.cfg
+++ b/scripts/path_info.cfg
@@ -23,7 +23,7 @@ if [[ -z ${supported_architectures["$version-$architecture"]} ]]; then
echo "================> Unsupported architecture: $architecture or version: $version"
exit 1
fi
-
+Server Start Time
echo "================> Architecture: $architecture"
# Set the BIN_DIR based on the architecture and version
diff --git a/scripts/push_start.sh b/scripts/push_start.sh
index 80da0f575..f13056259 100755
--- a/scripts/push_start.sh
+++ b/scripts/push_start.sh
@@ -14,9 +14,18 @@
# limitations under the License.
#Include shell font styles and some basic information
-source ./style_info.cfg
-source ./path_info.cfg
-source ./function.sh
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+
+#Include shell font styles and some basic information
+source $OPENIM_ROOT/scripts/style_info.cfg
+source $OPENIM_ROOT/scripts/path_info.cfg
+source $OPENIM_ROOT/scripts/function
+
+bin_dir="$OPENIM_ROOT/bin"
+logs_dir="$OPENIM_ROOT/logs"
+sdk_db_dir="$OPENIM_ROOT/sdk/db/"
+
+cd "$OPENIM_ROOT/scripts/"
list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}')
list2=$(cat $config_path | grep pushPrometheusPort | awk -F '[:]' '{print $NF}')
diff --git a/scripts/start_all.sh b/scripts/start_all.sh
index b847ef89b..92134ca44 100755
--- a/scripts/start_all.sh
+++ b/scripts/start_all.sh
@@ -17,11 +17,19 @@
#FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array.
#Include shell font styles and some basic information
-source ./style_info.cfg
-source ./path_info.cfg
-
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+#Include shell font styles and some basic information
+source $OPENIM_ROOT/scripts/style_info.cfg
+source $OPENIM_ROOT/scripts/path_info.cfg
+source $OPENIM_ROOT/scripts/function
+
+bin_dir="$OPENIM_ROOT/bin"
+logs_dir="$OPENIM_ROOT/logs"
+sdk_db_dir="$OPENIM_ROOT/sdk/db/"
+
+cd "$OPENIM_ROOT/scripts/"
+
# Print title
echo -e "${BOLD_PREFIX}${BLUE_PREFIX}OpenIM Server Start${COLOR_SUFFIX}"
diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh
index efe06d8f7..26f9abf8b 100755
--- a/scripts/start_cron.sh
+++ b/scripts/start_cron.sh
@@ -13,11 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+#Include shell font styles and some basic information
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
+source $OPENIM_ROOT/scripts/function
+
+bin_dir="$OPENIM_ROOT/bin"
+logs_dir="$OPENIM_ROOT/logs"
+sdk_db_dir="$OPENIM_ROOT/sdk/db/"
+
+cd "$OPENIM_ROOT/scripts/"
#Check if the service exists
#If it is exists,kill this process
diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh
index 940bf57c6..e67711d49 100755
--- a/scripts/start_rpc_service.sh
+++ b/scripts/start_rpc_service.sh
@@ -20,7 +20,7 @@ source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
source $OPENIM_ROOT/scripts/function
-bin_dir="$OPENIM_ROOT/bin"
+bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
@@ -80,7 +80,7 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
kill -9 $(eval $pid)
sleep 0.5
fi
- cd ../bin
+ cd $
#Get the rpc port in the configuration file
portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}')
list_to_string ${portList}
diff --git a/scripts/stop_all.sh b/scripts/stop_all.sh
index f04779d43..fac3d7f41 100755
--- a/scripts/stop_all.sh
+++ b/scripts/stop_all.sh
@@ -13,11 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#fixme This scripts is to stop the service
+#Include shell font styles and some basic information
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
-source ./style_info.cfg
-source ./path_info.cfg
+#Include shell font styles and some basic information
+source $OPENIM_ROOT/scripts/style_info.cfg
+source $OPENIM_ROOT/scripts/path_info.cfg
+source $OPENIM_ROOT/scripts/function
+bin_dir="$OPENIM_ROOT/bin"
+logs_dir="$OPENIM_ROOT/logs"
+sdk_db_dir="$OPENIM_ROOT/sdk/db/"
+
+cd "$OPENIM_ROOT/scripts/"
for i in ${service_names[*]}; do
#Check whether the service exists
From 44d7f79637aab649f15d3778521975dce594c45a Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 22:00:59 +0800
Subject: [PATCH 36/73] feat: add COLOR_SUFFIX=033[0m # End all colors and
special effects
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/githooks/pre-push | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push
index 39c42832c..d28e63869 100644
--- a/scripts/githooks/pre-push
+++ b/scripts/githooks/pre-push
@@ -40,6 +40,7 @@ if [[ `git status --porcelain` ]]; then
exit 1
fi
+COLOR_SUFFIX="\033[0m" # End all colors and special effects
PURPLE_PREFIX="\033[35m" # Purple prefix
BOLD_PREFIX="\033[1m" # Bold prefix
From 48f1580e04e3672af8dbaa398ad24b818d858651 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 22:05:55 +0800
Subject: [PATCH 37/73] feat: add cyan
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/githooks/pre-push | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push
index d28e63869..2553367b0 100644
--- a/scripts/githooks/pre-push
+++ b/scripts/githooks/pre-push
@@ -40,21 +40,48 @@ if [[ `git status --porcelain` ]]; then
exit 1
fi
-COLOR_SUFFIX="\033[0m" # End all colors and special effects
-PURPLE_PREFIX="\033[35m" # Purple prefix
-BOLD_PREFIX="\033[1m" # Bold prefix
+COLOR_SUFFIX="\033[0m"
+
+BLACK_PREFIX="\033[30m"
+RED_PREFIX="\033[31m"
+GREEN_PREFIX="\033[32m"
+YELLOW_PREFIX="\033[33m"
+BLUE_PREFIX="\033[34m"
+PURPLE_PREFIX="\033[35m"
+SKY_BLUE_PREFIX="\033[36m"
+WHITE_PREFIX="\033[37m"
+BOLD_PREFIX="\033[1m"
+UNDERLINE_PREFIX="\033[4m"
+ITALIC_PREFIX="\033[3m"
+
+# Function to print colored text
+print_color() {
+ local text=$1
+ local color=$2
+ echo -e "${color}${text}${COLOR_SUFFIX}"
+}
+
+# Function to print section separator
+print_separator() {
+ print_color "==========================================================" ${PURPLE_PREFIX}
+}
# Get current time
time=$(date +"%Y-%m-%d %H:%M:%S")
# Print section separator
-echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
+print_separator
# Print time of submission
-echo -e "${BOLD_PREFIX}${CYAN_PREFIX}Time of submission: ${time}${COLOR_SUFFIX}"
+print_color "Time of submission: ${time}" "${BOLD_PREFIX}${CYAN_PREFIX}"
+
+# Print additional information if needed
+print_color "Repository: ${repository}" "${YELLOW_PREFIX}"
+print_color "Author: ${author}" "${YELLOW_PREFIX}"
# Print section separator
-echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
+print_separator
+
#
#printMessage "Running the Flutter analyzer"
From abc538c64fa4d075cbeca48f95fa851e0de1512e Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 22:07:52 +0800
Subject: [PATCH 38/73] feat: add cyan
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/githooks/pre-push | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push
index 2553367b0..ad17b3c48 100644
--- a/scripts/githooks/pre-push
+++ b/scripts/githooks/pre-push
@@ -75,9 +75,12 @@ print_separator
# Print time of submission
print_color "Time of submission: ${time}" "${BOLD_PREFIX}${CYAN_PREFIX}"
+author=$(git config user.name)
+repository=$(basename -s .git $(git config --get remote.origin.url))
+
# Print additional information if needed
-print_color "Repository: ${repository}" "${YELLOW_PREFIX}"
-print_color "Author: ${author}" "${YELLOW_PREFIX}"
+print_color "Repository: ${repository}" "${BLUE_PREFIX}"
+print_color "Author: ${author}" "${PURPLE_PREFIX}"
# Print section separator
print_separator
From 4e648886512d4b5d13ada1bf0c2b99630b962d76 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 22:10:39 +0800
Subject: [PATCH 39/73] feat: add cyan
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/githooks/pre-push | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push
index ad17b3c48..8752023c6 100644
--- a/scripts/githooks/pre-push
+++ b/scripts/githooks/pre-push
@@ -73,13 +73,14 @@ time=$(date +"%Y-%m-%d %H:%M:%S")
print_separator
# Print time of submission
-print_color "Time of submission: ${time}" "${BOLD_PREFIX}${CYAN_PREFIX}"
-
-author=$(git config user.name)
-repository=$(basename -s .git $(git config --get remote.origin.url))
+print_color "PTIME: ${time}" "${BOLD_PREFIX}${CYAN_PREFIX}"
+echo ""
+Author=$(git config user.name)
+Repository=$(basename -s .git $(git config --get remote.origin.url))
# Print additional information if needed
print_color "Repository: ${repository}" "${BLUE_PREFIX}"
+echo ""
print_color "Author: ${author}" "${PURPLE_PREFIX}"
# Print section separator
From f4cef32b9552131112ddb5d76075eccc8f38f74f Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 22:12:30 +0800
Subject: [PATCH 40/73] feat: add cyan
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/githooks/pre-push | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push
index 8752023c6..97d426487 100644
--- a/scripts/githooks/pre-push
+++ b/scripts/githooks/pre-push
@@ -75,17 +75,34 @@ print_separator
# Print time of submission
print_color "PTIME: ${time}" "${BOLD_PREFIX}${CYAN_PREFIX}"
echo ""
-Author=$(git config user.name)
-Repository=$(basename -s .git $(git config --get remote.origin.url))
+author=$(git config user.name)
+repository=$(basename -s .git $(git config --get remote.origin.url))
# Print additional information if needed
print_color "Repository: ${repository}" "${BLUE_PREFIX}"
echo ""
+
print_color "Author: ${author}" "${PURPLE_PREFIX}"
# Print section separator
print_separator
+# 获取变更的文件列表
+file_list=$(git diff --name-status HEAD @{u})
+added_files=$(grep -c '^A' <<< "$file_list")
+modified_files=$(grep -c '^M' <<< "$file_list")
+deleted_files=$(grep -c '^D' <<< "$file_list")
+
+# 打印变更的文件统计
+print_color "Added Files: ${added_files}" "${YELLOW_PREFIX}"
+print_color "Modified Files: ${modified_files}" "${YELLOW_PREFIX}"
+print_color "Deleted Files: ${deleted_files}" "${YELLOW_PREFIX}"
+
+# 获取最近一次提交的摘要信息
+commit_message=$(git log -1 --pretty=format:"%s")
+
+# 打印提交的摘要信息
+print_color "Commit Message: ${commit_message}" "${YELLOW_PREFIX}"
#
#printMessage "Running the Flutter analyzer"
From 94bc02caa24bb6a4a88382f61453a9a687ca4ccc Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 7 Jul 2023 22:13:55 +0800
Subject: [PATCH 41/73] feat: add cyan
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/githooks/pre-push | 8 --------
1 file changed, 8 deletions(-)
diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push
index 97d426487..9087e0cb9 100644
--- a/scripts/githooks/pre-push
+++ b/scripts/githooks/pre-push
@@ -87,23 +87,15 @@ print_color "Author: ${author}" "${PURPLE_PREFIX}"
# Print section separator
print_separator
-# 获取变更的文件列表
file_list=$(git diff --name-status HEAD @{u})
added_files=$(grep -c '^A' <<< "$file_list")
modified_files=$(grep -c '^M' <<< "$file_list")
deleted_files=$(grep -c '^D' <<< "$file_list")
-# 打印变更的文件统计
print_color "Added Files: ${added_files}" "${YELLOW_PREFIX}"
print_color "Modified Files: ${modified_files}" "${YELLOW_PREFIX}"
print_color "Deleted Files: ${deleted_files}" "${YELLOW_PREFIX}"
-# 获取最近一次提交的摘要信息
-commit_message=$(git log -1 --pretty=format:"%s")
-
-# 打印提交的摘要信息
-print_color "Commit Message: ${commit_message}" "${YELLOW_PREFIX}"
-
#
#printMessage "Running the Flutter analyzer"
#flutter analyze
From b6e108774a0f550cb9fdae198fe0a957b20f3b51 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Sun, 9 Jul 2023 14:16:19 +0800
Subject: [PATCH 42/73] fix: directory name
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/batch_build_all_service.sh | 2 +-
scripts/build_all_service.sh | 25 ++++++++++++------------
scripts/enterprise/check_all.sh | 12 +++++++++---
scripts/enterprise/path_info.cfg | 4 ++--
scripts/msg_gateway_start.sh | 2 +-
scripts/msg_transfer_start.sh | 2 +-
scripts/path_info.cfg | 31 +++++++++++++++---------------
scripts/push_start.sh | 2 +-
scripts/start_all.sh | 2 +-
scripts/start_cron.sh | 2 +-
scripts/start_rpc_service.sh | 2 +-
scripts/stop_all.sh | 2 +-
12 files changed, 46 insertions(+), 42 deletions(-)
diff --git a/scripts/batch_build_all_service.sh b/scripts/batch_build_all_service.sh
index 79cbb6c64..83aba4451 100755
--- a/scripts/batch_build_all_service.sh
+++ b/scripts/batch_build_all_service.sh
@@ -17,7 +17,7 @@
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
# Include necessary files
-source "$(dirname "${BASH_SOURCE[0]}")/../scripts/function"
+source "$(dirname "${BASH_SOURCE[0]}")/../scripts.sh"
# Include specific functions and variables
source "$(dirname "${BASH_SOURCE[0]}")/../scripts/style_info.cfg" \
diff --git a/scripts/build_all_service.sh b/scripts/build_all_service.sh
index 7a583c970..aed63a818 100755
--- a/scripts/build_all_service.sh
+++ b/scripts/build_all_service.sh
@@ -17,12 +17,12 @@
source ./style_info.cfg
source ./path_info.cfg
source ./function.sh
-echo -e "\n"
+echo -e ""
echo -e "${BACKGROUND_BLUE}===============> Building all using make build binary files ${COLOR_SUFFIX}"
-echo -e "\n"
-echo -e "${BOLD_PREFIX}_____ _ _ _____ _____ _____ _____ _____ _____ _____ _____ _____ ${COLOR_SUFFIX}"
+echo -e ""
+echo -e "${BOLD_PREFIX}____________________________________________________________ ${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
@@ -39,14 +39,13 @@ if [ ! -d $sdk_db_dir ]; then
mkdir -p $sdk_db_dir
fi
-# OpenIM root path
+#Include shell font styles and some basic information
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
-source ./style_info.cfg
-source ./path_info.cfg
-source ./function.sh
-
-#!/bin/bash
+#Include shell font styles and some basic information
+source $OPENIM_ROOT/scripts/style_info.cfg
+source $OPENIM_ROOT/scripts/path_info.cfg
+source $OPENIM_ROOT/scripts/function.sh
cd $OPENIM_ROOT
@@ -102,11 +101,11 @@ for binary in $(find _output/bin/platforms/$REPO_DIR -type f); do
fi
done
-echo -e " \n"
+echo -e " "
echo -e "${BOLD_PREFIX}=====================> Build Results <=====================${COLOR_SUFFIX}"
-echo -e " \n"
+echo -e " "
if [[ "$BUILD_SUCCESS" == true ]]; then
echo -e "${GREEN_PREFIX}All binaries built successfully.${COLOR_SUFFIX}"
@@ -117,8 +116,8 @@ else
done
fi
-echo -e " \n"
+echo -e " "
echo -e "${BOLD_PREFIX}============================================================${COLOR_SUFFIX}"
-echo -e " \n"
+echo -e " "
diff --git a/scripts/enterprise/check_all.sh b/scripts/enterprise/check_all.sh
index 893e1bf32..8c9d3a82a 100755
--- a/scripts/enterprise/check_all.sh
+++ b/scripts/enterprise/check_all.sh
@@ -13,10 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+#Include shell font styles and some basic information
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+
+#Include shell font styles and some basic information
+source $OPENIM_ROOT/scripts/style_info.cfg
+source $OPENIM_ROOT/scripts/path_info.cfg
+source $OPENIM_ROOT/scripts/function.sh
+
+cd "$OPENIM_ROOT/scripts/"
-source ./style_info.cfg
-source ./enterprise/path_info.cfg
-source ./enterprise/function.sh
service_port_name=(
openImChatApiPort
openImAdminApiPort
diff --git a/scripts/enterprise/path_info.cfg b/scripts/enterprise/path_info.cfg
index 168d46049..6ce712593 100644
--- a/scripts/enterprise/path_info.cfg
+++ b/scripts/enterprise/path_info.cfg
@@ -15,8 +15,8 @@ service_source_root=(
../cmd/api/chat/
../cmd/api/admin/
#rpc service file
- ../cmd/rpc/admin/
- ../cmd/rpc/chat/
+ ../cmd/openim-rpc/admin/
+ ../cmd/openim-rpc/chat/
)
#service filename
service_names=(
diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh
index 9f4fb5e5f..5ca720aa8 100755
--- a/scripts/msg_gateway_start.sh
+++ b/scripts/msg_gateway_start.sh
@@ -19,7 +19,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function
+source $OPENIM_ROOT/scripts/function.sh
bin_dir="$OPENIM_ROOT/bin"
logs_dir="$OPENIM_ROOT/logs"
diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh
index 01118af32..2cd1ff8d7 100755
--- a/scripts/msg_transfer_start.sh
+++ b/scripts/msg_transfer_start.sh
@@ -19,7 +19,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function
+source $OPENIM_ROOT/scripts/function.sh
bin_dir="$OPENIM_ROOT/bin"
logs_dir="$OPENIM_ROOT/logs"
diff --git a/scripts/path_info.cfg b/scripts/path_info.cfg
index a86add786..6c031c8b3 100755
--- a/scripts/path_info.cfg
+++ b/scripts/path_info.cfg
@@ -23,7 +23,7 @@ if [[ -z ${supported_architectures["$version-$architecture"]} ]]; then
echo "================> Unsupported architecture: $architecture or version: $version"
exit 1
fi
-Server Start Time
+
echo "================> Architecture: $architecture"
# Set the BIN_DIR based on the architecture and version
@@ -31,32 +31,31 @@ BIN_DIR=${supported_architectures["$version-$architecture"]}
echo "================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR"
-
# Don't put the space between "="
openim_msggateway="openim-msggateway"
-msg_gateway_binary_root= $OPENIM_ROOT/$BIN_DIR/
+msg_gateway_binary_root="$OPENIM_ROOT/$BIN_DIR"
msg_gateway_source_root="../cmd/msggateway/"
msg_name="openim-rpc-msg"
-msg_binary_root=$OPENIM_ROOT/$BIN_DIR
-msg_source_root="../cmd/rpc/msg/"
+msg_binary_root="$OPENIM_ROOT/$BIN_DIR"
+msg_source_root="../cmd/openim-rpc/msg/"
push_name="openim-push"
-push_binary_root=$OPENIM_ROOT/$BIN_DIR
+push_binary_root="$OPENIM_ROOT/$BIN_DIR"
push_source_root="../cmd/push/"
openim_msgtransfer="openim-rpc-msg_transfer"
-msg_transfer_binary_root=$OPENIM_ROOT/$BIN_DIR
+msg_transfer_binary_root="$OPENIM_ROOT/$BIN_DIR"
msg_transfer_source_root="../cmd/msgtransfer/"
msg_transfer_service_num=4
cron_task_name="openim-crontask"
-cron_task_binary_root=$OPENIM_ROOT/$BIN_DIR
+cron_task_binary_root="$OPENIM_ROOT/$BIN_DIR"
cron_task_source_root="../cmd/crontask/"
cmd_utils_name="openim_cmd_utils"
-cmd_utils_binary_root=$OPENIM_ROOT/$BIN_DIR
+cmd_utils_binary_root="$OPENIM_ROOT/$BIN_DIR"
cmd_utils_source_root="../cmd/cmduitls/"
# Global configuration file default dir
@@ -67,13 +66,13 @@ service_source_root=(
# api service file
"../cmd/api/"
# rpc service file
- "../cmd/rpc/user/"
- "../cmd/rpc/friend/"
- "../cmd/rpc/group/"
- "../cmd/rpc/auth/"
- "../cmd/rpc/conversation/"
- "../cmd/rpc/third/"
- "../cmd/crontask"
+ "../cmd/openim-rpc/openim-rpc-user/"
+ "../cmd/openim-rpc/openim-rpc-friend/"
+ "../cmd/openim-rpc/openim-rpc-group/"
+ "../cmd/openim-rpc/openim-rpc-auth/"
+ "../cmd/openim-rpc/openim-rpc-conversation/"
+ "../cmd/openim-rpc/openim-rpc-third/"
+ "../cmd/openim-crontask"
"${msg_gateway_source_root}"
"${msg_transfer_source_root}"
"${msg_source_root}"
diff --git a/scripts/push_start.sh b/scripts/push_start.sh
index f13056259..c2a8e7d36 100755
--- a/scripts/push_start.sh
+++ b/scripts/push_start.sh
@@ -19,7 +19,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function
+source $OPENIM_ROOT/scripts/function.sh
bin_dir="$OPENIM_ROOT/bin"
logs_dir="$OPENIM_ROOT/logs"
diff --git a/scripts/start_all.sh b/scripts/start_all.sh
index 92134ca44..7a9fd656c 100755
--- a/scripts/start_all.sh
+++ b/scripts/start_all.sh
@@ -22,7 +22,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function
+source $OPENIM_ROOT/scripts/function.sh
bin_dir="$OPENIM_ROOT/bin"
logs_dir="$OPENIM_ROOT/logs"
diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh
index 26f9abf8b..b18d19478 100755
--- a/scripts/start_cron.sh
+++ b/scripts/start_cron.sh
@@ -19,7 +19,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function
+source $OPENIM_ROOT/scripts/function.sh
bin_dir="$OPENIM_ROOT/bin"
logs_dir="$OPENIM_ROOT/logs"
diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh
index e67711d49..028bdc8c8 100755
--- a/scripts/start_rpc_service.sh
+++ b/scripts/start_rpc_service.sh
@@ -18,7 +18,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function
+source $OPENIM_ROOT/scripts/function.sh
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
diff --git a/scripts/stop_all.sh b/scripts/stop_all.sh
index fac3d7f41..133bb9577 100755
--- a/scripts/stop_all.sh
+++ b/scripts/stop_all.sh
@@ -19,7 +19,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function
+source $OPENIM_ROOT/scripts/function.sh
bin_dir="$OPENIM_ROOT/bin"
logs_dir="$OPENIM_ROOT/logs"
From 7426ee0abe4c605e6256612fe9bb808e70a48ee9 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Sun, 9 Jul 2023 15:28:19 +0800
Subject: [PATCH 43/73] feat: sets the absolute path of the script
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
init_docker.sh | 33 ++++++++++++++++++++++++------
scripts/batch_build_all_service.sh | 2 +-
scripts/init_pwd.sh | 8 ++------
scripts/msg_gateway_start.sh | 2 +-
scripts/msg_transfer_start.sh | 2 +-
scripts/path_info.cfg | 23 ++++++++++++++++-----
scripts/push_start.sh | 2 +-
scripts/start_all.sh | 23 ++++++++++++---------
scripts/start_cron.sh | 2 +-
scripts/start_rpc_service.sh | 16 +++++++++++----
scripts/stop_all.sh | 2 +-
11 files changed, 78 insertions(+), 37 deletions(-)
diff --git a/init_docker.sh b/init_docker.sh
index edc1df58d..09213bf50 100644
--- a/init_docker.sh
+++ b/init_docker.sh
@@ -1,9 +1,30 @@
#!/usr/bin/env bash
-cd scripts ;
-chmod +x *.sh ;
-./env_check.sh;
-cd .. ;
-docker-compose up -d;
-cd scripts ;
+set -e
+
+# Change directory to the 'scripts' folder
+cd scripts
+
+# Grant execute permissions to all shell scripts in the 'scripts' folder
+chmod +x *.sh
+
+# Run the 'env_check.sh' script for environment checks
+./env_check.sh
+
+# Move back to the parent directory
+cd ..
+
+# Check if Docker is installed
+if ! command -v docker >/dev/null 2>&1; then
+ echo "Error: Docker is not installed. Please install Docker before running this script."
+ exit 1
+fi
+
+# Start Docker services using docker-compose
+docker-compose up -d
+
+# Move back to the 'scripts' folder
+cd scripts
+
+# Run the 'docker_check_service.sh' script for Docker service checks
./docker_check_service.sh
diff --git a/scripts/batch_build_all_service.sh b/scripts/batch_build_all_service.sh
index 83aba4451..7bb75de77 100755
--- a/scripts/batch_build_all_service.sh
+++ b/scripts/batch_build_all_service.sh
@@ -23,7 +23,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/../scripts.sh"
source "$(dirname "${BASH_SOURCE[0]}")/../scripts/style_info.cfg" \
"$OPENIM_ROOT/scripts/path_info.cfg"
-bin_dir="$OPENIM_ROOT/bin"
+bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
diff --git a/scripts/init_pwd.sh b/scripts/init_pwd.sh
index fa8296724..25ee559a3 100755
--- a/scripts/init_pwd.sh
+++ b/scripts/init_pwd.sh
@@ -1,3 +1,5 @@
+#!/bin/bash
+
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +16,6 @@
source ../.env
-
# Check if PASSWORD only contains letters and numbers
if [[ "$PASSWORD" =~ ^[a-zA-Z0-9]+$ ]]
then
@@ -24,15 +25,11 @@ else
exit
fi
-
echo "your user is:$USER"
echo "your password is:$PASSWORD"
echo "your minio endPoint is:$MINIO_ENDPOINT"
echo "your data dir is $DATA_DIR"
-
-#!/bin/bash
-
# Specify the config file
config_file='../config/config.yaml'
@@ -57,4 +54,3 @@ sed -i '/minio:/,/endpoint:/s|endpoint: .*|endpoint: '${MINIO_ENDPOINT}'|' $conf
# Replace secret for token
sed -i "s/secret: .*/secret: $PASSWORD/" $config_file
-
diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh
index 5ca720aa8..62a8479c9 100755
--- a/scripts/msg_gateway_start.sh
+++ b/scripts/msg_gateway_start.sh
@@ -21,7 +21,7 @@ source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
source $OPENIM_ROOT/scripts/function.sh
-bin_dir="$OPENIM_ROOT/bin"
+bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh
index 2cd1ff8d7..50c01cb9d 100755
--- a/scripts/msg_transfer_start.sh
+++ b/scripts/msg_transfer_start.sh
@@ -21,7 +21,7 @@ source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
source $OPENIM_ROOT/scripts/function.sh
-bin_dir="$OPENIM_ROOT/bin"
+bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
diff --git a/scripts/path_info.cfg b/scripts/path_info.cfg
index 6c031c8b3..57f328a47 100755
--- a/scripts/path_info.cfg
+++ b/scripts/path_info.cfg
@@ -2,7 +2,20 @@
architecture=$(uname -m)
version=$(uname -s | tr '[:upper:]' '[:lower:]')
-OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
+
+#Include shell font styles and some basic information
+source $SCRIPTS_ROOT/style_info.cfg
+source $SCRIPTS_ROOT/path_info.cfg
+source $SCRIPTS_ROOT/function.sh
+
+cd $SCRIPTS_ROOT
+
+echo -e "${BACKGROUND_YELLOW}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_YELLOW}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_YELLOW}=======>pwd=$PWD${COLOR_SUFFIX}"
# Define the supported architectures and corresponding bin directories
declare -A supported_architectures=(
@@ -46,20 +59,20 @@ push_source_root="../cmd/push/"
openim_msgtransfer="openim-rpc-msg_transfer"
msg_transfer_binary_root="$OPENIM_ROOT/$BIN_DIR"
-msg_transfer_source_root="../cmd/msgtransfer/"
+msg_transfer_source_root="$OPENIM_ROOT/cmd/msgtransfer/"
msg_transfer_service_num=4
cron_task_name="openim-crontask"
cron_task_binary_root="$OPENIM_ROOT/$BIN_DIR"
-cron_task_source_root="../cmd/crontask/"
+cron_task_source_root="$OPENIM_ROOT/cmd/crontask/"
cmd_utils_name="openim_cmd_utils"
cmd_utils_binary_root="$OPENIM_ROOT/$BIN_DIR"
-cmd_utils_source_root="../cmd/cmduitls/"
+cmd_utils_source_root="$OPENIM_ROOT/cmd/cmduitls/"
# Global configuration file default dir
-config_path="../config/config.yaml"
+config_path="$OPENIM_ROOT/config/config.yaml"
# servicefile dir path
service_source_root=(
diff --git a/scripts/push_start.sh b/scripts/push_start.sh
index c2a8e7d36..204f710e7 100755
--- a/scripts/push_start.sh
+++ b/scripts/push_start.sh
@@ -21,7 +21,7 @@ source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
source $OPENIM_ROOT/scripts/function.sh
-bin_dir="$OPENIM_ROOT/bin"
+bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
diff --git a/scripts/start_all.sh b/scripts/start_all.sh
index 7a9fd656c..44c613479 100755
--- a/scripts/start_all.sh
+++ b/scripts/start_all.sh
@@ -17,21 +17,26 @@
#FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array.
#Include shell font styles and some basic information
-OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
#Include shell font styles and some basic information
-source $OPENIM_ROOT/scripts/style_info.cfg
-source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function.sh
+source $SCRIPTS_ROOT/style_info.cfg
+source $SCRIPTS_ROOT/path_info.cfg
+source $SCRIPTS_ROOT/function.sh
-bin_dir="$OPENIM_ROOT/bin"
+cd $SCRIPTS_ROOT
+
+echo -e "${BACKGROUND_YELLOW}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_YELLOW}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_YELLOW}=======>pwd=$PWD${COLOR_SUFFIX}"
+
+bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
-cd "$OPENIM_ROOT/scripts/"
-
# Print title
-echo -e "${BOLD_PREFIX}${BLUE_PREFIX}OpenIM Server Start${COLOR_SUFFIX}"
+echo -e "${BOLD_PREFIX}${BLUE_PREFIX}================> OpenIM Server Start${COLOR_SUFFIX}"
# Get current time
time=$(date +"%Y-%m-%d %H:%M:%S")
@@ -45,7 +50,6 @@ echo -e "${BOLD_PREFIX}${CYAN_PREFIX}Server Start Time: ${time}${COLOR_SUFFIX}"
# Print section separator
echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
-cd $OPENIM_ROOT/scripts
# FIXME Put the shell script names here
need_to_start_server_shell=(
start_rpc_service.sh
@@ -55,7 +59,6 @@ need_to_start_server_shell=(
start_cron.sh
)
-
# Loop through the script names and execute them
for i in ${need_to_start_server_shell[*]}; do
chmod +x $i
diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh
index b18d19478..c7ce4e451 100755
--- a/scripts/start_cron.sh
+++ b/scripts/start_cron.sh
@@ -21,7 +21,7 @@ source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
source $OPENIM_ROOT/scripts/function.sh
-bin_dir="$OPENIM_ROOT/bin"
+bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh
index 028bdc8c8..2d0e70f63 100755
--- a/scripts/start_rpc_service.sh
+++ b/scripts/start_rpc_service.sh
@@ -13,12 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
#Include shell font styles and some basic information
-source $OPENIM_ROOT/scripts/style_info.cfg
-source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function.sh
+source $SCRIPTS_ROOT/style_info.cfg
+source $SCRIPTS_ROOT/path_info.cfg
+source $SCRIPTS_ROOT/function.sh
+
+cd $SCRIPTS_ROOT
+
+echo -e "${BACKGROUND_YELLOW}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_YELLOW}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_YELLOW}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
diff --git a/scripts/stop_all.sh b/scripts/stop_all.sh
index 133bb9577..7bec5b53f 100755
--- a/scripts/stop_all.sh
+++ b/scripts/stop_all.sh
@@ -21,7 +21,7 @@ source $OPENIM_ROOT/scripts/style_info.cfg
source $OPENIM_ROOT/scripts/path_info.cfg
source $OPENIM_ROOT/scripts/function.sh
-bin_dir="$OPENIM_ROOT/bin"
+bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
From d41ad35b212be822d1e93fddc4a1d2cf470206e6 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Sun, 9 Jul 2023 16:51:43 +0800
Subject: [PATCH 44/73] feat: add all command
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
README-zh_CN.md | 2 +-
README.md | 2 +-
cmd/openim-cmdutils/Makefile | 2 +-
config/config.yaml | 3 +-
scripts/batch_build_all_service.sh | 6 ++--
scripts/batch_start_all.sh | 21 +++++++++---
scripts/build_all_service.sh | 8 ++---
scripts/build_push_k8s_images.sh | 2 +-
scripts/check_all.sh | 26 +++++++++-----
scripts/docker_start_all.sh | 14 ++++----
scripts/enterprise/check_all.sh | 17 +++++----
scripts/env_check.sh | 2 +-
scripts/function.sh | 30 +++++++++-------
scripts/githooks/pre-push | 8 ++---
scripts/msg_gateway_start.sh | 25 +++++++++-----
scripts/msg_transfer_start.sh | 25 +++++++++-----
scripts/{path_info.cfg => path_info.sh} | 42 ++++++++++-------------
scripts/push_start.sh | 25 +++++++++-----
scripts/start_all.sh | 12 +++----
scripts/start_cron.sh | 27 +++++++++------
scripts/start_rpc_service.sh | 24 ++++++-------
scripts/stop_all.sh | 4 +--
scripts/{style_info.cfg => style_info.sh} | 2 ++
23 files changed, 189 insertions(+), 140 deletions(-)
rename scripts/{path_info.cfg => path_info.sh} (73%)
rename scripts/{style_info.cfg => style_info.sh} (98%)
diff --git a/README-zh_CN.md b/README-zh_CN.md
index 87d675c88..1cdd0a52e 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -142,7 +142,7 @@ Open-IM-Server 是一款即时通讯服务器,使用纯 Golang 开发,采用
> Open-IM 脚本提供服务编译、启动和停止脚本。有四个 Open-IM 脚本启动模块,一个是 http+rpc 服务启动模块,第二个是 WebSocket 服务启动模块,然后是 msg_transfer 模块,最后是 push 模块。
-+ path_info.cfg&&style_info.cfg&&
++ path_info.sh&&style_info.sh&&
functions.sh
diff --git a/README.md b/README.md
index d3d880d41..e8da2ab5e 100644
--- a/README.md
+++ b/README.md
@@ -146,7 +146,7 @@ all services build success
> Open-IM scripts provides service compilation, start, and stop scripts. There are four Open-IM scripts start modules, one is the http+rpc service start module, the second is the websocket service start module, then the msg_transfer module, and the last is the push module
-- path_info.cfg&&style_info.cfg&&functions.sh
+- path_info.sh&&style_info.sh&&functions.sh
- Contains the path information of each module, including the path where the source code is located, the name of the service startup, the shell print font style, and some functions for processing shell strings
- build_all_service.sh
- Compile the module, compile all the source code of Open-IM into a binary file and put it into the bin directory
diff --git a/cmd/openim-cmdutils/Makefile b/cmd/openim-cmdutils/Makefile
index 9c51aee84..e78ac33f6 100644
--- a/cmd/openim-cmdutils/Makefile
+++ b/cmd/openim-cmdutils/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim_cmd_utils
+NAME=openim-cmdutils
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
diff --git a/config/config.yaml b/config/config.yaml
index def91d2b5..ea6f8772d 100644
--- a/config/config.yaml
+++ b/config/config.yaml
@@ -274,5 +274,4 @@ prometheus: #prometheus每个服务的端口数量需要和rpcPort保持对应
conversationPrometheusPort: [ 20230 ]
rtcPrometheusPort: [ 21300 ]
thirdPrometheusPort: [ 21301 ]
- messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] #端口数量需要和script/path_info.cfg中的msg_transfer_service_num保持一致
-
+ messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] #端口数量需要和script/path_info.sh中的msg_transfer_service_num保持一致
diff --git a/scripts/batch_build_all_service.sh b/scripts/batch_build_all_service.sh
index 7bb75de77..f3bd791cf 100755
--- a/scripts/batch_build_all_service.sh
+++ b/scripts/batch_build_all_service.sh
@@ -20,8 +20,8 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "$(dirname "${BASH_SOURCE[0]}")/../scripts.sh"
# Include specific functions and variables
-source "$(dirname "${BASH_SOURCE[0]}")/../scripts/style_info.cfg" \
- "$OPENIM_ROOT/scripts/path_info.cfg"
+source "$(dirname "${BASH_SOURCE[0]}")/../scripts/style_info.sh" \
+ "$OPENIM_ROOT/scripts/path_info.sh"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
@@ -76,5 +76,5 @@ done
echo "success_num" $success_num "service num:" ${#service_source_root[*]}
if [ $success_num == ${#service_source_root[*]} ]
then
- echo -e ${YELLOW_PREFIX}"all services build success"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}"all services build success"${COLOR_SUFFIX}
fi
diff --git a/scripts/batch_start_all.sh b/scripts/batch_start_all.sh
index aa7713280..e291819f4 100755
--- a/scripts/batch_start_all.sh
+++ b/scripts/batch_start_all.sh
@@ -16,9 +16,20 @@
#fixme This scripts is the total startup scripts
#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
+#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
-cd "$OPENIM_ROOT/scripts/"
+#Include shell font styles and some basic information
+source $SCRIPTS_ROOT/style_info.sh
+source $SCRIPTS_ROOT/path_info.sh
+source $SCRIPTS_ROOT/function.sh
+
+cd $SCRIPTS_ROOT
+
+echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
need_to_start_server_shell=(
"start_rpc_service.sh"
@@ -30,13 +41,13 @@ need_to_start_server_shell=(
time=$(date +"%Y-%m-%d %H:%M:%S")
for _ in {1..3}; do
- echo "==========================================================" >> ../logs/openIM.log 2>&1
+ echo "==========================================================" >> $OPENIM_ROOT/logs/openIM.log 2>&1
done
-echo "==========server start time:${time}===========" >> ../logs/openIM.log 2>&1
+echo "==========server start time:${time}===========" >> $OPENIM_ROOT/logs/openIM.log 2>&1
for _ in {1..3}; do
- echo "==========================================================" >> ../logs/openIM.log 2>&1
+ echo "==========================================================" >> $OPENIM_ROOT/logs/openIM.log 2>&1
done
build_pid_array=()
@@ -74,5 +85,5 @@ done
echo "success_num" $success_num "service num:" ${#need_to_start_server_shell[*]}
if [ $success_num == ${#need_to_start_server_shell[*]} ]
then
- echo -e ${YELLOW_PREFIX}"all services build success"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}"all services build success"${COLOR_SUFFIX}
fi
diff --git a/scripts/build_all_service.sh b/scripts/build_all_service.sh
index aed63a818..fd196e48b 100755
--- a/scripts/build_all_service.sh
+++ b/scripts/build_all_service.sh
@@ -14,8 +14,8 @@
# limitations under the License.
-source ./style_info.cfg
-source ./path_info.cfg
+source ./style_info.sh
+source ./path_info.sh
source ./function.sh
echo -e ""
@@ -43,8 +43,8 @@ fi
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
-source $OPENIM_ROOT/scripts/style_info.cfg
-source $OPENIM_ROOT/scripts/path_info.cfg
+source $OPENIM_ROOT/scripts/style_info.sh
+source $OPENIM_ROOT/scripts/path_info.sh
source $OPENIM_ROOT/scripts/function.sh
cd $OPENIM_ROOT
diff --git a/scripts/build_push_k8s_images.sh b/scripts/build_push_k8s_images.sh
index ff9887c56..a620c7847 100755
--- a/scripts/build_push_k8s_images.sh
+++ b/scripts/build_push_k8s_images.sh
@@ -23,7 +23,7 @@ fi
set +e
echo "repository: ${repository}"
-source ./path_info.cfg
+source ./path_info.sh
echo "start to build docker images"
currentPwd=`pwd`
echo ${currentPwd}
diff --git a/scripts/check_all.sh b/scripts/check_all.sh
index 0bcb782dd..db420dd21 100755
--- a/scripts/check_all.sh
+++ b/scripts/check_all.sh
@@ -13,10 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
-source ./style_info.cfg
-source ./path_info.cfg
-source ./function.sh
+#Include shell font styles and some basic information
+source $SCRIPTS_ROOT/style_info.sh
+source $SCRIPTS_ROOT/path_info.sh
+source $SCRIPTS_ROOT/function.sh
+
+cd $SCRIPTS_ROOT
+
+echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
service_port_name=(
openImWsPort
@@ -37,8 +47,8 @@ for i in ${service_port_name[*]}; do
for j in ${ports_array}; do
port=$(ss -tunlp| grep openim | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
if [[ ${port} -ne ${j} ]]; then
- echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX}
- echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${BACKGROUND_GREEN}${j}${COLOR_SUFFIX}
+ echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX}
exit -1
else
echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX}
@@ -52,7 +62,7 @@ if [ $check -eq ${msg_transfer_service_num} ]; then
echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImMsgTransfer"${COLOR_SUFFIX}
else
echo -e ${RED_PREFIX}"openImMsgTransfer service does not start normally, num err"${COLOR_SUFFIX}
- echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX}
+ echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX}
exit -1
fi
@@ -62,8 +72,8 @@ if [ $check -ge 1 ]; then
echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImCronTask"${COLOR_SUFFIX}
else
echo -e ${RED_PREFIX}"cron_task_name service does not start normally"${COLOR_SUFFIX}
- echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX}
+ echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX}
exit -1
fi
-echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX}
+echo -e ${BACKGROUND_GREEN}"all services launch success"${COLOR_SUFFIX}
diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh
index 8ed198cae..98e5a131c 100755
--- a/scripts/docker_start_all.sh
+++ b/scripts/docker_start_all.sh
@@ -29,13 +29,13 @@ need_to_start_server_shell=(
sleep 10
time=`date +"%Y-%m-%d %H:%M:%S"`
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========server start time:${time}===========">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
-echo "==========================================================">>../logs/openIM.log 2>&1 &
+echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
+echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
+echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
+echo "==========server start time:${time}===========">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
+echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
+echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
+echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
for i in ${need_to_start_server_shell[*]}; do
chmod +x $i
./$i
diff --git a/scripts/enterprise/check_all.sh b/scripts/enterprise/check_all.sh
index 8c9d3a82a..7b8a3c5da 100755
--- a/scripts/enterprise/check_all.sh
+++ b/scripts/enterprise/check_all.sh
@@ -14,14 +14,19 @@
# limitations under the License.
#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
-source $OPENIM_ROOT/scripts/style_info.cfg
-source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function.sh
+source $SCRIPTS_ROOT/style_info.sh
+source $SCRIPTS_ROOT/path_info.sh
+source $SCRIPTS_ROOT/function.sh
-cd "$OPENIM_ROOT/scripts/"
+cd $SCRIPTS_ROOT
+
+echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
service_port_name=(
openImChatApiPort
@@ -37,8 +42,8 @@ for i in ${service_port_name[*]}; do
for j in ${ports_array}; do
port=$(ss -tunlp| grep openim | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
if [[ ${port} -ne ${j} ]]; then
- echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX}
- echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${BACKGROUND_GREEN}${j}${COLOR_SUFFIX}
+ echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX}
exit -1
else
echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX}
diff --git a/scripts/env_check.sh b/scripts/env_check.sh
index c6cfaf4bb..8c84567b7 100755
--- a/scripts/env_check.sh
+++ b/scripts/env_check.sh
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-source ./style_info.cfg
+source ./style_info.sh
echo -e "check time synchronize.................................."
t=`curl http://time.akamai.com/?iso -s`
diff --git a/scripts/function.sh b/scripts/function.sh
index e2dc96a25..e351c1ddb 100755
--- a/scripts/function.sh
+++ b/scripts/function.sh
@@ -13,17 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#input:[10023,2323,3434]
-#output:10023 2323 3434
-list_to_string(){
-ports_list=$*
-sub_s1=`echo $ports_list | sed 's/ //g'`
-sub_s2=${sub_s1//,/ }
-sub_s3=${sub_s2#*[}
-sub_s4=${sub_s3%]*}
-ports_array=$sub_s4
+# input: [10023, 2323, 3434]
+# output: 10023 2323 3434
+
+# 函数功能:将列表转换为字符串,去除空格和括号
+list_to_string() {
+ ports_list=$* # 获取传入的参数列表
+ sub_s1=$(echo $ports_list | sed 's/ //g') # 去除空格
+ sub_s2=${sub_s1//,/ } # 将逗号替换为空格
+ sub_s3=${sub_s2#*[} # 去除左括号及其之前的内容
+ sub_s4=${sub_s3%]*} # 去除右括号及其之后的内容
+ ports_array=$sub_s4 # 将处理后的字符串赋值给变量 ports_array
+}
+
+# 函数功能:去除字符串中的空格
+remove_space() {
+ value=$* # 获取传入的参数
+ result=$(echo $value | sed 's/ //g') # 去除空格
}
-remove_space(){
- value=$*
- result=`echo $value | sed 's/ //g'`
-}
\ No newline at end of file
diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push
index 9087e0cb9..2ed9736be 100644
--- a/scripts/githooks/pre-push
+++ b/scripts/githooks/pre-push
@@ -45,7 +45,7 @@ COLOR_SUFFIX="\033[0m"
BLACK_PREFIX="\033[30m"
RED_PREFIX="\033[31m"
GREEN_PREFIX="\033[32m"
-YELLOW_PREFIX="\033[33m"
+BACKGROUND_GREEN="\033[33m"
BLUE_PREFIX="\033[34m"
PURPLE_PREFIX="\033[35m"
SKY_BLUE_PREFIX="\033[36m"
@@ -92,9 +92,9 @@ added_files=$(grep -c '^A' <<< "$file_list")
modified_files=$(grep -c '^M' <<< "$file_list")
deleted_files=$(grep -c '^D' <<< "$file_list")
-print_color "Added Files: ${added_files}" "${YELLOW_PREFIX}"
-print_color "Modified Files: ${modified_files}" "${YELLOW_PREFIX}"
-print_color "Deleted Files: ${deleted_files}" "${YELLOW_PREFIX}"
+print_color "Added Files: ${added_files}" "${BACKGROUND_GREEN}"
+print_color "Modified Files: ${modified_files}" "${BACKGROUND_GREEN}"
+print_color "Deleted Files: ${deleted_files}" "${BACKGROUND_GREEN}"
#
#printMessage "Running the Flutter analyzer"
diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh
index 62a8479c9..7df840b21 100755
--- a/scripts/msg_gateway_start.sh
+++ b/scripts/msg_gateway_start.sh
@@ -14,12 +14,19 @@
# limitations under the License.
#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
-source $OPENIM_ROOT/scripts/style_info.cfg
-source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function.sh
+source $SCRIPTS_ROOT/style_info.sh
+source $SCRIPTS_ROOT/path_info.sh
+source $SCRIPTS_ROOT/function.sh
+
+cd $SCRIPTS_ROOT
+
+echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
@@ -53,8 +60,8 @@ fi
sleep 1
cd ${msg_gateway_binary_root}
for ((i = 0; i < ${#ws_ports[@]}; i++)); do
- echo "==========================start msg_gateway server===========================">>../logs/openIM.log
- nohup ./${openim-msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} >>../logs/openIM.log 2>&1 &
+ echo "==========================start msg_gateway server===========================">>$OPENIM_ROOT/logs/openIM.log
+ nohup ./${openim-msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
done
#Check launched service process
@@ -68,9 +75,9 @@ if [ $check -ge 1 ]; then
allPorts=${allPorts}"$ports "
done
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS"${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${openim-msggateway}${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${openim-msggateway}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allNewPid}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${YELLOW_PREFIX}${openim-msggateway}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${openim-msggateway}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh
index 50c01cb9d..b038d125a 100755
--- a/scripts/msg_transfer_start.sh
+++ b/scripts/msg_transfer_start.sh
@@ -14,12 +14,19 @@
# limitations under the License.
#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
-source $OPENIM_ROOT/scripts/style_info.cfg
-source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function.sh
+source $SCRIPTS_ROOT/style_info.sh
+source $SCRIPTS_ROOT/path_info.sh
+source $SCRIPTS_ROOT/function.sh
+
+cd $SCRIPTS_ROOT
+
+echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
@@ -49,8 +56,8 @@ for ((i = 0; i < ${msg_transfer_service_num}; i++)); do
if [ $prome_port != "" ]; then
cmd="$cmd --prometheus_port $prome_port"
fi
- echo "==========================start msg_transfer server===========================">>../logs/openIM.log
- $cmd >>../logs/openIM.log 2>&1 &
+ echo "==========================start msg_transfer server===========================">>$OPENIM_ROOT/logs/openIM.log
+ $cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
done
#Check launched service process
@@ -60,9 +67,9 @@ then
newPid=`ps aux | grep -w ./${openim-msgtransfer} | grep -v grep|awk '{print $2}'`
allPorts=""
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${openim-msgtransfer}${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${openim-msgtransfer}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${YELLOW_PREFIX}${openim-msgtransfer}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${openim-msgtransfer}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
diff --git a/scripts/path_info.cfg b/scripts/path_info.sh
similarity index 73%
rename from scripts/path_info.cfg
rename to scripts/path_info.sh
index 57f328a47..0edc0b5b2 100755
--- a/scripts/path_info.cfg
+++ b/scripts/path_info.sh
@@ -1,22 +1,17 @@
+#!/usr/bin/env bash
# Determine the architecture and version
architecture=$(uname -m)
version=$(uname -s | tr '[:upper:]' '[:lower:]')
#Include shell font styles and some basic information
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
-OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
-source $SCRIPTS_ROOT/style_info.cfg
-source $SCRIPTS_ROOT/path_info.cfg
-source $SCRIPTS_ROOT/function.sh
+source $SCRIPTS_ROOT/style_info.sh
cd $SCRIPTS_ROOT
-echo -e "${BACKGROUND_YELLOW}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_YELLOW}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_YELLOW}=======>pwd=$PWD${COLOR_SUFFIX}"
-
# Define the supported architectures and corresponding bin directories
declare -A supported_architectures=(
["linux-amd64"]="_output/bin/platforms/linux/amd64"
@@ -47,29 +42,28 @@ echo "================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR"
# Don't put the space between "="
openim_msggateway="openim-msggateway"
msg_gateway_binary_root="$OPENIM_ROOT/$BIN_DIR"
-msg_gateway_source_root="../cmd/msggateway/"
+msg_gateway_source_root="$OPENIM_ROOT/cmd/msggateway/"
msg_name="openim-rpc-msg"
msg_binary_root="$OPENIM_ROOT/$BIN_DIR"
-msg_source_root="../cmd/openim-rpc/msg/"
+msg_source_root="$OPENIM_ROOT/cmd/openim-rpc/msg/"
push_name="openim-push"
push_binary_root="$OPENIM_ROOT/$BIN_DIR"
-push_source_root="../cmd/push/"
+push_source_root="$OPENIM_ROOT/cmd/push/"
openim_msgtransfer="openim-rpc-msg_transfer"
msg_transfer_binary_root="$OPENIM_ROOT/$BIN_DIR"
-msg_transfer_source_root="$OPENIM_ROOT/cmd/msgtransfer/"
+msg_transfer_source_root="$OPENIM_ROOT/cmd/openim-msgtransfer/"
msg_transfer_service_num=4
cron_task_name="openim-crontask"
cron_task_binary_root="$OPENIM_ROOT/$BIN_DIR"
-cron_task_source_root="$OPENIM_ROOT/cmd/crontask/"
-
+cron_task_source_root="$OPENIM_ROOT/cmd/openim-crontask/"
-cmd_utils_name="openim_cmd_utils"
+cmd_utils_name="openim-cmdutils"
cmd_utils_binary_root="$OPENIM_ROOT/$BIN_DIR"
-cmd_utils_source_root="$OPENIM_ROOT/cmd/cmduitls/"
+cmd_utils_source_root="$OPENIM_ROOT/cmd/openim-cmdutils/"
# Global configuration file default dir
config_path="$OPENIM_ROOT/config/config.yaml"
@@ -77,15 +71,15 @@ config_path="$OPENIM_ROOT/config/config.yaml"
# servicefile dir path
service_source_root=(
# api service file
- "../cmd/api/"
+ "$OPENIM_ROOT/cmd/api/"
# rpc service file
- "../cmd/openim-rpc/openim-rpc-user/"
- "../cmd/openim-rpc/openim-rpc-friend/"
- "../cmd/openim-rpc/openim-rpc-group/"
- "../cmd/openim-rpc/openim-rpc-auth/"
- "../cmd/openim-rpc/openim-rpc-conversation/"
- "../cmd/openim-rpc/openim-rpc-third/"
- "../cmd/openim-crontask"
+ "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-user/"
+ "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-friend/"
+ "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-group/"
+ "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-auth/"
+ "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-conversation/"
+ "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-third/"
+ "$OPENIM_ROOT/cmd/openim-crontask"
"${msg_gateway_source_root}"
"${msg_transfer_source_root}"
"${msg_source_root}"
diff --git a/scripts/push_start.sh b/scripts/push_start.sh
index 204f710e7..55ac28bb3 100755
--- a/scripts/push_start.sh
+++ b/scripts/push_start.sh
@@ -14,12 +14,19 @@
# limitations under the License.
#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
-source $OPENIM_ROOT/scripts/style_info.cfg
-source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function.sh
+source $SCRIPTS_ROOT/style_info.sh
+source $SCRIPTS_ROOT/path_info.sh
+source $SCRIPTS_ROOT/function.sh
+
+cd $SCRIPTS_ROOT
+
+echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
@@ -46,8 +53,8 @@ sleep 1
cd ${push_binary_root}
for ((i = 0; i < ${#rpc_ports[@]}; i++)); do
- echo "==========================start push server===========================">>../logs/openIM.log
- nohup ./${push_name} --port ${rpc_ports[$i]} --prometheus_port ${prome_ports[$i]} >>../logs/openIM.log 2>&1 &
+ echo "==========================start push server===========================">>$OPENIM_ROOT/logs/openIM.log
+ nohup ./${push_name} --port ${rpc_ports[$i]} --prometheus_port ${prome_ports[$i]} >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
done
sleep 3
@@ -62,9 +69,9 @@ if [ $check -ge 1 ]; then
allPorts=${allPorts}"$i "
done
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${push_name}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
diff --git a/scripts/start_all.sh b/scripts/start_all.sh
index 44c613479..976320dad 100755
--- a/scripts/start_all.sh
+++ b/scripts/start_all.sh
@@ -21,15 +21,15 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
#Include shell font styles and some basic information
-source $SCRIPTS_ROOT/style_info.cfg
-source $SCRIPTS_ROOT/path_info.cfg
+source $SCRIPTS_ROOT/style_info.sh
+source $SCRIPTS_ROOT/path_info.sh
source $SCRIPTS_ROOT/function.sh
cd $SCRIPTS_ROOT
-echo -e "${BACKGROUND_YELLOW}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_YELLOW}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_YELLOW}=======>pwd=$PWD${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
@@ -65,7 +65,7 @@ for i in ${need_to_start_server_shell[*]}; do
echo -e ""
# Print script execution message
- echo -e "=========> ${YELLOW_PREFIX}Executing ${i}...${COLOR_SUFFIX}"
+ echo -e "=========> ${BACKGROUND_GREEN}Executing ${i}...${COLOR_SUFFIX}"
echo -e ""
./$i
diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh
index c7ce4e451..1fccedcf2 100755
--- a/scripts/start_cron.sh
+++ b/scripts/start_cron.sh
@@ -14,19 +14,24 @@
# limitations under the License.
#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
-source $OPENIM_ROOT/scripts/style_info.cfg
-source $OPENIM_ROOT/scripts/path_info.cfg
-source $OPENIM_ROOT/scripts/function.sh
+source $SCRIPTS_ROOT/style_info.sh
+source $SCRIPTS_ROOT/path_info.sh
+source $SCRIPTS_ROOT/function.sh
+
+cd $SCRIPTS_ROOT
+
+echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
-cd "$OPENIM_ROOT/scripts/"
-
#Check if the service exists
#If it is exists,kill this process
check=`ps aux | grep -w ./${cron_task_name} | grep -v grep| wc -l`
@@ -40,8 +45,8 @@ sleep 1
cd ${cron_task_binary_root}
#for ((i = 0; i < ${cron_task_service_num}; i++)); do
- echo "==========================start cron_task process===========================">>../logs/openIM.log
-nohup ./${cron_task_name} >>../logs/openIM.log 2>&1 &
+ echo "==========================start cron_task process===========================">>$OPENIM_ROOT/logs/openIM.log
+nohup ./${cron_task_name} >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
#done
#Check launched service process
@@ -51,9 +56,9 @@ then
newPid=`ps aux | grep -w ./${cron_task_name} | grep -v grep|awk '{print $2}'`
allPorts=""
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${cron_task_name}${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${cron_task_name}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${YELLOW_PREFIX}${cron_task_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${cron_task_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh
index 2d0e70f63..1cafd2b1c 100755
--- a/scripts/start_rpc_service.sh
+++ b/scripts/start_rpc_service.sh
@@ -15,25 +15,22 @@
#Include shell font styles and some basic information
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
-OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
-source $SCRIPTS_ROOT/style_info.cfg
-source $SCRIPTS_ROOT/path_info.cfg
-source $SCRIPTS_ROOT/function.sh
+source $SCRIPTS_ROOT/style_info.sh
+source $SCRIPTS_ROOT/path_info.sh
cd $SCRIPTS_ROOT
-echo -e "${BACKGROUND_YELLOW}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_YELLOW}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_YELLOW}=======>pwd=$PWD${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}${CYAN_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}${CYAN_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${BACKGROUND_GREEN}${CYAN_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
-cd $OPENIM_ROOT
-
#service filename
service_filename=(
#api
@@ -88,8 +85,9 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
kill -9 $(eval $pid)
sleep 0.5
fi
- cd $
- #Get the rpc port in the configuration file
+ cd $OPENIM_ROOT
+ cd $BIN_DIR
+ # Get the rpc port in the configuration file
portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}')
list_to_string ${portList}
service_ports=($ports_array)
@@ -109,8 +107,8 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
cmd="./${service_filename[$i]} --port ${service_ports[$j]}"
fi
echo $cmd
- echo "=====================start ${service_filename[$i]}======================">>../logs/openIM.log
- nohup $cmd >>../logs/openIM.log 2>&1 &
+ echo "=====================start ${service_filename[$i]}======================">>$OPENIM_ROOT/logs/openIM.log
+ nohup $cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
sleep 1
pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1"
echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:${service_ports[$j]} pid:$(eval $pid)$COLOR_SUFFIX"
diff --git a/scripts/stop_all.sh b/scripts/stop_all.sh
index 7bec5b53f..4e3537ea7 100755
--- a/scripts/stop_all.sh
+++ b/scripts/stop_all.sh
@@ -17,8 +17,8 @@
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
-source $OPENIM_ROOT/scripts/style_info.cfg
-source $OPENIM_ROOT/scripts/path_info.cfg
+source $OPENIM_ROOT/scripts/style_info.sh
+source $OPENIM_ROOT/scripts/path_info.sh
source $OPENIM_ROOT/scripts/function.sh
bin_dir="$BIN_DIR"
diff --git a/scripts/style_info.cfg b/scripts/style_info.sh
similarity index 98%
rename from scripts/style_info.cfg
rename to scripts/style_info.sh
index f0b6a32db..631f8a5f1 100755
--- a/scripts/style_info.cfg
+++ b/scripts/style_info.sh
@@ -1,3 +1,5 @@
+#!/usr/bin/env bash
+
COLOR_SUFFIX="\033[0m" # End all colors and special effects
BLACK_PREFIX="\033[30m" # Black prefix
From 826c86907cc4bde6a21c4ef7fc7af96517021bcb Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Sun, 9 Jul 2023 17:12:16 +0800
Subject: [PATCH 45/73] feat: complete the basic build
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.gitignore | 2 +-
cmd/openim-msgtransfer/Makefile | 2 +-
cmd/openim-msgtransfer/deploy.Dockerfile | 4 ++--
scripts/make-rules/golang.mk | 4 ++--
scripts/path_info.sh | 8 ++++----
scripts/start_rpc_service.sh | 1 +
6 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/.gitignore b/.gitignore
index a547540a7..6e29bad2c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,7 +33,7 @@ _output/
deploy/openim_demo
deploy/openim-api
deploy/openim-rpc-msg_gateway
-deploy/openim-rpc-msg_transfer
+deploy/openim-msgtransfer
deploy/openim-push
deploy/openim_timer_task
deploy/openim-rpc-user
diff --git a/cmd/openim-msgtransfer/Makefile b/cmd/openim-msgtransfer/Makefile
index 9d4aa7dec..e2d058f6d 100644
--- a/cmd/openim-msgtransfer/Makefile
+++ b/cmd/openim-msgtransfer/Makefile
@@ -1,6 +1,6 @@
.PHONY: all build run gotool install clean help
-NAME=openim-rpc-msg_transfer
+NAME=openim-msgtransfer
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
diff --git a/cmd/openim-msgtransfer/deploy.Dockerfile b/cmd/openim-msgtransfer/deploy.Dockerfile
index 747b7f422..78f1f955c 100644
--- a/cmd/openim-msgtransfer/deploy.Dockerfile
+++ b/cmd/openim-msgtransfer/deploy.Dockerfile
@@ -25,8 +25,8 @@ RUN apt-get install -y vim curl tzdata gawk
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
-COPY ./openim-rpc-msg_transfer ./
+COPY ./openim-msgtransfer ./
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
-CMD ["./openim-rpc-msg_transfer","--prometheus_port", "21400"]
+CMD ["./openim-msgtransfer","--prometheus_port", "21400"]
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index 1b6c92ed3..2a6fd7f0d 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -76,7 +76,7 @@ EXCLUDE_TESTS=github.com/OpenIMSDK/Open-IM-Server/test github.com/OpenIMSDK/Open
# ├── openim-crontask
# ├── openim_demo
# ├── openim-rpc-msg_gateway
-# ├── openim-rpc-msg_transfer
+# ├── openim-msgtransfer
# ├── openim-push
# ├── rpc/openim_admin_cms/ - main.go
# └── test/ - main.go
@@ -84,7 +84,7 @@ EXCLUDE_TESTS=github.com/OpenIMSDK/Open-IM-Server/test github.com/OpenIMSDK/Open
# PLATFORM=linux_amd64
# OS=linux
# ARCH=amd64
-# BINS=openim-api openim_cms_api openim-crontask openim_demo openim-rpc-msg_gateway openim-rpc-msg_transfer openim-push
+# BINS=openim-api openim_cms_api openim-crontask openim_demo openim-rpc-msg_gateway openim-msgtransfer openim-push
# BIN_DIR=/root/workspaces/OpenIM/_output/bin
# ==============================================================================
diff --git a/scripts/path_info.sh b/scripts/path_info.sh
index 0edc0b5b2..ab6f2b2df 100755
--- a/scripts/path_info.sh
+++ b/scripts/path_info.sh
@@ -42,17 +42,17 @@ echo "================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR"
# Don't put the space between "="
openim_msggateway="openim-msggateway"
msg_gateway_binary_root="$OPENIM_ROOT/$BIN_DIR"
-msg_gateway_source_root="$OPENIM_ROOT/cmd/msggateway/"
+msg_gateway_source_root="$OPENIM_ROOT/cmd/openim-msggateway/"
msg_name="openim-rpc-msg"
msg_binary_root="$OPENIM_ROOT/$BIN_DIR"
-msg_source_root="$OPENIM_ROOT/cmd/openim-rpc/msg/"
+msg_source_root="$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-msg/"
push_name="openim-push"
push_binary_root="$OPENIM_ROOT/$BIN_DIR"
-push_source_root="$OPENIM_ROOT/cmd/push/"
+push_source_root="$OPENIM_ROOT/cmd/openim-push/"
-openim_msgtransfer="openim-rpc-msg_transfer"
+openim_msgtransfer="openim-msgtransfer"
msg_transfer_binary_root="$OPENIM_ROOT/$BIN_DIR"
msg_transfer_source_root="$OPENIM_ROOT/cmd/openim-msgtransfer/"
msg_transfer_service_num=4
diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh
index 1cafd2b1c..132afdfe5 100755
--- a/scripts/start_rpc_service.sh
+++ b/scripts/start_rpc_service.sh
@@ -20,6 +20,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $SCRIPTS_ROOT/style_info.sh
source $SCRIPTS_ROOT/path_info.sh
+source $SCRIPTS_ROOT/function.sh
cd $SCRIPTS_ROOT
From 3c73ba03ba4ee3528ac48c362b1998001d1be785 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Sun, 9 Jul 2023 18:46:42 +0800
Subject: [PATCH 46/73] feat: fix code
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
internal/msgtransfer/persistent_msg_handler.go | 7 +------
pkg/common/kafka/consumer_group.go | 6 ------
pkg/utils/strings.go | 6 ------
pkg/utils/time_format.go | 6 ------
scripts/msg_gateway_start.sh | 2 +-
scripts/msg_transfer_start.sh | 2 +-
scripts/push_start.sh | 2 +-
scripts/start_cron.sh | 2 +-
8 files changed, 5 insertions(+), 28 deletions(-)
diff --git a/internal/msgtransfer/persistent_msg_handler.go b/internal/msgtransfer/persistent_msg_handler.go
index 30b739f7e..eaf47dee9 100644
--- a/internal/msgtransfer/persistent_msg_handler.go
+++ b/internal/msgtransfer/persistent_msg_handler.go
@@ -1,9 +1,4 @@
-/*
-** description("").
-** copyright('tuoyun,www.tuoyun.net').
-** author("fg,Gordon@tuoyun.net").
-** time(2021/5/11 15:37).
- */package msgtransfer
+package msgtransfer
import (
"context"
diff --git a/pkg/common/kafka/consumer_group.go b/pkg/common/kafka/consumer_group.go
index 065fc6277..2e0155f67 100644
--- a/pkg/common/kafka/consumer_group.go
+++ b/pkg/common/kafka/consumer_group.go
@@ -1,9 +1,3 @@
-/*
-** description("").
-** copyright('tuoyun,www.tuoyun.net').
-** author("fg,Gordon@tuoyun.net").
-** time(2021/5/11 9:36).
- */
package kafka
import (
diff --git a/pkg/utils/strings.go b/pkg/utils/strings.go
index 5c985d724..106c6a112 100644
--- a/pkg/utils/strings.go
+++ b/pkg/utils/strings.go
@@ -1,9 +1,3 @@
-/*
-** description("").
-** copyright('tuoyun,www.tuoyun.net').
-** author("fg,Gordon@tuoyun.net").
-** time(2021/4/8 15:09).
- */
package utils
import (
diff --git a/pkg/utils/time_format.go b/pkg/utils/time_format.go
index 59abb90c4..af1be7f04 100644
--- a/pkg/utils/time_format.go
+++ b/pkg/utils/time_format.go
@@ -1,9 +1,3 @@
-/*
-** description("").
-** copyright('tuoyun,www.tuoyun.net').
-** author("fg,Gordon@tuoyun.net").
-** time(2021/2/22 11:52).
- */
package utils
import (
diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh
index 7df840b21..164d993ae 100755
--- a/scripts/msg_gateway_start.sh
+++ b/scripts/msg_gateway_start.sh
@@ -79,5 +79,5 @@ if [ $check -ge 1 ]; then
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allNewPid}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${BACKGROUND_GREEN}${openim-msggateway}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${openim-msggateway}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh
index b038d125a..741485356 100755
--- a/scripts/msg_transfer_start.sh
+++ b/scripts/msg_transfer_start.sh
@@ -71,5 +71,5 @@ allPorts=""
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${BACKGROUND_GREEN}${openim-msgtransfer}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${openim-msgtransfer}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
diff --git a/scripts/push_start.sh b/scripts/push_start.sh
index 55ac28bb3..ea353cd56 100755
--- a/scripts/push_start.sh
+++ b/scripts/push_start.sh
@@ -73,5 +73,5 @@ if [ $check -ge 1 ]; then
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${BACKGROUND_GREEN}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh
index 1fccedcf2..bef9ca36e 100755
--- a/scripts/start_cron.sh
+++ b/scripts/start_cron.sh
@@ -60,5 +60,5 @@ allPorts=""
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${BACKGROUND_GREEN}${cron_task_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${cron_task_name}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
From eaaf309b30193bcac7f1c6a5c63a7994591cbf81 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Mon, 10 Jul 2023 11:51:47 +0800
Subject: [PATCH 47/73] feat: add link file
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
CHANGELOG.md | 1 +
CHANGELOG/.chglog/CHANGELOG.tpl.md | 38 +++--
CHANGELOG/.chglog/config.yml | 22 +--
CHANGELOG/CHANGELOG-0.0.0.md | 227 -----------------------------
CHANGELOG/CHANGELOG-1.0.0.md | 161 ++++++++++++++++++++
CHANGELOG/CHANGELOG-2.0.0.md | 169 +++++++++++++++++++++
CHANGELOG/CHANGELOG-3.0.0.md | 153 +++++++++++++++++++
CHANGELOG/CHANGELOG.md | 18 ++-
8 files changed, 539 insertions(+), 250 deletions(-)
create mode 120000 CHANGELOG.md
delete mode 100644 CHANGELOG/CHANGELOG-0.0.0.md
create mode 100644 CHANGELOG/CHANGELOG-1.0.0.md
create mode 100644 CHANGELOG/CHANGELOG-2.0.0.md
create mode 100644 CHANGELOG/CHANGELOG-3.0.0.md
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 120000
index 000000000..83b694704
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1 @@
+CHANGELOG.md
\ No newline at end of file
diff --git a/CHANGELOG/.chglog/CHANGELOG.tpl.md b/CHANGELOG/.chglog/CHANGELOG.tpl.md
index a1618de92..5683d039d 100644
--- a/CHANGELOG/.chglog/CHANGELOG.tpl.md
+++ b/CHANGELOG/.chglog/CHANGELOG.tpl.md
@@ -1,40 +1,56 @@
-{{ range .Versions }}
-
-## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }}
+{{ if .Versions -}}
+
+## [Unreleased]
-> {{ datetime "2006-01-02" .Tag.Date }}
+{{ if .Unreleased.CommitGroups -}}
+{{ range .Unreleased.CommitGroups -}}
+### {{ .Title }}
+{{ range .Commits -}}
+- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
+{{ end }}
+{{ end -}}
+{{ end -}}
+{{ end -}}
+{{ range .Versions }}
+
+## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{ range .CommitGroups -}}
### {{ .Title }}
-
{{ range .Commits -}}
-* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
+- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{- if .RevertCommits -}}
### Reverts
-
{{ range .RevertCommits -}}
-* {{ .Revert.Header }}
+- {{ .Revert.Header }}
{{ end }}
{{ end -}}
{{- if .MergeCommits -}}
### Pull Requests
-
{{ range .MergeCommits -}}
-* {{ .Header }}
+- {{ .Header }}
{{ end }}
{{ end -}}
{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
-
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
+{{ end -}}
+
+{{- if .Versions }}
+[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
+{{ range .Versions -}}
+{{ if .Tag.Previous -}}
+[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
+{{ end -}}
+{{ end -}}
{{ end -}}
\ No newline at end of file
diff --git a/CHANGELOG/.chglog/config.yml b/CHANGELOG/.chglog/config.yml
index b1b42dc1a..1eed7863b 100644
--- a/CHANGELOG/.chglog/config.yml
+++ b/CHANGELOG/.chglog/config.yml
@@ -5,18 +5,18 @@ info:
repository_url: https://github.com/OpenIMSDK/Open-IM-Server
options:
commits:
- # filters:
- # Type:
- # - feat
- # - fix
- # - perf
- # - refactor
+ filters:
+ Type:
+ - feat
+ - fix
+ - perf
+ - refactor
commit_groups:
- # title_maps:
- # feat: Features
- # fix: Bug Fixes
- # perf: Performance Improvements
- # refactor: Code Refactoring
+ title_maps:
+ feat: Features
+ fix: Bug Fixes
+ perf: Performance Improvements
+ refactor: Code Refactoring
header:
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
pattern_maps:
diff --git a/CHANGELOG/CHANGELOG-0.0.0.md b/CHANGELOG/CHANGELOG-0.0.0.md
deleted file mode 100644
index 65a0ab1b1..000000000
--- a/CHANGELOG/CHANGELOG-0.0.0.md
+++ /dev/null
@@ -1,227 +0,0 @@
-
-
-## [v2.3.3](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.2...v2.3.3)
-
-> 2022-09-18
-
-
-
-## [v2.3.2](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.0-rc2...v2.3.2)
-
-> 2022-09-09
-
-### GetSelfUserInfo
-
-* Handle the case where the user does not exist
-
-### Pull Requests
-
-* Merge pull request [#267](https://github.com/OpenIMSDK/Open-IM-Server/issues/267) from ouyangshi/del
-* Merge pull request [#265](https://github.com/OpenIMSDK/Open-IM-Server/issues/265) from ouyangshi/del
-* Merge pull request [#252](https://github.com/OpenIMSDK/Open-IM-Server/issues/252) from x-shadow-man/config-perf
-* Merge pull request [#263](https://github.com/OpenIMSDK/Open-IM-Server/issues/263) from ouyangshi/main
-* Merge pull request [#258](https://github.com/OpenIMSDK/Open-IM-Server/issues/258) from ouyangshi/main
-* Merge pull request [#261](https://github.com/OpenIMSDK/Open-IM-Server/issues/261) from ouyangshi/v2.3.0release
-
-
-
-## [v2.3.0-rc2](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.0-rc1...v2.3.0-rc2)
-
-> 2022-07-29
-
-
-
-## [v2.3.0-rc1](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.0-rc0...v2.3.0-rc1)
-
-> 2022-07-25
-
-
-
-## [v2.3.0-rc0](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.2.0...v2.3.0-rc0)
-
-> 2022-07-15
-
-
-
-## [v2.2.0](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.1.0...v2.2.0)
-
-> 2022-07-01
-
-
-
-## [v2.1.0](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.10...v2.1.0)
-
-> 2022-06-17
-
-
-
-## [v2.0.10](https://github.com/OpenIMSDK/Open-IM-Server/compare/list...v2.0.10)
-
-> 2022-05-13
-
-
-
-## [list](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.9...list)
-
-> 2022-04-29
-
-
-
-## [v2.0.9](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.7...v2.0.9)
-
-> 2022-04-29
-
-### Reverts
-
-* update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
-
-
-
-## [v2.0.7](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.6...v2.0.7)
-
-> 2022-04-08
-
-
-
-## [v2.0.6](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.5...v2.0.6)
-
-> 2022-04-01
-
-### Fix
-
-* json tag value of UserIDResult.UserID ([#178](https://github.com/OpenIMSDK/Open-IM-Server/issues/178))
-
-### Pull Requests
-
-* Merge pull request [#173](https://github.com/OpenIMSDK/Open-IM-Server/issues/173) from OpenIMSDK/tuoyun
-
-
-
-## [v2.0.5](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.04...v2.0.5)
-
-> 2022-03-24
-
-
-
-## [v2.04](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.3...v2.04)
-
-> 2022-03-18
-
-
-
-## [v2.0.3](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.2...v2.0.3)
-
-> 2022-03-11
-
-
-
-## [v2.0.2](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.1...v2.0.2)
-
-> 2022-03-04
-
-### Version
-
-* "3"
-* "2"
-
-
-
-## [v2.0.1](https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.0...v2.0.1)
-
-> 2022-02-25
-
-### DbMysqlDatabaseName
-
-* openIM_v2
-
-
-
-## [v2.0.0](https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.7...v2.0.0)
-
-> 2022-02-23
-
-### Pb
-
-* openim_sdk.OfflinePushInfo
-
-### Pull Requests
-
-* Merge pull request [#131](https://github.com/OpenIMSDK/Open-IM-Server/issues/131) from OpenIMSDK/cms-dev
-
-
-
-## [v1.0.7](https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.6...v1.0.7)
-
-> 2021-12-17
-
-
-
-## [v1.0.6](https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.5...v1.0.6)
-
-> 2021-12-10
-
-### Pb
-
-* openim_sdk.OfflinePushInfo
-
-
-
-## [v1.0.5](https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.4...v1.0.5)
-
-> 2021-12-03
-
-
-
-## [v1.0.4](https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.3...v1.0.4)
-
-> 2021-11-25
-
-
-
-## [v1.0.3](https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.1...v1.0.3)
-
-> 2021-11-12
-
-### Feat
-
-* test utils ([#26](https://github.com/OpenIMSDK/Open-IM-Server/issues/26))
-
-### Fix
-
-* Startup error ([#11](https://github.com/OpenIMSDK/Open-IM-Server/issues/11))
-
-### Pull Requests
-
-* Merge pull request [#12](https://github.com/OpenIMSDK/Open-IM-Server/issues/12) from njulk/main
-* Merge pull request [#9](https://github.com/OpenIMSDK/Open-IM-Server/issues/9) from xmcy0011/dev
-* Merge pull request [#6](https://github.com/OpenIMSDK/Open-IM-Server/issues/6) from Bloomingg/int
-
-
-
-## [v1.0.1](https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.0...v1.0.1)
-
-> 2021-11-04
-
-
-
-## v1.0.0
-
-> 2021-10-28
-
-### Ci
-
-* ignore files created by docker-compose ([#19](https://github.com/OpenIMSDK/Open-IM-Server/issues/19))
-
-### Feat
-
-* optimise get server ip ([#20](https://github.com/OpenIMSDK/Open-IM-Server/issues/20))
-
-### Reverts
-
-* friend modify
-* update
-
-### Pull Requests
-
-* Merge pull request [#7](https://github.com/OpenIMSDK/Open-IM-Server/issues/7) from memory-qianxiao/docker-compose_update
-* Merge pull request [#4](https://github.com/OpenIMSDK/Open-IM-Server/issues/4) from wujingke/patch-1
diff --git a/CHANGELOG/CHANGELOG-1.0.0.md b/CHANGELOG/CHANGELOG-1.0.0.md
new file mode 100644
index 000000000..966bf1895
--- /dev/null
+++ b/CHANGELOG/CHANGELOG-1.0.0.md
@@ -0,0 +1,161 @@
+
+## [Unreleased]
+
+### Bug Fixes
+- Fix make Help
+- fix the cicd error of the robot
+- binary name modification
+- optimization details
+- remove test file
+- rename open_im to openim
+- details optimize
+- fix cmd filename
+- fix scripts
+- script -> scripts
+- script -> scripts
+- env file
+- remote
+- comment invite trigger actions
+- docker compose
+- version ploblem
+- fix branch git hooks
+- Improved initial docker scripts
+- Update CONTRIBUTING.md
+- Update README.md file
+- docker compose
+- comment invite trigger actions
+- gosec help us audit the Go code
+- changelog error
+- cover adjustment in some actions
+- make up for small problems with pre-push D
+- optimize codeql ananlysis workflows
+- file name quest
+- binary name modification
+- copyright owner
+- readme styles
+- markfown lint test cicd actions deplpy
+- designing and supplementing gnore
+- robot name
+- readme file
+- fixed some connection display issues
+- Update README image address
+- directory name
+- **gnore:** remove .github
+
+### Code Refactoring
+- add openim-sdk-core submodule
+
+### Features
+- add actions form org
+- add deployments readme file
+- add all command
+- sets the absolute path of the script
+- add cyan
+- add cyan
+- add cyan
+- add cyan
+- add cyan
+- add COLOR_SUFFIX=033[0m # End all colors and special effects
+- fix scripts
+- add chmod
+- add all page
+- add make file
+- add scripts
+- add code comment
+- add make
+- add actions form org
+- add license
+- add makefile bug
+- add more feature in scripts
+- add git hook sign
+- add codeowners file
+- add release
+- add common scripts
+- add copyright
+- add scripts lib
+- use robot to migrate code
+- add feature
+- add code ql system
+- fix openim ci
+- fix code
+- set scripts
+- set scripts
+- add chmod script
+- ver3 branch
+- add scripts chmod
+- add scripts
+- docker compose logs unified directory
+- docker compose logs unified directory
+- add copyright permission
+- optimize scripts and makefiles
+- optimize scripts and makefiles
+- set up golang ci
+- refactoring main
+- migrate the original main branch code
+- add code comment
+- complete the basic build
+- adding actions ([#461](https://github.com/OpenIMSDK/Open-IM-Server/issues/461))
+- project actions
+- service architecture
+- service architecture
+- Automatic PR title AI fix
+- vscode gitignore
+- sync file to *
+- sync file to *
+- sync core branch
+- copy license
+- make multiarch
+- sync robot
+- tools optimize
+- resolving initialization
+- exchange tokens for the robot
+- provide robot for use
+- support for closing issues
+- comment invite trigger actions
+- add codecov context
+- super log dergen
+- set the structure of the rebase
+- adjust the install go-gitlint role
+- complete the githook design
+- designing and supplementing gnore
+- add recvID/groupID for msg modification callback ([#351](https://github.com/OpenIMSDK/Open-IM-Server/issues/351))
+- extensions ignore files
+- a feat of Makefile large-scale engineering design ([#370](https://github.com/OpenIMSDK/Open-IM-Server/issues/370))
+- zh-reamde
+- ADOPTERS
+- readme add shields
+- readme add shields
+- super dependencies makefile help
+- Improve tools information
+- Improve copyright information
+- Improve copyright information
+- Improve help information
+- good frist issue readme
+- good frist issue readme
+- good frist issue readme
+- slack
+- **githook:** make sure to trigger githook when you make
+- **main:** add stale labels
+- **main:** dockerfile fix
+- **main:** update readme in v3
+- **make:** define the common implementation of the base
+- **make:** define common githook
+- **make:** add file name pre-commit for githook
+- **make:** determine the base constant setting for common
+
+
+
+## v1.0.0 - 2021-10-28
+### Features
+- optimise get server ip ([#20](https://github.com/OpenIMSDK/Open-IM-Server/issues/20))
+
+### Reverts
+- friend modify
+- update
+
+### Pull Requests
+- Merge pull request [#7](https://github.com/OpenIMSDK/Open-IM-Server/issues/7) from memory-qianxiao/docker-compose_update
+- Merge pull request [#4](https://github.com/OpenIMSDK/Open-IM-Server/issues/4) from wujingke/patch-1
+
+
+[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.0...HEAD
diff --git a/CHANGELOG/CHANGELOG-2.0.0.md b/CHANGELOG/CHANGELOG-2.0.0.md
new file mode 100644
index 000000000..18f2eeb48
--- /dev/null
+++ b/CHANGELOG/CHANGELOG-2.0.0.md
@@ -0,0 +1,169 @@
+
+## [Unreleased]
+
+### Bug Fixes
+- Fix make Help
+- fix the cicd error of the robot
+- binary name modification
+- optimization details
+- remove test file
+- rename open_im to openim
+- details optimize
+- fix cmd filename
+- fix scripts
+- script -> scripts
+- script -> scripts
+- env file
+- remote
+- comment invite trigger actions
+- docker compose
+- version ploblem
+- fix branch git hooks
+- Improved initial docker scripts
+- Update CONTRIBUTING.md
+- Update README.md file
+- docker compose
+- comment invite trigger actions
+- gosec help us audit the Go code
+- changelog error
+- cover adjustment in some actions
+- make up for small problems with pre-push D
+- optimize codeql ananlysis workflows
+- file name quest
+- binary name modification
+- copyright owner
+- readme styles
+- markfown lint test cicd actions deplpy
+- designing and supplementing gnore
+- robot name
+- readme file
+- fixed some connection display issues
+- Update README image address
+- directory name
+- **gnore:** remove .github
+
+### Code Refactoring
+- add openim-sdk-core submodule
+
+### Features
+- add actions form org
+- add deployments readme file
+- add all command
+- sets the absolute path of the script
+- add cyan
+- add cyan
+- add cyan
+- add cyan
+- add cyan
+- add COLOR_SUFFIX=033[0m # End all colors and special effects
+- fix scripts
+- add chmod
+- add all page
+- add make file
+- add scripts
+- add code comment
+- add make
+- add actions form org
+- add license
+- add makefile bug
+- add more feature in scripts
+- add git hook sign
+- add codeowners file
+- add release
+- add common scripts
+- add copyright
+- add scripts lib
+- use robot to migrate code
+- add feature
+- add code ql system
+- fix openim ci
+- fix code
+- set scripts
+- set scripts
+- add chmod script
+- ver3 branch
+- add scripts chmod
+- add scripts
+- docker compose logs unified directory
+- docker compose logs unified directory
+- add copyright permission
+- optimize scripts and makefiles
+- optimize scripts and makefiles
+- set up golang ci
+- refactoring main
+- migrate the original main branch code
+- add code comment
+- complete the basic build
+- adding actions ([#461](https://github.com/OpenIMSDK/Open-IM-Server/issues/461))
+- project actions
+- service architecture
+- service architecture
+- Automatic PR title AI fix
+- vscode gitignore
+- sync file to *
+- sync file to *
+- sync core branch
+- copy license
+- make multiarch
+- sync robot
+- tools optimize
+- resolving initialization
+- exchange tokens for the robot
+- provide robot for use
+- support for closing issues
+- comment invite trigger actions
+- add codecov context
+- super log dergen
+- set the structure of the rebase
+- adjust the install go-gitlint role
+- complete the githook design
+- designing and supplementing gnore
+- add recvID/groupID for msg modification callback ([#351](https://github.com/OpenIMSDK/Open-IM-Server/issues/351))
+- extensions ignore files
+- a feat of Makefile large-scale engineering design ([#370](https://github.com/OpenIMSDK/Open-IM-Server/issues/370))
+- zh-reamde
+- ADOPTERS
+- readme add shields
+- readme add shields
+- super dependencies makefile help
+- Improve tools information
+- Improve copyright information
+- Improve copyright information
+- Improve help information
+- good frist issue readme
+- good frist issue readme
+- good frist issue readme
+- slack
+- **githook:** make sure to trigger githook when you make
+- **main:** add stale labels
+- **main:** dockerfile fix
+- **main:** update readme in v3
+- **make:** define the common implementation of the base
+- **make:** define common githook
+- **make:** add file name pre-commit for githook
+- **make:** determine the base constant setting for common
+
+
+
+## v2.0.0 - 2022-02-23
+### Bug Fixes
+- Startup error ([#11](https://github.com/OpenIMSDK/Open-IM-Server/issues/11))
+
+### Features
+- test utils ([#26](https://github.com/OpenIMSDK/Open-IM-Server/issues/26))
+- optimise get server ip ([#20](https://github.com/OpenIMSDK/Open-IM-Server/issues/20))
+
+### Reverts
+- friend modify
+- update
+
+### Pull Requests
+- Merge pull request [#131](https://github.com/OpenIMSDK/Open-IM-Server/issues/131) from OpenIMSDK/cms-dev
+- Merge pull request [#12](https://github.com/OpenIMSDK/Open-IM-Server/issues/12) from njulk/main
+- Merge pull request [#9](https://github.com/OpenIMSDK/Open-IM-Server/issues/9) from xmcy0011/dev
+- Merge pull request [#7](https://github.com/OpenIMSDK/Open-IM-Server/issues/7) from memory-qianxiao/docker-compose_update
+- Merge pull request [#6](https://github.com/OpenIMSDK/Open-IM-Server/issues/6) from Bloomingg/int
+- Merge pull request [#4](https://github.com/OpenIMSDK/Open-IM-Server/issues/4) from wujingke/patch-1
+
+
+[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.0...HEAD
diff --git a/CHANGELOG/CHANGELOG-3.0.0.md b/CHANGELOG/CHANGELOG-3.0.0.md
new file mode 100644
index 000000000..c826243cc
--- /dev/null
+++ b/CHANGELOG/CHANGELOG-3.0.0.md
@@ -0,0 +1,153 @@
+
+## [Unreleased]
+
+
+
+## v3.0.0 - 2023-07-10
+### Bug Fixes
+- Fix make Help
+- fix the cicd error of the robot
+- binary name modification
+- optimization details
+- remove test file
+- rename open_im to openim
+- details optimize
+- fix cmd filename
+- fix scripts
+- script -> scripts
+- script -> scripts
+- env file
+- remote
+- comment invite trigger actions
+- docker compose
+- version ploblem
+- fix branch git hooks
+- Improved initial docker scripts
+- Update CONTRIBUTING.md
+- Update README.md file
+- docker compose
+- comment invite trigger actions
+- gosec help us audit the Go code
+- changelog error
+- cover adjustment in some actions
+- make up for small problems with pre-push D
+- optimize codeql ananlysis workflows
+- file name quest
+- binary name modification
+- copyright owner
+- readme styles
+- markfown lint test cicd actions deplpy
+- designing and supplementing gnore
+- robot name
+- readme file
+- fixed some connection display issues
+- Update README image address
+- directory name
+- **gnore:** remove .github
+
+### Code Refactoring
+- add openim-sdk-core submodule
+
+### Features
+- add actions form org
+- add deployments readme file
+- add all command
+- sets the absolute path of the script
+- add cyan
+- add cyan
+- add cyan
+- add cyan
+- add cyan
+- add COLOR_SUFFIX=033[0m # End all colors and special effects
+- fix scripts
+- add chmod
+- add all page
+- add make file
+- add scripts
+- add code comment
+- add make
+- add actions form org
+- add license
+- add makefile bug
+- add more feature in scripts
+- add git hook sign
+- add codeowners file
+- add release
+- add common scripts
+- add copyright
+- add scripts lib
+- use robot to migrate code
+- add feature
+- add code ql system
+- fix openim ci
+- fix code
+- set scripts
+- set scripts
+- add chmod script
+- ver3 branch
+- add scripts chmod
+- add scripts
+- docker compose logs unified directory
+- docker compose logs unified directory
+- add copyright permission
+- optimize scripts and makefiles
+- optimize scripts and makefiles
+- set up golang ci
+- refactoring main
+- migrate the original main branch code
+- add code comment
+- complete the basic build
+- adding actions ([#461](https://github.com/OpenIMSDK/Open-IM-Server/issues/461))
+- project actions
+- service architecture
+- service architecture
+- Automatic PR title AI fix
+- vscode gitignore
+- sync file to *
+- sync file to *
+- sync core branch
+- copy license
+- make multiarch
+- sync robot
+- tools optimize
+- resolving initialization
+- exchange tokens for the robot
+- provide robot for use
+- support for closing issues
+- comment invite trigger actions
+- add codecov context
+- super log dergen
+- set the structure of the rebase
+- adjust the install go-gitlint role
+- complete the githook design
+- designing and supplementing gnore
+- add recvID/groupID for msg modification callback ([#351](https://github.com/OpenIMSDK/Open-IM-Server/issues/351))
+- extensions ignore files
+- a feat of Makefile large-scale engineering design ([#370](https://github.com/OpenIMSDK/Open-IM-Server/issues/370))
+- zh-reamde
+- ADOPTERS
+- readme add shields
+- readme add shields
+- super dependencies makefile help
+- Improve tools information
+- Improve copyright information
+- Improve copyright information
+- Improve help information
+- good frist issue readme
+- good frist issue readme
+- good frist issue readme
+- slack
+- **githook:** make sure to trigger githook when you make
+- **main:** add stale labels
+- **main:** dockerfile fix
+- **main:** update readme in v3
+- **make:** define the common implementation of the base
+- **make:** define common githook
+- **make:** add file name pre-commit for githook
+- **make:** determine the base constant setting for common
+
+### Reverts
+- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
+
+
+[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v3.0.0...HEAD
diff --git a/CHANGELOG/CHANGELOG.md b/CHANGELOG/CHANGELOG.md
index 0f9b12831..79c05c44a 100644
--- a/CHANGELOG/CHANGELOG.md
+++ b/CHANGELOG/CHANGELOG.md
@@ -1,3 +1,19 @@
# Changelog
-All notable changes to this project will be documented in this file.
\ No newline at end of file
+All notable changes to this project will be documented in this file.
+
+
+## command
+
+```bash
+git-chglog --tag-filter-pattern 'v3.0.0' -o CHANGELOG-3.0.1.md
+```
+
+
+## create next tag
+
+```bash
+git-chglog --next-tag 2.0.0 -o CHANGELOG.md
+git commit -am "release 2.0.0"
+git tag 2.0.0
+```
From a5191bac950b42438c367bf7795495c1e012eb9d Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Mon, 10 Jul 2023 11:58:11 +0800
Subject: [PATCH 48/73] feat: add link file
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 83b694704..c72a9ced0 120000
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1 +1 @@
-CHANGELOG.md
\ No newline at end of file
+CHANGELOG/CHANGELOG.md
\ No newline at end of file
From 5b05152f9a24284e4c843a90269efcf9786a32ba Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Mon, 10 Jul 2023 14:56:52 +0800
Subject: [PATCH 49/73] feat: optimize scripts
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
CHANGELOG/.chglog/config.yml | 1 +
scripts/build_all_service.sh | 13 ++++++++++---
scripts/msg_gateway_start.sh | 14 +++++++-------
scripts/msg_transfer_start.sh | 14 +++++++-------
4 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/CHANGELOG/.chglog/config.yml b/CHANGELOG/.chglog/config.yml
index 1eed7863b..fe6214ab9 100644
--- a/CHANGELOG/.chglog/config.yml
+++ b/CHANGELOG/.chglog/config.yml
@@ -1,3 +1,4 @@
+bin: git
style: github
template: CHANGELOG.tpl.md
info:
diff --git a/scripts/build_all_service.sh b/scripts/build_all_service.sh
index fd196e48b..5aea8b1d9 100755
--- a/scripts/build_all_service.sh
+++ b/scripts/build_all_service.sh
@@ -13,10 +13,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+
+cd $SCRIPTS_ROOT
+
+#Include shell font styles and some basic information
+source $SCRIPTS_ROOT/style_info.sh
+source $SCRIPTS_ROOT/path_info.sh
+source $SCRIPTS_ROOT/function.sh
-source ./style_info.sh
-source ./path_info.sh
-source ./function.sh
echo -e ""
echo -e "${BACKGROUND_BLUE}===============> Building all using make build binary files ${COLOR_SUFFIX}"
diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh
index 164d993ae..b3b71d220 100755
--- a/scripts/msg_gateway_start.sh
+++ b/scripts/msg_gateway_start.sh
@@ -51,9 +51,9 @@ if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then
fi
#Check if the service exists
#If it is exists,kill this process
-check=$(ps aux | grep -w ./${openim-msggateway} | grep -v grep | wc -l)
+check=$(ps aux | grep -w ./${openim_msggateway} | grep -v grep | wc -l)
if [ $check -ge 1 ]; then
- oldPid=$(ps aux | grep -w ./${openim-msggateway} | grep -v grep | awk '{print $2}')
+ oldPid=$(ps aux | grep -w ./${openim_msggateway} | grep -v grep | awk '{print $2}')
kill -9 ${oldPid}
fi
#Waiting port recycling
@@ -61,23 +61,23 @@ sleep 1
cd ${msg_gateway_binary_root}
for ((i = 0; i < ${#ws_ports[@]}; i++)); do
echo "==========================start msg_gateway server===========================">>$OPENIM_ROOT/logs/openIM.log
- nohup ./${openim-msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
+ nohup ./${openim_msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
done
#Check launched service process
sleep 3
-check=$(ps aux | grep -w ./${openim-msggateway} | grep -v grep | wc -l)
+check=$(ps aux | grep -w ./${openim_msggateway} | grep -v grep | wc -l)
allPorts=""
if [ $check -ge 1 ]; then
- allNewPid=$(ps aux | grep -w ./${openim-msggateway} | grep -v grep | awk '{print $2}')
+ allNewPid=$(ps aux | grep -w ./${openim_msggateway} | grep -v grep | awk '{print $2}')
for i in $allNewPid; do
ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}')
allPorts=${allPorts}"$ports "
done
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS"${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${openim-msggateway}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${openim_msggateway}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allNewPid}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${BACKGROUND_GREEN}${openim-msggateway}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${openim_msggateway}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh
index 741485356..541c82910 100755
--- a/scripts/msg_transfer_start.sh
+++ b/scripts/msg_transfer_start.sh
@@ -40,10 +40,10 @@ prome_ports=($ports_array)
#Check if the service exists
#If it is exists,kill this process
-check=`ps aux | grep -w ./${openim-msgtransfer} | grep -v grep| wc -l`
+check=`ps aux | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l`
if [ $check -ge 1 ]
then
-oldPid=`ps aux | grep -w ./${openim-msgtransfer} | grep -v grep|awk '{print $2}'`
+oldPid=`ps aux | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'`
kill -9 $oldPid
fi
#Waiting port recycling
@@ -52,7 +52,7 @@ sleep 1
cd ${msg_transfer_binary_root}
for ((i = 0; i < ${msg_transfer_service_num}; i++)); do
prome_port=${prome_ports[$i]}
- cmd="nohup ./${openim-msgtransfer}"
+ cmd="nohup ./${openim_msgtransfer}"
if [ $prome_port != "" ]; then
cmd="$cmd --prometheus_port $prome_port"
fi
@@ -61,15 +61,15 @@ for ((i = 0; i < ${msg_transfer_service_num}; i++)); do
done
#Check launched service process
-check=`ps aux | grep -w ./${openim-msgtransfer} | grep -v grep| wc -l`
+check=`ps aux | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l`
if [ $check -ge 1 ]
then
-newPid=`ps aux | grep -w ./${openim-msgtransfer} | grep -v grep|awk '{print $2}'`
+newPid=`ps aux | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'`
allPorts=""
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
- echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${openim-msgtransfer}${COLOR_SUFFIX}
+ echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${openim_msgtransfer}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX}
else
- echo -e ${BACKGROUND_GREEN}${openim-msgtransfer}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
+ echo -e ${BACKGROUND_GREEN}${openim_msgtransfer}${COLOR_SUFFIX}${RED_PREFIX}"\n SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi
From b4dcbe7202f771c8e35f29b957d667dfc4b4298a Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Mon, 10 Jul 2023 16:30:21 +0800
Subject: [PATCH 50/73] feature: release version logs
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
CHANGELOG/.chglog/CHANGELOG.tpl.md | 6 +
CHANGELOG/.chglog/config.yml | 52 +++++-
CHANGELOG/CHANGELOG-1.0.0.md | 161 ------------------
CHANGELOG/CHANGELOG-1.0.md | 56 +++++++
CHANGELOG/CHANGELOG-2.0.0.md | 169 -------------------
CHANGELOG/CHANGELOG-2.0.md | 121 ++++++++++++++
CHANGELOG/CHANGELOG-2.1.md | 50 ++++++
CHANGELOG/CHANGELOG-2.2.md | 50 ++++++
CHANGELOG/CHANGELOG-2.3.md | 70 ++++++++
CHANGELOG/CHANGELOG-2.9.md | 40 +++++
CHANGELOG/CHANGELOG-3.0.0.md | 153 -----------------
CHANGELOG/CHANGELOG-3.0.md | 255 +++++++++++++++++++++++++++++
CHANGELOG/CHANGELOG.md | 3 +-
13 files changed, 694 insertions(+), 492 deletions(-)
delete mode 100644 CHANGELOG/CHANGELOG-1.0.0.md
create mode 100644 CHANGELOG/CHANGELOG-1.0.md
delete mode 100644 CHANGELOG/CHANGELOG-2.0.0.md
create mode 100644 CHANGELOG/CHANGELOG-2.0.md
create mode 100644 CHANGELOG/CHANGELOG-2.1.md
create mode 100644 CHANGELOG/CHANGELOG-2.2.md
create mode 100644 CHANGELOG/CHANGELOG-2.3.md
create mode 100644 CHANGELOG/CHANGELOG-2.9.md
delete mode 100644 CHANGELOG/CHANGELOG-3.0.0.md
create mode 100644 CHANGELOG/CHANGELOG-3.0.md
diff --git a/CHANGELOG/.chglog/CHANGELOG.tpl.md b/CHANGELOG/.chglog/CHANGELOG.tpl.md
index 5683d039d..100a29ed8 100644
--- a/CHANGELOG/.chglog/CHANGELOG.tpl.md
+++ b/CHANGELOG/.chglog/CHANGELOG.tpl.md
@@ -1,3 +1,9 @@
+# Version logging for OpenIM
+
+
+
+
+
{{ if .Versions -}}
## [Unreleased]
diff --git a/CHANGELOG/.chglog/config.yml b/CHANGELOG/.chglog/config.yml
index fe6214ab9..296ca2eb7 100644
--- a/CHANGELOG/.chglog/config.yml
+++ b/CHANGELOG/.chglog/config.yml
@@ -5,6 +5,9 @@ info:
title: CHANGELOG
repository_url: https://github.com/OpenIMSDK/Open-IM-Server
options:
+ tag_filter_pattern: '^v'
+ sort: "date"
+
commits:
filters:
Type:
@@ -12,18 +15,53 @@ options:
- fix
- perf
- refactor
+ - docs
+ - test
+ - chore
+ - ci
+ - build
+ sort_by: Scope
+
commit_groups:
+ group_by: Type
+ sort_by: Title
+ title_order:
+ - feat
+ - fix
+ - perf
+ - refactor
+ - docs
+ - test
+ - chore
+ - ci
+ - build
title_maps:
feat: Features
- fix: Bug Fixes
- perf: Performance Improvements
- refactor: Code Refactoring
+
header:
- pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
+ pattern: ""
pattern_maps:
- - Type
- - Scope
- - Subject
+ - PropName
+
+ issues:
+ prefix:
+ - #
+
+ refs:
+ actions:
+ - Closes
+ - Fixes
+
+ merges:
+ pattern: "^Merge branch '(\\w+)'$"
+ pattern_maps:
+ - Source
+
+ reverts:
+ pattern: "^Revert \"([\\s\\S]*)\"$"
+ pattern_maps:
+ - Header
+
notes:
keywords:
- BREAKING CHANGE
\ No newline at end of file
diff --git a/CHANGELOG/CHANGELOG-1.0.0.md b/CHANGELOG/CHANGELOG-1.0.0.md
deleted file mode 100644
index 966bf1895..000000000
--- a/CHANGELOG/CHANGELOG-1.0.0.md
+++ /dev/null
@@ -1,161 +0,0 @@
-
-## [Unreleased]
-
-### Bug Fixes
-- Fix make Help
-- fix the cicd error of the robot
-- binary name modification
-- optimization details
-- remove test file
-- rename open_im to openim
-- details optimize
-- fix cmd filename
-- fix scripts
-- script -> scripts
-- script -> scripts
-- env file
-- remote
-- comment invite trigger actions
-- docker compose
-- version ploblem
-- fix branch git hooks
-- Improved initial docker scripts
-- Update CONTRIBUTING.md
-- Update README.md file
-- docker compose
-- comment invite trigger actions
-- gosec help us audit the Go code
-- changelog error
-- cover adjustment in some actions
-- make up for small problems with pre-push D
-- optimize codeql ananlysis workflows
-- file name quest
-- binary name modification
-- copyright owner
-- readme styles
-- markfown lint test cicd actions deplpy
-- designing and supplementing gnore
-- robot name
-- readme file
-- fixed some connection display issues
-- Update README image address
-- directory name
-- **gnore:** remove .github
-
-### Code Refactoring
-- add openim-sdk-core submodule
-
-### Features
-- add actions form org
-- add deployments readme file
-- add all command
-- sets the absolute path of the script
-- add cyan
-- add cyan
-- add cyan
-- add cyan
-- add cyan
-- add COLOR_SUFFIX=033[0m # End all colors and special effects
-- fix scripts
-- add chmod
-- add all page
-- add make file
-- add scripts
-- add code comment
-- add make
-- add actions form org
-- add license
-- add makefile bug
-- add more feature in scripts
-- add git hook sign
-- add codeowners file
-- add release
-- add common scripts
-- add copyright
-- add scripts lib
-- use robot to migrate code
-- add feature
-- add code ql system
-- fix openim ci
-- fix code
-- set scripts
-- set scripts
-- add chmod script
-- ver3 branch
-- add scripts chmod
-- add scripts
-- docker compose logs unified directory
-- docker compose logs unified directory
-- add copyright permission
-- optimize scripts and makefiles
-- optimize scripts and makefiles
-- set up golang ci
-- refactoring main
-- migrate the original main branch code
-- add code comment
-- complete the basic build
-- adding actions ([#461](https://github.com/OpenIMSDK/Open-IM-Server/issues/461))
-- project actions
-- service architecture
-- service architecture
-- Automatic PR title AI fix
-- vscode gitignore
-- sync file to *
-- sync file to *
-- sync core branch
-- copy license
-- make multiarch
-- sync robot
-- tools optimize
-- resolving initialization
-- exchange tokens for the robot
-- provide robot for use
-- support for closing issues
-- comment invite trigger actions
-- add codecov context
-- super log dergen
-- set the structure of the rebase
-- adjust the install go-gitlint role
-- complete the githook design
-- designing and supplementing gnore
-- add recvID/groupID for msg modification callback ([#351](https://github.com/OpenIMSDK/Open-IM-Server/issues/351))
-- extensions ignore files
-- a feat of Makefile large-scale engineering design ([#370](https://github.com/OpenIMSDK/Open-IM-Server/issues/370))
-- zh-reamde
-- ADOPTERS
-- readme add shields
-- readme add shields
-- super dependencies makefile help
-- Improve tools information
-- Improve copyright information
-- Improve copyright information
-- Improve help information
-- good frist issue readme
-- good frist issue readme
-- good frist issue readme
-- slack
-- **githook:** make sure to trigger githook when you make
-- **main:** add stale labels
-- **main:** dockerfile fix
-- **main:** update readme in v3
-- **make:** define the common implementation of the base
-- **make:** define common githook
-- **make:** add file name pre-commit for githook
-- **make:** determine the base constant setting for common
-
-
-
-## v1.0.0 - 2021-10-28
-### Features
-- optimise get server ip ([#20](https://github.com/OpenIMSDK/Open-IM-Server/issues/20))
-
-### Reverts
-- friend modify
-- update
-
-### Pull Requests
-- Merge pull request [#7](https://github.com/OpenIMSDK/Open-IM-Server/issues/7) from memory-qianxiao/docker-compose_update
-- Merge pull request [#4](https://github.com/OpenIMSDK/Open-IM-Server/issues/4) from wujingke/patch-1
-
-
-[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.0...HEAD
diff --git a/CHANGELOG/CHANGELOG-1.0.md b/CHANGELOG/CHANGELOG-1.0.md
new file mode 100644
index 000000000..04980fbd4
--- /dev/null
+++ b/CHANGELOG/CHANGELOG-1.0.md
@@ -0,0 +1,56 @@
+# Version logging for OpenIM
+
+> **Note**:
+> Deprecated version logging for OpenIM, please refer to [CHANGELOG.md](../CHANGELOG.md)
+
+
+
+- [Version logging for OpenIM](#version-logging-for-openim)
+ - [Unreleased](#unreleased)
+ - [v1.0.7 - 2021-12-17](#v107---2021-12-17)
+ - [v1.0.6 - 2021-12-10](#v106---2021-12-10)
+ - [v1.0.5 - 2021-12-03](#v105---2021-12-03)
+ - [v1.0.4 - 2021-11-25](#v104---2021-11-25)
+ - [v1.0.3 - 2021-11-12](#v103---2021-11-12)
+ - [v1.0.1 - 2021-11-04](#v101---2021-11-04)
+ - [v1.0.0 - 2021-10-28](#v100---2021-10-28)
+ - [Reverts](#reverts)
+
+
+
+
+## [Unreleased]
+
+
+
+## [v1.0.7] - 2021-12-17
+
+
+## [v1.0.6] - 2021-12-10
+
+
+## [v1.0.5] - 2021-12-03
+
+
+## [v1.0.4] - 2021-11-25
+
+
+## [v1.0.3] - 2021-11-12
+
+
+## [v1.0.1] - 2021-11-04
+
+
+## v1.0.0 - 2021-10-28
+### Reverts
+- friend modify
+- update
+
+
+[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.7...HEAD
+[v1.0.7]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.6...v1.0.7
+[v1.0.6]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.5...v1.0.6
+[v1.0.5]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.4...v1.0.5
+[v1.0.4]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.3...v1.0.4
+[v1.0.3]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.1...v1.0.3
+[v1.0.1]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.0...v1.0.1
diff --git a/CHANGELOG/CHANGELOG-2.0.0.md b/CHANGELOG/CHANGELOG-2.0.0.md
deleted file mode 100644
index 18f2eeb48..000000000
--- a/CHANGELOG/CHANGELOG-2.0.0.md
+++ /dev/null
@@ -1,169 +0,0 @@
-
-## [Unreleased]
-
-### Bug Fixes
-- Fix make Help
-- fix the cicd error of the robot
-- binary name modification
-- optimization details
-- remove test file
-- rename open_im to openim
-- details optimize
-- fix cmd filename
-- fix scripts
-- script -> scripts
-- script -> scripts
-- env file
-- remote
-- comment invite trigger actions
-- docker compose
-- version ploblem
-- fix branch git hooks
-- Improved initial docker scripts
-- Update CONTRIBUTING.md
-- Update README.md file
-- docker compose
-- comment invite trigger actions
-- gosec help us audit the Go code
-- changelog error
-- cover adjustment in some actions
-- make up for small problems with pre-push D
-- optimize codeql ananlysis workflows
-- file name quest
-- binary name modification
-- copyright owner
-- readme styles
-- markfown lint test cicd actions deplpy
-- designing and supplementing gnore
-- robot name
-- readme file
-- fixed some connection display issues
-- Update README image address
-- directory name
-- **gnore:** remove .github
-
-### Code Refactoring
-- add openim-sdk-core submodule
-
-### Features
-- add actions form org
-- add deployments readme file
-- add all command
-- sets the absolute path of the script
-- add cyan
-- add cyan
-- add cyan
-- add cyan
-- add cyan
-- add COLOR_SUFFIX=033[0m # End all colors and special effects
-- fix scripts
-- add chmod
-- add all page
-- add make file
-- add scripts
-- add code comment
-- add make
-- add actions form org
-- add license
-- add makefile bug
-- add more feature in scripts
-- add git hook sign
-- add codeowners file
-- add release
-- add common scripts
-- add copyright
-- add scripts lib
-- use robot to migrate code
-- add feature
-- add code ql system
-- fix openim ci
-- fix code
-- set scripts
-- set scripts
-- add chmod script
-- ver3 branch
-- add scripts chmod
-- add scripts
-- docker compose logs unified directory
-- docker compose logs unified directory
-- add copyright permission
-- optimize scripts and makefiles
-- optimize scripts and makefiles
-- set up golang ci
-- refactoring main
-- migrate the original main branch code
-- add code comment
-- complete the basic build
-- adding actions ([#461](https://github.com/OpenIMSDK/Open-IM-Server/issues/461))
-- project actions
-- service architecture
-- service architecture
-- Automatic PR title AI fix
-- vscode gitignore
-- sync file to *
-- sync file to *
-- sync core branch
-- copy license
-- make multiarch
-- sync robot
-- tools optimize
-- resolving initialization
-- exchange tokens for the robot
-- provide robot for use
-- support for closing issues
-- comment invite trigger actions
-- add codecov context
-- super log dergen
-- set the structure of the rebase
-- adjust the install go-gitlint role
-- complete the githook design
-- designing and supplementing gnore
-- add recvID/groupID for msg modification callback ([#351](https://github.com/OpenIMSDK/Open-IM-Server/issues/351))
-- extensions ignore files
-- a feat of Makefile large-scale engineering design ([#370](https://github.com/OpenIMSDK/Open-IM-Server/issues/370))
-- zh-reamde
-- ADOPTERS
-- readme add shields
-- readme add shields
-- super dependencies makefile help
-- Improve tools information
-- Improve copyright information
-- Improve copyright information
-- Improve help information
-- good frist issue readme
-- good frist issue readme
-- good frist issue readme
-- slack
-- **githook:** make sure to trigger githook when you make
-- **main:** add stale labels
-- **main:** dockerfile fix
-- **main:** update readme in v3
-- **make:** define the common implementation of the base
-- **make:** define common githook
-- **make:** add file name pre-commit for githook
-- **make:** determine the base constant setting for common
-
-
-
-## v2.0.0 - 2022-02-23
-### Bug Fixes
-- Startup error ([#11](https://github.com/OpenIMSDK/Open-IM-Server/issues/11))
-
-### Features
-- test utils ([#26](https://github.com/OpenIMSDK/Open-IM-Server/issues/26))
-- optimise get server ip ([#20](https://github.com/OpenIMSDK/Open-IM-Server/issues/20))
-
-### Reverts
-- friend modify
-- update
-
-### Pull Requests
-- Merge pull request [#131](https://github.com/OpenIMSDK/Open-IM-Server/issues/131) from OpenIMSDK/cms-dev
-- Merge pull request [#12](https://github.com/OpenIMSDK/Open-IM-Server/issues/12) from njulk/main
-- Merge pull request [#9](https://github.com/OpenIMSDK/Open-IM-Server/issues/9) from xmcy0011/dev
-- Merge pull request [#7](https://github.com/OpenIMSDK/Open-IM-Server/issues/7) from memory-qianxiao/docker-compose_update
-- Merge pull request [#6](https://github.com/OpenIMSDK/Open-IM-Server/issues/6) from Bloomingg/int
-- Merge pull request [#4](https://github.com/OpenIMSDK/Open-IM-Server/issues/4) from wujingke/patch-1
-
-
-[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.0...HEAD
diff --git a/CHANGELOG/CHANGELOG-2.0.md b/CHANGELOG/CHANGELOG-2.0.md
new file mode 100644
index 000000000..0340bd168
--- /dev/null
+++ b/CHANGELOG/CHANGELOG-2.0.md
@@ -0,0 +1,121 @@
+# Version logging for OpenIM:v2.0
+
+> **Note**:
+> Deprecated version logging for OpenIM, please refer to [CHANGELOG.md](../CHANGELOG.md)
+
+
+
+- [Version logging for OpenIM:v2.0](#version-logging-for-openimv20)
+ - [\[Unreleased\]](#unreleased)
+ - [\[v2.0.10\] - 2022-05-13](#v2010---2022-05-13)
+ - [\[v2.0.9\] - 2022-04-29](#v209---2022-04-29)
+ - [Reverts](#reverts)
+ - [Pull Requests](#pull-requests)
+ - [\[v2.0.8\] - 2022-04-24](#v208---2022-04-24)
+ - [Pull Requests](#pull-requests-1)
+ - [\[v2.0.7\] - 2022-04-08](#v207---2022-04-08)
+ - [Pull Requests](#pull-requests-2)
+ - [\[v2.0.6\] - 2022-04-01](#v206---2022-04-01)
+ - [Pull Requests](#pull-requests-3)
+ - [\[v2.0.5\] - 2022-03-24](#v205---2022-03-24)
+ - [\[v2.04\] - 2022-03-18](#v204---2022-03-18)
+ - [\[v2.0.3\] - 2022-03-11](#v203---2022-03-11)
+ - [\[v2.0.2\] - 2022-03-04](#v202---2022-03-04)
+ - [Pull Requests](#pull-requests-4)
+ - [\[v2.0.1\] - 2022-02-25](#v201---2022-02-25)
+ - [v2.0.0 - 2022-02-23](#v200---2022-02-23)
+ - [Reverts](#reverts-1)
+
+
+
+
+
+
+## [Unreleased]
+
+
+
+
+## [v2.0.10] - 2022-05-13
+
+
+
+## [v2.0.9] - 2022-04-29
+
+### Reverts
+
+- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
+
+### Pull Requests
+
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+
+
+## [v2.0.8] - 2022-04-24
+
+### Pull Requests
+
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+
+
+## [v2.0.7] - 2022-04-08
+
+### Pull Requests
+
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+
+
+## [v2.0.6] - 2022-04-01
+
+### Pull Requests
+
+- Merge branch 'tuoyun'
+
+
+
+
+## [v2.0.5] - 2022-03-24
+
+
+
+## [v2.04] - 2022-03-18
+
+
+
+## [v2.0.3] - 2022-03-11
+
+
+
+## [v2.0.2] - 2022-03-04
+
+### Pull Requests
+
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+
+
+## [v2.0.1] - 2022-02-25
+
+
+
+## v2.0.0 - 2022-02-23
+
+### Reverts
diff --git a/CHANGELOG/CHANGELOG-2.1.md b/CHANGELOG/CHANGELOG-2.1.md
new file mode 100644
index 000000000..32effd64d
--- /dev/null
+++ b/CHANGELOG/CHANGELOG-2.1.md
@@ -0,0 +1,50 @@
+# Version logging for OpenIM:v2.1
+
+> **Note**:
+> Deprecated version logging for OpenIM, please refer to [CHANGELOG.md](../CHANGELOG.md)
+
+
+
+- [Version logging for OpenIM:v2.1](#version-logging-for-openimv21)
+ - [Unreleased](#unreleased)
+ - [v2.1.0 - 2022-06-17](#v210---2022-06-17)
+ - [Reverts](#reverts)
+ - [Pull Requests](#pull-requests)
+
+
+
+
+
+## [Unreleased]
+
+
+
+## v2.1.0 - 2022-06-17
+### Reverts
+- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
+- friend modify
+- update
+
+### Pull Requests
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.1.0...HEAD
diff --git a/CHANGELOG/CHANGELOG-2.2.md b/CHANGELOG/CHANGELOG-2.2.md
new file mode 100644
index 000000000..e00204316
--- /dev/null
+++ b/CHANGELOG/CHANGELOG-2.2.md
@@ -0,0 +1,50 @@
+# Version logging for OpenIM:v2.2
+
+> **Note**:
+> Deprecated version logging for OpenIM, please refer to [CHANGELOG.md](../CHANGELOG.md)
+
+
+
+- [Version logging for OpenIM:v2.2](#version-logging-for-openimv22)
+ - [Unreleased](#unreleased)
+ - [v2.2.0 - 2022-07-01](#v220---2022-07-01)
+ - [Reverts](#reverts)
+ - [Pull Requests](#pull-requests)
+
+
+
+
+
+## [Unreleased]
+
+
+
+## v2.2.0 - 2022-07-01
+### Reverts
+- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
+- friend modify
+- update
+
+### Pull Requests
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.2.0...HEAD
diff --git a/CHANGELOG/CHANGELOG-2.3.md b/CHANGELOG/CHANGELOG-2.3.md
new file mode 100644
index 000000000..c33b81a9a
--- /dev/null
+++ b/CHANGELOG/CHANGELOG-2.3.md
@@ -0,0 +1,70 @@
+# Version logging for OpenIM:v2.3
+
+> **Note**:
+> Deprecated version logging for OpenIM, please refer to [CHANGELOG.md](../CHANGELOG.md)
+
+
+
+- [Version logging for OpenIM:v2.3](#version-logging-for-openimv23)
+ - [Unreleased](#unreleased)
+ - [v2.3.3 - 2022-09-18](#v233---2022-09-18)
+ - [v2.3.2 - 2022-09-09](#v232---2022-09-09)
+ - [v2.3.0-rc2 - 2022-07-29](#v230-rc2---2022-07-29)
+ - [v2.3.0-rc1 - 2022-07-25](#v230-rc1---2022-07-25)
+ - [v2.3.0-rc0 - 2022-07-15](#v230-rc0---2022-07-15)
+ - [Reverts](#reverts)
+ - [Pull Requests](#pull-requests)
+
+
+
+
+
+## [Unreleased]
+
+
+
+## [v2.3.3] - 2022-09-18
+
+
+## [v2.3.2] - 2022-09-09
+
+
+## [v2.3.0-rc2] - 2022-07-29
+
+
+## [v2.3.0-rc1] - 2022-07-25
+
+
+## v2.3.0-rc0 - 2022-07-15
+### Reverts
+- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
+- friend modify
+- update
+
+### Pull Requests
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.3...HEAD
+[v2.3.3]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.2...v2.3.3
+[v2.3.2]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.0-rc2...v2.3.2
+[v2.3.0-rc2]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.0-rc1...v2.3.0-rc2
+[v2.3.0-rc1]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.0-rc0...v2.3.0-rc1
diff --git a/CHANGELOG/CHANGELOG-2.9.md b/CHANGELOG/CHANGELOG-2.9.md
new file mode 100644
index 000000000..174286f0d
--- /dev/null
+++ b/CHANGELOG/CHANGELOG-2.9.md
@@ -0,0 +1,40 @@
+# Version logging for OpenIM
+
+
+
+
+
+
+## [Unreleased]
+
+
+
+## [v2.9.0+1.839643f] - 2023-07-07
+
+
+## [v2.9.0+2.35f07fe] - 2023-07-06
+
+
+## [v2.9.0+1.b5072b1] - 2023-07-05
+
+
+## [v2.9.0+3.2667a3a] - 2023-07-05
+
+
+## [v2.9.0+7.04818ca] - 2023-07-05
+
+
+## v2.9.0 - 2023-07-04
+### Reverts
+- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
+
+### Pull Requests
+- Merge branch 'tuoyun'
+
+
+[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+1.839643f...HEAD
+[v2.9.0+1.839643f]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+2.35f07fe...v2.9.0+1.839643f
+[v2.9.0+2.35f07fe]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+1.b5072b1...v2.9.0+2.35f07fe
+[v2.9.0+1.b5072b1]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+3.2667a3a...v2.9.0+1.b5072b1
+[v2.9.0+3.2667a3a]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+7.04818ca...v2.9.0+3.2667a3a
+[v2.9.0+7.04818ca]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0...v2.9.0+7.04818ca
diff --git a/CHANGELOG/CHANGELOG-3.0.0.md b/CHANGELOG/CHANGELOG-3.0.0.md
deleted file mode 100644
index c826243cc..000000000
--- a/CHANGELOG/CHANGELOG-3.0.0.md
+++ /dev/null
@@ -1,153 +0,0 @@
-
-## [Unreleased]
-
-
-
-## v3.0.0 - 2023-07-10
-### Bug Fixes
-- Fix make Help
-- fix the cicd error of the robot
-- binary name modification
-- optimization details
-- remove test file
-- rename open_im to openim
-- details optimize
-- fix cmd filename
-- fix scripts
-- script -> scripts
-- script -> scripts
-- env file
-- remote
-- comment invite trigger actions
-- docker compose
-- version ploblem
-- fix branch git hooks
-- Improved initial docker scripts
-- Update CONTRIBUTING.md
-- Update README.md file
-- docker compose
-- comment invite trigger actions
-- gosec help us audit the Go code
-- changelog error
-- cover adjustment in some actions
-- make up for small problems with pre-push D
-- optimize codeql ananlysis workflows
-- file name quest
-- binary name modification
-- copyright owner
-- readme styles
-- markfown lint test cicd actions deplpy
-- designing and supplementing gnore
-- robot name
-- readme file
-- fixed some connection display issues
-- Update README image address
-- directory name
-- **gnore:** remove .github
-
-### Code Refactoring
-- add openim-sdk-core submodule
-
-### Features
-- add actions form org
-- add deployments readme file
-- add all command
-- sets the absolute path of the script
-- add cyan
-- add cyan
-- add cyan
-- add cyan
-- add cyan
-- add COLOR_SUFFIX=033[0m # End all colors and special effects
-- fix scripts
-- add chmod
-- add all page
-- add make file
-- add scripts
-- add code comment
-- add make
-- add actions form org
-- add license
-- add makefile bug
-- add more feature in scripts
-- add git hook sign
-- add codeowners file
-- add release
-- add common scripts
-- add copyright
-- add scripts lib
-- use robot to migrate code
-- add feature
-- add code ql system
-- fix openim ci
-- fix code
-- set scripts
-- set scripts
-- add chmod script
-- ver3 branch
-- add scripts chmod
-- add scripts
-- docker compose logs unified directory
-- docker compose logs unified directory
-- add copyright permission
-- optimize scripts and makefiles
-- optimize scripts and makefiles
-- set up golang ci
-- refactoring main
-- migrate the original main branch code
-- add code comment
-- complete the basic build
-- adding actions ([#461](https://github.com/OpenIMSDK/Open-IM-Server/issues/461))
-- project actions
-- service architecture
-- service architecture
-- Automatic PR title AI fix
-- vscode gitignore
-- sync file to *
-- sync file to *
-- sync core branch
-- copy license
-- make multiarch
-- sync robot
-- tools optimize
-- resolving initialization
-- exchange tokens for the robot
-- provide robot for use
-- support for closing issues
-- comment invite trigger actions
-- add codecov context
-- super log dergen
-- set the structure of the rebase
-- adjust the install go-gitlint role
-- complete the githook design
-- designing and supplementing gnore
-- add recvID/groupID for msg modification callback ([#351](https://github.com/OpenIMSDK/Open-IM-Server/issues/351))
-- extensions ignore files
-- a feat of Makefile large-scale engineering design ([#370](https://github.com/OpenIMSDK/Open-IM-Server/issues/370))
-- zh-reamde
-- ADOPTERS
-- readme add shields
-- readme add shields
-- super dependencies makefile help
-- Improve tools information
-- Improve copyright information
-- Improve copyright information
-- Improve help information
-- good frist issue readme
-- good frist issue readme
-- good frist issue readme
-- slack
-- **githook:** make sure to trigger githook when you make
-- **main:** add stale labels
-- **main:** dockerfile fix
-- **main:** update readme in v3
-- **make:** define the common implementation of the base
-- **make:** define common githook
-- **make:** add file name pre-commit for githook
-- **make:** determine the base constant setting for common
-
-### Reverts
-- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
-
-
-[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v3.0.0...HEAD
diff --git a/CHANGELOG/CHANGELOG-3.0.md b/CHANGELOG/CHANGELOG-3.0.md
new file mode 100644
index 000000000..72cc56bbf
--- /dev/null
+++ b/CHANGELOG/CHANGELOG-3.0.md
@@ -0,0 +1,255 @@
+# Version logging for OpenIM
+
+**3.0 Major refactoring**
+
+
+
+- [Version logging for OpenIM](#version-logging-for-openim)
+ - [\[v3.0\]](#v30)
+ - [v3.0.0 - 2023-07-10](#v300---2023-07-10)
+ - [v2.9.0+1.839643f - 2023-07-07](#v2901839643f---2023-07-07)
+ - [v2.9.0+2.35f07fe - 2023-07-06](#v290235f07fe---2023-07-06)
+ - [v2.9.0+1.b5072b1 - 2023-07-05](#v2901b5072b1---2023-07-05)
+ - [v2.9.0+3.2667a3a - 2023-07-05](#v29032667a3a---2023-07-05)
+ - [v2.9.0+7.04818ca - 2023-07-05](#v290704818ca---2023-07-05)
+ - [v2.9.0 - 2023-07-04](#v290---2023-07-04)
+ - [v0.0.0+1.3714b4f - 2023-07-04](#v00013714b4f---2023-07-04)
+ - [v0.0.0+635.8b92c90 - 2023-07-04](#v0006358b92c90---2023-07-04)
+ - [v0.0.0+1.78a6d03 - 2023-07-04](#v000178a6d03---2023-07-04)
+ - [v0.0.0+2.e057c18 - 2023-07-04](#v0002e057c18---2023-07-04)
+ - [v0.0.0+630.b55ac4a - 2023-07-04](#v000630b55ac4a---2023-07-04)
+ - [Reverts](#reverts)
+ - [Pull Requests](#pull-requests)
+ - [v2.3.3 - 2022-09-18](#v233---2022-09-18)
+ - [v2.3.2 - 2022-09-09](#v232---2022-09-09)
+ - [v2.3.0-rc2 - 2022-07-29](#v230-rc2---2022-07-29)
+ - [v2.3.0-rc1 - 2022-07-25](#v230-rc1---2022-07-25)
+ - [v2.3.0-rc0 - 2022-07-15](#v230-rc0---2022-07-15)
+ - [v2.2.0 - 2022-07-01](#v220---2022-07-01)
+ - [v2.1.0 - 2022-06-17](#v210---2022-06-17)
+ - [Pull Requests](#pull-requests-1)
+ - [v2.0.10 - 2022-05-13](#v2010---2022-05-13)
+ - [v2.0.9 - 2022-04-29](#v209---2022-04-29)
+ - [Reverts](#reverts-1)
+ - [Pull Requests](#pull-requests-2)
+ - [v2.0.8 - 2022-04-24](#v208---2022-04-24)
+ - [Pull Requests](#pull-requests-3)
+ - [v2.0.7 - 2022-04-08](#v207---2022-04-08)
+ - [Pull Requests](#pull-requests-4)
+ - [v2.0.6 - 2022-04-01](#v206---2022-04-01)
+ - [Pull Requests](#pull-requests-5)
+ - [v2.0.5 - 2022-03-24](#v205---2022-03-24)
+ - [v2.04 - 2022-03-18](#v204---2022-03-18)
+ - [v2.0.3 - 2022-03-11](#v203---2022-03-11)
+ - [v2.0.2 - 2022-03-04](#v202---2022-03-04)
+ - [Pull Requests](#pull-requests-6)
+ - [v2.0.1 - 2022-02-25](#v201---2022-02-25)
+ - [v2.0.0 - 2022-02-23](#v200---2022-02-23)
+ - [v1.0.7 - 2021-12-17](#v107---2021-12-17)
+ - [v1.0.6 - 2021-12-10](#v106---2021-12-10)
+ - [v1.0.5 - 2021-12-03](#v105---2021-12-03)
+ - [v1.0.4 - 2021-11-25](#v104---2021-11-25)
+ - [v1.0.3 - 2021-11-12](#v103---2021-11-12)
+ - [v1.0.1 - 2021-11-04](#v101---2021-11-04)
+ - [v1.0.0 - 2021-10-28](#v100---2021-10-28)
+ - [Reverts](#reverts-2)
+
+
+
+
+
+## [v3.0]
+
+
+
+## [v3.0.0] - 2023-07-10
+
+
+## [v2.9.0+1.839643f] - 2023-07-07
+
+
+## [v2.9.0+2.35f07fe] - 2023-07-06
+
+
+## [v2.9.0+1.b5072b1] - 2023-07-05
+
+
+## [v2.9.0+3.2667a3a] - 2023-07-05
+
+
+## [v2.9.0+7.04818ca] - 2023-07-05
+
+
+## [v2.9.0] - 2023-07-04
+
+
+## [v0.0.0+1.3714b4f] - 2023-07-04
+
+
+## [v0.0.0+635.8b92c90] - 2023-07-04
+
+
+## [v0.0.0+1.78a6d03] - 2023-07-04
+
+
+## [v0.0.0+2.e057c18] - 2023-07-04
+
+
+## [v0.0.0+630.b55ac4a] - 2023-07-04
+### Reverts
+- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
+
+### Pull Requests
+- Merge branch 'tuoyun'
+
+
+
+## [v2.3.3] - 2022-09-18
+
+
+## [v2.3.2] - 2022-09-09
+
+
+## [v2.3.0-rc2] - 2022-07-29
+
+
+## [v2.3.0-rc1] - 2022-07-25
+
+
+## [v2.3.0-rc0] - 2022-07-15
+
+
+## [v2.2.0] - 2022-07-01
+
+
+## [v2.1.0] - 2022-06-17
+### Pull Requests
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+
+## [v2.0.10] - 2022-05-13
+
+
+## [v2.0.9] - 2022-04-29
+### Reverts
+- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
+
+### Pull Requests
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+
+## [v2.0.8] - 2022-04-24
+### Pull Requests
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+
+## [v2.0.7] - 2022-04-08
+### Pull Requests
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+
+## [v2.0.6] - 2022-04-01
+### Pull Requests
+- Merge branch 'tuoyun'
+
+
+
+## [v2.0.5] - 2022-03-24
+
+
+## [v2.04] - 2022-03-18
+
+
+## [v2.0.3] - 2022-03-11
+
+
+## [v2.0.2] - 2022-03-04
+### Pull Requests
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+- Merge branch 'tuoyun'
+
+
+
+## [v2.0.1] - 2022-02-25
+
+
+## [v2.0.0] - 2022-02-23
+
+
+## [v1.0.7] - 2021-12-17
+
+
+## [v1.0.6] - 2021-12-10
+
+
+## [v1.0.5] - 2021-12-03
+
+
+## [v1.0.4] - 2021-11-25
+
+
+## [v1.0.3] - 2021-11-12
+
+
+## [v1.0.1] - 2021-11-04
+
+
+## v1.0.0 - 2021-10-28
+### Reverts
+- friend modify
+- update
+
+
+[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v3.0.0...HEAD
+[v3.0.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+1.839643f...v3.0.0
+[v2.9.0+1.839643f]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+2.35f07fe...v2.9.0+1.839643f
+[v2.9.0+2.35f07fe]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+1.b5072b1...v2.9.0+2.35f07fe
+[v2.9.0+1.b5072b1]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+3.2667a3a...v2.9.0+1.b5072b1
+[v2.9.0+3.2667a3a]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+7.04818ca...v2.9.0+3.2667a3a
+[v2.9.0+7.04818ca]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0...v2.9.0+7.04818ca
+[v2.9.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v0.0.0+1.3714b4f...v2.9.0
+[v0.0.0+1.3714b4f]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v0.0.0+635.8b92c90...v0.0.0+1.3714b4f
+[v0.0.0+635.8b92c90]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v0.0.0+1.78a6d03...v0.0.0+635.8b92c90
+[v0.0.0+1.78a6d03]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v0.0.0+2.e057c18...v0.0.0+1.78a6d03
+[v0.0.0+2.e057c18]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v0.0.0+630.b55ac4a...v0.0.0+2.e057c18
+[v0.0.0+630.b55ac4a]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.3...v0.0.0+630.b55ac4a
+[v2.3.3]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.2...v2.3.3
+[v2.3.2]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.0-rc2...v2.3.2
+[v2.3.0-rc2]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.0-rc1...v2.3.0-rc2
+[v2.3.0-rc1]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.0-rc0...v2.3.0-rc1
+[v2.3.0-rc0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.2.0...v2.3.0-rc0
+[v2.2.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.1.0...v2.2.0
+[v2.1.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.10...v2.1.0
+[v2.0.10]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.9...v2.0.10
+[v2.0.9]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.8...v2.0.9
+[v2.0.8]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.7...v2.0.8
+[v2.0.7]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.6...v2.0.7
+[v2.0.6]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.5...v2.0.6
+[v2.0.5]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.04...v2.0.5
+[v2.04]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.3...v2.04
+[v2.0.3]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.2...v2.0.3
+[v2.0.2]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.1...v2.0.2
+[v2.0.1]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.0...v2.0.1
+[v2.0.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.7...v2.0.0
+[v1.0.7]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.6...v1.0.7
+[v1.0.6]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.5...v1.0.6
+[v1.0.5]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.4...v1.0.5
+[v1.0.4]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.3...v1.0.4
+[v1.0.3]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.1...v1.0.3
+[v1.0.1]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v1.0.0...v1.0.1
diff --git a/CHANGELOG/CHANGELOG.md b/CHANGELOG/CHANGELOG.md
index 79c05c44a..67f28d959 100644
--- a/CHANGELOG/CHANGELOG.md
+++ b/CHANGELOG/CHANGELOG.md
@@ -6,10 +6,9 @@ All notable changes to this project will be documented in this file.
## command
```bash
-git-chglog --tag-filter-pattern 'v3.0.0' -o CHANGELOG-3.0.1.md
+git-chglog --tag-filter-pattern 'v2.0.*' -o CHANGELOG-2.0.md
```
-
## create next tag
```bash
From 29d422b71d4b45a52c1d42995df14bae4e89612d Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Mon, 10 Jul 2023 17:49:28 +0800
Subject: [PATCH 51/73] feat: add scripts and fix
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/batch_start_all.sh | 6 +++---
scripts/build_all_service.sh | 8 ++++++--
scripts/check_all.sh | 6 +++---
scripts/enterprise/check_all.sh | 6 +++---
scripts/msg_gateway_start.sh | 6 +++---
scripts/msg_transfer_start.sh | 6 +++---
scripts/path_info.sh | 6 +++---
scripts/push_start.sh | 6 +++---
scripts/start_all.sh | 6 +++---
scripts/start_cron.sh | 6 +++---
10 files changed, 33 insertions(+), 29 deletions(-)
diff --git a/scripts/batch_start_all.sh b/scripts/batch_start_all.sh
index e291819f4..45ec813c5 100755
--- a/scripts/batch_start_all.sh
+++ b/scripts/batch_start_all.sh
@@ -27,9 +27,9 @@ source $SCRIPTS_ROOT/function.sh
cd $SCRIPTS_ROOT
-echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
need_to_start_server_shell=(
"start_rpc_service.sh"
diff --git a/scripts/build_all_service.sh b/scripts/build_all_service.sh
index 5aea8b1d9..ebbc02dfa 100755
--- a/scripts/build_all_service.sh
+++ b/scripts/build_all_service.sh
@@ -17,13 +17,17 @@
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
-cd $SCRIPTS_ROOT
-
#Include shell font styles and some basic information
source $SCRIPTS_ROOT/style_info.sh
source $SCRIPTS_ROOT/path_info.sh
source $SCRIPTS_ROOT/function.sh
+echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
+
+cd $SCRIPTS_ROOT
+
echo -e ""
echo -e "${BACKGROUND_BLUE}===============> Building all using make build binary files ${COLOR_SUFFIX}"
diff --git a/scripts/check_all.sh b/scripts/check_all.sh
index db420dd21..c4f5dd490 100755
--- a/scripts/check_all.sh
+++ b/scripts/check_all.sh
@@ -24,9 +24,9 @@ source $SCRIPTS_ROOT/function.sh
cd $SCRIPTS_ROOT
-echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
service_port_name=(
openImWsPort
diff --git a/scripts/enterprise/check_all.sh b/scripts/enterprise/check_all.sh
index 7b8a3c5da..973a6a962 100755
--- a/scripts/enterprise/check_all.sh
+++ b/scripts/enterprise/check_all.sh
@@ -24,9 +24,9 @@ source $SCRIPTS_ROOT/function.sh
cd $SCRIPTS_ROOT
-echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
service_port_name=(
openImChatApiPort
diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh
index b3b71d220..c66bd8460 100755
--- a/scripts/msg_gateway_start.sh
+++ b/scripts/msg_gateway_start.sh
@@ -24,9 +24,9 @@ source $SCRIPTS_ROOT/function.sh
cd $SCRIPTS_ROOT
-echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh
index 541c82910..e61492f34 100755
--- a/scripts/msg_transfer_start.sh
+++ b/scripts/msg_transfer_start.sh
@@ -24,9 +24,9 @@ source $SCRIPTS_ROOT/function.sh
cd $SCRIPTS_ROOT
-echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
diff --git a/scripts/path_info.sh b/scripts/path_info.sh
index ab6f2b2df..5351a43db 100755
--- a/scripts/path_info.sh
+++ b/scripts/path_info.sh
@@ -28,16 +28,16 @@ declare -A supported_architectures=(
# Check if the architecture and version are supported
if [[ -z ${supported_architectures["$version-$architecture"]} ]]; then
- echo "================> Unsupported architecture: $architecture or version: $version"
+ echo -e "${BLUE_PREFIX}================> Unsupported architecture: $architecture or version: $version${COLOR_SUFFIX}"
exit 1
fi
-echo "================> Architecture: $architecture"
+echo -e "${BLUE_PREFIX}================> Architecture: $architecture${COLOR_SUFFIX}"
# Set the BIN_DIR based on the architecture and version
BIN_DIR=${supported_architectures["$version-$architecture"]}
-echo "================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR"
+echo -e "${BLUE_PREFIX}================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR${COLOR_SUFFIX}"
# Don't put the space between "="
openim_msggateway="openim-msggateway"
diff --git a/scripts/push_start.sh b/scripts/push_start.sh
index ea353cd56..79d877c79 100755
--- a/scripts/push_start.sh
+++ b/scripts/push_start.sh
@@ -24,9 +24,9 @@ source $SCRIPTS_ROOT/function.sh
cd $SCRIPTS_ROOT
-echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
diff --git a/scripts/start_all.sh b/scripts/start_all.sh
index 976320dad..4e7db6e3e 100755
--- a/scripts/start_all.sh
+++ b/scripts/start_all.sh
@@ -27,9 +27,9 @@ source $SCRIPTS_ROOT/function.sh
cd $SCRIPTS_ROOT
-echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh
index bef9ca36e..79b5b9c31 100755
--- a/scripts/start_cron.sh
+++ b/scripts/start_cron.sh
@@ -24,9 +24,9 @@ source $SCRIPTS_ROOT/function.sh
cd $SCRIPTS_ROOT
-echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
-echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
+echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
From ae029ebdfa4a8a8e9f8271eea47b5e54cb869945 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Mon, 10 Jul 2023 18:11:11 +0800
Subject: [PATCH 52/73] feat: add scripts and fix
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
CHANGELOG/CHANGELOG-2.9.md | 12 ++++++++++++
CHANGELOG/CHANGELOG.md | 11 +++++++++++
2 files changed, 23 insertions(+)
diff --git a/CHANGELOG/CHANGELOG-2.9.md b/CHANGELOG/CHANGELOG-2.9.md
index 174286f0d..b51212ba8 100644
--- a/CHANGELOG/CHANGELOG-2.9.md
+++ b/CHANGELOG/CHANGELOG-2.9.md
@@ -2,6 +2,18 @@
+- [Version logging for OpenIM](#version-logging-for-openim)
+ - [Unreleased](#unreleased)
+ - [v2.9.0+1.839643f - 2023-07-07](#v2901839643f---2023-07-07)
+ - [v2.9.0+2.35f07fe - 2023-07-06](#v290235f07fe---2023-07-06)
+ - [v2.9.0+1.b5072b1 - 2023-07-05](#v2901b5072b1---2023-07-05)
+ - [v2.9.0+3.2667a3a - 2023-07-05](#v29032667a3a---2023-07-05)
+ - [v2.9.0+7.04818ca - 2023-07-05](#v290704818ca---2023-07-05)
+ - [v2.9.0 - 2023-07-04](#v290---2023-07-04)
+ - [Reverts](#reverts)
+ - [Pull Requests](#pull-requests)
+
+
diff --git a/CHANGELOG/CHANGELOG.md b/CHANGELOG/CHANGELOG.md
index 67f28d959..39ed572db 100644
--- a/CHANGELOG/CHANGELOG.md
+++ b/CHANGELOG/CHANGELOG.md
@@ -2,6 +2,7 @@
All notable changes to this project will be documented in this file.
++ [https://github.com/OpenIMSDK/Open-IM-Server/releases](https://github.com/OpenIMSDK/Open-IM-Server/releases)
## command
@@ -16,3 +17,13 @@ git-chglog --next-tag 2.0.0 -o CHANGELOG.md
git commit -am "release 2.0.0"
git tag 2.0.0
```
+
+## Release version logs
+
++ [OpenIM CHANGELOG-V1.0](CHANGELOG-1.0.md)
++ [OpenIM CHANGELOG-V2.0](CHANGELOG-2.0.md)
++ [OpenIM CHANGELOG-V2.1](CHANGELOG-2.1.md)
++ [OpenIM CHANGELOG-V2.2](CHANGELOG-2.2.md)
++ [OpenIM CHANGELOG-V2.3](CHANGELOG-2.3.md)
++ [OpenIM CHANGELOG-V2.9](CHANGELOG-2.9.md)
++ [OpenIM CHANGELOG-V3.0](CHANGELOG-3.0.md)
\ No newline at end of file
From 42aa349846c418f5f410552ba3526f9852563a95 Mon Sep 17 00:00:00 2001
From: Xinwei Xiong <86140903+cubxxw@users.noreply.github.com>
Date: Tue, 11 Jul 2023 16:18:12 +0800
Subject: [PATCH 53/73] feat: add the changelog (#490)
---
docker-compose.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docker-compose.yaml b/docker-compose.yaml
index db3ba4bcc..4b87306f5 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -100,8 +100,8 @@ services:
openim_server:
- image: openim/openim_server:v3.0.1
- container_name: openim_server
+ image: openim/open_im_server:v3.0.1
+ container_name: open_im_server
volumes:
- ./logs:/Open-IM-Server/logs
- ./config/config.yaml:/Open-IM-Server/config/config.yaml
From b5d1adb465c4109ee6760bad3acf3a3d5c39ef5b Mon Sep 17 00:00:00 2001
From: Xinwei Xiong <86140903+cubxxw@users.noreply.github.com>
Date: Tue, 11 Jul 2023 16:37:51 +0800
Subject: [PATCH 54/73] fix: docker file path (#492)
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Dockerfile b/Dockerfile
index 01923032c..76b2a4c14 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -32,7 +32,7 @@ VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/scripts
#Copy scripts files and binary files to the blank image
COPY --from=build /Open-IM-Server/scripts /Open-IM-Server/scripts
-COPY --from=build /Open-IM-Server/bin /Open-IM-Server/bin
+COPY --from=build /Open-IM-Server/bin /Open-IM-Server/_output/bin/platforms/linux/amd64/
WORKDIR /Open-IM-Server/scripts
From 0350636960c37ad0f3e945cd8661fe82af7f56c8 Mon Sep 17 00:00:00 2001
From: Xinwei Xiong <86140903+cubxxw@users.noreply.github.com>
Date: Tue, 11 Jul 2023 21:13:06 +0800
Subject: [PATCH 55/73] fix: docker file path (#495)
* fix: docker file path
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* fix: docker file path
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* fix: fix scripts
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---------
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
docker-compose.yaml | 4 ++--
pkg/common/cmd/root.go | 1 +
scripts/check_all.sh | 3 ++-
scripts/docker_start_all.sh | 4 ++++
scripts/msg_gateway_start.sh | 2 +-
scripts/msg_transfer_start.sh | 4 ++--
scripts/path_info.sh | 6 +++++-
scripts/start_all.sh | 4 +++-
scripts/start_rpc_service.sh | 7 +++++--
scripts/stop_all.sh | 3 ++-
10 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 4b87306f5..c78e4a63b 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -100,8 +100,8 @@ services:
openim_server:
- image: openim/open_im_server:v3.0.1
- container_name: open_im_server
+ image: ghcr.io/openimsdk/openim-server:v3.0.0
+ container_name: openim-server
volumes:
- ./logs:/Open-IM-Server/logs
- ./config/config.yaml:/Open-IM-Server/config/config.yaml
diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go
index 4a5744033..b15d984a0 100644
--- a/pkg/common/cmd/root.go
+++ b/pkg/common/cmd/root.go
@@ -84,6 +84,7 @@ func (r *RootCmd) GetPrometheusPortFlag() int {
func (r *RootCmd) getConfFromCmdAndInit(cmdLines *cobra.Command) error {
configFolderPath, _ := cmdLines.Flags().GetString(constant.FlagConf)
+ fmt.Println("configFolderPath:", configFolderPath)
return config.InitConfig(configFolderPath)
}
diff --git a/scripts/check_all.sh b/scripts/check_all.sh
index c4f5dd490..84dabb1eb 100755
--- a/scripts/check_all.sh
+++ b/scripts/check_all.sh
@@ -57,10 +57,11 @@ for i in ${service_port_name[*]}; do
done
#Check launched service process
-check=$(ps aux | grep -w ./${openim-msgtransfer} | grep -v grep | wc -l)
+check=$(ps aux | grep -w ./${openim_msgtransfer} | grep -v grep | wc -l)
if [ $check -eq ${msg_transfer_service_num} ]; then
echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImMsgTransfer"${COLOR_SUFFIX}
else
+ echo $check ${msg_transfer_service_num}
echo -e ${RED_PREFIX}"openImMsgTransfer service does not start normally, num err"${COLOR_SUFFIX}
echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX}
exit -1
diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh
index 98e5a131c..421900ef4 100755
--- a/scripts/docker_start_all.sh
+++ b/scripts/docker_start_all.sh
@@ -16,6 +16,10 @@
#fixme This scripts is the total startup scripts
#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
+#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+
#fixme Put the shell scripts name here
need_to_start_server_shell=(
start_rpc_service.sh
diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh
index c66bd8460..f99ce9017 100755
--- a/scripts/msg_gateway_start.sh
+++ b/scripts/msg_gateway_start.sh
@@ -61,7 +61,7 @@ sleep 1
cd ${msg_gateway_binary_root}
for ((i = 0; i < ${#ws_ports[@]}; i++)); do
echo "==========================start msg_gateway server===========================">>$OPENIM_ROOT/logs/openIM.log
- nohup ./${openim_msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
+ nohup ./${openim_msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} --config_folder_path ${configfile_path} >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
done
#Check launched service process
diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh
index e61492f34..e2034388b 100755
--- a/scripts/msg_transfer_start.sh
+++ b/scripts/msg_transfer_start.sh
@@ -52,9 +52,9 @@ sleep 1
cd ${msg_transfer_binary_root}
for ((i = 0; i < ${msg_transfer_service_num}; i++)); do
prome_port=${prome_ports[$i]}
- cmd="nohup ./${openim_msgtransfer}"
+ cmd="nohup ./${openim_msgtransfer} --config_folder_path ${configfile_path}"
if [ $prome_port != "" ]; then
- cmd="$cmd --prometheus_port $prome_port"
+ cmd="$cmd --prometheus_port $prome_port --config_folder_path ${configfile_path}"
fi
echo "==========================start msg_transfer server===========================">>$OPENIM_ROOT/logs/openIM.log
$cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
diff --git a/scripts/path_info.sh b/scripts/path_info.sh
index 5351a43db..595137566 100755
--- a/scripts/path_info.sh
+++ b/scripts/path_info.sh
@@ -65,8 +65,12 @@ cmd_utils_name="openim-cmdutils"
cmd_utils_binary_root="$OPENIM_ROOT/$BIN_DIR"
cmd_utils_source_root="$OPENIM_ROOT/cmd/openim-cmdutils/"
+echo "debug========> config_path=$config_path"
# Global configuration file default dir
config_path="$OPENIM_ROOT/config/config.yaml"
+configfile_path="$OPENIM_ROOT/config"
+
+echo "BUG: debug========> config_path=$config_path"
# servicefile dir path
service_source_root=(
@@ -104,4 +108,4 @@ service_names=(
"${msg_name}"
"${push_name}"
# "${sdk_server_name}"
-)
\ No newline at end of file
+)
diff --git a/scripts/start_all.sh b/scripts/start_all.sh
index 4e7db6e3e..3554b7d14 100755
--- a/scripts/start_all.sh
+++ b/scripts/start_all.sh
@@ -50,6 +50,8 @@ echo -e "${BOLD_PREFIX}${CYAN_PREFIX}Server Start Time: ${time}${COLOR_SUFFIX}"
# Print section separator
echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
+cd $SCRIPTS_ROOT
+
# FIXME Put the shell script names here
need_to_start_server_shell=(
start_rpc_service.sh
@@ -82,4 +84,4 @@ done
echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
# Print completion message
-echo -e "${GREEN_PREFIX}${BOLD_PREFIX}OpenIM Server has been started successfully!${COLOR_SUFFIX}"
\ No newline at end of file
+echo -e "${GREEN_PREFIX}${BOLD_PREFIX}OpenIM Server has been started successfully!${COLOR_SUFFIX}"
diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh
index 132afdfe5..cafbb254e 100755
--- a/scripts/start_rpc_service.sh
+++ b/scripts/start_rpc_service.sh
@@ -95,21 +95,24 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
portList2=$(cat $config_path | grep ${service_prometheus_port_name[$i]} | awk -F '[:]' '{print $NF}')
list_to_string $portList2
+ echo -e "debug========>cmd=$cmd AAAAA"
prome_ports=($ports_array)
#Start related rpc services based on the number of ports
for ((j = 0; j < ${#service_ports[*]}; j++)); do
#Start the service in the background
if [ -z "${prome_ports[$j]}" ]; then
- cmd="./${service_filename[$i]} --port ${service_ports[$j]}"
+ cmd="./${service_filename[$i]} --port ${service_ports[$j]} --config_folder_path ${configfile_path}"
else
- cmd="./${service_filename[$i]} --port ${service_ports[$j]} --prometheus_port ${prome_ports[$j]}"
+ cmd="./${service_filename[$i]} --port ${service_ports[$j]} --prometheus_port ${prome_ports[$j]} --config_folder_path ${configfile_path}"
fi
if [ $i -eq 0 -o $i -eq 1 ]; then
cmd="./${service_filename[$i]} --port ${service_ports[$j]}"
fi
echo $cmd
+ echo -e "debug========>cmd=$cmd"
echo "=====================start ${service_filename[$i]}======================">>$OPENIM_ROOT/logs/openIM.log
nohup $cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
+ echo -e "debug========>OpenIMROOT=$OPENIM_ROOT"
sleep 1
pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1"
echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:${service_ports[$j]} pid:$(eval $pid)$COLOR_SUFFIX"
diff --git a/scripts/stop_all.sh b/scripts/stop_all.sh
index 4e3537ea7..f413d2a66 100755
--- a/scripts/stop_all.sh
+++ b/scripts/stop_all.sh
@@ -14,6 +14,7 @@
# limitations under the License.
#Include shell font styles and some basic information
+SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
@@ -25,7 +26,7 @@ bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
-cd "$OPENIM_ROOT/scripts/"
+cd "$SCRIPTS_ROOT"
for i in ${service_names[*]}; do
#Check whether the service exists
From f13ffc6e6c848c625ed55e9d0c506bad403b9859 Mon Sep 17 00:00:00 2001
From: kubbot <3293172751ysy@gmail.com>
Date: Tue, 11 Jul 2023 22:10:43 +0800
Subject: [PATCH 56/73] fix: all file
Signed-off-by: kubbot <3293172751ysy@gmail.com>
---
Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Dockerfile b/Dockerfile
index 76b2a4c14..5df672921 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -32,7 +32,7 @@ VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/scripts
#Copy scripts files and binary files to the blank image
COPY --from=build /Open-IM-Server/scripts /Open-IM-Server/scripts
-COPY --from=build /Open-IM-Server/bin /Open-IM-Server/_output/bin/platforms/linux/amd64/
+COPY --from=build /Open-IM-Server/_output/bin/platforms/linux/amd64 /Open-IM-Server/_output/bin/platforms/linux/amd64
WORKDIR /Open-IM-Server/scripts
From 154658ee12cf789b98cb71fd572a72d47857de37 Mon Sep 17 00:00:00 2001
From: kubbot <3293172751ysy@gmail.com>
Date: Tue, 11 Jul 2023 22:14:44 +0800
Subject: [PATCH 57/73] feat: add make file
Signed-off-by: kubbot <3293172751ysy@gmail.com>
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 5fcc3b8c3..d1c733717 100644
--- a/Makefile
+++ b/Makefile
@@ -87,7 +87,7 @@ fmt:
vet:
@$(GO) vet ./...
-lint: Check syntax and styling of go sources. ✨
+## lint: Check syntax and styling of go sources. ✨
.PHONY: lint
lint:
@$(MAKE) go.lint
@@ -184,4 +184,4 @@ help: Makefile
## help-all: Show all help details info. ✨
.PHONY: help-all
help-all: go.help copyright.help tools.help image.help dependencies.help gen.help release.help swagger.help help
- $(call makeallhelp)
\ No newline at end of file
+ $(call makeallhelp)
From 531c8a9876af3cee82111f8546735ec6cbae81e5 Mon Sep 17 00:00:00 2001
From: pluto <83957921+plutoyty@users.noreply.github.com>
Date: Wed, 12 Jul 2023 10:06:30 +0800
Subject: [PATCH 58/73] Add database retry (#493)
---
pkg/common/db/relation/mysql_init.go | 33 ++++++++++++++++++++++------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go
index 67419c7bf..fe467b675 100644
--- a/pkg/common/db/relation/mysql_init.go
+++ b/pkg/common/db/relation/mysql_init.go
@@ -30,16 +30,18 @@ import (
"gorm.io/gorm/logger"
)
+const (
+ maxRetry = 100
+)
+
+//newMysqlGormDB Initialize the database connection
func newMysqlGormDB() (*gorm.DB, error) {
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address[0], "mysql")
- db, err := gorm.Open(mysql.Open(dsn), nil)
+
+ db, err := connectToDatabase(dsn, maxRetry)
if err != nil {
- time.Sleep(time.Duration(30) * time.Second)
- db, err = gorm.Open(mysql.Open(dsn), nil)
- if err != nil {
- panic(err.Error() + " open failed " + dsn)
- }
+ panic(err.Error() + " Open failed " + dsn)
}
sqlDB, err := db.DB()
if err != nil {
@@ -82,7 +84,24 @@ func newMysqlGormDB() (*gorm.DB, error) {
return db, nil
}
-// gorm mysql
+//connectToDatabase Connection retry for mysql
+func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
+ var db *gorm.DB
+ var err error
+ for i := 0; i <= maxRetry; i++ {
+ db, err = gorm.Open(mysql.Open(dsn), nil)
+ if err == nil {
+ return db, nil
+ }
+ if mysqlErr, ok := err.(*mysqlDriver.MySQLError); ok && mysqlErr.Number == 1045 {
+ return nil, err
+ }
+ time.Sleep(time.Duration(1) * time.Second)
+ }
+ return nil, err
+}
+
+// NewGormDB gorm mysql
func NewGormDB() (*gorm.DB, error) {
specialerror.AddReplace(gorm.ErrRecordNotFound, errs.ErrRecordNotFound)
specialerror.AddErrHandler(replaceDuplicateKey)
From dd7e2be74a07d836ef6c8c5e3b192b873db2777b Mon Sep 17 00:00:00 2001
From: Xinwei Xiong <86140903+cubxxw@users.noreply.github.com>
Date: Wed, 12 Jul 2023 12:28:18 +0800
Subject: [PATCH 59/73] feat: add logic to deploy images (#497)
* feat: add logic to deploy images
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* feat: add logic to deploy images
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* fix: add ubuntu
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* fix: sync quest
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* feat: add copyright information
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* feat: add more cicd design
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* fix: fix sync
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* feat: test file
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* feat: test file
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* feat: build multiarch
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* feat: build multiarch
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* feat: add start scripts
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---------
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.github/workflows/golangci-link.yml | 4 +-
.github/workflows/openim-ci.yml | 148 ++++++++++++++----
.github/workflows/scripts-test.yml | 50 ++++++
.github/workflows/sync.yml | 4 -
README.md | 14 +-
assets/README.md | 32 ++++
assets/intive-slack.png | Bin 0 -> 21044 bytes
assets/logo-gif/LICENSE | 1 +
assets/logo-gif/openim-logo.gif | Bin 0 -> 430462 bytes
assets/logo/LICENSE | 1 +
assets/logo/openim-logo-blue.png | Bin 0 -> 32557 bytes
assets/logo/openim-logo-cyan.png | Bin 0 -> 35907 bytes
assets/logo/openim-logo-gradient.png | Bin 0 -> 38678 bytes
assets/logo/openim-logo-green.png | Bin 0 -> 32597 bytes
assets/logo/openim-logo-orange.png | Bin 0 -> 37334 bytes
assets/logo/openim-logo-purple.png | Bin 0 -> 32931 bytes
assets/logo/openim-logo-red.png | Bin 0 -> 31948 bytes
assets/logo/openim-logo-yellow.png | Bin 0 -> 36659 bytes
assets/logo/openim-logo.png | Bin 0 -> 38208 bytes
go.mod | 1 -
go.sum | 2 -
install_im_server.sh | 36 +++--
.../msgtransfer/persistent_msg_handler.go | 14 ++
pkg/common/db/relation/mysql_init.go | 4 +-
pkg/common/kafka/consumer_group.go | 14 ++
pkg/utils/strings.go | 14 ++
pkg/utils/time_format.go | 14 ++
scripts/build_all_service.sh | 8 +-
scripts/path_info.sh | 14 ++
scripts/style_info.sh | 14 ++
30 files changed, 323 insertions(+), 66 deletions(-)
create mode 100644 .github/workflows/scripts-test.yml
create mode 100644 assets/README.md
create mode 100644 assets/intive-slack.png
create mode 100644 assets/logo-gif/LICENSE
create mode 100644 assets/logo-gif/openim-logo.gif
create mode 100644 assets/logo/LICENSE
create mode 100644 assets/logo/openim-logo-blue.png
create mode 100644 assets/logo/openim-logo-cyan.png
create mode 100644 assets/logo/openim-logo-gradient.png
create mode 100644 assets/logo/openim-logo-green.png
create mode 100644 assets/logo/openim-logo-orange.png
create mode 100644 assets/logo/openim-logo-purple.png
create mode 100644 assets/logo/openim-logo-red.png
create mode 100644 assets/logo/openim-logo-yellow.png
create mode 100644 assets/logo/openim-logo.png
diff --git a/.github/workflows/golangci-link.yml b/.github/workflows/golangci-link.yml
index 057dcff74..c5fdd7b1b 100644
--- a/.github/workflows/golangci-link.yml
+++ b/.github/workflows/golangci-link.yml
@@ -17,8 +17,8 @@ name: OpenKF golangci-lint
on:
push:
branches: [main]
- pull_request:
- branches: [main]
+# pull_request:
+# branches: [main]
jobs:
golangci:
name: lint
diff --git a/.github/workflows/openim-ci.yml b/.github/workflows/openim-ci.yml
index c8b95eb8e..5794b2ef3 100644
--- a/.github/workflows/openim-ci.yml
+++ b/.github/workflows/openim-ci.yml
@@ -1,26 +1,52 @@
+# Copyright © 2023 OpenIM open source community. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
name: OpenIM CI
-on:
-# main branch
+on:
push:
branches:
- - main
+ - main
+ paths-ignore:
+ - "docs/**"
+ - "README.md"
+ - "README_zh-CN.md"
+ - "CONTRIBUTING.md"
pull_request:
branches:
- - main
+ - main
+ paths-ignore:
+ - "README.md"
+ - "README_zh-CN.md"
+ - "CONTRIBUTING.md"
+ - "docs/**"
-jobs:
+env:
+ GO_VERSION: "1.19"
+ GOLANGCI_VERSION: "v1.50.1"
- openimci:
+jobs:
+ openim:
name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
environment:
- name: openimci
+ name: openim
strategy:
matrix:
- go_version: ['1.18', '1.19', '1.20']
- os: [ubuntu-latest, macOS-latest]
+ go_version: ["1.18","1.19","1.20"]
+ os: [ubuntu-latest]
steps:
- name: Set up Go ${{ matrix.go_version }}
@@ -32,41 +58,95 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- - name: Run go modules Tidy
+ - name: Run go modules tidy
run: |
make tidy
- - name: Generate all necessary files, such as error code files
+ - name: Run go format
run: |
- make gen
+ make format
+ echo "Run go format successfully"
- - name: Check syntax and styling of go sources
- run: |
- make lint
+ # - name: Generate all necessary files, such as error code files
+ # run: |
+ # make generate
- - name: Run unit test and get test coverage
- run: |
- make cover
+ # - name: Check syntax and styling of go sources
+ # run: |
+ # set -e
+ # make lint
+
+ # - name: Run unit test and get test coverage
+ # run: |
+ # make cover
- name: Build source code for host platform
run: |
- make build
+ make multiarch
+ echo "Build source code for host platform successfully"
- - name: Collect Test Coverage File
- uses: actions/upload-artifact@v1.0.0
- with:
- name: main-output
- path: _output/coverage.out
+ # - name: Collect Test Coverage File
+ # uses: actions/upload-artifact@v1.0.0
+ # with:
+ # name: main-output
+ # path: _output/tmp/coverage.out
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v1
+ # - name: Set up Docker Buildx
+ # uses: docker/setup-buildx-action@v1
- - name: Login to DockerHub
- uses: docker/login-action@v1
- with:
- username: ${{ env.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
+# lint:
+# runs-on: ubuntu-20.04
+# steps:
+# - name: Checkout
+# uses: actions/checkout@v3
+# with:
+# fetch-depth: 0
+
+# - name: Set up Go
+# uses: actions/setup-go@v3
+# with:
+# go-version: ${{ env.GO_VERSION }}
+
+# - name: golangci-lint
+# uses: golangci/golangci-lint-action@v3
+# with:
+# version: ${{ env.GOLANGCI_VERSION }}
- - name: Build docker images for host arch and push images to registry
- run: |
- make push
\ No newline at end of file
+# docker-image-tests:
+# runs-on: ubuntu-20.04
+# steps:
+# - name: Checkout
+# uses: actions/checkout@v3
+# with:
+# fetch-depth: 0
+
+# - name: Set up Go
+# uses: actions/setup-go@v3
+# with:
+# go-version: ${{ env.GO_VERSION }}
+
+# - name: Run tests
+# run: make build
+
+# - name: Test docker image
+# run: |
+# docker build -t openim:ci-build .
+
+# goreleaser-test:
+# runs-on: ubuntu-20.04
+# steps:
+# - name: Checkout
+# uses: actions/checkout@v3
+# with:
+# fetch-depth: 0
+
+# - name: Set up Go
+# uses: actions/setup-go@v3
+# with:
+# go-version: ${{ env.GO_VERSION }}
+
+# - name: Run GoReleaser
+# uses: goreleaser/goreleaser-action@v4
+# with:
+# version: latest
+# args: release --clean --skip-publish --snapshot
\ No newline at end of file
diff --git a/.github/workflows/scripts-test.yml b/.github/workflows/scripts-test.yml
new file mode 100644
index 000000000..5bcb2277c
--- /dev/null
+++ b/.github/workflows/scripts-test.yml
@@ -0,0 +1,50 @@
+name: Execute Scripts
+
+on:
+ push:
+ branches:
+ - main
+ paths-ignore:
+ - "docs/**"
+ - "README.md"
+ - "README_zh-CN.md"
+ - "CONTRIBUTING.md"
+ pull_request:
+ branches:
+ - main
+ paths-ignore:
+ - "README.md"
+ - "README_zh-CN.md"
+ - "CONTRIBUTING.md"
+ - "docs/**"
+
+jobs:
+ execute-scripts:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Start Docker Compose
+ run: docker-compose up -d
+
+ - name: Stop all services
+ run: |
+ chmod +x ./scripts/stop_all.sh
+ ./scripts/stop_all.sh
+
+ - name: Build all services
+ run: |
+ chmod +x ./scripts/build_all_service.sh
+ ./scripts/build_all_service.sh
+
+ - name: Start all services
+ run: |
+ chmod +x ./scripts/start_all.sh
+ ./scripts/start_all.sh
+
+ - name: Check all services
+ run: |
+ chmod +x ./scripts/check_all.sh
+ ./scripts/check_all.sh
diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml
index 871e400d5..d6e15bf23 100644
--- a/.github/workflows/sync.yml
+++ b/.github/workflows/sync.yml
@@ -8,9 +8,6 @@ on:
push:
branches:
- main
- pull_request:
- branches:
- - main
workflow_dispatch:
jobs:
@@ -25,7 +22,6 @@ jobs:
with:
GH_INSTALLATION_TOKEN: "${{ secrets.BOT_GITHUB_TOKEN }}"
CONFIG_PATH: .github/sync.yml
- GH_PAT: "${{ secrets.BOT_GITHUB_TOKEN }}"
ORIGINAL_MESSAGE: true
SKIP_PR: true
COMMIT_EACH_FILE: false
diff --git a/README.md b/README.md
index e8da2ab5e..b180f4438 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,11 @@
-
-
- Open IM Server
-
- ⭐️ Open source Instant Messaging Server ⭐️
-
+
+
+
+
+
+
+ ⭐️ Open source Instant Messaging Server ⭐️
+
diff --git a/assets/README.md b/assets/README.md
new file mode 100644
index 000000000..d3e735dc0
--- /dev/null
+++ b/assets/README.md
@@ -0,0 +1,32 @@
+# `/assets`
+
+The `/assets` directory in the OpenIM repository contains various assets such as images, logos, and animated GIFs. These assets serve different purposes and contribute to the functionality and aesthetics of the OpenIM project.
+
+## Directory Structure:
+
+```bash
+assets/
+├── README.md # Documentation for the assets directory
+├── images # Directory holding images related to OpenIM
+│ ├── architecture.png # Image depicting the architecture of OpenIM
+│ └── mvc.png # Image illustrating the Model-View-Controller (MVC) pattern
+├── intive-slack.png # Image displaying the Intive Slack logo
+├── logo # Directory containing various logo variations for OpenIM
+│ ├── openim-logo-black.png # OpenIM logo with a black background
+│ ├── openim-logo-blue.png # OpenIM logo with a blue background
+│ ├── openim-logo-green.png # OpenIM logo with a green background
+│ ├── openim-logo-purple.png # OpenIM logo with a purple background
+│ ├── openim-logo-white.png # OpenIM logo with a white background
+│ ├── openim-logo-yellow.png # OpenIM logo with a yellow background
+│ └── openim-logo.png # OpenIM logo with a transparent background
+└── logo-gif # Directory containing animated GIF versions of the OpenIM logo
+ └── openim-log.gif # Animated OpenIM logo with a transparent background
+```
+
+## Copyright Notice:
+
+The OpenIM logo, including its variations and animated versions, displayed in this repository [OpenIM](https://github.com/OpenIMSDK/openim) under the `/assets/logo` and `/assets/logo-gif` directories, are protected by copyright laws.
+
+The logo design is credited to @Xx(席欣).
+
+Please respect the intellectual property rights and refrain from unauthorized use and distribution of these assets.
\ No newline at end of file
diff --git a/assets/intive-slack.png b/assets/intive-slack.png
new file mode 100644
index 0000000000000000000000000000000000000000..3f27e0c6959298ec79a093ac36a00a58755767e9
GIT binary patch
literal 21044
zcmagFbx>Ph)HWI@?q1woiWhf^7k4chthjq|hu~76cyYJlP}~ZXQXGmy2<{}@{NDH8
zzwXTUP3BA{C+Fnsz1P}nJ?nW^;xyG2u`$Ro0002CvXZS901_0+t(jj
z;_xp}tW*`{0k8kPzV%k7!_T0*DH(afufYHBK$v8{mI45@a+Kv|bp2M(3Vg#Tmq4#I
zqSI<~V2CpgE2?xD9wHqcY5u1HgvQWyGD^1rglFHsC_z$dzT0jOL3dO@&jaD2H>6l7
zsA_zpVM_Gq%1W%NHI0)T4sFKD`HRyxHCr?iV#a4)=RU46=q5BUeAmrBg9c#tows+d
zD;++XUpjHGK3oKY!m1w0=ubaYd6+(1?fz(-}eld2r5s&Y$uw!qms
zLqC_1uEPv&;WgMCwcktCtwrxr$SW?5%dAU~Hza&;IOemDkNmFh`MT%U8*1~KOD;S>
zVM77IUgAgJtwpcpjk_67o0jMEk#sUDvxTs?g>&~{`{5stmLQe3m;Dv&j+fF7)fwic
zje-*hWUcq`m&L1Hs~U8@61aJ_bd)jCH#^1iL7{l7WjB-&?6}_iP?mcN+d0ipk=dpX
zd!`P#xkY{pemO5n$CH_x;fYc<*!?q-4y@~cBE9X@Sz;tGH1v1fq;b$Lhi;o~w(PnaRzYWaU!jZ9D~t5yywYmV
zwUq9Dm#Rq}q1*;7{Ax14mO8!nZ-w?&;{{wGMq@Y$UcI}4zT?fNMkXT1zjKWph{6^m
zITX#EwuV!v{XHFA4(xJz6w9<#xu2!$>x93!Z?z;-{n?%*W<`jr`M-k
zG3ZFWu5|fA$6-XUa;h&y{?d02!I%3>MUUaC`Pt@ogY_TtBTPG4s`UCox)8Y6%gLb6
zxII3zCG(*w`FvgfdJsE-gAUaCj?1&t{Yk-D^{3S(x=RLc{uN7T?-OTh^z9I49&*VW
zQ73RSI4Ybgo-If(DA-4*zEB?vWlZ)!xone4J|#5
zA9oBoE)O;%{)Z$#B~GU;nK}fLc|fsVX7II=sH#8tamwD%Z_dWy+2Xv2sTHvLb!F>C
z;n=~mef@EG@Xs)0%q9nYXujOlBsj8~4_d)J4I4B0J=6s(7-`g=d2Z%117ypX_$dGK9A7U!%B*tBDCejDz=pM0$6
zk_(binxw8inV57|jPBD;cUB4CQ|3!tpA_DXT29DI=Ma_&)vZeI#^5-?vmRL
zESv&w1s{N{63|xv`%S7M-wFdK3Yy2S=M36x&qi98kJpsgE`rU0W8|&
zr{l#ZvYK7<7i~nJf7;DawrKn}74fkh!{Y8?RrAot4F3D|*KO9|9~2!u!H+Q=(6!LS
zLg!JQ#K7P2@$+J>y?3J=o(D-6`V45W!rO7nq$i$r*b8QU-vhDbIe2z9@b!K}Beam%
znsn4aVb0bSwrgD@33JGoL-wD0qGr=@SrvXba&@YFFRyAHT{4{WWc0bAul@KH>Ip~y
zk}~JFGc~yO+~&`QFn$mGV-dp?5Fi?IMN_O)7T{sFk*EyHK>_&OwA{U3HvM^Pj`azO
zHH^jLUK_l`BFUdjgLP1NyKH$2-Dd;f$$l@^oY{MN%GDW~AHNL#^WEI(_OOqU0KI>C
zj%V5}FXYN%7q$X`7|~E=9i3A6?U&PWk*5)t+j*ElrzeaZ)c!8cIhtJkXn+sPPI#ie
zz86<~&km{o+{kr-eEMy_U~ufjg;DJH?~b=+qO`(24dopzCTWa_vhuV%NsebvkKCt{
ze&wqCU;FTVE%F@T(d|KZ%i-y*>sQzah1n{2Jh41G_?MU4;_RtQ-$)3MBPcW5{k6AK
zBk}L`fLsOQV6wuUa{tlaX5x2>7kh?R%a*E{n$mwfMTW20BtTnE2JC-F-KB+
z=Hy>B=sPX)#~Mx?2*#T{5BxKxIApVnejM(=m6t)iK);lJa#B%bBZV@@qXwY#KmB|k
z@ep6cTWie_)s2S_@HYDn^1_m|IZ|(&v&s?wwEao7{v+ud8Y&V6Yv!crpe&`aZ3?@O
zI3ulu9x7zf6Znqn+@CocF6J%S_-AlAZ2uX>SN~C~t|^jagNK<@k$THP9<|4nYtPR^
zqz^}pve$F%Pps*u-=c>F(;b~E1?6{{WU;0qSO9>w<{_9D)^KOp-Q<*6^7g&N>8{Dp
zub#)=i^iqOTyhdiE^YoQ5&+JbB+uXF6r|ky=oS}fUPFTK+>dQrX?Bu~S@AK_;dlni8LqGx`$p^h2
z2v(#i_f?!c2*t7#Q0;7u!*-O+N7KE^!icTKCx$)xMQe^Xe>`9ag}Mj#0te4aManIn
znhRWHQwg-4SeA#o>NHxP3p=ir>{`1XCni=%%|GbxN5om8<#vf3$>s_W-
zZl`SqO;k2EO0@C6(;U%{wnStI`IF1<`gkH7f~O}K7Wl{4KlfqkyEht
zKRe|6EIb=b96+;0p;ZY6J!AtCr%A))OnA|0x<02;(OY5)1x0Ef
z|F|jN+^|qDGizK0?ql(T$j%Bg_mNY?g&%cjIz))rCz)!pKUAvW3^=Dy{*ivQKLzbC
zaBu1cObLw|zPGxmcA5-@IpxY3VD0k5vz?Y?CXwx?gp}FE#T)Bn{_9gAi>{V=J3)+l
zzw|$}tE**Iiwft2l0cawAzY^SwdbKbUAl{RJ2aM@B)tcvJNM?CBUS@EiLW>3Yn8JS
z);E&gG(WB)P<`5ZuU6|{p?c4gdc#uMQ&Yg;-BTS&|6XHr>avwh;o9HzW|M|Em;gCl9LYb;gVKIBl^jC?^B_Og%E^-b{s(#a
zoZcAjSh&O+aKkiW*FPkmYJJXiM6}jy!zRooKGQSCLU@*Bk38?^V%xFtK*7EX-vonsZGnbofrO}+S
zbE6cuqsGZ;T+h>)nFx-o^jGhY94zYyP47&H!27H^E)6L{>6OS*S8mt9
zGwcQh&x6K{s>K;8T5`YL+d(~!;9H|Nfp=h7kp)hBJ3c<`c{8b<^W^MTC)gLfXKLtf
zF|g?EL|JIdy|e4;Wy`BFrOUOWG!REs;?bri<$GoKd6U#lf2-lmt$&}h3Klcm6oE%y
z+}02TYthV5KS4R8$@1f)4vm8|#C@En3Z&MdHCv3`Kg5d+&d;S@CexC(9(=~wxj&>A
z^fKw%%~0>_%+Jr?XIE-}TwCIw!{8RzX!i5-L1H3^o5?3QuT^qcQ8O#>USvj)Hn}eT
zQYfjcAALGFb~tx^@qD-s_s~xN50$>VjM@#TQvJtHeVW|d>p^(o>Fs)^claF4s89fJur
z{O3fo&QfA^q!upcFfiuUocOOok{KFoievVoy4YVKi|Mnywv<~9{eXZjms!S!}S
zWe8*u65}!VLDifyKk(@x#OEszT`Nmf@;<8Bb*r#Okf8+r?5Wp#N$=Gg)0F`pc04!Cnr$mpk4Wev8-Vk7bj?R4u0!1$G`u@%`+iyt
z&1WB_#YbVXlf26bTu$-mwI6$^Kc3~m+9m!!my?6})gl#G^@i%Qb1o^Sejw$;wweha
z2W;rJ%wt))bMktBaNt;lf<&fl>wW>QI4ol#@y#2U8S5h1$79p(Ss0q)=8g2D)XIuO
z=;$mq#qRZNtH_lW_jF6>@#y^4@pee!dYgMX3q!XChP#x<^61QlNk^9e7Ig8<`4#4S
z6CBvGRzt(5_2US3%Z-}df99dE2zuTO@O+kndYX7nNuP%?PK`EEd(}6Bb)K~Uw@UrH
zovm+>c?Fyk{#um|kK60h;z4cI%_TOc
zz@#}KFIKuq{FWs?x||dy!1$h0iAkGmMhaefC!phd(G(YbklkCQkG33@yF72CHM2m?
z)chXuWJ9_Tk-dc8Z^`aqsRrAYz|>ZYTXC
z+0CDyr*MDuG80#JLVKVJTHLrd%nWIgYNlD>Fz5OeFM%um+wb}Qg>;1t68iaTNF2mK
zf{q$pk=6@;fnJW+FDi1oQZ||mjd_y6GFnZXgD^s>r^B`}RNAL5YMdu=OYJ9>{wT0&
z$8F=ca@!&~J?}@2ibM_nju9UJDWna3n;?DR3Nqe@_F%3EXv8?LU-X1E^FN#^TIeQE
zxf2sF!?Fx^Orq#QELsm7uf14@LmIIXKkKrWE0!2TTPFs9zNF0kxt(IQJ7_X0!ZtlZ
zy2I7Kyzi~~uy#deeGGjF3P!=_aL{7PdyrfCTo|%Yqne6tT(zUQ(W-o%&2{a#hyTEW
zXst)*cnj>?UNjDW`(*-nEk2LNH*%snT~t;VcD>7d1D{$ksd%&?*K#`#mNmK*K?Rv;
z_b_e*R(k&h&Z#h^JupW+#`pinp$I2f`g_bmj_ND~$+{Zmyxgv5-$Wo3J*;_bc*poc
zK4LLy$wuzSY2`DN1q6aq!04y_K5L-mtt$t&d%OO=3yFaK
zHIL5~c4a@hgN?r}WeZ!nA2d2=-BD1TfcZW*_&?mQBq_SQBtFkVs%q;=#ofN${@T&y
zLw-MWot&ma>8lEc+mzZ4In!t8)KI)S4{RFxec&y$
z<#7>L31?>nnwPSV&|+|=pdUP9OUa=8+?4PTDi){I3X#ZAVfVxWqyyj~xVDorlTtz&pOTTCi~i?nBELXjF_hRe#<9s%)}^%w*=%ePzdIu=
zLabTJEXEpywZs3ODW^PvMU6u^>J2zLL!r+dfsr!v2;(|YeqzP4-KRHB0}ydmPxE})
zagGu6?Rw;2uE1ocx}B?doNdU#u@W8HK@GJMv>tHs54O{@&`?5KnSD2PW9ACq@>u4<
zBlxi6m>iscaeRr#wC7u`tFUqXw$-o3|N1-&bz`n=Z0?&
zkfoX8xud>CO7`CX1n@2?7;jNh6P{3N&6jF7u07l;S?U2(-b{zUx=g(#N?+%Y2=f>YUT^5RH8%6C-)`f5nA0>|*Xl
z_z#N_BG4m9Tj9+aSucpp>G)BCSQz?6eFwL9hVM{2TnjUM5=%jtO{*ps7YvpzJhKqM
zC)Vk?2rTQjK87O0e{l)jdkQSULpU5`7tb=$O}PIbYwaKZOQd~-hru!?vr;Mko%|E=
zyF&-wL>Zht+uG`bzXpkydgh~EsdWZL2j3Y}pdb@Sm$l802>CdK2RElcA7D+jNMVo1
z9XIMwYZJUiQbXlE3);S{{1bYs|NOpNqs$PV-IK4dUZ!-%4=H0Sy3ZYcoVx7lwt%LR
zF|vyAt9yBZuk5CSYN8uzy#*L(W+u4t7JaPx
zZj9W!aWhum<|;vf`h6~;k$W&^c{4Qs$gx#8PqR{hYHUo8jlFVK;qBWq^qW9ORA0=m
zXrntYW$IYr_M%r4yTBlP|A|Gd-Ye_sCFVfn>KISz$nd
zg8H+jXNvRA-VVi?KXc6~EXpPbHCu-JmLlXUD(0h5gr#DADIf2J`MDTeEp;Oi8j1ghn)NEydk1Ao;xw-s75rqmoj@+5p{LHFnPWe
zxDF5Tt(SF-o*yYhS*xlizN86hdBgH0I_1>nJznp
zxh!~x0zDJbU&PuH<|k~k~I)(>M;6kZ!1H$$^FT5z$Vl-)oDj@
zNOlCx4&jsGR2!Qb$lWTV_g|vhOo>wcXO-cU$S7P@F`iAn+UB4~vf|Zy$9d()f2@?N
zmOob>xI~AE1Tzpt689@(PPh{ks%;lMKmWp;r6d6X_I|w^CgOjhWz(t^W-#?_BB@eV
zT#+cU4RR%ebLFkgD9SjXUq)MH0NQPGl0+R=WXCvNUT#xQOL-?vzH=mr!VhTZyp-;g
zuBs_gudmtkd(Kr0fqmaG+ZfSe0N4(J
zzQz_oBHc~F``venM=O1$zV{H?nbWlvp;RaSXflB2{TB{XoHQ_`T}qbqk5)i2NkLgG
z5khgtm~PUTG!mL3eUqO!QIZJNU~W$$@nFJ0B7^S)bK!3c&;Bf{q2OLli+$VhF|GY~
zuagbA3wP6JReweR3<<@;OJ61`T%SFuRQuil@INMuOv%l&0=6?XM9Cws;R>BdvN1bC
z*+?f;IzhpDf1mE7oSef?I%*NlWDuNM2#fBxl1vQy@5a$xM|nAA@}k9yQOk1c3%J53
zx@SO)uAF6k>8G^FIBb&SgyRZ_Q8DAfeKRfzmKbDLT)d{}RmJvL?k}4dJsyUjW|WM*
zn>9~3;?ik+xR*52j`koh^^a{gI_4E(9lP^J3p?GVSpMt-;a_x8`f;4N6jr7OKOBfS#y#aBU`
z`n1q1K7FKDpRIHZX~^YyT1EfQohN-J?U7u#m)XO&k&>3z*V&&kKjfzJ8;>_ZNe1FO
z_M+KhobvMj%=9+-%ZiYTd88UOZ6+G>%^@%x@a1ETGFo7FeUETNC!5sQMvUDUBeLeHLq}*8o#b1^I0UIZhFi
zO%AtBEnFf-H}N#-CKt(29*35K@@q}q>M3kpyQ=-ECGkb0o`bWKI_mH7Qgxs
zd}-(eC8h3NLnH|3?e1J;(X&5rRJ^gW7?Z^NYMbXvDrn^S8CfUQe%@Yy8uvr%r$YYV
zL`yom3~xpzQxdKs6nUr_Dxx9rE*b;w=82B$2ajAUS*?s;ZowR{p;|9EKPXaK5w*03
zF6~FWB*)T=451ZTs|8JSR%)6I_#)D-$b)5qSOr3ig4)zIU-1VL6M=Z^RG*ex#Hq}6Q+cW~el*qHK*V)cx8%9w>34%LU^E3NSIMn@X
zr_tLj_m0cg8zc@deD*+cj^4d9_}Wy85dz$q;lB&HV);N|=CU6*&A4_#caW9cE#vik
zRKQ!Vi7i<-24@nsGzP=>V!GZgj6~Vn@?;--YmDA`(iSh?{e**aC&{}?u!8dz!Nri-
ziKWPJPR+s27BF;A0GC69=cCuE=h|4nrV(84E+oREkQ{e|*3SA=H5f3_scOF~!ircP
zzS8(MDKWRKPFC+q%$^Q+XQy|u@{SuPCPtQpU)xUI|32o_xWh#}!Z
zMpRX;sbbisIiBo$c7AtVjzcWs8)g;R?`qY;9HznM@=iQN);;(78A2;c{+0l^Z|jJUmz``ql=l*=9Q%EZ@0ONSq<(xIaM*1B19xABX62~?~T
z1A?4aghOsf|A^_yRcYht%)q85f=wdzuHO2ccSA~EY5zrF8)t?gkW#(DS7r-JeWjY8
zUZc3_Dc|YX8%pe*@uUwsqD5k~X=BPKTNrN77l#C|+=DsJf%K)#LI3Y9!unKPMHs9I
z=y%4C(U%#;--#N^?3D?a%+O%T9&rTe>~lEF{jQyTnPZMYqeV8;CfEm)i(DCf%sP`FVE?UK?1EfwW@mF!W}XXEG%KhQ9`2(%;zxFi?THl8m!^Ag?971+u&c4@XE8Oaab|AH!#JR?
zor20KqcRf#CC3EE!Wc19^!5JZr+)cPL7edoVd~~xY1a6hbK-%g$cTI1vE{$KAq83WPgNqnT$6l#dvE6pF+Cl;
z|A+pclK8X7o8sT~VHc&%*MgXyOv=$}&ml#aPq#6Bm)6Od-)_t|T$_$;i#vw&O^Lvu
z8-0q`K%1%D4pH&}#TdQI2C3$)uIJ@`N>kWfWAyxbQ1$NjDw3qC;RSVxDX4LPeqWa8
zYTgD!(xe(*A_=YE?Sg%#*lp|zS1}fA_Qvhne3~~`Tv}RwH+4WCS)KyqkB#L+V7cC>d1bf#xcSc`A|yF3WF9qCTZZdCMp}&mSsv~#3YDL
z<$kUemx&)=C9~Zj)2fpPsoJP4G+{^358^msEu16ON!?;tXH8G!n>GZB@7*#K6IbgO
zkFd0a==b605hP6~%NUZN$N!$Z%~s$zj4J1O6(OUj3F4r!n-ule(Inc#QB9MZk3R^dO;Xyv0tEG
z_sQ(zSZn{(f*1e~dekJK;pfc
zyeQj}C9VRcsH&t)AvgcjZ&a4ia45X-il144kye^ksS4wRI+wT9cS>21fO-K@|J>w}
zNgQJo$72PB)U1_Z@SOOWQz)Db!~q*Hf1GtxkjAU}ViT&!J})OrI$u?bH)+$Q^I
z?Wv@;n3ORM4O@inJX{Rkah1N|=e!a>iTT$5{TR=k)Scfe>`fL8#ij}#-ghSLB@xNO
zxMTBR8USrrEvut2eT*(r*d3Rqd)@}!s!-skv3G>Ict=uL#%JRSizQ-zgmvWIie!;V
zCX9@(_|$omTNp|*D36XL+PnKt0i;0RfwAl8!MD2}u7$gxI5aebGJ+5J2GqI4BaNKe
z@6ohwb6$R6PeR&J{}nUB$NgeSlg;P+OS#l=d2yS3ljf{YV4
z8+8X8eImU$q)w2Sa&{O0EJRnu`>hkJ%yWf&v*P$@m0W{r{UPK8S&RZ7F*0fLYIGvs
z>NhfL9u*0IG$k^cx@V`QLUB?(%_dXnupo;tx|fisOgDz1GAkN5%0u6MqmQD1??8(v
zT_;o3C0!%TUz?=_hphAu^{j>+PDdtWm3fPq`w8xhWly&(j!U6
z8%FZYF4F!F4IGn^vPlhcuqUx8R=~lHLR5zM(
ze9A8z3PR25-SFJvK05{GRvjH#_Dg%SV?Vlc6hTy#;2Cgk}u@
zbNFz0@qIMhW{FA;y^Jv{zydV8LZr-UO}K0M>0?ZdAt5!4zeK)N(#;YOIQclD^Ee42
z!~DJ6uf(LL+#Xcas?ABOB&7(dK(|N;#Tq!Tk*v>=m-;+1l=>+2#R}|JnX#<5-tQys
z_t`L$6Z?pj%d36t{B88Hh6&0Cg!6M1_cD2nQgKvtt3{-=1B)w0nLq$qnpbi=_06zQ
z&pjr>e;~Z*{Xq(#Zwc{Y>AntvTgkG`jQq-!-0HfYjSrS?oY$^0&vHAqkj~y}`2372
z$e4YJGyZplZDXS;-U%1Tb8No;}Ndg>Ble`Vmt_%7ih4)NN
zJ~NH4{M3)gB{p9-=m_3y)XCDwrzX{TkNuMZ;?ko$2mg?dBf-VF$zNUX{~YnbmoT{I
zVw%*EZ(k;(H}u&v72S{yAX}Xs(9u^hTBh4CjU0VANaOdy_RP@H5YS<@(-rc!R>8RD
zt-{b!v(oC7{wTQ_=x{JGOXwpxZi9zZBfmcx2j#@9u*&R}{4ZvTU0+9~1iNf^A5^zi
z(jE;JKK1KHO14qq=Ev=ZgKjB5>r8>Y?QpDehH_VBM&-fH;Hu%Nr!^s*#ga=Y6j!O-
z)4w&ZxsI^XLRz8B{Q@&l4k*d1b`9m=72jrB2>Qn%;ch~<&(g~3hl3j91@FsJk`Gs7
z3Bd>efGm8wGL}PvjYr5Vl|SH(PNkWy31PJ%CHaO^PipX1sAV?NZP~rQu%Y5|H#)Wh2l(B7&iVstjv?_$qUduv|<)Vs#H!B2+%QggOjTrW
z(Dwrmj74S?pO6FB32C&!P#+7H`in4^R6N}iZeKLKHk9%J5DMUo0#zqCl6^0ZC@0kHYm;(P*^X$eWejmhc65k(5L@c6gD
z>u2{bb!!rjFgGs$&!>^bA7Yn=Bk+EQ3OBd>>~OqDMzLMWP0QR*)kT?3rKG533^%(Q
zOvpO2;bf@bMg?oQVq5>&l9C6;urBxXsjOveQt?4jfaQO|IS%Rl3Y9gGiGZknyMO-?
zO^j1j;Rv|DN;!(4LR3(&AySWv@&s`3R)I?errhDYgIiJz6)W2M{)X^Q4u%_v>sILO
zo2jh3^?Q!|g5IGJs|=PazQXO+>5M>1y>9XiJ2JQ
z0pywZf1Bp>XSESlH1`}{FcfnzH^U(wXnt<;l_*1PCZF&la5UQ2@ZFA7@*^^SSb97$
z>`y$8oPLI3k9co~73Gi^rvXuVNERKA{*kIOJeY^t)m}$3p%%H8N6XTE9G=Ir<+P01
z$Eb5oW2_m`@@1)|RoMeghQ4cB?TketTb&fpHK0b5XFpm}i4P~N(r@W#9QOE7y8!oi
zdg~&+@%w=DZ<>r5fNR;Gi>P~OIGLvM^aO~pwAwUYx{;+|my7!~(STEf2-CzzFLWB@
z0gYdC1Z>g{M9^BeJdm~V{oV)FKTct1BN&QV`9TiDDj+*Exv5psBT9o`lzgR^Z2kvi
zP+#DtB{mFiXkQx|WjqDV=3rt?W1-x~e^a2%SSX>i0W^oVyBhoWzRr#uv=AUj3lq$%
zOv%o(B8ExY!zivsv!@k1AB1p797L5$hGl@2{3r?iI0>R+P}28L^G>BSz3;m>2+O&E
zm|i7CnWC$Xs}KvvOoqb0ztN>JD@W+rE22m0K5XGXM+mFbc?dK+02M{7((Cioo;H(b
z;`YJ-==6FX!-1ul*TZOvI%dq3{@{E?+Ga5zwK&84cM@&6D_Sg^E_Qgps0~Vgo_*Ak
zPTV5+5grSWH$VZ0J!5GPH|h}ArtRQBW3n;e(k<`hz5$yt__P=MuIr@tc8V`MmHX1l~Kco>paP
zc?3k5m-elBwv13z_#H>ShGL73zWq`)Z*QnVrl*=vBFReTf3f)6p7
zFQ4zDU10MeoT)d>@bG~zpMl^N_r4wHNSqr2K?G0_rR
z#L$k;!uimhEkEw23rP;*OmVoe4l1(lbUyERw4lfXQW3mLHmD}XguDp`x^zmL8Ukx=1b=7#S3R`fjy%}<}G@gVZ@UAgzydRwY8}6gYxI(d&Mq%qk=dzJSKn&
zw$E+b`SH0ptvrSnqP*fUCI$C*c>tL-K?(YfH~Lm)6U{|INAfDA&iVKXgvWrh~hM
zbZ6*ZAKM~Yo$<|AQ!>~_OH8v^p!V!kuUk^6-pJRqxaP6RsipB$t3-yPedT$sMHzU3
z>TeYnc>Pr~m3#Y|lv01VgwvQ;Li-QxM6vtV4H-ZjT5KNPW~y6Tq6A*5dP|dD2EKP#
zog%8II~gVx0V4iz9!WyVvI+0qwxaC02rr5hAsj#AqHh=t^{O!f^1hg-yCo%>h3$MR
zoQP)cFU9)y_L!FnmyZ5V2L_gpVIL18I(Kvs$(=8in?N`~SgF-;w2kkMe3N~^gf_UF
z&N$PWGtU%N$floAEtF@lA)yGamA|Dgj^1sWBvU_yfKiP(cge|6J?@$45`E4u&CpXN
z{RwS@YrbuhW?7KtbC$+NX(_JGr}Q)K7?Ys_7^NA%iFd!HXGhe2cXNJ)%rII1p>+Pr
z<9|mZ8SW>GwK+dm4{CbLvs-sHZ6V{^k2XO-)Ic(GWK#m3_Y*1VK~JL;|Lg_3dAE4?
zAoR*M_I8+t59s>?0-Mt<@%`4#w6aAfPoRZ3@DpZMJi(73jYuCp3^--9PfJ!@x&CE>
zFfbV$e5jG2psOsUl`x90Skw*I8cwP$_5$3k@$568Yu99+a05S0Tr_?M2ygv8e@hpoY^I_vK1`fkCzo`@^nzk8g`|*SjqeERHG>k8hBf2S?
z20enADgqTNW_SMT_*sQ~6YGP%>ThhGy}B!|m@k%B$UcTL);(J3N=NcB^p`?Tc6CY1
zzEj1icuE-!uE=D}+}nyn-+0vpF-xG*8WUGyP4SXO@!uFl^S)>!X=@#S=TEGB;NZ57
zcSw`DZwM9XeEBS;a2HwH5wg^Zn0lO8Ak{l1;61FQn~IZx3wy;
z8^?0~+7Jj^**6A{PbCK8-9J>5T1)Bd9C-@izUO{Z;zf-9QI)3N<8>%x3$yVIA>Bt~
z&z5q>f{ya}K&17HuOR~HQa=sP1kWNP)0e1=M#)D?U>7yIPfsAPp8m_%slvBzSR81H
zoNT@uhtMg*j6gj7ru)UcC_y5ViRolso--TQu|V1YBHXP7%KIstR+%g
zC?%e@!J147s;)6hR)a$CfWJ*}$f=d-WlPjDdQp`Gul1!u!MH}&+sl%$2{0(%#~B0S
zD0(=*wH3H`bV(o<4)}6neZtaz)38$T+%AzX{zLE+rdT%g=gS*mRp>keMX$
zlDr`9tK@Zm0)PYoFi)m)BbQ^yql5L2k*
zA^3FCcvG0wmlWzI9wVW4U1v2(F|HdPi7OUi$DjS;Qv&3KfDP7?JG=J2mTpE8aq#m?p+
z%K+Sj0xLxa&CGY}q=hhNT;Tn!omeO{KNzx7@-zdyVW
z0(ZQJkddw(p^x*q&2_{rS2uuw9iN^Tj52j9HZvK>qAi=r!{Y6`pydNs5_jp6G&YF{
z{!6YR{tSRSMDYgJDdPST!|##%)hpT#Zze72sba&fZjyF#D8XvCxM`8Oh{-Z)Dsq7}
zmRde{`caWBynJA4RM1O?V-Qn;?0
ziz*)YSm~v_NfnRlD>>KF-j}izR|5O8KH@_YVn+B1xtH{1s=$f}DXSTo6#M4D0{eR=Dop2ZzOe
zdf==xt^bP7DDR7Tj4q(9kGUraPv2Uot8RW_VR$<)4o$Hqy_a9~vw%U-@Zow?xY|B&
zO8;Wtt6m9%FCF2rrm!HV{oj>>na>ey2z>vB9P+YtYzlfrLT+=0{+nRdA)FN@j8M$D
zP41Nruq>}G3nuxMd^gDQ-kW}a$d!dQUcPkR&p*I*gh&|Ph4;$Ay}$Zt?5M7;uvV-4
zWfD9Zc3XExL)}iYJ3s0toA|Rlo(zdr^e**R6W%ODK8EbN)7L>7jMrQ{`2Rh{rsPOGrITS4P(Lk@4D(|q2zJnzb$k1
zkDl%%d>b4E@aqF+d_=f8n3oGXN#p_JKezYekEMSciKZq4i}${hW;-0t1@EL)R3zP@
zHqB+QwIqg;Zf;%}i6t|siE-G@zBkWh4HPgBdD%PL3OdU)U@LnJad>q!)r#G*ogs}SclReL#g7zoMRCrI4(&dDqeN|a$*!xXzQ{R$2
zob=7YTJCT}6z5*POGGHqswI_{E>o+|F^Y{TsiW>?LI0oz>KTK)tfHPyp
zwM5}SMI-@E#l(yWVt$X$slYNXj41+qBPwB=;2LyUy7ibZo~B#z_8i+&%_;G`=GI7`
z6G?-_mq-0ZLFQCXw}yr)7`yZ5kx-qAc=_qSCYKZW|3)YV6>HRx@0HOJ4yA?R|5p)X
zC9}%=b8$TeOEnWj?HT`K*dDS$)&D?q;<}sy!P`Jp)h_m`l^TM$Y@=nRU;{}9z9R~Y
zaQT=B4*S=-*Y+)Al1zBtFpIGO0_G|>fYL|uz!53tJ-nd{U+$PRXvw+CnNNi;oHb*t
zY#O4ZAdlYOik;VxiWdI6!^#6&ihzV44KN00d*y(>7%01guB|Vea$D7$vn;O6XyC^9
zyj`I0Wb`ZqJk$0unT$z_W9Uhr5DpzbB(1Czn6B;RXsMGo!mScPrGE*hFOrKuLmn|
ze#NNuF$_i{`7Kw4^$j=)0RW`e*wZ(k!dm7(qVkq+9b!a83BE%wLM)9ISf6QD2_t|n0LR@Ey5ri
zzW(94WJqBZc0rGK8bLwoj+PRcRcLI0@eO~*`zpO;1)rbsuCn*k-3+cTuEIB2Cj7M|
zkN_@1q39?8A3gz@9%EuaxJsB~P?w?Smv@*GR@R-jN=L_MW$At2zf9^M+RnFXr9HMWx#dUiMMCrpn}n3TwmLd=LbRt66m~7V4}H0FeiJ{v
z4dF;6tevNw5eD7>NMKB!-g}gE2QyAqHOuAZkmc@
z>4)%TmLHI;QOfOfz@B40i8Y?-YG)lAC*}tb13)Z8oYDA(+8hQmSyqA-!FUKD8zj2D
zf-%_?0rnc>Zzia$MDEz5bcD;6b((vUv{jv@VD(gXJEeUcP3>51ky|6AV{p*VH1aOT
zcA`32=sqnkY-e+D1IT3VyUl`W0}503jPi(0p~poyWc
zb!*AqK6V}bB+g5e9JRVGYQSlT8oVjR>0TmdOjn2TC>_HCvjs`2`zWq9Ze
zz`-eh8#&g^`-IU4MSRg(uMJOn`c?Fc64U9F-VlbdN~Ln_v0(kx&;I_4G@&epB0B6<
zav4fTA@VDM+O(;Efy4qM2aSmsngk%6UsxBlB_!%m^+8C(wjTSORjmk2QHkUvdmDjr
z^bDo+XLXb6vZZd(Qu+U|KmX#uf^yy&{XdnQc{o&Uz{UrOs6_Uq@!EHaOib47NuhTT
zLTD^y&5V64*$oNVNmO>4k!3~{CEJjY5L1kOH<%1#zEkh_|95?Vod3>pUFV$VJil{4
z_kG7DW2cR`f*Q?}B6la3jO#_F?nE7clxuAxdvkPj5WPR&_>~yWw@c;LtL9&06rT^6
zf1qpHxY=7c?O(4!{&`L3fZ%&960HK0w;6nDwqi8Cg2}U1H(Qi$mQRwsPqj<4iZ+Kr
z70L79jkg|uo>X3l$UvJ?&)$v4pCxA<5D-z2K_4kOkF^51!K5`m(Jjp2`u9%Wd6+oF
z^gH)cL$mm9!Ue{
zgkHOzMKiF{pA3~a+TFrJj~>{1m_HWbrE>;-Y7pf0Zw)y4Lqip$D=m?{)>q6~6F#*_ICe2|HnIV)x3sI-ow(cIq9l$|FmOfjvXVH>=+s`o
zMe?^R;!5<1P!d+ffvvS7vDD;wX4|r#Olf9nW#CGwTCjNT_AI)K>z!6_H=$P%UAYhu
z>Mg&wAG6{9!D3WRLEie6h0RTEyS&TxMe_u3NH;^GF3_pLDCW;`QbNC^Z0%JFNL1jK
zbjas7TjFR@(I8Lf5!E{X`39457Mr@I146_MPC7G*dRW<^Gd!7ZyO%c1)w+9Wy~>-k
zB8X(d&%Xj6Uq{S+XzJ2Np9WD-n=E>D?u*9@bM#nNUERkX$J~2h`T<(e{zg@%*3r+^
z3A9jtQ>^dP(O2FVPsDts+C{}jew(wmJY0n=!mcGf4e|*XzDa8!2t4$5UIhO*i=nbS
zSyT6fI6A{KV>6ICXKH)~^EDq?g;!n%jYapDCL?NneFH|3u*4kj9oi*Ks%n5oA_;
zKz^TIu-Dr@azWr(G|WKId`eyupYPXa{yjrSmOg$B9hIJCgyn^z@V*trf`~gQV-&{j
z6g{&;1;-wtvkAuy0rWAfb&6ocqaT+QENE8?y$%m2DU1)o-tT|Gg~TZtOW;LLbLj|B
zIVRT4WjO`{JFft7>5=Zbk{O=zQh`(lM4kzYNBGg3^{{;hBzfE|Z)762OVh|Fz#(s^
z{!#Vzqk;)|t#&!rlhjIbOT6KXYB5Bja$&(CwE9t;()XLYe1^33?meBuk)Q1
z{=u=^47qEMeRf&cT;R`HcAW*06!#aW>;qEn#Vw0IjwIh=<9QEAp()oW%aJT%A
z2&d~DG74IFKyGsV;(~i8Sfb8>l8(3GI-E6O+1}+Im(8k5S5+K{a^nc};I<$yG(GOP
z(J8P)dWKWt&UdZU_iZq$vn2Si;NRPGMR$De$n`#h(|K}@~aBV!sN4W
z=xZ2=Y5aE{J9&;1~WXcu{M5kCLy)@^|L
z%TwCL`Q@_Z;U!@d8}&5ENn|=?d8Rx?rg{(UQ##53oq$tMT&`b-Ono|~y_dIE
zdiU;|wa*+gz9_Ge@s&R_kU5cxN3qZW0Nf%~E8~SfX8kWqyd@GJDMDylPDZAj{2!3*
zej~t^3HJ6+9?S8#Q++1>-d3XMbzObCkz`Ybg|q#c)H@7(=g7*X1Hj^Y^IO1m(QA2c
z3RB~Fz_6ZA7dI@M$xlq&A<0hCTVW-af)1_IDTv1EHhXwDBjAK@5Np6B|^Qc4`luw`;{^y
z?U`TS)Q1TtgeltvQw2iur@FYA^Z467eQs^?y*Ia|=;B-NiPwaug{~BW1{Bdoe8t*1
z?|A0GfA?9#1|)TTY563tAM({L#}aYq5U|ndEOk#xAyJnX9@w&B;j=BJHP}9rvb1{L
zXZoovUUTBROq$3i5A!??c{NnzQq6(-OTJmj8mEuH)5etAZFDQ$Mk^M`@fv^*CpivD
zoiN_r-KEV}M%&yKoG}4DhUnEyp>c}#PQz7qvt_=H8uOB0>uk-NQ>zv9^b0Dzsq4$D
zSO6W{$)A+N@X5n~9o}d0n6~j68orhrp^8x7EV%4mMaUR`IORo5Z62?Uh}e_Mv8gP>
zPaU(u+QL`|Yh$f=-lOYi-E@R+QfvmaKr|9F&6!q%xKGY&roQD>1@gAGR+mB(K6amR
zMA8>!L=sJWeKy+3VUr2~Ju72#ge6(PcyMd-z>21Tu%^QJzddc+>}87>j<&t-+?l?LNH+Z%`Va0rY!{6^*M1QX~P>**;mqg;1?T4+C?*WDh|F@g8
zS=3Wm4mQN4)XlBc&gVdzLsEM?=jMq7RR^M%&@7QV=o4Uon@LW7gxqqcLf6jD_*ZQbnI5R`5cX6v8EB?djt1mIIIYO^gV=>~w
z`+*15B&Km+isH5eM9f*W@Ml?fHnM)ZKs0iWFqFg
zCAmS4tH$?}N~%bBs*8)7`VlI@cmfI1E~_x&ITd1?RpgS)c6@#9vbLsz`@+CLN7C0Y
zdDBEi8AVtYphxnV2=2hv>T+ivM?8D|Uvq`}vCCSCn;2K42!Q=}|6sq|@Y0N&_BT$$
z_+EG-Q79B$a@Kn${K^~5k#^J~w|kx#QtWY@%8G3orkOg*Qs1|?=aRcUQg(h79+Hx-
zhirXiRD9KtNG#M2VcHt~lIffX*u{(&cMSPjAgkQb3hxs4T1;IJ
zc`L3EXaT|l9%gixFPOfl0^aF2-9%~=P)89!DI#8bA@#mPHaVle4)h$YylD-_Rbdo1
zX5yRnT{~#2BNOWu^X@;0iyN7-uONkPD7WfMPVJfshdERv>af}qP9Fe8UH;ZPpiV%1
z6h|jVjkX5essg3nL`e)YK*51uh*jh_XOzZggN+KVJhDA5mc0FH=!P(6f8#`vM*3IsC
zE*)j%^l#ChLF1FbsoPV{5m!82T66V;RwWR(Q@z_Z;WDhNim%L)RC+toYQP8D&RD^?_MC4F~C3js+15ARHc@)6ZG__2mE
zefAis{_tqzy7Gg`VYQ>OuO4e7Hjd;{c4ayArzn?XW`qCm?r<2uJJ6Fmw>TUqoWmHTzi&(n6jOF}%KJFXns%~vs|G7V@R&RRP%wq|_Gl^k@JCMdMUjJfp8m+A
zpR_?1?By15y#oIVB7ac%nUb+!iCy#axlje;J8B=;$FFok$c4<)mLnLUB+<97`1THs
zs8y9*leX6TZx8)}28p2EhTaJIVUfdRV!(KwL&GkLxfb!tCos;O>r
z0M~0C?PBsyK%2dn;_yPOJFm;?l?8bCo`*`565`$Qtf1sEtOg#UG&7yA?LwXJ*oiGS6um=d?{|q)L~m6UUg#uO5>nmgckgB-
zeu912Exwm0G0I~-?>ihFhn=pxzOmC>`vd+udDNxOu(``
zQ@vtFLY2wY*D?SL$(Q+N)}DoAxBX(O#Wdb1Yh
zX0F)tZD{gQ{ksXa=(V@N@J{2<=^wj1oE{MldB4@Sqd|NhN$naZO`eGNPvwlw;Y=in
z7NIUTFV-7elXQzR=CBiS6f+oO)J$i88
z0rEXfO6-%eYLZ`flyar?eNkPj9Q6xlWw}n7Ir@E7q16=Xbdt`@nd7qE52hgD8#~PG
z9edc4g}&XJ;XkiI!k1Q-f+?_Mi9@$s1=D>NJ>j5zFZ71LS3H}j
z$;7CXtd&_esgruU@+n}A`QD-_={Hz7;zZkvwMTA-&Q1S2)Ujuz!dr4RXmX6ti8>R=
z+k>fg>U-+E-pA55aNUKy$Dr
z`rKCRFMmJoH@D(la@%5vMk@bz58?m2xbVLN=wS7VhR1aqzi$G?jUZD)3xhg+=a~Ni
DC_6OD
literal 0
HcmV?d00001
diff --git a/assets/logo-gif/LICENSE b/assets/logo-gif/LICENSE
new file mode 100644
index 000000000..fe61855c2
--- /dev/null
+++ b/assets/logo-gif/LICENSE
@@ -0,0 +1 @@
+# The OpenIM logo files are licensed under a choice of either Apache-2.0 or CC-BY-4.0 (Creative Commons Attribution 4.0 International).
\ No newline at end of file
diff --git a/assets/logo-gif/openim-logo.gif b/assets/logo-gif/openim-logo.gif
new file mode 100644
index 0000000000000000000000000000000000000000..7797896413b8fa290d3c51ad7ac145f34a44f2ed
GIT binary patch
literal 430462
zcmeFYcT^MMzwVpfNJ3CRP{e?!pr}zm5K%)D5Rjk65jn4;3(9U%Yr4u5YB0Q1C32mcr}>Sb4`%(Rv9$g;s!
z4-#y$KG@GxQsj$B4}UsUwz~e}vFH?C`Q0IniI1A>FNCr)94_Wu|JWzr)-Uw`?v`SXRF;2TdbZy#U3Bku10!6CG_q0a(Oi<}9I
ziH(bYryX%>7ce0uH7z}3AKfT3=fg*4Y
zfKd{D)bpc`uwu6nIc*zYRcuju^z1)D;T&!z{P^3uP&CwidvUd+$vNY)KIe6u+}vn!pHeDU4If~=lw^E}({
z%>~)LAIUZTd-V$$-|}p_vTn8%<_r{3Mw;L07k&6%=Cm~Zy`|{m&(Bn_fTTe&bEw95
z=Ml@+;!h(DwEg-C1|_*;Ezt^gKUz!jCce-$10)Sg^QXEpu4G%bl@`qOGVit|7?u^z
z4HQ3{`O#KZ^y??fLtx*f^5TV_x|+RICpCfLdP?=Mx9uFUl1+5K#is1Q*bjvL}&2FD$JYLerD
zyC6H{DQs#p=adOB9?=3s*D-&rm>?fO+G3+m2I5`|ZsFxiHRQzf)5~MPo
zF%qn{Iyn+TgvpK4v_v0_zSTXLIT~tkYHBo$bU|(`+{E<3ScLig%&|xd$EmR>vbWrL
zv{mGT@fe%5%<)+J!m05%O1<1fyu;TA6YreHGba*USEnZ4Q(=cE>7JstlZn0uvnG=Q
zPfbrI(=HsIN(nc$ol1?qpEZ>h?>Ie`PWL`Moskl0JDr)4mNlKlD4d?oX4W5`VdQ_c
zoyjR4&zkvAzB)bgkp(+4%d8c(oBh;yFnc!lL+h!T**x}zBXjxPrgn1$efP8H3I`o$
z=88DpN9K!1Bkkr(CeyO#OJ@sb=F7PCM}Czrf3^Enu|A&tt8!~~=GSKcT%OB6T)p
zAr3LP)oA5eZVgUHexX*_%zmLx%$o5@m$81P@$)SwiIbndw+?tUS=N@p$~%0^1dehl
z2cHz3tcicvc0fO1X-C(5DFeto92^`Q8~ZnPPF{x4!MneWo}FJf@%gMk8FJj;y5E%4V43uHv5#hp-p?}3dGBPG1
zDLEy9o(@aR%4T?GWafOz&D-}ezo@vRw5C<;
zIp3X3)BB%X4E}0C(0@=2K0wqe&Zw6!O3GcS;Qk1hl+(cbef+fi=Loan&(}TNGI&`W
zrA#1ffLkgUr@y0Yr{KSc!9u;ni`j(+ypQ~1qfC_jVv}q-W3gGjXm+uM&>+9mx>rk$
za$wI0<3!l5nN2d}Z$baZc>k{@+lN0=pZG^mg5zGt#XS$BKZ{Lylg4z9OY==+1f+a)
z&&&(WE=(vXPtN#|n#H6SRAv>HGV&{;3aSe#Y6~mt3O+Y58k#@0ww6{m71uVFHMEp{
z=`Q`!SKRgWQ{QmexACf`&ia;)_P(Bac3*qfx2nOPt$l+XUk7`7e)bLj{4y}q|8wm7
z_lcgNiEksE0nYgMiP0Y;bN%D90~2%K$L9N|W(TI{2507fPH=xtEp*SVcX7D`+}|T(
z!<_M{p^53C@!8>tx#`)dp}D1r+0~i(mHFA_Iqurz%If_3%KXCm?CPK4P2TAG_SE|3
z?E0TM9&c%7ad~xV?f3Hf#@gc2I(PN=;_Alo%Er>t_QLAc!YXfdd24Nrx4OQ*{AY9J
z_x8#a-a2n7OW;q`H_O|_
z9~XV(P^AG!%aT}75`cZ7U3KJ!*Pd&1k~>sVjKIP^G;mwC**GjzFQKJoTn`69=$dtA
z0cnqgbnJyZ(3-kL7SMofamsq*(EqXUW5o(s1YQj
zusv`l)UDF{8>*J|`^+rfYV9!Ab@Tr9xodCP}2WctTH8?!~f{%mp^j`Oybdmr<**C#&m{%o!N;>#nN4uI>jK)bnAgaIA2
ztC0m$<+|Yl>5xOZRjBJ+cd=GFOu4ZN>%#TGqZ1K2y45>kxt_8Hi72ziYSB`z7a=ea
zZLM3gyPxZ=(wc~U(O4t7!Sx}clW=q&-CF703%lsWgwu8F4qspJ
zH*ZZ6Eo!Vg=CTk#Mkk9k=+>W%T?n)>NZ#GsSbwT?A&3%~EHR?9_T!FD<>{
zoTX>TYjlb_K(0|^_ae>LAVqptQ)3*iGbCj8uFQ%`(}nAcq0y}=2bG(eF1aj*(b1{0
zI(p5QV;93S3{nr9H8q=-E=Di|Q{}Do^n)P(ouaKAmU+yRN$}1+7h85FB45Wn$RHrn
zFgQ-zEAF~`_)V`^6R#+<(0BG;;S~S4`w{Va?#bFAX%~VR7eg{H_@$V7CS3_&nE7X2
zjQDUd@`Fiu(&dQk8?o6IQArwJpY(%EjY5jdgL1Va3-u#%wc`s7gHMM9}3N|UW8@ceOqAlF8^Unxou35
zb41aLm;$Hxf*UF2FVk{fW_`3zDY4J2xSvw!oLcZKrOY|K+<{T#z=)@x|GGbky2~IXtBs{xRYLWhf!;t+Gh8$`B7GbV^aOIoGRzEx`+9#
zu7!Tu_XJiT
zqt-jKKAce#oY&-?-xBeu?p=O$Tz*r0Nn1okyLVn^WLZaMX+6EHDXY9SnORj-T9sPS
zom0{gUeg>^+ZE6L$*5}1uWL3^Bt^I{f-KpK*
za(f0UyMB~)^hCCBLb~VP_l>;&zL?%RS>81Ksckf?YdHJ+OnS#u>A*-~_hd=$Xln0b
z#?Wli1n=X>VkwW;+|W|n(%#tA&Z_%T-Oy3nJlNdUUDZ9<(EFpS`$xkUPIdQid-rht
z;B4FA^tZwJuLC2EKe(Kqqu+;Tx<`N2jjXheEe}qwexKX;Hn!Nd%&XnzwQTchmv~*9
zyn!v=;Nt4Y$jIcx?ARQCvNN|hGe5B~zpyknJianCxjZ|&G&1*lW@2q-X?cA4&+O9n
z*fwuvd1ZNHWov7BX?g3<%Ae)!KYW+-|4#Y-j}~pm*{_B&I-v*uk09otLHH^0;nsfz
zVr**PX}#TjQx)_c1;m`X-<$hS5EE|wvl+@=o*MiMVxYTU
z9PckBZKL=ghEiYY{TIZTGr!jV1H}A3I9wQY?w06w;Sr)+C
zcWYbKanP_S`_{+4@(%9oNXzHB*K%9G*OwY9zl4A0qpCvFp9asNd=Qg|@s;F*n8q0Q
zv%e=ep29z%iH18&`5?yXX7m+r2|kFqD!D_24`M*@JA4qce%=@g^n1gYT>ZcCGKm96q;GN^R_<;nM)zdQXU&H$M)7?d<_a}NE^p{TZKh-Ri
z9DG4l>Q0FI;i=T&YyMMd8xNYN(t$3h>5N&wi_@9?G5*t8W1psN{j)0njiN0)5BnDq
zV@#0blbHWfw6m=rb^h-lMq1YXUxAp%b^iZXK+L~4_fqV&UusjCU@Wz(t<5fdA;OO?
zv$b|TT<*|4l(XDvpggzSMbbIC(rse)aHYrGI%nmp#f!O>Ub4^8)jq4JhpXRg(sNe(
z?ThAC2Ph3k*9IMWAFh3On#fuE;kw3~Tl-0cA6w^m?s~L76(Qb;=>48>9SHcUbR4^!rOzdV>Z#1;nkiKy72W
zy-p>kSeqL9yTo)!UUJQVgS5qp0P|g^*!cYc@*!Mf2v)|509%Yv__^gRb8r8-Q%$3H
zS`G({3h9WRW-zM}SIjlg%874y8S5iaZ(eWA6n)k}$*H&>h*m$}{!P$zsHI*pG%>*3
z%3a7YT62#h3nW@hhaQZsK1ek#1;dW)`HuUkc*z(6*C4qI3j?9oX%!0gcf?ng$R4Fn
zg6@+wUAxIOAWduKlZFD&j5BhRkjqraY~|Hvo=uHlMuzvv_Z?m__I4kP*duj8L$G}NkhRr-1>*h&fLur-7zPGCU?
zipMNcO6;4A8}d4v2U4I)#}CH~p1v{UZ#h{lKI7@Nf0^rZx={gcl%WC3rywos@vxJ{
z8q(g*jnv&fGR-RWQj<8?Zid^gvgkT6j|AV}O$8sLf(WT3fJi(CV!f`VU?zAV6aheyn4Sk}@u>Hlj0u+wx}B%6=qnZQZV(U%mf$cD
zeE=aE#q$_C5qtt)C7{8D8IU~oT$+_Nd$rVcw^kbSJQ^zVnhg-N$LH)dze7+Nf=X%K
z1{pFn4vqWtmd{_M_Yz^pBopBptsr3=UotKq4>^i(-x=rYu}4+i55L92wGm{Djt}e&
zSV`_u(=#58ce#KGOIbhx&PyA&0uQ7ZqqF#mh-^oK-@&8UV*CduoF
zm7A}s0|0)G>$a0g1xrLr?dXyvTPE(gIi;!{@tt&EnX%xvpF;#4r2^3u4%7&@U-^gK
zFDH|Rl83tch3@g6hb7lt;nH1YpeUDmB0cD#Jy^_-1A?29y)dGLV?vRXhcnedJD$~4
zFRW;Z(+IwBh2yo-j=!!LxZX(@1`DU)>YoAQOT<1Nsy@?^9im^*Bemyuqwb~L(5TkY
zgJ*s>k%Du>(+$QB-}v2Z-kuv-)H-(T!EUvHjoMWL^#oV12d-{G#
zIu<*hohL`_8SFaMRPv_c(aoZ=-e2|4%O9V8{389#g|+*73_$73!`?G&UgV2PvmIQs
zUF9dXf)}c8RB+p6EaF!l6~}rRP+W>`3_nOK)+Yqt4;mThk?dV#Xj(qG8fI}o;^z6K
zrlC8Oz;uh&BfCm6@BRsmdJ!|e=e$z;wMS3m2I5=JL^)@ASS}guJUgMlb9PaC<&YOx
zI;H$gvD>iLA@xY@bW*)bRzbpwTk_z{`zObG^Dc2dd2G+x7?nK*f&Ohwrg-c273Wt5
zc24JB$DVo_rQ#55{?gC%Rk+?$FTK}^)-OU;JY$Yiw@=wtY&N1}QzUIyM|
z>6O?ri@4I8F$EVx@^1%c-w#T=7nWle#;}WH+>1(o9-H$bD#I=^*D5a0EAi?ThuD0V*j&e$qKk>8rYU7NlFQ9g3$2qGcFFlxiDi$H%dFFiUL}@0rxm&67N3o;
zQH!otORU$5tk#OHGK{a*jjFv8RdqkURy(E6B&GIRdb1g$>uySoZDyTQW}Qo3i)&e{
zQ$f?qqAnX|%PUroM@)vtyZq3oERW-KGFSswYF=1{Kv1BvDxOynZe=Fu94ZnvAOP<*}jSK*3rfG
zkw0})f9faJI>#6L#}|91mj|X7zt3&Q)A@CKIueC6BrE#BAV-$SG0BV#kub90lE
z)1ynjmY3#7W|ybu7f0qcC&m_+XIAHymPc2%XP34{w|Fz#e8BB&Zjn(EypOt5A60L>riw${6_@^a$
z@AYo{<|FQJbLXDSWv5~Px2Y;p0R+*5QtHRr#YTdt-(*QPO2d=q?Rn|cZ~`^>z|gtPZu2{IUl%2tMDO63$z37sBvE8DxK~QJCN>6F2n^!aGO)=Uf6Ur?PYx{Or
zv8qnMHc%R)>}I{|b_akRW_ak8)=)L-xcys?-C4Q{Mx(ukAH>yu7T@vRsZ@&tqmS#d
zv_`%%^g^O9he-~4ZgDkQr0#cfJZFyA9;=#2Fi&ouqkuk~dHN`9Z=0Nl?~ptCXd|vh
z^hPn;UBGZz9i{Z0^g(>=%f1Qa^NUsgHXVHdt_CUe|HJC9?M
zqhZSBo;Aa4kA2G|_?bedU^_yMSQQa^*y0IFJKoLj!(FNE6q@%H1CPC}*~9arQX$TL
zPbAyKypK^j{0yzCh5RU<``5{yI~io?(R`v9T^BRprW;(5DWUd3MbJ4KEK$wYKDIuo
zql3O9=)(38w_%>{tpdPyFadk4*FR5IU_zsuWzKVqHD9;h4dBSu6Fh~`B&X_-0K6xD
zl;)#=1|nrCZUUE@pvM}?=m&Uh`TP@tuZ0PhnE8R;>p;M3PfcA%tA;aAOIj@doZML@
zasNa}OzXY=#{vYJx^O4W-@I=jc2DcLRaQOk+_PwK{CMA;)4s-+NXtU+s#`TBmuV20
zSt?XsB~|Ml34AK_&Ynw4p)^LC(L?_nDrdc3##xNyhz=KLO^zKpb=%M3aCoBbBv4CG
z&R8s-3R{|moKoyB2u|{SVK%C*(ylD%l(K*C7@*u61YbNt9dV9Rg*->T8e2(E
zlO<^$ZSGKFdW)P48%a~Ebo04^&y<`EYfx3;yJQ;{_8s>C0eS*1DZ#-!Zk$1Cu-&lh
zS7FC(#xakmFf*GPN6*+!j9}dUF5W8-Q3^*}SxUd*IY$EkLa+c>JVc+6gnP~=f?xz+
z8@e>&91-~74F2;K(T_2>1EAgJC$wE^S3l*Y9=!$Y32~I!FJguRjh45Zb7CY*m^A`+
zUgz@XA9V0O4i$(Zz|&7_Ak}Hd;41jfA}p4`jrHnX_GGa5AQ_W7>3zmxN^PMzZHH6tLQhv=48W38=$W=lL)``10LRR0{hsY26-^r^Hga^
zu%kVAw|!aNo?11?RAdQYuT8a>73VB6-#JD;yn46F6U^}^OA#+%fzDqpcptNu5)h|d
zILnc;ac1q87?RadGIa86I6o9)q09l&G4ido)DHiW_ltFnN
zbObK(Nq5xbm$uJ}F6`mrw1Ml1ymc)+?Xic-G$TITY6i^Y1xAmML3mvw89>)
z@6UT3x`@R^&M$NVTOyF~C=Ppey0pdghhVmgGilaWR$N2^bqQvNLBppMOAO?F9th!S7WlyD8M
zmMbwUN1IgrSXos$8C`|Gq;hxPB6a^6F5V~NNaEO*BN2Lk9{YknuToeiPDrpke^=23
z)EjFKmev|4DadK)>w8IEKMDpvn}_ZtQ&0A*2fNq{^^VzGIQYaZ;Qm&aB!gZfxk~bq
z$uEcF$pG+SCg?D$TAvGmOGk3Nb`iPZ@(%B$w5rfA`YI-cn)~;qvAue$IJCO`K=3RF
z^JaPf%y{E-1?ndqi|%UuTC(S;++*i`WXmPt$*qYmhcFidtCo+h+X;kFz4ZwrE6#7(
zJSC#B*@nnRr=lWTT(LU#iNoM~KRAr=^tQl-_z{WsxLQf!>%XOz$?%v4K%D|Khpqg2
zzkoL$MqqF!HkIKPmq9U
z2uPfY9OPhUnCM@WH-3lEa*fE>4i@e-_!GPbp5}ajsR7XyoF!nqSTF+|IIUOf1o6B!
z2hN~j#6@(p){9x!4{K%9oDlBw?0%FF&UQM2^ASxdMHh0G4c^A2IMMB~X(TY{c<9!434pK{`c&
zLgb)hBsDt%s+oiF91i-K;ZIfA&t;;cxR{?zbQw(`kf3{?4gz}vVKl&b`~`!10*BX;
zu_U-D4q{A#oa2DQ2uNj|F@XZM2l(RhK}UI9D&?SU0TJyrq5QLlhIQV3VI5mW$4V
zE!4Lj5SYYiuq+jbWLgMtU=9@c3nJVB57|uth~q&-0QCw1s(=qu#`)tQ>Z*D$+y(S3
z`;>rO_=_h>X5rynI`${!Z6FQdN`c_1Kpzgm1rHMA0?=eWasl{X17NrSEC6_o2E_q@
zosp4|-#|x&!4@2d9UI98=upJNpPt^O;jYakV_!UYyAp+Prb19uU@{fug1>o$1KP(0
z%24BE06;7ObUG7?GXWjoo{jR0d6W@j0l3ZP-tjpZ`%FFRS_(F^MBp3goD|p9!e|`Y}ebxmJ^)j
zVu#3YdzxYqGzf!$so^4joCZLv<<>TONSH}{lw?+o>2=M1*
zff@>&f`dP!0nafZ`ZTyd9uYvozQDh61Yo-85G^7^g$lkv1nV%t3REzef~er4jTEfB
zuV!4!N*$*;b<@xR92ku(;J|@t;Na(I5Ir_npMZ!ZU}h-rY8E=W0P&0pvnIh*$S`RN
z#F_%WM?rkxqFca^ep_X85K&MoLr39EFA`$mIV6b%vmwF^xKMjKBA1CRAz;5yk`SA~Huuu#$+l
zNC&DD!3Xuh)tbm803sWQIa6SqG0yzys5DDMNAkFE6EegHV0;1xTUG!o(-EI=0^xY5
zEIC(+0#+h{jp#5>A~KGKh9N95NAiYrqQ+P3FW^D)xKsmfo&pI%rNGWoK|1okL`?J&Sc_j8D6sovNVZb(i6+oVmX`hugi1#wOexCT
zDSB;eK1ar6laR+VVfSez_lU*I`@?YBAQ=E6of+@GJCD}#et6@+C>vcwMLs3pBU8b*
zW>lB2fDRGMZqoDeDd7&tC+VB!nNqPi^gqD@7XuGQ_6JJ|fDD5QMXOog9toUsbff{6auY
z?6;iFR}S(;vO!%~&^sD>nL106ecjVwYLV^W+Tax5;8Nb;I@s`ftAQ%f=&si2
zY0>EI+UOhK=)YXv7&zD%ywymPXbM$p3b$yAbZv@`Z;CB%iXUuB*lMCnG$*Mwr&u(n
zxi)9SH)oYMGX|SKY&A0_T5{D|@-12lU0aIdTT07Y$_HC2w^~>dt<`F+wHB@QuC0yn
ztpZ+&1_b`wAdqC|
zZ0F=U-u%qKIn@58x8@uAxwwLJaph{^g=cA>)V$y7dB$DyiZSx{yXzb091!s|I8@I+
z`+{%!m4FnJ0LG2rY*U{U{qP)}=qx_ryB3wL6;xmroU0X4@DIXQ_z%KYt{+*Z6;pQc
zUkG1B{*~DL8*%xUBg(JDm0gc3vxqFQ4$80!%drj5v5v}o5tVf>Joj#V!QJ>W+vtL4
zarw{VN?*hj-U}|!Pb{)XtT0P1y`G$Hm0WJ0Qf`w`@+76qDXsX~hy1hAf8%z&$ZE~l
zYW=us-FM9QQgbh>)-JooD!avw(R?qp
z{u!h88Kc=Hz4pPU7S~TTFY=o2edw~y?{+Eu`aHYKv3%%J#qi78K8Mv7D(y~2L%KbA+qcTeZ3(8{iEBxr`nS~{cg3_4Ogyq4vy!HGa%^_YX)d7rJ
zFGh1%c5N)9#<#FBJij(9uQ{x=HLkoRwy43gyxXs|H>$MT=R;R=L2YtDO9~$ZmNn&7
zHe^+Fr&aX$Rg8L85AZ2qOl@CmeP>!tYjJHeqq-}r>05qXcYfuUVEaH@
z-^BNpvG1)t!)^T|4SnNX10(%EM!WgR{r9P^-jVii3vDB_t;77T$gzRp(e9C%!O@w)
zskz?inVPYs+L`Uv+3lu@)xojF!Re)*$+ecH?S|FuzSZr4g)#p6h2inp5q?AD#Kh#%
z{QBDT$oS&e%+k!<(%AIxxuuoSm95#8?a@u%EFT1}{%wWa-db5&+1y;);^+8(yA%H#
z5crn^{#n~xTb`R=oE!N66bSr(VhzM!5V)n|%3lOw?favAb9{Pa*8T})YqIv1Pj)7Al+8xCP!`0
zCham(lj~GyJ3uMsQn9DRP6j9qI*ee#j3U2%dxfY#jGUG1KiMp}2QLmk*jBuB*WcjO
zgYksOL}!xsq~DVMo(Bf>s$HR+PQx?v#aE;foEPP$?oI>!L)_Q9!+xAy&ac57u_O`Q
zpq5+Gm)=NEI}fEWE|_MfMS*yTBj;w87wf_3TD;#;e9}dutmT5k@~P|jh>Wylr;*^J
zUJfL6$YZgQORvx$RA&o96RjC(u}PYZyV2!jU%4Ly7o)Sg+Arp0^%Z7EhcBp1x5?jd
zAiCk`_Tb~*VoBHOWq{8&X3x!0rM19HflmW+gF6)tcn@yGS+ax=-M_7zvqh@Hq{nLt
zp4+m@l1zJTYX9`k{NxUB_2{WULAA(ZDho}D`(ZT#r&)`3pVn$UjMQW%%$L}nRg{Y*
z+*Pn5JM)kJa@U(rBm1(pmuvQQsZX3%=(gy3E=}FO9hCg_#*2rAH#Td#?gSu{R8M`I
zO*p!C?ZL;2+l)t_4Oa(U-}A<18m0S+@YZfUMw*+^umUFZ1KrcSfR+bez6AGcQrU;IzfFUR|D`sG5IluHs{
z-%Ji+9j!iGHx4&RQ(X?Uw&-|rO@60KhI!DXjOyLN?&hDWWiv53BjWGqwRkn5pa*_|
zF81;rVpGN#gXk)hIj&B;%e+uc)o(9*9fD`jKnJO}1+#qXRp~am{E_AV_3vCC02R{3
zqplKb4l{1oow?dcT#GR}lQHD4?m7h5!vW!@RCigiJ0jm`yZtZ4yq8-P+L@eDjlD>P
z?4SXFctDk)^pL+D;cx_bbj)$JOVCkwWT!`;2I?XX1aaCKgVzO$0)|kw`8DTvC8a2S
z@{o41I=SN(-VJ_{=q^J8Aa!v-L(9LXJ1W`HwX|$4F|gWb?5u~
z(L)#p9&y#CCK$9gg=Q&M25q@>#~%fjZ;T5aDL|Wg}b{&1f@?)@mKrc
zAyWK+efEI?L?R5Lt(%FsOzgO7e|PVR1F|0TRlx?2av`4rQxRN02!ujL{?wu(wCL^!
z_-upWB$pPt`<&P2GPtKzPgvs72L~iL-kqkV
zhkTNok-7zUbQ)oyFD5WWk3SwePvDNuDK7Lbj+1nC%Sx}{wm~&hpMlGkEA4i
zf*q<8YN~;UDb4bEz5P>L%>(_ke^AcAeV6jL7IsW8}?0SdeC{r@@ghSHq89==E
z*T|pW89G+8)cyEkGFaG^%rcS%S_FxMYC_2<8)A(x3Fj`U*qtMUt@2dnf{A2}(5-&<
zxT<~J+Z7+l?N@aNQ(0|tD*2GGh?ysG1n=|3)jOYLfCLirqkvR`cKHpx+q
z1t(5=F{V%&HbXq9%5#cVvYLC-{VH76!^~SAnQG
zVsEldxd!&S3Q+k(&;tm52&vuZE@m?n6mnu^H&a$C^|!dq@iW~yzY0KjlTSg8jk}ep
zF8OL768%GRBj0B#%{zVD++B*y9J%8
znmJdA>i2$&4^j^CA2b&r*iQa+tLLsHZle2Cpb+xtEE&G&D0|88Fv8qP{^!OyLl;^(
zCghGfQir$Bf)~bKeXOAj(-6}-)T%D{yi4=JG6H@S>jo9AJq^J*%AQNS2sJKF+T)pT
z+Gu=bpPft5L|9NYT#Zg;9Hc@nBWh%v#xTzO+yFNL_sXizv|}d~5qZvfm_T=VTvGgm
zmQZ8V>zKE5J{sRCUa}18(*v^V6-ESi3pt{P>UvV^-O=ve`bdTu?hb0JHuId}bern&
z+er0{H6`4a(;a%2}0FZ2-eZ8>50VeoX9qK#nHVP#7?W#x6C%G9M=EprK
z)5Pd@hS6R&ME8p4B*jy&7_HyuX(Z-##oWs*+UrJ!MbolZyQo8iwzoSEClDI0WY_5J
zbwXjz&8m-$e1nG^F0xe_1Lbp1EO7)UnLfH1=msXbmMM@yM;fgo{5f!wN!V#VCZK>0
zl0nU0S1cQC2fMGUtXeIPBa4{WlYM4Z8h+ll{ls_Ni3T7v`5Xe~d;ogQ2lpb`++PQQ
z$;j|$OnQa@0&+9p`8EN?HlS(fHS}{=swjvh<}j>n@`i?LV`GxwRs_1D$>&cOad2voeKtMUX|tnK$1jY3SFOkNDw_mYvKe^ClNd4
z0z|I`h-JRr0l0Q^+$$6w5~d7FuLGHp5IK0g!>0x1kw=dG4i(f8oWVZ;Hi2dFW)2Zy
zC=O_lBDckUO!UL{)BWpc=sF_WAQ~A(4*xU>f6Rg@Tw1#fD|T62Fb4(-q3#jhH~jvui!FXa2ofT-}6*K
zLcfTK3T8#U=D_XoU;+o^aV^@X1a#0G1m|24baaLMzBjFH;>ksZ<{xcIjyXPsouTP@
zF`?I3pd%_Et}aNN2`FRj%f6<><*{QO@Bk1A@PG&}V|&K16Q+A%I2_;s7xoMQCXj&M
zr-7zqlsOIb9AV=PbqG83Sm{30+*x3hb21F^&iRSp7S}ta5PF>jI!t>v5CarrVuYVQ
z+dh>rNrXS=3Pcj%e8@@R<2okNp9zyMg+1h;e~^%?e(!e>fai&*ZE$*r<7V%3{}L(B6AzF!w%7?gW`?X3fdf9g4pedhdQqXW
z^yGSB*ojlnffCz&OprVk>cB}K#bsEY&Ul_EE&Nm<2ZuBzn`=`6M;bHQwLuCjs2v9$
zv)guw{W8ZH+ek%Ea`%Z}mKr5smxM5n=yAt6X**c}Qxf#g>GY;$XetvK$b=rHUil%M
zT^|lHr@{_B2n=n^j(Qfe48Y{zk%7V>Nh&~_nbCL=M52PdX^1GY()Eq7oCnyQVp!_4
zV=JtEe1v^&1nY+fmmX4FMK#vIl!U4Wppu!;^)>RXank}@L=Fc%L;JYF+Yq%^
z5bWckM2bNBh#)-9WcZ-dQzeu0I7B`zZH@hMErZtYgvI)0ZoQS-0`dVlV2g`-On|tH
ze@IgW!U#9ARnzNJps8$ZKT#lr2~{A(9=9{d%Ywe8+^)|EQO*`UdQy->M;1qd4o}?E
zh`TP$ba%aI-^oHuGxHY#PdZ9{CiqQpa7;|B+!hc6g~IJv1s+prFnq2|i!CDU1IyYm
zlnHIUdOddoC`X5SvXP1dk~%I$cTVinb;P)=K`)c?Z-_j)u>#xy$c*5izA+y?$D^+`
z=XaL+(6Z5=@t9Z7kFoGd^DM+84os5*u6O|4!2;agEO|N(&Ec_RmnqnKI-)jOW18G0GKzfrc#_HF7H_C<3NSfBn5S6?PgxucGUeWW~I$73UL=mvo&O`FAe%C9Fm
z`?d*KjDcW10N(SmqQV)d)C@R}qbx61SRe6NBs@uCLX9~0rtA#-%t7jh^DM3Q0c1a4
z1LBwP4_-#`-)+cx{#8Bt^~+wMvp8fb_sKdHTSA0y<8lz?wB|D}MG$D^s88#~SWf_=
zrv=)lAH9nRL=%CQtg1mzvLy+%-v4-t`RuH+#TQebBRJ^F2C^4l007n88``&o!$y&=
z$dN3b;4>A=PbIjtR7LHoN94L)
z@`v}35SA8~IRPIz4;(A5TGnM&euUn9SsLF+x_Df^p({*!g(b*kV&0RUct3xo+Ir={
zRnTP$B7=(E6?gh{I_x=Bu%9L+>4FWh!#0!LN;v{70`_w!I)Dj(Nes52f_J$BAskpV
z1$u5GxE)p*?<2TK!@S4Cdz&ohTixqSph;9@AE%kQC4xQKG6FyqJK7q{fvO5@FO&Ek
zu^98|BNIf~ekQh8HG$6>zm%gZC@=qzn_lA(-{PAF4WdOUz+(VJEWW+mygi4~Zcu=s
zlTl`z_F3o`T^9H%;ZP@2VU0H{@_X>3tDS9cgGHbS`&Q)hbkfZjaKbDhi_XD@4>sb?
z#>LYFgagn4l#aaOwr>LfO#rGM-@dgRZb?I#)*g*LDcE=lWkUb_Xv|_i^??!%>On_!
z0j?;07g5f^T0H=7=9{a@hw1@fA<@{k2$Y-QO902A?Q|maVwU#5W^PNCBT_A{w
z@MOckG2kX=!J=d!h6!)ups#vA%=PRWQP|>Odhm>6r;7VCTMjE-J4%F(hGWEGD!COR(?TbO@08sq
zK{?|M8{uK?r*60$Xc9kyZ6qN*$mqsbST+Sa%NiW#46<*&j^QA>AAXOhXgkFPVaVV>
zI%b+H@G}T9^icaswcsQP6GC!XS1xWX{6UI@n2-={GR+??e(G1rm=2@%uYxWgxEkR@
zX4hRV0iZkC+AIpvj|&R`pgz(N_4uDtH0+Lffm&LUi+J!?Lod(bq2cPBZ2%f*O|DlA
zF&)MJqGKwUdj3roCZ{c13qjXN#vHa_fcMC?Dj5SWj6pNp2xswI1{9J0j;?RwKojWX
z0Wb|*fs21&CvoqgY*-);b7g+8jyxuZ3JxJ4+*o6~D;b4U$x-~cEOA_hJig4u{$vZx
zse+pv051$9_5)z8rXT|%%vxsfMeu}KqS7w_ri6{SMFbx{sd4vUgio@tSxf!oV
z5!e7A5g^Ed#n3S0ILwO&=s322fw)(ZI9!ubp@{=)QUs1l3pNtQW#;W&2?8b#0@-+^
zI{Pg@J2IsM7sf4L7eOxL5Lp1sEZw0zSmdp{6&rv~=0fF}Ps6Mq$j~k4dj#gmSiKB^
zoxj~qEdn5fIVcnM92Zx|n#-V~L_Q#71>s}!AZ6xBO)_Sxaz2&!W4?YAn#YyO=J%Q~
zfgkJ4chiByGmkHF`Hk)~DOOTZ*SL9mj+|&hg%M^CPjpeTpOUHA93-ZRg=7}PAF&~O
zNy$kXX*eA484*7BEg_nMtgnED%qMwjtbV~Qy`Lpb`wP6oBZ1yPDP%q#V64Y!dBaBO
zcwN%_xV%1lWSAnrU~-MWvgWPDe!-N;(en7j7!sOJgg>CcaO|X$
z>?Aub%z=#V=b$6;a0e!K3X6I6*kIZvLxTz2L0_wiHqfO*^tccb`D2}~pqvKR`-@1W
zyWj*D{gIlXNUaa~0<@tBP7~Z(m;!O_D+)Xc5KTgynSjU8urma=QZn*6?ay;EvILLj
zP?Xl#f}=$2;%C8S941iFVjTjrq1&H}GXUJy@)X)HgAOGo$y|&+|0%5`*+-D7<+?Hr
zWJMc~TnOHK_BBNO@~Cd;0mB5Xn9E}qBahy!^c24`ZV;>V@Q1y#(ZnT}31-Fa0JxV4oQtAONSruKjFu!a*%o_Yo;%c~XOy6tyY2X6GgkCxrPEA;pWcZ(
zo>iX4Ec4R~w;_lfdZ9QqUs98ZaaOUq$(au6OZ7o}&wEQ;TeND9IC`tz^>TW@)5GMp
zSVeDb