Merge branch 'OpenIMSDK:main' into main

pull/518/head
pluto 1 year ago committed by GitHub
commit 1fe6423593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,8 +17,8 @@ name: OpenKF golangci-lint
on: on:
push: push:
branches: [main] branches: [main]
pull_request: # pull_request:
branches: [main] # branches: [main]
jobs: jobs:
golangci: golangci:
name: lint name: lint

@ -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 name: OpenIM CI
on: on:
# main branch
push: push:
branches: branches:
- main - main
paths-ignore:
- "docs/**"
- "README.md"
- "README_zh-CN.md"
- "CONTRIBUTING.md"
pull_request: pull_request:
branches: 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 }} name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
environment: environment:
name: openimci name: openim
strategy: strategy:
matrix: matrix:
go_version: ['1.18', '1.19', '1.20'] go_version: ["1.18","1.19","1.20"]
os: [ubuntu-latest, macOS-latest] os: [ubuntu-latest]
steps: steps:
- name: Set up Go ${{ matrix.go_version }} - name: Set up Go ${{ matrix.go_version }}
@ -32,41 +58,95 @@ jobs:
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Run go modules Tidy - name: Run go modules tidy
run: | run: |
make tidy make tidy
- name: Generate all necessary files, such as error code files - name: Run go format
run: | run: |
make gen make format
echo "Run go format successfully"
- name: Check syntax and styling of go sources # - name: Generate all necessary files, such as error code files
run: | # run: |
make lint # make generate
- name: Run unit test and get test coverage # - name: Check syntax and styling of go sources
run: | # run: |
make cover # set -e
# make lint
# - name: Run unit test and get test coverage
# run: |
# make cover
- name: Build source code for host platform - name: Build source code for host platform
run: | run: |
make build make multiarch
echo "Build source code for host platform successfully"
- name: Collect Test Coverage File # - name: Collect Test Coverage File
uses: actions/upload-artifact@v1.0.0 # uses: actions/upload-artifact@v1.0.0
with: # with:
name: main-output # name: main-output
path: _output/coverage.out # path: _output/tmp/coverage.out
- name: Set up Docker Buildx # - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 # uses: docker/setup-buildx-action@v1
- name: Login to DockerHub # lint:
uses: docker/login-action@v1 # runs-on: ubuntu-20.04
with: # steps:
username: ${{ env.DOCKERHUB_USERNAME }} # - name: Checkout
password: ${{ secrets.DOCKERHUB_TOKEN }} # uses: actions/checkout@v3
# with:
# fetch-depth: 0
- name: Build docker images for host arch and push images to registry # - name: Set up Go
run: | # uses: actions/setup-go@v3
make push # with:
# go-version: ${{ env.GO_VERSION }}
# - name: golangci-lint
# uses: golangci/golangci-lint-action@v3
# with:
# version: ${{ env.GOLANGCI_VERSION }}
# 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

@ -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"

@ -8,9 +8,6 @@ on:
push: push:
branches: branches:
- main - main
pull_request:
branches:
- main
workflow_dispatch: workflow_dispatch:
jobs: jobs:
@ -25,7 +22,6 @@ jobs:
with: with:
GH_INSTALLATION_TOKEN: "${{ secrets.BOT_GITHUB_TOKEN }}" GH_INSTALLATION_TOKEN: "${{ secrets.BOT_GITHUB_TOKEN }}"
CONFIG_PATH: .github/sync.yml CONFIG_PATH: .github/sync.yml
GH_PAT: "${{ secrets.BOT_GITHUB_TOKEN }}"
ORIGINAL_MESSAGE: true ORIGINAL_MESSAGE: true
SKIP_PR: true SKIP_PR: true
COMMIT_EACH_FILE: false COMMIT_EACH_FILE: false

@ -1,9 +1,11 @@
<h1 align="center" style="border-bottom: none"> <p align="center">
<b> <a href="https://www.openim.online">
<a href="https://doc.rentsoft.cn/">Open IM Server</a><br> <img src="./assets/logo-gif/openim-logo.gif" width="60%" height="30%"/>
</b> </a>
⭐️ Open source Instant Messaging Server ⭐️ <br> </p>
</h1> <h3 align="center" style="border-bottom: none">
⭐️ Open source Instant Messaging Server ⭐️ <br>
<h3>
<p align=center> <p align=center>

