mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-21 01:09:01 +08:00
Compare commits
66 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5742932df5 | |||
| 1f25f7dc78 | |||
| a38dfb9a1d | |||
| 391e3ea10c | |||
| e2efd7abdd | |||
| c3e721f145 | |||
| 0f2d9308e8 | |||
| 36bb68e1e6 | |||
| d5996217a2 | |||
| 2bc8390e9f | |||
| 507f31ae79 | |||
| 292ce95abf | |||
| a7a880787b | |||
| ab91f24fd1 | |||
| 31611f5657 | |||
| e3280e8c65 | |||
| c7bca82675 | |||
| fd894c3d83 | |||
| 405776d321 | |||
| c47e073db8 | |||
| 30c0decaeb | |||
| f73b653d0e | |||
| 97e558eb92 | |||
| 714d5036df | |||
| ca543df323 | |||
| 5424129163 | |||
| d111769a93 | |||
| c534b84dd2 | |||
| 202b1dfdae | |||
| 2518985e43 | |||
| 90de0b730d | |||
| 92d8c65aa0 | |||
| 12e0afb4e3 | |||
| f4c464003c | |||
| 0dcdcbed4b | |||
| 5aab77d7af | |||
| 542fbec18e | |||
| fbbaacc27a | |||
| 186e83754b | |||
| 2d035f0029 | |||
| d9e4899da5 | |||
| fabdd4b313 | |||
| e13f7ebfe3 | |||
| b34f667a5f | |||
| ec0b9c54e1 | |||
| 995e68dcae | |||
| 5dd59a51d9 | |||
| 3640499340 | |||
| 7327f11794 | |||
| 810b1ccbb3 | |||
| 4423986176 | |||
| 666cd1e8a8 | |||
| 4bc35abf04 | |||
| f1c83e9d05 | |||
| 24ce8e3a2e | |||
| ebd4877158 | |||
| 802c0a5d0c | |||
| d36b7744de | |||
| 4b62802566 | |||
| 44c537c295 | |||
| f556139b49 | |||
| 0a2f20281e | |||
| 0414671efd | |||
| fd2b384253 | |||
| de5d006344 | |||
| e59bf2bfe8 |
+1
-1
@@ -15,7 +15,7 @@ CHANGELOG/
|
|||||||
# LICENSE
|
# LICENSE
|
||||||
|
|
||||||
# Ignore testing and linting configuration
|
# Ignore testing and linting configuration
|
||||||
.golangci.yml
|
scripts/golangci.yml
|
||||||
|
|
||||||
# Ignore deployment-related files
|
# Ignore deployment-related files
|
||||||
docker-compose.yaml
|
docker-compose.yaml
|
||||||
|
|||||||
@@ -1,19 +1,5 @@
|
|||||||
# Copyright © 2023 OpenIM. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
USER=root
|
USER=root
|
||||||
PASSWORD=openIM123
|
PASSWORD=openIM123
|
||||||
MINIO_ENDPOINT=http://127.0.0.1:10005
|
MINIO_ENDPOINT=http://127.0.0.1:10005
|
||||||
API_URL=http://127.0.0.1:10002
|
API_URL=http://127.0.0.1:10002/object/
|
||||||
DATA_DIR=./
|
DATA_DIR=./
|
||||||
+6
-6
@@ -75,15 +75,15 @@ OpenIMSDK/OpenKF:
|
|||||||
dest: .github/.codecov.yml
|
dest: .github/.codecov.yml
|
||||||
replace: false
|
replace: false
|
||||||
|
|
||||||
openim-docker/openim-docker:
|
openim-sigs/openim-docker:
|
||||||
- source: ./config
|
- source: ./config
|
||||||
dest: ./openim-server/main/config
|
dest: ./openim-server/config
|
||||||
replace: true
|
replace: true
|
||||||
- source: ./docs
|
- source: ./docs
|
||||||
dest: ./openim-server/main/docs
|
dest: ./openim-server/docs
|
||||||
replace: true
|
replace: true
|
||||||
- source: ./scripts
|
- source: ./scripts
|
||||||
dest: ./openim-server/main/scripts
|
dest: ./openim-server/scripts
|
||||||
replace: true
|
replace: true
|
||||||
|
|
||||||
group:
|
group:
|
||||||
@@ -97,7 +97,7 @@ group:
|
|||||||
OpenIMSDK/community
|
OpenIMSDK/community
|
||||||
OpenIMSDK/openim-charts
|
OpenIMSDK/openim-charts
|
||||||
OpenIMSDK/openim-sdk-cpp@main
|
OpenIMSDK/openim-sdk-cpp@main
|
||||||
files:
|
files:
|
||||||
- source: LICENSE
|
- source: LICENSE
|
||||||
dest: LICENSE
|
dest: LICENSE
|
||||||
replace: false
|
replace: false
|
||||||
@@ -127,4 +127,4 @@ group:
|
|||||||
replace: false
|
replace: false
|
||||||
- source: ./scripts/githooks/
|
- source: ./scripts/githooks/
|
||||||
dest: ./scripts/githooks/
|
dest: ./scripts/githooks/
|
||||||
replace: true
|
replace: true
|
||||||
@@ -26,8 +26,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
create-pr:
|
create-pr:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event.pull_request.base.ref == 'main'
|
if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true
|
||||||
# && github.event.pull_request.merged == true
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|||||||
@@ -51,4 +51,23 @@ jobs:
|
|||||||
echo "OWNER: $OWNER"
|
echo "OWNER: $OWNER"
|
||||||
echo "REPO: $REPO"
|
echo "REPO: $REPO"
|
||||||
git clone -b develop https://github.com/${OWNER}/${REPO}.git; cd ${REPO}
|
git clone -b develop https://github.com/${OWNER}/${REPO}.git; cd ${REPO}
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
|
|
||||||
|
# - name: deploy # Deployment
|
||||||
|
# run: |
|
||||||
|
# ssh work@182.92.xxx.xxx "
|
||||||
|
# # 【Attention】Log in with the 'work' account, manually create /home/work/imooc-lego directory
|
||||||
|
# # Then git clone https://username:password@github.com/imooc-lego/biz-editor-server.git -b dev (private repository, use GitHub username and password)
|
||||||
|
# # Remember to delete origin to avoid exposing GitHub password
|
||||||
|
# cd /home/work/imooc-lego/biz-editor-server;
|
||||||
|
# git remote add origin https://openimbot:${{secrets.WFP_PASSWORD}}@github.com/OpenIMSDK/open-im-server.git;
|
||||||
|
# git checkout dev;
|
||||||
|
# git pull origin dev; # Download the latest code again
|
||||||
|
# git remote remove origin; # Remove origin to avoid exposing GitHub password
|
||||||
|
# # Start docker
|
||||||
|
# docker-compose build editor-server; # Same as the service name in docker-compose.yml
|
||||||
|
# docker-compose up -d;
|
||||||
|
# "
|
||||||
|
# - name: delete ssh key # Delete ssh key
|
||||||
|
# run: rm -rf ~/.ssh/id_rsa
|
||||||
@@ -12,33 +12,5 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
name: e2e
|
# name: OpenIM e2e Test
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
schedule:
|
|
||||||
# run e2e test every 4 hours
|
|
||||||
- cron: 0 */4 * * *
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Test
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
env:
|
|
||||||
GO111MODULE: on
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- name: Set up Go 1.21
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.21
|
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Create e2e test
|
|
||||||
run: |
|
|
||||||
echo "...test e2e"
|
|
||||||
@@ -18,6 +18,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
jobs:
|
jobs:
|
||||||
golangci:
|
golangci:
|
||||||
name: lint
|
name: lint
|
||||||
@@ -26,25 +27,25 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '1.21'
|
go-version: '1.20'
|
||||||
cache: false
|
cache: false
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v3.7.0
|
uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
with:
|
||||||
# Require: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
# 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.54
|
version: v1.53
|
||||||
|
|
||||||
# Optional: working directory, useful for monorepos
|
# Optional: working directory, useful for monorepos
|
||||||
# working-directory: server
|
working-directory: server
|
||||||
|
|
||||||
# Optional: golangci-lint command line arguments.
|
# Optional: golangci-lint command line arguments.
|
||||||
#
|
#
|
||||||
# Note: by default the `.golangci.yml` file should be at the root of the repository.
|
# 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=`
|
# The location of the configuration file can be changed by using `--config=`
|
||||||
# args: --timeout=30m --config=/scripts/.golangci.yml --issues-exit-code=0
|
args: --timeout=30m --config=/scripts/golangci.yml # --issues-exit-code=0
|
||||||
|
|
||||||
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
||||||
only-new-issues: true
|
# only-new-issues: true
|
||||||
|
|
||||||
# Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
|
# Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
|
||||||
# install-mode: "goinstall"
|
install-mode: "goinstall"
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/first-interaction@v1.1.1
|
- uses: actions/first-interaction@main
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.REDBOT_GITHUB_TOKEN }}
|
repo-token: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||||
issue-message: |
|
issue-message: |
|
||||||
Hello! Thank you for filing an issue.
|
Hello! Thank you for filing an issue.
|
||||||
|
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ env:
|
|||||||
GO_VERSION: "1.19"
|
GO_VERSION: "1.19"
|
||||||
GOLANGCI_VERSION: "v1.50.1"
|
GOLANGCI_VERSION: "v1.50.1"
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
openim:
|
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 }}
|
||||||
permissions:
|
permissions:
|
||||||
|
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
|
||||||
contents: write
|
contents: write
|
||||||
environment:
|
environment:
|
||||||
name: openim
|
name: openim
|
||||||
@@ -52,63 +52,102 @@ jobs:
|
|||||||
os: [ubuntu-latest]
|
os: [ubuntu-latest]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup
|
- name: Set up Go ${{ matrix.go_version }}
|
||||||
uses: actions/checkout@v3
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
- name: Set up Go ${{ matrix.go_version }}
|
go-version: ${{ matrix.go_version }}
|
||||||
uses: actions/setup-go@v4
|
id: go
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go_version }}
|
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: Install Task
|
- name: Check out code into the Go module directory
|
||||||
uses: arduino/setup-task@v1
|
uses: actions/checkout@v3
|
||||||
with:
|
|
||||||
version: 2.x
|
|
||||||
|
|
||||||
- name: Module Operations
|
- name: Install Task
|
||||||
run: |
|
uses: arduino/setup-task@v1
|
||||||
sudo make tidy
|
with:
|
||||||
sudo make tools.verify.go-gitlint
|
version: 2.x
|
||||||
|
|
||||||
- name: Format Code
|
- name: Run go modules tidy
|
||||||
run: sudo make format
|
run: |
|
||||||
continue-on-error: true
|
sudo make tidy
|
||||||
|
sudo make tools.verify.go-gitlint
|
||||||
|
echo "Run go modules tidy successfully"
|
||||||
|
|
||||||
- name: Generate Files
|
- name: Run go format
|
||||||
run: make gen
|
run: |
|
||||||
continue-on-error: true
|
sudo make format
|
||||||
|
echo "Run go format successfully"
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Build Source
|
- name: Generate all necessary files, such as error code files
|
||||||
run: sudo make build
|
run: |
|
||||||
|
make gen
|
||||||
|
echo "Generate all necessary files successfully"
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Cleanup Build
|
- name: Build source code for host platform
|
||||||
run: sudo make clean
|
run: |
|
||||||
|
sudo make build
|
||||||
|
echo "Build source code for host platform successfully"
|
||||||
|
|
||||||
- name: Push Changes to Main
|
- name: OpenIM verify copyright
|
||||||
uses: stefanzweifel/git-auto-commit-action@v4
|
run: |
|
||||||
with:
|
sudo make verify-copyright
|
||||||
commit_message: "cicd: robot automated Change"
|
sudo make add-copyright
|
||||||
branch: main
|
echo "OpenIM verify successfully"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Set Current Directory
|
- name: Clean all build
|
||||||
id: set_directory
|
run: |
|
||||||
run: echo "::set-output name=directory::$(pwd)"
|
sudo make clean
|
||||||
continue-on-error: true
|
echo "Clean all build successfully"
|
||||||
|
|
||||||
- name: Collect and Display Test Coverage
|
- name: push OpenIM
|
||||||
id: collect_coverage
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
run: |
|
with:
|
||||||
cd ${{ steps.set_directory.outputs.directory }}
|
commit_message: "cicd: robot automated Change"
|
||||||
make cover
|
# commit_options: '--no-verify --signoff'
|
||||||
echo "::set-output name=coverage_file::./_output/tmp/coverage.out"
|
branch: main
|
||||||
echo "Test Coverage:"
|
# create_branch: true
|
||||||
cat ${{ steps.collect_coverage.outputs.coverage_file }}
|
# # Optional commit user and author settings
|
||||||
continue-on-error: true
|
# commit_user_name: kubbot # defaults to "github-actions[bot]"
|
||||||
|
# commit_user_email: 3293172751ysy@gmail.com # defaults to "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
# commit_author: Kubbot # defaults to author of the commit that triggered the run
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Commit Changes
|
||||||
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
|
with:
|
||||||
|
commit_message: "chore(fmt): robot automated format and lint Change"
|
||||||
|
commit_options: '--no-verify --signoff'
|
||||||
|
branch: main
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Set Current Directory
|
||||||
|
id: set_directory
|
||||||
|
run: |
|
||||||
|
echo "::set-output name=directory::$(pwd)"
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Collect Test Coverage File
|
||||||
|
id: collect_coverage
|
||||||
|
run: |
|
||||||
|
cd ${{ steps.set_directory.outputs.directory }}
|
||||||
|
make cover
|
||||||
|
echo "::set-output name=coverage_file::./_output/tmp/coverage.out"
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Display Test Coverage
|
||||||
|
run: |
|
||||||
|
echo "Test Coverage:"
|
||||||
|
cat ${{ steps.collect_coverage.outputs.coverage_file }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
openim-start:
|
openim-start:
|
||||||
name: Test OpenIM install/start on ${{ matrix.os }}
|
name: Teat OpenIM make install start on ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
environment:
|
environment:
|
||||||
name: openim
|
name: openim
|
||||||
@@ -117,56 +156,15 @@ jobs:
|
|||||||
go_version: ["1.21"]
|
go_version: ["1.21"]
|
||||||
os: ["ubuntu-latest"]
|
os: ["ubuntu-latest"]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout and Install OpenIM
|
- name: Set up Go ${{ matrix.go_version }}
|
||||||
uses: actions/checkout@v3
|
uses: actions/setup-go@v4
|
||||||
- name: Install Task
|
with:
|
||||||
uses: arduino/setup-task@v1
|
go-version: ${{ matrix.go_version }}
|
||||||
with:
|
id: go
|
||||||
version: 2.x
|
|
||||||
- name: Run OpenIM make install start
|
|
||||||
run: |
|
|
||||||
sudo make install
|
|
||||||
|
|
||||||
execute-scripts:
|
- name: Check out code into the Go module directory
|
||||||
name: Execute OpenIM script on ${{ matrix.os }}
|
uses: actions/checkout@v3
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
environment:
|
|
||||||
name: openim
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
go_version: ["1.20"]
|
|
||||||
os: ["ubuntu-latest"]
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Set up Go ${{ matrix.go_version }}
|
- name: Run OpenIM make install start
|
||||||
uses: actions/setup-go@v4
|
run: |
|
||||||
with:
|
sudo make install
|
||||||
go-version: ${{ matrix.go_version }}
|
|
||||||
id: go
|
|
||||||
- name: Install Task
|
|
||||||
uses: arduino/setup-task@v1
|
|
||||||
with:
|
|
||||||
version: 2.x
|
|
||||||
- name: Docker Operations
|
|
||||||
run: |
|
|
||||||
curl -o docker-compose.yaml https://raw.githubusercontent.com/OpenIMSDK/openim-docker/main/example/basic-openim-server-dependency.yml
|
|
||||||
sudo docker compose up -d
|
|
||||||
sudo sleep 60
|
|
||||||
|
|
||||||
- name: Module Operations
|
|
||||||
run: |
|
|
||||||
sudo make tidy
|
|
||||||
sudo make tools.verify.go-gitlint
|
|
||||||
|
|
||||||
- name: Build, Start and Check Services
|
|
||||||
run: |
|
|
||||||
sudo make init
|
|
||||||
sudo make build
|
|
||||||
sudo make start
|
|
||||||
sudo make check
|
|
||||||
|
|
||||||
- name: Print OpenIM Logs
|
|
||||||
run: sudo cat ./_output/logs/* 2>/dev/null
|
|
||||||
continue-on-error: true
|
|
||||||
@@ -20,13 +20,16 @@ on:
|
|||||||
- 'README.md'
|
- 'README.md'
|
||||||
- 'CONTRIBUTING.md'
|
- 'CONTRIBUTING.md'
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
workflow_dispatch:
|
pull_request:
|
||||||
schedule:
|
branches: [main]
|
||||||
- cron: '0 2 * * *'
|
paths-ignore:
|
||||||
|
- 'README.md'
|
||||||
|
- 'CONTRIBUTING.md'
|
||||||
|
- 'docs/**'
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -57,12 +60,6 @@ jobs:
|
|||||||
echo "Run go format successfully"
|
echo "Run go format successfully"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Run go lint
|
|
||||||
run: |
|
|
||||||
sudo make lint
|
|
||||||
echo "Run go lint successfully"
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Generate all necessary files, such as error code files
|
- name: Generate all necessary files, such as error code files
|
||||||
run: |
|
run: |
|
||||||
make generate
|
make generate
|
||||||
@@ -75,13 +72,18 @@ jobs:
|
|||||||
echo "Run unit test and get test coverage successfully"
|
echo "Run unit test and get test coverage successfully"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
# - name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
# uses: github/codeql-action/init@v2
|
uses: github/codeql-action/init@v2
|
||||||
# with:
|
with:
|
||||||
# languages: go
|
languages: go
|
||||||
|
|
||||||
# - name: Perform CodeQL Analysis
|
- name: Build source code for host platform
|
||||||
# uses: github/codeql-action/analyze@v2
|
run: |
|
||||||
|
sudo make build
|
||||||
|
echo "Build source code for host platform successfully"
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v2
|
||||||
|
|
||||||
- name: OpenIM verify copyright
|
- name: OpenIM verify copyright
|
||||||
run: |
|
run: |
|
||||||
@@ -90,33 +92,23 @@ jobs:
|
|||||||
echo "OpenIM verify successfully"
|
echo "OpenIM verify successfully"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
# - name: Commit code
|
- name: Commit code
|
||||||
# run: |
|
run: |
|
||||||
# git add .
|
git add .
|
||||||
# git commit -m "cicd: bump League Patch to cicd/patch-${{ github.event.number }}"
|
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v5
|
uses: peter-evans/create-pull-request@v5
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.BOT_GITHUB_TOKEN }}
|
|
||||||
commit-message: "cicd: bump League Patch to cicd/patch-${{ github.event.number }}"
|
commit-message: "cicd: bump League Patch to cicd/patch-${{ github.event.number }}"
|
||||||
title: Bump League Patch to cicd/patch-${{ github.event.number }}
|
title: Bump League Patch to cicd/patch-${{ github.event.number }}
|
||||||
author: kubbot <kubbot@3293172751ysy@gmail.com>
|
|
||||||
signoff: false
|
|
||||||
draft: false
|
|
||||||
branch: "cicd/patch-${{ github.event.number }}"
|
|
||||||
assignees: cubxxw
|
|
||||||
reviewers: cubxxw
|
|
||||||
delete-branch: true
|
|
||||||
body: |
|
body: |
|
||||||
Review criteria:
|
Review criteria:
|
||||||
|
|
||||||
- [ ] Disenchanter can connect and issue actions
|
- [ ] Disenchanter can connect and issue actions
|
||||||
|
|
||||||
This is an automated PR. @ ${{ github.actor }}
|
This is an automated PR.
|
||||||
<sub>[workflow](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/.github/workflows/pull-request.yml).</sub>
|
<sub>[workflow](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/.github/workflows/pull-request.yml).</sub>
|
||||||
base: main
|
base: main
|
||||||
labels: |
|
branch: cicd/patch-${{ github.event.number }}
|
||||||
kind/documentation
|
labels: kind/documentation, area/test, ok-to-test
|
||||||
enhancement
|
token: ${{ secrets.REDBOT_GITHUB_TOKEN }}
|
||||||
report
|
|
||||||
@@ -18,11 +18,11 @@ on:
|
|||||||
push:
|
push:
|
||||||
# branches to consider in the event; optional, defaults to all
|
# branches to consider in the event; optional, defaults to all
|
||||||
branches:
|
branches:
|
||||||
- main
|
- master
|
||||||
# pull_request event is required only for autolabeler
|
# pull_request event is required only for autolabeler
|
||||||
pull_request:
|
pull_request:
|
||||||
# Only following types are handled by the action, but one can default to all as well
|
# Only following types are handled by the action, but one can default to all as well
|
||||||
# types: [opened, reopened, synchronize]
|
types: [opened, reopened, synchronize]
|
||||||
# pull_request_target event is required for autolabeler to support PRs from forks
|
# pull_request_target event is required for autolabeler to support PRs from forks
|
||||||
# pull_request_target:
|
# pull_request_target:
|
||||||
# types: [opened, reopened, synchronize]
|
# types: [opened, reopened, synchronize]
|
||||||
|
|||||||
@@ -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.
|
|
||||||
|
|
||||||
name: OpenIM executes the script validation code
|
|
||||||
|
|
||||||
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/**"
|
|
||||||
|
|
||||||
env:
|
|
||||||
GO_VERSION: "1.19"
|
|
||||||
GOLANGCI_VERSION: "v1.50.1"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
openim:
|
|
||||||
name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }}
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
environment:
|
|
||||||
name: openim
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
go_version: ["1.21"]
|
|
||||||
os: [ubuntu-latest]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Setup
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: In ${{ matrix.os }} Execute the script validation code
|
|
||||||
uses: actions/setup-go@v4
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go_version }}
|
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: scripts validation
|
|
||||||
run: |
|
|
||||||
sudo make verify
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: verify format
|
|
||||||
run: |
|
|
||||||
sudo make format
|
|
||||||
|
|
||||||
- name: verify license
|
|
||||||
run: |
|
|
||||||
sudo make verify-copyright
|
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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 Scripts Execute CI
|
||||||
|
|
||||||
|
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@v3
|
||||||
|
|
||||||
|
- name: Download Docker Compose
|
||||||
|
run: |
|
||||||
|
curl -o docker-compose.yaml https://gist.githubusercontent.com/cubxxw/b1d5cbd2edfa23fee911118aa3e8249e/raw/openim-server.sh
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Start Docker Compose
|
||||||
|
run: |
|
||||||
|
sudo docker compose up -d
|
||||||
|
sudo sleep 60
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Stop all services
|
||||||
|
run: |
|
||||||
|
sudo chmod +x ./scripts/stop-all.sh
|
||||||
|
sudo ./scripts/stop-all.sh
|
||||||
|
sudo cat logs/openIM.log 2>/dev/null
|
||||||
|
shell: bash
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Build all services
|
||||||
|
run: |
|
||||||
|
sudo chmod +x ./scripts/build-all-service.sh
|
||||||
|
sudo ./scripts/build-all-service.sh
|
||||||
|
sudo cat logs/openIM.log 2>/dev/null
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Start all services
|
||||||
|
run: |
|
||||||
|
sudo chmod +x ./scripts/start-all.sh
|
||||||
|
sudo ./scripts/start-all.sh
|
||||||
|
sudo cat logs/openIM.log 2>/dev/null
|
||||||
|
continue-on-error: true
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Check all services
|
||||||
|
run: |
|
||||||
|
sudo chmod +x ./scripts/check-all.sh
|
||||||
|
sudo ./scripts/check-all.sh
|
||||||
|
sudo cat logs/openIM.log 2>/dev/null
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Print openIM.log
|
||||||
|
run: |
|
||||||
|
sudo cat logs/* 2>/dev/null
|
||||||
|
sudo cat logs/* 2>/dev/null >> "$GITHUB_OUTPUT"
|
||||||
|
shell: bash
|
||||||
|
continue-on-error: true
|
||||||
@@ -6,10 +6,6 @@
|
|||||||
name: Synchronize kubecub public code to other repositories
|
name: Synchronize kubecub public code to other repositories
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
|
||||||
- scripts/*
|
|
||||||
- docs/*
|
|
||||||
- config/*
|
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|||||||
@@ -30,12 +30,6 @@ bin/
|
|||||||
output/
|
output/
|
||||||
_output/
|
_output/
|
||||||
|
|
||||||
### OpenIM Config ###
|
|
||||||
config/config.yaml
|
|
||||||
./config/config.yaml
|
|
||||||
.env
|
|
||||||
./.env
|
|
||||||
|
|
||||||
### OpenIM deploy ###
|
### OpenIM deploy ###
|
||||||
deploy/openim_demo
|
deploy/openim_demo
|
||||||
deploy/openim-api
|
deploy/openim-api
|
||||||
@@ -163,7 +157,6 @@ vendor/
|
|||||||
|
|
||||||
# Go workspace file
|
# Go workspace file
|
||||||
# go.work
|
# go.work
|
||||||
go.work.sum
|
|
||||||
|
|
||||||
### JetBrains ###
|
### JetBrains ###
|
||||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
@@ -399,5 +392,3 @@ Sessionx.vim
|
|||||||
# End of https://www.toptal.com/developers/gitignore/api/go,git,vim,tags,test,emacs,backup,jetbrains
|
# End of https://www.toptal.com/developers/gitignore/api/go,git,vim,tags,test,emacs,backup,jetbrains
|
||||||
.idea
|
.idea
|
||||||
dist/
|
dist/
|
||||||
.env
|
|
||||||
config/config.yaml
|
|
||||||
|
|||||||
+50
-16
@@ -1,22 +1,53 @@
|
|||||||
# Version logging for OpenIM
|
# Version logging for OpenIM:v2.0
|
||||||
|
|
||||||
|
> **Note**:
|
||||||
|
> Deprecated version logging for OpenIM, please refer to [CHANGELOG.md](../CHANGELOG.md)
|
||||||
|
|
||||||
<!-- BEGIN MUNGE: GENERATED_TOC -->
|
<!-- BEGIN MUNGE: GENERATED_TOC -->
|
||||||
|
|
||||||
|
- [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)
|
||||||
|
|
||||||
<!-- END MUNGE: GENERATED_TOC -->
|
<!-- END MUNGE: GENERATED_TOC -->
|
||||||
|
|
||||||
|
|
||||||
<a name="unreleased"></a>
|
<a name="unreleased"></a>
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
|
||||||
<a name="v2.0.10"></a>
|
<a name="v2.0.10"></a>
|
||||||
|
|
||||||
## [v2.0.10] - 2022-05-13
|
## [v2.0.10] - 2022-05-13
|
||||||
|
|
||||||
<a name="v2.0.9"></a>
|
<a name="v2.0.9"></a>
|
||||||
|
|
||||||
## [v2.0.9] - 2022-04-29
|
## [v2.0.9] - 2022-04-29
|
||||||
|
|
||||||
### Reverts
|
### Reverts
|
||||||
|
|
||||||
- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
|
- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
|
||||||
|
|
||||||
### Pull Requests
|
### Pull Requests
|
||||||
|
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
@@ -26,38 +57,53 @@
|
|||||||
|
|
||||||
|
|
||||||
<a name="v2.0.8"></a>
|
<a name="v2.0.8"></a>
|
||||||
|
|
||||||
## [v2.0.8] - 2022-04-24
|
## [v2.0.8] - 2022-04-24
|
||||||
|
|
||||||
### Pull Requests
|
### Pull Requests
|
||||||
|
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
|
|
||||||
|
|
||||||
<a name="v2.0.7"></a>
|
<a name="v2.0.7"></a>
|
||||||
|
|
||||||
## [v2.0.7] - 2022-04-08
|
## [v2.0.7] - 2022-04-08
|
||||||
|
|
||||||
### Pull Requests
|
### Pull Requests
|
||||||
|
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
|
|
||||||
|
|
||||||
<a name="v2.0.6"></a>
|
<a name="v2.0.6"></a>
|
||||||
|
|
||||||
## [v2.0.6] - 2022-04-01
|
## [v2.0.6] - 2022-04-01
|
||||||
|
|
||||||
### Pull Requests
|
### Pull Requests
|
||||||
|
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
|
|
||||||
|
|
||||||
<a name="v2.0.5"></a>
|
<a name="v2.0.5"></a>
|
||||||
|
|
||||||
## [v2.0.5] - 2022-03-24
|
## [v2.0.5] - 2022-03-24
|
||||||
|
|
||||||
<a name="v2.04"></a>
|
<a name="v2.04"></a>
|
||||||
|
|
||||||
## [v2.04] - 2022-03-18
|
## [v2.04] - 2022-03-18
|
||||||
|
|
||||||
<a name="v2.0.3"></a>
|
<a name="v2.0.3"></a>
|
||||||
|
|
||||||
## [v2.0.3] - 2022-03-11
|
## [v2.0.3] - 2022-03-11
|
||||||
|
|
||||||
<a name="v2.0.2"></a>
|
<a name="v2.0.2"></a>
|
||||||
|
|
||||||
## [v2.0.2] - 2022-03-04
|
## [v2.0.2] - 2022-03-04
|
||||||
|
|
||||||
### Pull Requests
|
### Pull Requests
|
||||||
|
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
- Merge branch 'tuoyun'
|
- Merge branch 'tuoyun'
|
||||||
@@ -65,23 +111,11 @@
|
|||||||
|
|
||||||
|
|
||||||
<a name="v2.0.1"></a>
|
<a name="v2.0.1"></a>
|
||||||
|
|
||||||
## [v2.0.1] - 2022-02-25
|
## [v2.0.1] - 2022-02-25
|
||||||
|
|
||||||
<a name="v2.0.0"></a>
|
<a name="v2.0.0"></a>
|
||||||
|
|
||||||
## v2.0.0 - 2022-02-23
|
## v2.0.0 - 2022-02-23
|
||||||
|
|
||||||
### Reverts
|
### Reverts
|
||||||
- friend modify
|
|
||||||
- update
|
|
||||||
|
|
||||||
|
|
||||||
[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.10...HEAD
|
|
||||||
[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
|
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
# Version logging for OpenIM
|
|
||||||
|
|
||||||
<!-- BEGIN MUNGE: GENERATED_TOC -->
|
|
||||||
|
|
||||||
<!-- END MUNGE: GENERATED_TOC -->
|
|
||||||
|
|
||||||
<a name="unreleased"></a>
|
|
||||||
## [Unreleased]
|
|
||||||
|
|
||||||
|
|
||||||
<a name="v3.2.2-beta.3"></a>
|
|
||||||
## [v3.2.2-beta.3] - 2023-08-22
|
|
||||||
|
|
||||||
<a name="v3.2.2-beta.2"></a>
|
|
||||||
## [v3.2.2-beta.2] - 2023-08-21
|
|
||||||
|
|
||||||
<a name="v3.2.2-beta.1"></a>
|
|
||||||
## [v3.2.2-beta.1] - 2023-08-19
|
|
||||||
|
|
||||||
<a name="v3.2.0"></a>
|
|
||||||
## [v3.2.0] - 2023-08-18
|
|
||||||
|
|
||||||
<a name="v3.2.0-rc.0"></a>
|
|
||||||
## [v3.2.0-rc.0] - 2023-08-17
|
|
||||||
|
|
||||||
<a name="v3.2.2-beta.0"></a>
|
|
||||||
## [v3.2.2-beta.0] - 2023-08-17
|
|
||||||
|
|
||||||
<a name="v3.2.0-alpha.0"></a>
|
|
||||||
## v3.2.0-alpha.0 - 2023-08-16
|
|
||||||
### 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/v3.2.2-beta.3...HEAD
|
|
||||||
[v3.2.2-beta.3]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v3.2.2-beta.2...v3.2.2-beta.3
|
|
||||||
[v3.2.2-beta.2]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v3.2.2-beta.1...v3.2.2-beta.2
|
|
||||||
[v3.2.2-beta.1]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v3.2.0...v3.2.2-beta.1
|
|
||||||
[v3.2.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v3.2.0-rc.0...v3.2.0
|
|
||||||
[v3.2.0-rc.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v3.2.2-beta.0...v3.2.0-rc.0
|
|
||||||
[v3.2.2-beta.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v3.2.0-alpha.0...v3.2.2-beta.0
|
|
||||||
+3
-5
@@ -10,7 +10,7 @@ ENV GOPROXY=$GOPROXY
|
|||||||
# Set up the working directory
|
# Set up the working directory
|
||||||
WORKDIR /openim/openim-server
|
WORKDIR /openim/openim-server
|
||||||
|
|
||||||
COPY go.mod go.sum go.work ./
|
COPY go.mod go.sum go.work go.work.sum ./
|
||||||
#RUN go mod download
|
#RUN go mod download
|
||||||
|
|
||||||
# Copy all files to the container
|
# Copy all files to the container
|
||||||
@@ -19,13 +19,11 @@ ADD . .
|
|||||||
RUN make clean
|
RUN make clean
|
||||||
RUN make build
|
RUN make build
|
||||||
|
|
||||||
FROM ghcr.io/openim-sigs/openim-ubuntu-image:latest
|
FROM ghcr.io/openim-sigs/openim-bash-image:latest
|
||||||
|
|
||||||
WORKDIR ${SERVER_WORKDIR}
|
WORKDIR ${SERVER_WORKDIR}
|
||||||
|
|
||||||
# Copy scripts and binary files to the production image
|
# Copy scripts and binary files to the production image
|
||||||
COPY --from=builder ${OPENIM_SERVER_BINDIR} /openim/openim-server/_output/bin
|
COPY --from=builder ${OPENIM_SERVER_BINDIR} /openim/openim-server/_output/bin
|
||||||
COPY --from=builder ${OPENIM_SERVER_CMDDIR} /openim/openim-server/scripts
|
|
||||||
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
|
|
||||||
|
|
||||||
CMD ["/openim/openim-server/scripts/docker-start-all.sh"]
|
CMD ["bash","-c","${OPENIM_SERVER_CMDDIR}/docker-start-all.sh"]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
## all: Run tidy, gen, add-copyright, format, lint, cover, build ✨
|
## all: Run tidy, gen, add-copyright, format, lint, cover, build ✨
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: tidy gen add-copyright verify lint cover restart
|
all: tidy gen add-copyright lint cover restart
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Build set
|
# Build set
|
||||||
@@ -80,7 +80,7 @@ stop:
|
|||||||
|
|
||||||
## restart: Restart openim ✨
|
## restart: Restart openim ✨
|
||||||
.PHONY: restart
|
.PHONY: restart
|
||||||
restart: clean stop build init start
|
restart: clean stop build start
|
||||||
|
|
||||||
## multiarch: Build binaries for multiple platforms. See option PLATFORMS. ✨
|
## multiarch: Build binaries for multiple platforms. See option PLATFORMS. ✨
|
||||||
.PHONY: multiarch
|
.PHONY: multiarch
|
||||||
@@ -102,11 +102,6 @@ install:
|
|||||||
check:
|
check:
|
||||||
@$(MAKE) go.check
|
@$(MAKE) go.check
|
||||||
|
|
||||||
## check-component
|
|
||||||
.PHONY: check-component
|
|
||||||
check-component:
|
|
||||||
@$(MAKE) go.check-component
|
|
||||||
|
|
||||||
## tidy: tidy go.mod ✨
|
## tidy: tidy go.mod ✨
|
||||||
.PHONY: tidy
|
.PHONY: tidy
|
||||||
tidy:
|
tidy:
|
||||||
|
|||||||
@@ -121,16 +121,12 @@ $ make demo
|
|||||||
|
|
||||||
<details> <summary>Deploying with Docker Compose</summary>
|
<details> <summary>Deploying with Docker Compose</summary>
|
||||||
|
|
||||||
|
|
||||||
> docker compose will not be maintained in future versions, but it is still the easiest and most convenient way to organize docker compose deployments into a separate project https://github.com/openim-sigs/openim-docker to maintain.
|
|
||||||
|
|
||||||
**1. Clone the project**
|
**1. Clone the project**
|
||||||
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# choose what you need, We take branch 3.2 as an example
|
# choose what you need, We take branch 3.2 as an example
|
||||||
$ BRANCH=release-v3.2
|
$ BRANCH=release-v3.2
|
||||||
$ git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim/openim-server && export openim_dir=$(pwd)/openim && cd ${openim_dir}/openim-server
|
$ git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim && export openim=$(pwd)/openim && cd $openim
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
@@ -161,7 +157,7 @@ API_URL=http://127.0.0.1:10002/object/ #the app must be able to access this IP
|
|||||||
DATA_DIR=./ #designate large disk directory
|
DATA_DIR=./ #designate large disk directory
|
||||||
```
|
```
|
||||||
|
|
||||||
**3. Deploy and start**
|
3. **Deploy and start**
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
>
|
>
|
||||||
@@ -185,12 +181,10 @@ Looking at the command line at this point, there are two items in the output, ch
|
|||||||
|
|
||||||
<details> <summary>Compile from Source</summary>
|
<details> <summary>Compile from Source</summary>
|
||||||
|
|
||||||
|
|
||||||
Ur need `Go 1.18` or higher version, and `make`.
|
Ur need `Go 1.18` or higher version, and `make`.
|
||||||
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go version && make --version || echo "Error: One of the commands failed."
|
$ go version; make --version
|
||||||
```
|
```
|
||||||
|
|
||||||
Version Details: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md
|
Version Details: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md
|
||||||
@@ -198,26 +192,23 @@ Version Details: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conv
|
|||||||
```bash
|
```bash
|
||||||
# choose what you need
|
# choose what you need
|
||||||
$ BRANCH=release-v3.1
|
$ BRANCH=release-v3.1
|
||||||
$ git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim && export openim=$(pwd)/openim && cd $openim && make start
|
$ git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim && export openim=$(pwd)/openim && cd $openim && make build
|
||||||
```
|
```
|
||||||
|
|
||||||
> `make help` to help you see the instructions supported by OpenIM.
|
Read about the [OpenIM Version Policy](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md)
|
||||||
|
|
||||||
Use `make check` to check all component starts
|
`make help` to help you see the instructions supported by OpenIM.
|
||||||
|
|
||||||
```bash
|
All services have been successfully built as shown in the figure
|
||||||
$ make check
|
|
||||||
```
|
|
||||||
|
|
||||||
You can use the `make help-all` see OpenIM in action.
|

|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details> <summary>Component Configuration Instructions</summary>
|
<details> <summary>Component Configuration Instructions</summary>
|
||||||
The `config/config.yaml` file has detailed configuration instructions for the storage components.
|
|
||||||
|
|
||||||
|
|
||||||
The config file is available via [environment.sh](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/scripts/install/environment.sh) configuration [openim.yaml](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployments/templates/openim.yaml) template, and then through the `make init` to automatically generate a new configuration.
|
The config/config.yaml file has detailed configuration instructions for the storage components.
|
||||||
|
|
||||||
- Zookeeper
|
- Zookeeper
|
||||||
|
|
||||||
@@ -300,10 +291,26 @@ The config file is available via [environment.sh](https://github.com/OpenIMSDK/O
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details> <summary>Deployed with kubernetes</summary>
|
<details> <summary>Start and Stop Services</summary>
|
||||||
|
|
||||||
|
|
||||||
read: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployments/README.md
|
Start services
|
||||||
|
|
||||||
|
```
|
||||||
|
./scripts/start-all.sh;
|
||||||
|
```
|
||||||
|
|
||||||
|
Check services
|
||||||
|
|
||||||
|
```
|
||||||
|
./scripts/check-all.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Stop services
|
||||||
|
|
||||||
|
```
|
||||||
|
./scripts/stop-all.sh
|
||||||
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@@ -330,7 +337,6 @@ read: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployments/README.m
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
||||||
## :link: Relationship Between APP and OpenIM
|
## :link: Relationship Between APP and OpenIM
|
||||||
|
|
||||||
OpenIM isn't just an open-source instant messaging component, it's an integral part of your application ecosystem. Check out this diagram to understand how AppServer, AppClient, Open-IM-Server, and Open-IM-SDK interact.
|
OpenIM isn't just an open-source instant messaging component, it's an integral part of your application ecosystem. Check out this diagram to understand how AppServer, AppClient, Open-IM-Server, and Open-IM-SDK interact.
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||||
openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
|
openKeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/internal/api"
|
"github.com/OpenIMSDK/Open-IM-Server/internal/api"
|
||||||
@@ -66,11 +66,11 @@ func run(port int) error {
|
|||||||
}
|
}
|
||||||
fmt.Println("api start init discov client")
|
fmt.Println("api start init discov client")
|
||||||
var client discoveryregistry.SvcDiscoveryRegistry
|
var client discoveryregistry.SvcDiscoveryRegistry
|
||||||
client, err = openkeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
client, err = openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
||||||
openkeeper.WithFreq(time.Hour), openkeeper.WithUserNameAndPassword(
|
openKeeper.WithFreq(time.Hour), openKeeper.WithUserNameAndPassword(
|
||||||
config.Config.Zookeeper.Username,
|
config.Config.Zookeeper.Username,
|
||||||
config.Config.Zookeeper.Password,
|
config.Config.Zookeeper.Password,
|
||||||
), openkeeper.WithRoundRobin(), openkeeper.WithTimeout(10), openkeeper.WithLogger(log.NewZkLogger()))
|
), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-21
@@ -1,6 +1,6 @@
|
|||||||
# Copyright © 2023 OpenIM. All rights reserved.
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the License);
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
@@ -13,10 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# TODO: This config file is the template file
|
# Infrastructural configurations, please modify based on your setup
|
||||||
# --| source: deployments/templates/openim.yaml
|
|
||||||
# --| env: scripts/install/environment
|
|
||||||
# --| target: config/config.yaml
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
###################### Zookeeper ######################
|
###################### Zookeeper ######################
|
||||||
@@ -67,7 +64,7 @@ mongo:
|
|||||||
password: openIM123
|
password: openIM123
|
||||||
maxPoolSize: 100
|
maxPoolSize: 100
|
||||||
|
|
||||||
###################### Redis configuration information ######################
|
###################### Redis ######################
|
||||||
# Redis configuration
|
# Redis configuration
|
||||||
#
|
#
|
||||||
# Username is required only for Redis version 6.0+
|
# Username is required only for Redis version 6.0+
|
||||||
@@ -76,7 +73,7 @@ redis:
|
|||||||
username:
|
username:
|
||||||
password: openIM123
|
password: openIM123
|
||||||
|
|
||||||
###################### Kafka configuration information ######################
|
###################### Kafka ######################
|
||||||
# Kafka configuration
|
# Kafka configuration
|
||||||
#
|
#
|
||||||
# Kafka username
|
# Kafka username
|
||||||
@@ -99,7 +96,7 @@ kafka:
|
|||||||
msgToMySql: mysql
|
msgToMySql: mysql
|
||||||
msgToPush: push
|
msgToPush: push
|
||||||
|
|
||||||
###################### RPC configuration information ######################
|
###################### RPC ######################
|
||||||
# RPC configuration
|
# RPC configuration
|
||||||
#
|
#
|
||||||
# IP address to register with zookeeper when starting RPC, the IP and corresponding rpcPort should be accessible by api/gateway
|
# IP address to register with zookeeper when starting RPC, the IP and corresponding rpcPort should be accessible by api/gateway
|
||||||
@@ -108,7 +105,7 @@ rpc:
|
|||||||
registerIP:
|
registerIP:
|
||||||
listenIP: 0.0.0.0
|
listenIP: 0.0.0.0
|
||||||
|
|
||||||
###################### API configuration information ######################
|
###################### API ######################
|
||||||
# API configuration
|
# API configuration
|
||||||
#
|
#
|
||||||
# API service port
|
# API service port
|
||||||
@@ -117,7 +114,7 @@ api:
|
|||||||
openImApiPort: [ 10002 ]
|
openImApiPort: [ 10002 ]
|
||||||
listenIP: 0.0.0.0
|
listenIP: 0.0.0.0
|
||||||
|
|
||||||
###################### Object configuration information ######################
|
###################### Gateway ######################
|
||||||
# Object storage configuration
|
# Object storage configuration
|
||||||
#
|
#
|
||||||
# Use minio for object storage
|
# Use minio for object storage
|
||||||
@@ -153,12 +150,11 @@ object:
|
|||||||
accessKeySecret: ""
|
accessKeySecret: ""
|
||||||
sessionToken: ""
|
sessionToken: ""
|
||||||
|
|
||||||
###################### RPC Port Configuration ######################
|
|
||||||
# RPC service ports
|
# RPC service ports
|
||||||
# These ports are passed into the program by the script and are not recommended to modify
|
# These ports are passed into the program by the script and are not recommended to modify
|
||||||
# For launching multiple programs, just fill in multiple ports separated by commas
|
# For launching multiple programs, just fill in multiple ports separated by commas
|
||||||
# For example, [10110, 10111]
|
# For example, [10110, 10111]
|
||||||
rpcPort:
|
rpcPort:
|
||||||
openImUserPort: [ 10110 ]
|
openImUserPort: [ 10110 ]
|
||||||
openImFriendPort: [ 10120 ]
|
openImFriendPort: [ 10120 ]
|
||||||
openImMessagePort: [ 10130 ]
|
openImMessagePort: [ 10130 ]
|
||||||
@@ -169,7 +165,6 @@ rpcPort:
|
|||||||
openImConversationPort: [ 10180 ]
|
openImConversationPort: [ 10180 ]
|
||||||
openImThirdPort: [ 10190 ]
|
openImThirdPort: [ 10190 ]
|
||||||
|
|
||||||
###################### RPC Register Name Configuration ######################
|
|
||||||
# RPC service names for registration, it's not recommended to modify these
|
# RPC service names for registration, it's not recommended to modify these
|
||||||
rpcRegisterName:
|
rpcRegisterName:
|
||||||
openImUserName: User
|
openImUserName: User
|
||||||
@@ -182,7 +177,6 @@ rpcRegisterName:
|
|||||||
openImConversationName: Conversation
|
openImConversationName: Conversation
|
||||||
openImThirdName: Third
|
openImThirdName: Third
|
||||||
|
|
||||||
###################### Log Configuration ######################
|
|
||||||
# Log configuration
|
# Log configuration
|
||||||
#
|
#
|
||||||
# Storage directory
|
# Storage directory
|
||||||
@@ -197,11 +191,10 @@ log:
|
|||||||
rotationTime: 24
|
rotationTime: 24
|
||||||
remainRotationCount: 2
|
remainRotationCount: 2
|
||||||
remainLogLevel: 6
|
remainLogLevel: 6
|
||||||
isStdout: false
|
isStdout: false
|
||||||
isJson: false
|
isJson: false
|
||||||
withStack: false
|
withStack: false
|
||||||
|
|
||||||
###################### Variables definition ######################
|
|
||||||
# Long connection server configuration
|
# Long connection server configuration
|
||||||
#
|
#
|
||||||
# Websocket port for msg_gateway
|
# Websocket port for msg_gateway
|
||||||
@@ -243,8 +236,8 @@ push:
|
|||||||
# Built-in app manager user IDs
|
# Built-in app manager user IDs
|
||||||
# Built-in app manager nicknames
|
# Built-in app manager nicknames
|
||||||
manager:
|
manager:
|
||||||
userID: [ "openIM123456", "openIM654321", "openIMAdmin" ]
|
userID: [ "openIM123456","openIM654321","openIMAdmin" ]
|
||||||
nickname: [ "system1", "system2", "system3" ]
|
nickname: [ "system1","system2", "system3" ]
|
||||||
|
|
||||||
# Multi-platform login policy
|
# Multi-platform login policy
|
||||||
# For each platform(Android, iOS, Windows, Mac, web), only one can be online at a time
|
# For each platform(Android, iOS, Windows, Mac, web), only one can be online at a time
|
||||||
@@ -298,7 +291,6 @@ iosPush:
|
|||||||
badgeCount: true
|
badgeCount: true
|
||||||
production: false
|
production: false
|
||||||
|
|
||||||
###################### Third-party service configuration ######################
|
|
||||||
# Callback configuration
|
# Callback configuration
|
||||||
#
|
#
|
||||||
# Callback URL
|
# Callback URL
|
||||||
@@ -368,7 +360,7 @@ callback:
|
|||||||
failedContinue: true
|
failedContinue: true
|
||||||
|
|
||||||
###################### Prometheus ######################
|
###################### Prometheus ######################
|
||||||
# Prometheus configuration for various services
|
# Prometheus configuration
|
||||||
# The number of Prometheus ports per service needs to correspond to rpcPort
|
# The number of Prometheus ports per service needs to correspond to rpcPort
|
||||||
# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh
|
# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh
|
||||||
prometheus:
|
prometheus:
|
||||||
@@ -383,4 +375,4 @@ prometheus:
|
|||||||
conversationPrometheusPort: [ 20230 ]
|
conversationPrometheusPort: [ 20230 ]
|
||||||
rtcPrometheusPort: [ 21300 ]
|
rtcPrometheusPort: [ 21300 ]
|
||||||
thirdPrometheusPort: [ 21301 ]
|
thirdPrometheusPort: [ 21301 ]
|
||||||
messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports
|
messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ]
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OPENIM OPENIM RPC CONVERSATION
|
||||||
|
Documentation=https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployment/init/README.md
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=${OPENIM_DATA_DIR}/openim-rpc-conversation
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_DATA_DIR}/openim-rpc-conversation
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_LOG_DIR}
|
||||||
|
ExecStart=${OPENIM_INSTALL_DIR}/bin/openim-rpc-conversation --config=${OPENIM_CONFIG_DIR}/openim-rpc-conversation.yaml
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
StartLimitInterval=0
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OPENIM OPENIM RPC FRIEND
|
||||||
|
Documentation=https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployment/init/README.md
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=${OPENIM_DATA_DIR}/openim-rpc-friend
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_DATA_DIR}/openim-rpc-friend
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_LOG_DIR}
|
||||||
|
ExecStart=${OPENIM_INSTALL_DIR}/bin/openim-rpc-friend --config=${OPENIM_CONFIG_DIR}/openim-rpc-friend.yaml
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
StartLimitInterval=0
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OPENIM OPENIM RPC GROUP
|
||||||
|
Documentation=https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployment/init/README.md
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=${OPENIM_DATA_DIR}/openim-rpc-group
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_DATA_DIR}/openim-rpc-group
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_LOG_DIR}
|
||||||
|
ExecStart=${OPENIM_INSTALL_DIR}/bin/openim-rpc-group --config=${OPENIM_CONFIG_DIR}/openim-rpc-group.yaml
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
StartLimitInterval=0
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OPENIM OPENIM RPC MSG
|
||||||
|
Documentation=https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployment/init/README.md
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=${OPENIM_DATA_DIR}/openim-rpc-msg
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_DATA_DIR}/openim-rpc-msg
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_LOG_DIR}
|
||||||
|
ExecStart=${OPENIM_INSTALL_DIR}/bin/openim-rpc-msg --config=${OPENIM_CONFIG_DIR}/openim-rpc-msg.yaml
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
StartLimitInterval=0
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OPENIM OPENIM RPC THIRD
|
||||||
|
Documentation=https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployment/init/README.md
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=${OPENIM_DATA_DIR}/openim-rpc-third
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_DATA_DIR}/openim-rpc-third
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_LOG_DIR}
|
||||||
|
ExecStart=${OPENIM_INSTALL_DIR}/bin/openim-rpc-third --config=${OPENIM_CONFIG_DIR}/openim-rpc-third.yaml
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
StartLimitInterval=0
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OPENIM OPENIM RPC USER
|
||||||
|
Documentation=https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployment/init/README.md
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=${OPENIM_DATA_DIR}/openim-rpc-user
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_DATA_DIR}/openim-rpc-user
|
||||||
|
ExecStartPre=/usr/bin/mkdir -p ${OPENIM_LOG_DIR}
|
||||||
|
ExecStart=${OPENIM_INSTALL_DIR}/bin/openim-rpc-user --config=${OPENIM_CONFIG_DIR}/openim-rpc-user.yaml
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
StartLimitInterval=0
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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-cmdutils
|
||||||
|
description: "This is a description for openim-cmdutils"
|
||||||
|
type: "service"
|
||||||
@@ -13,7 +13,10 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# Infrastructural configurations, please modify based on your setup
|
# This config file is the template file
|
||||||
|
# --| source: scripts/template/config-tmpl/config.yaml
|
||||||
|
# --| env: scripts/install/environment.sh
|
||||||
|
# --| target: config/config.yaml
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
###################### Zookeeper ######################
|
###################### Zookeeper ######################
|
||||||
@@ -24,10 +27,10 @@
|
|||||||
# Zookeeper username
|
# Zookeeper username
|
||||||
# Zookeeper password
|
# Zookeeper password
|
||||||
zookeeper:
|
zookeeper:
|
||||||
schema: openim
|
schema: "openim"
|
||||||
address: [ 127.0.0.1:2181 ]
|
address: [ "127.0.0.1:2181" ]
|
||||||
username:
|
username: ""
|
||||||
password:
|
password: ""
|
||||||
|
|
||||||
###################### Mysql ######################
|
###################### Mysql ######################
|
||||||
# MySQL configuration
|
# MySQL configuration
|
||||||
@@ -39,15 +42,15 @@ zookeeper:
|
|||||||
# Log level: 1=slient, 2=error, 3=warn, 4=info
|
# Log level: 1=slient, 2=error, 3=warn, 4=info
|
||||||
# Slow query threshold in milliseconds
|
# Slow query threshold in milliseconds
|
||||||
mysql:
|
mysql:
|
||||||
address: [ 127.0.0.1:13306 ]
|
address: [ "127.0.0.1:13306" ]
|
||||||
username: root
|
username: "root"
|
||||||
password: openIM123
|
password: "openIM123"
|
||||||
database: openIM_v3
|
database: "openIM_v3"
|
||||||
maxOpenConn: 1000
|
maxOpenConn: "1000"
|
||||||
maxIdleConn: 100
|
maxIdleConn: "100"
|
||||||
maxLifeTime: 60
|
maxLifeTime: "60"
|
||||||
logLevel: 4
|
logLevel: "4"
|
||||||
slowThreshold: 500
|
slowThreshold: "500"
|
||||||
|
|
||||||
###################### Mongo ######################
|
###################### Mongo ######################
|
||||||
# MongoDB configuration
|
# MongoDB configuration
|
||||||
@@ -57,23 +60,23 @@ mysql:
|
|||||||
# Default MongoDB database name
|
# Default MongoDB database name
|
||||||
# Maximum connection pool size
|
# Maximum connection pool size
|
||||||
mongo:
|
mongo:
|
||||||
uri:
|
uri: ""
|
||||||
address: [ 127.0.0.1:37017 ]
|
address: [ "127.0.0.1:37017" ]
|
||||||
database: openIM_v3
|
database: "openIM_v3"
|
||||||
username: root
|
username: "root"
|
||||||
password: openIM123
|
password: "openIM123"
|
||||||
maxPoolSize: 100
|
maxPoolSize: "100"
|
||||||
|
|
||||||
###################### Redis ######################
|
###################### Redis configuration information ######################
|
||||||
# Redis configuration
|
# Redis configuration
|
||||||
#
|
#
|
||||||
# Username is required only for Redis version 6.0+
|
# Username is required only for Redis version 6.0+
|
||||||
redis:
|
redis:
|
||||||
address: [ 127.0.0.1:16379 ]
|
address: [ "127.0.0.1:16379" ]
|
||||||
username:
|
username: ""
|
||||||
password: openIM123
|
password: "openIM123"
|
||||||
|
|
||||||
###################### Kafka ######################
|
###################### Kafka configuration information ######################
|
||||||
# Kafka configuration
|
# Kafka configuration
|
||||||
#
|
#
|
||||||
# Kafka username
|
# Kafka username
|
||||||
@@ -81,9 +84,9 @@ redis:
|
|||||||
# It's not recommended to modify this topic name
|
# It's not recommended to modify this topic name
|
||||||
# Consumer group ID, it's not recommended to modify
|
# Consumer group ID, it's not recommended to modify
|
||||||
kafka:
|
kafka:
|
||||||
username:
|
username: ""
|
||||||
password:
|
password: ""
|
||||||
addr: [ 127.0.0.1:9092 ]
|
addr: [ "127.0.0.1:9092" ]
|
||||||
latestMsgToRedis:
|
latestMsgToRedis:
|
||||||
topic: "latestMsgToRedis"
|
topic: "latestMsgToRedis"
|
||||||
offlineMsgToMongo:
|
offlineMsgToMongo:
|
||||||
@@ -91,30 +94,30 @@ kafka:
|
|||||||
msgToPush:
|
msgToPush:
|
||||||
topic: "msgToPush"
|
topic: "msgToPush"
|
||||||
consumerGroupID:
|
consumerGroupID:
|
||||||
msgToRedis: redis
|
msgToRedis: "redis"
|
||||||
msgToMongo: mongo
|
msgToMongo: "mongo"
|
||||||
msgToMySql: mysql
|
msgToMySql: "mysql"
|
||||||
msgToPush: push
|
msgToPush: "push"
|
||||||
|
|
||||||
###################### RPC ######################
|
###################### RPC configuration information ######################
|
||||||
# RPC configuration
|
# RPC configuration
|
||||||
#
|
#
|
||||||
# IP address to register with zookeeper when starting RPC, the IP and corresponding rpcPort should be accessible by api/gateway
|
# IP address to register with zookeeper when starting RPC, the IP and corresponding rpcPort should be accessible by api/gateway
|
||||||
# Default listen IP is 0.0.0.0
|
# Default listen IP is 0.0.0.0
|
||||||
rpc:
|
rpc:
|
||||||
registerIP:
|
registerIP: ""
|
||||||
listenIP: 0.0.0.0
|
listenIP: "0.0.0.0"
|
||||||
|
|
||||||
###################### API ######################
|
###################### API configuration information ######################
|
||||||
# API configuration
|
# API configuration
|
||||||
#
|
#
|
||||||
# API service port
|
# API service port
|
||||||
# Default listen IP is 0.0.0.0
|
# Default listen IP is 0.0.0.0
|
||||||
api:
|
api:
|
||||||
openImApiPort: [ 10002 ]
|
openImApiPort: [ "10002" ]
|
||||||
listenIP: 0.0.0.0
|
listenIP: "0.0.0.0"
|
||||||
|
|
||||||
###################### Gateway ######################
|
###################### Object configuration information ######################
|
||||||
# Object storage configuration
|
# Object storage configuration
|
||||||
#
|
#
|
||||||
# Use minio for object storage
|
# Use minio for object storage
|
||||||
@@ -124,19 +127,16 @@ api:
|
|||||||
# Session token
|
# Session token
|
||||||
# Configuration for Tencent COS
|
# Configuration for Tencent COS
|
||||||
# Configuration for Aliyun OSS
|
# Configuration for Aliyun OSS
|
||||||
# apiURL is the address of the api, the access address of the app, use s3 must be configured
|
# It can be set by an environment variable or by a script
|
||||||
# minio.endpoint can be configured as an intranet address,
|
|
||||||
# minio.signEndpoint is minio public network address
|
|
||||||
object:
|
object:
|
||||||
enable: "minio"
|
enable: "minio"
|
||||||
apiURL: "http://127.0.0.1:10002"
|
apiURL: "http://127.0.0.1:10002/object/"
|
||||||
minio:
|
minio:
|
||||||
bucket: "openim"
|
bucket: "openim"
|
||||||
endpoint: "http://127.0.0.1:10005"
|
endpoint: "http://113.90.83.134:10005"
|
||||||
accessKeyID: "root"
|
accessKeyID: "root"
|
||||||
secretAccessKey: "openIM123"
|
secretAccessKey: "openIM123"
|
||||||
sessionToken: ""
|
sessionToken: ""
|
||||||
signEndpoint: "http://127.0.0.1:10005"
|
|
||||||
cos:
|
cos:
|
||||||
bucketURL: "https://temp-1252357374.cos.ap-chengdu.myqcloud.com"
|
bucketURL: "https://temp-1252357374.cos.ap-chengdu.myqcloud.com"
|
||||||
secretID: ""
|
secretID: ""
|
||||||
@@ -146,37 +146,41 @@ object:
|
|||||||
endpoint: "https://oss-cn-chengdu.aliyuncs.com"
|
endpoint: "https://oss-cn-chengdu.aliyuncs.com"
|
||||||
bucket: "demo-9999999"
|
bucket: "demo-9999999"
|
||||||
bucketURL: "https://demo-9999999.oss-cn-chengdu.aliyuncs.com"
|
bucketURL: "https://demo-9999999.oss-cn-chengdu.aliyuncs.com"
|
||||||
accessKeyID: ""
|
accessKeyID: "root"
|
||||||
accessKeySecret: ""
|
accessKeySecret: ""
|
||||||
sessionToken: ""
|
sessionToken: ""
|
||||||
|
|
||||||
|
|
||||||
|
###################### RPC Port Configuration ######################
|
||||||
# RPC service ports
|
# RPC service ports
|
||||||
# These ports are passed into the program by the script and are not recommended to modify
|
# These ports are passed into the program by the script and are not recommended to modify
|
||||||
# For launching multiple programs, just fill in multiple ports separated by commas
|
# For launching multiple programs, just fill in multiple ports separated by commas
|
||||||
# For example, [10110, 10111]
|
# For example, [10110, 10111]
|
||||||
rpcPort:
|
rpcPort:
|
||||||
openImUserPort: [ 10110 ]
|
openImUserPort: [ "10110" ]
|
||||||
openImFriendPort: [ 10120 ]
|
openImFriendPort: [ "10120" ]
|
||||||
openImMessagePort: [ 10130 ]
|
openImMessagePort: [ "10130" ]
|
||||||
openImMessageGatewayPort: [ 10140 ]
|
openImMessageGatewayPort: [ "10140" ]
|
||||||
openImGroupPort: [ 10150 ]
|
openImGroupPort: [ "10150" ]
|
||||||
openImAuthPort: [ 10160 ]
|
openImAuthPort: [ "10160" ]
|
||||||
openImPushPort: [ 10170 ]
|
openImPushPort: [ "10170" ]
|
||||||
openImConversationPort: [ 10180 ]
|
openImConversationPort: [ "10180" ]
|
||||||
openImThirdPort: [ 10190 ]
|
openImThirdPort: [ "10190" ]
|
||||||
|
|
||||||
|
###################### RPC Register Name Configuration ######################
|
||||||
# RPC service names for registration, it's not recommended to modify these
|
# RPC service names for registration, it's not recommended to modify these
|
||||||
rpcRegisterName:
|
rpcRegisterName:
|
||||||
openImUserName: User
|
openImUserName: "User"
|
||||||
openImFriendName: Friend
|
openImFriendName: "Friend"
|
||||||
openImMsgName: Msg
|
openImMsgName: "Msg"
|
||||||
openImPushName: Push
|
openImPushName: "Push"
|
||||||
openImMessageGatewayName: MessageGateway
|
openImMessageGatewayName: "MessageGateway"
|
||||||
openImGroupName: Group
|
openImGroupName: "Group"
|
||||||
openImAuthName: Auth
|
openImAuthName: "Auth"
|
||||||
openImConversationName: Conversation
|
openImConversationName: "Conversation"
|
||||||
openImThirdName: Third
|
openImThirdName: "Third"
|
||||||
|
|
||||||
|
###################### Log Configuration ######################
|
||||||
# Log configuration
|
# Log configuration
|
||||||
#
|
#
|
||||||
# Storage directory
|
# Storage directory
|
||||||
@@ -187,14 +191,15 @@ rpcRegisterName:
|
|||||||
# Whether to output in json format
|
# Whether to output in json format
|
||||||
# Whether to include stack trace in logs
|
# Whether to include stack trace in logs
|
||||||
log:
|
log:
|
||||||
storageLocation: ../../../../../logs/
|
storageLocation: "/root/workspaces/openim/openim-server/log/"
|
||||||
rotationTime: 24
|
rotationTime: 24
|
||||||
remainRotationCount: 2
|
remainRotationCount: 2
|
||||||
remainLogLevel: 6
|
remainLogLevel: 6
|
||||||
isStdout: false
|
isStdout: false
|
||||||
isJson: false
|
isJson: false
|
||||||
withStack: false
|
withStack: false
|
||||||
|
|
||||||
|
###################### Variables definition ######################
|
||||||
# Long connection server configuration
|
# Long connection server configuration
|
||||||
#
|
#
|
||||||
# Websocket port for msg_gateway
|
# Websocket port for msg_gateway
|
||||||
@@ -202,7 +207,7 @@ log:
|
|||||||
# Maximum length of websocket request package
|
# Maximum length of websocket request package
|
||||||
# Websocket connection handshake timeout
|
# Websocket connection handshake timeout
|
||||||
longConnSvr:
|
longConnSvr:
|
||||||
openImWsPort: [ 10001 ]
|
openImWsPort: [ "10001" ]
|
||||||
websocketMaxConnNum: 100000
|
websocketMaxConnNum: 100000
|
||||||
websocketMaxMsgLen: 4096
|
websocketMaxMsgLen: 4096
|
||||||
websocketTimeout: 10
|
websocketTimeout: 10
|
||||||
@@ -215,7 +220,7 @@ longConnSvr:
|
|||||||
# Account file, place it in the config directory
|
# Account file, place it in the config directory
|
||||||
# JPush configuration, modify these after applying in JPush backend
|
# JPush configuration, modify these after applying in JPush backend
|
||||||
push:
|
push:
|
||||||
enable: getui
|
enable: "getui"
|
||||||
geTui:
|
geTui:
|
||||||
pushUrl: "https://restapi.getui.com/v2/$appId"
|
pushUrl: "https://restapi.getui.com/v2/$appId"
|
||||||
masterSecret: ""
|
masterSecret: ""
|
||||||
@@ -226,18 +231,18 @@ push:
|
|||||||
fcm:
|
fcm:
|
||||||
serviceAccount: "x.json"
|
serviceAccount: "x.json"
|
||||||
jpns:
|
jpns:
|
||||||
appKey:
|
appKey: ""
|
||||||
masterSecret:
|
masterSecret: ""
|
||||||
pushUrl:
|
pushUrl: ""
|
||||||
pushIntent:
|
pushIntent: ""
|
||||||
|
|
||||||
# App manager configuration
|
# App manager configuration
|
||||||
#
|
#
|
||||||
# Built-in app manager user IDs
|
# Built-in app manager user IDs
|
||||||
# Built-in app manager nicknames
|
# Built-in app manager nicknames
|
||||||
manager:
|
manager:
|
||||||
userID: [ "openIM123456","openIM654321","openIMAdmin" ]
|
userID: [ "openIM123456", "openIM654321", "openIMAdmin" ]
|
||||||
nickname: [ "system1","system2", "system3" ]
|
nickname: [ "system1", "system2", "system3" ]
|
||||||
|
|
||||||
# Multi-platform login policy
|
# Multi-platform login policy
|
||||||
# For each platform(Android, iOS, Windows, Mac, web), only one can be online at a time
|
# For each platform(Android, iOS, Windows, Mac, web), only one can be online at a time
|
||||||
@@ -260,14 +265,14 @@ retainChatRecords: 365
|
|||||||
|
|
||||||
# Schedule to clear expired messages(older than retainChatRecords days) in MongoDB every Wednesday at 2am
|
# Schedule to clear expired messages(older than retainChatRecords days) in MongoDB every Wednesday at 2am
|
||||||
# This deletion is just for cleaning up disk usage according to previous configuration retainChatRecords, no notification will be sent
|
# This deletion is just for cleaning up disk usage according to previous configuration retainChatRecords, no notification will be sent
|
||||||
chatRecordsClearTime: "0 2 * * 3"
|
chatRecordsClearTime: "0 2 * * *"
|
||||||
|
|
||||||
# Schedule to auto delete messages every day at 2am
|
# Schedule to auto delete messages every day at 2am
|
||||||
# This deletion is for messages that have been retained for more than msg_destruct_time (seconds) in the conversation field
|
# This deletion is for messages that have been retained for more than msg_destruct_time (seconds) in the conversation field
|
||||||
msgDestructTime: "0 2 * * *"
|
msgDestructTime: "0 2 * * *"
|
||||||
|
|
||||||
# Secret key
|
# Secret key
|
||||||
secret: openIM123
|
secret: "openIM123"
|
||||||
|
|
||||||
# Token policy
|
# Token policy
|
||||||
#
|
#
|
||||||
@@ -291,6 +296,7 @@ iosPush:
|
|||||||
badgeCount: true
|
badgeCount: true
|
||||||
production: false
|
production: false
|
||||||
|
|
||||||
|
###################### Third-party service configuration ######################
|
||||||
# Callback configuration
|
# Callback configuration
|
||||||
#
|
#
|
||||||
# Callback URL
|
# Callback URL
|
||||||
@@ -360,19 +366,19 @@ callback:
|
|||||||
failedContinue: true
|
failedContinue: true
|
||||||
|
|
||||||
###################### Prometheus ######################
|
###################### Prometheus ######################
|
||||||
# Prometheus configuration
|
# Prometheus configuration for various services
|
||||||
# The number of Prometheus ports per service needs to correspond to rpcPort
|
# The number of Prometheus ports per service needs to correspond to rpcPort
|
||||||
# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh
|
# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh
|
||||||
prometheus:
|
prometheus:
|
||||||
enable: false
|
enable: "false"
|
||||||
userPrometheusPort: [ 20110 ]
|
userPrometheusPort: [ "20110" ]
|
||||||
friendPrometheusPort: [ 20120 ]
|
friendPrometheusPort: [ "20120" ]
|
||||||
messagePrometheusPort: [ 20130 ]
|
messagePrometheusPort: [ "20130" ]
|
||||||
messageGatewayPrometheusPort: [ 20140 ]
|
messageGatewayPrometheusPort: [ "20140" ]
|
||||||
groupPrometheusPort: [ 20150 ]
|
groupPrometheusPort: [ "20150" ]
|
||||||
authPrometheusPort: [ 20160 ]
|
authPrometheusPort: [ "20160" ]
|
||||||
pushPrometheusPort: [ 20170 ]
|
pushPrometheusPort: [ "20170" ]
|
||||||
conversationPrometheusPort: [ 20230 ]
|
conversationPrometheusPort: [ "20230" ]
|
||||||
rtcPrometheusPort: [ 21300 ]
|
rtcPrometheusPort: [ "21300" ]
|
||||||
thirdPrometheusPort: [ 21301 ]
|
thirdPrometheusPort: [ "21301" ]
|
||||||
messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ]
|
messageTransferPrometheusPort: [ "21400, 21401, 21402, 21403" ] # List of ports
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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-msggateway
|
||||||
|
description: "This is a description for openim-msggateway"
|
||||||
|
type: "service"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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-msgtransfer
|
||||||
|
description: "This is a description for openim-msgtransfer"
|
||||||
|
type: "service"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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-push
|
||||||
|
description: "This is a description for openim-push"
|
||||||
|
type: "service"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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-rpc-auth
|
||||||
|
description: "This is a description for openim-rpc-auth"
|
||||||
|
type: "service"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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-rpc-conversation
|
||||||
|
description: "This is a description for openim-rpc-conversation"
|
||||||
|
type: "service"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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-rpc-friend
|
||||||
|
description: "This is a description for openim-rpc-friend"
|
||||||
|
type: "service"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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-rpc-group
|
||||||
|
description: "This is a description for openim-rpc-group"
|
||||||
|
type: "service"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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-rpc-msg
|
||||||
|
description: "This is a description for openim-rpc-msg"
|
||||||
|
type: "service"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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-rpc-third
|
||||||
|
description: "This is a description for openim-rpc-third"
|
||||||
|
type: "service"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT 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-rpc-user
|
||||||
|
description: "This is a description for openim-rpc-user"
|
||||||
|
type: "service"
|
||||||
@@ -198,7 +198,7 @@ log:
|
|||||||
rotationTime: ${LOG_ROTATION_TIME}
|
rotationTime: ${LOG_ROTATION_TIME}
|
||||||
remainRotationCount: ${LOG_REMAIN_ROTATION_COUNT}
|
remainRotationCount: ${LOG_REMAIN_ROTATION_COUNT}
|
||||||
remainLogLevel: ${LOG_REMAIN_LOG_LEVEL}
|
remainLogLevel: ${LOG_REMAIN_LOG_LEVEL}
|
||||||
isStdout: ${LOG_IS_STDOUT}
|
isStdout: ${LOG_IS_STDOUT}
|
||||||
isJson: ${LOG_IS_JSON}
|
isJson: ${LOG_IS_JSON}
|
||||||
withStack: ${LOG_WITH_STACK}
|
withStack: ${LOG_WITH_STACK}
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ push:
|
|||||||
channelID: ""
|
channelID: ""
|
||||||
channelName: ""
|
channelName: ""
|
||||||
fcm:
|
fcm:
|
||||||
serviceAccount: "${FCM_SERVICE_ACCOUNT}"
|
serviceAccount: ${FCM_SERVICE_ACCOUNT}
|
||||||
jpns:
|
jpns:
|
||||||
appKey:
|
appKey:
|
||||||
masterSecret:
|
masterSecret:
|
||||||
@@ -384,4 +384,4 @@ prometheus:
|
|||||||
conversationPrometheusPort: [ ${CONVERSATION_PROM_PORT} ]
|
conversationPrometheusPort: [ ${CONVERSATION_PROM_PORT} ]
|
||||||
rtcPrometheusPort: [ ${RTC_PROM_PORT} ]
|
rtcPrometheusPort: [ ${RTC_PROM_PORT} ]
|
||||||
thirdPrometheusPort: [ ${THIRD_PROM_PORT} ]
|
thirdPrometheusPort: [ ${THIRD_PROM_PORT} ]
|
||||||
messageTransferPrometheusPort: [ ${MSG_TRANSFER_PROM_PORT} ] # List of ports
|
messageTransferPrometheusPort: [ ${MSG_TRANSFER_PROM_PORT} ] # List of ports
|
||||||
|
|||||||
+54
-54
@@ -90,8 +90,8 @@ services:
|
|||||||
- 9090:9090
|
- 9090:9090
|
||||||
container_name: minio
|
container_name: minio
|
||||||
volumes:
|
volumes:
|
||||||
- ${DATA_DIR}/components/mnt/data:/data
|
- /mnt/data:/data
|
||||||
- ${DATA_DIR}/components/mnt/config:/root/.minio
|
- /mnt/config:/root/.minio
|
||||||
environment:
|
environment:
|
||||||
MINIO_ROOT_USER: ${USER}
|
MINIO_ROOT_USER: ${USER}
|
||||||
MINIO_ROOT_PASSWORD: ${PASSWORD}
|
MINIO_ROOT_PASSWORD: ${PASSWORD}
|
||||||
@@ -99,9 +99,10 @@ services:
|
|||||||
command: minio server /data --console-address ':9090'
|
command: minio server /data --console-address ':9090'
|
||||||
|
|
||||||
openim-server:
|
openim-server:
|
||||||
image: ghcr.io/openimsdk/openim-server:main
|
# image: ghcr.io/openimsdk/openim-server:latest
|
||||||
# image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:main
|
image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:latest
|
||||||
# image: openim/openim-server:main
|
# image: openim/openim-server:latest
|
||||||
|
# build: .
|
||||||
container_name: openim-server
|
container_name: openim-server
|
||||||
# healthcheck:
|
# healthcheck:
|
||||||
# test: ["CMD-SHELL", "./scripts/check-all.sh"]
|
# test: ["CMD-SHELL", "./scripts/check-all.sh"]
|
||||||
@@ -109,9 +110,9 @@ services:
|
|||||||
# timeout: 10s
|
# timeout: 10s
|
||||||
# retries: 5
|
# retries: 5
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/openim/openim-server/logs
|
- ${DATA_DIR}/_output/openim/logs:/openim/openim-server/logs
|
||||||
- ./config:/openim/openim-server/config
|
- ${DATA_DIR}/config:/openim/openim-server/config
|
||||||
- ./scripts:/openim/openim-server/scripts
|
- ${DATA_DIR}/scripts:/openim/openim-server/scripts
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- zookeeper
|
- zookeeper
|
||||||
@@ -127,58 +128,57 @@ services:
|
|||||||
max-size: "1g"
|
max-size: "1g"
|
||||||
max-file: "2"
|
max-file: "2"
|
||||||
|
|
||||||
# openim-chat:
|
openim-chat:
|
||||||
# # image: ghcr.io/openimsdk/openim-server:release-v1.2
|
# image: ghcr.io/openimsdk/openim-chat:latest
|
||||||
# image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:release-v1.2
|
image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:latest
|
||||||
# # image: openim/openim-server:release-v1.2
|
# image: openim/openim-chat:latest
|
||||||
# container_name: openim-chat
|
container_name: openim-chat
|
||||||
# # healthcheck:
|
healthcheck:
|
||||||
# # test: ["CMD-SHELL", "./scripts/check-all.sh"]
|
test: ["CMD-SHELL", "./scripts/check-all.sh"]
|
||||||
# # interval: 30s
|
interval: 30s
|
||||||
# # timeout: 10s
|
timeout: 10s
|
||||||
# # retries: 5
|
retries: 5
|
||||||
# volumes:
|
|
||||||
# - openim-chat_logs:/openim/openim-chat/logs
|
|
||||||
# - openim-chat_config:/openim/openim-chat/config
|
|
||||||
# - openim-chat_scripts:/openim/openim-chat/scripts
|
|
||||||
# restart: always
|
|
||||||
# user: root:root
|
|
||||||
# depends_on:
|
|
||||||
# - mysql
|
|
||||||
# - mongodb
|
|
||||||
# - redis
|
|
||||||
# - minio
|
|
||||||
# - openim-server
|
|
||||||
# network_mode: "host"
|
|
||||||
# logging:
|
|
||||||
# driver: json-file
|
|
||||||
# options:
|
|
||||||
# max-size: "1g"
|
|
||||||
# max-file: "2"
|
|
||||||
|
|
||||||
prometheus:
|
|
||||||
image: prom/prometheus
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./.docker-compose_cfg/prometheus-compose.yml:/etc/prometheus/prometheus.yml
|
- ${DATA_DIR}/_output/openim/openim-chat/logs:/openim/openim-chat/logs
|
||||||
container_name: prometheus
|
- ${DATA_DIR}/_output/openim/openim-chat/config:/openim/openim-chat/config
|
||||||
# ports:
|
- ${DATA_DIR}/_output/openim/openim-chat/scripts:/openim/openim-chat/scripts
|
||||||
# - 9091:9091
|
restart: always
|
||||||
|
user: root:root
|
||||||
depends_on:
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
- mongodb
|
||||||
|
- redis
|
||||||
|
- minio
|
||||||
- openim-server
|
- openim-server
|
||||||
command: --web.listen-address=:9091 --config.file="/etc/prometheus/prometheus.yml"
|
|
||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: "1g"
|
||||||
|
max-file: "2"
|
||||||
|
|
||||||
grafana:
|
# prometheus:
|
||||||
image: grafana/grafana
|
# image: prom/prometheus
|
||||||
volumes:
|
# volumes:
|
||||||
- ./.docker-compose_cfg/datasource-compose.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
|
# - ./.docker-compose_cfg/prometheus-compose.yml:/etc/prometheus/prometheus.yml
|
||||||
- ./.docker-compose_cfg/grafana.ini:/etc/grafana/grafana.ini
|
# container_name: prometheus
|
||||||
- ./.docker-compose_cfg/node-exporter-full_rev1.json:/var/lib/grafana/dashboards/node-exporter-full_rev1.json
|
# # ports:
|
||||||
container_name: grafana
|
# # - 9091:9091
|
||||||
depends_on:
|
# depends_on:
|
||||||
- prometheus
|
# - openim-server
|
||||||
network_mode: "host"
|
# command: --web.listen-address=:9091 --config.file="/etc/prometheus/prometheus.yml"
|
||||||
|
# network_mode: "host"
|
||||||
|
|
||||||
|
# grafana:
|
||||||
|
# image: grafana/grafana
|
||||||
|
# volumes:
|
||||||
|
# - ./.docker-compose_cfg/datasource-compose.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
|
||||||
|
# - ./.docker-compose_cfg/grafana.ini:/etc/grafana/grafana.ini
|
||||||
|
# - ./.docker-compose_cfg/node-exporter-full_rev1.json:/var/lib/grafana/dashboards/node-exporter-full_rev1.json
|
||||||
|
# container_name: grafana
|
||||||
|
# depends_on:
|
||||||
|
# - prometheus
|
||||||
|
# network_mode: "host"
|
||||||
|
|
||||||
# node-exporter:
|
# node-exporter:
|
||||||
# image: quay.io/prometheus/node-exporter
|
# image: quay.io/prometheus/node-exporter
|
||||||
|
|||||||
@@ -65,12 +65,12 @@ It is critical that our full community is actively engaged on enhancements in th
|
|||||||
|
|
||||||
### Steps
|
### Steps
|
||||||
|
|
||||||
- Run the [cherry pick script](https://github.com/OpenIMSDK/Open-IM-Server/tree/main/scripts/cherry-pick.sh)
|
- Run the [cherry pick script](https://github.com/OpenIMSDK/Open-IM-Server/tree/main/scripts/cherry_pick_pull.sh)
|
||||||
|
|
||||||
This example applies a main branch PR #98765 to the remote branch `upstream/release-v3.1`:
|
This example applies a main branch PR #98765 to the remote branch `upstream/release-v3.1`:
|
||||||
|
|
||||||
```
|
```
|
||||||
scripts/cherry-pick.sh upstream/release-v3.1 98765
|
scripts/cherry_pick_pull.sh upstream/release-v3.1 98765
|
||||||
```
|
```
|
||||||
|
|
||||||
- Be aware the cherry pick script assumes you have a git remote called `upstream` that points at the openim-server github org.
|
- Be aware the cherry pick script assumes you have a git remote called `upstream` that points at the openim-server github org.
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ In the `scripts/init_config.sh` file, we defined some template files. These temp
|
|||||||
```
|
```
|
||||||
# Defines an associative array where the keys are the template files and the values are the corresponding output files.
|
# Defines an associative array where the keys are the template files and the values are the corresponding output files.
|
||||||
declare -A TEMPLATES=(
|
declare -A TEMPLATES=(
|
||||||
[""${OPENIM_ROOT}"/scripts/template/config-tmpl/env.template"]="${OPENIM_OUTPUT_SUBPATH}/bin/.env"
|
["${OPENIM_ROOT}/scripts/template/config-tmpl/env.template"]="${OPENIM_OUTPUT_SUBPATH}/bin/.env"
|
||||||
[""${OPENIM_ROOT}"/scripts/template/config-tmpl/config.yaml"]="${OPENIM_OUTPUT_SUBPATH}/bin/config.yaml"
|
["${OPENIM_ROOT}/scripts/template/config-tmpl/config.yaml"]="${OPENIM_OUTPUT_SUBPATH}/bin/config.yaml"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -104,21 +104,9 @@ git merge release-v3.1
|
|||||||
# Push the updates to the main branch
|
# Push the updates to the main branch
|
||||||
git push origin main
|
git push origin main
|
||||||
```
|
```
|
||||||
## Release Process
|
|
||||||
|
|
||||||
```
|
|
||||||
Publishing v3.2.0: A Step-by-Step Guide
|
|
||||||
(1) Create the tag v3.2.0-alpha.0 from the main branch.
|
|
||||||
(2) Bugs are fixed on the main branch. Once the bugs are resolved, tag the main branch as v3.2.0-rc.0.
|
|
||||||
(3) After further testing, if v3.2.0-rc.0 is deemed stable, create a branch named release-v3.2 from the tag v3.2.0-rc.0.
|
|
||||||
(4) From the release-v3.2 branch, create the tag v3.2.0. At this point, the official release of v3.2.0 is complete.
|
|
||||||
|
|
||||||
After the release of v3.2.0, if urgent bugs are discovered, fix them on the release-v3.2 branch. Then, submit two pull requests (PRs) to both the main and release-v3.2 branches. Tag the release-v3.2 branch as v3.2.1.
|
|
||||||
```
|
|
||||||
|
|
||||||
Throughout this process, active communication within the team is pivotal to maintaining transparency and consensus on changes.
|
Throughout this process, active communication within the team is pivotal to maintaining transparency and consensus on changes.
|
||||||
|
|
||||||
## Docker Images Version Management
|
## Docker Images Version Management
|
||||||
|
|
||||||
For more details on managing Docker image versions, visit [OpenIM Docker Images Administration](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/images.md).
|
For more details on managing Docker image versions, visit [OpenIM Docker Images Administration](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/images.md).
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ require (
|
|||||||
require github.com/google/uuid v1.3.0
|
require github.com/google/uuid v1.3.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/OpenIMSDK/protocol v0.0.15
|
github.com/OpenIMSDK/protocol v0.0.11
|
||||||
github.com/OpenIMSDK/tools v0.0.14
|
github.com/OpenIMSDK/tools v0.0.13
|
||||||
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible
|
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible
|
||||||
github.com/go-redis/redis v6.15.9+incompatible
|
github.com/go-redis/redis v6.15.9+incompatible
|
||||||
github.com/go-sql-driver/mysql v1.7.1
|
github.com/go-sql-driver/mysql v1.7.1
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7Biccwk
|
|||||||
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
|
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
|
||||||
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
|
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/OpenIMSDK/protocol v0.0.15 h1:KrrvdHH9kFF/tFYL2FXRPAr2e5F5DctSHfHq6MQjUI4=
|
github.com/OpenIMSDK/protocol v0.0.11 h1:3sWujfQhO1I1Da1b8UScaZcc0DNunSbNiH3DagZB/AA=
|
||||||
github.com/OpenIMSDK/protocol v0.0.15/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
github.com/OpenIMSDK/protocol v0.0.11/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
||||||
github.com/OpenIMSDK/tools v0.0.14 h1:WLof/+WxyPyRST+QkoTKubYCiV73uCLiL8pgnpH/yKQ=
|
github.com/OpenIMSDK/tools v0.0.13 h1:rcw4HS8S2DPZR9UOBxD8/ol9UBMzXBypzOVEytDRIMo=
|
||||||
github.com/OpenIMSDK/tools v0.0.14/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
|
github.com/OpenIMSDK/tools v0.0.13/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
|
||||||
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
|
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
|
||||||
github.com/Shopify/sarama v1.29.0 h1:ARid8o8oieau9XrHI55f/L3EoRAhm9px6sonbD7yuUE=
|
github.com/Shopify/sarama v1.29.0 h1:ARid8o8oieau9XrHI55f/L3EoRAhm9px6sonbD7yuUE=
|
||||||
github.com/Shopify/sarama v1.29.0/go.mod h1:2QpgD79wpdAESqNQMxNc0KYMkycd4slxGdV3TWSVqrU=
|
github.com/Shopify/sarama v1.29.0/go.mod h1:2QpgD79wpdAESqNQMxNc0KYMkycd4slxGdV3TWSVqrU=
|
||||||
|
|||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
cloud.google.com/go/iam v1.1.1 h1:lW7fzj15aVIXYHREOqjRBV9PsH0Z6u8Y46a1YGvQP4Y=
|
||||||
|
cloud.google.com/go/iam v1.1.1/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+KUZOU=
|
||||||
|
github.com/AlekSi/pointer v1.1.0 h1:SSDMPcXD9jSl8FPy9cRzoRaMJtm9g9ggGTxecRUbQoI=
|
||||||
|
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
|
||||||
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||||
|
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
|
||||||
|
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||||
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
|
||||||
|
github.com/marmotedu/component-base v1.6.2 h1:UtQkG0ZmAbVHVUdky5Sw68QLJno5ARSqslHu/xsVNl0=
|
||||||
|
github.com/marmotedu/errors v1.0.2 h1:qx9GtOljmAL+wLuemahe3WSWdXyEpJvLBlpXK8y2rdI=
|
||||||
|
github.com/marmotedu/marmotedu-sdk-go v1.6.2 h1:eQcHVdK89Xb107+XbeqIyEXzYFxmyjQFChBtijrQSl8=
|
||||||
|
github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM=
|
||||||
|
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
|
||||||
|
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
|
||||||
|
github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA=
|
||||||
|
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
|
||||||
|
github.com/spf13/viper v1.9.0 h1:yR6EXjTp0y0cLN8OZg1CRZmOBdI88UcGkhgyJhu6nZk=
|
||||||
|
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=
|
||||||
|
moul.io/http2curl v1.0.0 h1:6XwpyZOYsgZJrU8exnG87ncVkU1FVCcTRpwzOkTDUi8=
|
||||||
|
rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4=
|
||||||
+2
-12
@@ -167,15 +167,9 @@ func (m *MessageApi) DeleteMsgPhysical(c *gin.Context) {
|
|||||||
|
|
||||||
func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendMsgReq *msg.SendMsgReq, err error) {
|
func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendMsgReq *msg.SendMsgReq, err error) {
|
||||||
var data interface{}
|
var data interface{}
|
||||||
log.ZDebug(c, "getSendMsgReq", "req", req.Content)
|
|
||||||
switch req.ContentType {
|
switch req.ContentType {
|
||||||
case constant.Text:
|
case constant.Text:
|
||||||
text, ok := req.Content["content"].(string)
|
data = apistruct.TextElem{}
|
||||||
if !ok {
|
|
||||||
return nil, errs.ErrArgs.WithDetail("text is not string")
|
|
||||||
}
|
|
||||||
data = apistruct.TextContentElem{Content: text}
|
|
||||||
log.ZDebug(c, "getSendMsgReq", "data", data)
|
|
||||||
case constant.Picture:
|
case constant.Picture:
|
||||||
data = apistruct.PictureElem{}
|
data = apistruct.PictureElem{}
|
||||||
case constant.Voice:
|
case constant.Voice:
|
||||||
@@ -201,7 +195,7 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM
|
|||||||
if err := mapstructure.WeakDecode(req.Content, &data); err != nil {
|
if err := mapstructure.WeakDecode(req.Content, &data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.ZDebug(c, "getSendMsgReq", "req", req.Content)
|
log.ZDebug(c, "getSendMsgReq", "data", data)
|
||||||
if err := m.validate.Struct(data); err != nil {
|
if err := m.validate.Struct(data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -369,7 +363,3 @@ func (m *MessageApi) GetActiveGroup(c *gin.Context) {
|
|||||||
func (m *MessageApi) SearchMsg(c *gin.Context) {
|
func (m *MessageApi) SearchMsg(c *gin.Context) {
|
||||||
a2r.Call(msg.MsgClient.SearchMessage, m.Client, c)
|
a2r.Call(msg.MsgClient.SearchMessage, m.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) GetServerTime(c *gin.Context) {
|
|
||||||
a2r.Call(msg.MsgClient.GetServerTime, m.Client, c)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -187,7 +187,6 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
|
|||||||
|
|
||||||
msgGroup.POST("/batch_send_msg", m.BatchSendMsg)
|
msgGroup.POST("/batch_send_msg", m.BatchSendMsg)
|
||||||
msgGroup.POST("/check_msg_is_send_success", m.CheckMsgIsSendSuccess)
|
msgGroup.POST("/check_msg_is_send_success", m.CheckMsgIsSendSuccess)
|
||||||
msgGroup.POST("/get_server_time", m.GetServerTime)
|
|
||||||
}
|
}
|
||||||
// Conversation
|
// Conversation
|
||||||
conversationGroup := r.Group("/conversation", ParseToken)
|
conversationGroup := r.Group("/conversation", ParseToken)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func callBackURL() string {
|
func url() string {
|
||||||
return config.Config.Callback.CallbackUrl
|
return config.Config.Callback.CallbackUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ func CallbackUserOnline(ctx context.Context, userID string, platformID int, isAp
|
|||||||
ConnID: connID,
|
ConnID: connID,
|
||||||
}
|
}
|
||||||
resp := cbapi.CommonCallbackResp{}
|
resp := cbapi.CommonCallbackResp{}
|
||||||
return http.CallBackPostReturn(ctx, callBackURL(), &req, &resp, config.Config.Callback.CallbackUserOnline)
|
return http.CallBackPostReturn(ctx, url(), &req, &resp, config.Config.Callback.CallbackUserOnline)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CallbackUserOffline(ctx context.Context, userID string, platformID int, connID string) error {
|
func CallbackUserOffline(ctx context.Context, userID string, platformID int, connID string) error {
|
||||||
@@ -70,7 +70,7 @@ func CallbackUserOffline(ctx context.Context, userID string, platformID int, con
|
|||||||
ConnID: connID,
|
ConnID: connID,
|
||||||
}
|
}
|
||||||
resp := &cbapi.CallbackUserOfflineResp{}
|
resp := &cbapi.CallbackUserOfflineResp{}
|
||||||
return http.CallBackPostReturn(ctx, callBackURL(), req, resp, config.Config.Callback.CallbackUserOffline)
|
return http.CallBackPostReturn(ctx, url(), req, resp, config.Config.Callback.CallbackUserOffline)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CallbackUserKickOff(ctx context.Context, userID string, platformID int) error {
|
func CallbackUserKickOff(ctx context.Context, userID string, platformID int) error {
|
||||||
@@ -90,7 +90,7 @@ func CallbackUserKickOff(ctx context.Context, userID string, platformID int) err
|
|||||||
Seq: time.Now().UnixMilli(),
|
Seq: time.Now().UnixMilli(),
|
||||||
}
|
}
|
||||||
resp := &cbapi.CommonCallbackResp{}
|
resp := &cbapi.CommonCallbackResp{}
|
||||||
return http.CallBackPostReturn(ctx, callBackURL(), req, resp, config.Config.Callback.CallbackUserOffline)
|
return http.CallBackPostReturn(ctx, url(), req, resp, config.Config.Callback.CallbackUserOffline)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackground bool, connID
|
// func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackground bool, connID
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ package msggateway
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -72,11 +71,6 @@ func newContext(respWriter http.ResponseWriter, req *http.Request) *UserConnCont
|
|||||||
ConnID: utils.Md5(req.RemoteAddr + "_" + strconv.Itoa(int(utils.GetCurrentTimestampByMill()))),
|
ConnID: utils.Md5(req.RemoteAddr + "_" + strconv.Itoa(int(utils.GetCurrentTimestampByMill()))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func newTempContext() *UserConnContext {
|
|
||||||
return &UserConnContext{
|
|
||||||
Req: &http.Request{URL: &url.URL{}},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *UserConnContext) GetRemoteAddr() string {
|
func (c *UserConnContext) GetRemoteAddr() string {
|
||||||
return c.RemoteAddr
|
return c.RemoteAddr
|
||||||
@@ -122,15 +116,9 @@ func (c *UserConnContext) GetOperationID() string {
|
|||||||
return c.Req.URL.Query().Get(OperationID)
|
return c.Req.URL.Query().Get(OperationID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) SetOperationID(operationID string) {
|
|
||||||
c.Req.URL.Query().Set(OperationID, operationID)
|
|
||||||
}
|
|
||||||
func (c *UserConnContext) GetToken() string {
|
func (c *UserConnContext) GetToken() string {
|
||||||
return c.Req.URL.Query().Get(Token)
|
return c.Req.URL.Query().Get(Token)
|
||||||
}
|
}
|
||||||
func (c *UserConnContext) SetToken(token string) {
|
|
||||||
c.Req.URL.RawQuery = Token + "=" + token
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *UserConnContext) GetBackground() bool {
|
func (c *UserConnContext) GetBackground() bool {
|
||||||
b, err := strconv.ParseBool(c.Req.URL.Query().Get(BackgroundStatus))
|
b, err := strconv.ParseBool(c.Req.URL.Query().Get(BackgroundStatus))
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ package msggateway
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/mcontext"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
@@ -37,13 +35,13 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/startrpc"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/startrpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Server) InitServer(disCov discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func (s *Server) InitServer(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||||
rdb, err := cache.NewRedis()
|
rdb, err := cache.NewRedis()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
msgModel := cache.NewMsgCacheModel(rdb)
|
msgModel := cache.NewMsgCacheModel(rdb)
|
||||||
s.LongConnServer.SetDiscoveryRegistry(disCov)
|
s.LongConnServer.SetDiscoveryRegistry(client)
|
||||||
s.LongConnServer.SetCacheHandler(msgModel)
|
s.LongConnServer.SetCacheHandler(msgModel)
|
||||||
msggateway.RegisterMsgGatewayServer(server, s)
|
msggateway.RegisterMsgGatewayServer(server, s)
|
||||||
return nil
|
return nil
|
||||||
@@ -200,20 +198,6 @@ func (s *Server) MultiTerminalLoginCheck(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *msggateway.MultiTerminalLoginCheckReq,
|
req *msggateway.MultiTerminalLoginCheckReq,
|
||||||
) (*msggateway.MultiTerminalLoginCheckResp, error) {
|
) (*msggateway.MultiTerminalLoginCheckResp, error) {
|
||||||
if oldClients, userOK, clientOK := s.LongConnServer.GetUserPlatformCons(req.UserID, int(req.PlatformID)); userOK {
|
// TODO implement me
|
||||||
tempUserCtx := newTempContext()
|
panic("implement me")
|
||||||
tempUserCtx.SetToken(req.Token)
|
|
||||||
tempUserCtx.SetOperationID(mcontext.GetOperationID(ctx))
|
|
||||||
client := &Client{}
|
|
||||||
client.ctx = tempUserCtx
|
|
||||||
client.UserID = req.UserID
|
|
||||||
client.PlatformID = int(req.PlatformID)
|
|
||||||
i := &kickHandler{
|
|
||||||
clientOK: clientOK,
|
|
||||||
oldClients: oldClients,
|
|
||||||
newClient: client,
|
|
||||||
}
|
|
||||||
s.LongConnServer.SetKickHandlerInfo(i)
|
|
||||||
}
|
|
||||||
return &msggateway.MultiTerminalLoginCheckResp{}, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/msggateway"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
|
|
||||||
@@ -54,7 +52,6 @@ type LongConnServer interface {
|
|||||||
SetDiscoveryRegistry(client discoveryregistry.SvcDiscoveryRegistry)
|
SetDiscoveryRegistry(client discoveryregistry.SvcDiscoveryRegistry)
|
||||||
KickUserConn(client *Client) error
|
KickUserConn(client *Client) error
|
||||||
UnRegister(c *Client)
|
UnRegister(c *Client)
|
||||||
SetKickHandlerInfo(i *kickHandler)
|
|
||||||
Compressor
|
Compressor
|
||||||
Encoder
|
Encoder
|
||||||
MessageHandler
|
MessageHandler
|
||||||
@@ -81,7 +78,6 @@ type WsServer struct {
|
|||||||
validate *validator.Validate
|
validate *validator.Validate
|
||||||
cache cache.MsgModel
|
cache cache.MsgModel
|
||||||
userClient *rpcclient.UserRpcClient
|
userClient *rpcclient.UserRpcClient
|
||||||
disCov discoveryregistry.SvcDiscoveryRegistry
|
|
||||||
Compressor
|
Compressor
|
||||||
Encoder
|
Encoder
|
||||||
MessageHandler
|
MessageHandler
|
||||||
@@ -92,11 +88,10 @@ type kickHandler struct {
|
|||||||
newClient *Client
|
newClient *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WsServer) SetDiscoveryRegistry(disCov discoveryregistry.SvcDiscoveryRegistry) {
|
func (ws *WsServer) SetDiscoveryRegistry(client discoveryregistry.SvcDiscoveryRegistry) {
|
||||||
ws.MessageHandler = NewGrpcHandler(ws.validate, disCov)
|
ws.MessageHandler = NewGrpcHandler(ws.validate, client)
|
||||||
u := rpcclient.NewUserRpcClient(disCov)
|
u := rpcclient.NewUserRpcClient(client)
|
||||||
ws.userClient = &u
|
ws.userClient = &u
|
||||||
ws.disCov = disCov
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WsServer) SetUserOnlineStatus(ctx context.Context, client *Client, status int32) {
|
func (ws *WsServer) SetUserOnlineStatus(ctx context.Context, client *Client, status int32) {
|
||||||
@@ -185,31 +180,6 @@ func (ws *WsServer) Run() error {
|
|||||||
return http.ListenAndServe(":"+utils.IntToString(ws.port), nil) // Start listening
|
return http.ListenAndServe(":"+utils.IntToString(ws.port), nil) // Start listening
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WsServer) sendUserOnlineInfoToOtherNode(ctx context.Context, client *Client) error {
|
|
||||||
conns, err := ws.disCov.GetConns(ctx, config.Config.RpcRegisterName.OpenImMessageGatewayName)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// Online push user online message to other node
|
|
||||||
for _, v := range conns {
|
|
||||||
if v.Target() == ws.disCov.GetSelfConnTarget() {
|
|
||||||
log.ZDebug(ctx, "Filter out this node", "node", v.Target())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
msgClient := msggateway.NewMsgGatewayClient(v)
|
|
||||||
_, err := msgClient.MultiTerminalLoginCheck(ctx, &msggateway.MultiTerminalLoginCheckReq{UserID: client.UserID,
|
|
||||||
PlatformID: int32(client.PlatformID), Token: client.token})
|
|
||||||
if err != nil {
|
|
||||||
log.ZWarn(ctx, "MultiTerminalLoginCheck err", err, "node", v.Target())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func (ws *WsServer) SetKickHandlerInfo(i *kickHandler) {
|
|
||||||
ws.kickHandlerChan <- i
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ws *WsServer) registerClient(client *Client) {
|
func (ws *WsServer) registerClient(client *Client) {
|
||||||
var (
|
var (
|
||||||
userOK bool
|
userOK bool
|
||||||
@@ -241,7 +211,6 @@ func (ws *WsServer) registerClient(client *Client) {
|
|||||||
atomic.AddInt64(&ws.onlineUserConnNum, 1)
|
atomic.AddInt64(&ws.onlineUserConnNum, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ws.sendUserOnlineInfoToOtherNode(client.ctx, client)
|
|
||||||
ws.SetUserOnlineStatus(client.ctx, client, constant.Online)
|
ws.SetUserOnlineStatus(client.ctx, client, constant.Online)
|
||||||
log.ZInfo(
|
log.ZInfo(
|
||||||
client.ctx,
|
client.ctx,
|
||||||
@@ -280,10 +249,7 @@ func (ws *WsServer) multiTerminalLoginChecker(clientOK bool, oldClients []*Clien
|
|||||||
fallthrough
|
fallthrough
|
||||||
case constant.AllLoginButSameTermKick:
|
case constant.AllLoginButSameTermKick:
|
||||||
if clientOK {
|
if clientOK {
|
||||||
isDeleteUser := ws.clients.deleteClients(newClient.UserID, oldClients)
|
ws.clients.deleteClients(newClient.UserID, oldClients)
|
||||||
if isDeleteUser {
|
|
||||||
atomic.AddInt64(&ws.onlineUserNum, -1)
|
|
||||||
}
|
|
||||||
for _, c := range oldClients {
|
for _, c := range oldClients {
|
||||||
err := c.KickOnlineMessage()
|
err := c.KickOnlineMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -335,8 +301,7 @@ func (ws *WsServer) multiTerminalLoginChecker(clientOK bool, oldClients []*Clien
|
|||||||
m[k] = constant.KickedToken
|
m[k] = constant.KickedToken
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.ZDebug(newClient.ctx, "set token map is ", "token map", m, "userID",
|
log.ZDebug(newClient.ctx, "set token map is ", "token map", m, "userID", newClient.UserID)
|
||||||
newClient.UserID, "token", newClient.ctx.GetToken())
|
|
||||||
err = ws.cache.SetTokenMapByUidPid(newClient.ctx, newClient.UserID, newClient.PlatformID, m)
|
err = ws.cache.SetTokenMapByUidPid(newClient.ctx, newClient.UserID, newClient.PlatformID, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(newClient.ctx, "SetTokenMapByUidPid err", err, "userID", newClient.UserID, "platformID", newClient.PlatformID)
|
log.ZWarn(newClient.ctx, "SetTokenMapByUidPid err", err, "userID", newClient.UserID, "platformID", newClient.PlatformID)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
|
|
||||||
openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
|
openKeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
"github.com/OpenIMSDK/tools/mw"
|
"github.com/OpenIMSDK/tools/mw"
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
@@ -48,7 +48,7 @@ func StartTransfer(prometheusPort int) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := db.AutoMigrate(&relationtb.ChatLogModel{}); err != nil {
|
if err := db.AutoMigrate(&relationTb.ChatLogModel{}); err != nil {
|
||||||
fmt.Printf("gorm: AutoMigrate ChatLogModel err: %v\n", err)
|
fmt.Printf("gorm: AutoMigrate ChatLogModel err: %v\n", err)
|
||||||
}
|
}
|
||||||
rdb, err := cache.NewRedis()
|
rdb, err := cache.NewRedis()
|
||||||
@@ -62,9 +62,9 @@ func StartTransfer(prometheusPort int) error {
|
|||||||
if err := mongo.CreateMsgIndex(); err != nil {
|
if err := mongo.CreateMsgIndex(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
client, err := openkeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
client, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
||||||
openkeeper.WithFreq(time.Hour), openkeeper.WithRoundRobin(), openkeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
|
openKeeper.WithFreq(time.Hour), openKeeper.WithRoundRobin(), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
|
||||||
config.Config.Zookeeper.Password), openkeeper.WithTimeout(10), openkeeper.WithLogger(log.NewZkLogger()))
|
config.Config.Zookeeper.Password), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"github.com/Shopify/sarama"
|
"github.com/Shopify/sarama"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
@@ -52,7 +52,7 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(
|
|||||||
session sarama.ConsumerGroupSession,
|
session sarama.ConsumerGroupSession,
|
||||||
) {
|
) {
|
||||||
msg := cMsg.Value
|
msg := cMsg.Value
|
||||||
msgFromMQ := pbmsg.MsgDataToMongoByMQ{}
|
msgFromMQ := pbMsg.MsgDataToMongoByMQ{}
|
||||||
err := proto.Unmarshal(msg, &msgFromMQ)
|
err := proto.Unmarshal(msg, &msgFromMQ)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "unmarshall failed", err, "key", key, "len", len(msg))
|
log.ZError(ctx, "unmarshall failed", err, "key", key, "len", len(msg))
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(
|
|||||||
) {
|
) {
|
||||||
msg := cMsg.Value
|
msg := cMsg.Value
|
||||||
var tag bool
|
var tag bool
|
||||||
msgFromMQ := pbmsg.MsgDataToMQ{}
|
msgFromMQ := pbMsg.MsgDataToMQ{}
|
||||||
err := proto.Unmarshal(msg, &msgFromMQ)
|
err := proto.Unmarshal(msg, &msgFromMQ)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "msg_transfer Unmarshal msg err", err)
|
log.ZError(ctx, "msg_transfer Unmarshal msg err", err)
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import (
|
|||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
pbchat "github.com/OpenIMSDK/protocol/msg"
|
pbChat "github.com/OpenIMSDK/protocol/msg"
|
||||||
pbpush "github.com/OpenIMSDK/protocol/push"
|
pbPush "github.com/OpenIMSDK/protocol/push"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
@@ -47,12 +47,12 @@ func NewConsumerHandler(pusher *Pusher) *ConsumerHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConsumerHandler) handleMs2PsChat(ctx context.Context, msg []byte) {
|
func (c *ConsumerHandler) handleMs2PsChat(ctx context.Context, msg []byte) {
|
||||||
msgFromMQ := pbchat.PushMsgDataToMQ{}
|
msgFromMQ := pbChat.PushMsgDataToMQ{}
|
||||||
if err := proto.Unmarshal(msg, &msgFromMQ); err != nil {
|
if err := proto.Unmarshal(msg, &msgFromMQ); err != nil {
|
||||||
log.ZError(ctx, "push Unmarshal msg err", err, "msg", string(msg))
|
log.ZError(ctx, "push Unmarshal msg err", err, "msg", string(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pbData := &pbpush.PushMsgReq{
|
pbData := &pbPush.PushMsgReq{
|
||||||
MsgData: msgFromMQ.MsgData,
|
MsgData: msgFromMQ.MsgData,
|
||||||
ConversationID: msgFromMQ.ConversationID,
|
ConversationID: msgFromMQ.ConversationID,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
pbpush "github.com/OpenIMSDK/protocol/push"
|
pbPush "github.com/OpenIMSDK/protocol/push"
|
||||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
pbpush.RegisterPushMsgServiceServer(server, &pushServer{
|
pbPush.RegisterPushMsgServiceServer(server, &pushServer{
|
||||||
pusher: pusher,
|
pusher: pusher,
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
@@ -74,7 +74,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *pushServer) PushMsg(ctx context.Context, pbData *pbpush.PushMsgReq) (resp *pbpush.PushMsgResp, err error) {
|
func (r *pushServer) PushMsg(ctx context.Context, pbData *pbPush.PushMsgReq) (resp *pbPush.PushMsgResp, err error) {
|
||||||
switch pbData.MsgData.SessionType {
|
switch pbData.MsgData.SessionType {
|
||||||
case constant.SuperGroupChatType:
|
case constant.SuperGroupChatType:
|
||||||
err = r.pusher.Push2SuperGroup(ctx, pbData.MsgData.GroupID, pbData.MsgData)
|
err = r.pusher.Push2SuperGroup(ctx, pbData.MsgData.GroupID, pbData.MsgData)
|
||||||
@@ -88,15 +88,15 @@ func (r *pushServer) PushMsg(ctx context.Context, pbData *pbpush.PushMsgReq) (re
|
|||||||
log.ZWarn(ctx, "offline push failed", err, "msg", pbData.String())
|
log.ZWarn(ctx, "offline push failed", err, "msg", pbData.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &pbpush.PushMsgResp{}, nil
|
return &pbPush.PushMsgResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *pushServer) DelUserPushToken(
|
func (r *pushServer) DelUserPushToken(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbpush.DelUserPushTokenReq,
|
req *pbPush.DelUserPushTokenReq,
|
||||||
) (resp *pbpush.DelUserPushTokenResp, err error) {
|
) (resp *pbPush.DelUserPushTokenResp, err error) {
|
||||||
if err = r.pusher.database.DelFcmToken(ctx, req.UserID, int(req.PlatformID)); err != nil {
|
if err = r.pusher.database.DelFcmToken(ctx, req.UserID, int(req.PlatformID)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pbpush.DelUserPushTokenResp{}, nil
|
return &pbPush.DelUserPushTokenResp{}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
pbauth "github.com/OpenIMSDK/protocol/auth"
|
pbAuth "github.com/OpenIMSDK/protocol/auth"
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/protocol/msggateway"
|
"github.com/OpenIMSDK/protocol/msggateway"
|
||||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||||
@@ -49,7 +49,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
userRpcClient := rpcclient.NewUserRpcClient(client)
|
userRpcClient := rpcclient.NewUserRpcClient(client)
|
||||||
pbauth.RegisterAuthServer(server, &authServer{
|
pbAuth.RegisterAuthServer(server, &authServer{
|
||||||
userRpcClient: &userRpcClient,
|
userRpcClient: &userRpcClient,
|
||||||
RegisterCenter: client,
|
RegisterCenter: client,
|
||||||
authDatabase: controller.NewAuthDatabase(
|
authDatabase: controller.NewAuthDatabase(
|
||||||
@@ -61,8 +61,8 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *authServer) UserToken(ctx context.Context, req *pbauth.UserTokenReq) (*pbauth.UserTokenResp, error) {
|
func (s *authServer) UserToken(ctx context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) {
|
||||||
resp := pbauth.UserTokenResp{}
|
resp := pbAuth.UserTokenResp{}
|
||||||
if req.Secret != config.Config.Secret {
|
if req.Secret != config.Config.Secret {
|
||||||
return nil, errs.ErrNoPermission.Wrap("secret invalid")
|
return nil, errs.ErrNoPermission.Wrap("secret invalid")
|
||||||
}
|
}
|
||||||
@@ -105,9 +105,9 @@ func (s *authServer) parseToken(ctx context.Context, tokensString string) (claim
|
|||||||
|
|
||||||
func (s *authServer) ParseToken(
|
func (s *authServer) ParseToken(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbauth.ParseTokenReq,
|
req *pbAuth.ParseTokenReq,
|
||||||
) (resp *pbauth.ParseTokenResp, err error) {
|
) (resp *pbAuth.ParseTokenResp, err error) {
|
||||||
resp = &pbauth.ParseTokenResp{}
|
resp = &pbAuth.ParseTokenResp{}
|
||||||
claims, err := s.parseToken(ctx, req.Token)
|
claims, err := s.parseToken(ctx, req.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -118,14 +118,14 @@ func (s *authServer) ParseToken(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *authServer) ForceLogout(ctx context.Context, req *pbauth.ForceLogoutReq) (*pbauth.ForceLogoutResp, error) {
|
func (s *authServer) ForceLogout(ctx context.Context, req *pbAuth.ForceLogoutReq) (*pbAuth.ForceLogoutResp, error) {
|
||||||
if err := authverify.CheckAdmin(ctx); err != nil {
|
if err := authverify.CheckAdmin(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := s.forceKickOff(ctx, req.UserID, req.PlatformID, mcontext.GetOperationID(ctx)); err != nil {
|
if err := s.forceKickOff(ctx, req.UserID, req.PlatformID, mcontext.GetOperationID(ctx)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pbauth.ForceLogoutResp{}, nil
|
return &pbAuth.ForceLogoutResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *authServer) forceKickOff(ctx context.Context, userID string, platformID int32, operationID string) error {
|
func (s *authServer) forceKickOff(ctx context.Context, userID string, platformID int32, operationID string) error {
|
||||||
@@ -134,7 +134,7 @@ func (s *authServer) forceKickOff(ctx context.Context, userID string, platformID
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, v := range conns {
|
for _, v := range conns {
|
||||||
log.ZDebug(ctx, "forceKickOff", "conn", v.Target())
|
log.ZDebug(ctx, "forceKickOff", "conn", v.(*grpc.ClientConn).Target())
|
||||||
}
|
}
|
||||||
for _, v := range conns {
|
for _, v := range conns {
|
||||||
client := msggateway.NewMsgGatewayClient(v)
|
client := msggateway.NewMsgGatewayClient(v)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
pbconversation "github.com/OpenIMSDK/protocol/conversation"
|
pbConversation "github.com/OpenIMSDK/protocol/conversation"
|
||||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
@@ -33,7 +33,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
||||||
tablerelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
tableRelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
||||||
)
|
)
|
||||||
@@ -49,7 +49,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := db.AutoMigrate(&tablerelation.ConversationModel{}); err != nil {
|
if err := db.AutoMigrate(&tableRelation.ConversationModel{}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
rdb, err := cache.NewRedis()
|
rdb, err := cache.NewRedis()
|
||||||
@@ -59,7 +59,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
conversationDB := relation.NewConversationGorm(db)
|
conversationDB := relation.NewConversationGorm(db)
|
||||||
groupRpcClient := rpcclient.NewGroupRpcClient(client)
|
groupRpcClient := rpcclient.NewGroupRpcClient(client)
|
||||||
msgRpcClient := rpcclient.NewMessageRpcClient(client)
|
msgRpcClient := rpcclient.NewMessageRpcClient(client)
|
||||||
pbconversation.RegisterConversationServer(server, &conversationServer{
|
pbConversation.RegisterConversationServer(server, &conversationServer{
|
||||||
conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient),
|
conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient),
|
||||||
groupRpcClient: &groupRpcClient,
|
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)),
|
||||||
@@ -67,7 +67,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
return nil
|
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})
|
conversations, err := c.conversationDatabase.FindConversations(ctx, req.OwnerUserID, []string{req.ConversationID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -75,46 +75,46 @@ func (c *conversationServer) GetConversation(ctx context.Context, req *pbconvers
|
|||||||
if len(conversations) < 1 {
|
if len(conversations) < 1 {
|
||||||
return nil, errs.ErrRecordNotFound.Wrap("conversation not found")
|
return nil, errs.ErrRecordNotFound.Wrap("conversation not found")
|
||||||
}
|
}
|
||||||
resp := &pbconversation.GetConversationResp{Conversation: &pbconversation.Conversation{}}
|
resp := &pbConversation.GetConversationResp{Conversation: &pbConversation.Conversation{}}
|
||||||
resp.Conversation = convert.ConversationDB2Pb(conversations[0])
|
resp.Conversation = convert.ConversationDB2Pb(conversations[0])
|
||||||
return resp, nil
|
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)
|
conversations, err := c.conversationDatabase.GetUserAllConversation(ctx, req.OwnerUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp := &pbconversation.GetAllConversationsResp{Conversations: []*pbconversation.Conversation{}}
|
resp := &pbConversation.GetAllConversationsResp{Conversations: []*pbConversation.Conversation{}}
|
||||||
resp.Conversations = convert.ConversationsDB2Pb(conversations)
|
resp.Conversations = convert.ConversationsDB2Pb(conversations)
|
||||||
return resp, nil
|
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)
|
conversations, err := c.conversationDatabase.FindConversations(ctx, req.OwnerUserID, req.ConversationIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp := &pbconversation.GetConversationsResp{Conversations: []*pbconversation.Conversation{}}
|
resp := &pbConversation.GetConversationsResp{Conversations: []*pbConversation.Conversation{}}
|
||||||
resp.Conversations = convert.ConversationsDB2Pb(conversations)
|
resp.Conversations = convert.ConversationsDB2Pb(conversations)
|
||||||
return resp, nil
|
return resp, 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
|
var conversation tableRelation.ConversationModel
|
||||||
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
|
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
|
||||||
return nil, err
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
_ = c.conversationNotificationSender.ConversationChangeNotification(ctx, req.Conversation.OwnerUserID, []string{req.Conversation.ConversationID})
|
_ = c.conversationNotificationSender.ConversationChangeNotification(ctx, req.Conversation.OwnerUserID, []string{req.Conversation.ConversationID})
|
||||||
resp := &pbconversation.SetConversationResp{}
|
resp := &pbConversation.SetConversationResp{}
|
||||||
return resp, nil
|
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 {
|
if req.Conversation == nil {
|
||||||
return nil, errs.ErrArgs.Wrap("conversation must not be nil")
|
return nil, errs.ErrArgs.Wrap("conversation must not be nil")
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
var conversation tablerelation.ConversationModel
|
var conversation tableRelation.ConversationModel
|
||||||
conversation.ConversationID = req.Conversation.ConversationID
|
conversation.ConversationID = req.Conversation.ConversationID
|
||||||
conversation.ConversationType = req.Conversation.ConversationType
|
conversation.ConversationType = req.Conversation.ConversationType
|
||||||
conversation.UserID = req.Conversation.UserID
|
conversation.UserID = req.Conversation.UserID
|
||||||
@@ -161,7 +161,7 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
|
|||||||
m["is_msg_destruct"] = req.Conversation.IsMsgDestruct.Value
|
m["is_msg_destruct"] = req.Conversation.IsMsgDestruct.Value
|
||||||
}
|
}
|
||||||
if req.Conversation.IsPrivateChat != nil && req.Conversation.ConversationType != constant.SuperGroupChatType {
|
if req.Conversation.IsPrivateChat != nil && req.Conversation.ConversationType != constant.SuperGroupChatType {
|
||||||
var conversations []*tablerelation.ConversationModel
|
var conversations []*tableRelation.ConversationModel
|
||||||
for _, ownerUserID := range req.UserIDs {
|
for _, ownerUserID := range req.UserIDs {
|
||||||
conversation2 := conversation
|
conversation2 := conversation
|
||||||
conversation2.OwnerUserID = ownerUserID
|
conversation2.OwnerUserID = ownerUserID
|
||||||
@@ -185,26 +185,26 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
|
|||||||
for _, v := range req.UserIDs {
|
for _, v := range req.UserIDs {
|
||||||
c.conversationNotificationSender.ConversationChangeNotification(ctx, v, []string{req.Conversation.ConversationID})
|
c.conversationNotificationSender.ConversationChangeNotification(ctx, v, []string{req.Conversation.ConversationID})
|
||||||
}
|
}
|
||||||
return &pbconversation.SetConversationsResp{}, nil
|
return &pbConversation.SetConversationsResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取超级大群开启免打扰的用户ID.
|
// 获取超级大群开启免打扰的用户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)
|
userIDs, err := c.conversationDatabase.FindRecvMsgNotNotifyUserIDs(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pbconversation.GetRecvMsgNotNotifyUserIDsResp{UserIDs: userIDs}, nil
|
return &pbConversation.GetRecvMsgNotNotifyUserIDsResp{UserIDs: userIDs}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// create conversation without notification for msg redis transfer.
|
// 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
|
var conversation tableRelation.ConversationModel
|
||||||
conversation.ConversationID = msgprocessor.GetConversationIDBySessionType(constant.SingleChatType, req.RecvID, req.SendID)
|
conversation.ConversationID = msgprocessor.GetConversationIDBySessionType(constant.SingleChatType, req.RecvID, req.SendID)
|
||||||
conversation.ConversationType = constant.SingleChatType
|
conversation.ConversationType = constant.SingleChatType
|
||||||
conversation.OwnerUserID = req.SendID
|
conversation.OwnerUserID = req.SendID
|
||||||
conversation.UserID = req.RecvID
|
conversation.UserID = req.RecvID
|
||||||
err := c.conversationDatabase.CreateConversation(ctx, []*tablerelation.ConversationModel{&conversation})
|
err := c.conversationDatabase.CreateConversation(ctx, []*tableRelation.ConversationModel{&conversation})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(ctx, "create conversation failed", err, "conversation", conversation)
|
log.ZWarn(ctx, "create conversation failed", err, "conversation", conversation)
|
||||||
}
|
}
|
||||||
@@ -212,52 +212,52 @@ func (c *conversationServer) CreateSingleChatConversations(ctx context.Context,
|
|||||||
conversation2 := conversation
|
conversation2 := conversation
|
||||||
conversation2.OwnerUserID = req.RecvID
|
conversation2.OwnerUserID = req.RecvID
|
||||||
conversation2.UserID = req.SendID
|
conversation2.UserID = req.SendID
|
||||||
err = c.conversationDatabase.CreateConversation(ctx, []*tablerelation.ConversationModel{&conversation2})
|
err = c.conversationDatabase.CreateConversation(ctx, []*tableRelation.ConversationModel{&conversation2})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(ctx, "create conversation failed", err, "conversation2", conversation)
|
log.ZWarn(ctx, "create conversation failed", err, "conversation2", conversation)
|
||||||
}
|
}
|
||||||
return &pbconversation.CreateSingleChatConversationsResp{}, nil
|
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)
|
err := c.conversationDatabase.CreateGroupChatConversation(ctx, req.GroupID, req.UserIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pbconversation.CreateGroupChatConversationsResp{}, nil
|
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,
|
if err := c.conversationDatabase.UpdateUsersConversationFiled(ctx, req.OwnerUserID, req.ConversationID,
|
||||||
map[string]interface{}{"max_seq": req.MaxSeq}); err != nil {
|
map[string]interface{}{"max_seq": req.MaxSeq}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pbconversation.SetConversationMaxSeqResp{}, nil
|
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)
|
conversationIDs, err := c.conversationDatabase.GetConversationIDs(ctx, req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pbconversation.GetConversationIDsResp{ConversationIDs: conversationIDs}, nil
|
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)
|
hash, err := c.conversationDatabase.GetUserConversationIDsHash(ctx, req.OwnerUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pbconversation.GetUserConversationIDsHashResp{Hash: hash}, nil
|
return &pbConversation.GetUserConversationIDsHashResp{Hash: hash}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) GetConversationsByConversationID(
|
func (c *conversationServer) GetConversationsByConversationID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbconversation.GetConversationsByConversationIDReq,
|
req *pbConversation.GetConversationsByConversationIDReq,
|
||||||
) (*pbconversation.GetConversationsByConversationIDResp, error) {
|
) (*pbConversation.GetConversationsByConversationIDResp, error) {
|
||||||
conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, req.ConversationIDs)
|
conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, req.ConversationIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pbconversation.GetConversationsByConversationIDResp{Conversations: convert.ConversationsDB2Pb(conversations)}, nil
|
return &pbConversation.GetConversationsByConversationIDResp{Conversations: convert.ConversationsDB2Pb(conversations)}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
||||||
|
|
||||||
pbfriend "github.com/OpenIMSDK/protocol/friend"
|
pbFriend "github.com/OpenIMSDK/protocol/friend"
|
||||||
"github.com/OpenIMSDK/tools/mcontext"
|
"github.com/OpenIMSDK/tools/mcontext"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
||||||
@@ -29,8 +29,8 @@ import (
|
|||||||
|
|
||||||
func (s *friendServer) GetPaginationBlacks(
|
func (s *friendServer) GetPaginationBlacks(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbfriend.GetPaginationBlacksReq,
|
req *pbFriend.GetPaginationBlacksReq,
|
||||||
) (resp *pbfriend.GetPaginationBlacksResp, err error) {
|
) (resp *pbFriend.GetPaginationBlacksResp, err error) {
|
||||||
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
|
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ func (s *friendServer) GetPaginationBlacks(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp = &pbfriend.GetPaginationBlacksResp{}
|
resp = &pbFriend.GetPaginationBlacksResp{}
|
||||||
resp.Blacks, err = convert.BlackDB2Pb(ctx, blacks, s.userRpcClient.GetUsersInfoMap)
|
resp.Blacks, err = convert.BlackDB2Pb(ctx, blacks, s.userRpcClient.GetUsersInfoMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -52,12 +52,12 @@ func (s *friendServer) GetPaginationBlacks(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *friendServer) IsBlack(ctx context.Context, req *pbfriend.IsBlackReq) (*pbfriend.IsBlackResp, error) {
|
func (s *friendServer) IsBlack(ctx context.Context, req *pbFriend.IsBlackReq) (*pbFriend.IsBlackResp, error) {
|
||||||
in1, in2, err := s.blackDatabase.CheckIn(ctx, req.UserID1, req.UserID2)
|
in1, in2, err := s.blackDatabase.CheckIn(ctx, req.UserID1, req.UserID2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp := &pbfriend.IsBlackResp{}
|
resp := &pbFriend.IsBlackResp{}
|
||||||
resp.InUser1Blacks = in1
|
resp.InUser1Blacks = in1
|
||||||
resp.InUser2Blacks = in2
|
resp.InUser2Blacks = in2
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@@ -65,8 +65,8 @@ func (s *friendServer) IsBlack(ctx context.Context, req *pbfriend.IsBlackReq) (*
|
|||||||
|
|
||||||
func (s *friendServer) RemoveBlack(
|
func (s *friendServer) RemoveBlack(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbfriend.RemoveBlackReq,
|
req *pbFriend.RemoveBlackReq,
|
||||||
) (*pbfriend.RemoveBlackResp, error) {
|
) (*pbFriend.RemoveBlackResp, error) {
|
||||||
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
|
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -74,10 +74,10 @@ func (s *friendServer) RemoveBlack(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.notificationSender.BlackDeletedNotification(ctx, req)
|
s.notificationSender.BlackDeletedNotification(ctx, req)
|
||||||
return &pbfriend.RemoveBlackResp{}, nil
|
return &pbFriend.RemoveBlackResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *friendServer) AddBlack(ctx context.Context, req *pbfriend.AddBlackReq) (*pbfriend.AddBlackResp, error) {
|
func (s *friendServer) AddBlack(ctx context.Context, req *pbFriend.AddBlackReq) (*pbFriend.AddBlackResp, error) {
|
||||||
if err := authverify.CheckAccessV3(ctx, req.OwnerUserID); err != nil {
|
if err := authverify.CheckAccessV3(ctx, req.OwnerUserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -95,5 +95,5 @@ func (s *friendServer) AddBlack(ctx context.Context, req *pbfriend.AddBlackReq)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.notificationSender.BlackAddedNotification(ctx, req)
|
s.notificationSender.BlackAddedNotification(ctx, req)
|
||||||
return &pbfriend.AddBlackResp{}, nil
|
return &pbFriend.AddBlackResp{}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,31 +17,31 @@ package group
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
pbgroup "github.com/OpenIMSDK/protocol/group"
|
pbGroup "github.com/OpenIMSDK/protocol/group"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *groupServer) GetGroupInfoCache(
|
func (s *groupServer) GetGroupInfoCache(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbgroup.GetGroupInfoCacheReq,
|
req *pbGroup.GetGroupInfoCacheReq,
|
||||||
) (resp *pbgroup.GetGroupInfoCacheResp, err error) {
|
) (resp *pbGroup.GetGroupInfoCacheResp, err error) {
|
||||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp = &pbgroup.GetGroupInfoCacheResp{GroupInfo: convert.Db2PbGroupInfo(group, "", 0)}
|
resp = &pbGroup.GetGroupInfoCacheResp{GroupInfo: convert.Db2PbGroupInfo(group, "", 0)}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMemberCache(
|
func (s *groupServer) GetGroupMemberCache(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbgroup.GetGroupMemberCacheReq,
|
req *pbGroup.GetGroupMemberCacheReq,
|
||||||
) (resp *pbgroup.GetGroupMemberCacheResp, err error) {
|
) (resp *pbGroup.GetGroupMemberCacheResp, err error) {
|
||||||
members, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.GroupMemberID)
|
members, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.GroupMemberID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp = &pbgroup.GetGroupMemberCacheResp{Member: convert.Db2PbGroupMember(members)}
|
resp = &pbGroup.GetGroupMemberCacheResp{Member: convert.Db2PbGroupMember(members)}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/tools/mcontext"
|
"github.com/OpenIMSDK/tools/mcontext"
|
||||||
|
|
||||||
pbgroup "github.com/OpenIMSDK/protocol/group"
|
pbGroup "github.com/OpenIMSDK/protocol/group"
|
||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
"github.com/OpenIMSDK/protocol/sdkws"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -49,9 +49,6 @@ func UpdateGroupInfoMap(ctx context.Context, group *sdkws.GroupInfoForSet) map[s
|
|||||||
if group.ApplyMemberFriend != nil {
|
if group.ApplyMemberFriend != nil {
|
||||||
m["apply_member_friend"] = group.ApplyMemberFriend.Value
|
m["apply_member_friend"] = group.ApplyMemberFriend.Value
|
||||||
}
|
}
|
||||||
if group.Ex != nil {
|
|
||||||
m["ex"] = group.Ex.Value
|
|
||||||
}
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +64,7 @@ func UpdateGroupMemberMutedTimeMap(t time.Time) map[string]any {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateGroupMemberMap(req *pbgroup.SetGroupMemberInfo) map[string]any {
|
func UpdateGroupMemberMap(req *pbGroup.SetGroupMemberInfo) map[string]any {
|
||||||
m := make(map[string]any)
|
m := make(map[string]any)
|
||||||
if req.Nickname != nil {
|
if req.Nickname != nil {
|
||||||
m["nickname"] = req.Nickname.Value
|
m["nickname"] = req.Nickname.Value
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *groupServer) FindGroupMember(
|
func (s *groupServer) FindGroupMember(
|
||||||
@@ -27,7 +27,7 @@ func (s *groupServer) FindGroupMember(
|
|||||||
groupIDs []string,
|
groupIDs []string,
|
||||||
userIDs []string,
|
userIDs []string,
|
||||||
roleLevels []int32,
|
roleLevels []int32,
|
||||||
) ([]*relationtb.GroupMemberModel, error) {
|
) ([]*relationTb.GroupMemberModel, error) {
|
||||||
members, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, userIDs, roleLevels)
|
members, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, userIDs, roleLevels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -63,7 +63,7 @@ func (s *groupServer) TakeGroupMember(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
userID string,
|
userID string,
|
||||||
) (*relationtb.GroupMemberModel, error) {
|
) (*relationTb.GroupMemberModel, error) {
|
||||||
member, err := s.GroupDatabase.TakeGroupMember(ctx, groupID, userID)
|
member, err := s.GroupDatabase.TakeGroupMember(ctx, groupID, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -83,7 +83,7 @@ func (s *groupServer) TakeGroupMember(
|
|||||||
return member, nil
|
return member, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) TakeGroupOwner(ctx context.Context, groupID string) (*relationtb.GroupMemberModel, error) {
|
func (s *groupServer) TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error) {
|
||||||
owner, err := s.GroupDatabase.TakeGroupOwner(ctx, groupID)
|
owner, err := s.GroupDatabase.TakeGroupOwner(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -107,7 +107,7 @@ func (s *groupServer) PageGetGroupMember(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (uint32, []*relationtb.GroupMemberModel, error) {
|
) (uint32, []*relationTb.GroupMemberModel, error) {
|
||||||
total, members, err := s.GroupDatabase.PageGetGroupMember(ctx, groupID, pageNumber, showNumber)
|
total, members, err := s.GroupDatabase.PageGetGroupMember(ctx, groupID, pageNumber, showNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, err
|
return 0, nil, err
|
||||||
|
|||||||
+116
-116
@@ -29,7 +29,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
|
||||||
|
|
||||||
pbconversation "github.com/OpenIMSDK/protocol/conversation"
|
pbConversation "github.com/OpenIMSDK/protocol/conversation"
|
||||||
"github.com/OpenIMSDK/protocol/wrapperspb"
|
"github.com/OpenIMSDK/protocol/wrapperspb"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
||||||
@@ -42,7 +42,7 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
pbgroup "github.com/OpenIMSDK/protocol/group"
|
pbGroup "github.com/OpenIMSDK/protocol/group"
|
||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
"github.com/OpenIMSDK/protocol/sdkws"
|
||||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
@@ -53,7 +53,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := db.AutoMigrate(&relationtb.GroupModel{}, &relationtb.GroupMemberModel{}, &relationtb.GroupRequestModel{}); err != nil {
|
if err := db.AutoMigrate(&relationTb.GroupModel{}, &relationTb.GroupMemberModel{}, &relationTb.GroupRequestModel{}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
mongo, err := unrelation.NewMongo()
|
mongo, err := unrelation.NewMongo()
|
||||||
@@ -89,8 +89,8 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
})
|
})
|
||||||
gs.conversationRpcClient = conversationRpcClient
|
gs.conversationRpcClient = conversationRpcClient
|
||||||
gs.msgRpcClient = msgRpcClient
|
gs.msgRpcClient = msgRpcClient
|
||||||
pbgroup.RegisterGroupServer(server, &gs)
|
pbGroup.RegisterGroupServer(server, &gs)
|
||||||
//pbgroup.RegisterGroupServer(server, &groupServer{
|
//pbGroup.RegisterGroupServer(server, &groupServer{
|
||||||
// GroupDatabase: database,
|
// GroupDatabase: database,
|
||||||
// User: userRpcClient,
|
// User: userRpcClient,
|
||||||
// Notification: notification.NewGroupNotificationSender(database, &msgRpcClient, &userRpcClient, func(ctx context.Context, userIDs []string) ([]notification.CommonUser, error) {
|
// Notification: notification.NewGroupNotificationSender(database, &msgRpcClient, &userRpcClient, func(ctx context.Context, userIDs []string) ([]notification.CommonUser, error) {
|
||||||
@@ -173,7 +173,7 @@ func (s *groupServer) GenGroupID(ctx context.Context, groupID *string) error {
|
|||||||
return errs.ErrData.Wrap("group id gen error")
|
return errs.ErrData.Wrap("group id gen error")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupReq) (*pbgroup.CreateGroupResp, error) {
|
func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupReq) (*pbGroup.CreateGroupResp, error) {
|
||||||
if req.OwnerUserID == "" {
|
if req.OwnerUserID == "" {
|
||||||
return nil, errs.ErrArgs.Wrap("no group owner")
|
return nil, errs.ErrArgs.Wrap("no group owner")
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR
|
|||||||
if err := CallbackBeforeCreateGroup(ctx, req); err != nil {
|
if err := CallbackBeforeCreateGroup(ctx, req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var groupMembers []*relationtb.GroupMemberModel
|
var groupMembers []*relationTb.GroupMemberModel
|
||||||
group := convert.Pb2DBGroupInfo(req.GroupInfo)
|
group := convert.Pb2DBGroupInfo(req.GroupInfo)
|
||||||
if err := s.GenGroupID(ctx, &group.GroupID); err != nil {
|
if err := s.GenGroupID(ctx, &group.GroupID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -241,10 +241,10 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := s.GroupDatabase.CreateGroup(ctx, []*relationtb.GroupModel{group}, groupMembers); err != nil {
|
if err := s.GroupDatabase.CreateGroup(ctx, []*relationTb.GroupModel{group}, groupMembers); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp := &pbgroup.CreateGroupResp{GroupInfo: &sdkws.GroupInfo{}}
|
resp := &pbGroup.CreateGroupResp{GroupInfo: &sdkws.GroupInfo{}}
|
||||||
resp.GroupInfo = convert.Db2PbGroupInfo(group, req.OwnerUserID, uint32(len(userIDs)))
|
resp.GroupInfo = convert.Db2PbGroupInfo(group, req.OwnerUserID, uint32(len(userIDs)))
|
||||||
resp.GroupInfo.MemberCount = uint32(len(userIDs))
|
resp.GroupInfo.MemberCount = uint32(len(userIDs))
|
||||||
if req.GroupInfo.GroupType == constant.SuperGroup {
|
if req.GroupInfo.GroupType == constant.SuperGroup {
|
||||||
@@ -273,8 +273,8 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.GetJoinedGroupListResp{}
|
||||||
if err := authverify.CheckAccessV3(ctx, req.FromUserID); err != nil {
|
if err := authverify.CheckAccessV3(ctx, req.FromUserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -292,7 +292,7 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbgroup.GetJo
|
|||||||
if len(members) == 0 {
|
if len(members) == 0 {
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
groupIDs := utils.Slice(members, func(e *relationtb.GroupMemberModel) string {
|
groupIDs := utils.Slice(members, func(e *relationTb.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
groups, err := s.GroupDatabase.FindGroup(ctx, groupIDs)
|
groups, err := s.GroupDatabase.FindGroup(ctx, groupIDs)
|
||||||
@@ -307,12 +307,12 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbgroup.GetJo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
resp.Groups = utils.Slice(utils.Order(groupIDs, groups, func(group *relationtb.GroupModel) string {
|
resp.Groups = utils.Slice(utils.Order(groupIDs, groups, func(group *relationTb.GroupModel) string {
|
||||||
return group.GroupID
|
return group.GroupID
|
||||||
}), func(group *relationtb.GroupModel) *sdkws.GroupInfo {
|
}), func(group *relationTb.GroupModel) *sdkws.GroupInfo {
|
||||||
var userID string
|
var userID string
|
||||||
if user := ownerMap[group.GroupID]; user != nil {
|
if user := ownerMap[group.GroupID]; user != nil {
|
||||||
userID = user.UserID
|
userID = user.UserID
|
||||||
@@ -322,8 +322,8 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbgroup.GetJo
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.InviteUserToGroupResp{}
|
||||||
if len(req.InvitedUserIDs) == 0 {
|
if len(req.InvitedUserIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("user empty")
|
return nil, errs.ErrArgs.Wrap("user empty")
|
||||||
}
|
}
|
||||||
@@ -341,7 +341,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var groupMember *relationtb.GroupMemberModel
|
var groupMember *relationTb.GroupMemberModel
|
||||||
var opUserID string
|
var opUserID string
|
||||||
if !authverify.IsAppManagerUid(ctx) {
|
if !authverify.IsAppManagerUid(ctx) {
|
||||||
opUserID = mcontext.GetOpUserID(ctx)
|
opUserID = mcontext.GetOpUserID(ctx)
|
||||||
@@ -357,9 +357,9 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
if group.NeedVerification == constant.AllNeedVerification {
|
if group.NeedVerification == constant.AllNeedVerification {
|
||||||
if !authverify.IsAppManagerUid(ctx) {
|
if !authverify.IsAppManagerUid(ctx) {
|
||||||
if !(groupMember.RoleLevel == constant.GroupOwner || groupMember.RoleLevel == constant.GroupAdmin) {
|
if !(groupMember.RoleLevel == constant.GroupOwner || groupMember.RoleLevel == constant.GroupAdmin) {
|
||||||
var requests []*relationtb.GroupRequestModel
|
var requests []*relationTb.GroupRequestModel
|
||||||
for _, userID := range req.InvitedUserIDs {
|
for _, userID := range req.InvitedUserIDs {
|
||||||
requests = append(requests, &relationtb.GroupRequestModel{
|
requests = append(requests, &relationTb.GroupRequestModel{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
GroupID: req.GroupID,
|
GroupID: req.GroupID,
|
||||||
JoinSource: constant.JoinByInvitation,
|
JoinSource: constant.JoinByInvitation,
|
||||||
@@ -372,7 +372,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, request := range requests {
|
for _, request := range requests {
|
||||||
s.Notification.JoinGroupApplicationNotification(ctx, &pbgroup.JoinGroupReq{
|
s.Notification.JoinGroupApplicationNotification(ctx, &pbGroup.JoinGroupReq{
|
||||||
GroupID: request.GroupID,
|
GroupID: request.GroupID,
|
||||||
ReqMessage: request.ReqMsg,
|
ReqMessage: request.ReqMsg,
|
||||||
JoinSource: request.JoinSource,
|
JoinSource: request.JoinSource,
|
||||||
@@ -396,7 +396,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
opUserID := mcontext.GetOpUserID(ctx)
|
opUserID := mcontext.GetOpUserID(ctx)
|
||||||
var groupMembers []*relationtb.GroupMemberModel
|
var groupMembers []*relationTb.GroupMemberModel
|
||||||
for _, userID := range req.InvitedUserIDs {
|
for _, userID := range req.InvitedUserIDs {
|
||||||
member := convert.Pb2DbGroupMember(userMap[userID])
|
member := convert.Pb2DbGroupMember(userMap[userID])
|
||||||
member.Nickname = ""
|
member.Nickname = ""
|
||||||
@@ -423,8 +423,8 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.GetGroupAllMemberResp{}
|
||||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -436,13 +436,13 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbgroup.GetGro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationtb.GroupMemberModel) (string, bool) {
|
nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) {
|
||||||
return e.UserID, e.Nickname == ""
|
return e.UserID, e.Nickname == ""
|
||||||
}), true)
|
}), true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Members = utils.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||||
if e.Nickname == "" {
|
if e.Nickname == "" {
|
||||||
e.Nickname = nameMap[e.UserID]
|
e.Nickname = nameMap[e.UserID]
|
||||||
}
|
}
|
||||||
@@ -451,8 +451,8 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbgroup.GetGro
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.GetGroupMemberListResp{}
|
||||||
total, members, err := s.PageGetGroupMember(ctx, req.GroupID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
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))
|
log.ZDebug(ctx, "GetGroupMemberList", "total", total, "members", members, "length", len(members))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -464,8 +464,8 @@ func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbgroup.GetGr
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.KickGroupMemberResp{}
|
||||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -494,7 +494,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGrou
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
memberMap := make(map[string]*relationtb.GroupMemberModel)
|
memberMap := make(map[string]*relationTb.GroupMemberModel)
|
||||||
for i, member := range members {
|
for i, member := range members {
|
||||||
memberMap[member.UserID] = members[i]
|
memberMap[member.UserID] = members[i]
|
||||||
}
|
}
|
||||||
@@ -572,8 +572,8 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGrou
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.GetGroupMembersInfoResp{}
|
||||||
if len(req.UserIDs) == 0 {
|
if len(req.UserIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("userIDs empty")
|
return nil, errs.ErrArgs.Wrap("userIDs empty")
|
||||||
}
|
}
|
||||||
@@ -584,13 +584,13 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbgroup.GetG
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationtb.GroupMemberModel) (string, bool) {
|
nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) {
|
||||||
return e.UserID, e.Nickname == ""
|
return e.UserID, e.Nickname == ""
|
||||||
}), true)
|
}), true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Members = utils.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||||
if e.Nickname == "" {
|
if e.Nickname == "" {
|
||||||
e.Nickname = nameMap[e.UserID]
|
e.Nickname = nameMap[e.UserID]
|
||||||
}
|
}
|
||||||
@@ -599,12 +599,12 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbgroup.GetG
|
|||||||
return resp, nil
|
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) {
|
||||||
groupIDs, err := s.GroupDatabase.FindUserManagedGroupID(ctx, req.FromUserID)
|
groupIDs, err := s.GroupDatabase.FindUserManagedGroupID(ctx, req.FromUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp := &pbgroup.GetGroupApplicationListResp{}
|
resp := &pbGroup.GetGroupApplicationListResp{}
|
||||||
if len(groupIDs) == 0 {
|
if len(groupIDs) == 0 {
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
@@ -630,7 +630,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbgroup.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groupMap := utils.SliceToMap(groups, func(e *relationtb.GroupModel) string {
|
groupMap := utils.SliceToMap(groups, func(e *relationTb.GroupModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(utils.Keys(groupMap), groupIDs); len(ids) > 0 {
|
if ids := utils.Single(utils.Keys(groupMap), groupIDs); len(ids) > 0 {
|
||||||
@@ -644,17 +644,17 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbgroup.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
resp.GroupRequests = utils.Slice(groupRequests, func(e *relationtb.GroupRequestModel) *sdkws.GroupRequest {
|
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
|
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{}
|
resp := &pbGroup.GetGroupsInfoResp{}
|
||||||
if len(req.GroupIDs) == 0 {
|
if len(req.GroupIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("groupID is empty")
|
return nil, errs.ErrArgs.Wrap("groupID is empty")
|
||||||
}
|
}
|
||||||
@@ -670,10 +670,10 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbgroup.GetGroupsI
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
resp.GroupInfos = utils.Slice(groups, func(e *relationtb.GroupModel) *sdkws.GroupInfo {
|
resp.GroupInfos = utils.Slice(groups, func(e *relationTb.GroupModel) *sdkws.GroupInfo {
|
||||||
var ownerUserID string
|
var ownerUserID string
|
||||||
if owner, ok := ownerMap[e.GroupID]; ok {
|
if owner, ok := ownerMap[e.GroupID]; ok {
|
||||||
ownerUserID = owner.UserID
|
ownerUserID = owner.UserID
|
||||||
@@ -683,7 +683,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbgroup.GetGroupsI
|
|||||||
return resp, nil
|
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")
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
||||||
if !utils.Contain(req.HandleResult, constant.GroupResponseAgree, constant.GroupResponseRefuse) {
|
if !utils.Contain(req.HandleResult, constant.GroupResponseAgree, constant.GroupResponseRefuse) {
|
||||||
return nil, errs.ErrArgs.Wrap("HandleResult unknown")
|
return nil, errs.ErrArgs.Wrap("HandleResult unknown")
|
||||||
@@ -717,9 +717,9 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup
|
|||||||
if _, err := s.User.GetPublicUserInfo(ctx, req.FromUserID); err != nil {
|
if _, err := s.User.GetPublicUserInfo(ctx, req.FromUserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var member *relationtb.GroupMemberModel
|
var member *relationTb.GroupMemberModel
|
||||||
if (!inGroup) && req.HandleResult == constant.GroupResponseAgree {
|
if (!inGroup) && req.HandleResult == constant.GroupResponseAgree {
|
||||||
member = &relationtb.GroupMemberModel{
|
member = &relationTb.GroupMemberModel{
|
||||||
GroupID: req.GroupID,
|
GroupID: req.GroupID,
|
||||||
UserID: req.FromUserID,
|
UserID: req.FromUserID,
|
||||||
Nickname: "",
|
Nickname: "",
|
||||||
@@ -754,10 +754,10 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup
|
|||||||
case constant.GroupResponseRefuse:
|
case constant.GroupResponseRefuse:
|
||||||
s.Notification.GroupApplicationRejectedNotification(ctx, req)
|
s.Notification.GroupApplicationRejectedNotification(ctx, req)
|
||||||
}
|
}
|
||||||
return &pbgroup.GroupApplicationResponseResp{}, nil
|
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")
|
defer log.ZInfo(ctx, "JoinGroup.Return")
|
||||||
user, err := s.User.GetUserInfo(ctx, req.InviterUserID)
|
user, err := s.User.GetUserInfo(ctx, req.InviterUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -777,7 +777,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.ZInfo(ctx, "JoinGroup.groupInfo", "group", group, "eq", group.NeedVerification == constant.Directly)
|
log.ZInfo(ctx, "JoinGroup.groupInfo", "group", group, "eq", group.NeedVerification == constant.Directly)
|
||||||
resp = &pbgroup.JoinGroupResp{}
|
resp = &pbGroup.JoinGroupResp{}
|
||||||
if group.NeedVerification == constant.Directly {
|
if group.NeedVerification == constant.Directly {
|
||||||
if group.GroupType == constant.SuperGroup {
|
if group.GroupType == constant.SuperGroup {
|
||||||
return nil, errs.ErrGroupTypeNotSupport.Wrap()
|
return nil, errs.ErrGroupTypeNotSupport.Wrap()
|
||||||
@@ -793,7 +793,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
|||||||
if err := CallbackBeforeMemberJoinGroup(ctx, groupMember, group.Ex); err != nil {
|
if err := CallbackBeforeMemberJoinGroup(ctx, groupMember, group.Ex); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := s.GroupDatabase.CreateGroup(ctx, nil, []*relationtb.GroupMemberModel{groupMember}); err != nil {
|
if err := s.GroupDatabase.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := s.conversationRpcClient.GroupChatFirstCreateConversation(ctx, req.GroupID, []string{req.InviterUserID}); err != nil {
|
if err := s.conversationRpcClient.GroupChatFirstCreateConversation(ctx, req.GroupID, []string{req.InviterUserID}); err != nil {
|
||||||
@@ -802,7 +802,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
|||||||
s.Notification.MemberEnterNotification(ctx, req.GroupID, req.InviterUserID)
|
s.Notification.MemberEnterNotification(ctx, req.GroupID, req.InviterUserID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
groupRequest := relationtb.GroupRequestModel{
|
groupRequest := relationTb.GroupRequestModel{
|
||||||
UserID: req.InviterUserID,
|
UserID: req.InviterUserID,
|
||||||
ReqMsg: req.ReqMessage,
|
ReqMsg: req.ReqMessage,
|
||||||
GroupID: req.GroupID,
|
GroupID: req.GroupID,
|
||||||
@@ -810,15 +810,15 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
|||||||
ReqTime: time.Now(),
|
ReqTime: time.Now(),
|
||||||
HandledTime: time.Unix(0, 0),
|
HandledTime: time.Unix(0, 0),
|
||||||
}
|
}
|
||||||
if err := s.GroupDatabase.CreateGroupRequest(ctx, []*relationtb.GroupRequestModel{&groupRequest}); err != nil {
|
if err := s.GroupDatabase.CreateGroupRequest(ctx, []*relationTb.GroupRequestModel{&groupRequest}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.Notification.JoinGroupApplicationNotification(ctx, req)
|
s.Notification.JoinGroupApplicationNotification(ctx, req)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) QuitGroup(ctx context.Context, req *pbgroup.QuitGroupReq) (*pbgroup.QuitGroupResp, error) {
|
func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) (*pbGroup.QuitGroupResp, error) {
|
||||||
resp := &pbgroup.QuitGroupResp{}
|
resp := &pbGroup.QuitGroupResp{}
|
||||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -857,8 +857,8 @@ func (s *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, gro
|
|||||||
return s.conversationRpcClient.SetConversationMaxSeq(ctx, userIDs, conevrsationID, maxSeq)
|
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
|
var opMember *relationTb.GroupMemberModel
|
||||||
if !authverify.IsAppManagerUid(ctx) {
|
if !authverify.IsAppManagerUid(ctx) {
|
||||||
var err error
|
var err error
|
||||||
opMember, err = s.TakeGroupMember(ctx, req.GroupInfoForSet.GroupID, mcontext.GetOpUserID(ctx))
|
opMember, err = s.TakeGroupMember(ctx, req.GroupInfoForSet.GroupID, mcontext.GetOpUserID(ctx))
|
||||||
@@ -876,7 +876,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbgroup.SetGroupInf
|
|||||||
if group.Status == constant.GroupStatusDismissed {
|
if group.Status == constant.GroupStatusDismissed {
|
||||||
return nil, utils.Wrap(errs.ErrDismissedAlready, "")
|
return nil, utils.Wrap(errs.ErrDismissedAlready, "")
|
||||||
}
|
}
|
||||||
resp := &pbgroup.SetGroupInfoResp{}
|
resp := &pbGroup.SetGroupInfoResp{}
|
||||||
count, err := s.GroupDatabase.FindGroupMemberNum(ctx, group.GroupID)
|
count, err := s.GroupDatabase.FindGroupMemberNum(ctx, group.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -908,12 +908,12 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbgroup.SetGroupInf
|
|||||||
if req.GroupInfoForSet.Notification != "" {
|
if req.GroupInfoForSet.Notification != "" {
|
||||||
go func() {
|
go func() {
|
||||||
nctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(ctx))
|
nctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(ctx))
|
||||||
conversation := &pbconversation.ConversationReq{
|
conversation := &pbConversation.ConversationReq{
|
||||||
ConversationID: msgprocessor.GetConversationIDBySessionType(constant.SuperGroupChatType, req.GroupInfoForSet.GroupID),
|
ConversationID: msgprocessor.GetConversationIDBySessionType(constant.SuperGroupChatType, req.GroupInfoForSet.GroupID),
|
||||||
ConversationType: constant.SuperGroupChatType,
|
ConversationType: constant.SuperGroupChatType,
|
||||||
GroupID: req.GroupInfoForSet.GroupID,
|
GroupID: req.GroupInfoForSet.GroupID,
|
||||||
}
|
}
|
||||||
resp, err := s.GetGroupMemberUserIDs(nctx, &pbgroup.GetGroupMemberUserIDsReq{GroupID: req.GroupInfoForSet.GroupID})
|
resp, err := s.GetGroupMemberUserIDs(nctx, &pbGroup.GetGroupMemberUserIDsReq{GroupID: req.GroupInfoForSet.GroupID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(ctx, "GetGroupMemberIDs", err)
|
log.ZWarn(ctx, "GetGroupMemberIDs", err)
|
||||||
return
|
return
|
||||||
@@ -940,8 +940,8 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbgroup.SetGroupInf
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.TransferGroupOwnerResp{}
|
||||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -956,7 +956,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbgroup.Trans
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
memberMap := utils.SliceToMap(members, func(e *relationtb.GroupMemberModel) string { return e.UserID })
|
memberMap := utils.SliceToMap(members, func(e *relationTb.GroupMemberModel) string { return e.UserID })
|
||||||
if ids := utils.Single([]string{req.OldOwnerUserID, req.NewOwnerUserID}, utils.Keys(memberMap)); len(ids) > 0 {
|
if ids := utils.Single([]string{req.OldOwnerUserID, req.NewOwnerUserID}, utils.Keys(memberMap)); len(ids) > 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("user not in group " + strings.Join(ids, ","))
|
return nil, errs.ErrArgs.Wrap("user not in group " + strings.Join(ids, ","))
|
||||||
}
|
}
|
||||||
@@ -980,10 +980,10 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbgroup.Trans
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq) (*pbgroup.GetGroupsResp, error) {
|
func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq) (*pbGroup.GetGroupsResp, error) {
|
||||||
resp := &pbgroup.GetGroupsResp{}
|
resp := &pbGroup.GetGroupsResp{}
|
||||||
var (
|
var (
|
||||||
groups []*relationtb.GroupModel
|
groups []*relationTb.GroupModel
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if req.GroupID != "" {
|
if req.GroupID != "" {
|
||||||
@@ -995,14 +995,14 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groupIDs := utils.Slice(groups, func(e *relationtb.GroupModel) string {
|
groupIDs := utils.Slice(groups, func(e *relationTb.GroupModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
ownerMembers, err := s.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
ownerMembers, err := s.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ownerMemberMap := utils.SliceToMap(ownerMembers, func(e *relationtb.GroupMemberModel) string {
|
ownerMemberMap := utils.SliceToMap(ownerMembers, func(e *relationTb.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(groupIDs, utils.Keys(ownerMemberMap)); len(ids) > 0 {
|
if ids := utils.Single(groupIDs, utils.Keys(ownerMemberMap)); len(ids) > 0 {
|
||||||
@@ -1012,27 +1012,27 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Groups = utils.Slice(groups, func(group *relationtb.GroupModel) *pbgroup.CMSGroup {
|
resp.Groups = utils.Slice(groups, func(group *relationTb.GroupModel) *pbGroup.CMSGroup {
|
||||||
member := ownerMemberMap[group.GroupID]
|
member := ownerMemberMap[group.GroupID]
|
||||||
return convert.Db2PbCMSGroup(group, member.UserID, member.Nickname, uint32(groupMemberNumMap[group.GroupID]))
|
return convert.Db2PbCMSGroup(group, member.UserID, member.Nickname, uint32(groupMemberNumMap[group.GroupID]))
|
||||||
})
|
})
|
||||||
return resp, nil
|
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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Total = total
|
resp.Total = total
|
||||||
nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationtb.GroupMemberModel) (string, bool) {
|
nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) {
|
||||||
return e.UserID, e.Nickname == ""
|
return e.UserID, e.Nickname == ""
|
||||||
}), true)
|
}), true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Members = utils.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||||
if e.Nickname == "" {
|
if e.Nickname == "" {
|
||||||
e.Nickname = nameMap[e.UserID]
|
e.Nickname = nameMap[e.UserID]
|
||||||
}
|
}
|
||||||
@@ -1041,8 +1041,8 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbgroup.GetGr
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.GetUserReqApplicationListResp{}
|
||||||
user, err := s.User.GetPublicUserInfo(ctx, req.UserID)
|
user, err := s.User.GetPublicUserInfo(ctx, req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -1060,14 +1060,14 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbgrou
|
|||||||
if len(requests) == 0 {
|
if len(requests) == 0 {
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
groupIDs := utils.Distinct(utils.Slice(requests, func(e *relationtb.GroupRequestModel) string {
|
groupIDs := utils.Distinct(utils.Slice(requests, func(e *relationTb.GroupRequestModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
}))
|
}))
|
||||||
groups, err := s.GroupDatabase.FindNotDismissedGroup(ctx, groupIDs)
|
groups, err := s.GroupDatabase.FindNotDismissedGroup(ctx, groupIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groupMap := utils.SliceToMap(groups, func(e *relationtb.GroupModel) string {
|
groupMap := utils.SliceToMap(groups, func(e *relationTb.GroupModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(groupIDs, utils.Keys(groupMap)); len(ids) > 0 {
|
if ids := utils.Single(groupIDs, utils.Keys(groupMap)); len(ids) > 0 {
|
||||||
@@ -1077,7 +1077,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbgrou
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(groupIDs, utils.Keys(ownerMap)); len(ids) > 0 {
|
if ids := utils.Single(groupIDs, utils.Keys(ownerMap)); len(ids) > 0 {
|
||||||
@@ -1087,15 +1087,15 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbgrou
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.GroupRequests = utils.Slice(requests, func(e *relationtb.GroupRequestModel) *sdkws.GroupRequest {
|
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
|
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")
|
defer log.ZInfo(ctx, "DismissGroup.return")
|
||||||
resp := &pbgroup.DismissGroupResp{}
|
resp := &pbGroup.DismissGroupResp{}
|
||||||
owner, err := s.TakeGroupOwner(ctx, req.GroupID)
|
owner, err := s.TakeGroupOwner(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -1142,8 +1142,8 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbgroup.DismissGrou
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.MuteGroupMemberResp{}
|
||||||
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
|
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
//}
|
//}
|
||||||
@@ -1177,8 +1177,8 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbgroup.MuteGrou
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.CancelMuteGroupMemberResp{}
|
||||||
//member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
//member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||||
//if err != nil {
|
//if err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
@@ -1225,8 +1225,8 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbgroup.Ca
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) MuteGroup(ctx context.Context, req *pbgroup.MuteGroupReq) (*pbgroup.MuteGroupResp, error) {
|
func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) (*pbGroup.MuteGroupResp, error) {
|
||||||
resp := &pbgroup.MuteGroupResp{}
|
resp := &pbGroup.MuteGroupResp{}
|
||||||
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -1237,8 +1237,8 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbgroup.MuteGroupReq)
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.CancelMuteGroupResp{}
|
||||||
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -1249,8 +1249,8 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbgroup.CancelMu
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.SetGroupMemberInfoResp{}
|
||||||
if len(req.Members) == 0 {
|
if len(req.Members) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("members empty")
|
return nil, errs.ErrArgs.Wrap("members empty")
|
||||||
}
|
}
|
||||||
@@ -1280,7 +1280,7 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbgroup.SetGr
|
|||||||
return fmt.Sprintf("[group: %s user: %s]", e[0], e[1])
|
return fmt.Sprintf("[group: %s user: %s]", e[0], e[1])
|
||||||
}), ","))
|
}), ","))
|
||||||
}
|
}
|
||||||
memberMap := utils.SliceToMap(members, func(e *relationtb.GroupMemberModel) [2]string {
|
memberMap := utils.SliceToMap(members, func(e *relationTb.GroupMemberModel) [2]string {
|
||||||
return [...]string{e.GroupID, e.UserID}
|
return [...]string{e.GroupID, e.UserID}
|
||||||
})
|
})
|
||||||
if !authverify.IsAppManagerUid(ctx) {
|
if !authverify.IsAppManagerUid(ctx) {
|
||||||
@@ -1349,8 +1349,8 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbgroup.SetGr
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err = s.GroupDatabase.UpdateGroupMembers(ctx, utils.Slice(req.Members, func(e *pbgroup.SetGroupMemberInfo) *relationtb.BatchUpdateGroupMember {
|
if err = s.GroupDatabase.UpdateGroupMembers(ctx, utils.Slice(req.Members, func(e *pbGroup.SetGroupMemberInfo) *relationTb.BatchUpdateGroupMember {
|
||||||
return &relationtb.BatchUpdateGroupMember{
|
return &relationTb.BatchUpdateGroupMember{
|
||||||
GroupID: e.GroupID,
|
GroupID: e.GroupID,
|
||||||
UserID: e.UserID,
|
UserID: e.UserID,
|
||||||
Map: UpdateGroupMemberMap(e),
|
Map: UpdateGroupMemberMap(e),
|
||||||
@@ -1377,8 +1377,8 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbgroup.SetGr
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.GetGroupAbstractInfoResp{}
|
||||||
if len(req.GroupIDs) == 0 {
|
if len(req.GroupIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
||||||
}
|
}
|
||||||
@@ -1389,7 +1389,7 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbgroup.Get
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if ids := utils.Single(req.GroupIDs, utils.Slice(groups, func(group *relationtb.GroupModel) string {
|
if ids := utils.Single(req.GroupIDs, utils.Slice(groups, func(group *relationTb.GroupModel) string {
|
||||||
return group.GroupID
|
return group.GroupID
|
||||||
})); len(ids) > 0 {
|
})); len(ids) > 0 {
|
||||||
return nil, errs.ErrGroupIDNotFound.Wrap("not found group " + strings.Join(ids, ","))
|
return nil, errs.ErrGroupIDNotFound.Wrap("not found group " + strings.Join(ids, ","))
|
||||||
@@ -1401,15 +1401,15 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbgroup.Get
|
|||||||
if ids := utils.Single(req.GroupIDs, utils.Keys(groupUserMap)); len(ids) > 0 {
|
if ids := utils.Single(req.GroupIDs, utils.Keys(groupUserMap)); len(ids) > 0 {
|
||||||
return nil, errs.ErrGroupIDNotFound.Wrap(fmt.Sprintf("group %s not found member", strings.Join(ids, ",")))
|
return nil, errs.ErrGroupIDNotFound.Wrap(fmt.Sprintf("group %s not found member", strings.Join(ids, ",")))
|
||||||
}
|
}
|
||||||
resp.GroupAbstractInfos = utils.Slice(groups, func(group *relationtb.GroupModel) *pbgroup.GroupAbstractInfo {
|
resp.GroupAbstractInfos = utils.Slice(groups, func(group *relationTb.GroupModel) *pbGroup.GroupAbstractInfo {
|
||||||
users := groupUserMap[group.GroupID]
|
users := groupUserMap[group.GroupID]
|
||||||
return convert.Db2PbGroupAbstractInfo(group.GroupID, users.MemberNum, users.Hash)
|
return convert.Db2PbGroupAbstractInfo(group.GroupID, users.MemberNum, users.Hash)
|
||||||
})
|
})
|
||||||
return resp, nil
|
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{}
|
resp := &pbGroup.GetUserInGroupMembersResp{}
|
||||||
if len(req.GroupIDs) == 0 {
|
if len(req.GroupIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
||||||
}
|
}
|
||||||
@@ -1417,13 +1417,13 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbgroup.Ge
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationtb.GroupMemberModel) (string, bool) {
|
nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) {
|
||||||
return e.UserID, e.Nickname == ""
|
return e.UserID, e.Nickname == ""
|
||||||
}), true)
|
}), true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Members = utils.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||||
if e.Nickname == "" {
|
if e.Nickname == "" {
|
||||||
e.Nickname = nameMap[e.UserID]
|
e.Nickname = nameMap[e.UserID]
|
||||||
}
|
}
|
||||||
@@ -1432,8 +1432,8 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbgroup.Ge
|
|||||||
return resp, nil
|
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 = &pbGroup.GetGroupMemberUserIDsResp{}
|
||||||
resp.UserIDs, err = s.GroupDatabase.FindGroupMemberUserID(ctx, req.GroupID)
|
resp.UserIDs, err = s.GroupDatabase.FindGroupMemberUserID(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -1441,8 +1441,8 @@ func (s *groupServer) GetGroupMemberUserIDs(ctx context.Context, req *pbgroup.Ge
|
|||||||
return resp, nil
|
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{}
|
resp := &pbGroup.GetGroupMemberRoleLevelResp{}
|
||||||
if len(req.RoleLevels) == 0 {
|
if len(req.RoleLevels) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("RoleLevels empty")
|
return nil, errs.ErrArgs.Wrap("RoleLevels empty")
|
||||||
}
|
}
|
||||||
@@ -1450,13 +1450,13 @@ func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbgroup.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationtb.GroupMemberModel) (string, bool) {
|
nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) {
|
||||||
return e.UserID, e.Nickname == ""
|
return e.UserID, e.Nickname == ""
|
||||||
}), true)
|
}), true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Members = utils.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||||
if e.Nickname == "" {
|
if e.Nickname == "" {
|
||||||
e.Nickname = nameMap[e.UserID]
|
e.Nickname = nameMap[e.UserID]
|
||||||
}
|
}
|
||||||
@@ -1465,8 +1465,8 @@ func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbgroup.
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *pbgroup.GetGroupUsersReqApplicationListReq) (*pbgroup.GetGroupUsersReqApplicationListResp, error) {
|
func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *pbGroup.GetGroupUsersReqApplicationListReq) (*pbGroup.GetGroupUsersReqApplicationListResp, error) {
|
||||||
resp := &pbgroup.GetGroupUsersReqApplicationListResp{}
|
resp := &pbGroup.GetGroupUsersReqApplicationListResp{}
|
||||||
total, requests, err := s.GroupDatabase.FindGroupRequests(ctx, req.GroupID, req.UserIDs)
|
total, requests, err := s.GroupDatabase.FindGroupRequests(ctx, req.GroupID, req.UserIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -1474,14 +1474,14 @@ func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *
|
|||||||
if len(requests) == 0 {
|
if len(requests) == 0 {
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
groupIDs := utils.Distinct(utils.Slice(requests, func(e *relationtb.GroupRequestModel) string {
|
groupIDs := utils.Distinct(utils.Slice(requests, func(e *relationTb.GroupRequestModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
}))
|
}))
|
||||||
groups, err := s.GroupDatabase.FindGroup(ctx, groupIDs)
|
groups, err := s.GroupDatabase.FindGroup(ctx, groupIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groupMap := utils.SliceToMap(groups, func(e *relationtb.GroupModel) string {
|
groupMap := utils.SliceToMap(groups, func(e *relationTb.GroupModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(groupIDs, utils.Keys(groupMap)); len(ids) > 0 {
|
if ids := utils.Single(groupIDs, utils.Keys(groupMap)); len(ids) > 0 {
|
||||||
@@ -1491,7 +1491,7 @@ func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(groupIDs, utils.Keys(ownerMap)); len(ids) > 0 {
|
if ids := utils.Single(groupIDs, utils.Keys(ownerMap)); len(ids) > 0 {
|
||||||
@@ -1501,7 +1501,7 @@ func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.GroupRequests = utils.Slice(requests, func(e *relationtb.GroupRequestModel) *sdkws.GroupRequest {
|
resp.GroupRequests = utils.Slice(requests, func(e *relationTb.GroupRequestModel) *sdkws.GroupRequest {
|
||||||
return convert.Db2PbGroupRequest(e, nil, convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNum[e.GroupID])))
|
return convert.Db2PbGroupRequest(e, nil, convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNum[e.GroupID])))
|
||||||
})
|
})
|
||||||
resp.Total = total
|
resp.Total = total
|
||||||
@@ -1515,7 +1515,7 @@ func (s *groupServer) groupMemberHashCode(ctx context.Context, groupID string) (
|
|||||||
}
|
}
|
||||||
var members []*sdkws.GroupMemberFullInfo
|
var members []*sdkws.GroupMemberFullInfo
|
||||||
if len(userIDs) > 0 {
|
if len(userIDs) > 0 {
|
||||||
resp, err := s.GetGroupMembersInfo(ctx, &pbgroup.GetGroupMembersInfoReq{GroupID: groupID, UserIDs: userIDs})
|
resp, err := s.GetGroupMembersInfo(ctx, &pbGroup.GetGroupMembersInfoReq{GroupID: groupID, UserIDs: userIDs})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
pbgroup "github.com/OpenIMSDK/protocol/group"
|
pbGroup "github.com/OpenIMSDK/protocol/group"
|
||||||
sdkws "github.com/OpenIMSDK/protocol/sdkws"
|
sdkws "github.com/OpenIMSDK/protocol/sdkws"
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
@@ -32,9 +32,9 @@ import (
|
|||||||
|
|
||||||
func (s *groupServer) GetJoinedSuperGroupList(
|
func (s *groupServer) GetJoinedSuperGroupList(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbgroup.GetJoinedSuperGroupListReq,
|
req *pbGroup.GetJoinedSuperGroupListReq,
|
||||||
) (*pbgroup.GetJoinedSuperGroupListResp, error) {
|
) (*pbGroup.GetJoinedSuperGroupListResp, error) {
|
||||||
resp := &pbgroup.GetJoinedSuperGroupListResp{}
|
resp := &pbGroup.GetJoinedSuperGroupListResp{}
|
||||||
groupIDs, err := s.GroupDatabase.FindJoinSuperGroup(ctx, req.UserID)
|
groupIDs, err := s.GroupDatabase.FindJoinSuperGroup(ctx, req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -80,9 +80,9 @@ func (s *groupServer) GetJoinedSuperGroupList(
|
|||||||
|
|
||||||
func (s *groupServer) GetSuperGroupsInfo(
|
func (s *groupServer) GetSuperGroupsInfo(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbgroup.GetSuperGroupsInfoReq,
|
req *pbGroup.GetSuperGroupsInfoReq,
|
||||||
) (resp *pbgroup.GetSuperGroupsInfoResp, err error) {
|
) (resp *pbGroup.GetSuperGroupsInfoResp, err error) {
|
||||||
resp = &pbgroup.GetSuperGroupsInfoResp{}
|
resp = &pbGroup.GetSuperGroupsInfoResp{}
|
||||||
if len(req.GroupIDs) == 0 {
|
if len(req.GroupIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
pbchat "github.com/OpenIMSDK/protocol/msg"
|
pbChat "github.com/OpenIMSDK/protocol/msg"
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
"github.com/OpenIMSDK/tools/mcontext"
|
"github.com/OpenIMSDK/tools/mcontext"
|
||||||
@@ -36,7 +36,7 @@ func cbURL() string {
|
|||||||
return config.Config.Callback.CallbackUrl
|
return config.Config.Callback.CallbackUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
func toCommonCallback(ctx context.Context, msg *pbchat.SendMsgReq, command string) cbapi.CommonCallbackReq {
|
func toCommonCallback(ctx context.Context, msg *pbChat.SendMsgReq, command string) cbapi.CommonCallbackReq {
|
||||||
return cbapi.CommonCallbackReq{
|
return cbapi.CommonCallbackReq{
|
||||||
SendID: msg.MsgData.SendID,
|
SendID: msg.MsgData.SendID,
|
||||||
ServerMsgID: msg.MsgData.ServerMsgID,
|
ServerMsgID: msg.MsgData.ServerMsgID,
|
||||||
@@ -69,7 +69,7 @@ func GetContent(msg *sdkws.MsgData) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func callbackBeforeSendSingleMsg(ctx context.Context, msg *pbchat.SendMsgReq) error {
|
func callbackBeforeSendSingleMsg(ctx context.Context, msg *pbChat.SendMsgReq) error {
|
||||||
if !config.Config.Callback.CallbackBeforeSendSingleMsg.Enable {
|
if !config.Config.Callback.CallbackBeforeSendSingleMsg.Enable {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ func callbackBeforeSendSingleMsg(ctx context.Context, msg *pbchat.SendMsgReq) er
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func callbackAfterSendSingleMsg(ctx context.Context, msg *pbchat.SendMsgReq) error {
|
func callbackAfterSendSingleMsg(ctx context.Context, msg *pbChat.SendMsgReq) error {
|
||||||
if !config.Config.Callback.CallbackAfterSendSingleMsg.Enable {
|
if !config.Config.Callback.CallbackAfterSendSingleMsg.Enable {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ func callbackAfterSendSingleMsg(ctx context.Context, msg *pbchat.SendMsgReq) err
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func callbackBeforeSendGroupMsg(ctx context.Context, msg *pbchat.SendMsgReq) error {
|
func callbackBeforeSendGroupMsg(ctx context.Context, msg *pbChat.SendMsgReq) error {
|
||||||
if !config.Config.Callback.CallbackAfterSendSingleMsg.Enable {
|
if !config.Config.Callback.CallbackAfterSendSingleMsg.Enable {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ func callbackBeforeSendGroupMsg(ctx context.Context, msg *pbchat.SendMsgReq) err
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func callbackAfterSendGroupMsg(ctx context.Context, msg *pbchat.SendMsgReq) error {
|
func callbackAfterSendGroupMsg(ctx context.Context, msg *pbChat.SendMsgReq) error {
|
||||||
if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable {
|
if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ func callbackAfterSendGroupMsg(ctx context.Context, msg *pbchat.SendMsgReq) erro
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func callbackMsgModify(ctx context.Context, msg *pbchat.SendMsgReq) error {
|
func callbackMsgModify(ctx context.Context, msg *pbChat.SendMsgReq) error {
|
||||||
if !config.Config.Callback.CallbackMsgModify.Enable || msg.MsgData.ContentType != constant.Text {
|
if !config.Config.Callback.CallbackMsgModify.Enable || msg.MsgData.ContentType != constant.Text {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||||
"github.com/OpenIMSDK/tools/mcontext"
|
"github.com/OpenIMSDK/tools/mcontext"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *msgServer) SetSendMsgStatus(
|
func (m *msgServer) SetSendMsgStatus(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbmsg.SetSendMsgStatusReq,
|
req *pbMsg.SetSendMsgStatusReq,
|
||||||
) (*pbmsg.SetSendMsgStatusResp, error) {
|
) (*pbMsg.SetSendMsgStatusResp, error) {
|
||||||
resp := &pbmsg.SetSendMsgStatusResp{}
|
resp := &pbMsg.SetSendMsgStatusResp{}
|
||||||
if err := m.MsgDatabase.SetSendMsgStatus(ctx, mcontext.GetOperationID(ctx), req.Status); err != nil {
|
if err := m.MsgDatabase.SetSendMsgStatus(ctx, mcontext.GetOperationID(ctx), req.Status); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -35,9 +35,9 @@ func (m *msgServer) SetSendMsgStatus(
|
|||||||
|
|
||||||
func (m *msgServer) GetSendMsgStatus(
|
func (m *msgServer) GetSendMsgStatus(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbmsg.GetSendMsgStatusReq,
|
req *pbMsg.GetSendMsgStatusReq,
|
||||||
) (*pbmsg.GetSendMsgStatusResp, error) {
|
) (*pbMsg.GetSendMsgStatusResp, error) {
|
||||||
resp := &pbmsg.GetSendMsgStatusResp{}
|
resp := &pbMsg.GetSendMsgStatusResp{}
|
||||||
status, err := m.MsgDatabase.GetSendMsgStatus(ctx, mcontext.GetOperationID(ctx))
|
status, err := m.MsgDatabase.GetSendMsgStatus(ctx, mcontext.GetOperationID(ctx))
|
||||||
if IsNotFound(err) {
|
if IsNotFound(err) {
|
||||||
resp.Status = constant.MsgStatusNotExist
|
resp.Status = constant.MsgStatusNotExist
|
||||||
|
|||||||
@@ -26,11 +26,9 @@ import (
|
|||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
"github.com/OpenIMSDK/protocol/sdkws"
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
"github.com/OpenIMSDK/tools/mcontext"
|
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||||
unrelationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.RevokeMsgResp, error) {
|
func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.RevokeMsgResp, error) {
|
||||||
@@ -100,7 +98,7 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
now := time.Now().UnixMilli()
|
now := time.Now().UnixMilli()
|
||||||
err = m.MsgDatabase.RevokeMsg(ctx, req.ConversationID, req.Seq, &unrelationtb.RevokeModel{
|
err = m.MsgDatabase.RevokeMsg(ctx, req.ConversationID, req.Seq, &unRelationTb.RevokeModel{
|
||||||
Role: role,
|
Role: role,
|
||||||
UserID: req.UserID,
|
UserID: req.UserID,
|
||||||
Nickname: user.Nickname,
|
Nickname: user.Nickname,
|
||||||
@@ -109,15 +107,13 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
revokerUserID := mcontext.GetOpUserID(ctx)
|
|
||||||
tips := sdkws.RevokeMsgTips{
|
tips := sdkws.RevokeMsgTips{
|
||||||
RevokerUserID: revokerUserID,
|
RevokerUserID: req.UserID,
|
||||||
ClientMsgID: msgs[0].ClientMsgID,
|
ClientMsgID: msgs[0].ClientMsgID,
|
||||||
RevokeTime: now,
|
RevokeTime: now,
|
||||||
Seq: req.Seq,
|
Seq: req.Seq,
|
||||||
SesstionType: msgs[0].SessionType,
|
SesstionType: msgs[0].SessionType,
|
||||||
ConversationID: req.ConversationID,
|
ConversationID: req.ConversationID,
|
||||||
IsAdminRevoke: utils.Contain(revokerUserID, config.Config.Manager.UserID...),
|
|
||||||
}
|
}
|
||||||
var recvID string
|
var recvID string
|
||||||
if msgs[0].SessionType == constant.SuperGroupChatType {
|
if msgs[0].SessionType == constant.SuperGroupChatType {
|
||||||
|
|||||||
+24
-24
@@ -20,8 +20,8 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
pbconversation "github.com/OpenIMSDK/protocol/conversation"
|
pbConversation "github.com/OpenIMSDK/protocol/conversation"
|
||||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
"github.com/OpenIMSDK/protocol/sdkws"
|
||||||
"github.com/OpenIMSDK/protocol/wrapperspb"
|
"github.com/OpenIMSDK/protocol/wrapperspb"
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
@@ -29,11 +29,11 @@ import (
|
|||||||
"github.com/OpenIMSDK/tools/mcontext"
|
"github.com/OpenIMSDK/tools/mcontext"
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
promepkg "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
promePkg "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *msgServer) SendMsg(ctx context.Context, req *pbmsg.SendMsgReq) (resp *pbmsg.SendMsgResp, error error) {
|
func (m *msgServer) SendMsg(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, error error) {
|
||||||
resp = &pbmsg.SendMsgResp{}
|
resp = &pbMsg.SendMsgResp{}
|
||||||
if req.MsgData != nil {
|
if req.MsgData != nil {
|
||||||
flag := isMessageHasReadEnabled(req.MsgData)
|
flag := isMessageHasReadEnabled(req.MsgData)
|
||||||
if !flag {
|
if !flag {
|
||||||
@@ -57,11 +57,11 @@ func (m *msgServer) SendMsg(ctx context.Context, req *pbmsg.SendMsgReq) (resp *p
|
|||||||
|
|
||||||
func (m *msgServer) sendMsgSuperGroupChat(
|
func (m *msgServer) sendMsgSuperGroupChat(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbmsg.SendMsgReq,
|
req *pbMsg.SendMsgReq,
|
||||||
) (resp *pbmsg.SendMsgResp, err error) {
|
) (resp *pbMsg.SendMsgResp, err error) {
|
||||||
promepkg.Inc(promepkg.WorkSuperGroupChatMsgRecvSuccessCounter)
|
promePkg.Inc(promePkg.WorkSuperGroupChatMsgRecvSuccessCounter)
|
||||||
if err = m.messageVerification(ctx, req); err != nil {
|
if err = m.messageVerification(ctx, req); err != nil {
|
||||||
promepkg.Inc(promepkg.WorkSuperGroupChatMsgProcessFailedCounter)
|
promePkg.Inc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err = callbackBeforeSendGroupMsg(ctx, req); err != nil {
|
if err = callbackBeforeSendGroupMsg(ctx, req); err != nil {
|
||||||
@@ -80,8 +80,8 @@ func (m *msgServer) sendMsgSuperGroupChat(
|
|||||||
if err = callbackAfterSendGroupMsg(ctx, req); err != nil {
|
if err = callbackAfterSendGroupMsg(ctx, req); err != nil {
|
||||||
log.ZWarn(ctx, "CallbackAfterSendGroupMsg", err)
|
log.ZWarn(ctx, "CallbackAfterSendGroupMsg", err)
|
||||||
}
|
}
|
||||||
promepkg.Inc(promepkg.WorkSuperGroupChatMsgProcessSuccessCounter)
|
promePkg.Inc(promePkg.WorkSuperGroupChatMsgProcessSuccessCounter)
|
||||||
resp = &pbmsg.SendMsgResp{}
|
resp = &pbMsg.SendMsgResp{}
|
||||||
resp.SendTime = req.MsgData.SendTime
|
resp.SendTime = req.MsgData.SendTime
|
||||||
resp.ServerMsgID = req.MsgData.ServerMsgID
|
resp.ServerMsgID = req.MsgData.ServerMsgID
|
||||||
resp.ClientMsgID = req.MsgData.ClientMsgID
|
resp.ClientMsgID = req.MsgData.ClientMsgID
|
||||||
@@ -92,7 +92,7 @@ func (m *msgServer) setConversationAtInfo(nctx context.Context, msg *sdkws.MsgDa
|
|||||||
log.ZDebug(nctx, "setConversationAtInfo", "msg", msg)
|
log.ZDebug(nctx, "setConversationAtInfo", "msg", msg)
|
||||||
ctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(nctx))
|
ctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(nctx))
|
||||||
var atUserID []string
|
var atUserID []string
|
||||||
conversation := &pbconversation.ConversationReq{
|
conversation := &pbConversation.ConversationReq{
|
||||||
ConversationID: msgprocessor.GetConversationIDByMsg(msg),
|
ConversationID: msgprocessor.GetConversationIDByMsg(msg),
|
||||||
ConversationType: msg.SessionType,
|
ConversationType: msg.SessionType,
|
||||||
GroupID: msg.GroupID,
|
GroupID: msg.GroupID,
|
||||||
@@ -131,14 +131,14 @@ func (m *msgServer) setConversationAtInfo(nctx context.Context, msg *sdkws.MsgDa
|
|||||||
|
|
||||||
func (m *msgServer) sendMsgNotification(
|
func (m *msgServer) sendMsgNotification(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbmsg.SendMsgReq,
|
req *pbMsg.SendMsgReq,
|
||||||
) (resp *pbmsg.SendMsgResp, err error) {
|
) (resp *pbMsg.SendMsgResp, err error) {
|
||||||
promepkg.Inc(promepkg.SingleChatMsgRecvSuccessCounter)
|
promePkg.Inc(promePkg.SingleChatMsgRecvSuccessCounter)
|
||||||
if err := m.MsgDatabase.MsgToMQ(ctx, utils.GenConversationUniqueKeyForSingle(req.MsgData.SendID, req.MsgData.RecvID), req.MsgData); err != nil {
|
if err := m.MsgDatabase.MsgToMQ(ctx, utils.GenConversationUniqueKeyForSingle(req.MsgData.SendID, req.MsgData.RecvID), req.MsgData); err != nil {
|
||||||
promepkg.Inc(promepkg.SingleChatMsgProcessFailedCounter)
|
promePkg.Inc(promePkg.SingleChatMsgProcessFailedCounter)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp = &pbmsg.SendMsgResp{
|
resp = &pbMsg.SendMsgResp{
|
||||||
ServerMsgID: req.MsgData.ServerMsgID,
|
ServerMsgID: req.MsgData.ServerMsgID,
|
||||||
ClientMsgID: req.MsgData.ClientMsgID,
|
ClientMsgID: req.MsgData.ClientMsgID,
|
||||||
SendTime: req.MsgData.SendTime,
|
SendTime: req.MsgData.SendTime,
|
||||||
@@ -146,8 +146,8 @@ func (m *msgServer) sendMsgNotification(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq) (resp *pbmsg.SendMsgResp, err error) {
|
func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, err error) {
|
||||||
promepkg.Inc(promepkg.SingleChatMsgRecvSuccessCounter)
|
promePkg.Inc(promePkg.SingleChatMsgRecvSuccessCounter)
|
||||||
if err := m.messageVerification(ctx, req); err != nil {
|
if err := m.messageVerification(ctx, req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !isSend {
|
if !isSend {
|
||||||
promepkg.Inc(promepkg.SingleChatMsgProcessFailedCounter)
|
promePkg.Inc(promePkg.SingleChatMsgProcessFailedCounter)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
} else {
|
} else {
|
||||||
if err = callbackBeforeSendSingleMsg(ctx, req); err != nil {
|
if err = callbackBeforeSendSingleMsg(ctx, req); err != nil {
|
||||||
@@ -176,23 +176,23 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := m.MsgDatabase.MsgToMQ(ctx, utils.GenConversationUniqueKeyForSingle(req.MsgData.SendID, req.MsgData.RecvID), req.MsgData); err != nil {
|
if err := m.MsgDatabase.MsgToMQ(ctx, utils.GenConversationUniqueKeyForSingle(req.MsgData.SendID, req.MsgData.RecvID), req.MsgData); err != nil {
|
||||||
promepkg.Inc(promepkg.SingleChatMsgProcessFailedCounter)
|
promePkg.Inc(promePkg.SingleChatMsgProcessFailedCounter)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = callbackAfterSendSingleMsg(ctx, req)
|
err = callbackAfterSendSingleMsg(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(ctx, "CallbackAfterSendSingleMsg", err, "req", req)
|
log.ZWarn(ctx, "CallbackAfterSendSingleMsg", err, "req", req)
|
||||||
}
|
}
|
||||||
resp = &pbmsg.SendMsgResp{
|
resp = &pbMsg.SendMsgResp{
|
||||||
ServerMsgID: req.MsgData.ServerMsgID,
|
ServerMsgID: req.MsgData.ServerMsgID,
|
||||||
ClientMsgID: req.MsgData.ClientMsgID,
|
ClientMsgID: req.MsgData.ClientMsgID,
|
||||||
SendTime: req.MsgData.SendTime,
|
SendTime: req.MsgData.SendTime,
|
||||||
}
|
}
|
||||||
promepkg.Inc(promepkg.SingleChatMsgProcessSuccessCounter)
|
promePkg.Inc(promePkg.SingleChatMsgProcessSuccessCounter)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *msgServer) BatchSendMsg(ctx context.Context, in *pbmsg.BatchSendMessageReq) (*pbmsg.BatchSendMessageResp, error) {
|
func (m *msgServer) BatchSendMsg(ctx context.Context, in *pbMsg.BatchSendMessageReq) (*pbMsg.BatchSendMessageResp, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,16 +17,16 @@ package msg
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *msgServer) GetConversationMaxSeq(
|
func (m *msgServer) GetConversationMaxSeq(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbmsg.GetConversationMaxSeqReq,
|
req *pbMsg.GetConversationMaxSeqReq,
|
||||||
) (resp *pbmsg.GetConversationMaxSeqResp, err error) {
|
) (resp *pbMsg.GetConversationMaxSeqResp, err error) {
|
||||||
maxSeq, err := m.MsgDatabase.GetMaxSeq(ctx, req.ConversationID)
|
maxSeq, err := m.MsgDatabase.GetMaxSeq(ctx, req.ConversationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pbmsg.GetConversationMaxSeqResp{MaxSeq: maxSeq}, nil
|
return &pbMsg.GetConversationMaxSeqResp{MaxSeq: maxSeq}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func (m *msgServer) GetActiveGroup(ctx context.Context, req *msg.GetActiveGroupR
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var pbgroups []*msg.ActiveGroup
|
var pbGroups []*msg.ActiveGroup
|
||||||
if len(groups) > 0 {
|
if len(groups) > 0 {
|
||||||
groupIDs := utils.Slice(groups, func(e *unrelation.GroupCount) string { return e.GroupID })
|
groupIDs := utils.Slice(groups, func(e *unrelation.GroupCount) string { return e.GroupID })
|
||||||
resp, err := m.Group.GetGroupInfos(ctx, groupIDs, false)
|
resp, err := m.Group.GetGroupInfos(ctx, groupIDs, false)
|
||||||
@@ -91,17 +91,17 @@ func (m *msgServer) GetActiveGroup(ctx context.Context, req *msg.GetActiveGroupR
|
|||||||
for i, group := range groups {
|
for i, group := range groups {
|
||||||
groupMap[group.GroupID] = resp[i]
|
groupMap[group.GroupID] = resp[i]
|
||||||
}
|
}
|
||||||
pbgroups = make([]*msg.ActiveGroup, 0, len(groups))
|
pbGroups = make([]*msg.ActiveGroup, 0, len(groups))
|
||||||
for _, group := range groups {
|
for _, group := range groups {
|
||||||
pbgroup := groupMap[group.GroupID]
|
pbGroup := groupMap[group.GroupID]
|
||||||
if pbgroup == nil {
|
if pbGroup == nil {
|
||||||
pbgroup = &sdkws.GroupInfo{
|
pbGroup = &sdkws.GroupInfo{
|
||||||
GroupID: group.GroupID,
|
GroupID: group.GroupID,
|
||||||
GroupName: group.GroupID,
|
GroupName: group.GroupID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pbgroups = append(pbgroups, &msg.ActiveGroup{
|
pbGroups = append(pbGroups, &msg.ActiveGroup{
|
||||||
Group: pbgroup,
|
Group: pbGroup,
|
||||||
Count: group.Count,
|
Count: group.Count,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -110,6 +110,6 @@ func (m *msgServer) GetActiveGroup(ctx context.Context, req *msg.GetActiveGroupR
|
|||||||
MsgCount: msgCount,
|
MsgCount: msgCount,
|
||||||
GroupCount: groupCount,
|
GroupCount: groupCount,
|
||||||
DateCount: dateCount,
|
DateCount: dateCount,
|
||||||
Groups: pbgroups,
|
Groups: pbGroups,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,31 +164,27 @@ func (m *msgServer) SearchMessage(ctx context.Context, req *msg.SearchMessageReq
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, chatLog := range chatLogs {
|
for _, chatLog := range chatLogs {
|
||||||
pbchatLog := &msg.ChatLog{}
|
pbChatLog := &msg.ChatLog{}
|
||||||
utils.CopyStructFields(pbchatLog, chatLog)
|
utils.CopyStructFields(pbChatLog, chatLog)
|
||||||
pbchatLog.SendTime = chatLog.SendTime
|
pbChatLog.SendTime = chatLog.SendTime
|
||||||
pbchatLog.CreateTime = chatLog.CreateTime
|
pbChatLog.CreateTime = chatLog.CreateTime
|
||||||
if chatLog.SenderNickname == "" {
|
if chatLog.SenderNickname == "" {
|
||||||
pbchatLog.SenderNickname = sendMap[chatLog.SendID]
|
pbChatLog.SenderNickname = sendMap[chatLog.SendID]
|
||||||
}
|
}
|
||||||
switch chatLog.SessionType {
|
switch chatLog.SessionType {
|
||||||
case constant.SingleChatType:
|
case constant.SingleChatType:
|
||||||
pbchatLog.RecvNickname = recvMap[chatLog.RecvID]
|
pbChatLog.RecvNickname = recvMap[chatLog.RecvID]
|
||||||
|
|
||||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||||
pbchatLog.SenderFaceURL = groupMap[chatLog.GroupID].FaceURL
|
pbChatLog.SenderFaceURL = groupMap[chatLog.GroupID].FaceURL
|
||||||
pbchatLog.GroupMemberCount = groupMap[chatLog.GroupID].MemberCount
|
pbChatLog.GroupMemberCount = groupMap[chatLog.GroupID].MemberCount
|
||||||
pbchatLog.RecvID = groupMap[chatLog.GroupID].GroupID
|
pbChatLog.RecvID = groupMap[chatLog.GroupID].GroupID
|
||||||
pbchatLog.GroupName = groupMap[chatLog.GroupID].GroupName
|
pbChatLog.GroupName = groupMap[chatLog.GroupID].GroupName
|
||||||
pbchatLog.GroupOwner = groupMap[chatLog.GroupID].OwnerUserID
|
pbChatLog.GroupOwner = groupMap[chatLog.GroupID].OwnerUserID
|
||||||
pbchatLog.GroupType = groupMap[chatLog.GroupID].GroupType
|
pbChatLog.GroupType = groupMap[chatLog.GroupID].GroupType
|
||||||
}
|
}
|
||||||
resp.ChatLogs = append(resp.ChatLogs, pbchatLog)
|
resp.ChatLogs = append(resp.ChatLogs, pbChatLog)
|
||||||
}
|
}
|
||||||
resp.ChatLogsNum = total
|
resp.ChatLogsNum = total
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *msgServer) GetServerTime(ctx context.Context, _ *msg.GetServerTimeReq) (*msg.GetServerTimeResp, error) {
|
|
||||||
return &msg.GetServerTimeResp{ServerTime: utils.GetCurrentTimestampByMill()}, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := db.AutoMigrate(&relationtb.ObjectModel{}); err != nil {
|
if err := db.AutoMigrate(&relationTb.ObjectModel{}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// 根据配置文件策略选择 oss 方式
|
// 根据配置文件策略选择 oss 方式
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright © 2023 OpenIM. All rights reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES 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
|
package tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -76,10 +76,6 @@ type TextElem struct {
|
|||||||
Text string `mapstructure:"text" validate:"required"`
|
Text string `mapstructure:"text" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TextContentElem struct {
|
|
||||||
Content string `json:"content" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RevokeElem struct {
|
type RevokeElem struct {
|
||||||
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,16 +81,9 @@ type configStruct struct {
|
|||||||
} `yaml:"redis"`
|
} `yaml:"redis"`
|
||||||
|
|
||||||
Kafka struct {
|
Kafka struct {
|
||||||
Username string `yaml:"username"`
|
Username string `yaml:"username"`
|
||||||
Password string `yaml:"password"`
|
Password string `yaml:"password"`
|
||||||
Addr []string `yaml:"addr"`
|
Addr []string `yaml:"addr"`
|
||||||
TLS *struct {
|
|
||||||
CACrt string `yaml:"caCrt"`
|
|
||||||
ClientCrt string `yaml:"clientCrt"`
|
|
||||||
ClientKey string `yaml:"clientKey"`
|
|
||||||
ClientKeyPwd string `yaml:"clientKeyPwd"`
|
|
||||||
InsecureSkipVerify bool `yaml:"insecureSkipVerify"`
|
|
||||||
} `yaml:"tls"`
|
|
||||||
LatestMsgToRedis struct {
|
LatestMsgToRedis struct {
|
||||||
Topic string `yaml:"topic"`
|
Topic string `yaml:"topic"`
|
||||||
} `yaml:"latestMsgToRedis"`
|
} `yaml:"latestMsgToRedis"`
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package convert
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
pbgroup "github.com/OpenIMSDK/protocol/group"
|
pbGroup "github.com/OpenIMSDK/protocol/group"
|
||||||
sdkws "github.com/OpenIMSDK/protocol/sdkws"
|
sdkws "github.com/OpenIMSDK/protocol/sdkws"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
@@ -45,7 +45,7 @@ func Db2PbGroupInfo(m *relation.GroupModel, ownerUserID string, memberCount uint
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Pb2DbGroupRequest(req *pbgroup.GroupApplicationResponseReq, handleUserID string) *relation.GroupRequestModel {
|
func Pb2DbGroupRequest(req *pbGroup.GroupApplicationResponseReq, handleUserID string) *relation.GroupRequestModel {
|
||||||
return &relation.GroupRequestModel{
|
return &relation.GroupRequestModel{
|
||||||
UserID: req.FromUserID,
|
UserID: req.FromUserID,
|
||||||
GroupID: req.GroupID,
|
GroupID: req.GroupID,
|
||||||
@@ -61,8 +61,8 @@ func Db2PbCMSGroup(
|
|||||||
ownerUserID string,
|
ownerUserID string,
|
||||||
ownerUserName string,
|
ownerUserName string,
|
||||||
memberCount uint32,
|
memberCount uint32,
|
||||||
) *pbgroup.CMSGroup {
|
) *pbGroup.CMSGroup {
|
||||||
return &pbgroup.CMSGroup{
|
return &pbGroup.CMSGroup{
|
||||||
GroupInfo: Db2PbGroupInfo(m, ownerUserID, memberCount),
|
GroupInfo: Db2PbGroupInfo(m, ownerUserID, memberCount),
|
||||||
GroupOwnerUserID: ownerUserID,
|
GroupOwnerUserID: ownerUserID,
|
||||||
GroupOwnerUserName: ownerUserName,
|
GroupOwnerUserName: ownerUserName,
|
||||||
@@ -110,8 +110,8 @@ func Db2PbGroupAbstractInfo(
|
|||||||
groupID string,
|
groupID string,
|
||||||
groupMemberNumber uint32,
|
groupMemberNumber uint32,
|
||||||
groupMemberListHash uint64,
|
groupMemberListHash uint64,
|
||||||
) *pbgroup.GroupAbstractInfo {
|
) *pbGroup.GroupAbstractInfo {
|
||||||
return &pbgroup.GroupAbstractInfo{
|
return &pbGroup.GroupAbstractInfo{
|
||||||
GroupID: groupID,
|
GroupID: groupID,
|
||||||
GroupMemberNumber: groupMemberNumber,
|
GroupMemberNumber: groupMemberNumber,
|
||||||
GroupMemberListHash: groupMemberListHash,
|
GroupMemberListHash: groupMemberListHash,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
package convert
|
package convert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
|
||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
"github.com/OpenIMSDK/protocol/sdkws"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||||
@@ -79,9 +78,6 @@ func MsgDB2Pb(msgModel *unrelation.MsgDataModel) *sdkws.MsgData {
|
|||||||
msg.SendTime = msgModel.SendTime
|
msg.SendTime = msgModel.SendTime
|
||||||
msg.CreateTime = msgModel.CreateTime
|
msg.CreateTime = msgModel.CreateTime
|
||||||
msg.Status = msgModel.Status
|
msg.Status = msgModel.Status
|
||||||
if msgModel.SessionType == constant.SingleChatType {
|
|
||||||
msg.IsRead = msgModel.IsRead
|
|
||||||
}
|
|
||||||
msg.Options = msgModel.Options
|
msg.Options = msgModel.Options
|
||||||
if msgModel.OfflinePush != nil {
|
if msgModel.OfflinePush != nil {
|
||||||
msg.OfflinePushInfo = &sdkws.OfflinePushInfo{
|
msg.OfflinePushInfo = &sdkws.OfflinePushInfo{
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
"github.com/OpenIMSDK/protocol/sdkws"
|
||||||
|
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func UsersDB2Pb(users []*relationtb.UserModel) (result []*sdkws.UserInfo) {
|
func UsersDB2Pb(users []*relationTb.UserModel) (result []*sdkws.UserInfo) {
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
var userPb sdkws.UserInfo
|
var userPb sdkws.UserInfo
|
||||||
userPb.UserID = user.UserID
|
userPb.UserID = user.UserID
|
||||||
@@ -37,8 +37,8 @@ func UsersDB2Pb(users []*relationtb.UserModel) (result []*sdkws.UserInfo) {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserPb2DB(user *sdkws.UserInfo) *relationtb.UserModel {
|
func UserPb2DB(user *sdkws.UserInfo) *relationTb.UserModel {
|
||||||
var userDB relationtb.UserModel
|
var userDB relationTb.UserModel
|
||||||
userDB.UserID = user.UserID
|
userDB.UserID = user.UserID
|
||||||
userDB.Nickname = user.Nickname
|
userDB.Nickname = user.Nickname
|
||||||
userDB.FaceURL = user.FaceURL
|
userDB.FaceURL = user.FaceURL
|
||||||
|
|||||||
Vendored
+3
-3
@@ -21,7 +21,7 @@ import (
|
|||||||
"github.com/dtm-labs/rockscache"
|
"github.com/dtm-labs/rockscache"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -43,12 +43,12 @@ type BlackCacheRedis struct {
|
|||||||
metaCache
|
metaCache
|
||||||
expireTime time.Duration
|
expireTime time.Duration
|
||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
blackDB relationtb.BlackModelInterface
|
blackDB relationTb.BlackModelInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBlackCacheRedis(
|
func NewBlackCacheRedis(
|
||||||
rdb redis.UniversalClient,
|
rdb redis.UniversalClient,
|
||||||
blackDB relationtb.BlackModelInterface,
|
blackDB relationTb.BlackModelInterface,
|
||||||
options rockscache.Options,
|
options rockscache.Options,
|
||||||
) BlackCache {
|
) BlackCache {
|
||||||
rcClient := rockscache.NewClient(rdb, options)
|
rcClient := rockscache.NewClient(rdb, options)
|
||||||
|
|||||||
Vendored
+15
-15
@@ -27,7 +27,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -54,7 +54,7 @@ type ConversationCache interface {
|
|||||||
DelUserConversationIDsHash(ownerUserIDs ...string) ConversationCache
|
DelUserConversationIDsHash(ownerUserIDs ...string) ConversationCache
|
||||||
|
|
||||||
// get one conversation from msgCache
|
// get one conversation from msgCache
|
||||||
GetConversation(ctx context.Context, ownerUserID, conversationID string) (*relationtb.ConversationModel, error)
|
GetConversation(ctx context.Context, ownerUserID, conversationID string) (*relationTb.ConversationModel, error)
|
||||||
DelConversations(ownerUserID string, conversationIDs ...string) ConversationCache
|
DelConversations(ownerUserID string, conversationIDs ...string) ConversationCache
|
||||||
DelUsersConversation(conversationID string, ownerUserIDs ...string) ConversationCache
|
DelUsersConversation(conversationID string, ownerUserIDs ...string) ConversationCache
|
||||||
// get one conversation from msgCache
|
// get one conversation from msgCache
|
||||||
@@ -62,9 +62,9 @@ type ConversationCache interface {
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
ownerUserID string,
|
ownerUserID string,
|
||||||
conversationIDs []string,
|
conversationIDs []string,
|
||||||
) ([]*relationtb.ConversationModel, error)
|
) ([]*relationTb.ConversationModel, error)
|
||||||
// get one user's all conversations from msgCache
|
// get one user's all conversations from msgCache
|
||||||
GetUserAllConversations(ctx context.Context, ownerUserID string) ([]*relationtb.ConversationModel, error)
|
GetUserAllConversations(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error)
|
||||||
// get user conversation recv msg from msgCache
|
// get user conversation recv msg from msgCache
|
||||||
GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error)
|
GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error)
|
||||||
DelUserRecvMsgOpt(ownerUserID, conversationID string) ConversationCache
|
DelUserRecvMsgOpt(ownerUserID, conversationID string) ConversationCache
|
||||||
@@ -81,14 +81,14 @@ type ConversationCache interface {
|
|||||||
GetConversationsByConversationID(
|
GetConversationsByConversationID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
conversationIDs []string,
|
conversationIDs []string,
|
||||||
) ([]*relationtb.ConversationModel, error)
|
) ([]*relationTb.ConversationModel, error)
|
||||||
DelConversationByConversationID(conversationIDs ...string) ConversationCache
|
DelConversationByConversationID(conversationIDs ...string) ConversationCache
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConversationRedis(
|
func NewConversationRedis(
|
||||||
rdb redis.UniversalClient,
|
rdb redis.UniversalClient,
|
||||||
opts rockscache.Options,
|
opts rockscache.Options,
|
||||||
db relationtb.ConversationModelInterface,
|
db relationTb.ConversationModelInterface,
|
||||||
) ConversationCache {
|
) ConversationCache {
|
||||||
rcClient := rockscache.NewClient(rdb, opts)
|
rcClient := rockscache.NewClient(rdb, opts)
|
||||||
return &ConversationRedisCache{
|
return &ConversationRedisCache{
|
||||||
@@ -102,7 +102,7 @@ func NewConversationRedis(
|
|||||||
type ConversationRedisCache struct {
|
type ConversationRedisCache struct {
|
||||||
metaCache
|
metaCache
|
||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
conversationDB relationtb.ConversationModelInterface
|
conversationDB relationTb.ConversationModelInterface
|
||||||
expireTime time.Duration
|
expireTime time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,13 +214,13 @@ func (c *ConversationRedisCache) DelUserConversationIDsHash(ownerUserIDs ...stri
|
|||||||
func (c *ConversationRedisCache) GetConversation(
|
func (c *ConversationRedisCache) GetConversation(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
ownerUserID, conversationID string,
|
ownerUserID, conversationID string,
|
||||||
) (*relationtb.ConversationModel, error) {
|
) (*relationTb.ConversationModel, error) {
|
||||||
return getCache(
|
return getCache(
|
||||||
ctx,
|
ctx,
|
||||||
c.rcClient,
|
c.rcClient,
|
||||||
c.getConversationKey(ownerUserID, conversationID),
|
c.getConversationKey(ownerUserID, conversationID),
|
||||||
c.expireTime,
|
c.expireTime,
|
||||||
func(ctx context.Context) (*relationtb.ConversationModel, error) {
|
func(ctx context.Context) (*relationTb.ConversationModel, error) {
|
||||||
return c.conversationDB.Take(ctx, ownerUserID, conversationID)
|
return c.conversationDB.Take(ctx, ownerUserID, conversationID)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -237,7 +237,7 @@ func (c *ConversationRedisCache) DelConversations(ownerUserID string, conversati
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRedisCache) getConversationIndex(
|
func (c *ConversationRedisCache) getConversationIndex(
|
||||||
convsation *relationtb.ConversationModel,
|
convsation *relationTb.ConversationModel,
|
||||||
keys []string,
|
keys []string,
|
||||||
) (int, error) {
|
) (int, error) {
|
||||||
key := c.getConversationKey(convsation.OwnerUserID, convsation.ConversationID)
|
key := c.getConversationKey(convsation.OwnerUserID, convsation.ConversationID)
|
||||||
@@ -253,7 +253,7 @@ func (c *ConversationRedisCache) GetConversations(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
ownerUserID string,
|
ownerUserID string,
|
||||||
conversationIDs []string,
|
conversationIDs []string,
|
||||||
) ([]*relationtb.ConversationModel, error) {
|
) ([]*relationTb.ConversationModel, error) {
|
||||||
var keys []string
|
var keys []string
|
||||||
for _, conversarionID := range conversationIDs {
|
for _, conversarionID := range conversationIDs {
|
||||||
keys = append(keys, c.getConversationKey(ownerUserID, conversarionID))
|
keys = append(keys, c.getConversationKey(ownerUserID, conversarionID))
|
||||||
@@ -264,7 +264,7 @@ func (c *ConversationRedisCache) GetConversations(
|
|||||||
keys,
|
keys,
|
||||||
c.expireTime,
|
c.expireTime,
|
||||||
c.getConversationIndex,
|
c.getConversationIndex,
|
||||||
func(ctx context.Context) ([]*relationtb.ConversationModel, error) {
|
func(ctx context.Context) ([]*relationTb.ConversationModel, error) {
|
||||||
return c.conversationDB.Find(ctx, ownerUserID, conversationIDs)
|
return c.conversationDB.Find(ctx, ownerUserID, conversationIDs)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -273,7 +273,7 @@ func (c *ConversationRedisCache) GetConversations(
|
|||||||
func (c *ConversationRedisCache) GetUserAllConversations(
|
func (c *ConversationRedisCache) GetUserAllConversations(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
ownerUserID string,
|
ownerUserID string,
|
||||||
) ([]*relationtb.ConversationModel, error) {
|
) ([]*relationTb.ConversationModel, error) {
|
||||||
conversationIDs, err := c.GetUserConversationIDs(ctx, ownerUserID)
|
conversationIDs, err := c.GetUserConversationIDs(ctx, ownerUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -288,7 +288,7 @@ func (c *ConversationRedisCache) GetUserAllConversations(
|
|||||||
keys,
|
keys,
|
||||||
c.expireTime,
|
c.expireTime,
|
||||||
c.getConversationIndex,
|
c.getConversationIndex,
|
||||||
func(ctx context.Context) ([]*relationtb.ConversationModel, error) {
|
func(ctx context.Context) ([]*relationTb.ConversationModel, error) {
|
||||||
return c.conversationDB.FindUserIDAllConversations(ctx, ownerUserID)
|
return c.conversationDB.FindUserIDAllConversations(ctx, ownerUserID)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -425,7 +425,7 @@ func (c *ConversationRedisCache) DelUserAllHasReadSeqs(
|
|||||||
func (c *ConversationRedisCache) GetConversationsByConversationID(
|
func (c *ConversationRedisCache) GetConversationsByConversationID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
conversationIDs []string,
|
conversationIDs []string,
|
||||||
) ([]*relationtb.ConversationModel, error) {
|
) ([]*relationTb.ConversationModel, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+6
-6
@@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -41,21 +41,21 @@ type FriendCache interface {
|
|||||||
// call when friendID List changed
|
// call when friendID List changed
|
||||||
DelFriendIDs(ownerUserID ...string) FriendCache
|
DelFriendIDs(ownerUserID ...string) FriendCache
|
||||||
// get single friendInfo from msgCache
|
// get single friendInfo from msgCache
|
||||||
GetFriend(ctx context.Context, ownerUserID, friendUserID string) (friend *relationtb.FriendModel, err error)
|
GetFriend(ctx context.Context, ownerUserID, friendUserID string) (friend *relationTb.FriendModel, err error)
|
||||||
// del friend when friend info changed
|
// del friend when friend info changed
|
||||||
DelFriend(ownerUserID, friendUserID string) FriendCache
|
DelFriend(ownerUserID, friendUserID string) FriendCache
|
||||||
}
|
}
|
||||||
|
|
||||||
type FriendCacheRedis struct {
|
type FriendCacheRedis struct {
|
||||||
metaCache
|
metaCache
|
||||||
friendDB relationtb.FriendModelInterface
|
friendDB relationTb.FriendModelInterface
|
||||||
expireTime time.Duration
|
expireTime time.Duration
|
||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFriendCacheRedis(
|
func NewFriendCacheRedis(
|
||||||
rdb redis.UniversalClient,
|
rdb redis.UniversalClient,
|
||||||
friendDB relationtb.FriendModelInterface,
|
friendDB relationTb.FriendModelInterface,
|
||||||
options rockscache.Options,
|
options rockscache.Options,
|
||||||
) FriendCache {
|
) FriendCache {
|
||||||
rcClient := rockscache.NewClient(rdb, options)
|
rcClient := rockscache.NewClient(rdb, options)
|
||||||
@@ -140,13 +140,13 @@ func (f *FriendCacheRedis) DelTwoWayFriendIDs(ctx context.Context, ownerUserID s
|
|||||||
func (f *FriendCacheRedis) GetFriend(
|
func (f *FriendCacheRedis) GetFriend(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
ownerUserID, friendUserID string,
|
ownerUserID, friendUserID string,
|
||||||
) (friend *relationtb.FriendModel, err error) {
|
) (friend *relationTb.FriendModel, err error) {
|
||||||
return getCache(
|
return getCache(
|
||||||
ctx,
|
ctx,
|
||||||
f.rcClient,
|
f.rcClient,
|
||||||
f.getFriendKey(ownerUserID, friendUserID),
|
f.getFriendKey(ownerUserID, friendUserID),
|
||||||
f.expireTime,
|
f.expireTime,
|
||||||
func(ctx context.Context) (*relationtb.FriendModel, error) {
|
func(ctx context.Context) (*relationTb.FriendModel, error) {
|
||||||
return f.friendDB.Take(ctx, ownerUserID, friendUserID)
|
return f.friendDB.Take(ctx, ownerUserID, friendUserID)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Vendored
+40
-40
@@ -25,8 +25,8 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
unrelationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
unrelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -44,17 +44,17 @@ const (
|
|||||||
type GroupCache interface {
|
type GroupCache interface {
|
||||||
metaCache
|
metaCache
|
||||||
NewCache() GroupCache
|
NewCache() GroupCache
|
||||||
GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
|
GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||||
GetGroupInfo(ctx context.Context, groupID string) (group *relationtb.GroupModel, err error)
|
GetGroupInfo(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||||
DelGroupsInfo(groupIDs ...string) GroupCache
|
DelGroupsInfo(groupIDs ...string) GroupCache
|
||||||
|
|
||||||
GetJoinedSuperGroupIDs(ctx context.Context, userID string) (joinedSuperGroupIDs []string, err error)
|
GetJoinedSuperGroupIDs(ctx context.Context, userID string) (joinedSuperGroupIDs []string, err error)
|
||||||
DelJoinedSuperGroupIDs(userIDs ...string) GroupCache
|
DelJoinedSuperGroupIDs(userIDs ...string) GroupCache
|
||||||
GetSuperGroupMemberIDs(ctx context.Context, groupIDs ...string) (models []*unrelationtb.SuperGroupModel, err error)
|
GetSuperGroupMemberIDs(ctx context.Context, groupIDs ...string) (models []*unrelationTb.SuperGroupModel, err error)
|
||||||
DelSuperGroupMemberIDs(groupIDs ...string) GroupCache
|
DelSuperGroupMemberIDs(groupIDs ...string) GroupCache
|
||||||
|
|
||||||
GetGroupMembersHash(ctx context.Context, groupID string) (hashCode uint64, err error)
|
GetGroupMembersHash(ctx context.Context, groupID string) (hashCode uint64, err error)
|
||||||
GetGroupMemberHashMap(ctx context.Context, groupIDs []string) (map[string]*relationtb.GroupSimpleUserID, error)
|
GetGroupMemberHashMap(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error)
|
||||||
DelGroupMembersHash(groupID string) GroupCache
|
DelGroupMembersHash(groupID string) GroupCache
|
||||||
|
|
||||||
GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error)
|
GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error)
|
||||||
@@ -68,19 +68,19 @@ type GroupCache interface {
|
|||||||
GetGroupMemberInfo(
|
GetGroupMemberInfo(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID, userID string,
|
groupID, userID string,
|
||||||
) (groupMember *relationtb.GroupMemberModel, err error)
|
) (groupMember *relationTb.GroupMemberModel, err error)
|
||||||
GetGroupMembersInfo(
|
GetGroupMembersInfo(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
userID []string,
|
userID []string,
|
||||||
) (groupMembers []*relationtb.GroupMemberModel, err error)
|
) (groupMembers []*relationTb.GroupMemberModel, err error)
|
||||||
GetAllGroupMembersInfo(ctx context.Context, groupID string) (groupMembers []*relationtb.GroupMemberModel, err error)
|
GetAllGroupMembersInfo(ctx context.Context, groupID string) (groupMembers []*relationTb.GroupMemberModel, err error)
|
||||||
GetGroupMembersPage(
|
GetGroupMembersPage(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
userID []string,
|
userID []string,
|
||||||
showNumber, pageNumber int32,
|
showNumber, pageNumber int32,
|
||||||
) (total uint32, groupMembers []*relationtb.GroupMemberModel, err error)
|
) (total uint32, groupMembers []*relationTb.GroupMemberModel, err error)
|
||||||
|
|
||||||
DelGroupMembersInfo(groupID string, userID ...string) GroupCache
|
DelGroupMembersInfo(groupID string, userID ...string) GroupCache
|
||||||
|
|
||||||
@@ -90,10 +90,10 @@ type GroupCache interface {
|
|||||||
|
|
||||||
type GroupCacheRedis struct {
|
type GroupCacheRedis struct {
|
||||||
metaCache
|
metaCache
|
||||||
groupDB relationtb.GroupModelInterface
|
groupDB relationTb.GroupModelInterface
|
||||||
groupMemberDB relationtb.GroupMemberModelInterface
|
groupMemberDB relationTb.GroupMemberModelInterface
|
||||||
groupRequestDB relationtb.GroupRequestModelInterface
|
groupRequestDB relationTb.GroupRequestModelInterface
|
||||||
mongoDB unrelationtb.SuperGroupModelInterface
|
mongoDB unrelationTb.SuperGroupModelInterface
|
||||||
expireTime time.Duration
|
expireTime time.Duration
|
||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
hashCode func(ctx context.Context, groupID string) (uint64, error)
|
hashCode func(ctx context.Context, groupID string) (uint64, error)
|
||||||
@@ -101,10 +101,10 @@ type GroupCacheRedis struct {
|
|||||||
|
|
||||||
func NewGroupCacheRedis(
|
func NewGroupCacheRedis(
|
||||||
rdb redis.UniversalClient,
|
rdb redis.UniversalClient,
|
||||||
groupDB relationtb.GroupModelInterface,
|
groupDB relationTb.GroupModelInterface,
|
||||||
groupMemberDB relationtb.GroupMemberModelInterface,
|
groupMemberDB relationTb.GroupMemberModelInterface,
|
||||||
groupRequestDB relationtb.GroupRequestModelInterface,
|
groupRequestDB relationTb.GroupRequestModelInterface,
|
||||||
mongoClient unrelationtb.SuperGroupModelInterface,
|
mongoClient unrelationTb.SuperGroupModelInterface,
|
||||||
hashCode func(ctx context.Context, groupID string) (uint64, error),
|
hashCode func(ctx context.Context, groupID string) (uint64, error),
|
||||||
opts rockscache.Options,
|
opts rockscache.Options,
|
||||||
) GroupCache {
|
) GroupCache {
|
||||||
@@ -162,7 +162,7 @@ func (g *GroupCacheRedis) getGroupMemberNumKey(groupID string) string {
|
|||||||
return groupMemberNumKey + groupID
|
return groupMemberNumKey + groupID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupCacheRedis) GetGroupIndex(group *relationtb.GroupModel, keys []string) (int, error) {
|
func (g *GroupCacheRedis) GetGroupIndex(group *relationTb.GroupModel, keys []string) (int, error) {
|
||||||
key := g.getGroupInfoKey(group.GroupID)
|
key := g.getGroupInfoKey(group.GroupID)
|
||||||
for i, _key := range keys {
|
for i, _key := range keys {
|
||||||
if _key == key {
|
if _key == key {
|
||||||
@@ -172,7 +172,7 @@ func (g *GroupCacheRedis) GetGroupIndex(group *relationtb.GroupModel, keys []str
|
|||||||
return 0, errIndex
|
return 0, errIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupCacheRedis) GetGroupMemberIndex(groupMember *relationtb.GroupMemberModel, keys []string) (int, error) {
|
func (g *GroupCacheRedis) GetGroupMemberIndex(groupMember *relationTb.GroupMemberModel, keys []string) (int, error) {
|
||||||
key := g.getGroupMemberInfoKey(groupMember.GroupID, groupMember.UserID)
|
key := g.getGroupMemberInfoKey(groupMember.GroupID, groupMember.UserID)
|
||||||
for i, _key := range keys {
|
for i, _key := range keys {
|
||||||
if _key == key {
|
if _key == key {
|
||||||
@@ -186,7 +186,7 @@ func (g *GroupCacheRedis) GetGroupMemberIndex(groupMember *relationtb.GroupMembe
|
|||||||
func (g *GroupCacheRedis) GetGroupsInfo(
|
func (g *GroupCacheRedis) GetGroupsInfo(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupIDs []string,
|
groupIDs []string,
|
||||||
) (groups []*relationtb.GroupModel, err error) {
|
) (groups []*relationTb.GroupModel, err error) {
|
||||||
var keys []string
|
var keys []string
|
||||||
for _, group := range groupIDs {
|
for _, group := range groupIDs {
|
||||||
keys = append(keys, g.getGroupInfoKey(group))
|
keys = append(keys, g.getGroupInfoKey(group))
|
||||||
@@ -197,19 +197,19 @@ func (g *GroupCacheRedis) GetGroupsInfo(
|
|||||||
keys,
|
keys,
|
||||||
g.expireTime,
|
g.expireTime,
|
||||||
g.GetGroupIndex,
|
g.GetGroupIndex,
|
||||||
func(ctx context.Context) ([]*relationtb.GroupModel, error) {
|
func(ctx context.Context) ([]*relationTb.GroupModel, error) {
|
||||||
return g.groupDB.Find(ctx, groupIDs)
|
return g.groupDB.Find(ctx, groupIDs)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupCacheRedis) GetGroupInfo(ctx context.Context, groupID string) (group *relationtb.GroupModel, err error) {
|
func (g *GroupCacheRedis) GetGroupInfo(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
||||||
return getCache(
|
return getCache(
|
||||||
ctx,
|
ctx,
|
||||||
g.rcClient,
|
g.rcClient,
|
||||||
g.getGroupInfoKey(groupID),
|
g.getGroupInfoKey(groupID),
|
||||||
g.expireTime,
|
g.expireTime,
|
||||||
func(ctx context.Context) (*relationtb.GroupModel, error) {
|
func(ctx context.Context) (*relationTb.GroupModel, error) {
|
||||||
return g.groupDB.Take(ctx, groupID)
|
return g.groupDB.Take(ctx, groupID)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -247,7 +247,7 @@ func (g *GroupCacheRedis) GetJoinedSuperGroupIDs(
|
|||||||
func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
|
func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupIDs ...string,
|
groupIDs ...string,
|
||||||
) (models []*unrelationtb.SuperGroupModel, err error) {
|
) (models []*unrelationTb.SuperGroupModel, err error) {
|
||||||
var keys []string
|
var keys []string
|
||||||
for _, group := range groupIDs {
|
for _, group := range groupIDs {
|
||||||
keys = append(keys, g.getSuperGroupMemberIDsKey(group))
|
keys = append(keys, g.getSuperGroupMemberIDsKey(group))
|
||||||
@@ -257,7 +257,7 @@ func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
|
|||||||
g.rcClient,
|
g.rcClient,
|
||||||
keys,
|
keys,
|
||||||
g.expireTime,
|
g.expireTime,
|
||||||
func(model *unrelationtb.SuperGroupModel, keys []string) (int, error) {
|
func(model *unrelationTb.SuperGroupModel, keys []string) (int, error) {
|
||||||
for i, key := range keys {
|
for i, key := range keys {
|
||||||
if g.getSuperGroupMemberIDsKey(model.GroupID) == key {
|
if g.getSuperGroupMemberIDsKey(model.GroupID) == key {
|
||||||
return i, nil
|
return i, nil
|
||||||
@@ -265,7 +265,7 @@ func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
|
|||||||
}
|
}
|
||||||
return 0, errIndex
|
return 0, errIndex
|
||||||
},
|
},
|
||||||
func(ctx context.Context) ([]*unrelationtb.SuperGroupModel, error) {
|
func(ctx context.Context) ([]*unrelationTb.SuperGroupModel, error) {
|
||||||
return g.mongoDB.FindSuperGroup(ctx, groupIDs)
|
return g.mongoDB.FindSuperGroup(ctx, groupIDs)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -305,7 +305,7 @@ func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID strin
|
|||||||
// return 0, err
|
// return 0, err
|
||||||
// }
|
// }
|
||||||
// log.ZInfo(ctx, "GetGroupMembersHash", "groupID", groupID, "userIDs", userIDs)
|
// log.ZInfo(ctx, "GetGroupMembersHash", "groupID", groupID, "userIDs", userIDs)
|
||||||
// var members []*relationtb.GroupMemberModel
|
// var members []*relationTb.GroupMemberModel
|
||||||
// if len(userIDs) > 0 {
|
// if len(userIDs) > 0 {
|
||||||
// members, err = g.GetGroupMembersInfo(ctx, groupID, userIDs)
|
// members, err = g.GetGroupMembersInfo(ctx, groupID, userIDs)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
@@ -313,7 +313,7 @@ func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID strin
|
|||||||
// }
|
// }
|
||||||
// utils.Sort(userIDs, true)
|
// utils.Sort(userIDs, true)
|
||||||
// }
|
// }
|
||||||
// memberMap := make(map[string]*relationtb.GroupMemberModel)
|
// memberMap := make(map[string]*relationTb.GroupMemberModel)
|
||||||
// for i, member := range members {
|
// for i, member := range members {
|
||||||
// memberMap[member.UserID] = members[i]
|
// memberMap[member.UserID] = members[i]
|
||||||
// }
|
// }
|
||||||
@@ -354,8 +354,8 @@ func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID strin
|
|||||||
func (g *GroupCacheRedis) GetGroupMemberHashMap(
|
func (g *GroupCacheRedis) GetGroupMemberHashMap(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupIDs []string,
|
groupIDs []string,
|
||||||
) (map[string]*relationtb.GroupSimpleUserID, error) {
|
) (map[string]*relationTb.GroupSimpleUserID, error) {
|
||||||
res := make(map[string]*relationtb.GroupSimpleUserID)
|
res := make(map[string]*relationTb.GroupSimpleUserID)
|
||||||
for _, groupID := range groupIDs {
|
for _, groupID := range groupIDs {
|
||||||
hash, err := g.GetGroupMembersHash(ctx, groupID)
|
hash, err := g.GetGroupMembersHash(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -366,7 +366,7 @@ func (g *GroupCacheRedis) GetGroupMemberHashMap(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
res[groupID] = &relationtb.GroupSimpleUserID{Hash: hash, MemberNum: uint32(num)}
|
res[groupID] = &relationTb.GroupSimpleUserID{Hash: hash, MemberNum: uint32(num)}
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
@@ -433,13 +433,13 @@ func (g *GroupCacheRedis) DelJoinedGroupID(userIDs ...string) GroupCache {
|
|||||||
func (g *GroupCacheRedis) GetGroupMemberInfo(
|
func (g *GroupCacheRedis) GetGroupMemberInfo(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID, userID string,
|
groupID, userID string,
|
||||||
) (groupMember *relationtb.GroupMemberModel, err error) {
|
) (groupMember *relationTb.GroupMemberModel, err error) {
|
||||||
return getCache(
|
return getCache(
|
||||||
ctx,
|
ctx,
|
||||||
g.rcClient,
|
g.rcClient,
|
||||||
g.getGroupMemberInfoKey(groupID, userID),
|
g.getGroupMemberInfoKey(groupID, userID),
|
||||||
g.expireTime,
|
g.expireTime,
|
||||||
func(ctx context.Context) (*relationtb.GroupMemberModel, error) {
|
func(ctx context.Context) (*relationTb.GroupMemberModel, error) {
|
||||||
return g.groupMemberDB.Take(ctx, groupID, userID)
|
return g.groupMemberDB.Take(ctx, groupID, userID)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -449,7 +449,7 @@ func (g *GroupCacheRedis) GetGroupMembersInfo(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
userIDs []string,
|
userIDs []string,
|
||||||
) ([]*relationtb.GroupMemberModel, error) {
|
) ([]*relationTb.GroupMemberModel, error) {
|
||||||
var keys []string
|
var keys []string
|
||||||
for _, userID := range userIDs {
|
for _, userID := range userIDs {
|
||||||
keys = append(keys, g.getGroupMemberInfoKey(groupID, userID))
|
keys = append(keys, g.getGroupMemberInfoKey(groupID, userID))
|
||||||
@@ -460,7 +460,7 @@ func (g *GroupCacheRedis) GetGroupMembersInfo(
|
|||||||
keys,
|
keys,
|
||||||
g.expireTime,
|
g.expireTime,
|
||||||
g.GetGroupMemberIndex,
|
g.GetGroupMemberIndex,
|
||||||
func(ctx context.Context) ([]*relationtb.GroupMemberModel, error) {
|
func(ctx context.Context) ([]*relationTb.GroupMemberModel, error) {
|
||||||
return g.groupMemberDB.Find(ctx, []string{groupID}, userIDs, nil)
|
return g.groupMemberDB.Find(ctx, []string{groupID}, userIDs, nil)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -471,7 +471,7 @@ func (g *GroupCacheRedis) GetGroupMembersPage(
|
|||||||
groupID string,
|
groupID string,
|
||||||
userIDs []string,
|
userIDs []string,
|
||||||
showNumber, pageNumber int32,
|
showNumber, pageNumber int32,
|
||||||
) (total uint32, groupMembers []*relationtb.GroupMemberModel, err error) {
|
) (total uint32, groupMembers []*relationTb.GroupMemberModel, err error) {
|
||||||
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
|
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, err
|
return 0, nil, err
|
||||||
@@ -488,7 +488,7 @@ func (g *GroupCacheRedis) GetGroupMembersPage(
|
|||||||
func (g *GroupCacheRedis) GetAllGroupMembersInfo(
|
func (g *GroupCacheRedis) GetAllGroupMembersInfo(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
) (groupMembers []*relationtb.GroupMemberModel, err error) {
|
) (groupMembers []*relationTb.GroupMemberModel, err error) {
|
||||||
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
|
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -499,7 +499,7 @@ func (g *GroupCacheRedis) GetAllGroupMembersInfo(
|
|||||||
func (g *GroupCacheRedis) GetAllGroupMemberInfo(
|
func (g *GroupCacheRedis) GetAllGroupMemberInfo(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
) ([]*relationtb.GroupMemberModel, error) {
|
) ([]*relationTb.GroupMemberModel, error) {
|
||||||
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
|
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -514,7 +514,7 @@ func (g *GroupCacheRedis) GetAllGroupMemberInfo(
|
|||||||
keys,
|
keys,
|
||||||
g.expireTime,
|
g.expireTime,
|
||||||
g.GetGroupMemberIndex,
|
g.GetGroupMemberIndex,
|
||||||
func(ctx context.Context) ([]*relationtb.GroupMemberModel, error) {
|
func(ctx context.Context) ([]*relationTb.GroupMemberModel, error) {
|
||||||
return g.groupMemberDB.Find(ctx, []string{groupID}, groupMemberIDs, nil)
|
return g.groupMemberDB.Find(ctx, []string{groupID}, groupMemberIDs, nil)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Vendored
+2
-2
@@ -33,7 +33,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
unrelationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||||
|
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
)
|
)
|
||||||
@@ -143,7 +143,7 @@ type msgCache struct {
|
|||||||
rdb redis.UniversalClient
|
rdb redis.UniversalClient
|
||||||
expireTime time.Duration
|
expireTime time.Duration
|
||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
msgDocDatabase unrelationtb.MsgDocModelInterface
|
msgDocDatabase unRelationTb.MsgDocModelInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *msgCache) getMaxSeqKey(conversationID string) string {
|
func (c *msgCache) getMaxSeqKey(conversationID string) string {
|
||||||
|
|||||||
Vendored
+11
-12
@@ -17,19 +17,18 @@ package cache
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/user"
|
"github.com/OpenIMSDK/protocol/user"
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/dtm-labs/rockscache"
|
"github.com/dtm-labs/rockscache"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -45,8 +44,8 @@ const (
|
|||||||
type UserCache interface {
|
type UserCache interface {
|
||||||
metaCache
|
metaCache
|
||||||
NewCache() UserCache
|
NewCache() UserCache
|
||||||
GetUserInfo(ctx context.Context, userID string) (userInfo *relationtb.UserModel, err error)
|
GetUserInfo(ctx context.Context, userID string) (userInfo *relationTb.UserModel, err error)
|
||||||
GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationtb.UserModel, error)
|
GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationTb.UserModel, error)
|
||||||
DelUsersInfo(userIDs ...string) UserCache
|
DelUsersInfo(userIDs ...string) UserCache
|
||||||
GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error)
|
GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error)
|
||||||
DelUsersGlobalRecvMsgOpt(userIDs ...string) UserCache
|
DelUsersGlobalRecvMsgOpt(userIDs ...string) UserCache
|
||||||
@@ -57,14 +56,14 @@ type UserCache interface {
|
|||||||
type UserCacheRedis struct {
|
type UserCacheRedis struct {
|
||||||
metaCache
|
metaCache
|
||||||
rdb redis.UniversalClient
|
rdb redis.UniversalClient
|
||||||
userDB relationtb.UserModelInterface
|
userDB relationTb.UserModelInterface
|
||||||
expireTime time.Duration
|
expireTime time.Duration
|
||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserCacheRedis(
|
func NewUserCacheRedis(
|
||||||
rdb redis.UniversalClient,
|
rdb redis.UniversalClient,
|
||||||
userDB relationtb.UserModelInterface,
|
userDB relationTb.UserModelInterface,
|
||||||
options rockscache.Options,
|
options rockscache.Options,
|
||||||
) UserCache {
|
) UserCache {
|
||||||
rcClient := rockscache.NewClient(rdb, options)
|
rcClient := rockscache.NewClient(rdb, options)
|
||||||
@@ -99,19 +98,19 @@ func (u *UserCacheRedis) getUserStatusHashKey(userID string, Id int32) string {
|
|||||||
return userID + "_" + string(Id) + platformID
|
return userID + "_" + string(Id) + platformID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserCacheRedis) GetUserInfo(ctx context.Context, userID string) (userInfo *relationtb.UserModel, err error) {
|
func (u *UserCacheRedis) GetUserInfo(ctx context.Context, userID string) (userInfo *relationTb.UserModel, err error) {
|
||||||
return getCache(
|
return getCache(
|
||||||
ctx,
|
ctx,
|
||||||
u.rcClient,
|
u.rcClient,
|
||||||
u.getUserInfoKey(userID),
|
u.getUserInfoKey(userID),
|
||||||
u.expireTime,
|
u.expireTime,
|
||||||
func(ctx context.Context) (*relationtb.UserModel, error) {
|
func(ctx context.Context) (*relationTb.UserModel, error) {
|
||||||
return u.userDB.Take(ctx, userID)
|
return u.userDB.Take(ctx, userID)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationtb.UserModel, error) {
|
func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationTb.UserModel, error) {
|
||||||
var keys []string
|
var keys []string
|
||||||
for _, userID := range userIDs {
|
for _, userID := range userIDs {
|
||||||
keys = append(keys, u.getUserInfoKey(userID))
|
keys = append(keys, u.getUserInfoKey(userID))
|
||||||
@@ -121,7 +120,7 @@ func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]
|
|||||||
u.rcClient,
|
u.rcClient,
|
||||||
keys,
|
keys,
|
||||||
u.expireTime,
|
u.expireTime,
|
||||||
func(user *relationtb.UserModel, keys []string) (int, error) {
|
func(user *relationTb.UserModel, keys []string) (int, error) {
|
||||||
for i, key := range keys {
|
for i, key := range keys {
|
||||||
if key == u.getUserInfoKey(user.UserID) {
|
if key == u.getUserInfoKey(user.UserID) {
|
||||||
return i, nil
|
return i, nil
|
||||||
@@ -129,7 +128,7 @@ func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]
|
|||||||
}
|
}
|
||||||
return 0, errIndex
|
return 0, errIndex
|
||||||
},
|
},
|
||||||
func(ctx context.Context) ([]*relationtb.UserModel, error) {
|
func(ctx context.Context) ([]*relationTb.UserModel, error) {
|
||||||
return u.userDB.Find(ctx, userIDs)
|
return u.userDB.Find(ctx, userIDs)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,23 +15,23 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||||
|
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ChatLogDatabase interface {
|
type ChatLogDatabase interface {
|
||||||
CreateChatLog(msg *pbmsg.MsgDataToMQ) error
|
CreateChatLog(msg *pbMsg.MsgDataToMQ) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewChatLogDatabase(chatLogModelInterface relationtb.ChatLogModelInterface) ChatLogDatabase {
|
func NewChatLogDatabase(chatLogModelInterface relationTb.ChatLogModelInterface) ChatLogDatabase {
|
||||||
return &chatLogDatabase{chatLogModel: chatLogModelInterface}
|
return &chatLogDatabase{chatLogModel: chatLogModelInterface}
|
||||||
}
|
}
|
||||||
|
|
||||||
type chatLogDatabase struct {
|
type chatLogDatabase struct {
|
||||||
chatLogModel relationtb.ChatLogModelInterface
|
chatLogModel relationTb.ChatLogModelInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *chatLogDatabase) CreateChatLog(msg *pbmsg.MsgDataToMQ) error {
|
func (c *chatLogDatabase) CreateChatLog(msg *pbMsg.MsgDataToMQ) error {
|
||||||
return c.chatLogModel.Create(msg)
|
return c.chatLogModel.Create(msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,36 +26,36 @@ import (
|
|||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConversationDatabase interface {
|
type ConversationDatabase interface {
|
||||||
// UpdateUserConversationFiled 更新用户该会话的属性信息
|
// 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 创建一批新的会话
|
||||||
CreateConversation(ctx context.Context, conversations []*relationtb.ConversationModel) error
|
CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error
|
||||||
// SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
|
// SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
|
||||||
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation []*relationtb.ConversationModel) error
|
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation []*relationTb.ConversationModel) error
|
||||||
// FindConversations 根据会话ID获取某个用户的多个会话
|
// 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 获取超级大群开启免打扰的用户ID
|
||||||
FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
|
FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
|
||||||
// GetUserAllConversation 获取一个用户在服务器上所有的会话
|
// GetUserAllConversation 获取一个用户在服务器上所有的会话
|
||||||
GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationtb.ConversationModel, error)
|
GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error)
|
||||||
// SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
|
// SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
|
||||||
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationtb.ConversationModel) error
|
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error
|
||||||
// SetUsersConversationFiledTx 设置多个用户会话关于某个字段的更新操作,如果会话不存在则创建,否则更新,内部保证事务操作
|
// 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
|
CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error
|
||||||
GetConversationIDs(ctx context.Context, userID string) ([]string, error)
|
GetConversationIDs(ctx context.Context, userID string) ([]string, error)
|
||||||
GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error)
|
GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error)
|
||||||
GetAllConversationIDs(ctx context.Context) ([]string, error)
|
GetAllConversationIDs(ctx context.Context) ([]string, error)
|
||||||
GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, 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)
|
||||||
GetConversationIDsNeedDestruct(ctx context.Context) ([]*relationtb.ConversationModel, error)
|
GetConversationIDsNeedDestruct(ctx context.Context) ([]*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{
|
return &conversationDatabase{
|
||||||
conversationDB: conversation,
|
conversationDB: conversation,
|
||||||
cache: cache,
|
cache: cache,
|
||||||
@@ -64,12 +64,12 @@ func NewConversationDatabase(conversation relationtb.ConversationModelInterface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
type conversationDatabase struct {
|
type conversationDatabase struct {
|
||||||
conversationDB relationtb.ConversationModelInterface
|
conversationDB relationTb.ConversationModelInterface
|
||||||
cache cache.ConversationCache
|
cache cache.ConversationCache
|
||||||
tx tx.Tx
|
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()
|
cache := c.cache.NewCache()
|
||||||
if err := c.tx.Transaction(func(tx any) error {
|
if err := c.tx.Transaction(func(tx any) error {
|
||||||
conversationTx := c.conversationDB.NewTx(tx)
|
conversationTx := c.conversationDB.NewTx(tx)
|
||||||
@@ -91,10 +91,10 @@ func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context,
|
|||||||
}
|
}
|
||||||
NotUserIDs := utils.DifferenceString(haveUserIDs, userIDs)
|
NotUserIDs := utils.DifferenceString(haveUserIDs, userIDs)
|
||||||
log.ZDebug(ctx, "SetUsersConversationFiledTx", "NotUserIDs", NotUserIDs, "haveUserIDs", haveUserIDs, "userIDs", userIDs)
|
log.ZDebug(ctx, "SetUsersConversationFiledTx", "NotUserIDs", NotUserIDs, "haveUserIDs", haveUserIDs, "userIDs", userIDs)
|
||||||
var conversations []*relationtb.ConversationModel
|
var conversations []*relationTb.ConversationModel
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
for _, v := range NotUserIDs {
|
for _, v := range NotUserIDs {
|
||||||
temp := new(relationtb.ConversationModel)
|
temp := new(relationTb.ConversationModel)
|
||||||
if err := utils.CopyStructFields(temp, conversation); err != nil {
|
if err := utils.CopyStructFields(temp, conversation); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ func (c *conversationDatabase) UpdateUsersConversationFiled(ctx context.Context,
|
|||||||
return c.cache.DelUsersConversation(conversationID, userIDs...).ExecDel(ctx)
|
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 {
|
if err := c.conversationDB.Create(ctx, conversations); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ func (c *conversationDatabase) CreateConversation(ctx context.Context, conversat
|
|||||||
return cache.DelConversationIDs(userIDs...).DelUserConversationIDsHash(userIDs...).ExecDel(ctx)
|
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()
|
cache := c.cache.NewCache()
|
||||||
if err := c.tx.Transaction(func(tx any) error {
|
if err := c.tx.Transaction(func(tx any) error {
|
||||||
conversationTx := c.conversationDB.NewTx(tx)
|
conversationTx := c.conversationDB.NewTx(tx)
|
||||||
@@ -161,7 +161,7 @@ func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(ctx context.Con
|
|||||||
newConversation.UserID = userID
|
newConversation.UserID = userID
|
||||||
newConversation.ConversationID = conversation.ConversationID
|
newConversation.ConversationID = conversation.ConversationID
|
||||||
newConversation.IsPrivateChat = conversation.IsPrivateChat
|
newConversation.IsPrivateChat = conversation.IsPrivateChat
|
||||||
if err := conversationTx.Create(ctx, []*relationtb.ConversationModel{&newConversation}); err != nil {
|
if err := conversationTx.Create(ctx, []*relationTb.ConversationModel{&newConversation}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cache = cache.DelConversationIDs(ownerUserID).DelUserConversationIDsHash(ownerUserID)
|
cache = cache.DelConversationIDs(ownerUserID).DelUserConversationIDsHash(ownerUserID)
|
||||||
@@ -175,19 +175,19 @@ func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(ctx context.Con
|
|||||||
return cache.ExecDel(ctx)
|
return 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)
|
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)
|
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)
|
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()
|
cache := c.cache.NewCache()
|
||||||
if err := c.tx.Transaction(func(tx any) error {
|
if err := c.tx.Transaction(func(tx any) error {
|
||||||
var conversationIDs []string
|
var conversationIDs []string
|
||||||
@@ -213,7 +213,7 @@ func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUs
|
|||||||
existConversationIDs = append(existConversationIDs, conversation.ConversationID)
|
existConversationIDs = append(existConversationIDs, conversation.ConversationID)
|
||||||
}
|
}
|
||||||
|
|
||||||
var notExistConversations []*relationtb.ConversationModel
|
var notExistConversations []*relationTb.ConversationModel
|
||||||
for _, conversation := range conversations {
|
for _, conversation := range conversations {
|
||||||
if !utils.IsContain(conversation.ConversationID, existConversationIDs) {
|
if !utils.IsContain(conversation.ConversationID, existConversationIDs) {
|
||||||
notExistConversations = append(notExistConversations, conversation)
|
notExistConversations = append(notExistConversations, conversation)
|
||||||
@@ -246,9 +246,9 @@ func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
notExistUserIDs := utils.DifferenceString(userIDs, existConversationUserIDs)
|
notExistUserIDs := utils.DifferenceString(userIDs, existConversationUserIDs)
|
||||||
var conversations []*relationtb.ConversationModel
|
var conversations []*relationTb.ConversationModel
|
||||||
for _, v := range notExistUserIDs {
|
for _, v := range notExistUserIDs {
|
||||||
conversation := relationtb.ConversationModel{ConversationType: constant.SuperGroupChatType, GroupID: groupID, OwnerUserID: v, ConversationID: conversationID}
|
conversation := relationTb.ConversationModel{ConversationType: constant.SuperGroupChatType, GroupID: groupID, OwnerUserID: v, ConversationID: conversationID}
|
||||||
conversations = append(conversations, &conversation)
|
conversations = append(conversations, &conversation)
|
||||||
cache = cache.DelConversations(v, conversationID)
|
cache = cache.DelConversations(v, conversationID)
|
||||||
}
|
}
|
||||||
@@ -289,10 +289,10 @@ func (c *conversationDatabase) GetUserAllHasReadSeqs(ctx context.Context, ownerU
|
|||||||
return c.cache.GetUserAllHasReadSeqs(ctx, ownerUserID)
|
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)
|
return c.conversationDB.GetConversationsByConversationID(ctx, conversationIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) GetConversationIDsNeedDestruct(ctx context.Context) ([]*relationtb.ConversationModel, error) {
|
func (c *conversationDatabase) GetConversationIDsNeedDestruct(ctx context.Context) ([]*relationTb.ConversationModel, error) {
|
||||||
return c.conversationDB.GetConversationIDsNeedDestruct(ctx)
|
return c.conversationDB.GetConversationIDsNeedDestruct(ctx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,22 +30,22 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
unrelationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupDatabase interface {
|
type GroupDatabase interface {
|
||||||
// Group
|
// Group
|
||||||
CreateGroup(ctx context.Context, groups []*relationtb.GroupModel, groupMembers []*relationtb.GroupMemberModel) error
|
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
||||||
TakeGroup(ctx context.Context, groupID string) (group *relationtb.GroupModel, err error)
|
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||||
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
|
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||||
FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
|
FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||||
SearchGroup(
|
SearchGroup(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
keyword string,
|
keyword string,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (uint32, []*relationtb.GroupModel, error)
|
) (uint32, []*relationTb.GroupModel, error)
|
||||||
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
||||||
DismissGroup(ctx context.Context, groupID string, deleteMember bool) error // 解散群,并删除群成员
|
DismissGroup(ctx context.Context, groupID string, deleteMember bool) error // 解散群,并删除群成员
|
||||||
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
|
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
|
||||||
@@ -54,14 +54,14 @@ type GroupDatabase interface {
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
userID string,
|
userID string,
|
||||||
) (groupMember *relationtb.GroupMemberModel, err error)
|
) (groupMember *relationTb.GroupMemberModel, err error)
|
||||||
TakeGroupOwner(ctx context.Context, groupID string) (*relationtb.GroupMemberModel, error)
|
TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error)
|
||||||
FindGroupMember(
|
FindGroupMember(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupIDs []string,
|
groupIDs []string,
|
||||||
userIDs []string,
|
userIDs []string,
|
||||||
roleLevels []int32,
|
roleLevels []int32,
|
||||||
) ([]*relationtb.GroupMemberModel, error)
|
) ([]*relationTb.GroupMemberModel, error)
|
||||||
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
|
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
|
||||||
FindGroupMemberNum(ctx context.Context, groupID string) (uint32, error)
|
FindGroupMemberNum(ctx context.Context, groupID string) (uint32, error)
|
||||||
FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
|
FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
|
||||||
@@ -69,19 +69,19 @@ type GroupDatabase interface {
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupIDs []string,
|
groupIDs []string,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (uint32, []*relationtb.GroupRequestModel, error)
|
) (uint32, []*relationTb.GroupRequestModel, error)
|
||||||
// PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber,
|
// PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber,
|
||||||
// showNumber int32) (uint32, []*relationtb.GroupMemberModel, error)
|
// showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
|
||||||
PageGetJoinGroup(
|
PageGetJoinGroup(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
userID string,
|
userID string,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
|
) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error)
|
||||||
PageGetGroupMember(
|
PageGetGroupMember(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
|
) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error)
|
||||||
SearchGroupMember(
|
SearchGroupMember(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
keyword string,
|
keyword string,
|
||||||
@@ -89,17 +89,17 @@ type GroupDatabase interface {
|
|||||||
userIDs []string,
|
userIDs []string,
|
||||||
roleLevels []int32,
|
roleLevels []int32,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (uint32, []*relationtb.GroupMemberModel, error)
|
) (uint32, []*relationTb.GroupMemberModel, error)
|
||||||
HandlerGroupRequest(
|
HandlerGroupRequest(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
userID string,
|
userID string,
|
||||||
handledMsg string,
|
handledMsg string,
|
||||||
handleResult int32,
|
handleResult int32,
|
||||||
member *relationtb.GroupMemberModel,
|
member *relationTb.GroupMemberModel,
|
||||||
) error
|
) error
|
||||||
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||||
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationtb.GroupSimpleUserID, error)
|
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error)
|
||||||
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
||||||
TransferGroupOwner(
|
TransferGroupOwner(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
@@ -108,18 +108,18 @@ type GroupDatabase interface {
|
|||||||
roleLevel int32,
|
roleLevel int32,
|
||||||
) error // 转让群
|
) error // 转让群
|
||||||
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
|
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
|
||||||
UpdateGroupMembers(ctx context.Context, data []*relationtb.BatchUpdateGroupMember) error
|
UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error
|
||||||
// GroupRequest
|
// GroupRequest
|
||||||
CreateGroupRequest(ctx context.Context, requests []*relationtb.GroupRequestModel) error
|
CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error
|
||||||
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationtb.GroupRequestModel, error)
|
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error)
|
||||||
FindGroupRequests(ctx context.Context, groupID string, userIDs []string) (int64, []*relationtb.GroupRequestModel, error)
|
FindGroupRequests(ctx context.Context, groupID string, userIDs []string) (int64, []*relationTb.GroupRequestModel, error)
|
||||||
PageGroupRequestUser(
|
PageGroupRequestUser(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
userID string,
|
userID string,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (uint32, []*relationtb.GroupRequestModel, error)
|
) (uint32, []*relationTb.GroupRequestModel, error)
|
||||||
// SuperGroupModelInterface
|
// SuperGroupModelInterface
|
||||||
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelationtb.SuperGroupModel, error)
|
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unRelationTb.SuperGroupModel, error)
|
||||||
FindJoinSuperGroup(ctx context.Context, userID string) ([]string, error)
|
FindJoinSuperGroup(ctx context.Context, userID string) ([]string, error)
|
||||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||||
DeleteSuperGroup(ctx context.Context, groupID string) error
|
DeleteSuperGroup(ctx context.Context, groupID string) error
|
||||||
@@ -133,12 +133,12 @@ type GroupDatabase interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewGroupDatabase(
|
func NewGroupDatabase(
|
||||||
group relationtb.GroupModelInterface,
|
group relationTb.GroupModelInterface,
|
||||||
member relationtb.GroupMemberModelInterface,
|
member relationTb.GroupMemberModelInterface,
|
||||||
request relationtb.GroupRequestModelInterface,
|
request relationTb.GroupRequestModelInterface,
|
||||||
tx tx.Tx,
|
tx tx.Tx,
|
||||||
ctxTx tx.CtxTx,
|
ctxTx tx.CtxTx,
|
||||||
superGroup unrelationtb.SuperGroupModelInterface,
|
superGroup unRelationTb.SuperGroupModelInterface,
|
||||||
cache cache.GroupCache,
|
cache cache.GroupCache,
|
||||||
) GroupDatabase {
|
) GroupDatabase {
|
||||||
database := &groupDatabase{
|
database := &groupDatabase{
|
||||||
@@ -177,13 +177,13 @@ func InitGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, database *mongo.D
|
|||||||
}
|
}
|
||||||
|
|
||||||
type groupDatabase struct {
|
type groupDatabase struct {
|
||||||
groupDB relationtb.GroupModelInterface
|
groupDB relationTb.GroupModelInterface
|
||||||
groupMemberDB relationtb.GroupMemberModelInterface
|
groupMemberDB relationTb.GroupMemberModelInterface
|
||||||
groupRequestDB relationtb.GroupRequestModelInterface
|
groupRequestDB relationTb.GroupRequestModelInterface
|
||||||
tx tx.Tx
|
tx tx.Tx
|
||||||
ctxTx tx.CtxTx
|
ctxTx tx.CtxTx
|
||||||
cache cache.GroupCache
|
cache cache.GroupCache
|
||||||
mongoDB unrelationtb.SuperGroupModelInterface
|
mongoDB unRelationTb.SuperGroupModelInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error) {
|
func (g *groupDatabase) GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error) {
|
||||||
@@ -204,8 +204,8 @@ func (g *groupDatabase) FindGroupMemberNum(ctx context.Context, groupID string)
|
|||||||
|
|
||||||
func (g *groupDatabase) CreateGroup(
|
func (g *groupDatabase) CreateGroup(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groups []*relationtb.GroupModel,
|
groups []*relationTb.GroupModel,
|
||||||
groupMembers []*relationtb.GroupMemberModel,
|
groupMembers []*relationTb.GroupMemberModel,
|
||||||
) error {
|
) error {
|
||||||
cache := g.cache.NewCache()
|
cache := g.cache.NewCache()
|
||||||
if err := g.tx.Transaction(func(tx any) error {
|
if err := g.tx.Transaction(func(tx any) error {
|
||||||
@@ -219,7 +219,7 @@ func (g *groupDatabase) CreateGroup(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createGroupIDs := utils.DistinctAnyGetComparable(groups, func(group *relationtb.GroupModel) string {
|
createGroupIDs := utils.DistinctAnyGetComparable(groups, func(group *relationTb.GroupModel) string {
|
||||||
return group.GroupID
|
return group.GroupID
|
||||||
})
|
})
|
||||||
m := make(map[string]struct{})
|
m := make(map[string]struct{})
|
||||||
@@ -239,11 +239,11 @@ func (g *groupDatabase) CreateGroup(
|
|||||||
return cache.ExecDel(ctx)
|
return cache.ExecDel(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) TakeGroup(ctx context.Context, groupID string) (group *relationtb.GroupModel, err error) {
|
func (g *groupDatabase) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
||||||
return g.cache.GetGroupInfo(ctx, groupID)
|
return g.cache.GetGroupInfo(ctx, groupID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error) {
|
func (g *groupDatabase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
||||||
return g.cache.GetGroupsInfo(ctx, groupIDs)
|
return g.cache.GetGroupsInfo(ctx, groupIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ func (g *groupDatabase) SearchGroup(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
keyword string,
|
keyword string,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (uint32, []*relationtb.GroupModel, error) {
|
) (uint32, []*relationTb.GroupModel, error) {
|
||||||
return g.groupDB.Search(ctx, keyword, pageNumber, showNumber)
|
return g.groupDB.Search(ctx, keyword, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,11 +290,11 @@ func (g *groupDatabase) TakeGroupMember(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
userID string,
|
userID string,
|
||||||
) (groupMember *relationtb.GroupMemberModel, err error) {
|
) (groupMember *relationTb.GroupMemberModel, err error) {
|
||||||
return g.cache.GetGroupMemberInfo(ctx, groupID, userID)
|
return g.cache.GetGroupMemberInfo(ctx, groupID, userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) TakeGroupOwner(ctx context.Context, groupID string) (*relationtb.GroupMemberModel, error) {
|
func (g *groupDatabase) TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error) {
|
||||||
return g.groupMemberDB.TakeOwner(ctx, groupID) // todo cache group owner
|
return g.groupMemberDB.TakeOwner(ctx, groupID) // todo cache group owner
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ func (g *groupDatabase) PageGroupRequest(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupIDs []string,
|
groupIDs []string,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (uint32, []*relationtb.GroupRequestModel, error) {
|
) (uint32, []*relationTb.GroupRequestModel, error) {
|
||||||
return g.groupRequestDB.PageGroup(ctx, groupIDs, pageNumber, showNumber)
|
return g.groupRequestDB.PageGroup(ctx, groupIDs, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ func (g *groupDatabase) FindGroupMember(
|
|||||||
groupIDs []string,
|
groupIDs []string,
|
||||||
userIDs []string,
|
userIDs []string,
|
||||||
roleLevels []int32,
|
roleLevels []int32,
|
||||||
) (totalGroupMembers []*relationtb.GroupMemberModel, err error) {
|
) (totalGroupMembers []*relationTb.GroupMemberModel, err error) {
|
||||||
if len(roleLevels) == 0 {
|
if len(roleLevels) == 0 {
|
||||||
for _, groupID := range groupIDs {
|
for _, groupID := range groupIDs {
|
||||||
groupMembers, err := g.cache.GetGroupMembersInfo(ctx, groupID, userIDs)
|
groupMembers, err := g.cache.GetGroupMembersInfo(ctx, groupID, userIDs)
|
||||||
@@ -333,7 +333,7 @@ func (g *groupDatabase) PageGetJoinGroup(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
userID string,
|
userID string,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error) {
|
) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error) {
|
||||||
groupIDs, err := g.cache.GetJoinedGroupIDs(ctx, userID)
|
groupIDs, err := g.cache.GetJoinedGroupIDs(ctx, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, err
|
return 0, nil, err
|
||||||
@@ -352,7 +352,7 @@ func (g *groupDatabase) PageGetGroupMember(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error) {
|
) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error) {
|
||||||
groupMemberIDs, err := g.cache.GetGroupMemberIDs(ctx, groupID)
|
groupMemberIDs, err := g.cache.GetGroupMemberIDs(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, err
|
return 0, nil, err
|
||||||
@@ -375,7 +375,7 @@ func (g *groupDatabase) SearchGroupMember(
|
|||||||
userIDs []string,
|
userIDs []string,
|
||||||
roleLevels []int32,
|
roleLevels []int32,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (uint32, []*relationtb.GroupMemberModel, error) {
|
) (uint32, []*relationTb.GroupMemberModel, error) {
|
||||||
return g.groupMemberDB.SearchMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
return g.groupMemberDB.SearchMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@ func (g *groupDatabase) HandlerGroupRequest(
|
|||||||
userID string,
|
userID string,
|
||||||
handledMsg string,
|
handledMsg string,
|
||||||
handleResult int32,
|
handleResult int32,
|
||||||
member *relationtb.GroupMemberModel,
|
member *relationTb.GroupMemberModel,
|
||||||
) error {
|
) error {
|
||||||
//cache := g.cache.NewCache()
|
//cache := g.cache.NewCache()
|
||||||
//if err := g.tx.Transaction(func(tx any) error {
|
//if err := g.tx.Transaction(func(tx any) error {
|
||||||
@@ -393,7 +393,7 @@ func (g *groupDatabase) HandlerGroupRequest(
|
|||||||
// return err
|
// return err
|
||||||
// }
|
// }
|
||||||
// if member != nil {
|
// if member != nil {
|
||||||
// if err := g.groupMemberDB.NewTx(tx).Create(ctx, []*relationtb.GroupMemberModel{member}); err != nil {
|
// if err := g.groupMemberDB.NewTx(tx).Create(ctx, []*relationTb.GroupMemberModel{member}); err != nil {
|
||||||
// return err
|
// return err
|
||||||
// }
|
// }
|
||||||
// cache = cache.DelGroupMembersHash(groupID).DelGroupMemberIDs(groupID).DelGroupsMemberNum(groupID).DelJoinedGroupID(member.UserID)
|
// cache = cache.DelGroupMembersHash(groupID).DelGroupMemberIDs(groupID).DelGroupsMemberNum(groupID).DelJoinedGroupID(member.UserID)
|
||||||
@@ -409,7 +409,7 @@ func (g *groupDatabase) HandlerGroupRequest(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if member != nil {
|
if member != nil {
|
||||||
if err := g.groupMemberDB.NewTx(tx).Create(ctx, []*relationtb.GroupMemberModel{member}); err != nil {
|
if err := g.groupMemberDB.NewTx(tx).Create(ctx, []*relationTb.GroupMemberModel{member}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := g.cache.NewCache().DelGroupMembersHash(groupID).DelGroupMembersInfo(groupID, member.UserID).DelGroupMemberIDs(groupID).DelGroupsMemberNum(groupID).DelJoinedGroupID(member.UserID).ExecDel(ctx); err != nil {
|
if err := g.cache.NewCache().DelGroupMembersHash(groupID).DelGroupMembersInfo(groupID, member.UserID).DelGroupMemberIDs(groupID).DelGroupsMemberNum(groupID).DelJoinedGroupID(member.UserID).ExecDel(ctx); err != nil {
|
||||||
@@ -435,7 +435,7 @@ func (g *groupDatabase) DeleteGroupMember(ctx context.Context, groupID string, u
|
|||||||
func (g *groupDatabase) MapGroupMemberUserID(
|
func (g *groupDatabase) MapGroupMemberUserID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupIDs []string,
|
groupIDs []string,
|
||||||
) (map[string]*relationtb.GroupSimpleUserID, error) {
|
) (map[string]*relationTb.GroupSimpleUserID, error) {
|
||||||
return g.cache.GetGroupMemberHashMap(ctx, groupIDs)
|
return g.cache.GetGroupMemberHashMap(ctx, groupIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,7 +491,7 @@ func (g *groupDatabase) UpdateGroupMember(
|
|||||||
return g.cache.DelGroupMembersInfo(groupID, userID).ExecDel(ctx)
|
return g.cache.DelGroupMembersInfo(groupID, userID).ExecDel(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) UpdateGroupMembers(ctx context.Context, data []*relationtb.BatchUpdateGroupMember) error {
|
func (g *groupDatabase) UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error {
|
||||||
cache := g.cache.NewCache()
|
cache := g.cache.NewCache()
|
||||||
if err := g.tx.Transaction(func(tx any) error {
|
if err := g.tx.Transaction(func(tx any) error {
|
||||||
for _, item := range data {
|
for _, item := range data {
|
||||||
@@ -507,7 +507,7 @@ func (g *groupDatabase) UpdateGroupMembers(ctx context.Context, data []*relation
|
|||||||
return cache.ExecDel(ctx)
|
return cache.ExecDel(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) CreateGroupRequest(ctx context.Context, requests []*relationtb.GroupRequestModel) error {
|
func (g *groupDatabase) CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error {
|
||||||
return g.tx.Transaction(func(tx any) error {
|
return g.tx.Transaction(func(tx any) error {
|
||||||
db := g.groupRequestDB.NewTx(tx)
|
db := g.groupRequestDB.NewTx(tx)
|
||||||
for _, request := range requests {
|
for _, request := range requests {
|
||||||
@@ -523,7 +523,7 @@ func (g *groupDatabase) TakeGroupRequest(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupID string,
|
groupID string,
|
||||||
userID string,
|
userID string,
|
||||||
) (*relationtb.GroupRequestModel, error) {
|
) (*relationTb.GroupRequestModel, error) {
|
||||||
return g.groupRequestDB.Take(ctx, groupID, userID)
|
return g.groupRequestDB.Take(ctx, groupID, userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -531,14 +531,14 @@ func (g *groupDatabase) PageGroupRequestUser(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
userID string,
|
userID string,
|
||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (uint32, []*relationtb.GroupRequestModel, error) {
|
) (uint32, []*relationTb.GroupRequestModel, error) {
|
||||||
return g.groupRequestDB.Page(ctx, userID, pageNumber, showNumber)
|
return g.groupRequestDB.Page(ctx, userID, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) FindSuperGroup(
|
func (g *groupDatabase) FindSuperGroup(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupIDs []string,
|
groupIDs []string,
|
||||||
) (models []*unrelationtb.SuperGroupModel, err error) {
|
) (models []*unRelationTb.SuperGroupModel, err error) {
|
||||||
return g.cache.GetSuperGroupMemberIDs(ctx, groupIDs...)
|
return g.cache.GetSuperGroupMemberIDs(ctx, groupIDs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,10 +596,10 @@ func (g *groupDatabase) CountRangeEverydayTotal(ctx context.Context, start time.
|
|||||||
return g.groupDB.CountRangeEverydayTotal(ctx, start, end)
|
return g.groupDB.CountRangeEverydayTotal(ctx, start, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) FindGroupRequests(ctx context.Context, groupID string, userIDs []string) (int64, []*relationtb.GroupRequestModel, error) {
|
func (g *groupDatabase) FindGroupRequests(ctx context.Context, groupID string, userIDs []string) (int64, []*relationTb.GroupRequestModel, error) {
|
||||||
return g.groupRequestDB.FindGroupRequests(ctx, groupID, userIDs)
|
return g.groupRequestDB.FindGroupRequests(ctx, groupID, userIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error) {
|
func (g *groupDatabase) FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
||||||
return g.groupDB.FindNotDismissedGroup(ctx, groupIDs)
|
return g.groupDB.FindNotDismissedGroup(ctx, groupIDs)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,14 +27,14 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"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/convert"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
unrelationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
|
||||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
"github.com/OpenIMSDK/protocol/sdkws"
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
)
|
)
|
||||||
@@ -48,7 +48,7 @@ type CommonMsgDatabase interface {
|
|||||||
// 批量插入消息
|
// 批量插入消息
|
||||||
BatchInsertChat2DB(ctx context.Context, conversationID string, msgs []*sdkws.MsgData, currentMaxSeq int64) error
|
BatchInsertChat2DB(ctx context.Context, conversationID string, msgs []*sdkws.MsgData, currentMaxSeq int64) error
|
||||||
// 撤回消息
|
// 撤回消息
|
||||||
RevokeMsg(ctx context.Context, conversationID string, seq int64, revoke *unrelationtb.RevokeModel) error
|
RevokeMsg(ctx context.Context, conversationID string, seq int64, revoke *unRelationTb.RevokeModel) error
|
||||||
// mark as read
|
// mark as read
|
||||||
MarkSingleChatMsgsAsRead(ctx context.Context, userID string, conversationID string, seqs []int64) error
|
MarkSingleChatMsgsAsRead(ctx context.Context, userID string, conversationID string, seqs []int64) error
|
||||||
// 刪除redis中消息缓存
|
// 刪除redis中消息缓存
|
||||||
@@ -93,7 +93,7 @@ type CommonMsgDatabase interface {
|
|||||||
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
|
SetSendMsgStatus(ctx context.Context, id string, status int32) error
|
||||||
GetSendMsgStatus(ctx context.Context, id string) (int32, error)
|
GetSendMsgStatus(ctx context.Context, id string) (int32, error)
|
||||||
SearchMessage(ctx context.Context, req *pbmsg.SearchMessageReq) (total int32, msgData []*sdkws.MsgData, err error)
|
SearchMessage(ctx context.Context, req *pbMsg.SearchMessageReq) (total int32, msgData []*sdkws.MsgData, err error)
|
||||||
|
|
||||||
// to mq
|
// to mq
|
||||||
MsgToMQ(ctx context.Context, key string, msg2mq *sdkws.MsgData) error
|
MsgToMQ(ctx context.Context, key string, msg2mq *sdkws.MsgData) error
|
||||||
@@ -109,7 +109,7 @@ type CommonMsgDatabase interface {
|
|||||||
ase bool,
|
ase bool,
|
||||||
pageNumber int32,
|
pageNumber int32,
|
||||||
showNumber int32,
|
showNumber int32,
|
||||||
) (msgCount int64, userCount int64, users []*unrelationtb.UserCount, dateCount map[string]int64, err error)
|
) (msgCount int64, userCount int64, users []*unRelationTb.UserCount, dateCount map[string]int64, err error)
|
||||||
RangeGroupSendCount(
|
RangeGroupSendCount(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
start time.Time,
|
start time.Time,
|
||||||
@@ -117,11 +117,11 @@ type CommonMsgDatabase interface {
|
|||||||
ase bool,
|
ase bool,
|
||||||
pageNumber int32,
|
pageNumber int32,
|
||||||
showNumber int32,
|
showNumber int32,
|
||||||
) (msgCount int64, userCount int64, groups []*unrelationtb.GroupCount, dateCount map[string]int64, err error)
|
) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error)
|
||||||
ConvertMsgsDocLen(ctx context.Context, conversationIDs []string)
|
ConvertMsgsDocLen(ctx context.Context, conversationIDs []string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCommonMsgDatabase(msgDocModel unrelationtb.MsgDocModelInterface, cacheModel cache.MsgModel) CommonMsgDatabase {
|
func NewCommonMsgDatabase(msgDocModel unRelationTb.MsgDocModelInterface, cacheModel cache.MsgModel) CommonMsgDatabase {
|
||||||
return &commonMsgDatabase{
|
return &commonMsgDatabase{
|
||||||
msgDocDatabase: msgDocModel,
|
msgDocDatabase: msgDocModel,
|
||||||
cache: cacheModel,
|
cache: cacheModel,
|
||||||
@@ -139,8 +139,8 @@ func InitCommonMsgDatabase(rdb redis.UniversalClient, database *mongo.Database)
|
|||||||
}
|
}
|
||||||
|
|
||||||
type commonMsgDatabase struct {
|
type commonMsgDatabase struct {
|
||||||
msgDocDatabase unrelationtb.MsgDocModelInterface
|
msgDocDatabase unRelationTb.MsgDocModelInterface
|
||||||
msg unrelationtb.MsgDocModel
|
msg unRelationTb.MsgDocModel
|
||||||
cache cache.MsgModel
|
cache cache.MsgModel
|
||||||
producer *kafka.Producer
|
producer *kafka.Producer
|
||||||
producerToMongo *kafka.Producer
|
producerToMongo *kafka.Producer
|
||||||
@@ -155,14 +155,14 @@ func (db *commonMsgDatabase) MsgToMQ(ctx context.Context, key string, msg2mq *sd
|
|||||||
|
|
||||||
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 {
|
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 err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) MsgToPushMQ(ctx context.Context, key, conversationID string, msg2mq *sdkws.MsgData) (int32, int64, error) {
|
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})
|
partition, offset, err := db.producerToPush.SendMessage(ctx, key, &pbMsg.PushMsgDataToMQ{MsgData: msg2mq, ConversationID: conversationID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "MsgToPushMQ", err, "key", key, "msg2mq", msg2mq)
|
log.ZError(ctx, "MsgToPushMQ", err, "key", key, "msg2mq", msg2mq)
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
@@ -172,7 +172,7 @@ func (db *commonMsgDatabase) MsgToPushMQ(ctx context.Context, key, conversationI
|
|||||||
|
|
||||||
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 {
|
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 err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -188,13 +188,13 @@ func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationI
|
|||||||
var ok bool
|
var ok bool
|
||||||
switch key {
|
switch key {
|
||||||
case updateKeyMsg:
|
case updateKeyMsg:
|
||||||
var msg *unrelationtb.MsgDataModel
|
var msg *unRelationTb.MsgDataModel
|
||||||
msg, ok = field.(*unrelationtb.MsgDataModel)
|
msg, ok = field.(*unRelationTb.MsgDataModel)
|
||||||
if msg != nil && msg.Seq != firstSeq+int64(i) {
|
if msg != nil && msg.Seq != firstSeq+int64(i) {
|
||||||
return errs.ErrInternalServer.Wrap("seq is invalid")
|
return errs.ErrInternalServer.Wrap("seq is invalid")
|
||||||
}
|
}
|
||||||
case updateKeyRevoke:
|
case updateKeyRevoke:
|
||||||
_, ok = field.(*unrelationtb.RevokeModel)
|
_, ok = field.(*unRelationTb.RevokeModel)
|
||||||
default:
|
default:
|
||||||
return errs.ErrInternalServer.Wrap("key is invalid")
|
return errs.ErrInternalServer.Wrap("key is invalid")
|
||||||
}
|
}
|
||||||
@@ -234,9 +234,9 @@ func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationI
|
|||||||
continue // 匹配到了,继续下一个(不一定修改)
|
continue // 匹配到了,继续下一个(不一定修改)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doc := unrelationtb.MsgDocModel{
|
doc := unRelationTb.MsgDocModel{
|
||||||
DocID: db.msg.GetDocID(conversationID, seq),
|
DocID: db.msg.GetDocID(conversationID, seq),
|
||||||
Msg: make([]*unrelationtb.MsgInfoModel, num),
|
Msg: make([]*unRelationTb.MsgInfoModel, num),
|
||||||
}
|
}
|
||||||
var insert int // 插入的数量
|
var insert int // 插入的数量
|
||||||
for j := i; j < len(fields); j++ {
|
for j := i; j < len(fields); j++ {
|
||||||
@@ -247,18 +247,18 @@ func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationI
|
|||||||
insert++
|
insert++
|
||||||
switch key {
|
switch key {
|
||||||
case updateKeyMsg:
|
case updateKeyMsg:
|
||||||
doc.Msg[db.msg.GetMsgIndex(seq)] = &unrelationtb.MsgInfoModel{
|
doc.Msg[db.msg.GetMsgIndex(seq)] = &unRelationTb.MsgInfoModel{
|
||||||
Msg: fields[j].(*unrelationtb.MsgDataModel),
|
Msg: fields[j].(*unRelationTb.MsgDataModel),
|
||||||
}
|
}
|
||||||
case updateKeyRevoke:
|
case updateKeyRevoke:
|
||||||
doc.Msg[db.msg.GetMsgIndex(seq)] = &unrelationtb.MsgInfoModel{
|
doc.Msg[db.msg.GetMsgIndex(seq)] = &unRelationTb.MsgInfoModel{
|
||||||
Revoke: fields[j].(*unrelationtb.RevokeModel),
|
Revoke: fields[j].(*unRelationTb.RevokeModel),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i, model := range doc.Msg {
|
for i, model := range doc.Msg {
|
||||||
if model == nil {
|
if model == nil {
|
||||||
model = &unrelationtb.MsgInfoModel{}
|
model = &unRelationTb.MsgInfoModel{}
|
||||||
doc.Msg[i] = model
|
doc.Msg[i] = model
|
||||||
}
|
}
|
||||||
if model.DelList == nil {
|
if model.DelList == nil {
|
||||||
@@ -288,9 +288,9 @@ func (db *commonMsgDatabase) BatchInsertChat2DB(ctx context.Context, conversatio
|
|||||||
if msg == nil {
|
if msg == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var offlinePushModel *unrelationtb.OfflinePushModel
|
var offlinePushModel *unRelationTb.OfflinePushModel
|
||||||
if msg.OfflinePushInfo != nil {
|
if msg.OfflinePushInfo != nil {
|
||||||
offlinePushModel = &unrelationtb.OfflinePushModel{
|
offlinePushModel = &unRelationTb.OfflinePushModel{
|
||||||
Title: msg.OfflinePushInfo.Title,
|
Title: msg.OfflinePushInfo.Title,
|
||||||
Desc: msg.OfflinePushInfo.Desc,
|
Desc: msg.OfflinePushInfo.Desc,
|
||||||
Ex: msg.OfflinePushInfo.Ex,
|
Ex: msg.OfflinePushInfo.Ex,
|
||||||
@@ -298,7 +298,7 @@ func (db *commonMsgDatabase) BatchInsertChat2DB(ctx context.Context, conversatio
|
|||||||
IOSBadgeCount: msg.OfflinePushInfo.IOSBadgeCount,
|
IOSBadgeCount: msg.OfflinePushInfo.IOSBadgeCount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msgs[i] = &unrelationtb.MsgDataModel{
|
msgs[i] = &unRelationTb.MsgDataModel{
|
||||||
SendID: msg.SendID,
|
SendID: msg.SendID,
|
||||||
RecvID: msg.RecvID,
|
RecvID: msg.RecvID,
|
||||||
GroupID: msg.GroupID,
|
GroupID: msg.GroupID,
|
||||||
@@ -325,7 +325,7 @@ func (db *commonMsgDatabase) BatchInsertChat2DB(ctx context.Context, conversatio
|
|||||||
return db.BatchInsertBlock(ctx, conversationID, msgs, updateKeyMsg, msgList[0].Seq)
|
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)
|
return db.BatchInsertBlock(ctx, conversationID, []any{revoke}, updateKeyRevoke, seq)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,7 +413,7 @@ func (db *commonMsgDatabase) getMsgBySeqs(ctx context.Context, userID, conversat
|
|||||||
return totalMsgs, nil
|
return totalMsgs, 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)
|
msgs, err := db.msgDocDatabase.GetMsgBySeqIndexIn1Doc(ctx, userID, docID, seqs)
|
||||||
for _, msg := range msgs {
|
for _, msg := range msgs {
|
||||||
if msg.IsRead {
|
if msg.IsRead {
|
||||||
@@ -927,7 +927,7 @@ func (db *commonMsgDatabase) RangeUserSendCount(
|
|||||||
ase bool,
|
ase bool,
|
||||||
pageNumber int32,
|
pageNumber int32,
|
||||||
showNumber int32,
|
showNumber int32,
|
||||||
) (msgCount int64, userCount int64, users []*unrelationtb.UserCount, dateCount map[string]int64, err error) {
|
) (msgCount int64, userCount int64, users []*unRelationTb.UserCount, dateCount map[string]int64, err error) {
|
||||||
return db.msgDocDatabase.RangeUserSendCount(ctx, start, end, group, ase, pageNumber, showNumber)
|
return db.msgDocDatabase.RangeUserSendCount(ctx, start, end, group, ase, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -938,11 +938,11 @@ func (db *commonMsgDatabase) RangeGroupSendCount(
|
|||||||
ase bool,
|
ase bool,
|
||||||
pageNumber int32,
|
pageNumber int32,
|
||||||
showNumber int32,
|
showNumber int32,
|
||||||
) (msgCount int64, userCount int64, groups []*unrelationtb.GroupCount, dateCount map[string]int64, err error) {
|
) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error) {
|
||||||
return db.msgDocDatabase.RangeGroupSendCount(ctx, start, end, ase, pageNumber, showNumber)
|
return db.msgDocDatabase.RangeGroupSendCount(ctx, start, end, ase, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) SearchMessage(ctx context.Context, req *pbmsg.SearchMessageReq) (total int32, msgData []*sdkws.MsgData, err error) {
|
func (db *commonMsgDatabase) SearchMessage(ctx context.Context, req *pbMsg.SearchMessageReq) (total int32, msgData []*sdkws.MsgData, err error) {
|
||||||
var totalMsgs []*sdkws.MsgData
|
var totalMsgs []*sdkws.MsgData
|
||||||
total, msgs, err := db.msgDocDatabase.SearchMessage(ctx, req)
|
total, msgs, err := db.msgDocDatabase.SearchMessage(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
unrelationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -173,10 +173,10 @@ func Test_Insert(t *testing.T) {
|
|||||||
var arr []any
|
var arr []any
|
||||||
for i := 0; i < 345; i++ {
|
for i := 0; i < 345; i++ {
|
||||||
if i%2 == 0 {
|
if i%2 == 0 {
|
||||||
arr = append(arr, (*unrelationtb.MsgDataModel)(nil))
|
arr = append(arr, (*unRelationTb.MsgDataModel)(nil))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
arr = append(arr, &unrelationtb.MsgDataModel{
|
arr = append(arr, &unRelationTb.MsgDataModel{
|
||||||
Seq: int64(i),
|
Seq: int64(i),
|
||||||
Content: fmt.Sprintf("test-%d", i),
|
Content: fmt.Sprintf("test-%d", i),
|
||||||
})
|
})
|
||||||
@@ -191,7 +191,7 @@ func Test_Revoke(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
var arr []any
|
var arr []any
|
||||||
for i := 0; i < 456; i++ {
|
for i := 0; i < 456; i++ {
|
||||||
arr = append(arr, &unrelationtb.RevokeModel{
|
arr = append(arr, &unRelationTb.RevokeModel{
|
||||||
UserID: "uid_" + strconv.Itoa(i),
|
UserID: "uid_" + strconv.Itoa(i),
|
||||||
Nickname: "uname_" + strconv.Itoa(i),
|
Nickname: "uname_" + strconv.Itoa(i),
|
||||||
Time: time.Now().UnixMilli(),
|
Time: time.Now().UnixMilli(),
|
||||||
@@ -254,7 +254,7 @@ func Test_FindBySeq(t *testing.T) {
|
|||||||
//
|
//
|
||||||
// c := mongo.GetClient().Database("openIM").Collection("msg")
|
// c := mongo.GetClient().Database("openIM").Collection("msg")
|
||||||
//
|
//
|
||||||
// var o unrelationtb.MsgDocModel
|
// var o unRelationTb.MsgDocModel
|
||||||
//
|
//
|
||||||
// err = c.FindOne(context.Background(), bson.M{"doc_id": "test:0"}).Decode(&o)
|
// err = c.FindOne(context.Background(), bson.M{"doc_id": "test:0"}).Decode(&o)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/user"
|
"github.com/OpenIMSDK/protocol/user"
|
||||||
|
|
||||||
unrelationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"github.com/OpenIMSDK/tools/tx"
|
"github.com/OpenIMSDK/tools/tx"
|
||||||
@@ -71,10 +71,10 @@ type userDatabase struct {
|
|||||||
userDB relation.UserModelInterface
|
userDB relation.UserModelInterface
|
||||||
cache cache.UserCache
|
cache cache.UserCache
|
||||||
tx tx.Tx
|
tx tx.Tx
|
||||||
mongoDB unrelationtb.UserModelInterface
|
mongoDB unRelationTb.UserModelInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserDatabase(userDB relation.UserModelInterface, cache cache.UserCache, tx tx.Tx, mongoDB unrelationtb.UserModelInterface) UserDatabase {
|
func NewUserDatabase(userDB relation.UserModelInterface, cache cache.UserCache, tx tx.Tx, mongoDB unRelationTb.UserModelInterface) UserDatabase {
|
||||||
return &userDatabase{userDB: userDB, cache: cache, tx: tx, mongoDB: mongoDB}
|
return &userDatabase{userDB: userDB, cache: cache, tx: tx, mongoDB: mongoDB}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||||
sdkws "github.com/OpenIMSDK/protocol/sdkws"
|
sdkws "github.com/OpenIMSDK/protocol/sdkws"
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ func NewChatLogGorm(db *gorm.DB) relation.ChatLogModelInterface {
|
|||||||
return &ChatLogGorm{NewMetaDB(db, &relation.ChatLogModel{})}
|
return &ChatLogGorm{NewMetaDB(db, &relation.ChatLogModel{})}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ChatLogGorm) Create(msg *pbmsg.MsgDataToMQ) error {
|
func (c *ChatLogGorm) Create(msg *pbMsg.MsgDataToMQ) error {
|
||||||
chatLog := new(relation.ChatLogModel)
|
chatLog := new(relation.ChatLogModel)
|
||||||
copier.Copy(chatLog, msg.MsgData)
|
copier.Copy(chatLog, msg.MsgData)
|
||||||
switch msg.MsgData.SessionType {
|
switch msg.MsgData.SessionType {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
mysqldriver "github.com/go-sql-driver/mysql"
|
mysqlDriver "github.com/go-sql-driver/mysql"
|
||||||
"gorm.io/driver/mysql"
|
"gorm.io/driver/mysql"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
@@ -94,7 +94,7 @@ func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
if mysqlErr, ok := err.(*mysqldriver.MySQLError); ok && mysqlErr.Number == 1045 {
|
if mysqlErr, ok := err.(*mysqlDriver.MySQLError); ok && mysqlErr.Number == 1045 {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
time.Sleep(time.Duration(1) * time.Second)
|
time.Sleep(time.Duration(1) * time.Second)
|
||||||
@@ -117,7 +117,7 @@ func replaceDuplicateKey(err error) errs.CodeError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsMysqlDuplicateKey(err error) bool {
|
func IsMysqlDuplicateKey(err error) bool {
|
||||||
if mysqlErr, ok := err.(*mysqldriver.MySQLError); ok {
|
if mysqlErr, ok := err.(*mysqlDriver.MySQLError); ok {
|
||||||
return mysqlErr.Number == 1062
|
return mysqlErr.Number == 1062
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright © 2023 OpenIM. All rights reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package minio
|
package minio
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -77,15 +77,15 @@ func NewMinio() (s3.Interface, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
m := &Minio{
|
m := &Minio{
|
||||||
bucket: conf.Bucket,
|
bucket: conf.Bucket,
|
||||||
core: &minio.Core{Client: client},
|
bucketURL: conf.Endpoint + "/" + conf.Bucket + "/",
|
||||||
lock: &sync.Mutex{},
|
core: &minio.Core{Client: client},
|
||||||
init: false,
|
lock: &sync.Mutex{},
|
||||||
|
init: false,
|
||||||
}
|
}
|
||||||
if conf.SignEndpoint == "" || conf.SignEndpoint == conf.Endpoint {
|
if conf.SignEndpoint == "" || conf.SignEndpoint == conf.Endpoint {
|
||||||
m.opts = opts
|
m.opts = opts
|
||||||
m.sign = m.core.Client
|
m.sign = m.core.Client
|
||||||
m.bucketURL = conf.Endpoint + "/" + conf.Bucket + "/"
|
|
||||||
} else {
|
} else {
|
||||||
su, err := url.Parse(conf.SignEndpoint)
|
su, err := url.Parse(conf.SignEndpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -99,7 +99,6 @@ func NewMinio() (s3.Interface, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
m.bucketURL = conf.SignEndpoint + "/" + conf.Bucket + "/"
|
|
||||||
}
|
}
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright © 2023 OpenIM. All rights reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package minio
|
package minio
|
||||||
|
|
||||||
type minioImageInfo struct {
|
type minioImageInfo struct {
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright © 2023 OpenIM. All rights reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package oss
|
package oss
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user