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..1358bcb37 --- /dev/null +++ b/.github/workflows/scripts-test.yml @@ -0,0 +1,63 @@ +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 stop + 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 + cat logs/openIM.log + + - name: Start all services + run: | + chmod +x ./scripts/start_all.sh + ./scripts/start_all.sh + cat logs/openIM.log + continue-on-error: true + + - name: Check all services + run: | + chmod +x ./scripts/check_all.sh + ./scripts/check_all.sh + cat logs/openIM.log + continue-on-error: true + + - name: Print openIM.log + run: | + cat -n logs/openIM.log + cat logs/openIM.log >> "$GITHUB_OUTPUT" + 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 000000000..3f27e0c69 Binary files /dev/null and b/assets/intive-slack.png differ 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 000000000..779789641 Binary files /dev/null and b/assets/logo-gif/openim-logo.gif differ diff --git a/assets/logo/LICENSE b/assets/logo/LICENSE new file mode 100644 index 000000000..fe61855c2 --- /dev/null +++ b/assets/logo/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/openim-logo-blue.png b/assets/logo/openim-logo-blue.png new file mode 100644 index 000000000..555bde4be Binary files /dev/null and b/assets/logo/openim-logo-blue.png differ diff --git a/assets/logo/openim-logo-cyan.png b/assets/logo/openim-logo-cyan.png new file mode 100644 index 000000000..a27807f83 Binary files /dev/null and b/assets/logo/openim-logo-cyan.png differ diff --git a/assets/logo/openim-logo-gradient.png b/assets/logo/openim-logo-gradient.png new file mode 100644 index 000000000..40198d531 Binary files /dev/null and b/assets/logo/openim-logo-gradient.png differ diff --git a/assets/logo/openim-logo-green.png b/assets/logo/openim-logo-green.png new file mode 100644 index 000000000..d071443c2 Binary files /dev/null and b/assets/logo/openim-logo-green.png differ diff --git a/assets/logo/openim-logo-orange.png b/assets/logo/openim-logo-orange.png new file mode 100644 index 000000000..398d9d63a Binary files /dev/null and b/assets/logo/openim-logo-orange.png differ diff --git a/assets/logo/openim-logo-purple.png b/assets/logo/openim-logo-purple.png new file mode 100644 index 000000000..f08dd8acd Binary files /dev/null and b/assets/logo/openim-logo-purple.png differ diff --git a/assets/logo/openim-logo-red.png b/assets/logo/openim-logo-red.png new file mode 100644 index 000000000..eb1e54251 Binary files /dev/null and b/assets/logo/openim-logo-red.png differ diff --git a/assets/logo/openim-logo-yellow.png b/assets/logo/openim-logo-yellow.png new file mode 100644 index 000000000..7440e3c63 Binary files /dev/null and b/assets/logo/openim-logo-yellow.png differ diff --git a/assets/logo/openim-logo.png b/assets/logo/openim-logo.png new file mode 100644 index 000000000..cc87f0ac3 Binary files /dev/null and b/assets/logo/openim-logo.png differ diff --git a/go.mod b/go.mod index 88d5abb09..0a8c1fd52 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,6 @@ 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 12f5d41bb..443d6cb9d 100644 --- a/go.sum +++ b/go.sum @@ -784,8 +784,6 @@ 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/install_im_server.sh b/install_im_server.sh index fe219c967..b08597e80 100644 --- a/install_im_server.sh +++ b/install_im_server.sh @@ -1,27 +1,39 @@ #!/usr/bin/env bash -internet_ip=`curl ifconfig.me -s` + +# Get the public internet IP address +internet_ip=$(curl ifconfig.me -s) echo $internet_ip +# Load environment variables from .env file source .env echo $MINIO_ENDPOINT -if [ $MINIO_ENDPOINT == "http://127.0.0.1:10005" ]; then - sed -i "s/127.0.0.1/${internet_ip}/" .env +# Replace local IP address with the public IP address in .env file +if [ $MINIO_ENDPOINT == "http://127.0.0.1:10005" ]; then + sed -i "s/127.0.0.1/${internet_ip}/" .env fi - -cd scripts ; -chmod +x *.sh ; + +# Change directory to scripts folder +cd scripts +chmod +x *.sh + +# Execute necessary scripts ./init_pwd.sh -./env_check.sh; -cd .. ; +./env_check.sh + +# Go back to the previous directory +cd .. +# Check if docker-compose command is available if command -v docker-compose &> /dev/null then - docker-compose up -d ; + docker-compose up -d else - docker compose up -d ; + docker compose up -d fi +# Change directory to scripts folder again +cd scripts -cd scripts ; -./docker_check_service.sh +# Check docker services +./docker_check_service.sh \ No newline at end of file diff --git a/internal/msgtransfer/persistent_msg_handler.go b/internal/msgtransfer/persistent_msg_handler.go index eaf47dee9..9ee0f5393 100644 --- a/internal/msgtransfer/persistent_msg_handler.go +++ b/internal/msgtransfer/persistent_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/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go index 8586ac338..4a6758cba 100644 --- a/pkg/common/db/relation/mysql_init.go +++ b/pkg/common/db/relation/mysql_init.go @@ -34,7 +34,7 @@ const ( maxRetry = 100 //number of retries ) -//newMysqlGormDB Initialize the database connection +// 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") @@ -84,7 +84,7 @@ func newMysqlGormDB() (*gorm.DB, error) { return db, nil } -//connectToDatabase Connection retry for mysql +// connectToDatabase Connection retry for mysql func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) { var db *gorm.DB var err error diff --git a/pkg/common/db/unrelation/extend_msg.go b/pkg/common/db/unrelation/extend_msg.go index 17e0b2e19..6f09247bc 100644 --- a/pkg/common/db/unrelation/extend_msg.go +++ b/pkg/common/db/unrelation/extend_msg.go @@ -152,7 +152,7 @@ func (e *ExtendMsgSetMongoDriver) InsertOrUpdateReactionExtendMsgSet( return utils.Wrap(err, "") } if set == nil { - return errors.New(fmt.Sprintf("conversationID %s has no set", conversationID)) + return fmt.Errorf("conversationID %s has no set", conversationID) } _, err = e.ExtendMsgSetCollection.UpdateOne( ctx, @@ -181,7 +181,7 @@ func (e *ExtendMsgSetMongoDriver) DeleteReactionExtendMsgSet( return utils.Wrap(err, "") } if set == nil { - return errors.New(fmt.Sprintf("conversationID %s has no set", conversationID)) + return fmt.Errorf("conversationID %s has no set", conversationID) } _, err = e.ExtendMsgSetCollection.UpdateOne( ctx, @@ -226,5 +226,5 @@ func (e *ExtendMsgSetMongoDriver) TakeExtendMsg( if v, ok := setList[0].ExtendMsgs[clientMsgID]; ok { return &v, nil } - return nil, errors.New(fmt.Sprintf("cant find client msg id: %s", clientMsgID)) + return nil, fmt.Errorf("cant find client msg id: %s", clientMsgID) } diff --git a/pkg/common/kafka/consumer_group.go b/pkg/common/kafka/consumer_group.go index 2e0155f67..0f801e8b2 100644 --- a/pkg/common/kafka/consumer_group.go +++ b/pkg/common/kafka/consumer_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 kafka import ( diff --git a/pkg/utils/strings.go b/pkg/utils/strings.go index 106c6a112..641c43e9f 100644 --- a/pkg/utils/strings.go +++ b/pkg/utils/strings.go @@ -1,3 +1,17 @@ +// Copyright © 2023 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES 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/time_format.go b/pkg/utils/time_format.go index af1be7f04..9278a58ef 100644 --- a/pkg/utils/time_format.go +++ b/pkg/utils/time_format.go @@ -1,3 +1,17 @@ +// Copyright © 2023 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES 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/build_all_service.sh b/scripts/build_all_service.sh index ebbc02dfa..5d8592eca 100755 --- a/scripts/build_all_service.sh +++ b/scripts/build_all_service.sh @@ -53,10 +53,12 @@ fi #Include shell font styles and some basic information OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +echo "PWD=================>$PWD" + #Include shell font styles and some basic information -source $OPENIM_ROOT/scripts/style_info.sh -source $OPENIM_ROOT/scripts/path_info.sh -source $OPENIM_ROOT/scripts/function.sh +source ./style_info.sh +source ./path_info.sh +source ./function.sh cd $OPENIM_ROOT diff --git a/scripts/path_info.sh b/scripts/path_info.sh index 595137566..bff87ed83 100755 --- a/scripts/path_info.sh +++ b/scripts/path_info.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. + # Determine the architecture and version architecture=$(uname -m) version=$(uname -s | tr '[:upper:]' '[:lower:]') diff --git a/scripts/style_info.sh b/scripts/style_info.sh index 631f8a5f1..3c747dd0c 100755 --- a/scripts/style_info.sh +++ b/scripts/style_info.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. + COLOR_SUFFIX="\033[0m" # End all colors and special effects