mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-05 05:12:45 +08:00
fix: Fix Bug related issues with OpenIM actions PR (#921)
* feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
parent
73c4b68052
commit
b2ea4ce2a3
@ -15,7 +15,7 @@ CHANGELOG/
|
||||
# LICENSE
|
||||
|
||||
# Ignore testing and linting configuration
|
||||
scripts/golangci.yml
|
||||
.golangci.yml
|
||||
|
||||
# Ignore deployment-related files
|
||||
docker-compose.yaml
|
||||
|
8
.github/sync.yml
vendored
8
.github/sync.yml
vendored
@ -75,15 +75,15 @@ OpenIMSDK/OpenKF:
|
||||
dest: .github/.codecov.yml
|
||||
replace: false
|
||||
|
||||
openim-sigs/openim-docker:
|
||||
openim-docker/openim-docker:
|
||||
- source: ./config
|
||||
dest: ./openim-server/config
|
||||
dest: ./openim-server/main/config
|
||||
replace: true
|
||||
- source: ./docs
|
||||
dest: ./openim-server/docs
|
||||
dest: ./openim-server/main/docs
|
||||
replace: true
|
||||
- source: ./scripts
|
||||
dest: ./openim-server/scripts
|
||||
dest: ./openim-server/main/scripts
|
||||
replace: true
|
||||
|
||||
group:
|
||||
|
3
.github/workflows/auto-gh-pr.yml
vendored
3
.github/workflows/auto-gh-pr.yml
vendored
@ -26,7 +26,8 @@ on:
|
||||
jobs:
|
||||
create-pr:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true
|
||||
if: github.event.pull_request.base.ref == 'main'
|
||||
# && github.event.pull_request.merged == true
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v3
|
||||
|
21
.github/workflows/deploy.yml
vendored
21
.github/workflows/deploy.yml
vendored
@ -51,23 +51,4 @@ jobs:
|
||||
echo "OWNER: $OWNER"
|
||||
echo "REPO: $REPO"
|
||||
git clone -b develop https://github.com/${OWNER}/${REPO}.git; cd ${REPO}
|
||||
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
|
||||
docker compose up -d
|
30
.github/workflows/e2e-test.yml
vendored
30
.github/workflows/e2e-test.yml
vendored
@ -12,5 +12,33 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# name: OpenIM e2e Test
|
||||
name: e2e
|
||||
|
||||
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"
|
15
.github/workflows/golangci-lint.yml
vendored
15
.github/workflows/golangci-lint.yml
vendored
@ -18,7 +18,6 @@ on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
jobs:
|
||||
golangci:
|
||||
name: lint
|
||||
@ -27,25 +26,25 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.20'
|
||||
go-version: '1.21'
|
||||
cache: false
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
uses: golangci/golangci-lint-action@v3.7.0
|
||||
with:
|
||||
# Require: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
||||
version: v1.53
|
||||
version: v1.54
|
||||
|
||||
# Optional: working directory, useful for monorepos
|
||||
working-directory: server
|
||||
# working-directory: server
|
||||
|
||||
# Optional: golangci-lint command line arguments.
|
||||
#
|
||||
# Note: by default the `.golangci.yml` file should be at the root of the repository.
|
||||
# The location of the configuration file can be changed by using `--config=`
|
||||
args: --timeout=30m --config=/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`.
|
||||
# only-new-issues: true
|
||||
only-new-issues: true
|
||||
|
||||
# Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
|
||||
install-mode: "goinstall"
|
||||
# install-mode: "goinstall"
|
4
.github/workflows/greetings.yml
vendored
4
.github/workflows/greetings.yml
vendored
@ -26,9 +26,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/first-interaction@main
|
||||
- uses: actions/first-interaction@v1.1.1
|
||||
with:
|
||||
repo-token: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||
repo-token: ${{ secrets.REDBOT_GITHUB_TOKEN }}
|
||||
issue-message: |
|
||||
Hello! Thank you for filing an issue.
|
||||
|
||||
|
9
.github/workflows/openimci.yml
vendored
9
.github/workflows/openimci.yml
vendored
@ -151,7 +151,7 @@ jobs:
|
||||
version: 2.x
|
||||
- name: Docker Operations
|
||||
run: |
|
||||
curl -o docker-compose.yaml https://gist.githubusercontent.com/cubxxw/b1d5cbd2edfa23fee911118aa3e8249e/raw/openim-server.sh
|
||||
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
|
||||
|
||||
@ -162,9 +162,10 @@ jobs:
|
||||
|
||||
- name: Build, Start and Check Services
|
||||
run: |
|
||||
make build
|
||||
make start
|
||||
make check
|
||||
sudo make init
|
||||
sudo make build
|
||||
sudo make start
|
||||
sudo make check
|
||||
|
||||
- name: Print OpenIM Logs
|
||||
run: sudo cat ./_output/logs/* 2>/dev/null
|
||||
|
60
.github/workflows/pull-request.yml
vendored
60
.github/workflows/pull-request.yml
vendored
@ -20,16 +20,13 @@ on:
|
||||
- 'README.md'
|
||||
- 'CONTRIBUTING.md'
|
||||
- 'docs/**'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'CONTRIBUTING.md'
|
||||
- 'docs/**'
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 2 * * *'
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -60,6 +57,12 @@ jobs:
|
||||
echo "Run go format successfully"
|
||||
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
|
||||
run: |
|
||||
make generate
|
||||
@ -72,18 +75,13 @@ jobs:
|
||||
echo "Run unit test and get test coverage successfully"
|
||||
continue-on-error: true
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: go
|
||||
# - name: Initialize CodeQL
|
||||
# uses: github/codeql-action/init@v2
|
||||
# with:
|
||||
# languages: go
|
||||
|
||||
- name: Build source code for host platform
|
||||
run: |
|
||||
sudo make build
|
||||
echo "Build source code for host platform successfully"
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
# - name: Perform CodeQL Analysis
|
||||
# uses: github/codeql-action/analyze@v2
|
||||
|
||||
- name: OpenIM verify copyright
|
||||
run: |
|
||||
@ -92,23 +90,33 @@ jobs:
|
||||
echo "OpenIM verify successfully"
|
||||
continue-on-error: true
|
||||
|
||||
- name: Commit code
|
||||
run: |
|
||||
git add .
|
||||
# - name: Commit code
|
||||
# run: |
|
||||
# git add .
|
||||
# git commit -m "cicd: bump League Patch to cicd/patch-${{ github.event.number }}"
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
with:
|
||||
token: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||
commit-message: "cicd: 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: |
|
||||
Review criteria:
|
||||
|
||||
|
||||
- [ ] Disenchanter can connect and issue actions
|
||||
|
||||
This is an automated PR.
|
||||
This is an automated PR. @ ${{ github.actor }}
|
||||
<sub>[workflow](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/.github/workflows/pull-request.yml).</sub>
|
||||
base: main
|
||||
branch: cicd/patch-${{ github.event.number }}
|
||||
labels: kind/documentation, area/test, ok-to-test
|
||||
token: ${{ secrets.REDBOT_GITHUB_TOKEN }}
|
||||
labels: |
|
||||
kind/documentation
|
||||
enhancement
|
||||
report
|
4
.github/workflows/release-drafter.yml
vendored
4
.github/workflows/release-drafter.yml
vendored
@ -18,11 +18,11 @@ on:
|
||||
push:
|
||||
# branches to consider in the event; optional, defaults to all
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
# pull_request event is required only for autolabeler
|
||||
pull_request:
|
||||
# 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:
|
||||
# types: [opened, reopened, synchronize]
|
||||
|
74
.github/workflows/scripts-verify.yml
vendored
Normal file
74
.github/workflows/scripts-verify.yml
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
# Copyright © 2023 OpenIM. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT 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
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -399,3 +399,5 @@ Sessionx.vim
|
||||
# End of https://www.toptal.com/developers/gitignore/api/go,git,vim,tags,test,emacs,backup,jetbrains
|
||||
.idea
|
||||
dist/
|
||||
.env
|
||||
config/config.yaml
|
||||
|
@ -58,7 +58,6 @@ run:
|
||||
skip-files:
|
||||
- ".*\\.my\\.go$"
|
||||
- _test.go
|
||||
- ".*\\.pb\\.go"
|
||||
|
||||
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
|
||||
# If invoked with -mod=readonly, the go command is disallowed from the implicit
|
||||
@ -177,7 +176,7 @@ linters-settings:
|
||||
# put imports beginning with prefix after 3rd-party packages;
|
||||
# only support one prefix
|
||||
# if not set, use goimports.local-prefixes
|
||||
prefix: github.com/OpenIMSDK/OpenKF
|
||||
prefix: github.com/OpenIMSDK/Open-IM-Server
|
||||
gocognit:
|
||||
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
||||
min-complexity: 30
|
||||
@ -334,10 +333,8 @@ linters-settings:
|
||||
goimports:
|
||||
# put imports beginning with prefix after 3rd-party packages;
|
||||
# it's a comma-separated list of prefixes
|
||||
local-prefixes: github.com/OpenIMSDK/OpenKF
|
||||
golint:
|
||||
# minimal confidence for issues, default is 0.8
|
||||
min-confidence: 0.9
|
||||
local-prefixes: github.com/OpenIMSDK/Open-IM-Server
|
||||
|
||||
gomnd:
|
||||
settings:
|
||||
mnd:
|
||||
@ -443,12 +440,7 @@ linters-settings:
|
||||
# packages-with-error-message:
|
||||
# # specify an error message to output when a blacklisted package is used
|
||||
# - github.com/Sirupsen/logrus: "logging is allowed only by logutils.Log"
|
||||
ifshort:
|
||||
# Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax.
|
||||
# Has higher priority than max-decl-chars.
|
||||
max-decl-lines: 1
|
||||
# Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
|
||||
max-decl-chars: 30
|
||||
|
||||
|
||||
importas:
|
||||
# if set to `true`, force to use alias.
|
||||
@ -723,7 +715,6 @@ linters:
|
||||
- asciicheck
|
||||
- bodyclose
|
||||
- cyclop
|
||||
- deadcode
|
||||
# - depguard
|
||||
- dogsled
|
||||
- dupl
|
||||
@ -751,7 +742,6 @@ linters:
|
||||
- gosec
|
||||
- gosimple
|
||||
- govet
|
||||
- ifshort
|
||||
- importas
|
||||
- ineffassign
|
||||
- lll
|
||||
@ -771,19 +761,16 @@ linters:
|
||||
- rowserrcheck
|
||||
- sqlclosecheck
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- stylecheck
|
||||
- thelper
|
||||
- tparallel
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- varcheck
|
||||
- wastedassign
|
||||
- whitespace
|
||||
- bidichk
|
||||
- wastedassign
|
||||
- golint
|
||||
- execinquery
|
||||
- nosprintfhostport
|
||||
- grouper
|
||||
@ -814,10 +801,6 @@ issues:
|
||||
|
||||
# Excluding configuration per-path, per-linter, per-text and per-source
|
||||
exclude-rules:
|
||||
- linters:
|
||||
- golint
|
||||
path: (internal/api/.*)\.go # exclude golint for internal/api/... files
|
||||
|
||||
- linters:
|
||||
- revive
|
||||
path: (log/.*)\.go
|
||||
@ -857,9 +840,7 @@ issues:
|
||||
|
||||
- path: (pkg/app/.*)\.go
|
||||
linters:
|
||||
- deadcode
|
||||
- unused
|
||||
- varcheck
|
||||
- forbidigo
|
||||
|
||||
# Exclude some staticcheck messages
|
@ -1,53 +1,22 @@
|
||||
# Version logging for OpenIM:v2.0
|
||||
|
||||
> **Note**:
|
||||
> Deprecated version logging for OpenIM, please refer to [CHANGELOG.md](../CHANGELOG.md)
|
||||
# Version logging for OpenIM
|
||||
|
||||
<!-- 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 -->
|
||||
|
||||
|
||||
<a name="unreleased"></a>
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
<a name="v2.0.10"></a>
|
||||
|
||||
## [v2.0.10] - 2022-05-13
|
||||
|
||||
<a name="v2.0.9"></a>
|
||||
|
||||
## [v2.0.9] - 2022-04-29
|
||||
|
||||
### Reverts
|
||||
|
||||
- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
|
||||
|
||||
### Pull Requests
|
||||
|
||||
- Merge branch 'tuoyun'
|
||||
- Merge branch 'tuoyun'
|
||||
- Merge branch 'tuoyun'
|
||||
@ -57,53 +26,38 @@
|
||||
|
||||
|
||||
<a name="v2.0.8"></a>
|
||||
|
||||
## [v2.0.8] - 2022-04-24
|
||||
|
||||
### Pull Requests
|
||||
|
||||
- Merge branch 'tuoyun'
|
||||
- Merge branch 'tuoyun'
|
||||
|
||||
|
||||
<a name="v2.0.7"></a>
|
||||
|
||||
## [v2.0.7] - 2022-04-08
|
||||
|
||||
### Pull Requests
|
||||
|
||||
- Merge branch 'tuoyun'
|
||||
- Merge branch 'tuoyun'
|
||||
- Merge branch 'tuoyun'
|
||||
|
||||
|
||||
<a name="v2.0.6"></a>
|
||||
|
||||
## [v2.0.6] - 2022-04-01
|
||||
|
||||
### Pull Requests
|
||||
|
||||
- Merge branch 'tuoyun'
|
||||
|
||||
|
||||
<a name="v2.0.5"></a>
|
||||
|
||||
## [v2.0.5] - 2022-03-24
|
||||
|
||||
<a name="v2.04"></a>
|
||||
|
||||
## [v2.04] - 2022-03-18
|
||||
|
||||
<a name="v2.0.3"></a>
|
||||
|
||||
## [v2.0.3] - 2022-03-11
|
||||
|
||||
<a name="v2.0.2"></a>
|
||||
|
||||
## [v2.0.2] - 2022-03-04
|
||||
|
||||
### Pull Requests
|
||||
|
||||
- Merge branch 'tuoyun'
|
||||
- Merge branch 'tuoyun'
|
||||
- Merge branch 'tuoyun'
|
||||
@ -111,11 +65,23 @@
|
||||
|
||||
|
||||
<a name="v2.0.1"></a>
|
||||
|
||||
## [v2.0.1] - 2022-02-25
|
||||
|
||||
<a name="v2.0.0"></a>
|
||||
|
||||
## v2.0.0 - 2022-02-23
|
||||
|
||||
### 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
|
||||
|
44
CHANGELOG/CHANGELOG-3.2.md
Normal file
44
CHANGELOG/CHANGELOG-3.2.md
Normal file
@ -0,0 +1,44 @@
|
||||
# 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
|
9
Makefile
9
Makefile
@ -6,7 +6,7 @@
|
||||
|
||||
## all: Run tidy, gen, add-copyright, format, lint, cover, build ✨
|
||||
.PHONY: all
|
||||
all: tidy gen add-copyright lint cover restart
|
||||
all: tidy gen add-copyright verify lint cover restart
|
||||
|
||||
# ==============================================================================
|
||||
# Build set
|
||||
@ -80,7 +80,7 @@ stop:
|
||||
|
||||
## restart: Restart openim ✨
|
||||
.PHONY: restart
|
||||
restart: clean stop build start
|
||||
restart: clean stop build init start
|
||||
|
||||
## multiarch: Build binaries for multiple platforms. See option PLATFORMS. ✨
|
||||
.PHONY: multiarch
|
||||
@ -102,6 +102,11 @@ install:
|
||||
check:
|
||||
@$(MAKE) go.check
|
||||
|
||||
## check-component
|
||||
.PHONY: check-component
|
||||
check-component:
|
||||
@$(MAKE) go.check-component
|
||||
|
||||
## tidy: tidy go.mod ✨
|
||||
.PHONY: tidy
|
||||
tidy:
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
"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/Open-IM-Server/internal/api"
|
||||
@ -66,11 +66,11 @@ func run(port int) error {
|
||||
}
|
||||
fmt.Println("api start init discov client")
|
||||
var client discoveryregistry.SvcDiscoveryRegistry
|
||||
client, err = openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
||||
openKeeper.WithFreq(time.Hour), openKeeper.WithUserNameAndPassword(
|
||||
client, err = openkeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
||||
openkeeper.WithFreq(time.Hour), openkeeper.WithUserNameAndPassword(
|
||||
config.Config.Zookeeper.Username,
|
||||
config.Config.Zookeeper.Password,
|
||||
), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))
|
||||
), openkeeper.WithRoundRobin(), openkeeper.WithTimeout(10), openkeeper.WithLogger(log.NewZkLogger()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ services:
|
||||
- 9090:9090
|
||||
container_name: minio
|
||||
volumes:
|
||||
- /mnt/data:/data
|
||||
- /mnt/config:/root/.minio
|
||||
- ${DATA_DIR}/components/mnt/data:/data
|
||||
- ${DATA_DIR}/components/mnt/config:/root/.minio
|
||||
environment:
|
||||
MINIO_ROOT_USER: ${USER}
|
||||
MINIO_ROOT_PASSWORD: ${PASSWORD}
|
||||
@ -99,9 +99,9 @@ services:
|
||||
command: minio server /data --console-address ':9090'
|
||||
|
||||
openim-server:
|
||||
# image: ghcr.io/openimsdk/openim-server:release-v3.2
|
||||
image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:release-v3.2
|
||||
# image: openim/openim-server:release-v3.2
|
||||
image: ghcr.io/openimsdk/openim-server:main
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:main
|
||||
# image: openim/openim-server:main
|
||||
container_name: openim-server
|
||||
# healthcheck:
|
||||
# test: ["CMD-SHELL", "./scripts/check-all.sh"]
|
||||
@ -109,9 +109,9 @@ services:
|
||||
# timeout: 10s
|
||||
# retries: 5
|
||||
volumes:
|
||||
- ${DATA_DIR}/_output/openim/logs:/openim/openim-server/logs
|
||||
- ${DATA_DIR}/config:/openim/openim-server/config
|
||||
- ${DATA_DIR}/scripts:/openim/openim-server/scripts
|
||||
- ./logs:/openim/openim-server/logs
|
||||
- ./config:/openim/openim-server/config
|
||||
- ./scripts:/openim/openim-server/scripts
|
||||
restart: always
|
||||
depends_on:
|
||||
- zookeeper
|
||||
@ -179,10 +179,6 @@ services:
|
||||
- prometheus
|
||||
network_mode: "host"
|
||||
|
||||
volumes:
|
||||
openim-chat_logs:
|
||||
openim-chat_config:
|
||||
openim-chat_scripts:
|
||||
|
||||
# node-exporter:
|
||||
# image: quay.io/prometheus/node-exporter
|
||||
|
@ -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.
|
||||
declare -A TEMPLATES=(
|
||||
["${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/env.template"]="${OPENIM_OUTPUT_SUBPATH}/bin/.env"
|
||||
[""${OPENIM_ROOT}"/scripts/template/config-tmpl/config.yaml"]="${OPENIM_OUTPUT_SUBPATH}/bin/config.yaml"
|
||||
)
|
||||
```
|
||||
|
||||
|
@ -363,6 +363,7 @@ func (m *MessageApi) GetActiveGroup(c *gin.Context) {
|
||||
func (m *MessageApi) SearchMsg(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.SearchMessage, m.Client, c)
|
||||
}
|
||||
|
||||
func (m *MessageApi) GetServerTime(c *gin.Context) {
|
||||
a2r.Call(msg.MsgClient.GetServerTime, m.Client, c)
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
"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/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/controller"
|
||||
"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/prome"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||
@ -48,7 +48,7 @@ func StartTransfer(prometheusPort int) error {
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
rdb, err := cache.NewRedis()
|
||||
@ -62,9 +62,9 @@ func StartTransfer(prometheusPort int) error {
|
||||
if err := mongo.CreateMsgIndex(); err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
||||
openKeeper.WithFreq(time.Hour), openKeeper.WithRoundRobin(), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
|
||||
config.Config.Zookeeper.Password), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))
|
||||
client, err := openkeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
||||
openkeeper.WithFreq(time.Hour), openkeeper.WithRoundRobin(), openkeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
|
||||
config.Config.Zookeeper.Password), openkeeper.WithTimeout(10), openkeeper.WithLogger(log.NewZkLogger()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"github.com/Shopify/sarama"
|
||||
"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/Open-IM-Server/pkg/common/config"
|
||||
@ -52,7 +52,7 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(
|
||||
session sarama.ConsumerGroupSession,
|
||||
) {
|
||||
msg := cMsg.Value
|
||||
msgFromMQ := pbMsg.MsgDataToMongoByMQ{}
|
||||
msgFromMQ := pbmsg.MsgDataToMongoByMQ{}
|
||||
err := proto.Unmarshal(msg, &msgFromMQ)
|
||||
if err != nil {
|
||||
log.ZError(ctx, "unmarshall failed", err, "key", key, "len", len(msg))
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
|
||||
"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/utils"
|
||||
|
||||
@ -54,7 +54,7 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(
|
||||
) {
|
||||
msg := cMsg.Value
|
||||
var tag bool
|
||||
msgFromMQ := pbMsg.MsgDataToMQ{}
|
||||
msgFromMQ := pbmsg.MsgDataToMQ{}
|
||||
err := proto.Unmarshal(msg, &msgFromMQ)
|
||||
if err != nil {
|
||||
log.ZError(ctx, "msg_transfer Unmarshal msg err", err)
|
||||
|
@ -21,8 +21,8 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
pbChat "github.com/OpenIMSDK/protocol/msg"
|
||||
pbPush "github.com/OpenIMSDK/protocol/push"
|
||||
pbchat "github.com/OpenIMSDK/protocol/msg"
|
||||
pbpush "github.com/OpenIMSDK/protocol/push"
|
||||
"github.com/OpenIMSDK/tools/log"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
@ -47,12 +47,12 @@ func NewConsumerHandler(pusher *Pusher) *ConsumerHandler {
|
||||
}
|
||||
|
||||
func (c *ConsumerHandler) handleMs2PsChat(ctx context.Context, msg []byte) {
|
||||
msgFromMQ := pbChat.PushMsgDataToMQ{}
|
||||
msgFromMQ := pbchat.PushMsgDataToMQ{}
|
||||
if err := proto.Unmarshal(msg, &msgFromMQ); err != nil {
|
||||
log.ZError(ctx, "push Unmarshal msg err", err, "msg", string(msg))
|
||||
return
|
||||
}
|
||||
pbData := &pbPush.PushMsgReq{
|
||||
pbData := &pbpush.PushMsgReq{
|
||||
MsgData: msgFromMQ.MsgData,
|
||||
ConversationID: msgFromMQ.ConversationID,
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"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/log"
|
||||
|
||||
@ -60,7 +60,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
wg.Add(2)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
pbPush.RegisterPushMsgServiceServer(server, &pushServer{
|
||||
pbpush.RegisterPushMsgServiceServer(server, &pushServer{
|
||||
pusher: pusher,
|
||||
})
|
||||
}()
|
||||
@ -74,7 +74,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
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 {
|
||||
case constant.SuperGroupChatType:
|
||||
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())
|
||||
}
|
||||
}
|
||||
return &pbPush.PushMsgResp{}, nil
|
||||
return &pbpush.PushMsgResp{}, nil
|
||||
}
|
||||
|
||||
func (r *pushServer) DelUserPushToken(
|
||||
ctx context.Context,
|
||||
req *pbPush.DelUserPushTokenReq,
|
||||
) (resp *pbPush.DelUserPushTokenResp, err error) {
|
||||
req *pbpush.DelUserPushTokenReq,
|
||||
) (resp *pbpush.DelUserPushTokenResp, err error) {
|
||||
if err = r.pusher.database.DelFcmToken(ctx, req.UserID, int(req.PlatformID)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pbPush.DelUserPushTokenResp{}, nil
|
||||
return &pbpush.DelUserPushTokenResp{}, nil
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
|
||||
"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/msggateway"
|
||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||
@ -49,7 +49,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
return err
|
||||
}
|
||||
userRpcClient := rpcclient.NewUserRpcClient(client)
|
||||
pbAuth.RegisterAuthServer(server, &authServer{
|
||||
pbauth.RegisterAuthServer(server, &authServer{
|
||||
userRpcClient: &userRpcClient,
|
||||
RegisterCenter: client,
|
||||
authDatabase: controller.NewAuthDatabase(
|
||||
@ -61,8 +61,8 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *authServer) UserToken(ctx context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) {
|
||||
resp := pbAuth.UserTokenResp{}
|
||||
func (s *authServer) UserToken(ctx context.Context, req *pbauth.UserTokenReq) (*pbauth.UserTokenResp, error) {
|
||||
resp := pbauth.UserTokenResp{}
|
||||
if req.Secret != config.Config.Secret {
|
||||
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(
|
||||
ctx context.Context,
|
||||
req *pbAuth.ParseTokenReq,
|
||||
) (resp *pbAuth.ParseTokenResp, err error) {
|
||||
resp = &pbAuth.ParseTokenResp{}
|
||||
req *pbauth.ParseTokenReq,
|
||||
) (resp *pbauth.ParseTokenResp, err error) {
|
||||
resp = &pbauth.ParseTokenResp{}
|
||||
claims, err := s.parseToken(ctx, req.Token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -118,14 +118,14 @@ func (s *authServer) ParseToken(
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.forceKickOff(ctx, req.UserID, req.PlatformID, mcontext.GetOperationID(ctx)); err != nil {
|
||||
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 {
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"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/errs"
|
||||
"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/controller"
|
||||
"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/notification"
|
||||
)
|
||||
@ -49,7 +49,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := db.AutoMigrate(&tableRelation.ConversationModel{}); err != nil {
|
||||
if err := db.AutoMigrate(&tablerelation.ConversationModel{}); err != nil {
|
||||
return err
|
||||
}
|
||||
rdb, err := cache.NewRedis()
|
||||
@ -59,7 +59,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
conversationDB := relation.NewConversationGorm(db)
|
||||
groupRpcClient := rpcclient.NewGroupRpcClient(client)
|
||||
msgRpcClient := rpcclient.NewMessageRpcClient(client)
|
||||
pbConversation.RegisterConversationServer(server, &conversationServer{
|
||||
pbconversation.RegisterConversationServer(server, &conversationServer{
|
||||
conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient),
|
||||
groupRpcClient: &groupRpcClient,
|
||||
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
|
||||
}
|
||||
|
||||
func (c *conversationServer) GetConversation(ctx context.Context, req *pbConversation.GetConversationReq) (*pbConversation.GetConversationResp, error) {
|
||||
func (c *conversationServer) GetConversation(ctx context.Context, req *pbconversation.GetConversationReq) (*pbconversation.GetConversationResp, error) {
|
||||
conversations, err := c.conversationDatabase.FindConversations(ctx, req.OwnerUserID, []string{req.ConversationID})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -75,46 +75,46 @@ func (c *conversationServer) GetConversation(ctx context.Context, req *pbConvers
|
||||
if len(conversations) < 1 {
|
||||
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])
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (c *conversationServer) GetAllConversations(ctx context.Context, req *pbConversation.GetAllConversationsReq) (*pbConversation.GetAllConversationsResp, error) {
|
||||
func (c *conversationServer) GetAllConversations(ctx context.Context, req *pbconversation.GetAllConversationsReq) (*pbconversation.GetAllConversationsResp, error) {
|
||||
conversations, err := c.conversationDatabase.GetUserAllConversation(ctx, req.OwnerUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp := &pbConversation.GetAllConversationsResp{Conversations: []*pbConversation.Conversation{}}
|
||||
resp := &pbconversation.GetAllConversationsResp{Conversations: []*pbconversation.Conversation{}}
|
||||
resp.Conversations = convert.ConversationsDB2Pb(conversations)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (c *conversationServer) GetConversations(ctx context.Context, req *pbConversation.GetConversationsReq) (*pbConversation.GetConversationsResp, error) {
|
||||
func (c *conversationServer) GetConversations(ctx context.Context, req *pbconversation.GetConversationsReq) (*pbconversation.GetConversationsResp, error) {
|
||||
conversations, err := c.conversationDatabase.FindConversations(ctx, req.OwnerUserID, req.ConversationIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp := &pbConversation.GetConversationsResp{Conversations: []*pbConversation.Conversation{}}
|
||||
resp := &pbconversation.GetConversationsResp{Conversations: []*pbconversation.Conversation{}}
|
||||
resp.Conversations = convert.ConversationsDB2Pb(conversations)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (c *conversationServer) SetConversation(ctx context.Context, req *pbConversation.SetConversationReq) (*pbConversation.SetConversationResp, error) {
|
||||
var conversation tableRelation.ConversationModel
|
||||
func (c *conversationServer) SetConversation(ctx context.Context, req *pbconversation.SetConversationReq) (*pbconversation.SetConversationResp, error) {
|
||||
var conversation tablerelation.ConversationModel
|
||||
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err := c.conversationDatabase.SetUserConversations(ctx, req.Conversation.OwnerUserID, []*tableRelation.ConversationModel{&conversation})
|
||||
err := c.conversationDatabase.SetUserConversations(ctx, req.Conversation.OwnerUserID, []*tablerelation.ConversationModel{&conversation})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_ = c.conversationNotificationSender.ConversationChangeNotification(ctx, req.Conversation.OwnerUserID, []string{req.Conversation.ConversationID})
|
||||
resp := &pbConversation.SetConversationResp{}
|
||||
resp := &pbconversation.SetConversationResp{}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (c *conversationServer) SetConversations(ctx context.Context, req *pbConversation.SetConversationsReq) (*pbConversation.SetConversationsResp, error) {
|
||||
func (c *conversationServer) SetConversations(ctx context.Context, req *pbconversation.SetConversationsReq) (*pbconversation.SetConversationsResp, error) {
|
||||
if req.Conversation == nil {
|
||||
return nil, errs.ErrArgs.Wrap("conversation must not be nil")
|
||||
}
|
||||
@ -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.ConversationType = req.Conversation.ConversationType
|
||||
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
|
||||
}
|
||||
if req.Conversation.IsPrivateChat != nil && req.Conversation.ConversationType != constant.SuperGroupChatType {
|
||||
var conversations []*tableRelation.ConversationModel
|
||||
var conversations []*tablerelation.ConversationModel
|
||||
for _, ownerUserID := range req.UserIDs {
|
||||
conversation2 := conversation
|
||||
conversation2.OwnerUserID = ownerUserID
|
||||
@ -185,26 +185,26 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbConver
|
||||
for _, v := range req.UserIDs {
|
||||
c.conversationNotificationSender.ConversationChangeNotification(ctx, v, []string{req.Conversation.ConversationID})
|
||||
}
|
||||
return &pbConversation.SetConversationsResp{}, nil
|
||||
return &pbconversation.SetConversationsResp{}, nil
|
||||
}
|
||||
|
||||
// 获取超级大群开启免打扰的用户ID.
|
||||
func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req *pbConversation.GetRecvMsgNotNotifyUserIDsReq) (*pbConversation.GetRecvMsgNotNotifyUserIDsResp, error) {
|
||||
func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req *pbconversation.GetRecvMsgNotNotifyUserIDsReq) (*pbconversation.GetRecvMsgNotNotifyUserIDsResp, error) {
|
||||
userIDs, err := c.conversationDatabase.FindRecvMsgNotNotifyUserIDs(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pbConversation.GetRecvMsgNotNotifyUserIDsResp{UserIDs: userIDs}, nil
|
||||
return &pbconversation.GetRecvMsgNotNotifyUserIDsResp{UserIDs: userIDs}, nil
|
||||
}
|
||||
|
||||
// create conversation without notification for msg redis transfer.
|
||||
func (c *conversationServer) CreateSingleChatConversations(ctx context.Context, req *pbConversation.CreateSingleChatConversationsReq) (*pbConversation.CreateSingleChatConversationsResp, error) {
|
||||
var conversation tableRelation.ConversationModel
|
||||
func (c *conversationServer) CreateSingleChatConversations(ctx context.Context, req *pbconversation.CreateSingleChatConversationsReq) (*pbconversation.CreateSingleChatConversationsResp, error) {
|
||||
var conversation tablerelation.ConversationModel
|
||||
conversation.ConversationID = msgprocessor.GetConversationIDBySessionType(constant.SingleChatType, req.RecvID, req.SendID)
|
||||
conversation.ConversationType = constant.SingleChatType
|
||||
conversation.OwnerUserID = req.SendID
|
||||
conversation.UserID = req.RecvID
|
||||
err := c.conversationDatabase.CreateConversation(ctx, []*tableRelation.ConversationModel{&conversation})
|
||||
err := c.conversationDatabase.CreateConversation(ctx, []*tablerelation.ConversationModel{&conversation})
|
||||
if err != nil {
|
||||
log.ZWarn(ctx, "create conversation failed", err, "conversation", conversation)
|
||||
}
|
||||
@ -212,52 +212,52 @@ func (c *conversationServer) CreateSingleChatConversations(ctx context.Context,
|
||||
conversation2 := conversation
|
||||
conversation2.OwnerUserID = req.RecvID
|
||||
conversation2.UserID = req.SendID
|
||||
err = c.conversationDatabase.CreateConversation(ctx, []*tableRelation.ConversationModel{&conversation2})
|
||||
err = c.conversationDatabase.CreateConversation(ctx, []*tablerelation.ConversationModel{&conversation2})
|
||||
if err != nil {
|
||||
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)
|
||||
if err != nil {
|
||||
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,
|
||||
map[string]interface{}{"max_seq": req.MaxSeq}); err != nil {
|
||||
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)
|
||||
if err != nil {
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pbConversation.GetUserConversationIDsHashResp{Hash: hash}, nil
|
||||
return &pbconversation.GetUserConversationIDsHashResp{Hash: hash}, nil
|
||||
}
|
||||
|
||||
func (c *conversationServer) GetConversationsByConversationID(
|
||||
ctx context.Context,
|
||||
req *pbConversation.GetConversationsByConversationIDReq,
|
||||
) (*pbConversation.GetConversationsByConversationIDResp, error) {
|
||||
req *pbconversation.GetConversationsByConversationIDReq,
|
||||
) (*pbconversation.GetConversationsByConversationIDResp, error) {
|
||||
conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, req.ConversationIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pbConversation.GetConversationsByConversationIDResp{Conversations: convert.ConversationsDB2Pb(conversations)}, nil
|
||||
return &pbconversation.GetConversationsByConversationIDResp{Conversations: convert.ConversationsDB2Pb(conversations)}, nil
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
|
||||
"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/Open-IM-Server/pkg/common/convert"
|
||||
@ -29,8 +29,8 @@ import (
|
||||
|
||||
func (s *friendServer) GetPaginationBlacks(
|
||||
ctx context.Context,
|
||||
req *pbFriend.GetPaginationBlacksReq,
|
||||
) (resp *pbFriend.GetPaginationBlacksResp, err error) {
|
||||
req *pbfriend.GetPaginationBlacksReq,
|
||||
) (resp *pbfriend.GetPaginationBlacksResp, err error) {
|
||||
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -43,7 +43,7 @@ func (s *friendServer) GetPaginationBlacks(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &pbFriend.GetPaginationBlacksResp{}
|
||||
resp = &pbfriend.GetPaginationBlacksResp{}
|
||||
resp.Blacks, err = convert.BlackDB2Pb(ctx, blacks, s.userRpcClient.GetUsersInfoMap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -52,12 +52,12 @@ func (s *friendServer) GetPaginationBlacks(
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp := &pbFriend.IsBlackResp{}
|
||||
resp := &pbfriend.IsBlackResp{}
|
||||
resp.InUser1Blacks = in1
|
||||
resp.InUser2Blacks = in2
|
||||
return resp, nil
|
||||
@ -65,8 +65,8 @@ func (s *friendServer) IsBlack(ctx context.Context, req *pbFriend.IsBlackReq) (*
|
||||
|
||||
func (s *friendServer) RemoveBlack(
|
||||
ctx context.Context,
|
||||
req *pbFriend.RemoveBlackReq,
|
||||
) (*pbFriend.RemoveBlackResp, error) {
|
||||
req *pbfriend.RemoveBlackReq,
|
||||
) (*pbfriend.RemoveBlackResp, error) {
|
||||
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -74,10 +74,10 @@ func (s *friendServer) RemoveBlack(
|
||||
return nil, err
|
||||
}
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
@ -95,5 +95,5 @@ func (s *friendServer) AddBlack(ctx context.Context, req *pbFriend.AddBlackReq)
|
||||
return nil, err
|
||||
}
|
||||
s.notificationSender.BlackAddedNotification(ctx, req)
|
||||
return &pbFriend.AddBlackResp{}, nil
|
||||
return &pbfriend.AddBlackResp{}, nil
|
||||
}
|
||||
|
@ -17,31 +17,31 @@ package group
|
||||
import (
|
||||
"context"
|
||||
|
||||
pbGroup "github.com/OpenIMSDK/protocol/group"
|
||||
pbgroup "github.com/OpenIMSDK/protocol/group"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
||||
)
|
||||
|
||||
func (s *groupServer) GetGroupInfoCache(
|
||||
ctx context.Context,
|
||||
req *pbGroup.GetGroupInfoCacheReq,
|
||||
) (resp *pbGroup.GetGroupInfoCacheResp, err error) {
|
||||
req *pbgroup.GetGroupInfoCacheReq,
|
||||
) (resp *pbgroup.GetGroupInfoCacheResp, err error) {
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &pbGroup.GetGroupInfoCacheResp{GroupInfo: convert.Db2PbGroupInfo(group, "", 0)}
|
||||
resp = &pbgroup.GetGroupInfoCacheResp{GroupInfo: convert.Db2PbGroupInfo(group, "", 0)}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupMemberCache(
|
||||
ctx context.Context,
|
||||
req *pbGroup.GetGroupMemberCacheReq,
|
||||
) (resp *pbGroup.GetGroupMemberCacheResp, err error) {
|
||||
req *pbgroup.GetGroupMemberCacheReq,
|
||||
) (resp *pbgroup.GetGroupMemberCacheResp, err error) {
|
||||
members, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.GroupMemberID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = &pbGroup.GetGroupMemberCacheResp{Member: convert.Db2PbGroupMember(members)}
|
||||
resp = &pbgroup.GetGroupMemberCacheResp{Member: convert.Db2PbGroupMember(members)}
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
|
||||
"github.com/OpenIMSDK/tools/mcontext"
|
||||
|
||||
pbGroup "github.com/OpenIMSDK/protocol/group"
|
||||
pbgroup "github.com/OpenIMSDK/protocol/group"
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
)
|
||||
|
||||
@ -64,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)
|
||||
if req.Nickname != nil {
|
||||
m["nickname"] = req.Nickname.Value
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
|
||||
"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(
|
||||
@ -27,7 +27,7 @@ func (s *groupServer) FindGroupMember(
|
||||
groupIDs []string,
|
||||
userIDs []string,
|
||||
roleLevels []int32,
|
||||
) ([]*relationTb.GroupMemberModel, error) {
|
||||
) ([]*relationtb.GroupMemberModel, error) {
|
||||
members, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, userIDs, roleLevels)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -63,7 +63,7 @@ func (s *groupServer) TakeGroupMember(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userID string,
|
||||
) (*relationTb.GroupMemberModel, error) {
|
||||
) (*relationtb.GroupMemberModel, error) {
|
||||
member, err := s.GroupDatabase.TakeGroupMember(ctx, groupID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -83,7 +83,7 @@ func (s *groupServer) TakeGroupMember(
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -107,7 +107,7 @@ func (s *groupServer) PageGetGroupMember(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
pageNumber, showNumber int32,
|
||||
) (uint32, []*relationTb.GroupMemberModel, error) {
|
||||
) (uint32, []*relationtb.GroupMemberModel, error) {
|
||||
total, members, err := s.GroupDatabase.PageGetGroupMember(ctx, groupID, pageNumber, showNumber)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
|
@ -29,7 +29,7 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
||||
"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/Open-IM-Server/pkg/rpcclient/notification"
|
||||
@ -42,7 +42,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"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/tools/discoveryregistry"
|
||||
"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/controller"
|
||||
"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"
|
||||
)
|
||||
|
||||
@ -62,7 +62,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
mongo, err := unrelation.NewMongo()
|
||||
@ -89,8 +89,8 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
})
|
||||
gs.conversationRpcClient = conversationRpcClient
|
||||
gs.msgRpcClient = msgRpcClient
|
||||
pbGroup.RegisterGroupServer(server, &gs)
|
||||
//pbGroup.RegisterGroupServer(server, &groupServer{
|
||||
pbgroup.RegisterGroupServer(server, &gs)
|
||||
//pbgroup.RegisterGroupServer(server, &groupServer{
|
||||
// GroupDatabase: database,
|
||||
// User: userRpcClient,
|
||||
// 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")
|
||||
}
|
||||
|
||||
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 == "" {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
var groupMembers []*relationTb.GroupMemberModel
|
||||
var groupMembers []*relationtb.GroupMemberModel
|
||||
group := convert.Pb2DBGroupInfo(req.GroupInfo)
|
||||
if err := s.GenGroupID(ctx, &group.GroupID); err != nil {
|
||||
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
|
||||
}
|
||||
resp := &pbGroup.CreateGroupResp{GroupInfo: &sdkws.GroupInfo{}}
|
||||
resp := &pbgroup.CreateGroupResp{GroupInfo: &sdkws.GroupInfo{}}
|
||||
resp.GroupInfo = convert.Db2PbGroupInfo(group, req.OwnerUserID, uint32(len(userIDs)))
|
||||
resp.GroupInfo.MemberCount = uint32(len(userIDs))
|
||||
if req.GroupInfo.GroupType == constant.SuperGroup {
|
||||
@ -273,8 +273,8 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJoinedGroupListReq) (*pbGroup.GetJoinedGroupListResp, error) {
|
||||
resp := &pbGroup.GetJoinedGroupListResp{}
|
||||
func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbgroup.GetJoinedGroupListReq) (*pbgroup.GetJoinedGroupListResp, error) {
|
||||
resp := &pbgroup.GetJoinedGroupListResp{}
|
||||
if err := authverify.CheckAccessV3(ctx, req.FromUserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -292,7 +292,7 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
||||
if len(members) == 0 {
|
||||
return resp, nil
|
||||
}
|
||||
groupIDs := utils.Slice(members, func(e *relationTb.GroupMemberModel) string {
|
||||
groupIDs := utils.Slice(members, func(e *relationtb.GroupMemberModel) string {
|
||||
return e.GroupID
|
||||
})
|
||||
groups, err := s.GroupDatabase.FindGroup(ctx, groupIDs)
|
||||
@ -307,12 +307,12 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string {
|
||||
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
||||
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
|
||||
}), func(group *relationTb.GroupModel) *sdkws.GroupInfo {
|
||||
}), func(group *relationtb.GroupModel) *sdkws.GroupInfo {
|
||||
var userID string
|
||||
if user := ownerMap[group.GroupID]; user != nil {
|
||||
userID = user.UserID
|
||||
@ -322,8 +322,8 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.InviteUserToGroupReq) (*pbGroup.InviteUserToGroupResp, error) {
|
||||
resp := &pbGroup.InviteUserToGroupResp{}
|
||||
func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.InviteUserToGroupReq) (*pbgroup.InviteUserToGroupResp, error) {
|
||||
resp := &pbgroup.InviteUserToGroupResp{}
|
||||
if len(req.InvitedUserIDs) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("user empty")
|
||||
}
|
||||
@ -341,7 +341,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var groupMember *relationTb.GroupMemberModel
|
||||
var groupMember *relationtb.GroupMemberModel
|
||||
var opUserID string
|
||||
if !authverify.IsAppManagerUid(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 !authverify.IsAppManagerUid(ctx) {
|
||||
if !(groupMember.RoleLevel == constant.GroupOwner || groupMember.RoleLevel == constant.GroupAdmin) {
|
||||
var requests []*relationTb.GroupRequestModel
|
||||
var requests []*relationtb.GroupRequestModel
|
||||
for _, userID := range req.InvitedUserIDs {
|
||||
requests = append(requests, &relationTb.GroupRequestModel{
|
||||
requests = append(requests, &relationtb.GroupRequestModel{
|
||||
UserID: userID,
|
||||
GroupID: req.GroupID,
|
||||
JoinSource: constant.JoinByInvitation,
|
||||
@ -372,7 +372,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
return nil, err
|
||||
}
|
||||
for _, request := range requests {
|
||||
s.Notification.JoinGroupApplicationNotification(ctx, &pbGroup.JoinGroupReq{
|
||||
s.Notification.JoinGroupApplicationNotification(ctx, &pbgroup.JoinGroupReq{
|
||||
GroupID: request.GroupID,
|
||||
ReqMessage: request.ReqMsg,
|
||||
JoinSource: request.JoinSource,
|
||||
@ -396,7 +396,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
}
|
||||
} else {
|
||||
opUserID := mcontext.GetOpUserID(ctx)
|
||||
var groupMembers []*relationTb.GroupMemberModel
|
||||
var groupMembers []*relationtb.GroupMemberModel
|
||||
for _, userID := range req.InvitedUserIDs {
|
||||
member := convert.Pb2DbGroupMember(userMap[userID])
|
||||
member.Nickname = ""
|
||||
@ -423,8 +423,8 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGroupAllMemberReq) (*pbGroup.GetGroupAllMemberResp, error) {
|
||||
resp := &pbGroup.GetGroupAllMemberResp{}
|
||||
func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbgroup.GetGroupAllMemberReq) (*pbgroup.GetGroupAllMemberResp, error) {
|
||||
resp := &pbgroup.GetGroupAllMemberResp{}
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -436,13 +436,13 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
|
||||
if err != nil {
|
||||
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 == ""
|
||||
}), true)
|
||||
if err != nil {
|
||||
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 == "" {
|
||||
e.Nickname = nameMap[e.UserID]
|
||||
}
|
||||
@ -451,8 +451,8 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGroupMemberListReq) (*pbGroup.GetGroupMemberListResp, error) {
|
||||
resp := &pbGroup.GetGroupMemberListResp{}
|
||||
func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbgroup.GetGroupMemberListReq) (*pbgroup.GetGroupMemberListResp, error) {
|
||||
resp := &pbgroup.GetGroupMemberListResp{}
|
||||
total, members, err := s.PageGetGroupMember(ctx, req.GroupID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
log.ZDebug(ctx, "GetGroupMemberList", "total", total, "members", members, "length", len(members))
|
||||
if err != nil {
|
||||
@ -464,8 +464,8 @@ func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGr
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGroupMemberReq) (*pbGroup.KickGroupMemberResp, error) {
|
||||
resp := &pbGroup.KickGroupMemberResp{}
|
||||
func (s *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGroupMemberReq) (*pbgroup.KickGroupMemberResp, error) {
|
||||
resp := &pbgroup.KickGroupMemberResp{}
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -494,7 +494,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
memberMap := make(map[string]*relationTb.GroupMemberModel)
|
||||
memberMap := make(map[string]*relationtb.GroupMemberModel)
|
||||
for i, member := range members {
|
||||
memberMap[member.UserID] = members[i]
|
||||
}
|
||||
@ -572,8 +572,8 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetGroupMembersInfoReq) (*pbGroup.GetGroupMembersInfoResp, error) {
|
||||
resp := &pbGroup.GetGroupMembersInfoResp{}
|
||||
func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbgroup.GetGroupMembersInfoReq) (*pbgroup.GetGroupMembersInfoResp, error) {
|
||||
resp := &pbgroup.GetGroupMembersInfoResp{}
|
||||
if len(req.UserIDs) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("userIDs empty")
|
||||
}
|
||||
@ -584,13 +584,13 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
|
||||
if err != nil {
|
||||
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 == ""
|
||||
}), true)
|
||||
if err != nil {
|
||||
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 == "" {
|
||||
e.Nickname = nameMap[e.UserID]
|
||||
}
|
||||
@ -599,12 +599,12 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.GetGroupApplicationListReq) (*pbGroup.GetGroupApplicationListResp, error) {
|
||||
func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbgroup.GetGroupApplicationListReq) (*pbgroup.GetGroupApplicationListResp, error) {
|
||||
groupIDs, err := s.GroupDatabase.FindUserManagedGroupID(ctx, req.FromUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp := &pbGroup.GetGroupApplicationListResp{}
|
||||
resp := &pbgroup.GetGroupApplicationListResp{}
|
||||
if len(groupIDs) == 0 {
|
||||
return resp, nil
|
||||
}
|
||||
@ -630,7 +630,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupMap := utils.SliceToMap(groups, func(e *relationTb.GroupModel) string {
|
||||
groupMap := utils.SliceToMap(groups, func(e *relationtb.GroupModel) string {
|
||||
return e.GroupID
|
||||
})
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string {
|
||||
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
||||
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 resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsInfoReq) (*pbGroup.GetGroupsInfoResp, error) {
|
||||
resp := &pbGroup.GetGroupsInfoResp{}
|
||||
func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbgroup.GetGroupsInfoReq) (*pbgroup.GetGroupsInfoResp, error) {
|
||||
resp := &pbgroup.GetGroupsInfoResp{}
|
||||
if len(req.GroupIDs) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("groupID is empty")
|
||||
}
|
||||
@ -670,10 +670,10 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string {
|
||||
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
||||
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
|
||||
if owner, ok := ownerMap[e.GroupID]; ok {
|
||||
ownerUserID = owner.UserID
|
||||
@ -683,7 +683,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (*pbGroup.GroupApplicationResponseResp, error) {
|
||||
func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup.GroupApplicationResponseReq) (*pbgroup.GroupApplicationResponseResp, error) {
|
||||
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
||||
if !utils.Contain(req.HandleResult, constant.GroupResponseAgree, constant.GroupResponseRefuse) {
|
||||
return nil, errs.ErrArgs.Wrap("HandleResult unknown")
|
||||
@ -717,9 +717,9 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
||||
if _, err := s.User.GetPublicUserInfo(ctx, req.FromUserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var member *relationTb.GroupMemberModel
|
||||
var member *relationtb.GroupMemberModel
|
||||
if (!inGroup) && req.HandleResult == constant.GroupResponseAgree {
|
||||
member = &relationTb.GroupMemberModel{
|
||||
member = &relationtb.GroupMemberModel{
|
||||
GroupID: req.GroupID,
|
||||
UserID: req.FromUserID,
|
||||
Nickname: "",
|
||||
@ -754,10 +754,10 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
||||
case constant.GroupResponseRefuse:
|
||||
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")
|
||||
user, err := s.User.GetUserInfo(ctx, req.InviterUserID)
|
||||
if err != nil {
|
||||
@ -777,7 +777,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
return nil, err
|
||||
}
|
||||
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.GroupType == constant.SuperGroup {
|
||||
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 {
|
||||
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
|
||||
}
|
||||
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)
|
||||
return resp, nil
|
||||
}
|
||||
groupRequest := relationTb.GroupRequestModel{
|
||||
groupRequest := relationtb.GroupRequestModel{
|
||||
UserID: req.InviterUserID,
|
||||
ReqMsg: req.ReqMessage,
|
||||
GroupID: req.GroupID,
|
||||
@ -810,15 +810,15 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
ReqTime: time.Now(),
|
||||
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
|
||||
}
|
||||
s.Notification.JoinGroupApplicationNotification(ctx, req)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) (*pbGroup.QuitGroupResp, error) {
|
||||
resp := &pbGroup.QuitGroupResp{}
|
||||
func (s *groupServer) QuitGroup(ctx context.Context, req *pbgroup.QuitGroupReq) (*pbgroup.QuitGroupResp, error) {
|
||||
resp := &pbgroup.QuitGroupResp{}
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -857,8 +857,8 @@ func (s *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, gro
|
||||
return s.conversationRpcClient.SetConversationMaxSeq(ctx, userIDs, conevrsationID, maxSeq)
|
||||
}
|
||||
|
||||
func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInfoReq) (*pbGroup.SetGroupInfoResp, error) {
|
||||
var opMember *relationTb.GroupMemberModel
|
||||
func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbgroup.SetGroupInfoReq) (*pbgroup.SetGroupInfoResp, error) {
|
||||
var opMember *relationtb.GroupMemberModel
|
||||
if !authverify.IsAppManagerUid(ctx) {
|
||||
var err error
|
||||
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 {
|
||||
return nil, utils.Wrap(errs.ErrDismissedAlready, "")
|
||||
}
|
||||
resp := &pbGroup.SetGroupInfoResp{}
|
||||
resp := &pbgroup.SetGroupInfoResp{}
|
||||
count, err := s.GroupDatabase.FindGroupMemberNum(ctx, group.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -908,12 +908,12 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
if req.GroupInfoForSet.Notification != "" {
|
||||
go func() {
|
||||
nctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(ctx))
|
||||
conversation := &pbConversation.ConversationReq{
|
||||
conversation := &pbconversation.ConversationReq{
|
||||
ConversationID: msgprocessor.GetConversationIDBySessionType(constant.SuperGroupChatType, req.GroupInfoForSet.GroupID),
|
||||
ConversationType: constant.SuperGroupChatType,
|
||||
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 {
|
||||
log.ZWarn(ctx, "GetGroupMemberIDs", err)
|
||||
return
|
||||
@ -940,8 +940,8 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) (*pbGroup.TransferGroupOwnerResp, error) {
|
||||
resp := &pbGroup.TransferGroupOwnerResp{}
|
||||
func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbgroup.TransferGroupOwnerReq) (*pbgroup.TransferGroupOwnerResp, error) {
|
||||
resp := &pbgroup.TransferGroupOwnerResp{}
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -956,7 +956,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans
|
||||
if err != nil {
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq) (*pbGroup.GetGroupsResp, error) {
|
||||
resp := &pbGroup.GetGroupsResp{}
|
||||
func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq) (*pbgroup.GetGroupsResp, error) {
|
||||
resp := &pbgroup.GetGroupsResp{}
|
||||
var (
|
||||
groups []*relationTb.GroupModel
|
||||
groups []*relationtb.GroupModel
|
||||
err error
|
||||
)
|
||||
if req.GroupID != "" {
|
||||
@ -995,14 +995,14 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupIDs := utils.Slice(groups, func(e *relationTb.GroupModel) string {
|
||||
groupIDs := utils.Slice(groups, func(e *relationtb.GroupModel) string {
|
||||
return e.GroupID
|
||||
})
|
||||
ownerMembers, err := s.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ownerMemberMap := utils.SliceToMap(ownerMembers, func(e *relationTb.GroupMemberModel) string {
|
||||
ownerMemberMap := utils.SliceToMap(ownerMembers, func(e *relationtb.GroupMemberModel) string {
|
||||
return e.GroupID
|
||||
})
|
||||
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 {
|
||||
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]
|
||||
return convert.Db2PbCMSGroup(group, member.UserID, member.Nickname, uint32(groupMemberNumMap[group.GroupID]))
|
||||
})
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) {
|
||||
resp := &pbGroup.GetGroupMembersCMSResp{}
|
||||
func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbgroup.GetGroupMembersCMSReq) (*pbgroup.GetGroupMembersCMSResp, error) {
|
||||
resp := &pbgroup.GetGroupMembersCMSResp{}
|
||||
total, members, err := s.GroupDatabase.SearchGroupMember(ctx, req.UserName, []string{req.GroupID}, nil, nil, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
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 == ""
|
||||
}), true)
|
||||
if err != nil {
|
||||
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 == "" {
|
||||
e.Nickname = nameMap[e.UserID]
|
||||
}
|
||||
@ -1041,8 +1041,8 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGr
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGroup.GetUserReqApplicationListReq) (*pbGroup.GetUserReqApplicationListResp, error) {
|
||||
resp := &pbGroup.GetUserReqApplicationListResp{}
|
||||
func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbgroup.GetUserReqApplicationListReq) (*pbgroup.GetUserReqApplicationListResp, error) {
|
||||
resp := &pbgroup.GetUserReqApplicationListResp{}
|
||||
user, err := s.User.GetPublicUserInfo(ctx, req.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1060,14 +1060,14 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
|
||||
if len(requests) == 0 {
|
||||
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
|
||||
}))
|
||||
groups, err := s.GroupDatabase.FindNotDismissedGroup(ctx, groupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupMap := utils.SliceToMap(groups, func(e *relationTb.GroupModel) string {
|
||||
groupMap := utils.SliceToMap(groups, func(e *relationtb.GroupModel) string {
|
||||
return e.GroupID
|
||||
})
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string {
|
||||
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
||||
return e.GroupID
|
||||
})
|
||||
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 {
|
||||
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 resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGroupReq) (*pbGroup.DismissGroupResp, error) {
|
||||
func (s *groupServer) DismissGroup(ctx context.Context, req *pbgroup.DismissGroupReq) (*pbgroup.DismissGroupResp, error) {
|
||||
defer log.ZInfo(ctx, "DismissGroup.return")
|
||||
resp := &pbGroup.DismissGroupResp{}
|
||||
resp := &pbgroup.DismissGroupResp{}
|
||||
owner, err := s.TakeGroupOwner(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1142,8 +1142,8 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGroupMemberReq) (*pbGroup.MuteGroupMemberResp, error) {
|
||||
resp := &pbGroup.MuteGroupMemberResp{}
|
||||
func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbgroup.MuteGroupMemberReq) (*pbgroup.MuteGroupMemberResp, error) {
|
||||
resp := &pbgroup.MuteGroupMemberResp{}
|
||||
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
@ -1177,8 +1177,8 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.CancelMuteGroupMemberReq) (*pbGroup.CancelMuteGroupMemberResp, error) {
|
||||
resp := &pbGroup.CancelMuteGroupMemberResp{}
|
||||
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbgroup.CancelMuteGroupMemberReq) (*pbgroup.CancelMuteGroupMemberResp, error) {
|
||||
resp := &pbgroup.CancelMuteGroupMemberResp{}
|
||||
//member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
@ -1225,8 +1225,8 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) (*pbGroup.MuteGroupResp, error) {
|
||||
resp := &pbGroup.MuteGroupResp{}
|
||||
func (s *groupServer) MuteGroup(ctx context.Context, req *pbgroup.MuteGroupReq) (*pbgroup.MuteGroupResp, error) {
|
||||
resp := &pbgroup.MuteGroupResp{}
|
||||
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1237,8 +1237,8 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMuteGroupReq) (*pbGroup.CancelMuteGroupResp, error) {
|
||||
resp := &pbGroup.CancelMuteGroupResp{}
|
||||
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbgroup.CancelMuteGroupReq) (*pbgroup.CancelMuteGroupResp, error) {
|
||||
resp := &pbgroup.CancelMuteGroupResp{}
|
||||
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1249,8 +1249,8 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (*pbGroup.SetGroupMemberInfoResp, error) {
|
||||
resp := &pbGroup.SetGroupMemberInfoResp{}
|
||||
func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbgroup.SetGroupMemberInfoReq) (*pbgroup.SetGroupMemberInfoResp, error) {
|
||||
resp := &pbgroup.SetGroupMemberInfoResp{}
|
||||
if len(req.Members) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("members empty")
|
||||
}
|
||||
@ -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])
|
||||
}), ","))
|
||||
}
|
||||
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}
|
||||
})
|
||||
if !authverify.IsAppManagerUid(ctx) {
|
||||
@ -1349,8 +1349,8 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if err = s.GroupDatabase.UpdateGroupMembers(ctx, utils.Slice(req.Members, func(e *pbGroup.SetGroupMemberInfo) *relationTb.BatchUpdateGroupMember {
|
||||
return &relationTb.BatchUpdateGroupMember{
|
||||
if err = s.GroupDatabase.UpdateGroupMembers(ctx, utils.Slice(req.Members, func(e *pbgroup.SetGroupMemberInfo) *relationtb.BatchUpdateGroupMember {
|
||||
return &relationtb.BatchUpdateGroupMember{
|
||||
GroupID: e.GroupID,
|
||||
UserID: e.UserID,
|
||||
Map: UpdateGroupMemberMap(e),
|
||||
@ -1377,8 +1377,8 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.GetGroupAbstractInfoReq) (*pbGroup.GetGroupAbstractInfoResp, error) {
|
||||
resp := &pbGroup.GetGroupAbstractInfoResp{}
|
||||
func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbgroup.GetGroupAbstractInfoReq) (*pbgroup.GetGroupAbstractInfoResp, error) {
|
||||
resp := &pbgroup.GetGroupAbstractInfoResp{}
|
||||
if len(req.GroupIDs) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
||||
}
|
||||
@ -1389,7 +1389,7 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.Get
|
||||
if err != nil {
|
||||
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
|
||||
})); len(ids) > 0 {
|
||||
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 {
|
||||
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]
|
||||
return convert.Db2PbGroupAbstractInfo(group.GroupID, users.MemberNum, users.Hash)
|
||||
})
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.GetUserInGroupMembersReq) (*pbGroup.GetUserInGroupMembersResp, error) {
|
||||
resp := &pbGroup.GetUserInGroupMembersResp{}
|
||||
func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbgroup.GetUserInGroupMembersReq) (*pbgroup.GetUserInGroupMembersResp, error) {
|
||||
resp := &pbgroup.GetUserInGroupMembersResp{}
|
||||
if len(req.GroupIDs) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
||||
}
|
||||
@ -1417,13 +1417,13 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.Ge
|
||||
if err != nil {
|
||||
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 == ""
|
||||
}), true)
|
||||
if err != nil {
|
||||
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 == "" {
|
||||
e.Nickname = nameMap[e.UserID]
|
||||
}
|
||||
@ -1432,8 +1432,8 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.Ge
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupMemberUserIDs(ctx context.Context, req *pbGroup.GetGroupMemberUserIDsReq) (resp *pbGroup.GetGroupMemberUserIDsResp, err error) {
|
||||
resp = &pbGroup.GetGroupMemberUserIDsResp{}
|
||||
func (s *groupServer) GetGroupMemberUserIDs(ctx context.Context, req *pbgroup.GetGroupMemberUserIDsReq) (resp *pbgroup.GetGroupMemberUserIDsResp, err error) {
|
||||
resp = &pbgroup.GetGroupMemberUserIDsResp{}
|
||||
resp.UserIDs, err = s.GroupDatabase.FindGroupMemberUserID(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1441,8 +1441,8 @@ func (s *groupServer) GetGroupMemberUserIDs(ctx context.Context, req *pbGroup.Ge
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbGroup.GetGroupMemberRoleLevelReq) (*pbGroup.GetGroupMemberRoleLevelResp, error) {
|
||||
resp := &pbGroup.GetGroupMemberRoleLevelResp{}
|
||||
func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbgroup.GetGroupMemberRoleLevelReq) (*pbgroup.GetGroupMemberRoleLevelResp, error) {
|
||||
resp := &pbgroup.GetGroupMemberRoleLevelResp{}
|
||||
if len(req.RoleLevels) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("RoleLevels empty")
|
||||
}
|
||||
@ -1450,13 +1450,13 @@ func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbGroup.
|
||||
if err != nil {
|
||||
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 == ""
|
||||
}), true)
|
||||
if err != nil {
|
||||
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 == "" {
|
||||
e.Nickname = nameMap[e.UserID]
|
||||
}
|
||||
@ -1465,8 +1465,8 @@ func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbGroup.
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *pbGroup.GetGroupUsersReqApplicationListReq) (*pbGroup.GetGroupUsersReqApplicationListResp, error) {
|
||||
resp := &pbGroup.GetGroupUsersReqApplicationListResp{}
|
||||
func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *pbgroup.GetGroupUsersReqApplicationListReq) (*pbgroup.GetGroupUsersReqApplicationListResp, error) {
|
||||
resp := &pbgroup.GetGroupUsersReqApplicationListResp{}
|
||||
total, requests, err := s.GroupDatabase.FindGroupRequests(ctx, req.GroupID, req.UserIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1474,14 +1474,14 @@ func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *
|
||||
if len(requests) == 0 {
|
||||
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
|
||||
}))
|
||||
groups, err := s.GroupDatabase.FindGroup(ctx, groupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupMap := utils.SliceToMap(groups, func(e *relationTb.GroupModel) string {
|
||||
groupMap := utils.SliceToMap(groups, func(e *relationtb.GroupModel) string {
|
||||
return e.GroupID
|
||||
})
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string {
|
||||
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
|
||||
return e.GroupID
|
||||
})
|
||||
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 {
|
||||
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])))
|
||||
})
|
||||
resp.Total = total
|
||||
@ -1515,7 +1515,7 @@ func (s *groupServer) groupMemberHashCode(ctx context.Context, groupID string) (
|
||||
}
|
||||
var members []*sdkws.GroupMemberFullInfo
|
||||
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 {
|
||||
return 0, err
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
pbGroup "github.com/OpenIMSDK/protocol/group"
|
||||
pbgroup "github.com/OpenIMSDK/protocol/group"
|
||||
sdkws "github.com/OpenIMSDK/protocol/sdkws"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
@ -32,9 +32,9 @@ import (
|
||||
|
||||
func (s *groupServer) GetJoinedSuperGroupList(
|
||||
ctx context.Context,
|
||||
req *pbGroup.GetJoinedSuperGroupListReq,
|
||||
) (*pbGroup.GetJoinedSuperGroupListResp, error) {
|
||||
resp := &pbGroup.GetJoinedSuperGroupListResp{}
|
||||
req *pbgroup.GetJoinedSuperGroupListReq,
|
||||
) (*pbgroup.GetJoinedSuperGroupListResp, error) {
|
||||
resp := &pbgroup.GetJoinedSuperGroupListResp{}
|
||||
groupIDs, err := s.GroupDatabase.FindJoinSuperGroup(ctx, req.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -80,9 +80,9 @@ func (s *groupServer) GetJoinedSuperGroupList(
|
||||
|
||||
func (s *groupServer) GetSuperGroupsInfo(
|
||||
ctx context.Context,
|
||||
req *pbGroup.GetSuperGroupsInfoReq,
|
||||
) (resp *pbGroup.GetSuperGroupsInfoResp, err error) {
|
||||
resp = &pbGroup.GetSuperGroupsInfoResp{}
|
||||
req *pbgroup.GetSuperGroupsInfoReq,
|
||||
) (resp *pbgroup.GetSuperGroupsInfoResp, err error) {
|
||||
resp = &pbgroup.GetSuperGroupsInfoResp{}
|
||||
if len(req.GroupIDs) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"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/log"
|
||||
"github.com/OpenIMSDK/tools/mcontext"
|
||||
@ -36,7 +36,7 @@ func cbURL() string {
|
||||
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{
|
||||
SendID: msg.MsgData.SendID,
|
||||
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 {
|
||||
return nil
|
||||
}
|
||||
@ -87,7 +87,7 @@ func callbackBeforeSendSingleMsg(ctx context.Context, msg *pbChat.SendMsgReq) er
|
||||
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 {
|
||||
return nil
|
||||
}
|
||||
@ -105,7 +105,7 @@ func callbackAfterSendSingleMsg(ctx context.Context, msg *pbChat.SendMsgReq) err
|
||||
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 {
|
||||
return nil
|
||||
}
|
||||
@ -123,7 +123,7 @@ func callbackBeforeSendGroupMsg(ctx context.Context, msg *pbChat.SendMsgReq) err
|
||||
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 {
|
||||
return nil
|
||||
}
|
||||
@ -141,7 +141,7 @@ func callbackAfterSendGroupMsg(ctx context.Context, msg *pbChat.SendMsgReq) erro
|
||||
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 {
|
||||
return nil
|
||||
}
|
||||
|
@ -18,15 +18,15 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
||||
"github.com/OpenIMSDK/tools/mcontext"
|
||||
)
|
||||
|
||||
func (m *msgServer) SetSendMsgStatus(
|
||||
ctx context.Context,
|
||||
req *pbMsg.SetSendMsgStatusReq,
|
||||
) (*pbMsg.SetSendMsgStatusResp, error) {
|
||||
resp := &pbMsg.SetSendMsgStatusResp{}
|
||||
req *pbmsg.SetSendMsgStatusReq,
|
||||
) (*pbmsg.SetSendMsgStatusResp, error) {
|
||||
resp := &pbmsg.SetSendMsgStatusResp{}
|
||||
if err := m.MsgDatabase.SetSendMsgStatus(ctx, mcontext.GetOperationID(ctx), req.Status); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -35,9 +35,9 @@ func (m *msgServer) SetSendMsgStatus(
|
||||
|
||||
func (m *msgServer) GetSendMsgStatus(
|
||||
ctx context.Context,
|
||||
req *pbMsg.GetSendMsgStatusReq,
|
||||
) (*pbMsg.GetSendMsgStatusResp, error) {
|
||||
resp := &pbMsg.GetSendMsgStatusResp{}
|
||||
req *pbmsg.GetSendMsgStatusReq,
|
||||
) (*pbmsg.GetSendMsgStatusResp, error) {
|
||||
resp := &pbmsg.GetSendMsgStatusResp{}
|
||||
status, err := m.MsgDatabase.GetSendMsgStatus(ctx, mcontext.GetOperationID(ctx))
|
||||
if IsNotFound(err) {
|
||||
resp.Status = constant.MsgStatusNotExist
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
"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) {
|
||||
@ -100,7 +100,7 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
|
||||
}
|
||||
}
|
||||
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,
|
||||
UserID: req.UserID,
|
||||
Nickname: user.Nickname,
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
pbConversation "github.com/OpenIMSDK/protocol/conversation"
|
||||
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||
pbconversation "github.com/OpenIMSDK/protocol/conversation"
|
||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
"github.com/OpenIMSDK/protocol/wrapperspb"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
@ -29,11 +29,11 @@ import (
|
||||
"github.com/OpenIMSDK/tools/mcontext"
|
||||
"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) {
|
||||
resp = &pbMsg.SendMsgResp{}
|
||||
func (m *msgServer) SendMsg(ctx context.Context, req *pbmsg.SendMsgReq) (resp *pbmsg.SendMsgResp, error error) {
|
||||
resp = &pbmsg.SendMsgResp{}
|
||||
if req.MsgData != nil {
|
||||
flag := isMessageHasReadEnabled(req.MsgData)
|
||||
if !flag {
|
||||
@ -57,11 +57,11 @@ func (m *msgServer) SendMsg(ctx context.Context, req *pbMsg.SendMsgReq) (resp *p
|
||||
|
||||
func (m *msgServer) sendMsgSuperGroupChat(
|
||||
ctx context.Context,
|
||||
req *pbMsg.SendMsgReq,
|
||||
) (resp *pbMsg.SendMsgResp, err error) {
|
||||
promePkg.Inc(promePkg.WorkSuperGroupChatMsgRecvSuccessCounter)
|
||||
req *pbmsg.SendMsgReq,
|
||||
) (resp *pbmsg.SendMsgResp, err error) {
|
||||
promepkg.Inc(promepkg.WorkSuperGroupChatMsgRecvSuccessCounter)
|
||||
if err = m.messageVerification(ctx, req); err != nil {
|
||||
promePkg.Inc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter)
|
||||
promepkg.Inc(promepkg.WorkSuperGroupChatMsgProcessFailedCounter)
|
||||
return nil, err
|
||||
}
|
||||
if err = callbackBeforeSendGroupMsg(ctx, req); err != nil {
|
||||
@ -80,8 +80,8 @@ func (m *msgServer) sendMsgSuperGroupChat(
|
||||
if err = callbackAfterSendGroupMsg(ctx, req); err != nil {
|
||||
log.ZWarn(ctx, "CallbackAfterSendGroupMsg", err)
|
||||
}
|
||||
promePkg.Inc(promePkg.WorkSuperGroupChatMsgProcessSuccessCounter)
|
||||
resp = &pbMsg.SendMsgResp{}
|
||||
promepkg.Inc(promepkg.WorkSuperGroupChatMsgProcessSuccessCounter)
|
||||
resp = &pbmsg.SendMsgResp{}
|
||||
resp.SendTime = req.MsgData.SendTime
|
||||
resp.ServerMsgID = req.MsgData.ServerMsgID
|
||||
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)
|
||||
ctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(nctx))
|
||||
var atUserID []string
|
||||
conversation := &pbConversation.ConversationReq{
|
||||
conversation := &pbconversation.ConversationReq{
|
||||
ConversationID: msgprocessor.GetConversationIDByMsg(msg),
|
||||
ConversationType: msg.SessionType,
|
||||
GroupID: msg.GroupID,
|
||||
@ -131,14 +131,14 @@ func (m *msgServer) setConversationAtInfo(nctx context.Context, msg *sdkws.MsgDa
|
||||
|
||||
func (m *msgServer) sendMsgNotification(
|
||||
ctx context.Context,
|
||||
req *pbMsg.SendMsgReq,
|
||||
) (resp *pbMsg.SendMsgResp, err error) {
|
||||
promePkg.Inc(promePkg.SingleChatMsgRecvSuccessCounter)
|
||||
req *pbmsg.SendMsgReq,
|
||||
) (resp *pbmsg.SendMsgResp, err error) {
|
||||
promepkg.Inc(promepkg.SingleChatMsgRecvSuccessCounter)
|
||||
if err := m.MsgDatabase.MsgToMQ(ctx, utils.GenConversationUniqueKeyForSingle(req.MsgData.SendID, req.MsgData.RecvID), req.MsgData); err != nil {
|
||||
promePkg.Inc(promePkg.SingleChatMsgProcessFailedCounter)
|
||||
promepkg.Inc(promepkg.SingleChatMsgProcessFailedCounter)
|
||||
return nil, err
|
||||
}
|
||||
resp = &pbMsg.SendMsgResp{
|
||||
resp = &pbmsg.SendMsgResp{
|
||||
ServerMsgID: req.MsgData.ServerMsgID,
|
||||
ClientMsgID: req.MsgData.ClientMsgID,
|
||||
SendTime: req.MsgData.SendTime,
|
||||
@ -146,8 +146,8 @@ func (m *msgServer) sendMsgNotification(
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, err error) {
|
||||
promePkg.Inc(promePkg.SingleChatMsgRecvSuccessCounter)
|
||||
func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq) (resp *pbmsg.SendMsgResp, err error) {
|
||||
promepkg.Inc(promepkg.SingleChatMsgRecvSuccessCounter)
|
||||
if err := m.messageVerification(ctx, req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -166,7 +166,7 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbMsg.SendMsgReq
|
||||
}
|
||||
}
|
||||
if !isSend {
|
||||
promePkg.Inc(promePkg.SingleChatMsgProcessFailedCounter)
|
||||
promepkg.Inc(promepkg.SingleChatMsgProcessFailedCounter)
|
||||
return nil, nil
|
||||
} else {
|
||||
if err = callbackBeforeSendSingleMsg(ctx, req); err != nil {
|
||||
@ -176,23 +176,23 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbMsg.SendMsgReq
|
||||
return nil, err
|
||||
}
|
||||
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
|
||||
}
|
||||
err = callbackAfterSendSingleMsg(ctx, req)
|
||||
if err != nil {
|
||||
log.ZWarn(ctx, "CallbackAfterSendSingleMsg", err, "req", req)
|
||||
}
|
||||
resp = &pbMsg.SendMsgResp{
|
||||
resp = &pbmsg.SendMsgResp{
|
||||
ServerMsgID: req.MsgData.ServerMsgID,
|
||||
ClientMsgID: req.MsgData.ClientMsgID,
|
||||
SendTime: req.MsgData.SendTime,
|
||||
}
|
||||
promePkg.Inc(promePkg.SingleChatMsgProcessSuccessCounter)
|
||||
promepkg.Inc(promepkg.SingleChatMsgProcessSuccessCounter)
|
||||
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
|
||||
}
|
||||
|
@ -17,16 +17,16 @@ package msg
|
||||
import (
|
||||
"context"
|
||||
|
||||
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
||||
)
|
||||
|
||||
func (m *msgServer) GetConversationMaxSeq(
|
||||
ctx context.Context,
|
||||
req *pbMsg.GetConversationMaxSeqReq,
|
||||
) (resp *pbMsg.GetConversationMaxSeqResp, err error) {
|
||||
req *pbmsg.GetConversationMaxSeqReq,
|
||||
) (resp *pbmsg.GetConversationMaxSeqResp, err error) {
|
||||
maxSeq, err := m.MsgDatabase.GetMaxSeq(ctx, req.ConversationID)
|
||||
if err != nil {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
var pbGroups []*msg.ActiveGroup
|
||||
var pbgroups []*msg.ActiveGroup
|
||||
if len(groups) > 0 {
|
||||
groupIDs := utils.Slice(groups, func(e *unrelation.GroupCount) string { return e.GroupID })
|
||||
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 {
|
||||
groupMap[group.GroupID] = resp[i]
|
||||
}
|
||||
pbGroups = make([]*msg.ActiveGroup, 0, len(groups))
|
||||
pbgroups = make([]*msg.ActiveGroup, 0, len(groups))
|
||||
for _, group := range groups {
|
||||
pbGroup := groupMap[group.GroupID]
|
||||
if pbGroup == nil {
|
||||
pbGroup = &sdkws.GroupInfo{
|
||||
pbgroup := groupMap[group.GroupID]
|
||||
if pbgroup == nil {
|
||||
pbgroup = &sdkws.GroupInfo{
|
||||
GroupID: group.GroupID,
|
||||
GroupName: group.GroupID,
|
||||
}
|
||||
}
|
||||
pbGroups = append(pbGroups, &msg.ActiveGroup{
|
||||
Group: pbGroup,
|
||||
pbgroups = append(pbgroups, &msg.ActiveGroup{
|
||||
Group: pbgroup,
|
||||
Count: group.Count,
|
||||
})
|
||||
}
|
||||
@ -110,6 +110,6 @@ func (m *msgServer) GetActiveGroup(ctx context.Context, req *msg.GetActiveGroupR
|
||||
MsgCount: msgCount,
|
||||
GroupCount: groupCount,
|
||||
DateCount: dateCount,
|
||||
Groups: pbGroups,
|
||||
Groups: pbgroups,
|
||||
}, nil
|
||||
}
|
||||
|
@ -164,30 +164,31 @@ func (m *msgServer) SearchMessage(ctx context.Context, req *msg.SearchMessageReq
|
||||
}
|
||||
}
|
||||
for _, chatLog := range chatLogs {
|
||||
pbChatLog := &msg.ChatLog{}
|
||||
utils.CopyStructFields(pbChatLog, chatLog)
|
||||
pbChatLog.SendTime = chatLog.SendTime
|
||||
pbChatLog.CreateTime = chatLog.CreateTime
|
||||
pbchatLog := &msg.ChatLog{}
|
||||
utils.CopyStructFields(pbchatLog, chatLog)
|
||||
pbchatLog.SendTime = chatLog.SendTime
|
||||
pbchatLog.CreateTime = chatLog.CreateTime
|
||||
if chatLog.SenderNickname == "" {
|
||||
pbChatLog.SenderNickname = sendMap[chatLog.SendID]
|
||||
pbchatLog.SenderNickname = sendMap[chatLog.SendID]
|
||||
}
|
||||
switch chatLog.SessionType {
|
||||
case constant.SingleChatType:
|
||||
pbChatLog.RecvNickname = recvMap[chatLog.RecvID]
|
||||
pbchatLog.RecvNickname = recvMap[chatLog.RecvID]
|
||||
|
||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||
pbChatLog.SenderFaceURL = groupMap[chatLog.GroupID].FaceURL
|
||||
pbChatLog.GroupMemberCount = groupMap[chatLog.GroupID].MemberCount
|
||||
pbChatLog.RecvID = groupMap[chatLog.GroupID].GroupID
|
||||
pbChatLog.GroupName = groupMap[chatLog.GroupID].GroupName
|
||||
pbChatLog.GroupOwner = groupMap[chatLog.GroupID].OwnerUserID
|
||||
pbChatLog.GroupType = groupMap[chatLog.GroupID].GroupType
|
||||
pbchatLog.SenderFaceURL = groupMap[chatLog.GroupID].FaceURL
|
||||
pbchatLog.GroupMemberCount = groupMap[chatLog.GroupID].MemberCount
|
||||
pbchatLog.RecvID = groupMap[chatLog.GroupID].GroupID
|
||||
pbchatLog.GroupName = groupMap[chatLog.GroupID].GroupName
|
||||
pbchatLog.GroupOwner = groupMap[chatLog.GroupID].OwnerUserID
|
||||
pbchatLog.GroupType = groupMap[chatLog.GroupID].GroupType
|
||||
}
|
||||
resp.ChatLogs = append(resp.ChatLogs, pbChatLog)
|
||||
resp.ChatLogs = append(resp.ChatLogs, pbchatLog)
|
||||
}
|
||||
resp.ChatLogsNum = total
|
||||
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/controller"
|
||||
"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"
|
||||
)
|
||||
|
||||
@ -58,7 +58,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := db.AutoMigrate(&relationTb.ObjectModel{}); err != nil {
|
||||
if err := db.AutoMigrate(&relationtb.ObjectModel{}); err != nil {
|
||||
return err
|
||||
}
|
||||
// 根据配置文件策略选择 oss 方式
|
||||
|
@ -17,7 +17,7 @@ package convert
|
||||
import (
|
||||
"time"
|
||||
|
||||
pbGroup "github.com/OpenIMSDK/protocol/group"
|
||||
pbgroup "github.com/OpenIMSDK/protocol/group"
|
||||
sdkws "github.com/OpenIMSDK/protocol/sdkws"
|
||||
|
||||
"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{
|
||||
UserID: req.FromUserID,
|
||||
GroupID: req.GroupID,
|
||||
@ -61,8 +61,8 @@ func Db2PbCMSGroup(
|
||||
ownerUserID string,
|
||||
ownerUserName string,
|
||||
memberCount uint32,
|
||||
) *pbGroup.CMSGroup {
|
||||
return &pbGroup.CMSGroup{
|
||||
) *pbgroup.CMSGroup {
|
||||
return &pbgroup.CMSGroup{
|
||||
GroupInfo: Db2PbGroupInfo(m, ownerUserID, memberCount),
|
||||
GroupOwnerUserID: ownerUserID,
|
||||
GroupOwnerUserName: ownerUserName,
|
||||
@ -110,8 +110,8 @@ func Db2PbGroupAbstractInfo(
|
||||
groupID string,
|
||||
groupMemberNumber uint32,
|
||||
groupMemberListHash uint64,
|
||||
) *pbGroup.GroupAbstractInfo {
|
||||
return &pbGroup.GroupAbstractInfo{
|
||||
) *pbgroup.GroupAbstractInfo {
|
||||
return &pbgroup.GroupAbstractInfo{
|
||||
GroupID: groupID,
|
||||
GroupMemberNumber: groupMemberNumber,
|
||||
GroupMemberListHash: groupMemberListHash,
|
||||
|
@ -19,10 +19,10 @@ import (
|
||||
|
||||
"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 {
|
||||
var userPb sdkws.UserInfo
|
||||
userPb.UserID = user.UserID
|
||||
@ -37,8 +37,8 @@ func UsersDB2Pb(users []*relationTb.UserModel) (result []*sdkws.UserInfo) {
|
||||
return result
|
||||
}
|
||||
|
||||
func UserPb2DB(user *sdkws.UserInfo) *relationTb.UserModel {
|
||||
var userDB relationTb.UserModel
|
||||
func UserPb2DB(user *sdkws.UserInfo) *relationtb.UserModel {
|
||||
var userDB relationtb.UserModel
|
||||
userDB.UserID = user.UserID
|
||||
userDB.Nickname = user.Nickname
|
||||
userDB.FaceURL = user.FaceURL
|
||||
|
6
pkg/common/db/cache/black.go
vendored
6
pkg/common/db/cache/black.go
vendored
@ -21,7 +21,7 @@ import (
|
||||
"github.com/dtm-labs/rockscache"
|
||||
"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 (
|
||||
@ -43,12 +43,12 @@ type BlackCacheRedis struct {
|
||||
metaCache
|
||||
expireTime time.Duration
|
||||
rcClient *rockscache.Client
|
||||
blackDB relationTb.BlackModelInterface
|
||||
blackDB relationtb.BlackModelInterface
|
||||
}
|
||||
|
||||
func NewBlackCacheRedis(
|
||||
rdb redis.UniversalClient,
|
||||
blackDB relationTb.BlackModelInterface,
|
||||
blackDB relationtb.BlackModelInterface,
|
||||
options rockscache.Options,
|
||||
) BlackCache {
|
||||
rcClient := rockscache.NewClient(rdb, options)
|
||||
|
30
pkg/common/db/cache/conversation.go
vendored
30
pkg/common/db/cache/conversation.go
vendored
@ -27,7 +27,7 @@ import (
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
"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 (
|
||||
@ -54,7 +54,7 @@ type ConversationCache interface {
|
||||
DelUserConversationIDsHash(ownerUserIDs ...string) ConversationCache
|
||||
|
||||
// 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
|
||||
DelUsersConversation(conversationID string, ownerUserIDs ...string) ConversationCache
|
||||
// get one conversation from msgCache
|
||||
@ -62,9 +62,9 @@ type ConversationCache interface {
|
||||
ctx context.Context,
|
||||
ownerUserID string,
|
||||
conversationIDs []string,
|
||||
) ([]*relationTb.ConversationModel, error)
|
||||
) ([]*relationtb.ConversationModel, error)
|
||||
// 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
|
||||
GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error)
|
||||
DelUserRecvMsgOpt(ownerUserID, conversationID string) ConversationCache
|
||||
@ -81,14 +81,14 @@ type ConversationCache interface {
|
||||
GetConversationsByConversationID(
|
||||
ctx context.Context,
|
||||
conversationIDs []string,
|
||||
) ([]*relationTb.ConversationModel, error)
|
||||
) ([]*relationtb.ConversationModel, error)
|
||||
DelConversationByConversationID(conversationIDs ...string) ConversationCache
|
||||
}
|
||||
|
||||
func NewConversationRedis(
|
||||
rdb redis.UniversalClient,
|
||||
opts rockscache.Options,
|
||||
db relationTb.ConversationModelInterface,
|
||||
db relationtb.ConversationModelInterface,
|
||||
) ConversationCache {
|
||||
rcClient := rockscache.NewClient(rdb, opts)
|
||||
return &ConversationRedisCache{
|
||||
@ -102,7 +102,7 @@ func NewConversationRedis(
|
||||
type ConversationRedisCache struct {
|
||||
metaCache
|
||||
rcClient *rockscache.Client
|
||||
conversationDB relationTb.ConversationModelInterface
|
||||
conversationDB relationtb.ConversationModelInterface
|
||||
expireTime time.Duration
|
||||
}
|
||||
|
||||
@ -214,13 +214,13 @@ func (c *ConversationRedisCache) DelUserConversationIDsHash(ownerUserIDs ...stri
|
||||
func (c *ConversationRedisCache) GetConversation(
|
||||
ctx context.Context,
|
||||
ownerUserID, conversationID string,
|
||||
) (*relationTb.ConversationModel, error) {
|
||||
) (*relationtb.ConversationModel, error) {
|
||||
return getCache(
|
||||
ctx,
|
||||
c.rcClient,
|
||||
c.getConversationKey(ownerUserID, conversationID),
|
||||
c.expireTime,
|
||||
func(ctx context.Context) (*relationTb.ConversationModel, error) {
|
||||
func(ctx context.Context) (*relationtb.ConversationModel, error) {
|
||||
return c.conversationDB.Take(ctx, ownerUserID, conversationID)
|
||||
},
|
||||
)
|
||||
@ -237,7 +237,7 @@ func (c *ConversationRedisCache) DelConversations(ownerUserID string, conversati
|
||||
}
|
||||
|
||||
func (c *ConversationRedisCache) getConversationIndex(
|
||||
convsation *relationTb.ConversationModel,
|
||||
convsation *relationtb.ConversationModel,
|
||||
keys []string,
|
||||
) (int, error) {
|
||||
key := c.getConversationKey(convsation.OwnerUserID, convsation.ConversationID)
|
||||
@ -253,7 +253,7 @@ func (c *ConversationRedisCache) GetConversations(
|
||||
ctx context.Context,
|
||||
ownerUserID string,
|
||||
conversationIDs []string,
|
||||
) ([]*relationTb.ConversationModel, error) {
|
||||
) ([]*relationtb.ConversationModel, error) {
|
||||
var keys []string
|
||||
for _, conversarionID := range conversationIDs {
|
||||
keys = append(keys, c.getConversationKey(ownerUserID, conversarionID))
|
||||
@ -264,7 +264,7 @@ func (c *ConversationRedisCache) GetConversations(
|
||||
keys,
|
||||
c.expireTime,
|
||||
c.getConversationIndex,
|
||||
func(ctx context.Context) ([]*relationTb.ConversationModel, error) {
|
||||
func(ctx context.Context) ([]*relationtb.ConversationModel, error) {
|
||||
return c.conversationDB.Find(ctx, ownerUserID, conversationIDs)
|
||||
},
|
||||
)
|
||||
@ -273,7 +273,7 @@ func (c *ConversationRedisCache) GetConversations(
|
||||
func (c *ConversationRedisCache) GetUserAllConversations(
|
||||
ctx context.Context,
|
||||
ownerUserID string,
|
||||
) ([]*relationTb.ConversationModel, error) {
|
||||
) ([]*relationtb.ConversationModel, error) {
|
||||
conversationIDs, err := c.GetUserConversationIDs(ctx, ownerUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -288,7 +288,7 @@ func (c *ConversationRedisCache) GetUserAllConversations(
|
||||
keys,
|
||||
c.expireTime,
|
||||
c.getConversationIndex,
|
||||
func(ctx context.Context) ([]*relationTb.ConversationModel, error) {
|
||||
func(ctx context.Context) ([]*relationtb.ConversationModel, error) {
|
||||
return c.conversationDB.FindUserIDAllConversations(ctx, ownerUserID)
|
||||
},
|
||||
)
|
||||
@ -425,7 +425,7 @@ func (c *ConversationRedisCache) DelUserAllHasReadSeqs(
|
||||
func (c *ConversationRedisCache) GetConversationsByConversationID(
|
||||
ctx context.Context,
|
||||
conversationIDs []string,
|
||||
) ([]*relationTb.ConversationModel, error) {
|
||||
) ([]*relationtb.ConversationModel, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
|
12
pkg/common/db/cache/friend.go
vendored
12
pkg/common/db/cache/friend.go
vendored
@ -23,7 +23,7 @@ import (
|
||||
|
||||
"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 (
|
||||
@ -41,21 +41,21 @@ type FriendCache interface {
|
||||
// call when friendID List changed
|
||||
DelFriendIDs(ownerUserID ...string) FriendCache
|
||||
// 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
|
||||
DelFriend(ownerUserID, friendUserID string) FriendCache
|
||||
}
|
||||
|
||||
type FriendCacheRedis struct {
|
||||
metaCache
|
||||
friendDB relationTb.FriendModelInterface
|
||||
friendDB relationtb.FriendModelInterface
|
||||
expireTime time.Duration
|
||||
rcClient *rockscache.Client
|
||||
}
|
||||
|
||||
func NewFriendCacheRedis(
|
||||
rdb redis.UniversalClient,
|
||||
friendDB relationTb.FriendModelInterface,
|
||||
friendDB relationtb.FriendModelInterface,
|
||||
options rockscache.Options,
|
||||
) FriendCache {
|
||||
rcClient := rockscache.NewClient(rdb, options)
|
||||
@ -140,13 +140,13 @@ func (f *FriendCacheRedis) DelTwoWayFriendIDs(ctx context.Context, ownerUserID s
|
||||
func (f *FriendCacheRedis) GetFriend(
|
||||
ctx context.Context,
|
||||
ownerUserID, friendUserID string,
|
||||
) (friend *relationTb.FriendModel, err error) {
|
||||
) (friend *relationtb.FriendModel, err error) {
|
||||
return getCache(
|
||||
ctx,
|
||||
f.rcClient,
|
||||
f.getFriendKey(ownerUserID, friendUserID),
|
||||
f.expireTime,
|
||||
func(ctx context.Context) (*relationTb.FriendModel, error) {
|
||||
func(ctx context.Context) (*relationtb.FriendModel, error) {
|
||||
return f.friendDB.Take(ctx, ownerUserID, friendUserID)
|
||||
},
|
||||
)
|
||||
|
80
pkg/common/db/cache/group.go
vendored
80
pkg/common/db/cache/group.go
vendored
@ -25,8 +25,8 @@ import (
|
||||
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
unrelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
unrelationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -44,17 +44,17 @@ const (
|
||||
type GroupCache interface {
|
||||
metaCache
|
||||
NewCache() GroupCache
|
||||
GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||
GetGroupInfo(ctx context.Context, groupID string) (group *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)
|
||||
DelGroupsInfo(groupIDs ...string) GroupCache
|
||||
|
||||
GetJoinedSuperGroupIDs(ctx context.Context, userID string) (joinedSuperGroupIDs []string, err error)
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error)
|
||||
@ -68,19 +68,19 @@ type GroupCache interface {
|
||||
GetGroupMemberInfo(
|
||||
ctx context.Context,
|
||||
groupID, userID string,
|
||||
) (groupMember *relationTb.GroupMemberModel, err error)
|
||||
) (groupMember *relationtb.GroupMemberModel, err error)
|
||||
GetGroupMembersInfo(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userID []string,
|
||||
) (groupMembers []*relationTb.GroupMemberModel, err error)
|
||||
GetAllGroupMembersInfo(ctx context.Context, groupID string) (groupMembers []*relationTb.GroupMemberModel, err error)
|
||||
) (groupMembers []*relationtb.GroupMemberModel, err error)
|
||||
GetAllGroupMembersInfo(ctx context.Context, groupID string) (groupMembers []*relationtb.GroupMemberModel, err error)
|
||||
GetGroupMembersPage(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userID []string,
|
||||
showNumber, pageNumber int32,
|
||||
) (total uint32, groupMembers []*relationTb.GroupMemberModel, err error)
|
||||
) (total uint32, groupMembers []*relationtb.GroupMemberModel, err error)
|
||||
|
||||
DelGroupMembersInfo(groupID string, userID ...string) GroupCache
|
||||
|
||||
@ -90,10 +90,10 @@ type GroupCache interface {
|
||||
|
||||
type GroupCacheRedis struct {
|
||||
metaCache
|
||||
groupDB relationTb.GroupModelInterface
|
||||
groupMemberDB relationTb.GroupMemberModelInterface
|
||||
groupRequestDB relationTb.GroupRequestModelInterface
|
||||
mongoDB unrelationTb.SuperGroupModelInterface
|
||||
groupDB relationtb.GroupModelInterface
|
||||
groupMemberDB relationtb.GroupMemberModelInterface
|
||||
groupRequestDB relationtb.GroupRequestModelInterface
|
||||
mongoDB unrelationtb.SuperGroupModelInterface
|
||||
expireTime time.Duration
|
||||
rcClient *rockscache.Client
|
||||
hashCode func(ctx context.Context, groupID string) (uint64, error)
|
||||
@ -101,10 +101,10 @@ type GroupCacheRedis struct {
|
||||
|
||||
func NewGroupCacheRedis(
|
||||
rdb redis.UniversalClient,
|
||||
groupDB relationTb.GroupModelInterface,
|
||||
groupMemberDB relationTb.GroupMemberModelInterface,
|
||||
groupRequestDB relationTb.GroupRequestModelInterface,
|
||||
mongoClient unrelationTb.SuperGroupModelInterface,
|
||||
groupDB relationtb.GroupModelInterface,
|
||||
groupMemberDB relationtb.GroupMemberModelInterface,
|
||||
groupRequestDB relationtb.GroupRequestModelInterface,
|
||||
mongoClient unrelationtb.SuperGroupModelInterface,
|
||||
hashCode func(ctx context.Context, groupID string) (uint64, error),
|
||||
opts rockscache.Options,
|
||||
) GroupCache {
|
||||
@ -162,7 +162,7 @@ func (g *GroupCacheRedis) getGroupMemberNumKey(groupID string) string {
|
||||
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)
|
||||
for i, _key := range keys {
|
||||
if _key == key {
|
||||
@ -172,7 +172,7 @@ func (g *GroupCacheRedis) GetGroupIndex(group *relationTb.GroupModel, keys []str
|
||||
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)
|
||||
for i, _key := range keys {
|
||||
if _key == key {
|
||||
@ -186,7 +186,7 @@ func (g *GroupCacheRedis) GetGroupMemberIndex(groupMember *relationTb.GroupMembe
|
||||
func (g *GroupCacheRedis) GetGroupsInfo(
|
||||
ctx context.Context,
|
||||
groupIDs []string,
|
||||
) (groups []*relationTb.GroupModel, err error) {
|
||||
) (groups []*relationtb.GroupModel, err error) {
|
||||
var keys []string
|
||||
for _, group := range groupIDs {
|
||||
keys = append(keys, g.getGroupInfoKey(group))
|
||||
@ -197,19 +197,19 @@ func (g *GroupCacheRedis) GetGroupsInfo(
|
||||
keys,
|
||||
g.expireTime,
|
||||
g.GetGroupIndex,
|
||||
func(ctx context.Context) ([]*relationTb.GroupModel, error) {
|
||||
func(ctx context.Context) ([]*relationtb.GroupModel, error) {
|
||||
return g.groupDB.Find(ctx, groupIDs)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func (g *GroupCacheRedis) GetGroupInfo(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
||||
func (g *GroupCacheRedis) GetGroupInfo(ctx context.Context, groupID string) (group *relationtb.GroupModel, err error) {
|
||||
return getCache(
|
||||
ctx,
|
||||
g.rcClient,
|
||||
g.getGroupInfoKey(groupID),
|
||||
g.expireTime,
|
||||
func(ctx context.Context) (*relationTb.GroupModel, error) {
|
||||
func(ctx context.Context) (*relationtb.GroupModel, error) {
|
||||
return g.groupDB.Take(ctx, groupID)
|
||||
},
|
||||
)
|
||||
@ -247,7 +247,7 @@ func (g *GroupCacheRedis) GetJoinedSuperGroupIDs(
|
||||
func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
|
||||
ctx context.Context,
|
||||
groupIDs ...string,
|
||||
) (models []*unrelationTb.SuperGroupModel, err error) {
|
||||
) (models []*unrelationtb.SuperGroupModel, err error) {
|
||||
var keys []string
|
||||
for _, group := range groupIDs {
|
||||
keys = append(keys, g.getSuperGroupMemberIDsKey(group))
|
||||
@ -257,7 +257,7 @@ func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
|
||||
g.rcClient,
|
||||
keys,
|
||||
g.expireTime,
|
||||
func(model *unrelationTb.SuperGroupModel, keys []string) (int, error) {
|
||||
func(model *unrelationtb.SuperGroupModel, keys []string) (int, error) {
|
||||
for i, key := range keys {
|
||||
if g.getSuperGroupMemberIDsKey(model.GroupID) == key {
|
||||
return i, nil
|
||||
@ -265,7 +265,7 @@ func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
|
||||
}
|
||||
return 0, errIndex
|
||||
},
|
||||
func(ctx context.Context) ([]*unrelationTb.SuperGroupModel, error) {
|
||||
func(ctx context.Context) ([]*unrelationtb.SuperGroupModel, error) {
|
||||
return g.mongoDB.FindSuperGroup(ctx, groupIDs)
|
||||
},
|
||||
)
|
||||
@ -305,7 +305,7 @@ func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID strin
|
||||
// return 0, err
|
||||
// }
|
||||
// log.ZInfo(ctx, "GetGroupMembersHash", "groupID", groupID, "userIDs", userIDs)
|
||||
// var members []*relationTb.GroupMemberModel
|
||||
// var members []*relationtb.GroupMemberModel
|
||||
// if len(userIDs) > 0 {
|
||||
// members, err = g.GetGroupMembersInfo(ctx, groupID, userIDs)
|
||||
// if err != nil {
|
||||
@ -313,7 +313,7 @@ func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID strin
|
||||
// }
|
||||
// utils.Sort(userIDs, true)
|
||||
// }
|
||||
// memberMap := make(map[string]*relationTb.GroupMemberModel)
|
||||
// memberMap := make(map[string]*relationtb.GroupMemberModel)
|
||||
// for i, member := range members {
|
||||
// memberMap[member.UserID] = members[i]
|
||||
// }
|
||||
@ -354,8 +354,8 @@ func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID strin
|
||||
func (g *GroupCacheRedis) GetGroupMemberHashMap(
|
||||
ctx context.Context,
|
||||
groupIDs []string,
|
||||
) (map[string]*relationTb.GroupSimpleUserID, error) {
|
||||
res := make(map[string]*relationTb.GroupSimpleUserID)
|
||||
) (map[string]*relationtb.GroupSimpleUserID, error) {
|
||||
res := make(map[string]*relationtb.GroupSimpleUserID)
|
||||
for _, groupID := range groupIDs {
|
||||
hash, err := g.GetGroupMembersHash(ctx, groupID)
|
||||
if err != nil {
|
||||
@ -366,7 +366,7 @@ func (g *GroupCacheRedis) GetGroupMemberHashMap(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res[groupID] = &relationTb.GroupSimpleUserID{Hash: hash, MemberNum: uint32(num)}
|
||||
res[groupID] = &relationtb.GroupSimpleUserID{Hash: hash, MemberNum: uint32(num)}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
@ -433,13 +433,13 @@ func (g *GroupCacheRedis) DelJoinedGroupID(userIDs ...string) GroupCache {
|
||||
func (g *GroupCacheRedis) GetGroupMemberInfo(
|
||||
ctx context.Context,
|
||||
groupID, userID string,
|
||||
) (groupMember *relationTb.GroupMemberModel, err error) {
|
||||
) (groupMember *relationtb.GroupMemberModel, err error) {
|
||||
return getCache(
|
||||
ctx,
|
||||
g.rcClient,
|
||||
g.getGroupMemberInfoKey(groupID, userID),
|
||||
g.expireTime,
|
||||
func(ctx context.Context) (*relationTb.GroupMemberModel, error) {
|
||||
func(ctx context.Context) (*relationtb.GroupMemberModel, error) {
|
||||
return g.groupMemberDB.Take(ctx, groupID, userID)
|
||||
},
|
||||
)
|
||||
@ -449,7 +449,7 @@ func (g *GroupCacheRedis) GetGroupMembersInfo(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userIDs []string,
|
||||
) ([]*relationTb.GroupMemberModel, error) {
|
||||
) ([]*relationtb.GroupMemberModel, error) {
|
||||
var keys []string
|
||||
for _, userID := range userIDs {
|
||||
keys = append(keys, g.getGroupMemberInfoKey(groupID, userID))
|
||||
@ -460,7 +460,7 @@ func (g *GroupCacheRedis) GetGroupMembersInfo(
|
||||
keys,
|
||||
g.expireTime,
|
||||
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)
|
||||
},
|
||||
)
|
||||
@ -471,7 +471,7 @@ func (g *GroupCacheRedis) GetGroupMembersPage(
|
||||
groupID string,
|
||||
userIDs []string,
|
||||
showNumber, pageNumber int32,
|
||||
) (total uint32, groupMembers []*relationTb.GroupMemberModel, err error) {
|
||||
) (total uint32, groupMembers []*relationtb.GroupMemberModel, err error) {
|
||||
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
@ -488,7 +488,7 @@ func (g *GroupCacheRedis) GetGroupMembersPage(
|
||||
func (g *GroupCacheRedis) GetAllGroupMembersInfo(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
) (groupMembers []*relationTb.GroupMemberModel, err error) {
|
||||
) (groupMembers []*relationtb.GroupMemberModel, err error) {
|
||||
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -499,7 +499,7 @@ func (g *GroupCacheRedis) GetAllGroupMembersInfo(
|
||||
func (g *GroupCacheRedis) GetAllGroupMemberInfo(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
) ([]*relationTb.GroupMemberModel, error) {
|
||||
) ([]*relationtb.GroupMemberModel, error) {
|
||||
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -514,7 +514,7 @@ func (g *GroupCacheRedis) GetAllGroupMemberInfo(
|
||||
keys,
|
||||
g.expireTime,
|
||||
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)
|
||||
},
|
||||
)
|
||||
|
4
pkg/common/db/cache/msg.go
vendored
4
pkg/common/db/cache/msg.go
vendored
@ -33,7 +33,7 @@ import (
|
||||
"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"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
@ -143,7 +143,7 @@ type msgCache struct {
|
||||
rdb redis.UniversalClient
|
||||
expireTime time.Duration
|
||||
rcClient *rockscache.Client
|
||||
msgDocDatabase unRelationTb.MsgDocModelInterface
|
||||
msgDocDatabase unrelationtb.MsgDocModelInterface
|
||||
}
|
||||
|
||||
func (c *msgCache) getMaxSeqKey(conversationID string) string {
|
||||
|
20
pkg/common/db/cache/user.go
vendored
20
pkg/common/db/cache/user.go
vendored
@ -29,7 +29,7 @@ import (
|
||||
"github.com/dtm-labs/rockscache"
|
||||
"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 (
|
||||
@ -45,8 +45,8 @@ const (
|
||||
type UserCache interface {
|
||||
metaCache
|
||||
NewCache() UserCache
|
||||
GetUserInfo(ctx context.Context, userID string) (userInfo *relationTb.UserModel, err error)
|
||||
GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationTb.UserModel, error)
|
||||
GetUserInfo(ctx context.Context, userID string) (userInfo *relationtb.UserModel, err error)
|
||||
GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationtb.UserModel, error)
|
||||
DelUsersInfo(userIDs ...string) UserCache
|
||||
GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error)
|
||||
DelUsersGlobalRecvMsgOpt(userIDs ...string) UserCache
|
||||
@ -57,14 +57,14 @@ type UserCache interface {
|
||||
type UserCacheRedis struct {
|
||||
metaCache
|
||||
rdb redis.UniversalClient
|
||||
userDB relationTb.UserModelInterface
|
||||
userDB relationtb.UserModelInterface
|
||||
expireTime time.Duration
|
||||
rcClient *rockscache.Client
|
||||
}
|
||||
|
||||
func NewUserCacheRedis(
|
||||
rdb redis.UniversalClient,
|
||||
userDB relationTb.UserModelInterface,
|
||||
userDB relationtb.UserModelInterface,
|
||||
options rockscache.Options,
|
||||
) UserCache {
|
||||
rcClient := rockscache.NewClient(rdb, options)
|
||||
@ -99,19 +99,19 @@ func (u *UserCacheRedis) getUserStatusHashKey(userID string, Id int32) string {
|
||||
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(
|
||||
ctx,
|
||||
u.rcClient,
|
||||
u.getUserInfoKey(userID),
|
||||
u.expireTime,
|
||||
func(ctx context.Context) (*relationTb.UserModel, error) {
|
||||
func(ctx context.Context) (*relationtb.UserModel, error) {
|
||||
return u.userDB.Take(ctx, userID)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationTb.UserModel, error) {
|
||||
func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationtb.UserModel, error) {
|
||||
var keys []string
|
||||
for _, userID := range userIDs {
|
||||
keys = append(keys, u.getUserInfoKey(userID))
|
||||
@ -121,7 +121,7 @@ func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]
|
||||
u.rcClient,
|
||||
keys,
|
||||
u.expireTime,
|
||||
func(user *relationTb.UserModel, keys []string) (int, error) {
|
||||
func(user *relationtb.UserModel, keys []string) (int, error) {
|
||||
for i, key := range keys {
|
||||
if key == u.getUserInfoKey(user.UserID) {
|
||||
return i, nil
|
||||
@ -129,7 +129,7 @@ func (u *UserCacheRedis) GetUsersInfo(ctx context.Context, userIDs []string) ([]
|
||||
}
|
||||
return 0, errIndex
|
||||
},
|
||||
func(ctx context.Context) ([]*relationTb.UserModel, error) {
|
||||
func(ctx context.Context) ([]*relationtb.UserModel, error) {
|
||||
return u.userDB.Find(ctx, userIDs)
|
||||
},
|
||||
)
|
||||
|
@ -15,23 +15,23 @@
|
||||
package controller
|
||||
|
||||
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 {
|
||||
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}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -26,36 +26,36 @@ import (
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
"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 {
|
||||
// UpdateUserConversationFiled 更新用户该会话的属性信息
|
||||
UpdateUsersConversationFiled(ctx context.Context, userIDs []string, conversationID string, args map[string]interface{}) error
|
||||
// CreateConversation 创建一批新的会话
|
||||
CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error
|
||||
CreateConversation(ctx context.Context, conversations []*relationtb.ConversationModel) error
|
||||
// SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
|
||||
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation []*relationTb.ConversationModel) error
|
||||
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation []*relationtb.ConversationModel) error
|
||||
// FindConversations 根据会话ID获取某个用户的多个会话
|
||||
FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error)
|
||||
FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationtb.ConversationModel, error)
|
||||
// FindRecvMsgNotNotifyUserIDs 获取超级大群开启免打扰的用户ID
|
||||
FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
|
||||
// GetUserAllConversation 获取一个用户在服务器上所有的会话
|
||||
GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error)
|
||||
GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationtb.ConversationModel, error)
|
||||
// SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
|
||||
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error
|
||||
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationtb.ConversationModel) error
|
||||
// SetUsersConversationFiledTx 设置多个用户会话关于某个字段的更新操作,如果会话不存在则创建,否则更新,内部保证事务操作
|
||||
SetUsersConversationFiledTx(ctx context.Context, userIDs []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error
|
||||
SetUsersConversationFiledTx(ctx context.Context, userIDs []string, conversation *relationtb.ConversationModel, filedMap map[string]interface{}) error
|
||||
CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error
|
||||
GetConversationIDs(ctx context.Context, userID string) ([]string, error)
|
||||
GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error)
|
||||
GetAllConversationIDs(ctx context.Context) ([]string, error)
|
||||
GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error)
|
||||
GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*relationTb.ConversationModel, error)
|
||||
GetConversationIDsNeedDestruct(ctx context.Context) ([]*relationTb.ConversationModel, error)
|
||||
GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*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{
|
||||
conversationDB: conversation,
|
||||
cache: cache,
|
||||
@ -64,12 +64,12 @@ func NewConversationDatabase(conversation relationTb.ConversationModelInterface,
|
||||
}
|
||||
|
||||
type conversationDatabase struct {
|
||||
conversationDB relationTb.ConversationModelInterface
|
||||
conversationDB relationtb.ConversationModelInterface
|
||||
cache cache.ConversationCache
|
||||
tx tx.Tx
|
||||
}
|
||||
|
||||
func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context, userIDs []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) (err error) {
|
||||
func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context, userIDs []string, conversation *relationtb.ConversationModel, filedMap map[string]interface{}) (err error) {
|
||||
cache := c.cache.NewCache()
|
||||
if err := c.tx.Transaction(func(tx any) error {
|
||||
conversationTx := c.conversationDB.NewTx(tx)
|
||||
@ -91,10 +91,10 @@ func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context,
|
||||
}
|
||||
NotUserIDs := utils.DifferenceString(haveUserIDs, userIDs)
|
||||
log.ZDebug(ctx, "SetUsersConversationFiledTx", "NotUserIDs", NotUserIDs, "haveUserIDs", haveUserIDs, "userIDs", userIDs)
|
||||
var conversations []*relationTb.ConversationModel
|
||||
var conversations []*relationtb.ConversationModel
|
||||
now := time.Now()
|
||||
for _, v := range NotUserIDs {
|
||||
temp := new(relationTb.ConversationModel)
|
||||
temp := new(relationtb.ConversationModel)
|
||||
if err := utils.CopyStructFields(temp, conversation); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -124,7 +124,7 @@ func (c *conversationDatabase) UpdateUsersConversationFiled(ctx context.Context,
|
||||
return c.cache.DelUsersConversation(conversationID, userIDs...).ExecDel(ctx)
|
||||
}
|
||||
|
||||
func (c *conversationDatabase) CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error {
|
||||
func (c *conversationDatabase) CreateConversation(ctx context.Context, conversations []*relationtb.ConversationModel) error {
|
||||
if err := c.conversationDB.Create(ctx, conversations); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -137,7 +137,7 @@ func (c *conversationDatabase) CreateConversation(ctx context.Context, conversat
|
||||
return cache.DelConversationIDs(userIDs...).DelUserConversationIDsHash(userIDs...).ExecDel(ctx)
|
||||
}
|
||||
|
||||
func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(ctx context.Context, conversations []*relationTb.ConversationModel) error {
|
||||
func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(ctx context.Context, conversations []*relationtb.ConversationModel) error {
|
||||
cache := c.cache.NewCache()
|
||||
if err := c.tx.Transaction(func(tx any) error {
|
||||
conversationTx := c.conversationDB.NewTx(tx)
|
||||
@ -161,7 +161,7 @@ func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(ctx context.Con
|
||||
newConversation.UserID = userID
|
||||
newConversation.ConversationID = conversation.ConversationID
|
||||
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
|
||||
}
|
||||
cache = cache.DelConversationIDs(ownerUserID).DelUserConversationIDsHash(ownerUserID)
|
||||
@ -175,19 +175,19 @@ func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(ctx context.Con
|
||||
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)
|
||||
}
|
||||
|
||||
func (c *conversationDatabase) GetConversation(ctx context.Context, ownerUserID string, conversationID string) (*relationTb.ConversationModel, error) {
|
||||
func (c *conversationDatabase) GetConversation(ctx context.Context, ownerUserID string, conversationID string) (*relationtb.ConversationModel, error) {
|
||||
return c.cache.GetConversation(ctx, ownerUserID, conversationID)
|
||||
}
|
||||
|
||||
func (c *conversationDatabase) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) {
|
||||
func (c *conversationDatabase) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationtb.ConversationModel, error) {
|
||||
return c.cache.GetUserAllConversations(ctx, ownerUserID)
|
||||
}
|
||||
|
||||
func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error {
|
||||
func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationtb.ConversationModel) error {
|
||||
cache := c.cache.NewCache()
|
||||
if err := c.tx.Transaction(func(tx any) error {
|
||||
var conversationIDs []string
|
||||
@ -213,7 +213,7 @@ func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUs
|
||||
existConversationIDs = append(existConversationIDs, conversation.ConversationID)
|
||||
}
|
||||
|
||||
var notExistConversations []*relationTb.ConversationModel
|
||||
var notExistConversations []*relationtb.ConversationModel
|
||||
for _, conversation := range conversations {
|
||||
if !utils.IsContain(conversation.ConversationID, existConversationIDs) {
|
||||
notExistConversations = append(notExistConversations, conversation)
|
||||
@ -246,9 +246,9 @@ func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context,
|
||||
return err
|
||||
}
|
||||
notExistUserIDs := utils.DifferenceString(userIDs, existConversationUserIDs)
|
||||
var conversations []*relationTb.ConversationModel
|
||||
var conversations []*relationtb.ConversationModel
|
||||
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)
|
||||
cache = cache.DelConversations(v, conversationID)
|
||||
}
|
||||
@ -289,10 +289,10 @@ func (c *conversationDatabase) GetUserAllHasReadSeqs(ctx context.Context, ownerU
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -30,22 +30,22 @@ import (
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/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"
|
||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
unrelationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
||||
)
|
||||
|
||||
type GroupDatabase interface {
|
||||
// Group
|
||||
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
||||
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||
FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||
CreateGroup(ctx context.Context, groups []*relationtb.GroupModel, groupMembers []*relationtb.GroupMemberModel) error
|
||||
TakeGroup(ctx context.Context, groupID string) (group *relationtb.GroupModel, err error)
|
||||
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
|
||||
FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
|
||||
SearchGroup(
|
||||
ctx context.Context,
|
||||
keyword string,
|
||||
pageNumber, showNumber int32,
|
||||
) (uint32, []*relationTb.GroupModel, error)
|
||||
) (uint32, []*relationtb.GroupModel, error)
|
||||
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
||||
DismissGroup(ctx context.Context, groupID string, deleteMember bool) error // 解散群,并删除群成员
|
||||
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
|
||||
@ -54,14 +54,14 @@ type GroupDatabase interface {
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userID string,
|
||||
) (groupMember *relationTb.GroupMemberModel, err error)
|
||||
TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error)
|
||||
) (groupMember *relationtb.GroupMemberModel, err error)
|
||||
TakeGroupOwner(ctx context.Context, groupID string) (*relationtb.GroupMemberModel, error)
|
||||
FindGroupMember(
|
||||
ctx context.Context,
|
||||
groupIDs []string,
|
||||
userIDs []string,
|
||||
roleLevels []int32,
|
||||
) ([]*relationTb.GroupMemberModel, error)
|
||||
) ([]*relationtb.GroupMemberModel, error)
|
||||
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
|
||||
FindGroupMemberNum(ctx context.Context, groupID string) (uint32, error)
|
||||
FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
|
||||
@ -69,19 +69,19 @@ type GroupDatabase interface {
|
||||
ctx context.Context,
|
||||
groupIDs []string,
|
||||
pageNumber, showNumber int32,
|
||||
) (uint32, []*relationTb.GroupRequestModel, error)
|
||||
) (uint32, []*relationtb.GroupRequestModel, error)
|
||||
// PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber,
|
||||
// showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
|
||||
// showNumber int32) (uint32, []*relationtb.GroupMemberModel, error)
|
||||
PageGetJoinGroup(
|
||||
ctx context.Context,
|
||||
userID string,
|
||||
pageNumber, showNumber int32,
|
||||
) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error)
|
||||
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
|
||||
PageGetGroupMember(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
pageNumber, showNumber int32,
|
||||
) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error)
|
||||
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
|
||||
SearchGroupMember(
|
||||
ctx context.Context,
|
||||
keyword string,
|
||||
@ -89,17 +89,17 @@ type GroupDatabase interface {
|
||||
userIDs []string,
|
||||
roleLevels []int32,
|
||||
pageNumber, showNumber int32,
|
||||
) (uint32, []*relationTb.GroupMemberModel, error)
|
||||
) (uint32, []*relationtb.GroupMemberModel, error)
|
||||
HandlerGroupRequest(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userID string,
|
||||
handledMsg string,
|
||||
handleResult int32,
|
||||
member *relationTb.GroupMemberModel,
|
||||
member *relationtb.GroupMemberModel,
|
||||
) 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)
|
||||
TransferGroupOwner(
|
||||
ctx context.Context,
|
||||
@ -108,18 +108,18 @@ type GroupDatabase interface {
|
||||
roleLevel int32,
|
||||
) 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
|
||||
CreateGroupRequest(ctx context.Context, requests []*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)
|
||||
CreateGroupRequest(ctx context.Context, requests []*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)
|
||||
PageGroupRequestUser(
|
||||
ctx context.Context,
|
||||
userID string,
|
||||
pageNumber, showNumber int32,
|
||||
) (uint32, []*relationTb.GroupRequestModel, error)
|
||||
) (uint32, []*relationtb.GroupRequestModel, error)
|
||||
// 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)
|
||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||
DeleteSuperGroup(ctx context.Context, groupID string) error
|
||||
@ -133,12 +133,12 @@ type GroupDatabase interface {
|
||||
}
|
||||
|
||||
func NewGroupDatabase(
|
||||
group relationTb.GroupModelInterface,
|
||||
member relationTb.GroupMemberModelInterface,
|
||||
request relationTb.GroupRequestModelInterface,
|
||||
group relationtb.GroupModelInterface,
|
||||
member relationtb.GroupMemberModelInterface,
|
||||
request relationtb.GroupRequestModelInterface,
|
||||
tx tx.Tx,
|
||||
ctxTx tx.CtxTx,
|
||||
superGroup unRelationTb.SuperGroupModelInterface,
|
||||
superGroup unrelationtb.SuperGroupModelInterface,
|
||||
cache cache.GroupCache,
|
||||
) GroupDatabase {
|
||||
database := &groupDatabase{
|
||||
@ -177,13 +177,13 @@ func InitGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, database *mongo.D
|
||||
}
|
||||
|
||||
type groupDatabase struct {
|
||||
groupDB relationTb.GroupModelInterface
|
||||
groupMemberDB relationTb.GroupMemberModelInterface
|
||||
groupRequestDB relationTb.GroupRequestModelInterface
|
||||
groupDB relationtb.GroupModelInterface
|
||||
groupMemberDB relationtb.GroupMemberModelInterface
|
||||
groupRequestDB relationtb.GroupRequestModelInterface
|
||||
tx tx.Tx
|
||||
ctxTx tx.CtxTx
|
||||
cache cache.GroupCache
|
||||
mongoDB unRelationTb.SuperGroupModelInterface
|
||||
mongoDB unrelationtb.SuperGroupModelInterface
|
||||
}
|
||||
|
||||
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(
|
||||
ctx context.Context,
|
||||
groups []*relationTb.GroupModel,
|
||||
groupMembers []*relationTb.GroupMemberModel,
|
||||
groups []*relationtb.GroupModel,
|
||||
groupMembers []*relationtb.GroupMemberModel,
|
||||
) error {
|
||||
cache := g.cache.NewCache()
|
||||
if err := g.tx.Transaction(func(tx any) error {
|
||||
@ -219,7 +219,7 @@ func (g *groupDatabase) CreateGroup(
|
||||
return err
|
||||
}
|
||||
}
|
||||
createGroupIDs := utils.DistinctAnyGetComparable(groups, func(group *relationTb.GroupModel) string {
|
||||
createGroupIDs := utils.DistinctAnyGetComparable(groups, func(group *relationtb.GroupModel) string {
|
||||
return group.GroupID
|
||||
})
|
||||
m := make(map[string]struct{})
|
||||
@ -239,11 +239,11 @@ func (g *groupDatabase) CreateGroup(
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ func (g *groupDatabase) SearchGroup(
|
||||
ctx context.Context,
|
||||
keyword string,
|
||||
pageNumber, showNumber int32,
|
||||
) (uint32, []*relationTb.GroupModel, error) {
|
||||
) (uint32, []*relationtb.GroupModel, error) {
|
||||
return g.groupDB.Search(ctx, keyword, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
@ -290,11 +290,11 @@ func (g *groupDatabase) TakeGroupMember(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userID string,
|
||||
) (groupMember *relationTb.GroupMemberModel, err error) {
|
||||
) (groupMember *relationtb.GroupMemberModel, err error) {
|
||||
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
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ func (g *groupDatabase) PageGroupRequest(
|
||||
ctx context.Context,
|
||||
groupIDs []string,
|
||||
pageNumber, showNumber int32,
|
||||
) (uint32, []*relationTb.GroupRequestModel, error) {
|
||||
) (uint32, []*relationtb.GroupRequestModel, error) {
|
||||
return g.groupRequestDB.PageGroup(ctx, groupIDs, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
@ -315,7 +315,7 @@ func (g *groupDatabase) FindGroupMember(
|
||||
groupIDs []string,
|
||||
userIDs []string,
|
||||
roleLevels []int32,
|
||||
) (totalGroupMembers []*relationTb.GroupMemberModel, err error) {
|
||||
) (totalGroupMembers []*relationtb.GroupMemberModel, err error) {
|
||||
if len(roleLevels) == 0 {
|
||||
for _, groupID := range groupIDs {
|
||||
groupMembers, err := g.cache.GetGroupMembersInfo(ctx, groupID, userIDs)
|
||||
@ -333,7 +333,7 @@ func (g *groupDatabase) PageGetJoinGroup(
|
||||
ctx context.Context,
|
||||
userID string,
|
||||
pageNumber, showNumber int32,
|
||||
) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error) {
|
||||
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error) {
|
||||
groupIDs, err := g.cache.GetJoinedGroupIDs(ctx, userID)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
@ -352,7 +352,7 @@ func (g *groupDatabase) PageGetGroupMember(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
pageNumber, showNumber int32,
|
||||
) (total uint32, totalGroupMembers []*relationTb.GroupMemberModel, err error) {
|
||||
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error) {
|
||||
groupMemberIDs, err := g.cache.GetGroupMemberIDs(ctx, groupID)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
@ -375,7 +375,7 @@ func (g *groupDatabase) SearchGroupMember(
|
||||
userIDs []string,
|
||||
roleLevels []int32,
|
||||
pageNumber, showNumber int32,
|
||||
) (uint32, []*relationTb.GroupMemberModel, error) {
|
||||
) (uint32, []*relationtb.GroupMemberModel, error) {
|
||||
return g.groupMemberDB.SearchMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ func (g *groupDatabase) HandlerGroupRequest(
|
||||
userID string,
|
||||
handledMsg string,
|
||||
handleResult int32,
|
||||
member *relationTb.GroupMemberModel,
|
||||
member *relationtb.GroupMemberModel,
|
||||
) error {
|
||||
//cache := g.cache.NewCache()
|
||||
//if err := g.tx.Transaction(func(tx any) error {
|
||||
@ -393,7 +393,7 @@ func (g *groupDatabase) HandlerGroupRequest(
|
||||
// return err
|
||||
// }
|
||||
// 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
|
||||
// }
|
||||
// cache = cache.DelGroupMembersHash(groupID).DelGroupMemberIDs(groupID).DelGroupsMemberNum(groupID).DelJoinedGroupID(member.UserID)
|
||||
@ -409,7 +409,7 @@ func (g *groupDatabase) HandlerGroupRequest(
|
||||
return err
|
||||
}
|
||||
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
|
||||
}
|
||||
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(
|
||||
ctx context.Context,
|
||||
groupIDs []string,
|
||||
) (map[string]*relationTb.GroupSimpleUserID, error) {
|
||||
) (map[string]*relationtb.GroupSimpleUserID, error) {
|
||||
return g.cache.GetGroupMemberHashMap(ctx, groupIDs)
|
||||
}
|
||||
|
||||
@ -491,7 +491,7 @@ func (g *groupDatabase) UpdateGroupMember(
|
||||
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()
|
||||
if err := g.tx.Transaction(func(tx any) error {
|
||||
for _, item := range data {
|
||||
@ -507,7 +507,7 @@ func (g *groupDatabase) UpdateGroupMembers(ctx context.Context, data []*relation
|
||||
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 {
|
||||
db := g.groupRequestDB.NewTx(tx)
|
||||
for _, request := range requests {
|
||||
@ -523,7 +523,7 @@ func (g *groupDatabase) TakeGroupRequest(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userID string,
|
||||
) (*relationTb.GroupRequestModel, error) {
|
||||
) (*relationtb.GroupRequestModel, error) {
|
||||
return g.groupRequestDB.Take(ctx, groupID, userID)
|
||||
}
|
||||
|
||||
@ -531,14 +531,14 @@ func (g *groupDatabase) PageGroupRequestUser(
|
||||
ctx context.Context,
|
||||
userID string,
|
||||
pageNumber, showNumber int32,
|
||||
) (uint32, []*relationTb.GroupRequestModel, error) {
|
||||
) (uint32, []*relationtb.GroupRequestModel, error) {
|
||||
return g.groupRequestDB.Page(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *groupDatabase) FindSuperGroup(
|
||||
ctx context.Context,
|
||||
groupIDs []string,
|
||||
) (models []*unRelationTb.SuperGroupModel, err error) {
|
||||
) (models []*unrelationtb.SuperGroupModel, err error) {
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -27,14 +27,14 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||
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/kafka"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
||||
|
||||
"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/tools/utils"
|
||||
)
|
||||
@ -48,7 +48,7 @@ type CommonMsgDatabase interface {
|
||||
// 批量插入消息
|
||||
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
|
||||
MarkSingleChatMsgsAsRead(ctx context.Context, userID string, conversationID string, seqs []int64) error
|
||||
// 刪除redis中消息缓存
|
||||
@ -93,7 +93,7 @@ type CommonMsgDatabase interface {
|
||||
GetConversationMinMaxSeqInMongoAndCache(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error)
|
||||
SetSendMsgStatus(ctx context.Context, id string, status int32) error
|
||||
GetSendMsgStatus(ctx context.Context, id string) (int32, error)
|
||||
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
|
||||
MsgToMQ(ctx context.Context, key string, msg2mq *sdkws.MsgData) error
|
||||
@ -109,7 +109,7 @@ type CommonMsgDatabase interface {
|
||||
ase bool,
|
||||
pageNumber 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(
|
||||
ctx context.Context,
|
||||
start time.Time,
|
||||
@ -117,11 +117,11 @@ type CommonMsgDatabase interface {
|
||||
ase bool,
|
||||
pageNumber 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)
|
||||
}
|
||||
|
||||
func NewCommonMsgDatabase(msgDocModel unRelationTb.MsgDocModelInterface, cacheModel cache.MsgModel) CommonMsgDatabase {
|
||||
func NewCommonMsgDatabase(msgDocModel unrelationtb.MsgDocModelInterface, cacheModel cache.MsgModel) CommonMsgDatabase {
|
||||
return &commonMsgDatabase{
|
||||
msgDocDatabase: msgDocModel,
|
||||
cache: cacheModel,
|
||||
@ -139,8 +139,8 @@ func InitCommonMsgDatabase(rdb redis.UniversalClient, database *mongo.Database)
|
||||
}
|
||||
|
||||
type commonMsgDatabase struct {
|
||||
msgDocDatabase unRelationTb.MsgDocModelInterface
|
||||
msg unRelationTb.MsgDocModel
|
||||
msgDocDatabase unrelationtb.MsgDocModelInterface
|
||||
msg unrelationtb.MsgDocModel
|
||||
cache cache.MsgModel
|
||||
producer *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 {
|
||||
if len(messages) > 0 {
|
||||
_, _, err := db.producerToModify.SendMessage(ctx, key, &pbMsg.MsgDataToModifyByMQ{ConversationID: conversationID, Messages: messages})
|
||||
_, _, err := db.producerToModify.SendMessage(ctx, key, &pbmsg.MsgDataToModifyByMQ{ConversationID: conversationID, Messages: messages})
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db *commonMsgDatabase) MsgToPushMQ(ctx context.Context, key, conversationID string, msg2mq *sdkws.MsgData) (int32, int64, error) {
|
||||
partition, offset, err := db.producerToPush.SendMessage(ctx, key, &pbMsg.PushMsgDataToMQ{MsgData: msg2mq, ConversationID: conversationID})
|
||||
partition, offset, err := db.producerToPush.SendMessage(ctx, key, &pbmsg.PushMsgDataToMQ{MsgData: msg2mq, ConversationID: conversationID})
|
||||
if err != nil {
|
||||
log.ZError(ctx, "MsgToPushMQ", err, "key", key, "msg2mq", msg2mq)
|
||||
return 0, 0, err
|
||||
@ -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 {
|
||||
if len(messages) > 0 {
|
||||
_, _, err := db.producerToMongo.SendMessage(ctx, key, &pbMsg.MsgDataToMongoByMQ{LastSeq: lastSeq, ConversationID: conversationID, MsgData: messages})
|
||||
_, _, err := db.producerToMongo.SendMessage(ctx, key, &pbmsg.MsgDataToMongoByMQ{LastSeq: lastSeq, ConversationID: conversationID, MsgData: messages})
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@ -188,13 +188,13 @@ func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationI
|
||||
var ok bool
|
||||
switch key {
|
||||
case updateKeyMsg:
|
||||
var msg *unRelationTb.MsgDataModel
|
||||
msg, ok = field.(*unRelationTb.MsgDataModel)
|
||||
var msg *unrelationtb.MsgDataModel
|
||||
msg, ok = field.(*unrelationtb.MsgDataModel)
|
||||
if msg != nil && msg.Seq != firstSeq+int64(i) {
|
||||
return errs.ErrInternalServer.Wrap("seq is invalid")
|
||||
}
|
||||
case updateKeyRevoke:
|
||||
_, ok = field.(*unRelationTb.RevokeModel)
|
||||
_, ok = field.(*unrelationtb.RevokeModel)
|
||||
default:
|
||||
return errs.ErrInternalServer.Wrap("key is invalid")
|
||||
}
|
||||
@ -234,9 +234,9 @@ func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationI
|
||||
continue // 匹配到了,继续下一个(不一定修改)
|
||||
}
|
||||
}
|
||||
doc := unRelationTb.MsgDocModel{
|
||||
doc := unrelationtb.MsgDocModel{
|
||||
DocID: db.msg.GetDocID(conversationID, seq),
|
||||
Msg: make([]*unRelationTb.MsgInfoModel, num),
|
||||
Msg: make([]*unrelationtb.MsgInfoModel, num),
|
||||
}
|
||||
var insert int // 插入的数量
|
||||
for j := i; j < len(fields); j++ {
|
||||
@ -247,18 +247,18 @@ func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationI
|
||||
insert++
|
||||
switch key {
|
||||
case updateKeyMsg:
|
||||
doc.Msg[db.msg.GetMsgIndex(seq)] = &unRelationTb.MsgInfoModel{
|
||||
Msg: fields[j].(*unRelationTb.MsgDataModel),
|
||||
doc.Msg[db.msg.GetMsgIndex(seq)] = &unrelationtb.MsgInfoModel{
|
||||
Msg: fields[j].(*unrelationtb.MsgDataModel),
|
||||
}
|
||||
case updateKeyRevoke:
|
||||
doc.Msg[db.msg.GetMsgIndex(seq)] = &unRelationTb.MsgInfoModel{
|
||||
Revoke: fields[j].(*unRelationTb.RevokeModel),
|
||||
doc.Msg[db.msg.GetMsgIndex(seq)] = &unrelationtb.MsgInfoModel{
|
||||
Revoke: fields[j].(*unrelationtb.RevokeModel),
|
||||
}
|
||||
}
|
||||
}
|
||||
for i, model := range doc.Msg {
|
||||
if model == nil {
|
||||
model = &unRelationTb.MsgInfoModel{}
|
||||
model = &unrelationtb.MsgInfoModel{}
|
||||
doc.Msg[i] = model
|
||||
}
|
||||
if model.DelList == nil {
|
||||
@ -288,9 +288,9 @@ func (db *commonMsgDatabase) BatchInsertChat2DB(ctx context.Context, conversatio
|
||||
if msg == nil {
|
||||
continue
|
||||
}
|
||||
var offlinePushModel *unRelationTb.OfflinePushModel
|
||||
var offlinePushModel *unrelationtb.OfflinePushModel
|
||||
if msg.OfflinePushInfo != nil {
|
||||
offlinePushModel = &unRelationTb.OfflinePushModel{
|
||||
offlinePushModel = &unrelationtb.OfflinePushModel{
|
||||
Title: msg.OfflinePushInfo.Title,
|
||||
Desc: msg.OfflinePushInfo.Desc,
|
||||
Ex: msg.OfflinePushInfo.Ex,
|
||||
@ -298,7 +298,7 @@ func (db *commonMsgDatabase) BatchInsertChat2DB(ctx context.Context, conversatio
|
||||
IOSBadgeCount: msg.OfflinePushInfo.IOSBadgeCount,
|
||||
}
|
||||
}
|
||||
msgs[i] = &unRelationTb.MsgDataModel{
|
||||
msgs[i] = &unrelationtb.MsgDataModel{
|
||||
SendID: msg.SendID,
|
||||
RecvID: msg.RecvID,
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ func (db *commonMsgDatabase) getMsgBySeqs(ctx context.Context, userID, conversat
|
||||
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)
|
||||
for _, msg := range msgs {
|
||||
if msg.IsRead {
|
||||
@ -927,7 +927,7 @@ func (db *commonMsgDatabase) RangeUserSendCount(
|
||||
ase bool,
|
||||
pageNumber 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)
|
||||
}
|
||||
|
||||
@ -938,11 +938,11 @@ func (db *commonMsgDatabase) RangeGroupSendCount(
|
||||
ase bool,
|
||||
pageNumber 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)
|
||||
}
|
||||
|
||||
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
|
||||
total, msgs, err := db.msgDocDatabase.SearchMessage(ctx, req)
|
||||
if err != nil {
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||
unrelationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
||||
)
|
||||
|
||||
@ -173,10 +173,10 @@ func Test_Insert(t *testing.T) {
|
||||
var arr []any
|
||||
for i := 0; i < 345; i++ {
|
||||
if i%2 == 0 {
|
||||
arr = append(arr, (*unRelationTb.MsgDataModel)(nil))
|
||||
arr = append(arr, (*unrelationtb.MsgDataModel)(nil))
|
||||
continue
|
||||
}
|
||||
arr = append(arr, &unRelationTb.MsgDataModel{
|
||||
arr = append(arr, &unrelationtb.MsgDataModel{
|
||||
Seq: int64(i),
|
||||
Content: fmt.Sprintf("test-%d", i),
|
||||
})
|
||||
@ -191,7 +191,7 @@ func Test_Revoke(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
var arr []any
|
||||
for i := 0; i < 456; i++ {
|
||||
arr = append(arr, &unRelationTb.RevokeModel{
|
||||
arr = append(arr, &unrelationtb.RevokeModel{
|
||||
UserID: "uid_" + strconv.Itoa(i),
|
||||
Nickname: "uname_" + strconv.Itoa(i),
|
||||
Time: time.Now().UnixMilli(),
|
||||
@ -254,7 +254,7 @@ func Test_FindBySeq(t *testing.T) {
|
||||
//
|
||||
// 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)
|
||||
// if err != nil {
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
|
||||
"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/tx"
|
||||
@ -71,10 +71,10 @@ type userDatabase struct {
|
||||
userDB relation.UserModelInterface
|
||||
cache cache.UserCache
|
||||
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}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
||||
sdkws "github.com/OpenIMSDK/protocol/sdkws"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
@ -36,7 +36,7 @@ func NewChatLogGorm(db *gorm.DB) relation.ChatLogModelInterface {
|
||||
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)
|
||||
copier.Copy(chatLog, msg.MsgData)
|
||||
switch msg.MsgData.SessionType {
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
mysqlDriver "github.com/go-sql-driver/mysql"
|
||||
mysqldriver "github.com/go-sql-driver/mysql"
|
||||
"gorm.io/driver/mysql"
|
||||
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
@ -94,7 +94,7 @@ func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
|
||||
if err == 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
|
||||
}
|
||||
time.Sleep(time.Duration(1) * time.Second)
|
||||
@ -117,7 +117,7 @@ func replaceDuplicateKey(err error) errs.CodeError {
|
||||
}
|
||||
|
||||
func IsMysqlDuplicateKey(err error) bool {
|
||||
if mysqlErr, ok := err.(*mysqlDriver.MySQLError); ok {
|
||||
if mysqlErr, ok := err.(*mysqldriver.MySQLError); ok {
|
||||
return mysqlErr.Number == 1062
|
||||
}
|
||||
return false
|
||||
|
@ -17,7 +17,7 @@ package relation
|
||||
import (
|
||||
"time"
|
||||
|
||||
pbMsg "github.com/OpenIMSDK/protocol/msg"
|
||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -47,5 +47,5 @@ func (ChatLogModel) TableName() string {
|
||||
}
|
||||
|
||||
type ChatLogModelInterface interface {
|
||||
Create(msg *pbMsg.MsgDataToMQ) error
|
||||
Create(msg *pbmsg.MsgDataToMQ) error
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
urlLib "net/url"
|
||||
urllib "net/url"
|
||||
"time"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
@ -110,7 +110,7 @@ func callBackPostReturn(
|
||||
callbackConfig config.CallBackConfig,
|
||||
) error {
|
||||
defer log.ZDebug(ctx, "callback", "url", url, "command", command, "input", input, "callbackConfig", callbackConfig)
|
||||
v := urlLib.Values{}
|
||||
v := urllib.Values{}
|
||||
v.Set(constant.CallbackCommand, command)
|
||||
url = url + "?" + v.Encode()
|
||||
b, err := Post(ctx, url, nil, input, callbackConfig.CallbackTimeOut)
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
|
||||
grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||
grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
|
||||
@ -79,9 +79,9 @@ func Start(
|
||||
prome.NewGrpcRequestCounter()
|
||||
prome.NewGrpcRequestFailedCounter()
|
||||
prome.NewGrpcRequestSuccessCounter()
|
||||
unaryInterceptor := mw.InterceptChain(grpcPrometheus.UnaryServerInterceptor, mw.RpcServerInterceptor)
|
||||
unaryInterceptor := mw.InterceptChain(grpcprometheus.UnaryServerInterceptor, mw.RpcServerInterceptor)
|
||||
options = append(options, []grpc.ServerOption{
|
||||
grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor),
|
||||
grpc.StreamInterceptor(grpcprometheus.StreamServerInterceptor),
|
||||
grpc.UnaryInterceptor(unaryInterceptor),
|
||||
}...)
|
||||
} else {
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
pbConversation "github.com/OpenIMSDK/protocol/conversation"
|
||||
pbconversation "github.com/OpenIMSDK/protocol/conversation"
|
||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
|
||||
@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
type Conversation struct {
|
||||
Client pbConversation.ConversationClient
|
||||
Client pbconversation.ConversationClient
|
||||
conn grpc.ClientConnInterface
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
@ -38,7 +38,7 @@ func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry) *Conversatio
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
client := pbConversation.NewConversationClient(conn)
|
||||
client := pbconversation.NewConversationClient(conn)
|
||||
return &Conversation{discov: discov, conn: conn, Client: client}
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ func NewConversationRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) Con
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
|
||||
var req pbConversation.GetConversationReq
|
||||
var req pbconversation.GetConversationReq
|
||||
req.OwnerUserID = userID
|
||||
req.ConversationID = conversationID
|
||||
conversation, err := c.Client.GetConversation(ctx, &req)
|
||||
@ -60,46 +60,46 @@ func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Cont
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Context, recvID, sendID string) error {
|
||||
_, err := c.Client.CreateSingleChatConversations(ctx, &pbConversation.CreateSingleChatConversationsReq{RecvID: recvID, SendID: sendID})
|
||||
_, err := c.Client.CreateSingleChatConversations(ctx, &pbconversation.CreateSingleChatConversationsReq{RecvID: recvID, SendID: sendID})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(ctx context.Context, groupID string, userIDs []string) error {
|
||||
_, err := c.Client.CreateGroupChatConversations(ctx, &pbConversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID})
|
||||
_, err := c.Client.CreateGroupChatConversations(ctx, &pbconversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) SetConversationMaxSeq(ctx context.Context, ownerUserIDs []string, conversationID string, maxSeq int64) error {
|
||||
_, err := c.Client.SetConversationMaxSeq(ctx, &pbConversation.SetConversationMaxSeqReq{OwnerUserID: ownerUserIDs, ConversationID: conversationID, MaxSeq: maxSeq})
|
||||
_, err := c.Client.SetConversationMaxSeq(ctx, &pbconversation.SetConversationMaxSeqReq{OwnerUserID: ownerUserIDs, ConversationID: conversationID, MaxSeq: maxSeq})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbConversation.ConversationReq) error {
|
||||
_, err := c.Client.SetConversations(ctx, &pbConversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation})
|
||||
func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbconversation.ConversationReq) error {
|
||||
_, err := c.Client.SetConversations(ctx, &pbconversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GetConversationIDs(ctx context.Context, ownerUserID string) ([]string, error) {
|
||||
resp, err := c.Client.GetConversationIDs(ctx, &pbConversation.GetConversationIDsReq{UserID: ownerUserID})
|
||||
resp, err := c.Client.GetConversationIDs(ctx, &pbconversation.GetConversationIDsReq{UserID: ownerUserID})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.ConversationIDs, nil
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GetConversation(ctx context.Context, ownerUserID, conversationID string) (*pbConversation.Conversation, error) {
|
||||
resp, err := c.Client.GetConversation(ctx, &pbConversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID})
|
||||
func (c *ConversationRpcClient) GetConversation(ctx context.Context, ownerUserID, conversationID string) (*pbconversation.Conversation, error) {
|
||||
resp, err := c.Client.GetConversation(ctx, &pbconversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.Conversation, nil
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*pbConversation.Conversation, error) {
|
||||
func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*pbconversation.Conversation, error) {
|
||||
if len(conversationIDs) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
resp, err := c.Client.GetConversationsByConversationID(ctx, &pbConversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs})
|
||||
resp, err := c.Client.GetConversationsByConversationID(ctx, &pbconversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -113,13 +113,13 @@ func (c *ConversationRpcClient) GetConversations(
|
||||
ctx context.Context,
|
||||
ownerUserID string,
|
||||
conversationIDs []string,
|
||||
) ([]*pbConversation.Conversation, error) {
|
||||
) ([]*pbconversation.Conversation, error) {
|
||||
if len(conversationIDs) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
resp, err := c.Client.GetConversations(
|
||||
ctx,
|
||||
&pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs},
|
||||
&pbconversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -20,12 +20,12 @@ import (
|
||||
"github.com/OpenIMSDK/tools/mcontext"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
pbFriend "github.com/OpenIMSDK/protocol/friend"
|
||||
pbfriend "github.com/OpenIMSDK/protocol/friend"
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||
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"
|
||||
)
|
||||
|
||||
@ -46,7 +46,7 @@ func WithFriendDB(db controller.FriendDatabase) friendNotificationSenderOptions
|
||||
}
|
||||
|
||||
func WithDBFunc(
|
||||
fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error),
|
||||
fn func(ctx context.Context, userIDs []string) (users []*relationtb.UserModel, err error),
|
||||
) friendNotificationSenderOptions {
|
||||
return func(s *FriendNotificationSender) {
|
||||
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
|
||||
@ -127,7 +127,7 @@ func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Conte
|
||||
|
||||
func (f *FriendNotificationSender) FriendApplicationAddNotification(
|
||||
ctx context.Context,
|
||||
req *pbFriend.ApplyToAddFriendReq,
|
||||
req *pbfriend.ApplyToAddFriendReq,
|
||||
) error {
|
||||
tips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.FromUserID,
|
||||
@ -138,7 +138,7 @@ func (f *FriendNotificationSender) FriendApplicationAddNotification(
|
||||
|
||||
func (f *FriendNotificationSender) FriendApplicationAgreedNotification(
|
||||
ctx context.Context,
|
||||
req *pbFriend.RespondFriendApplyReq,
|
||||
req *pbfriend.RespondFriendApplyReq,
|
||||
) error {
|
||||
tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.FromUserID,
|
||||
@ -149,7 +149,7 @@ func (f *FriendNotificationSender) FriendApplicationAgreedNotification(
|
||||
|
||||
func (f *FriendNotificationSender) FriendApplicationRefusedNotification(
|
||||
ctx context.Context,
|
||||
req *pbFriend.RespondFriendApplyReq,
|
||||
req *pbfriend.RespondFriendApplyReq,
|
||||
) error {
|
||||
tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.FromUserID,
|
||||
@ -182,7 +182,7 @@ func (f *FriendNotificationSender) FriendAddedNotification(
|
||||
return f.Notification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &tips)
|
||||
}
|
||||
|
||||
func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) error {
|
||||
func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *pbfriend.DeleteFriendReq) error {
|
||||
tips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.OwnerUserID,
|
||||
ToUserID: req.FriendUserID,
|
||||
@ -197,14 +197,14 @@ func (f *FriendNotificationSender) FriendRemarkSetNotification(ctx context.Conte
|
||||
return f.Notification(ctx, fromUserID, toUserID, constant.FriendRemarkSetNotification, &tips)
|
||||
}
|
||||
|
||||
func (f *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) error {
|
||||
func (f *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *pbfriend.AddBlackReq) error {
|
||||
tips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
tips.FromToUserID.FromUserID = req.OwnerUserID
|
||||
tips.FromToUserID.ToUserID = req.BlackUserID
|
||||
return f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &tips)
|
||||
}
|
||||
|
||||
func (f *FriendNotificationSender) BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) {
|
||||
func (f *FriendNotificationSender) BlackDeletedNotification(ctx context.Context, req *pbfriend.RemoveBlackReq) {
|
||||
blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.OwnerUserID,
|
||||
ToUserID: req.BlackUserID,
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"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/tools/errs"
|
||||
"github.com/OpenIMSDK/tools/log"
|
||||
@ -317,7 +317,7 @@ func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(ctx conte
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips, rpcclient.WithRpcGetUserName())
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) (err error) {
|
||||
func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.Context, req *pbgroup.JoinGroupReq) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
@ -362,7 +362,7 @@ func (g *GroupNotificationSender) MemberQuitNotification(ctx context.Context, me
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), member.GroupID, constant.MemberQuitNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
||||
func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx context.Context, req *pbgroup.GroupApplicationResponseReq) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
@ -390,7 +390,7 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
||||
func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx context.Context, req *pbgroup.GroupApplicationResponseReq) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
@ -418,7 +418,7 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) (err error) {
|
||||
func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.Context, req *pbgroup.TransferGroupOwnerReq) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||
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"
|
||||
)
|
||||
|
||||
@ -41,7 +41,7 @@ func WithUserDB(db controller.UserDatabase) userNotificationSenderOptions {
|
||||
}
|
||||
|
||||
func WithUserFunc(
|
||||
fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error),
|
||||
fn func(ctx context.Context, userIDs []string) (users []*relationtb.UserModel, err error),
|
||||
) userNotificationSenderOptions {
|
||||
return func(u *UserNotificationSender) {
|
||||
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
|
||||
|
@ -31,12 +31,14 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
)
|
||||
|
||||
// User represents a structure holding connection details for the User RPC client.
|
||||
type User struct {
|
||||
conn grpc.ClientConnInterface
|
||||
Client user.UserClient
|
||||
Discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
// NewUser initializes and returns a User instance based on the provided service discovery registry.
|
||||
func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
|
||||
if err != nil {
|
||||
@ -46,17 +48,21 @@ func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
|
||||
return &User{Discov: discov, Client: client, conn: conn}
|
||||
}
|
||||
|
||||
// UserRpcClient represents the structure for a User RPC client.
|
||||
type UserRpcClient User
|
||||
|
||||
// NewUserRpcClientByUser initializes a UserRpcClient based on the provided User instance.
|
||||
func NewUserRpcClientByUser(user *User) *UserRpcClient {
|
||||
rpc := UserRpcClient(*user)
|
||||
return &rpc
|
||||
}
|
||||
|
||||
// NewUserRpcClient initializes a UserRpcClient based on the provided service discovery registry.
|
||||
func NewUserRpcClient(client discoveryregistry.SvcDiscoveryRegistry) UserRpcClient {
|
||||
return UserRpcClient(*NewUser(client))
|
||||
}
|
||||
|
||||
// GetUsersInfo retrieves information for multiple users based on their user IDs.
|
||||
func (u *UserRpcClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error) {
|
||||
resp, err := u.Client.GetDesignateUsers(ctx, &user.GetDesignateUsersReq{
|
||||
UserIDs: userIDs,
|
||||
@ -72,6 +78,7 @@ func (u *UserRpcClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*
|
||||
return resp.UsersInfo, nil
|
||||
}
|
||||
|
||||
// GetUserInfo retrieves information for a single user based on the provided user ID.
|
||||
func (u *UserRpcClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.UserInfo, error) {
|
||||
users, err := u.GetUsersInfo(ctx, []string{userID})
|
||||
if err != nil {
|
||||
@ -80,6 +87,7 @@ func (u *UserRpcClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.
|
||||
return users[0], nil
|
||||
}
|
||||
|
||||
// GetUsersInfoMap retrieves a map of user information indexed by their user IDs.
|
||||
func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
|
||||
users, err := u.GetUsersInfo(ctx, userIDs)
|
||||
if err != nil {
|
||||
@ -90,6 +98,7 @@ func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (
|
||||
}), nil
|
||||
}
|
||||
|
||||
// GetPublicUserInfos retrieves public information for multiple users based on their user IDs.
|
||||
func (u *UserRpcClient) GetPublicUserInfos(
|
||||
ctx context.Context,
|
||||
userIDs []string,
|
||||
@ -109,6 +118,7 @@ func (u *UserRpcClient) GetPublicUserInfos(
|
||||
}), nil
|
||||
}
|
||||
|
||||
// GetPublicUserInfo retrieves public information for a single user based on the provided user ID.
|
||||
func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) {
|
||||
users, err := u.GetPublicUserInfos(ctx, []string{userID}, true)
|
||||
if err != nil {
|
||||
@ -117,6 +127,7 @@ func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*
|
||||
return users[0], nil
|
||||
}
|
||||
|
||||
// GetPublicUserInfoMap retrieves a map of public user information indexed by their user IDs.
|
||||
func (u *UserRpcClient) GetPublicUserInfoMap(
|
||||
ctx context.Context,
|
||||
userIDs []string,
|
||||
@ -131,16 +142,15 @@ func (u *UserRpcClient) GetPublicUserInfoMap(
|
||||
}), nil
|
||||
}
|
||||
|
||||
// GetUserGlobalMsgRecvOpt retrieves the global message receive option for a user based on the provided user ID.
|
||||
func (u *UserRpcClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID string) (int32, error) {
|
||||
resp, err := u.Client.GetGlobalRecvMessageOpt(ctx, &user.GetGlobalRecvMessageOptReq{
|
||||
UserID: userID,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return resp.GlobalRecvMsgOpt, err
|
||||
}
|
||||
|
||||
// Access verifies the access rights for the provided user ID.
|
||||
func (u *UserRpcClient) Access(ctx context.Context, ownerUserID string) error {
|
||||
_, err := u.GetUserInfo(ctx, ownerUserID)
|
||||
if err != nil {
|
||||
@ -149,6 +159,7 @@ func (u *UserRpcClient) Access(ctx context.Context, ownerUserID string) error {
|
||||
return authverify.CheckAccessV3(ctx, ownerUserID)
|
||||
}
|
||||
|
||||
// GetAllUserIDs retrieves all user IDs with pagination options.
|
||||
func (u *UserRpcClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumber int32) ([]string, error) {
|
||||
resp, err := u.Client.GetAllUserID(ctx, &user.GetAllUserIDReq{Pagination: &sdkws.RequestPagination{PageNumber: pageNumber, ShowNumber: showNumber}})
|
||||
if err != nil {
|
||||
@ -157,6 +168,7 @@ func (u *UserRpcClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumbe
|
||||
return resp.UserIDs, nil
|
||||
}
|
||||
|
||||
// SetUserStatus sets the status for a user based on the provided user ID, status, and platform ID.
|
||||
func (u *UserRpcClient) SetUserStatus(ctx context.Context, userID string, status int32, platformID int) error {
|
||||
_, err := u.Client.SetUserStatus(ctx, &user.SetUserStatusReq{StatusList: []*user.OnlineStatus{{UserID: userID, Status: status, PlatformIDs: []int32{int32(platformID)}}}})
|
||||
return err
|
||||
|
@ -33,7 +33,7 @@ source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
||||
# Check the system type
|
||||
system_type=$(uname)
|
||||
|
||||
pushd "${OPENIM_ROOT}/tools/ncpu" >/dev/null
|
||||
pushd ""${OPENIM_ROOT}"/tools/ncpu" >/dev/null
|
||||
cpu_count=$(go run .)
|
||||
popd >/dev/null
|
||||
|
||||
|
@ -42,7 +42,7 @@ OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd -P)
|
||||
|
||||
# Constants
|
||||
readonly OPENIM_BUILD_IMAGE_REPO=openim-build
|
||||
#readonly OPENIM_BUILD_IMAGE_CROSS_TAG="$(cat "${OPENIM_ROOT}/build/build-image/cross/VERSION")"
|
||||
#readonly OPENIM_BUILD_IMAGE_CROSS_TAG="$(cat ""${OPENIM_ROOT}"/build/build-image/cross/VERSION")"
|
||||
|
||||
readonly OPENIM_DOCKER_REGISTRY="${OPENIM_DOCKER_REGISTRY:-k8s.gcr.io}"
|
||||
readonly OPENIM_BASE_IMAGE_REGISTRY="${OPENIM_BASE_IMAGE_REGISTRY:-us.gcr.io/k8s-artifacts-prod/build-image}"
|
||||
@ -53,7 +53,7 @@ readonly OPENIM_BASE_IMAGE_REGISTRY="${OPENIM_BASE_IMAGE_REGISTRY:-us.gcr.io/k8s
|
||||
#
|
||||
# Increment/change this number if you change the build image (anything under
|
||||
# build/build-image) or change the set of volumes in the data container.
|
||||
#readonly OPENIM_BUILD_IMAGE_VERSION_BASE="$(cat "${OPENIM_ROOT}/build/build-image/VERSION")"
|
||||
#readonly OPENIM_BUILD_IMAGE_VERSION_BASE="$(cat ""${OPENIM_ROOT}"/build/build-image/VERSION")"
|
||||
#readonly OPENIM_BUILD_IMAGE_VERSION="${OPENIM_BUILD_IMAGE_VERSION_BASE}-${OPENIM_BUILD_IMAGE_CROSS_TAG}"
|
||||
|
||||
# Here we map the output directories across both the local and remote _output
|
||||
@ -66,7 +66,7 @@ readonly OPENIM_BASE_IMAGE_REGISTRY="${OPENIM_BASE_IMAGE_REGISTRY:-us.gcr.io/k8s
|
||||
# is really remote, this is the stuff that has to be copied
|
||||
# back.
|
||||
# OUT_DIR can come in from the Makefile, so honor it.
|
||||
readonly LOCAL_OUTPUT_ROOT="${OPENIM_ROOT}/${OUT_DIR:-_output}"
|
||||
readonly LOCAL_OUTPUT_ROOT=""${OPENIM_ROOT}"/${OUT_DIR:-_output}"
|
||||
readonly LOCAL_OUTPUT_SUBPATH="${LOCAL_OUTPUT_ROOT}/platforms"
|
||||
readonly LOCAL_OUTPUT_BINPATH="${LOCAL_OUTPUT_SUBPATH}"
|
||||
readonly LOCAL_OUTPUT_GOPATH="${LOCAL_OUTPUT_SUBPATH}/go"
|
||||
@ -147,7 +147,7 @@ function openim::build::verify_prereqs() {
|
||||
fi
|
||||
|
||||
OPENIM_GIT_BRANCH=$(git symbolic-ref --short -q HEAD 2>/dev/null || true)
|
||||
OPENIM_ROOT_HASH=$(openim::build::short_hash "${HOSTNAME:-}:${OPENIM_ROOT}:${OPENIM_GIT_BRANCH}")
|
||||
OPENIM_ROOT_HASH=$(openim::build::short_hash "${HOSTNAME:-}:"${OPENIM_ROOT}":${OPENIM_GIT_BRANCH}")
|
||||
OPENIM_BUILD_IMAGE_TAG_BASE="build-${OPENIM_ROOT_HASH}"
|
||||
#OPENIM_BUILD_IMAGE_TAG="${OPENIM_BUILD_IMAGE_TAG_BASE}-${OPENIM_BUILD_IMAGE_VERSION}"
|
||||
#OPENIM_BUILD_IMAGE="${OPENIM_BUILD_IMAGE_REPO}:${OPENIM_BUILD_IMAGE_TAG}"
|
||||
@ -161,7 +161,7 @@ function openim::build::verify_prereqs() {
|
||||
#LOCAL_OUTPUT_BUILD_CONTEXT="${LOCAL_OUTPUT_IMAGE_STAGING}/${OPENIM_BUILD_IMAGE}"
|
||||
|
||||
openim::version::get_version_vars
|
||||
#openim::version::save_version_vars "${OPENIM_ROOT}/.dockerized-openim-version-defs"
|
||||
#openim::version::save_version_vars ""${OPENIM_ROOT}"/.dockerized-openim-version-defs"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@ -416,8 +416,8 @@ function openim::build::build_image() {
|
||||
|
||||
cp /etc/localtime "${LOCAL_OUTPUT_BUILD_CONTEXT}/"
|
||||
|
||||
cp "${OPENIM_ROOT}/build/build-image/Dockerfile" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
||||
cp "${OPENIM_ROOT}/build/build-image/rsyncd.sh" "${LOCAL_OUTPUT_BUILD_CONTEXT}/"
|
||||
cp ""${OPENIM_ROOT}"/build/build-image/Dockerfile" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
||||
cp ""${OPENIM_ROOT}"/build/build-image/rsyncd.sh" "${LOCAL_OUTPUT_BUILD_CONTEXT}/"
|
||||
dd if=/dev/urandom bs=512 count=1 2>/dev/null | LC_ALL=C tr -dc 'A-Za-z0-9' | dd bs=32 count=1 2>/dev/null > "${LOCAL_OUTPUT_BUILD_CONTEXT}/rsyncd.password"
|
||||
chmod go= "${LOCAL_OUTPUT_BUILD_CONTEXT}/rsyncd.password"
|
||||
|
||||
|
@ -22,10 +22,10 @@ source "${OPENIM_ROOT}/scripts/install/common.sh"
|
||||
|
||||
trap 'openim::util::onCtrlC' INT
|
||||
|
||||
nohup ${OPENIM_ROOT}/scripts/start-all.sh >> ${LOG_FILE} 2>&1 &
|
||||
nohup "${OPENIM_ROOT}"/scripts/start-all.sh >> ${LOG_FILE} 2>&1 &
|
||||
|
||||
sleep 15
|
||||
|
||||
nohup ${OPENIM_ROOT}/scripts/check-all.sh >> ${LOG_FILE} 2>&1 &
|
||||
nohup "${OPENIM_ROOT}"/scripts/check-all.sh >> ${LOG_FILE} 2>&1 &
|
||||
|
||||
tail -f ${LOG_FILE}
|
@ -21,7 +21,7 @@ set -o pipefail
|
||||
|
||||
# The root of the build/dist directory
|
||||
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
|
||||
source ${OPENIM_ROOT}/scripts/lib/util.sh
|
||||
source "${OPENIM_ROOT}"/scripts/lib/util.sh
|
||||
|
||||
mkdir -p ${OPENIM_OUTPUT_TMP}
|
||||
cd ${OPENIM_OUTPUT_TMP}
|
||||
|
@ -25,12 +25,12 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
||||
|
||||
# 定义一个配置文件数组,其中包含需要生成的配置文件的名称路径 (en: Define a profile array that contains the name path of the profile to be generated.)
|
||||
readonly ENV_FILE=${ENV_FILE:-${OPENIM_ROOT}/scripts/install/environment.sh}
|
||||
readonly ENV_FILE=${ENV_FILE:-"${OPENIM_ROOT}"/scripts/install/environment.sh}
|
||||
|
||||
# 定义关联数组,其中键是模板文件,值是对应的输出文件 (en: Defines an associative array where the keys are the template files and the values are the corresponding output files.)
|
||||
declare -A TEMPLATES=(
|
||||
["${OPENIM_ROOT}/deployments/templates/env_template.yaml"]="${OPENIM_ROOT}/.env"
|
||||
["${OPENIM_ROOT}/deployments/templates/openim.yaml"]="${OPENIM_ROOT}/config/config.yaml"
|
||||
[""${OPENIM_ROOT}"/deployments/templates/env_template.yaml"]=""${OPENIM_ROOT}"/.env"
|
||||
[""${OPENIM_ROOT}"/deployments/templates/openim.yaml"]=""${OPENIM_ROOT}"/config/config.yaml"
|
||||
)
|
||||
|
||||
for template in "${!TEMPLATES[@]}"; do
|
||||
@ -40,11 +40,11 @@ for template in "${!TEMPLATES[@]}"; do
|
||||
openim::log::error_exit "template file ${template} does not exist..."
|
||||
fi
|
||||
|
||||
openim::log::info "Working with template file: ${template} to ${output_file}..."
|
||||
"${OPENIM_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || {
|
||||
openim::log::info "⌚ Working with template file: ${template} to ${output_file}..."
|
||||
""${OPENIM_ROOT}"/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || {
|
||||
openim::log::error "Error processing template file ${template}"
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
|
||||
openim::log::success "All configuration files have been successfully generated!"
|
||||
openim::log::success "✨ All configuration files have been successfully generated!"
|
@ -43,10 +43,10 @@ echo -e "===> ${PURPLE_PREFIX} you api url is:$API_URL ${COLOR_SUFFIX}"
|
||||
echo ""
|
||||
|
||||
# Specify the config file
|
||||
config_file=${OPENIM_ROOT}/config/config.yaml
|
||||
config_file="${OPENIM_ROOT}"/config/config.yaml
|
||||
|
||||
# Load variables from .env file
|
||||
source ${OPENIM_ROOT}/.env
|
||||
source "${OPENIM_ROOT}"/.env
|
||||
|
||||
# Replace the password and username field for mysql
|
||||
sed -i "/mysql:/,/database:/ s/password:.*/password: $PASSWORD/" $config_file
|
||||
|
@ -24,24 +24,26 @@ source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
||||
|
||||
trap 'openim::util::onCtrlC' INT
|
||||
|
||||
chmod +x ${OPENIM_ROOT}/scripts/*.sh
|
||||
${OPENIM_ROOT}/scripts/init-config.sh
|
||||
chmod +x "${OPENIM_ROOT}"/scripts/*.sh
|
||||
"${OPENIM_ROOT}"/scripts/init-config.sh
|
||||
|
||||
openim::util::ensure_docker_daemon_connectivity
|
||||
|
||||
DOCKER_COMPOSE_COMMAND=
|
||||
# Check if docker-compose command is available
|
||||
if command -v docker-compose &> /dev/null
|
||||
if command -v docker compose &> /dev/null
|
||||
then
|
||||
openim::log::info "docker-compose command is available"
|
||||
DOCKER_COMPOSE_COMMAND="docker-compose"
|
||||
else
|
||||
openim::log::info "docker compose command is available"
|
||||
DOCKER_COMPOSE_COMMAND="docker compose"
|
||||
else
|
||||
DOCKER_COMPOSE_COMMAND="docker-compose"
|
||||
fi
|
||||
|
||||
pushd "${OPENIM_ROOT}" >/dev/null
|
||||
${DOCKER_COMPOSE_COMMAND} up -d
|
||||
sleep 60
|
||||
${DOCKER_COMPOSE_COMMAND} ps
|
||||
${DOCKER_COMPOSE_COMMAND} logs
|
||||
popd >/dev/null
|
||||
pushd "${OPENIM_ROOT}"
|
||||
|
||||
${DOCKER_COMPOSE_COMMAND} up -d
|
||||
sleep 60
|
||||
${DOCKER_COMPOSE_COMMAND} logs
|
||||
${DOCKER_COMPOSE_COMMAND} ps
|
||||
|
||||
popd
|
||||
|
@ -20,7 +20,7 @@ set +o nounset
|
||||
set -o pipefail
|
||||
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
# Start MySQL service
|
||||
docker run -d \
|
||||
|
@ -21,7 +21,7 @@
|
||||
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
|
||||
|
||||
# 生成文件存放目录
|
||||
LOCAL_OUTPUT_ROOT="${OPENIM_ROOT}/${OUT_DIR:-_output}"
|
||||
LOCAL_OUTPUT_ROOT=""${OPENIM_ROOT}"/${OUT_DIR:-_output}"
|
||||
source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
||||
|
||||
#TODO
|
||||
@ -57,7 +57,7 @@ def "LINUX_PASSWORD" "${PASSWORD}"
|
||||
def "INSTALL_DIR" "${LOCAL_OUTPUT_ROOT}/installs"
|
||||
mkdir -p ${INSTALL_DIR}
|
||||
|
||||
def "ENV_FILE" "${OPENIM_ROOT}/scripts/install/environment.sh"
|
||||
def "ENV_FILE" ""${OPENIM_ROOT}"/scripts/install/environment.sh"
|
||||
|
||||
###################### openim 配置 ######################
|
||||
# read: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/deployment/init/README.md
|
||||
@ -67,7 +67,7 @@ def "OPENIM_CONFIG_DIR" "/etc/openim"
|
||||
def "OPENIM_LOG_DIR" "/var/log/openim"
|
||||
def "CA_FILE" "${OPENIM_CONFIG_DIR}/cert/ca.pem"
|
||||
|
||||
def "OPNEIM_CONFIG" "${OPENIM_ROOT}/config"
|
||||
def "OPNEIM_CONFIG" ""${OPENIM_ROOT}"/config"
|
||||
# TODO 注意: 一般的配置都可以使用 def 函数来定义,如果是包含特殊字符,比如说:
|
||||
# TODO readonly MSG_DESTRUCT_TIME=${MSG_DESTRUCT_TIME:-'0 2 * * *'}
|
||||
# TODO 使用 readonly 来定义合适,负责无法正常解析, 并且 yaml 模板需要加 "" 来包裹
|
||||
@ -186,7 +186,7 @@ def "OPENIM_CONVERSATION_NAME" "Conversation" # OpenIM对话服务名称
|
||||
def "OPENIM_THIRD_NAME" "Third" # OpenIM第三方服务名称
|
||||
|
||||
###################### Log Configuration Variables ######################
|
||||
def "LOG_STORAGE_LOCATION" "${OPENIM_ROOT}/logs/" # 日志存储位置
|
||||
def "LOG_STORAGE_LOCATION" ""${OPENIM_ROOT}"/logs/" # 日志存储位置
|
||||
def "LOG_ROTATION_TIME" "24" # 日志轮替时间
|
||||
def "LOG_REMAIN_ROTATION_COUNT" "2" # 保留的日志轮替数量
|
||||
def "LOG_REMAIN_LOG_LEVEL" "6" # 保留的日志级别
|
||||
@ -248,7 +248,7 @@ readonly MSG_TRANSFER_PROM_PORT=${MSG_TRANSFER_PROM_PORT:-'21400, 21401, 21402,
|
||||
###################### OpenIM openim-api ######################
|
||||
def "OPENIM_API_HOST" "127.0.0.1"
|
||||
def "OPENIM_API_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-api" # OpenIM openim-api 二进制文件路径
|
||||
def "OPENIM_API_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-api 配置文件路径
|
||||
def "OPENIM_API_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-api 配置文件路径
|
||||
def "OPENIM_API_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-api" # OpenIM openim-api 日志存储路径
|
||||
def "OPENIM_API_LOG_LEVEL" "info" # OpenIM openim-api 日志级别
|
||||
def "OPENIM_API_LOG_MAX_SIZE" "100" # OpenIM openim-api 日志最大大小(MB)
|
||||
@ -260,7 +260,7 @@ def "OPENIM_API_LOG_WITH_STACK" "${LOG_WITH_STACK}" # OpenIM openim-ap
|
||||
###################### OpenIM openim-cmdutils ######################
|
||||
def "OPENIM_CMDUTILS_HOST" "127.0.0.1"
|
||||
def "OPENIM_CMDUTILS_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-cmdutils" # OpenIM openim-cmdutils 二进制文件路径
|
||||
def "OPENIM_CMDUTILS_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-cmdutils 配置文件路径
|
||||
def "OPENIM_CMDUTILS_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-cmdutils 配置文件路径
|
||||
def "OPENIM_CMDUTILS_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-cmdutils" # OpenIM openim-cmdutils 日志存储路径
|
||||
def "OPENIM_CMDUTILS_LOG_LEVEL" "info" # OpenIM openim-cmdutils 日志级别
|
||||
def "OPENIM_CMDUTILS_LOG_MAX_SIZE" "100" # OpenIM openim-cmdutils 日志最大大小(MB)
|
||||
@ -272,7 +272,7 @@ def "OPENIM_CMDUTILS_LOG_WITH_STACK" "${LOG_WITH_STACK}" # OpenIM
|
||||
###################### OpenIM openim-crontask ######################
|
||||
def "OPENIM_CRONTASK_HOST" "127.0.0.1"
|
||||
def "OPENIM_CRONTASK_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-crontask" # OpenIM openim-crontask 二进制文件路径
|
||||
def "OPENIM_CRONTASK_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-crontask 配置文件路径
|
||||
def "OPENIM_CRONTASK_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-crontask 配置文件路径
|
||||
def "OPENIM_CRONTASK_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-crontask" # OpenIM openim-crontask 日志存储路径
|
||||
def "OPENIM_CRONTASK_LOG_LEVEL" "info" # OpenIM openim-crontask 日志级别
|
||||
def "OPENIM_CRONTASK_LOG_MAX_SIZE" "100" # OpenIM openim-crontask 日志最大大小(MB)
|
||||
@ -284,7 +284,7 @@ def "OPENIM_CRONTASK_LOG_WITH_STACK" "${LOG_WITH_STACK}" # OpenIM
|
||||
###################### OpenIM openim-msggateway ######################
|
||||
def "OPENIM_MSGGATEWAY_HOST" "127.0.0.1"
|
||||
def "OPENIM_MSGGATEWAY_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-msggateway"
|
||||
def "OPENIM_MSGGATEWAY_CONFIG" "${OPENIM_ROOT}/config/"
|
||||
def "OPENIM_MSGGATEWAY_CONFIG" ""${OPENIM_ROOT}"/config/"
|
||||
def "OPENIM_MSGGATEWAY_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-msggateway"
|
||||
def "OPENIM_MSGGATEWAY_LOG_LEVEL" "info"
|
||||
def "OPENIM_MSGGATEWAY_LOG_MAX_SIZE" "100"
|
||||
@ -299,7 +299,7 @@ readonly OPENIM_MSGGATEWAY_NUM=${OPENIM_MSGGATEWAY_NUM:-'4'}
|
||||
###################### OpenIM openim-msgtransfer ######################
|
||||
def "OPENIM_MSGTRANSFER_HOST" "127.0.0.1"
|
||||
def "OPENIM_MSGTRANSFER_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" # OpenIM openim-msgtransfer 二进制文件路径
|
||||
def "OPENIM_MSGTRANSFER_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-msgtransfer 配置文件路径
|
||||
def "OPENIM_MSGTRANSFER_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-msgtransfer 配置文件路径
|
||||
def "OPENIM_MSGTRANSFER_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-msgtransfer" # OpenIM openim-msgtransfer 日志存储路径
|
||||
def "OPENIM_MSGTRANSFER_LOG_LEVEL" "info" # OpenIM openim-msgtransfer 日志级别
|
||||
def "OPENIM_MSGTRANSFER_LOG_MAX_SIZE" "100" # OpenIM openim-msgtransfer 日志最大大小(MB)
|
||||
@ -311,7 +311,7 @@ def "OPENIM_MSGTRANSFER_LOG_WITH_STACK" "${LOG_WITH_STACK}" #
|
||||
###################### OpenIM openim-push ######################
|
||||
def "OPENIM_PUSH_HOST" "127.0.0.1"
|
||||
def "OPENIM_PUSH_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-push" # OpenIM openim-push 二进制文件路径
|
||||
def "OPENIM_PUSH_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-push 配置文件路径
|
||||
def "OPENIM_PUSH_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-push 配置文件路径
|
||||
def "OPENIM_PUSH_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-push" # OpenIM openim-push 日志存储路径
|
||||
def "OPENIM_PUSH_LOG_LEVEL" "info" # OpenIM openim-push 日志级别
|
||||
def "OPENIM_PUSH_LOG_MAX_SIZE" "100" # OpenIM openim-push 日志最大大小(MB)
|
||||
@ -323,7 +323,7 @@ def "OPENIM_PUSH_LOG_WITH_STACK" "${LOG_WITH_STACK}" # OpenIM openim-
|
||||
###################### OpenIM openim-rpc-auth ######################
|
||||
def "OPENIM_RPC_AUTH_HOST" "127.0.0.1"
|
||||
def "OPENIM_RPC_AUTH_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-rpc-auth" # OpenIM openim-rpc-auth 二进制文件路径
|
||||
def "OPENIM_RPC_AUTH_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-rpc-auth 配置文件路径
|
||||
def "OPENIM_RPC_AUTH_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-rpc-auth 配置文件路径
|
||||
def "OPENIM_RPC_AUTH_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-rpc-auth" # OpenIM openim-rpc-auth 日志存储路径
|
||||
def "OPENIM_RPC_AUTH_LOG_LEVEL" "info" # OpenIM openim-rpc-auth 日志级别
|
||||
def "OPENIM_RPC_AUTH_LOG_MAX_SIZE" "100" # OpenIM openim-rpc-auth 日志最大大小(MB)
|
||||
@ -335,7 +335,7 @@ def "OPENIM_RPC_AUTH_LOG_WITH_STACK" "${LOG_WITH_STACK}" # OpenIM
|
||||
###################### OpenIM openim-rpc-conversation ######################
|
||||
def "OPENIM_RPC_CONVERSATION_HOST" "127.0.0.1"
|
||||
def "OPENIM_RPC_CONVERSATION_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-rpc-conversation" # OpenIM openim-rpc-conversation 二进制文件路径
|
||||
def "OPENIM_RPC_CONVERSATION_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-rpc-conversation 配置文件路径
|
||||
def "OPENIM_RPC_CONVERSATION_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-rpc-conversation 配置文件路径
|
||||
def "OPENIM_RPC_CONVERSATION_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-rpc-conversation" # OpenIM openim-rpc-conversation 日志存储路径
|
||||
def "OPENIM_RPC_CONVERSATION_LOG_LEVEL" "info" # OpenIM openim-rpc-conversation 日志级别
|
||||
def "OPENIM_RPC_CONVERSATION_LOG_MAX_SIZE" "100" # OpenIM openim-rpc-conversation 日志最大大小(MB)
|
||||
@ -347,7 +347,7 @@ def "OPENIM_RPC_CONVERSATION_LOG_WITH_STACK" "${LOG_WITH_STACK}"
|
||||
###################### OpenIM openim-rpc-friend ######################
|
||||
def "OPENIM_RPC_FRIEND_HOST" "127.0.0.1"
|
||||
def "OPENIM_RPC_FRIEND_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-rpc-friend" # OpenIM openim-rpc-friend 二进制文件路径
|
||||
def "OPENIM_RPC_FRIEND_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-rpc-friend 配置文件路径
|
||||
def "OPENIM_RPC_FRIEND_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-rpc-friend 配置文件路径
|
||||
def "OPENIM_RPC_FRIEND_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-rpc-friend" # OpenIM openim-rpc-friend 日志存储路径
|
||||
def "OPENIM_RPC_FRIEND_LOG_LEVEL" "info" # OpenIM openim-rpc-friend 日志级别
|
||||
def "OPENIM_RPC_FRIEND_LOG_MAX_SIZE" "100" # OpenIM openim-rpc-friend 日志最大大小(MB)
|
||||
@ -359,7 +359,7 @@ def "OPENIM_RPC_FRIEND_LOG_WITH_STACK" "${LOG_WITH_STACK}" # Op
|
||||
###################### OpenIM openim-rpc-group ######################
|
||||
def "OPENIM_RPC_GROUP_HOST" "127.0.0.1"
|
||||
def "OPENIM_RPC_GROUP_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-rpc-group" # OpenIM openim-rpc-group 二进制文件路径
|
||||
def "OPENIM_RPC_GROUP_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-rpc-group 配置文件路径
|
||||
def "OPENIM_RPC_GROUP_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-rpc-group 配置文件路径
|
||||
def "OPENIM_RPC_GROUP_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-rpc-group" # OpenIM openim-rpc-group 日志存储路径
|
||||
def "OPENIM_RPC_GROUP_LOG_LEVEL" "info" # OpenIM openim-rpc-group 日志级别
|
||||
def "OPENIM_RPC_GROUP_LOG_MAX_SIZE" "100" # OpenIM openim-rpc-group 日志最大大小(MB)
|
||||
@ -371,7 +371,7 @@ def "OPENIM_RPC_GROUP_LOG_WITH_STACK" "${LOG_WITH_STACK}" # Open
|
||||
###################### OpenIM openim-rpc-msg ######################
|
||||
def "OPENIM_RPC_MSG_HOST" "127.0.0.1"
|
||||
def "OPENIM_RPC_MSG_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-rpc-msg" # OpenIM openim-rpc-msg 二进制文件路径
|
||||
def "OPENIM_RPC_MSG_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-rpc-msg 配置文件路径
|
||||
def "OPENIM_RPC_MSG_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-rpc-msg 配置文件路径
|
||||
def "OPENIM_RPC_MSG_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-rpc-msg" # OpenIM openim-rpc-msg 日志存储路径
|
||||
def "OPENIM_RPC_MSG_LOG_LEVEL" "info" # OpenIM openim-rpc-msg 日志级别
|
||||
def "OPENIM_RPC_MSG_LOG_MAX_SIZE" "100" # OpenIM openim-rpc-msg 日志最大大小(MB)
|
||||
@ -383,7 +383,7 @@ def "OPENIM_RPC_MSG_LOG_WITH_STACK" "${LOG_WITH_STACK}" # OpenIM o
|
||||
###################### OpenIM openim-rpc-third ######################
|
||||
def "OPENIM_RPC_THIRD_HOST" "127.0.0.1"
|
||||
def "OPENIM_RPC_THIRD_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-rpc-third" # OpenIM openim-rpc-third 二进制文件路径
|
||||
def "OPENIM_RPC_THIRD_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-rpc-third 配置文件路径
|
||||
def "OPENIM_RPC_THIRD_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-rpc-third 配置文件路径
|
||||
def "OPENIM_RPC_THIRD_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-rpc-third" # OpenIM openim-rpc-third 日志存储路径
|
||||
def "OPENIM_RPC_THIRD_LOG_LEVEL" "info" # OpenIM openim-rpc-third 日志级别
|
||||
def "OPENIM_RPC_THIRD_LOG_MAX_SIZE" "100" # OpenIM openim-rpc-third 日志最大大小(MB)
|
||||
@ -395,7 +395,7 @@ def "OPENIM_RPC_THIRD_LOG_WITH_STACK" "${LOG_WITH_STACK}" # Open
|
||||
###################### OpenIM openim-rpc-user ######################
|
||||
def "OPENIM_RPC_USER_HOST" "127.0.0.1"
|
||||
def "OPENIM_RPC_USER_BINARY" "${OPENIM_OUTPUT_HOSTBIN}/openim-rpc-user" # OpenIM openim-rpc-user 二进制文件路径
|
||||
def "OPENIM_RPC_USER_CONFIG" "${OPENIM_ROOT}/config/" # OpenIM openim-rpc-user 配置文件路径
|
||||
def "OPENIM_RPC_USER_CONFIG" ""${OPENIM_ROOT}"/config/" # OpenIM openim-rpc-user 配置文件路径
|
||||
def "OPENIM_RPC_USER_LOG_DIR" "${LOG_STORAGE_LOCATION}/openim-rpc-user" # OpenIM openim-rpc-user 日志存储路径
|
||||
def "OPENIM_RPC_USER_LOG_LEVEL" "info" # OpenIM openim-rpc-user 日志级别
|
||||
def "OPENIM_RPC_USER_LOG_MAX_SIZE" "100" # OpenIM openim-rpc-user 日志最大大小(MB)
|
||||
|
@ -49,17 +49,17 @@
|
||||
###############################################################################
|
||||
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
source ${OPENIM_ROOT}/scripts/install/openim-msggateway.sh
|
||||
source ${OPENIM_ROOT}/scripts/install/openim-msgtransfer.sh
|
||||
source ${OPENIM_ROOT}/scripts/install/openim-push.sh
|
||||
source ${OPENIM_ROOT}/scripts/install/openim-rpc.sh
|
||||
source ${OPENIM_ROOT}/scripts/install/openim-crontask.sh
|
||||
source ${OPENIM_ROOT}/scripts/install/openim-api.sh
|
||||
source ${OPENIM_ROOT}/scripts/install/openim-man.sh
|
||||
source ${OPENIM_ROOT}/scripts/install/openim-tools.sh
|
||||
source ${OPENIM_ROOT}/scripts/install/test.sh
|
||||
source "${OPENIM_ROOT}"/scripts/install/openim-msggateway.sh
|
||||
source "${OPENIM_ROOT}"/scripts/install/openim-msgtransfer.sh
|
||||
source "${OPENIM_ROOT}"/scripts/install/openim-push.sh
|
||||
source "${OPENIM_ROOT}"/scripts/install/openim-rpc.sh
|
||||
source "${OPENIM_ROOT}"/scripts/install/openim-crontask.sh
|
||||
source "${OPENIM_ROOT}"/scripts/install/openim-api.sh
|
||||
source "${OPENIM_ROOT}"/scripts/install/openim-man.sh
|
||||
source "${OPENIM_ROOT}"/scripts/install/openim-tools.sh
|
||||
source "${OPENIM_ROOT}"/scripts/install/test.sh
|
||||
|
||||
# Detailed help function
|
||||
function openim::install::show_help() {
|
||||
|
@ -19,7 +19,7 @@ set +o nounset
|
||||
set -o pipefail
|
||||
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
SERVER_NAME="openim-api"
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
#
|
||||
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
SERVER_NAME="openim-crontask"
|
||||
|
||||
@ -68,7 +68,7 @@ EOF
|
||||
# install openim-crontask
|
||||
function openim::crontask::install()
|
||||
{
|
||||
pushd ${OPENIM_ROOT}
|
||||
pushd "${OPENIM_ROOT}"
|
||||
|
||||
# 1. Build openim-crontask
|
||||
make build BINS=${SERVER_NAME}
|
||||
|
@ -26,9 +26,9 @@
|
||||
# ./openim-man.sh openim::man::status - Check installation status
|
||||
#
|
||||
# Dependencies:
|
||||
# - Assumes there's a common.sh in "${OPENIM_ROOT}/scripts/install/"
|
||||
# - Assumes there's a common.sh in ""${OPENIM_ROOT}"/scripts/install/"
|
||||
# containing shared functions and variables.
|
||||
# - Relies on the script "${OPENIM_ROOT}/scripts/update-generated-docs.sh"
|
||||
# - Relies on the script ""${OPENIM_ROOT}"/scripts/update-generated-docs.sh"
|
||||
# to generate the man pages.
|
||||
#
|
||||
# Notes:
|
||||
@ -58,7 +58,7 @@ function openim::man::install() {
|
||||
pushd "${OPENIM_ROOT}" > /dev/null
|
||||
|
||||
# Generate man pages for each component
|
||||
"${OPENIM_ROOT}/scripts/update-generated-docs.sh"
|
||||
""${OPENIM_ROOT}"/scripts/update-generated-docs.sh"
|
||||
openim::common::sudo "cp docs/man/man1/* /usr/share/man/man1/"
|
||||
|
||||
# Verify installation status
|
||||
|
@ -21,7 +21,7 @@ set -o pipefail
|
||||
ulimit -n 200000
|
||||
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
SERVER_NAME="openim-msggateway"
|
||||
|
||||
@ -77,7 +77,7 @@ EOF
|
||||
# install openim-msggateway
|
||||
function openim::msggateway::install()
|
||||
{
|
||||
pushd ${OPENIM_ROOT}
|
||||
pushd "${OPENIM_ROOT}"
|
||||
|
||||
# 1. Build openim-msggateway
|
||||
make build BINS=${SERVER_NAME}
|
||||
|
@ -21,7 +21,7 @@ set -o pipefail
|
||||
ulimit -n 200000
|
||||
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
SERVER_NAME="openim-msgtransfer"
|
||||
|
||||
@ -91,7 +91,7 @@ EOF
|
||||
# install openim-msgtransfer
|
||||
function openim::msgtransfer::install()
|
||||
{
|
||||
pushd ${OPENIM_ROOT}
|
||||
pushd "${OPENIM_ROOT}"
|
||||
|
||||
# 1. Build openim-msgtransfer
|
||||
make build BINS=${SERVER_NAME}
|
||||
|
@ -45,7 +45,7 @@ set +o nounset
|
||||
set -o pipefail
|
||||
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
SERVER_NAME="openim-push"
|
||||
|
||||
@ -90,7 +90,7 @@ EOF
|
||||
# install openim-push
|
||||
function openim::push::install()
|
||||
{
|
||||
pushd ${OPENIM_ROOT}
|
||||
pushd "${OPENIM_ROOT}"
|
||||
|
||||
# 1. Build openim-push
|
||||
make build BINS=${SERVER_NAME}
|
||||
|
@ -44,10 +44,10 @@ set +o nounset
|
||||
set -o pipefail
|
||||
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
SERVER_NAME="openim-rpc"
|
||||
readonly OPENIM_RPC_CONFIG=${OPENIM_ROOT}/config
|
||||
readonly OPENIM_RPC_CONFIG="${OPENIM_ROOT}"/config
|
||||
|
||||
openim::rpc::service_name() {
|
||||
local targets=(
|
||||
|
@ -43,7 +43,7 @@ set +o nounset
|
||||
set -o pipefail
|
||||
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
SERVER_NAME="openim-tools"
|
||||
|
||||
|
@ -25,17 +25,17 @@ docker_compose_file_name="docker-compose.yaml"
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_env() {
|
||||
source ${OPENIM_ROOT}/.env
|
||||
source "${OPENIM_ROOT}"/.env
|
||||
}
|
||||
|
||||
# Replace local IP with public IP in .env
|
||||
replace_ip() {
|
||||
if [ "$API_URL" == "http://127.0.0.1:10002/object/" ]; then
|
||||
sed -i "s/127.0.0.1/${internet_ip}/" ${OPENIM_ROOT}/.env
|
||||
sed -i "s/127.0.0.1/${internet_ip}/" "${OPENIM_ROOT}"/.env
|
||||
fi
|
||||
|
||||
if [ "$MINIO_ENDPOINT" == "http://127.0.0.1:10005" ]; then
|
||||
sed -i "s/127.0.0.1/${internet_ip}/" ${OPENIM_ROOT}/.env
|
||||
sed -i "s/127.0.0.1/${internet_ip}/" "${OPENIM_ROOT}"/.env
|
||||
fi
|
||||
|
||||
openim::log::info "Your minio endpoint is ${MINIO_ENDPOINT}"
|
||||
@ -43,12 +43,12 @@ replace_ip() {
|
||||
|
||||
# Execute necessary scripts
|
||||
execute_scripts() {
|
||||
chmod +x ${OPENIM_ROOT}/scripts/*.sh
|
||||
chmod +x "${OPENIM_ROOT}"/scripts/*.sh
|
||||
openim::log::info "Executing init_pwd.sh"
|
||||
${OPENIM_ROOT}/scripts/init_pwd.sh
|
||||
"${OPENIM_ROOT}"/scripts/init_pwd.sh
|
||||
|
||||
openim::log::info "Executing env_check.sh"
|
||||
${OPENIM_ROOT}/scripts/env_check.sh
|
||||
"${OPENIM_ROOT}"/scripts/env_check.sh
|
||||
}
|
||||
|
||||
# Start docker compose
|
||||
@ -60,7 +60,7 @@ start_docker_compose() {
|
||||
docker compose up -d
|
||||
fi
|
||||
|
||||
${OPENIM_ROOT}/scripts/docker-check-service.sh
|
||||
"${OPENIM_ROOT}"/scripts/docker-check-service.sh
|
||||
}
|
||||
|
||||
main() {
|
||||
|
@ -55,7 +55,7 @@ openim::chat::validate() {
|
||||
# validate installed version is at least equal to minimum
|
||||
version=$(chat --version | grep Version | head -n 1 | cut -d " " -f 3)
|
||||
if [[ $(openim::chat::version "${CHAT_VERSION}") -gt $(openim::chat::version "${version}") ]]; then
|
||||
export PATH=${OPENIM_ROOT}/third_party/chat:${PATH}
|
||||
export PATH="${OPENIM_ROOT}"/third_party/chat:${PATH}
|
||||
hash chat
|
||||
echo "${PATH}"
|
||||
version=$(chat --version | grep Version | head -n 1 | cut -d " " -f 3)
|
||||
@ -148,7 +148,7 @@ openim::chat::install() {
|
||||
os=$(openim::util::host_os)
|
||||
arch=$(openim::util::host_arch)
|
||||
|
||||
cd "${OPENIM_ROOT}/third_party" || return 1
|
||||
cd ""${OPENIM_ROOT}"/third_party" || return 1
|
||||
if [[ $(readlink chat) == chat-v${CHAT_VERSION}-${os}-* ]]; then
|
||||
openim::log::info "chat v${CHAT_VERSION} already installed. To use:"
|
||||
openim::log::info "export PATH=\"$(pwd)/chat:\${PATH}\""
|
||||
|
@ -89,7 +89,7 @@ readonly OPENIM_SERVER_TARGETS
|
||||
readonly OPENIM_SERVER_BINARIES=("${OPENIM_SERVER_TARGETS[@]##*/}")
|
||||
|
||||
# TODO: Label
|
||||
START_SCRIPTS_PATH="${OPENIM_ROOT}/scripts/install/"
|
||||
START_SCRIPTS_PATH=""${OPENIM_ROOT}"/scripts/install/"
|
||||
openim::golang::start_script_list() {
|
||||
local targets=(
|
||||
openim-api.sh
|
||||
|
@ -33,7 +33,7 @@ export GO111MODULE=on
|
||||
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
|
||||
|
||||
OPENIM_OUTPUT_SUBPATH="${OPENIM_OUTPUT_SUBPATH:-_output}"
|
||||
OPENIM_OUTPUT="${OPENIM_ROOT}/${OPENIM_OUTPUT_SUBPATH}"
|
||||
OPENIM_OUTPUT=""${OPENIM_ROOT}"/${OPENIM_OUTPUT_SUBPATH}"
|
||||
|
||||
OPENIM_OUTPUT_BINPATH="${OPENIM_OUTPUT}/bin/platforms"
|
||||
OPENIM_OUTPUT_BINTOOLPATH="${OPENIM_OUTPUT}/bin/tools"
|
||||
@ -50,8 +50,8 @@ OPENIM_RSYNC_COMPRESS="${KUBE_RSYNC_COMPRESS:-0}"
|
||||
export no_proxy="127.0.0.1,localhost${no_proxy:+,${no_proxy}}"
|
||||
|
||||
# This is a symlink to binaries for "this platform", e.g. build tools.
|
||||
export THIS_PLATFORM_BIN="${OPENIM_ROOT}/_output/bin/platforms"
|
||||
export THIS_PLATFORM_BIN_TOOLS="${OPENIM_ROOT}/_output/bin/tools"
|
||||
export THIS_PLATFORM_BIN=""${OPENIM_ROOT}"/_output/bin/platforms"
|
||||
export THIS_PLATFORM_BIN_TOOLS=""${OPENIM_ROOT}"/_output/bin/tools"
|
||||
|
||||
. $(dirname ${BASH_SOURCE})/color.sh
|
||||
. $(dirname ${BASH_SOURCE})/util.sh
|
||||
|
@ -144,7 +144,7 @@ function openim::release::package_src_tarball() {
|
||||
-path "${OPENIM_ROOT}"/.config\* -o \
|
||||
-path "${OPENIM_ROOT}"/.chglog\* -o \
|
||||
-path "${OPENIM_ROOT}"/.gitlint -o \
|
||||
-path "${OPENIM_ROOT}"/scripts/golangci.yml -o \
|
||||
-path "${OPENIM_ROOT}"/.golangci.yml -o \
|
||||
-path "${OPENIM_ROOT}"/build/goreleaser.yaml -o \
|
||||
-path "${OPENIM_ROOT}"/.note.md -o \
|
||||
-path "${OPENIM_ROOT}"/.todo.md \
|
||||
@ -354,7 +354,7 @@ function openim::release::create_docker_images_for_server() {
|
||||
rm -rf "${docker_build_path}"
|
||||
mkdir -p "${docker_build_path}"
|
||||
ln "${binary_file_path}" "${docker_build_path}/${binary_name}"
|
||||
ln "${OPENIM_ROOT}/build/nsswitch.conf" "${docker_build_path}/nsswitch.conf"
|
||||
ln ""${OPENIM_ROOT}"/build/nsswitch.conf" "${docker_build_path}/nsswitch.conf"
|
||||
chmod 0644 "${docker_build_path}/nsswitch.conf"
|
||||
cat <<EOF > "${docker_file_path}"
|
||||
FROM ${base_image}
|
||||
@ -399,7 +399,7 @@ EOF
|
||||
function openim::release::package_openim_manifests_tarball() {
|
||||
openim::log::status "Building tarball: manifests"
|
||||
|
||||
local src_dir="${OPENIM_ROOT}/deployments"
|
||||
local src_dir=""${OPENIM_ROOT}"/deployments"
|
||||
|
||||
local release_stage="${RELEASE_STAGE}/manifests/openim"
|
||||
rm -rf "${release_stage}"
|
||||
@ -420,7 +420,7 @@ function openim::release::package_openim_manifests_tarball() {
|
||||
#cp "${src_dir}/openim-rpc-msg.yaml" "${dst_dir}"
|
||||
#cp "${src_dir}/openim-rpc-third.yaml" "${dst_dir}"
|
||||
#cp "${src_dir}/openim-rpc-user.yaml" "${dst_dir}"
|
||||
#cp "${OPENIM_ROOT}/cluster/gce/gci/health-monitor.sh" "${dst_dir}/health-monitor.sh"
|
||||
#cp ""${OPENIM_ROOT}"/cluster/gce/gci/health-monitor.sh" "${dst_dir}/health-monitor.sh"
|
||||
|
||||
openim::release::clean_cruft
|
||||
|
||||
@ -454,7 +454,7 @@ EOF
|
||||
|
||||
# We want everything in /scripts.
|
||||
mkdir -p "${release_stage}/release"
|
||||
cp -R "${OPENIM_ROOT}/scripts/release" "${release_stage}/"
|
||||
cp -R ""${OPENIM_ROOT}"/scripts/release" "${release_stage}/"
|
||||
cat <<EOF > "${release_stage}/release/get-openim-binaries.sh"
|
||||
#!/usr/bin/env bash
|
||||
# This file download openim client and server binaries from tencent cos bucket.
|
||||
@ -473,9 +473,9 @@ EOF
|
||||
|
||||
# Include hack/lib as a dependency for the cluster/ scripts
|
||||
#mkdir -p "${release_stage}/hack"
|
||||
#cp -R "${OPENIM_ROOT}/hack/lib" "${release_stage}/hack/"
|
||||
#cp -R ""${OPENIM_ROOT}"/hack/lib" "${release_stage}/hack/"
|
||||
|
||||
cp -R ${OPENIM_ROOT}/{docs,configs,scripts,deployments,init,README.md,LICENSE} "${release_stage}/"
|
||||
cp -R "${OPENIM_ROOT}"/{docs,configs,scripts,deployments,init,README.md,LICENSE} "${release_stage}/"
|
||||
|
||||
echo "${OPENIM_GIT_VERSION}" > "${release_stage}/version"
|
||||
|
||||
@ -613,10 +613,10 @@ function openim::release::github_release() {
|
||||
function openim::release::generate_changelog() {
|
||||
openim::log::info "generate CHANGELOG-${OPENIM_GIT_VERSION#v}.md and commit it"
|
||||
|
||||
git-chglog ${OPENIM_GIT_VERSION} > ${OPENIM_ROOT}/CHANGELOG/CHANGELOG-${OPENIM_GIT_VERSION#v}.md
|
||||
git-chglog ${OPENIM_GIT_VERSION} > "${OPENIM_ROOT}"/CHANGELOG/CHANGELOG-${OPENIM_GIT_VERSION#v}.md
|
||||
|
||||
set +o errexit
|
||||
git add ${OPENIM_ROOT}/CHANGELOG/CHANGELOG-${OPENIM_GIT_VERSION#v}.md
|
||||
git add "${OPENIM_ROOT}"/CHANGELOG/CHANGELOG-${OPENIM_GIT_VERSION#v}.md
|
||||
git commit -a -m "docs(changelog): add CHANGELOG-${OPENIM_GIT_VERSION#v}.md"
|
||||
git push -f origin main # 最后将 CHANGELOG 也 push 上去
|
||||
}
|
||||
|
@ -529,11 +529,11 @@ openim::util::find-binary-for-platform() {
|
||||
local -r lookfor="$1"
|
||||
local -r platform="$2"
|
||||
local locations=(
|
||||
"${OPENIM_ROOT}/_output/bin/${lookfor}"
|
||||
"${OPENIM_ROOT}/_output/${platform}/${lookfor}"
|
||||
"${OPENIM_ROOT}/_output/local/bin/${platform}/${lookfor}"
|
||||
"${OPENIM_ROOT}/_output/platforms/${platform}/${lookfor}"
|
||||
"${OPENIM_ROOT}/_output/platforms/bin/${platform}/${lookfor}"
|
||||
""${OPENIM_ROOT}"/_output/bin/${lookfor}"
|
||||
""${OPENIM_ROOT}"/_output/${platform}/${lookfor}"
|
||||
""${OPENIM_ROOT}"/_output/local/bin/${platform}/${lookfor}"
|
||||
""${OPENIM_ROOT}"/_output/platforms/${platform}/${lookfor}"
|
||||
""${OPENIM_ROOT}"/_output/platforms/bin/${platform}/${lookfor}"
|
||||
)
|
||||
|
||||
# List most recently-updated location.
|
||||
@ -610,11 +610,11 @@ openim::util::gen-docs() {
|
||||
# Removes previously generated docs-- we don't want to check them in. $OPENIM_ROOT
|
||||
# must be set.
|
||||
openim::util::remove-gen-docs() {
|
||||
if [ -e "${OPENIM_ROOT}/docs/.generated_docs" ]; then
|
||||
if [ -e ""${OPENIM_ROOT}"/docs/.generated_docs" ]; then
|
||||
# remove all of the old docs; we don't want to check them in.
|
||||
while read -r file; do
|
||||
rm "${OPENIM_ROOT}/${file}" 2>/dev/null || true
|
||||
done <"${OPENIM_ROOT}/docs/.generated_docs"
|
||||
rm ""${OPENIM_ROOT}"/${file}" 2>/dev/null || true
|
||||
done <""${OPENIM_ROOT}"/docs/.generated_docs"
|
||||
# The docs/.generated_docs file lists itself, so we don't need to explicitly
|
||||
# delete it.
|
||||
fi
|
||||
@ -1212,9 +1212,7 @@ function openim::util::get_server_ip() {
|
||||
}
|
||||
|
||||
function openim::util::onCtrlC() {
|
||||
kill -9 "${do_sth_pid}" "${progress_pid}" "${countdown_pid}"
|
||||
echo
|
||||
echo 'Ctrl+C is captured'
|
||||
echo -e "\n${t_reset}Ctrl+C Press it. It's exiting openim make init..."
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,12 @@ go.check:
|
||||
@echo "===========> Checking openim"
|
||||
@$(ROOT_DIR)/scripts/check-all.sh
|
||||
|
||||
## go.check-component: Check openim component
|
||||
.PHONY: go.check-component
|
||||
go.check-component:
|
||||
@echo "===========> Checking openim component"
|
||||
@$(ROOT_DIR)/scripts/install/openim-tools.sh openim::tools::pre-start
|
||||
|
||||
## go.build.verify: Verify that a suitable version of Go exists
|
||||
.PHONY: go.build.verify
|
||||
go.build.verify:
|
||||
@ -166,7 +172,7 @@ go.build.multiarch: go.build.verify $(foreach p,$(PLATFORMS),$(addprefix go.buil
|
||||
.PHONY: go.lint
|
||||
go.lint: tools.verify.golangci-lint
|
||||
@echo "===========> Run golangci to lint source codes"
|
||||
@$(TOOLS_DIR)/golangci-lint run --color always -c $(ROOT_DIR)/scripts/golangci.yml $(ROOT_DIR)/...
|
||||
@$(TOOLS_DIR)/golangci-lint run --color always -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/...
|
||||
|
||||
## go.test: Run unit test
|
||||
.PHONY: go.test
|
||||
|
@ -26,7 +26,7 @@ set +o errexit
|
||||
openim::golang::check_openim_binaries
|
||||
if [[ $? -ne 0 ]]; then
|
||||
openim::log::error "OpenIM binaries are not found. Please run 'make build' to build binaries."
|
||||
${OPENIM_ROOT}/scripts/build-all-service.sh
|
||||
"${OPENIM_ROOT}"/scripts/build-all-service.sh
|
||||
fi
|
||||
set -o errexit
|
||||
|
||||
@ -71,4 +71,6 @@ ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start
|
||||
|
||||
execute_scripts
|
||||
|
||||
${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start
|
||||
${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start
|
||||
|
||||
openim::log::success "✨ All OpenIM services have been successfully started!"
|
@ -113,7 +113,7 @@ if ${HAVE_SHELLCHECK}; then
|
||||
else
|
||||
openim::log::info "Using shellcheck ${SHELLCHECK_VERSION} docker image."
|
||||
"${DOCKER}" run \
|
||||
--rm -v "${OPENIM_ROOT}:${OPENIM_ROOT}" -w "${OPENIM_ROOT}" \
|
||||
--rm -v ""${OPENIM_ROOT}":"${OPENIM_ROOT}"" -w "${OPENIM_ROOT}" \
|
||||
"${SHELLCHECK_IMAGE}" \
|
||||
shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" >&2 || res=$?
|
||||
fi
|
||||
|
@ -30,12 +30,12 @@ export GOBIN="${KUBE_OUTPUT_BINPATH}"
|
||||
PATH="${GOBIN}:${PATH}"
|
||||
|
||||
# Install tools we need
|
||||
pushd "${OPENIM_ROOT}/tools" >/dev/null
|
||||
pushd ""${OPENIM_ROOT}"/tools" >/dev/null
|
||||
GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
|
||||
popd >/dev/null
|
||||
|
||||
# Spell checking
|
||||
# All the skipping files are defined in scripts/.spelling_failures
|
||||
skipping_file="${OPENIM_ROOT}/scripts/.spelling_failures"
|
||||
skipping_file=""${OPENIM_ROOT}"/scripts/.spelling_failures"
|
||||
failing_packages=$(sed "s| | -e |g" "${skipping_file}")
|
||||
git ls-files | grep -v -e "${failing_packages}" | xargs misspell -i "Creater,creater,ect" -error -o stderr
|
||||
|
@ -317,4 +317,4 @@ func main() {
|
||||
if failed {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,4 +118,4 @@ func TestDedup(t *testing.T) {
|
||||
i, tc.input, out, tc.expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -305,4 +305,4 @@ func upstreamLinkify(line string) string {
|
||||
return fmt.Sprintf("UPSTREAM: [%s#%s](https://github.com/%s/pull/%s):%s", m[1], m[2], m[1], m[2], m[3])
|
||||
}
|
||||
return line
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,5 @@ func main() {
|
||||
// openim-rpc-user
|
||||
switch module {
|
||||
case "openim-api":
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ import (
|
||||
|
||||
// profiling configuration variables
|
||||
var (
|
||||
profileName string = "none" // Name of the profile to capture.
|
||||
profileOutput string = "profile.pprof" // File to write the profile data.
|
||||
profileName string = "none" // Name of the profile to capture.
|
||||
profileOutput string = "profile.pprof" // File to write the profile data.
|
||||
)
|
||||
|
||||
// addProfilingFlags registers profiling related flags to the given FlagSet.
|
||||
@ -41,8 +41,8 @@ func addProfilingFlags(flags *pflag.FlagSet) {
|
||||
flags.StringVar(&profileOutput, "profile-output", "profile.pprof", "File to write the profile data")
|
||||
}
|
||||
|
||||
// initProfiling sets up profiling based on the user's choice.
|
||||
// If 'cpu' is selected, it starts the CPU profile. For block and mutex profiles,
|
||||
// initProfiling sets up profiling based on the user's choice.
|
||||
// If 'cpu' is selected, it starts the CPU profile. For block and mutex profiles,
|
||||
// sampling rates are set up.
|
||||
func initProfiling() error {
|
||||
switch profileName {
|
||||
@ -55,10 +55,10 @@ func initProfiling() error {
|
||||
}
|
||||
return pprof.StartCPUProfile(f)
|
||||
case "block":
|
||||
runtime.SetBlockProfileRate(1) // Sampling every block event
|
||||
runtime.SetBlockProfileRate(1) // Sampling every block event
|
||||
return nil
|
||||
case "mutex":
|
||||
runtime.SetMutexProfileFraction(1) // Sampling every mutex event
|
||||
runtime.SetMutexProfileFraction(1) // Sampling every mutex event
|
||||
return nil
|
||||
default:
|
||||
if profile := pprof.Lookup(profileName); profile == nil {
|
||||
@ -68,8 +68,8 @@ func initProfiling() error {
|
||||
}
|
||||
}
|
||||
|
||||
// flushProfiling writes the profiling data to the specified file.
|
||||
// For heap profiles, it runs the GC before capturing the data.
|
||||
// flushProfiling writes the profiling data to the specified file.
|
||||
// For heap profiles, it runs the GC before capturing the data.
|
||||
// It stops the CPU profile if it was started.
|
||||
func flushProfiling() error {
|
||||
switch profileName {
|
||||
|
@ -69,4 +69,4 @@ func streamYaml(writer io.Writer, indent *int, in *yaml.Node) error {
|
||||
return err
|
||||
}
|
||||
return encoder.Close()
|
||||
}
|
||||
}
|
||||
|
@ -70,12 +70,12 @@ func Test_fetchYaml(t *testing.T) {
|
||||
Tag: "!!map",
|
||||
Value: "",
|
||||
Content: []*yaml.Node{
|
||||
&yaml.Node{
|
||||
{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: "!!str",
|
||||
Value: "key",
|
||||
},
|
||||
&yaml.Node{
|
||||
{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: "!!str",
|
||||
Value: "value",
|
||||
@ -126,12 +126,12 @@ func Test_streamYaml(t *testing.T) {
|
||||
Tag: "!!map",
|
||||
Value: "",
|
||||
Content: []*yaml.Node{
|
||||
&yaml.Node{
|
||||
{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: "!!str",
|
||||
Value: "key",
|
||||
},
|
||||
&yaml.Node{
|
||||
{
|
||||
Kind: yaml.ScalarNode,
|
||||
Tag: "!!str",
|
||||
Value: "value",
|
||||
|
Loading…
x
Reference in New Issue
Block a user