@ -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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@ -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).

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

@ -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).

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

@ -43,7 +43,6 @@ require (
github.com/go-sql-driver/mysql v1.6.0 github.com/go-sql-driver/mysql v1.6.0
github.com/go-zookeeper/zk v1.0.3 github.com/go-zookeeper/zk v1.0.3
github.com/redis/go-redis/v9 v9.0.5 github.com/redis/go-redis/v9 v9.0.5
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
) )
require ( require (

@ -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/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 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= 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 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 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= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

@ -1,27 +1,39 @@
#!/usr/bin/env bash #!/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 echo $internet_ip
# Load environment variables from .env file
source .env source .env
echo $MINIO_ENDPOINT 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 fi
cd scripts ; # Change directory to scripts folder
chmod +x *.sh ; cd scripts
chmod +x *.sh
# Execute necessary scripts
./init_pwd.sh ./init_pwd.sh
./env_check.sh; ./env_check.sh
cd .. ;
# Go back to the previous directory
cd ..
# Check if docker-compose command is available
if command -v docker-compose &> /dev/null if command -v docker-compose &> /dev/null
then then
docker-compose up -d ; docker-compose up -d
else else
docker compose up -d ; docker compose up -d
fi fi
# Change directory to scripts folder again
cd scripts
cd scripts ; # Check docker services
./docker_check_service.sh ./docker_check_service.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.
package msgtransfer package msgtransfer
import ( import (

@ -34,7 +34,7 @@ const (
maxRetry = 100 //number of retries maxRetry = 100 //number of retries
) )
//newMysqlGormDB Initialize the database connection // newMysqlGormDB Initialize the database connection
func newMysqlGormDB() (*gorm.DB, error) { func newMysqlGormDB() (*gorm.DB, error) {
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local", 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") 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 return db, nil
} }
//connectToDatabase Connection retry for mysql // connectToDatabase Connection retry for mysql
func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) { func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
var db *gorm.DB var db *gorm.DB
var err error var err error

@ -152,7 +152,7 @@ func (e *ExtendMsgSetMongoDriver) InsertOrUpdateReactionExtendMsgSet(
return utils.Wrap(err, "") return utils.Wrap(err, "")
} }
if set == nil { 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( _, err = e.ExtendMsgSetCollection.UpdateOne(
ctx, ctx,
@ -181,7 +181,7 @@ func (e *ExtendMsgSetMongoDriver) DeleteReactionExtendMsgSet(
return utils.Wrap(err, "") return utils.Wrap(err, "")
} }
if set == nil { 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( _, err = e.ExtendMsgSetCollection.UpdateOne(
ctx, ctx,
@ -226,5 +226,5 @@ func (e *ExtendMsgSetMongoDriver) TakeExtendMsg(
if v, ok := setList[0].ExtendMsgs[clientMsgID]; ok { if v, ok := setList[0].ExtendMsgs[clientMsgID]; ok {
return &v, nil 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)
} }

@ -1,3 +1,17 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES 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 package kafka
import ( import (

@ -1,3 +1,17 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES 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 package utils
import ( import (

@ -1,3 +1,17 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES 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 package utils
import ( import (

@ -53,10 +53,12 @@ fi
#Include shell font styles and some basic information #Include shell font styles and some basic information
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
echo "PWD=================>$PWD"
#Include shell font styles and some basic information #Include shell font styles and some basic information
source $OPENIM_ROOT/scripts/style_info.sh source ./style_info.sh
source $OPENIM_ROOT/scripts/path_info.sh source ./path_info.sh
source $OPENIM_ROOT/scripts/function.sh source ./function.sh
cd $OPENIM_ROOT cd $OPENIM_ROOT

@ -1,4 +1,18 @@
#!/usr/bin/env bash #!/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 # Determine the architecture and version
architecture=$(uname -m) architecture=$(uname -m)
version=$(uname -s | tr '[:upper:]' '[:lower:]') version=$(uname -s | tr '[:upper:]' '[:lower:]')

@ -1,4 +1,18 @@
#!/usr/bin/env bash #!/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 COLOR_SUFFIX="\033[0m" # End all colors and special effects

Loading…
Cancel
Save