Compare commits
156 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| db081e6a4c | |||
| 6b0a2c9464 | |||
| 775aba52bd | |||
| e1770173ef | |||
| c73ce45e9e | |||
| 7aefb7fa2b | |||
| baece7eb3a | |||
| 1b31a07b40 | |||
| 83ba487c61 | |||
| 8dc0b639a2 | |||
| 9a636a15de | |||
| 7b12a8755a | |||
| b67c244bbd | |||
| 0bd2c00088 | |||
| cb1487109a | |||
| c9d8625274 | |||
| d0b659ccea | |||
| c182001fcf | |||
| c8038213c7 | |||
| 40a7bb9d48 | |||
| 7e48d1a00f | |||
| a64e5a776a | |||
| 9dc798bc53 | |||
| c6ea841064 | |||
| 0e03c5f89e | |||
| 70502685ce | |||
| a2fe6ffc7a | |||
| 1c724aa89b | |||
| 5d307c16b4 | |||
| 96c264981e | |||
| 60c507ff10 | |||
| 33ee58904b | |||
| 0938b11f83 | |||
| c0d633bc34 | |||
| 7a9506f616 | |||
| 36afd67a2c | |||
| 59d1090a6d | |||
| f384bb2aff | |||
| 4411ba3482 | |||
| 379118e481 | |||
| 661b1a5e6a | |||
| fd2d5252c5 | |||
| 284e89d410 | |||
| d7a649f699 | |||
| c758628701 | |||
| 28614e4c13 | |||
| beb9a37649 | |||
| 0e9810e9ff | |||
| 0c5cec8413 | |||
| 6135ce0919 | |||
| fdd765f982 | |||
| 529821475e | |||
| f2b21cbce6 | |||
| 061ee3abd2 | |||
| e2c53754b5 | |||
| f328ebc300 | |||
| 135c2c36aa | |||
| 16cf98213c | |||
| 094911bab2 | |||
| 6ee90b60c3 | |||
| c80b625977 | |||
| cc4ae8648e | |||
| 4f7eead38c | |||
| 386a99edbd | |||
| 982506c2fb | |||
| 5767a0fadc | |||
| a01fec538e | |||
| d451c36b2d | |||
| 0ae8433436 | |||
| 863c90e8bd | |||
| 396a87ab71 | |||
| a60b584dca | |||
| 3cb3b6ba2d | |||
| 16fbf7c63e | |||
| b980c9e751 | |||
| 127d45abc9 | |||
| e99f441e50 | |||
| 186cfa7226 | |||
| 7627ebed5c | |||
| 1be159b47c | |||
| 4e3ab62f6c | |||
| 85cb95602d | |||
| ff917466eb | |||
| 1235715c22 | |||
| 1393e40eb9 | |||
| 442c838bda | |||
| ea5039d2ae | |||
| 8f2e9f5261 | |||
| e1147aff9e | |||
| f9b39e91ee | |||
| 4bf73b0a47 | |||
| 05ee20613b | |||
| 286163ce18 | |||
| f0976c9ade | |||
| 1ab7660f0d | |||
| 84c7b8827e | |||
| 5e1aa43793 | |||
| a9b71e5a96 | |||
| 08ed131e19 | |||
| 85e3a81419 | |||
| 818ed107c6 | |||
| 4f322254b0 | |||
| decd6a98be | |||
| 5ae35bfee1 | |||
| a6ba349cb6 | |||
| 3e3818d4b5 | |||
| 6661c5baac | |||
| e813016402 | |||
| 924aa8ecb5 | |||
| 64edd9b7ea | |||
| 4400423fca | |||
| 0554778c83 | |||
| 2bc6d77d10 | |||
| 7ac790e4d0 | |||
| 0732fe6171 | |||
| d7b3ea0a6e | |||
| 0a2b6605d7 | |||
| f559795ba3 | |||
| 6b8b5f7896 | |||
| 1bf4fa0d87 | |||
| d53507b7b6 | |||
| 787bfccc2c | |||
| 955bfe3f40 | |||
| 78d7588af7 | |||
| bbde362570 | |||
| 972dd5f531 | |||
| 464320a3ec | |||
| 2aa49f080e | |||
| 9dac12cf2b | |||
| d1f3266383 | |||
| 1e2a60c802 | |||
| ee9c3cbde3 | |||
| 235be5da0c | |||
| 29adb5de07 | |||
| 4618bf990d | |||
| 0a57830925 | |||
| 71a2090363 | |||
| e420871e1f | |||
| 01b2de80ae | |||
| cdd86349d0 | |||
| 45293152bb | |||
| 7bf7686314 | |||
| 5888dc3b5d | |||
| 3d9355848b | |||
| 7033b603ca | |||
| 71ad683614 | |||
| 1fdc4d06d1 | |||
| cff9ee39be | |||
| 458f872fe3 | |||
| ac99da044a | |||
| a6bd8e5205 | |||
| f9fdd540f9 | |||
| 1706f5df07 | |||
| 40fc3e6c08 | |||
| 2608ae58df | |||
| 0e62deed0a |
+396
-15
@@ -1,22 +1,403 @@
|
|||||||
bin
|
# Copyright © 2023 OpenIMSDK.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# For the entire design of.gitignore, ignore git commits and ignore files
|
||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
|
||||||
|
### OpenIM developer supplement ###
|
||||||
logs
|
logs
|
||||||
.devcontainer
|
.devcontainer
|
||||||
components
|
components
|
||||||
logs
|
|
||||||
out-test
|
out-test
|
||||||
.github
|
Dockerfile.cross
|
||||||
.idea
|
|
||||||
|
|
||||||
|
### Makefile ###
|
||||||
|
tmp/
|
||||||
|
bin/
|
||||||
|
output/
|
||||||
|
_output/
|
||||||
|
|
||||||
deploy/open_im_demo
|
### OpenIM Config ###
|
||||||
deploy/open_im_api
|
config/config.yaml
|
||||||
deploy/open_im_msg_gateway
|
./config/config.yaml
|
||||||
deploy/open_im_msg_transfer
|
.env
|
||||||
deploy/open_im_push
|
./.env
|
||||||
deploy/open_im_timer_task
|
|
||||||
deploy/open_im_rpc_user
|
### OpenIM deploy ###
|
||||||
deploy/open_im_rpc_friend
|
deploy/openim_demo
|
||||||
deploy/open_im_rpc_group
|
deploy/openim-api
|
||||||
deploy/open_im_rpc_msg
|
deploy/openim-rpc-msg_gateway
|
||||||
deploy/open_im_rpc_auth
|
deploy/openim-msgtransfer
|
||||||
|
deploy/openim-push
|
||||||
|
deploy/openim_timer_task
|
||||||
|
deploy/openim-rpc-user
|
||||||
|
deploy/openim-rpc-friend
|
||||||
|
deploy/openim-rpc-group
|
||||||
|
deploy/openim-rpc-msg
|
||||||
|
deploy/openim-rpc-auth
|
||||||
deploy/Open-IM-SDK-Core
|
deploy/Open-IM-SDK-Core
|
||||||
|
|
||||||
|
# files used by the developer
|
||||||
|
.idea.md
|
||||||
|
.todo.md
|
||||||
|
.note.md
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/go,git,vim,tags,test,emacs,backup,jetbrains
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=go,git,vim,tags,test,emacs,backup,jetbrains
|
||||||
|
|
||||||
|
### Backup ###
|
||||||
|
*.bak
|
||||||
|
*.gho
|
||||||
|
*.ori
|
||||||
|
*.orig
|
||||||
|
*.tmp
|
||||||
|
|
||||||
|
### Emacs ###
|
||||||
|
# -*- mode: gitignore; -*-
|
||||||
|
*~
|
||||||
|
\#*\#
|
||||||
|
/.emacs.desktop
|
||||||
|
/.emacs.desktop.lock
|
||||||
|
*.elc
|
||||||
|
auto-save-list
|
||||||
|
tramp
|
||||||
|
.\#*
|
||||||
|
|
||||||
|
# Org-mode
|
||||||
|
.org-id-locations
|
||||||
|
*_archive
|
||||||
|
|
||||||
|
# flymake-mode
|
||||||
|
*_flymake.*
|
||||||
|
|
||||||
|
# eshell files
|
||||||
|
/eshell/history
|
||||||
|
/eshell/lastdir
|
||||||
|
|
||||||
|
# elpa packages
|
||||||
|
/elpa/
|
||||||
|
|
||||||
|
# reftex files
|
||||||
|
*.rel
|
||||||
|
|
||||||
|
# AUCTeX auto folder
|
||||||
|
/auto/
|
||||||
|
|
||||||
|
# cask packages
|
||||||
|
.cask/
|
||||||
|
dist/
|
||||||
|
|
||||||
|
# Flycheck
|
||||||
|
flycheck_*.el
|
||||||
|
|
||||||
|
# server auth directory
|
||||||
|
/server/
|
||||||
|
|
||||||
|
# projectiles files
|
||||||
|
.projectile
|
||||||
|
|
||||||
|
# directory configuration
|
||||||
|
.dir-locals.el
|
||||||
|
|
||||||
|
# network security
|
||||||
|
/network-security.data
|
||||||
|
|
||||||
|
### vscode ###
|
||||||
|
.vscode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/vim,jetbrains,vscode,git,go,tags,backup,test
|
||||||
|
|
||||||
|
### Git ###
|
||||||
|
# Created by git for backups. To disable backups in Git:
|
||||||
|
# $ git config --global mergetool.keepBackup false
|
||||||
|
|
||||||
|
# Created by git when using merge tools for conflicts
|
||||||
|
*.BACKUP.*
|
||||||
|
*.BASE.*
|
||||||
|
*.LOCAL.*
|
||||||
|
*.REMOTE.*
|
||||||
|
*_BACKUP_*.txt
|
||||||
|
*_BASE_*.txt
|
||||||
|
*_LOCAL_*.txt
|
||||||
|
*_REMOTE_*.txt
|
||||||
|
|
||||||
|
### Go ###
|
||||||
|
# If you prefer the allow list template instead of the deny list, see community template:
|
||||||
|
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||||
|
#
|
||||||
|
# Binaries for programs and plugins
|
||||||
|
*.exe
|
||||||
|
*.exe~
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Test binary, built with `go test -c`
|
||||||
|
*.test
|
||||||
|
|
||||||
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
|
*.out
|
||||||
|
|
||||||
|
# Dependency directories (remove the comment below to include it)
|
||||||
|
vendor/
|
||||||
|
|
||||||
|
# Go workspace file
|
||||||
|
# go.work
|
||||||
|
go.work.sum
|
||||||
|
|
||||||
|
### JetBrains ###
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# AWS User-specific
|
||||||
|
.idea/**/aws.xml
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/artifacts
|
||||||
|
# .idea/compiler.xml
|
||||||
|
# .idea/jarRepositories.xml
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# SonarLint plugin
|
||||||
|
.idea/sonarlint/
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
### JetBrains Patch ###
|
||||||
|
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||||
|
|
||||||
|
# *.iml
|
||||||
|
# modules.xml
|
||||||
|
# .idea/misc.xml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# Sonarlint plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
||||||
|
.idea/**/sonarlint/
|
||||||
|
|
||||||
|
# SonarQube Plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
||||||
|
.idea/**/sonarIssues.xml
|
||||||
|
|
||||||
|
# Markdown Navigator plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
||||||
|
.idea/**/markdown-navigator.xml
|
||||||
|
.idea/**/markdown-navigator-enh.xml
|
||||||
|
.idea/**/markdown-navigator/
|
||||||
|
|
||||||
|
# Cache file creation bug
|
||||||
|
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
||||||
|
.idea/$CACHE_FILE$
|
||||||
|
|
||||||
|
# CodeStream plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/12206-codestream
|
||||||
|
.idea/codestream.xml
|
||||||
|
|
||||||
|
# Azure Toolkit for IntelliJ plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
|
||||||
|
.idea/**/azureSettings.xml
|
||||||
|
|
||||||
|
### Tags ###
|
||||||
|
# Ignore tags created by etags, ctags, gtags (GNU global) and cscope
|
||||||
|
TAGS
|
||||||
|
.TAGS
|
||||||
|
!TAGS/
|
||||||
|
tags
|
||||||
|
.tags
|
||||||
|
!tags/
|
||||||
|
gtags.files
|
||||||
|
GTAGS
|
||||||
|
GRTAGS
|
||||||
|
GPATH
|
||||||
|
GSYMS
|
||||||
|
cscope.files
|
||||||
|
cscope.out
|
||||||
|
cscope.in.out
|
||||||
|
cscope.po.out
|
||||||
|
|
||||||
|
|
||||||
|
### Test ###
|
||||||
|
### Ignore all files that could be used to test your code and
|
||||||
|
### you wouldn't want to push
|
||||||
|
|
||||||
|
# Reference https://en.wikipedia.org/wiki/Metasyntactic_variable
|
||||||
|
|
||||||
|
# Most common
|
||||||
|
*foo
|
||||||
|
*bar
|
||||||
|
*fubar
|
||||||
|
*foobar
|
||||||
|
*baz
|
||||||
|
|
||||||
|
# Less common
|
||||||
|
*qux
|
||||||
|
*quux
|
||||||
|
*bongo
|
||||||
|
*bazola
|
||||||
|
*ztesch
|
||||||
|
|
||||||
|
# UK, Australia
|
||||||
|
*wibble
|
||||||
|
*wobble
|
||||||
|
*wubble
|
||||||
|
*flob
|
||||||
|
*blep
|
||||||
|
*blah
|
||||||
|
*boop
|
||||||
|
*beep
|
||||||
|
|
||||||
|
# Japanese
|
||||||
|
*hoge
|
||||||
|
*piyo
|
||||||
|
*fuga
|
||||||
|
*hogera
|
||||||
|
*hogehoge
|
||||||
|
|
||||||
|
# Portugal, Spain
|
||||||
|
*fulano
|
||||||
|
*sicrano
|
||||||
|
*beltrano
|
||||||
|
*mengano
|
||||||
|
*perengano
|
||||||
|
*zutano
|
||||||
|
|
||||||
|
# France, Italy, the Netherlands
|
||||||
|
*toto
|
||||||
|
*titi
|
||||||
|
*tata
|
||||||
|
*tutu
|
||||||
|
*pipppo
|
||||||
|
*pluto
|
||||||
|
*paperino
|
||||||
|
*aap
|
||||||
|
*noot
|
||||||
|
*mies
|
||||||
|
|
||||||
|
# Other names that would make sense
|
||||||
|
*tests
|
||||||
|
*testsdir
|
||||||
|
*testsfile
|
||||||
|
*testsfiles
|
||||||
|
*testdir
|
||||||
|
*testfile
|
||||||
|
*testfiles
|
||||||
|
*testing
|
||||||
|
*testingdir
|
||||||
|
*testingfile
|
||||||
|
*testingfiles
|
||||||
|
*temp
|
||||||
|
*tempdir
|
||||||
|
*tempfile
|
||||||
|
*tempfiles
|
||||||
|
*tmp
|
||||||
|
*tmpdir
|
||||||
|
*tmpfile
|
||||||
|
*tmpfiles
|
||||||
|
*lol
|
||||||
|
|
||||||
|
### Vim ###
|
||||||
|
# Swap
|
||||||
|
[._]*.s[a-v][a-z]
|
||||||
|
!*.svg # comment out if you don't need vector files
|
||||||
|
[._]*.sw[a-p]
|
||||||
|
[._]s[a-rt-v][a-z]
|
||||||
|
[._]ss[a-gi-z]
|
||||||
|
[._]sw[a-p]
|
||||||
|
|
||||||
|
# Session
|
||||||
|
Session.vim
|
||||||
|
Sessionx.vim
|
||||||
|
|
||||||
|
# Temporary
|
||||||
|
.netrwhist
|
||||||
|
# Auto-generated tag files
|
||||||
|
# Persistent undo
|
||||||
|
[._]*.un~
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/go,git,vim,tags,test,emacs,backup,jetbrains
|
||||||
|
.idea
|
||||||
|
dist/
|
||||||
|
.env
|
||||||
|
config/config.yaml
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ By deployment of the Open-IM-Server on the customer's server, developers can int
|
|||||||
- Supports multiple protocols
|
- Supports multiple protocols
|
||||||
|
|
||||||
## Community
|
## Community
|
||||||
|
|
||||||
- Join Slack Community : https://join.slack.com/t/openimcommunity/shared_invite/zt-1jo5m1wm9-ym2qj0LUU5UbO68L6Z1zQg
|
|
||||||
- 中文官网访问这里:[Open-IM中文开发文档](https://doc.rentsoft.cn/)
|
- 中文官网访问这里:[Open-IM中文开发文档](https://doc.rentsoft.cn/)
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|||||||
+1
-1
Submodule cmd/Open-IM-SDK-Core updated: 1667b0f4e2...e731cb86ec
@@ -1,13 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_api
|
NAME=open_im_api
|
||||||
BIN_DIR=../../bin/
|
BIN_DIR=../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -16,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ func main() {
|
|||||||
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
||||||
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
||||||
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
||||||
|
//only for supergroup
|
||||||
|
groupRouterGroup.POST("/invite_user_to_groups", group.InviteUserToGroups)
|
||||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList)
|
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList)
|
||||||
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
|
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
|
||||||
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
|
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
|
||||||
@@ -175,8 +177,10 @@ func main() {
|
|||||||
conversationGroup.POST("/get_all_conversations", conversation.GetAllConversations)
|
conversationGroup.POST("/get_all_conversations", conversation.GetAllConversations)
|
||||||
conversationGroup.POST("/get_conversation", conversation.GetConversation)
|
conversationGroup.POST("/get_conversation", conversation.GetConversation)
|
||||||
conversationGroup.POST("/get_conversations", conversation.GetConversations)
|
conversationGroup.POST("/get_conversations", conversation.GetConversations)
|
||||||
|
//deprecated
|
||||||
conversationGroup.POST("/set_conversation", conversation.SetConversation)
|
conversationGroup.POST("/set_conversation", conversation.SetConversation)
|
||||||
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
||||||
|
//deprecated
|
||||||
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
||||||
conversationGroup.POST("/modify_conversation_field", conversation.ModifyConversationField)
|
conversationGroup.POST("/modify_conversation_field", conversation.ModifyConversationField)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_cms_api
|
NAME=open_im_cms_api
|
||||||
BIN_DIR=../../bin/
|
BIN_DIR=../../bin/
|
||||||
|
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -16,8 +28,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_cron_task
|
NAME=open_im_cron_task
|
||||||
BIN_DIR=../../bin/
|
BIN_DIR=../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_demo
|
NAME=open_im_demo
|
||||||
BIN_DIR=../../bin/
|
BIN_DIR=../../bin/
|
||||||
|
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -16,8 +28,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_msg_gateway
|
NAME=open_im_msg_gateway
|
||||||
BIN_DIR=../../bin/
|
BIN_DIR=../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_msg_transfer
|
NAME=open_im_msg_transfer
|
||||||
BIN_DIR=../../bin/
|
BIN_DIR=../../bin/
|
||||||
|
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -16,8 +28,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_push
|
NAME=open_im_push
|
||||||
BIN_DIR=../../bin/
|
BIN_DIR=../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_admin_cms
|
NAME=open_im_admin_cms
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_auth
|
NAME=open_im_auth
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_cache
|
NAME=open_im_cache
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_conversation
|
NAME=open_im_conversation
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ func main() {
|
|||||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcConversation default listen port 11300")
|
rpcPort := flag.Int("port", defaultPorts[0], "RpcConversation default listen port 11300")
|
||||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.ConversationPrometheusPort[0], "conversationPrometheusPort default listen port")
|
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.ConversationPrometheusPort[0], "conversationPrometheusPort default listen port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start conversation rpc server, port: ", *rpcPort, ", OpenIM version: ", constant.CurrentVersion, "\n")
|
fmt.Println("start conversation rpc server, port: ", *rpcPort, ", OpenIM version: ", constant.CurrentVersion)
|
||||||
rpcServer := rpcConversation.NewRpcConversationServer(*rpcPort)
|
rpcServer := rpcConversation.NewRpcConversationServer(*rpcPort)
|
||||||
go func() {
|
go func() {
|
||||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||||
|
|||||||
@@ -1,12 +1,25 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_friend
|
NAME=open_im_friend
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +28,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,25 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_group
|
NAME=open_im_group
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +28,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_msg
|
NAME=open_im_msg
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_office
|
NAME=open_im_office
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_organization
|
NAME=open_im_organization
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_user
|
NAME=open_im_user
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../../bin/
|
||||||
|
|
||||||
|
OS:= $(or $(os),linux)
|
||||||
|
ARCH:=$(or $(arch),amd64)
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
|
ifeq ($(OS),windows)
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
BINARY_NAME=${NAME}
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-w -s"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -15,8 +27,7 @@ gotool:
|
|||||||
go fmt ./
|
go fmt ./
|
||||||
go vet ./
|
go vet ./
|
||||||
|
|
||||||
install:
|
install:build
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
mv ${BINARY_NAME} ${BIN_DIR}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
+61
-51
@@ -36,7 +36,7 @@ mongo:
|
|||||||
dbPassword: #mongo密码,建议先不设置
|
dbPassword: #mongo密码,建议先不设置
|
||||||
dbMaxPoolSize: 100
|
dbMaxPoolSize: 100
|
||||||
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
||||||
chatRecordsClearTime: "* * * * *" # 每天凌晨3点清除消息,该配置和linux定时任务一样, 清理操作建议设置在用户活跃少的时候 # 0 3 * * *
|
chatRecordsClearTime: "0 3 * * *" # 每天凌晨3点清除消息,该配置和linux定时任务一样, 清理操作建议设置在用户活跃少的时候 # 0 3 * * *
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
dbAddress: [ 127.0.0.1:16379 ] #redis地址 单机时,填写一个地址即可,使用redis集群时候,填写集群中多个节点地址(主从地址都可以填写,增加容灾能力),默认即可
|
dbAddress: [ 127.0.0.1:16379 ] #redis地址 单机时,填写一个地址即可,使用redis集群时候,填写集群中多个节点地址(主从地址都可以填写,增加容灾能力),默认即可
|
||||||
@@ -115,11 +115,11 @@ sdk:
|
|||||||
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
|
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
|
||||||
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
|
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
|
||||||
tencent:
|
tencent:
|
||||||
appID: 1302656840
|
appID:
|
||||||
region: ap-chengdu
|
region:
|
||||||
bucket: echat-1302656840
|
bucket:
|
||||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC1
|
secretID:
|
||||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe1
|
secretKey:
|
||||||
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
|
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
|
||||||
bucket: openim # 存储内容桶
|
bucket: openim # 存储内容桶
|
||||||
appBucket: app # 存储app的桶
|
appBucket: app # 存储app的桶
|
||||||
@@ -132,24 +132,24 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
|||||||
storageTime: 50 #文件在minio中保存的时间
|
storageTime: 50 #文件在minio中保存的时间
|
||||||
isDistributedMod: false # 是否分布式多硬盘部署 默认docker-compose中为false
|
isDistributedMod: false # 是否分布式多硬盘部署 默认docker-compose中为false
|
||||||
ali: # ali oss
|
ali: # ali oss
|
||||||
regionID: "oss-cn-beijing"
|
regionID:
|
||||||
accessKeyID: ""
|
accessKeyID:
|
||||||
accessKeySecret: ""
|
accessKeySecret:
|
||||||
stsEndpoint: "sts.cn-beijing.aliyun.com"
|
stsEndpoint:
|
||||||
ossEndpoint: "oss-cn-beijing.aliyuncs.com"
|
ossEndpoint:
|
||||||
bucket: "bucket1"
|
bucket:
|
||||||
finalHost: "http://bucket1.oss-cn-beijing.aliyuncs.com"
|
finalHost:
|
||||||
stsDurationSeconds: 3600
|
stsDurationSeconds:
|
||||||
OssRoleArn: "acs:ram::xxx:role/xxx"
|
OssRoleArn:
|
||||||
aws:
|
aws:
|
||||||
accessKeyID: 1 #AssumeRole用户关联的accessKeyID
|
accessKeyID: #AssumeRole用户关联的accessKeyID
|
||||||
accessKeySecret: 2 #AssumeRole用户关联的accessKeySecrect
|
accessKeySecret: #AssumeRole用户关联的accessKeySecrect
|
||||||
region: ap-southeast-1 #分区
|
region: #分区
|
||||||
bucket: ouyang #桶
|
bucket: #桶
|
||||||
finalHost: ouyang.s3.ap-southeast-1.amazonaws.com #对外Host
|
finalHost: #对外Host
|
||||||
roleArn: arn:aws:iam::192209831083:role/AWS_S3_FOR_OUYANG #RoleArn
|
roleArn: #RoleArn
|
||||||
externalId: AssumeRoleExtend #角色扩展Id
|
externalId: #角色扩展Id
|
||||||
roleSessionName: Required-AWS-ID-OPENIM #角色SESSION名称
|
roleSessionName: #角色SESSION名称
|
||||||
|
|
||||||
|
|
||||||
rpcport: #rpc服务端口 默认即可
|
rpcport: #rpc服务端口 默认即可
|
||||||
@@ -216,17 +216,17 @@ longconnsvr:
|
|||||||
push:
|
push:
|
||||||
tpns: #腾讯推送,暂未测试 暂不要使用
|
tpns: #腾讯推送,暂未测试 暂不要使用
|
||||||
ios:
|
ios:
|
||||||
accessID: 1600018281
|
accessID:
|
||||||
secretKey: 3cd68a77a95b89e5089a1aca523f318f
|
secretKey:
|
||||||
android:
|
android:
|
||||||
accessID: 111
|
accessID:
|
||||||
secretKey: 111
|
secretKey:
|
||||||
enable: false # true or false (bool)
|
enable: false # true or false (bool)
|
||||||
jpns: #极光推送 在极光后台申请后,修改以下四项,必须修改
|
jpns: #极光推送 在极光后台申请后,修改以下四项,必须修改
|
||||||
appKey: cf47465a368f24c659608e7e
|
appKey:
|
||||||
masterSecret: 02204efe3f3832947a236ee5
|
masterSecret:
|
||||||
pushUrl: "https://api.jpush.cn/v3/push"
|
pushUrl:
|
||||||
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
|
pushIntent:
|
||||||
enable: false # true or false (bool)
|
enable: false # true or false (bool)
|
||||||
getui: #个推推送
|
getui: #个推推送
|
||||||
pushUrl:
|
pushUrl:
|
||||||
@@ -236,14 +236,21 @@ push:
|
|||||||
enable: # true or false (bool)
|
enable: # true or false (bool)
|
||||||
channelID: ""
|
channelID: ""
|
||||||
channelName: ""
|
channelName: ""
|
||||||
|
channel:
|
||||||
|
HW:
|
||||||
|
category:
|
||||||
|
XM:
|
||||||
|
channelID:
|
||||||
|
OPPO:
|
||||||
|
channelID:
|
||||||
fcm: #firebase cloud message 消息推送
|
fcm: #firebase cloud message 消息推送
|
||||||
serviceAccount: "openim-5c6c0-firebase-adminsdk-ppwol-8765884a78.json" #帐号文件,此处需要改修配置,并且这个文件放在 config目录下
|
serviceAccount: #帐号文件,此处需要改修配置,并且这个文件放在 config目录下
|
||||||
enable: false
|
enable: false
|
||||||
mob: #袤博推送
|
mob: #袤博推送
|
||||||
appKey: "3377f689a25" #帐号文件,此处需要改修配置,并且这个文件放在 config目录下
|
appKey: #帐号文件,此处需要改修配置,并且这个文件放在 config目录下
|
||||||
pushUrl: "https://api.push.mob.com/v3/push/createPush"
|
pushUrl:
|
||||||
scheme: "dianzhijiaunilinks://dianzhijia.com?page=rent"
|
scheme:
|
||||||
appSecret: "77b4e20e94db3a776b87d8693be23e"
|
appSecret:
|
||||||
enable: false
|
enable: false
|
||||||
|
|
||||||
|
|
||||||
@@ -311,6 +318,9 @@ callback:
|
|||||||
callbackAfterSendGroupMsg:
|
callbackAfterSendGroupMsg:
|
||||||
enable: false
|
enable: false
|
||||||
callbackTimeOut: 2
|
callbackTimeOut: 2
|
||||||
|
callbackAfterConsumeGroupMsg:
|
||||||
|
enable: false
|
||||||
|
callbackTimeOut: 2
|
||||||
callbackMsgModify:
|
callbackMsgModify:
|
||||||
enable: false
|
enable: false
|
||||||
callbackTimeOut: 2
|
callbackTimeOut: 2
|
||||||
@@ -765,18 +775,18 @@ demo:
|
|||||||
#demo对外服务端口,默认即可,需要开放此端口或做nginx转发
|
#demo对外服务端口,默认即可,需要开放此端口或做nginx转发
|
||||||
openImDemoPort: [ 10004 ]
|
openImDemoPort: [ 10004 ]
|
||||||
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,enable为true则必须修改,阿里云为默认短信验证方式
|
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,enable为true则必须修改,阿里云为默认短信验证方式
|
||||||
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe7
|
accessKeyId:
|
||||||
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV
|
accessKeySecret:
|
||||||
signName: 托云信息技术
|
signName:
|
||||||
verificationCodeTemplateCode: SMS_226810164
|
verificationCodeTemplateCode:
|
||||||
enable: false
|
enable: false
|
||||||
tencentsms: #腾讯云短信配置,在腾讯云申请成功后,修改以下选项,enable为true则必须修改
|
tencentsms: #腾讯云短信配置,在腾讯云申请成功后,修改以下选项,enable为true则必须修改
|
||||||
appID: 2400000648
|
appID:
|
||||||
region: "ap-singapore"
|
region:
|
||||||
secretID: IKIDra4JPGsFMDwQedMq42lESQBgwwgBQQAe
|
secretID:
|
||||||
secretKey: HI6fz4uUotjJdiX6QUIrAE2buxlKdgU2
|
secretKey:
|
||||||
signName: ""
|
signName:
|
||||||
verificationCodeTemplateCode: 2902877
|
verificationCodeTemplateCode:
|
||||||
enable: true
|
enable: true
|
||||||
superCode: 666666 #超级验证码,建议修改掉,收不到短信验证码时可以用此替代
|
superCode: 666666 #超级验证码,建议修改掉,收不到短信验证码时可以用此替代
|
||||||
needInvitationCode: false
|
needInvitationCode: false
|
||||||
@@ -784,11 +794,11 @@ demo:
|
|||||||
codeTTL: 60
|
codeTTL: 60
|
||||||
useSuperCode: true
|
useSuperCode: true
|
||||||
mail: #仅支持qq邮箱,具体操作参考 https://service.mail.qq.com/cgi-bin/help?subtype=1&id=28&no=1001256 必须修改
|
mail: #仅支持qq邮箱,具体操作参考 https://service.mail.qq.com/cgi-bin/help?subtype=1&id=28&no=1001256 必须修改
|
||||||
title: "openIM"
|
title:
|
||||||
senderMail: "765567899@qq.com"
|
senderMail:
|
||||||
senderAuthorizationCode: "gxyausfoevlzbfag"
|
senderAuthorizationCode:
|
||||||
smtpAddr: "smtp.qq.com"
|
smtpAddr:
|
||||||
smtpPort: 25 #需开放此端口 出口方向
|
smtpPort: #需开放此端口 出口方向
|
||||||
testDepartMentID: 001
|
testDepartMentID: 001
|
||||||
imAPIURL: http://127.0.0.1:10002
|
imAPIURL: http://127.0.0.1:10002
|
||||||
onboardProcess: false # 是否开启注册流程
|
onboardProcess: false # 是否开启注册流程
|
||||||
|
|||||||
+22
-22
@@ -79,11 +79,11 @@ cmsapi:
|
|||||||
|
|
||||||
credential:
|
credential:
|
||||||
tencent:
|
tencent:
|
||||||
appID: 1302656840
|
appID:
|
||||||
region: ap-chengdu
|
region:
|
||||||
bucket: echat-1302656840
|
bucket:
|
||||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
|
secretID:
|
||||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
|
secretKey:
|
||||||
|
|
||||||
|
|
||||||
rpcport:
|
rpcport:
|
||||||
@@ -131,16 +131,16 @@ longconnsvr:
|
|||||||
push:
|
push:
|
||||||
tpns:
|
tpns:
|
||||||
ios:
|
ios:
|
||||||
accessID: 1600018281
|
accessID:
|
||||||
secretKey: 3cd68a77a95b89e5089a1aca523f318f
|
secretKey:
|
||||||
android:
|
android:
|
||||||
accessID: 111
|
accessID:
|
||||||
secretKey: 111
|
secretKey:
|
||||||
jpns:
|
jpns:
|
||||||
appKey: cf47465a368f24c659608e7e
|
appKey:
|
||||||
masterSecret: 02204efe3f3832947a236ee5
|
masterSecret:
|
||||||
pushUrl: "https://api.jpush.cn/v3/push"
|
pushUrl:
|
||||||
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
|
pushIntent:
|
||||||
manager:
|
manager:
|
||||||
appManagerUid: ["openIM123456","openIM654321"]
|
appManagerUid: ["openIM123456","openIM654321"]
|
||||||
secrets: ["openIM1","openIM2"]
|
secrets: ["openIM1","openIM2"]
|
||||||
@@ -168,16 +168,16 @@ demoswitch: true
|
|||||||
demo:
|
demo:
|
||||||
openImDemoPort: [ 42233 ]
|
openImDemoPort: [ 42233 ]
|
||||||
alismsverify:
|
alismsverify:
|
||||||
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe71
|
accessKeyId:
|
||||||
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV1
|
accessKeySecret:
|
||||||
signName: OpenIM Corporation
|
signName:
|
||||||
verificationCodeTemplateCode: SMS_2268101641
|
verificationCodeTemplateCode:
|
||||||
superCode: 666666
|
superCode: 666666
|
||||||
mail:
|
mail:
|
||||||
title: "openIM"
|
title:
|
||||||
senderMail: "1765567899@qq.com"
|
senderMail:
|
||||||
senderAuthorizationCode: "1gxyausfoevlzbfag"
|
senderAuthorizationCode:
|
||||||
smtpAddr: "smtp.qq.com"
|
smtpAddr:
|
||||||
smtpPort: 25
|
smtpPort:
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ ADD ./open_im_admin_cms $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config", "/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config", "/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: admin-cms
|
- name: admin-cms
|
||||||
image: openim/admin_cms:v2.3.4
|
image: openim/admin_cms:v2.3.8
|
||||||
# imagePullPolicy: Always #每次启动都重新拉取镜像
|
# imagePullPolicy: Always #每次启动都重新拉取镜像
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10200
|
- containerPort: 10200
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,11 +30,13 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ ADD ./open_im_api $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: api
|
- name: api
|
||||||
image: openim/api:v2.3.4
|
image: openim/api:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10002
|
- containerPort: 10002
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,11 +30,12 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ ADD ./open_im_auth $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: auth
|
- name: auth
|
||||||
image: openim/auth:v2.3.4
|
image: openim/auth:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10160
|
- containerPort: 10160
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,10 +30,11 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
source ./path_info.cfg
|
source ./path_info.cfg
|
||||||
|
|
||||||
# images version
|
# images version
|
||||||
version=v2.3.4
|
version=v2.3.8
|
||||||
git pull
|
git pull
|
||||||
cd ../script/; ./build_all_service.sh
|
cd ../script/; ./build_all_service.sh
|
||||||
cd ../deploy_k8s/
|
cd ../deploy_k8s/
|
||||||
|
|||||||
Vendored
+2
-1
@@ -12,7 +12,8 @@ ADD ./open_im_cache $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
WORKDIR $CMDDIR
|
WORKDIR $CMDDIR
|
||||||
|
|||||||
Vendored
+6
-8
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: cache
|
- name: cache
|
||||||
image: openim/cache:v2.3.4
|
image: openim/cache:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10240
|
- containerPort: 10240
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,10 +30,11 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
@@ -11,7 +11,8 @@ ADD ./open_im_cms_api $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
WORKDIR $CMDDIR
|
WORKDIR $CMDDIR
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: cms-api
|
- name: cms-api
|
||||||
image: openim/cms_api:v2.3.4
|
image: openim/cms_api:v2.3.8
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10006
|
- containerPort: 10006
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,11 +30,12 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ ADD ./open_im_conversation $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
WORKDIR $CMDDIR
|
WORKDIR $CMDDIR
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: conversation
|
- name: conversation
|
||||||
image: openim/conversation:v2.3.4
|
image: openim/conversation:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10230
|
- containerPort: 10230
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -34,11 +31,12 @@ spec:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ ADD ./open_im_demo $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: demo
|
- name: demo
|
||||||
image: openim/demo:v2.3.4
|
image: openim/demo:v2.3.8
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10004
|
- containerPort: 10004
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,11 +30,12 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: friend
|
- name: friend
|
||||||
image: openim/friend:v2.3.4
|
image: openim/friend:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10120
|
- containerPort: 10120
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,11 +30,12 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ ADD ./open_im_friend $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
WORKDIR $CMDDIR
|
WORKDIR $CMDDIR
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: group
|
- name: group
|
||||||
image: openim/group:v2.3.4
|
image: openim/group:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10150
|
- containerPort: 10150
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,10 +30,11 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
@@ -11,7 +11,8 @@ ADD ./open_im_group $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,18 +9,17 @@
|
|||||||
6. 将rpcRegisterIP修改为空, 此地址为每个rpc注册到ETCD的地址, 置空每个rpc将会将pod地址注册到ETCD, 才能正确rpc请求(重要)
|
6. 将rpcRegisterIP修改为空, 此地址为每个rpc注册到ETCD的地址, 置空每个rpc将会将pod地址注册到ETCD, 才能正确rpc请求(重要)
|
||||||
7. 如果使用minio作为对象存储, 还需要修改minio的地址
|
7. 如果使用minio作为对象存储, 还需要修改minio的地址
|
||||||
8. 其他如果使用离线推送,需要修改push离线推送配置
|
8. 其他如果使用离线推送,需要修改push离线推送配置
|
||||||
9. 修改demo中的imAPIURL字段为openIM api的ingress或者service地址, 需要让demo的pod能正确请求到(重要)
|
|
||||||
10. 其他非必须配置修改, 如短信,推送等
|
|
||||||
|
|
||||||
### 2. 项目根目录创建im configMap到k8s openim namespace
|
### 2. 项目根目录创建im configMap到k8s openim namespace
|
||||||
1. 为open-IM项目创建单独命名空间
|
1. 为open-IM项目创建单独命名空间
|
||||||
```
|
```
|
||||||
kubectl create namespace openim
|
kubectl create namespace openim
|
||||||
```
|
```
|
||||||
2. 在项目根目录通过config/config.yaml
|
2. 修改config.yaml后在项目根目录创建configmap, config/usualConfig.yaml只需要挂载不需要修改配置
|
||||||
```
|
```
|
||||||
kubectl -n openim create configmap config --from-file=config/config.yaml
|
kubectl -n openim create configmap openim-config --from-file=config/config.yaml
|
||||||
kubectl -n openim create configmap usualConfig --from-file=config/usualConfig.yaml
|
kubectl -n openim create configmap openim-usualconfig --from-file=config/usualConfig.yaml
|
||||||
```
|
```
|
||||||
查看configmap
|
查看configmap
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: msg
|
- name: msg
|
||||||
image: openim/msg:v2.3.4
|
image: openim/msg:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10130
|
- containerPort: 10130
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,10 +30,11 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
@@ -12,7 +12,8 @@ ADD ./open_im_msg $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: msg-gateway
|
- name: msg-gateway
|
||||||
image: openim/msg_gateway:v2.3.4
|
image: openim/msg_gateway:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- name: rpc-port
|
- name: rpc-port
|
||||||
@@ -26,9 +26,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -36,11 +33,12 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ ADD ./open_im_msg_gateway $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,15 +15,12 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: msg-transfer
|
- name: msg-transfer
|
||||||
image: openim/msg_transfer:v2.3.4
|
image: openim/msg_transfer:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -31,10 +28,11 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ ADD ./open_im_msg_transfer $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: office
|
- name: office
|
||||||
image: openim/office:v2.3.4
|
image: openim/office:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10210
|
- containerPort: 10210
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,10 +30,11 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
@@ -12,7 +12,8 @@ ADD ./open_im_office $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: organization
|
- name: organization
|
||||||
image: openim/organization:v2.3.4
|
image: openim/organization:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10220
|
- containerPort: 10220
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,10 +30,11 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
@@ -12,7 +12,8 @@ ADD ./open_im_organization $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: push
|
- name: push
|
||||||
image: openim/push:v2.3.4
|
image: openim/push:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10170
|
- containerPort: 10170
|
||||||
@@ -23,9 +23,6 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -33,10 +30,11 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
@@ -12,7 +12,8 @@ ADD ./open_im_push $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: sdk-server
|
- name: sdk-server
|
||||||
image: openim/sdk_server:v2.3.4
|
image: openim/sdk_server:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10003
|
- containerPort: 10003
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ ADD ./open_im_sdk_server $WORKDIR/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
|
||||||
chmod +x $WORKDIR/main
|
chmod +x $WORKDIR/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||||
|
|
||||||
WORKDIR $CMDDIR
|
WORKDIR $CMDDIR
|
||||||
|
|||||||
@@ -15,15 +15,12 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: user
|
- name: user
|
||||||
image: openim/user:v2.3.4
|
image: openim/user:v2.3.8
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
- name: usualConfig
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
env:
|
env:
|
||||||
- name: CONFIG_NAME
|
- name: CONFIG_NAME
|
||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
@@ -31,10 +28,11 @@ spec:
|
|||||||
value: "/Open-IM-Server"
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
projected:
|
||||||
|
sources:
|
||||||
|
- configMap:
|
||||||
name: openim-config
|
name: openim-config
|
||||||
- name: usualConfig
|
- configMap:
|
||||||
configMap:
|
name: openim-usualconfig
|
||||||
name: openim-usualConfig
|
|
||||||
strategy: #更新策略
|
strategy: #更新策略
|
||||||
type: RollingUpdate # 滚动更新
|
type: RollingUpdate # 滚动更新
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ ADD ./open_im_user $WORKDIR/cmd/main
|
|||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||||
chmod +x $WORKDIR/cmd/main
|
chmod +x $WORKDIR/cmd/main
|
||||||
|
RUN apt-get -qq update \
|
||||||
|
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -115,7 +115,7 @@ services:
|
|||||||
|
|
||||||
|
|
||||||
open_im_server:
|
open_im_server:
|
||||||
image: openim/open_im_server:v2.3.6
|
image: openim/open_im_server:v2.3.8
|
||||||
container_name: open_im_server
|
container_name: open_im_server
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/Open-IM-Server/logs
|
- ./logs:/Open-IM-Server/logs
|
||||||
@@ -139,7 +139,7 @@ services:
|
|||||||
max-file: "2"
|
max-file: "2"
|
||||||
|
|
||||||
open_im_enterprise:
|
open_im_enterprise:
|
||||||
image: openim/open_im_enterprise:v1.0.2
|
image: openim/open_im_enterprise:v1.0.3
|
||||||
container_name: open_im_enterprise
|
container_name: open_im_enterprise
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/Open-IM-Enterprise/logs
|
- ./logs:/Open-IM-Enterprise/logs
|
||||||
|
|||||||
@@ -370,6 +370,47 @@ func InviteUserToGroup(c *gin.Context) {
|
|||||||
log.NewInfo(req.OperationID, "InviteUserToGroup api return ", resp)
|
log.NewInfo(req.OperationID, "InviteUserToGroup api return ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
func InviteUserToGroups(c *gin.Context) {
|
||||||
|
params := api.InviteUserToGroupsReq{}
|
||||||
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
|
log.NewError("0", "BindJSON failed ", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req := &rpc.InviteUserToGroupsReq{}
|
||||||
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
|
var ok bool
|
||||||
|
var errInfo string
|
||||||
|
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||||
|
log.NewError(req.OperationID, errMsg)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String())
|
||||||
|
|
||||||
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||||
|
if etcdConn == nil {
|
||||||
|
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
|
log.NewError(req.OperationID, errMsg)
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
RpcResp, err := client.InviteUserToGroups(context.Background(), req)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "InviteUserToGroup failed ", err.Error(), req.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp := api.InviteUserToGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||||
|
|
||||||
|
log.NewInfo(req.OperationID, "InviteUserToGroups api return ", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
// @Summary 创建群组
|
// @Summary 创建群组
|
||||||
// @Description 创建群组
|
// @Description 创建群组
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ func SetOptions(options map[string]bool, value bool) {
|
|||||||
|
|
||||||
func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||||
var newContent string
|
var newContent string
|
||||||
|
options := make(map[string]bool, 5)
|
||||||
var err error
|
var err error
|
||||||
switch params.ContentType {
|
switch params.ContentType {
|
||||||
case constant.Text:
|
case constant.Text:
|
||||||
@@ -56,13 +57,16 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
|||||||
fallthrough
|
fallthrough
|
||||||
case constant.CustomOnlineOnly:
|
case constant.CustomOnlineOnly:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
case constant.AtText:
|
||||||
|
fallthrough
|
||||||
case constant.AdvancedRevoke:
|
case constant.AdvancedRevoke:
|
||||||
|
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
||||||
newContent = utils.StructToJsonString(params.Content)
|
newContent = utils.StructToJsonString(params.Content)
|
||||||
case constant.Revoke:
|
case constant.Revoke:
|
||||||
|
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
||||||
newContent = params.Content["revokeMsgClientID"].(string)
|
newContent = params.Content["revokeMsgClientID"].(string)
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
options := make(map[string]bool, 5)
|
|
||||||
if params.IsOnlineOnly {
|
if params.IsOnlineOnly {
|
||||||
SetOptions(options, false)
|
SetOptions(options, false)
|
||||||
}
|
}
|
||||||
@@ -155,6 +159,8 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
data = CustomElem{}
|
data = CustomElem{}
|
||||||
case constant.CustomOnlineOnly:
|
case constant.CustomOnlineOnly:
|
||||||
data = CustomElem{}
|
data = CustomElem{}
|
||||||
|
case constant.AtText:
|
||||||
|
data = AtElem{}
|
||||||
//case constant.HasReadReceipt:
|
//case constant.HasReadReceipt:
|
||||||
//case constant.Typing:
|
//case constant.Typing:
|
||||||
//case constant.Quote:
|
//case constant.Quote:
|
||||||
@@ -469,6 +475,10 @@ type FileElem struct {
|
|||||||
type AtElem struct {
|
type AtElem struct {
|
||||||
Text string `mapstructure:"text"`
|
Text string `mapstructure:"text"`
|
||||||
AtUserList []string `mapstructure:"atUserList"`
|
AtUserList []string `mapstructure:"atUserList"`
|
||||||
|
AtUsersInfo []struct {
|
||||||
|
AtUserID string `json:"atUserID,omitempty"`
|
||||||
|
GroupNickname string `json:"groupNickname,omitempty"`
|
||||||
|
} `json:"atUsersInfo,omitempty"`
|
||||||
IsAtSelf bool `mapstructure:"isAtSelf"`
|
IsAtSelf bool `mapstructure:"isAtSelf"`
|
||||||
}
|
}
|
||||||
type LocationElem struct {
|
type LocationElem struct {
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import (
|
|||||||
|
|
||||||
func SetMessageReactionExtensions(c *gin.Context) {
|
func SetMessageReactionExtensions(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req api.SetMessageReactionExtensionsCallbackReq
|
req api.SetMessageReactionExtensionsReq
|
||||||
resp api.SetMessageReactionExtensionsCallbackResp
|
resp api.SetMessageReactionExtensionsResp
|
||||||
reqPb rpc.SetMessageReactionExtensionsReq
|
reqPb rpc.SetMessageReactionExtensionsReq
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ func SetMessageReactionExtensions(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
var errInfo string
|
||||||
ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
ok, reqPb.OpUserID, errInfo, reqPb.OpUserIDPlatformID = token_verify.GetUserIDAndPlatformIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
@@ -72,7 +72,7 @@ func GetMessageListReactionExtensions(c *gin.Context) {
|
|||||||
reqPb rpc.GetMessageListReactionExtensionsReq
|
reqPb rpc.GetMessageListReactionExtensionsReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||||
@@ -86,7 +86,7 @@ func GetMessageListReactionExtensions(c *gin.Context) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusOK, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,8 +115,9 @@ func AddMessageReactionExtensions(c *gin.Context) {
|
|||||||
var (
|
var (
|
||||||
req api.AddMessageReactionExtensionsReq
|
req api.AddMessageReactionExtensionsReq
|
||||||
resp api.AddMessageReactionExtensionsResp
|
resp api.AddMessageReactionExtensionsResp
|
||||||
reqPb rpc.ModifyMessageReactionExtensionsReq
|
reqPb rpc.AddMessageReactionExtensionsReq
|
||||||
)
|
)
|
||||||
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
@@ -128,7 +129,7 @@ func AddMessageReactionExtensions(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
var errInfo string
|
||||||
ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
ok, reqPb.OpUserID, errInfo, reqPb.OpUserIDPlatformID = token_verify.GetUserIDAndPlatformIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
@@ -152,6 +153,9 @@ func AddMessageReactionExtensions(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp.ErrCode = respPb.ErrCode
|
resp.ErrCode = respPb.ErrCode
|
||||||
resp.ErrMsg = respPb.ErrMsg
|
resp.ErrMsg = respPb.ErrMsg
|
||||||
|
resp.Data.ResultKeyValue = respPb.Result
|
||||||
|
resp.Data.MsgFirstModifyTime = respPb.MsgFirstModifyTime
|
||||||
|
resp.Data.IsReact = respPb.IsReact
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,7 @@ func ResetUserGroupMinSeq(operationID, groupID string, userIDList []string) erro
|
|||||||
log.NewError(operationID, utils.GetSelfFuncName(), "GetGroupUserMinSeq failed", groupID, userID, err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), "GetGroupUserMinSeq failed", groupID, userID, err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if userMinSeq > uint64(minSeq) {
|
if userMinSeq < uint64(minSeq) {
|
||||||
err = db.DB.SetGroupUserMinSeq(groupID, userID, userMinSeq)
|
|
||||||
} else {
|
|
||||||
err = db.DB.SetGroupUserMinSeq(groupID, userID, uint64(minSeq))
|
err = db.DB.SetGroupUserMinSeq(groupID, userID, uint64(minSeq))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -56,6 +54,19 @@ func DeleteMongoMsgAndResetRedisSeq(operationID, userID string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "delMsgIDStruct: ", delStruct, "minSeq", minSeq)
|
log.NewDebug(operationID, utils.GetSelfFuncName(), "delMsgIDStruct: ", delStruct, "minSeq", minSeq)
|
||||||
|
|
||||||
|
userCurrentMinSeq, err := db.DB.GetUserMinSeq(userID)
|
||||||
|
if err != nil && err != goRedis.Nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
userCurrentMaxSeq, err := db.DB.GetUserMaxSeq(userID)
|
||||||
|
if err != nil && err != goRedis.Nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if userCurrentMinSeq > userCurrentMaxSeq {
|
||||||
|
minSeq = uint32(userCurrentMaxSeq)
|
||||||
|
}
|
||||||
|
|
||||||
err = db.DB.SetUserMinSeq(userID, minSeq)
|
err = db.DB.SetUserMinSeq(userID, minSeq)
|
||||||
return utils.Wrap(err, "")
|
return utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
@@ -100,13 +111,13 @@ func deleteMongoMsg(operationID string, ID string, index int64, delStruct *delMs
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
return delStruct.getSetMinSeq() + 1, nil
|
return delStruct.getSetMinSeq(), nil
|
||||||
}
|
}
|
||||||
log.NewDebug(operationID, "ID:", ID, "index:", index, "uid:", msgs.UID, "len:", len(msgs.Msg))
|
log.NewDebug(operationID, "ID:", ID, "index:", index, "uid:", msgs.UID, "len:", len(msgs.Msg))
|
||||||
if len(msgs.Msg) > db.GetSingleGocMsgNum() {
|
if len(msgs.Msg) > db.GetSingleGocMsgNum() {
|
||||||
log.NewWarn(operationID, utils.GetSelfFuncName(), "msgs too large", len(msgs.Msg), msgs.UID)
|
log.NewWarn(operationID, utils.GetSelfFuncName(), "msgs too large", len(msgs.Msg), msgs.UID)
|
||||||
}
|
}
|
||||||
if msgs.Msg[len(msgs.Msg)-1].SendTime+(int64(config.Config.Mongo.DBRetainChatRecords)*24*60*60*1000) > utils.GetCurrentTimestampByMill() && msgListIsFull(msgs) {
|
if msgs.Msg[len(msgs.Msg)-1].SendTime+(int64(config.Config.Mongo.DBRetainChatRecords)*24*60*60*1000) < utils.GetCurrentTimestampByMill() && msgListIsFull(msgs) {
|
||||||
delStruct.delUidList = append(delStruct.delUidList, msgs.UID)
|
delStruct.delUidList = append(delStruct.delUidList, msgs.UID)
|
||||||
lastMsgPb := &server_api_params.MsgData{}
|
lastMsgPb := &server_api_params.MsgData{}
|
||||||
err = proto.Unmarshal(msgs.Msg[len(msgs.Msg)-1].Msg, lastMsgPb)
|
err = proto.Unmarshal(msgs.Msg[len(msgs.Msg)-1].Msg, lastMsgPb)
|
||||||
@@ -114,10 +125,14 @@ func deleteMongoMsg(operationID string, ID string, index int64, delStruct *delMs
|
|||||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), len(msgs.Msg)-1, msgs.UID)
|
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), len(msgs.Msg)-1, msgs.UID)
|
||||||
return 0, utils.Wrap(err, "proto.Unmarshal failed")
|
return 0, utils.Wrap(err, "proto.Unmarshal failed")
|
||||||
}
|
}
|
||||||
delStruct.minSeq = lastMsgPb.Seq
|
delStruct.minSeq = lastMsgPb.Seq + 1
|
||||||
|
log.NewDebug(operationID, utils.GetSelfFuncName(), msgs.UID, "add to delUidList", "minSeq", lastMsgPb.Seq+1)
|
||||||
} else {
|
} else {
|
||||||
var hasMarkDelFlag bool
|
var hasMarkDelFlag bool
|
||||||
for _, msg := range msgs.Msg {
|
for index, msg := range msgs.Msg {
|
||||||
|
if msg.SendTime == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
msgPb := &server_api_params.MsgData{}
|
msgPb := &server_api_params.MsgData{}
|
||||||
err = proto.Unmarshal(msg.Msg, msgPb)
|
err = proto.Unmarshal(msg.Msg, msgPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -127,19 +142,20 @@ func deleteMongoMsg(operationID string, ID string, index int64, delStruct *delMs
|
|||||||
if utils.GetCurrentTimestampByMill() > msg.SendTime+(int64(config.Config.Mongo.DBRetainChatRecords)*24*60*60*1000) {
|
if utils.GetCurrentTimestampByMill() > msg.SendTime+(int64(config.Config.Mongo.DBRetainChatRecords)*24*60*60*1000) {
|
||||||
msgPb.Status = constant.MsgDeleted
|
msgPb.Status = constant.MsgDeleted
|
||||||
bytes, _ := proto.Marshal(msgPb)
|
bytes, _ := proto.Marshal(msgPb)
|
||||||
msg.Msg = bytes
|
msgs.Msg[index].Msg = bytes
|
||||||
msg.SendTime = 0
|
msgs.Msg[index].SendTime = 0
|
||||||
hasMarkDelFlag = true
|
hasMarkDelFlag = true
|
||||||
} else {
|
} else {
|
||||||
if err := delMongoMsgsPhysical(delStruct.delUidList); err != nil {
|
if err := delMongoMsgsPhysical(delStruct.delUidList); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
if hasMarkDelFlag {
|
if hasMarkDelFlag {
|
||||||
|
log.NewInfo(operationID, ID, "hasMarkDelFlag", "index:", index, "msgPb:", msgPb, msgs.UID)
|
||||||
if err := db.DB.UpdateOneMsgList(msgs); err != nil {
|
if err := db.DB.UpdateOneMsgList(msgs); err != nil {
|
||||||
return delStruct.getSetMinSeq(), utils.Wrap(err, "")
|
return delStruct.getSetMinSeq(), utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return msgPb.Seq + 1, nil
|
return msgPb.Seq, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,10 +188,11 @@ func checkMaxSeqWithMongo(operationID, ID string, diffusionType int) error {
|
|||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == goRedis.Nil {
|
if err == goRedis.Nil {
|
||||||
return nil
|
|
||||||
}
|
} else {
|
||||||
return utils.Wrap(err, "GetUserMaxSeq failed")
|
return utils.Wrap(err, "GetUserMaxSeq failed")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
msg, err := db.DB.GetNewestMsg(ID)
|
msg, err := db.DB.GetNewestMsg(ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return utils.Wrap(err, "GetNewestMsg failed")
|
return utils.Wrap(err, "GetNewestMsg failed")
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -12,6 +13,7 @@ import (
|
|||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -23,7 +25,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GenUserChat(startSeq, stopSeq, delSeq, index uint32, userID string) *db.UserChat {
|
func GenUserChat(startSeq, stopSeq, delSeq, index uint32, userID string) *db.UserChat {
|
||||||
chat := &db.UserChat{UID: userID + strconv.Itoa(int(index))}
|
chat := &db.UserChat{UID: userID + ":" + strconv.Itoa(int(index))}
|
||||||
for i := startSeq; i <= stopSeq; i++ {
|
for i := startSeq; i <= stopSeq; i++ {
|
||||||
msg := server_api_params.MsgData{
|
msg := server_api_params.MsgData{
|
||||||
SendID: "sendID1",
|
SendID: "sendID1",
|
||||||
@@ -44,7 +46,12 @@ func GenUserChat(startSeq, stopSeq, delSeq, index uint32, userID string) *db.Use
|
|||||||
Status: 1,
|
Status: 1,
|
||||||
}
|
}
|
||||||
bytes, _ := proto.Marshal(&msg)
|
bytes, _ := proto.Marshal(&msg)
|
||||||
sendTime := 0
|
var sendTime int64
|
||||||
|
if i <= delSeq {
|
||||||
|
sendTime = 10000
|
||||||
|
} else {
|
||||||
|
sendTime = utils.GetCurrentTimestampByMill()
|
||||||
|
}
|
||||||
chat.Msg = append(chat.Msg, db.MsgInfo{SendTime: int64(sendTime), Msg: bytes})
|
chat.Msg = append(chat.Msg, db.MsgInfo{SendTime: int64(sendTime), Msg: bytes})
|
||||||
}
|
}
|
||||||
return chat
|
return chat
|
||||||
@@ -54,17 +61,28 @@ func SetUserMaxSeq(userID string, seq int) error {
|
|||||||
return redisClient.Set(context.Background(), "REDIS_USER_INCR_SEQ"+userID, seq, 0).Err()
|
return redisClient.Set(context.Background(), "REDIS_USER_INCR_SEQ"+userID, seq, 0).Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserMinSeq(userID string) (uint64, error) {
|
||||||
|
key := "REDIS_USER_MIN_SEQ:" + userID
|
||||||
|
seq, err := redisClient.Get(context.Background(), key).Result()
|
||||||
|
return uint64(utils.StringToInt(seq)), err
|
||||||
|
}
|
||||||
|
|
||||||
func CreateChat(userChat *db.UserChat) error {
|
func CreateChat(userChat *db.UserChat) error {
|
||||||
_, err := mongoClient.InsertOne(context.Background(), userChat)
|
_, err := mongoClient.InsertOne(context.Background(), userChat)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DelChat(uid string, index int) error {
|
||||||
|
_, err := mongoClient.DeleteOne(context.Background(), bson.M{"uid": uid + ":" + strconv.Itoa(index)})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
|
func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
|
||||||
operationID := getCronTaskOperationID()
|
operationID := getCronTaskOperationID()
|
||||||
redisClient = redis.NewClient(&redis.Options{
|
redisClient = redis.NewClient(&redis.Options{
|
||||||
Addr: "127.0.0.1:16379",
|
Addr: "127.0.0.1:16379",
|
||||||
Password: "openIM123", // no password set
|
Password: "openIM123", // no password set
|
||||||
DB: 13, // use default DB
|
DB: 0, // use default DB
|
||||||
})
|
})
|
||||||
mongoUri := fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin",
|
mongoUri := fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin",
|
||||||
"root", "openIM123", "127.0.0.1:37017",
|
"root", "openIM123", "127.0.0.1:37017",
|
||||||
@@ -72,33 +90,137 @@ func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
|
|||||||
client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(mongoUri))
|
client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(mongoUri))
|
||||||
mongoClient = client.Database("openIM").Collection("msg")
|
mongoClient = client.Database("openIM").Collection("msg")
|
||||||
testUID1 := "test_del_id1"
|
testUID1 := "test_del_id1"
|
||||||
//testUID2 := "test_del_id2"
|
err = DelChat(testUID1, 0)
|
||||||
//testUID3 := "test_del_id3"
|
|
||||||
//testUID4 := "test_del_id4"
|
|
||||||
//testUID5 := "test_del_id5"
|
|
||||||
//testUID6 := "test_del_id6"
|
|
||||||
err = SetUserMaxSeq(testUID1, 600)
|
err = SetUserMaxSeq(testUID1, 600)
|
||||||
userChat := GenUserChat(1, 500, 200, 0, testUID1)
|
userChat := GenUserChat(1, 600, 200, 0, testUID1)
|
||||||
err = CreateChat(userChat)
|
err = CreateChat(userChat)
|
||||||
|
|
||||||
if err := DeleteMongoMsgAndResetRedisSeq(operationID, testUID1); err != nil {
|
if err := DeleteMongoMsgAndResetRedisSeq(operationID, testUID1); err != nil {
|
||||||
t.Error("checkMaxSeqWithMongo failed", testUID1)
|
t.Error("checkMaxSeqWithMongo failed", testUID1)
|
||||||
}
|
}
|
||||||
if err := checkMaxSeqWithMongo(operationID, testUID1, constant.WriteDiffusion); err != nil {
|
if err := checkMaxSeqWithMongo(operationID, testUID1, constant.WriteDiffusion); err != nil {
|
||||||
t.Error("checkMaxSeqWithMongo failed", testUID1)
|
t.Error("checkMaxSeqWithMongo failed", testUID1)
|
||||||
}
|
}
|
||||||
|
minSeq, err := GetUserMinSeq(testUID1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("err is not nil", testUID1, err.Error())
|
t.Error("err is not nil", testUID1, err.Error())
|
||||||
}
|
}
|
||||||
// testWorkingGroupIDList := []string{"test_del_id1", "test_del_id2", "test_del_id3", "test_del_id4", "test_del_id5"}
|
if minSeq != 201 {
|
||||||
// for _, groupID := range testWorkingGroupIDList {
|
t.Error("test1 is not the same", "minSeq:", minSeq, "targetSeq", 201)
|
||||||
// operationID = groupID + "-" + operationID
|
}
|
||||||
// log.NewDebug(operationID, utils.GetSelfFuncName(), "groupID:", groupID, "userIDList:", testUserIDList)
|
|
||||||
// if err := ResetUserGroupMinSeq(operationID, groupID, testUserIDList); err != nil {
|
testUID2 := "test_del_id2"
|
||||||
// t.Error("checkMaxSeqWithMongo failed", groupID)
|
err = DelChat(testUID2, 0)
|
||||||
// }
|
err = DelChat(testUID2, 1)
|
||||||
// if err := checkMaxSeqWithMongo(operationID, groupID, constant.ReadDiffusion); err != nil {
|
err = SetUserMaxSeq(testUID2, 7000)
|
||||||
// t.Error("checkMaxSeqWithMongo failed", groupID)
|
userChat = GenUserChat(1, 4999, 5000, 0, testUID2)
|
||||||
// }
|
userChat2 := GenUserChat(5000, 7000, 6000, 1, testUID2)
|
||||||
// }
|
err = CreateChat(userChat)
|
||||||
|
err = CreateChat(userChat2)
|
||||||
|
|
||||||
|
if err := DeleteMongoMsgAndResetRedisSeq(operationID, testUID2); err != nil {
|
||||||
|
t.Error("checkMaxSeqWithMongo failed", testUID2)
|
||||||
|
}
|
||||||
|
if err := checkMaxSeqWithMongo(operationID, testUID2, constant.WriteDiffusion); err != nil {
|
||||||
|
t.Error("checkMaxSeqWithMongo failed", testUID2)
|
||||||
|
}
|
||||||
|
minSeq, err = GetUserMinSeq(testUID2)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("err is not nil", testUID2, err.Error())
|
||||||
|
}
|
||||||
|
if minSeq != 6001 {
|
||||||
|
t.Error("test2 is not the same", "minSeq:", minSeq, "targetSeq", 6001)
|
||||||
|
}
|
||||||
|
|
||||||
|
testUID3 := "test_del_id3"
|
||||||
|
err = DelChat(testUID3, 0)
|
||||||
|
err = SetUserMaxSeq(testUID3, 4999)
|
||||||
|
userChat = GenUserChat(1, 4999, 5000, 0, testUID3)
|
||||||
|
err = CreateChat(userChat)
|
||||||
|
if err := DeleteMongoMsgAndResetRedisSeq(operationID, testUID3); err != nil {
|
||||||
|
t.Error("checkMaxSeqWithMongo failed", testUID3)
|
||||||
|
}
|
||||||
|
if err := checkMaxSeqWithMongo(operationID, testUID3, constant.WriteDiffusion); err != nil {
|
||||||
|
t.Error("checkMaxSeqWithMongo failed", testUID3)
|
||||||
|
}
|
||||||
|
minSeq, err = GetUserMinSeq(testUID3)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("err is not nil", testUID3, err.Error())
|
||||||
|
}
|
||||||
|
if minSeq != 5000 {
|
||||||
|
t.Error("test3 is not the same", "minSeq:", minSeq, "targetSeq", 5000)
|
||||||
|
}
|
||||||
|
|
||||||
|
testUID4 := "test_del_id4"
|
||||||
|
err = DelChat(testUID4, 0)
|
||||||
|
err = DelChat(testUID4, 1)
|
||||||
|
err = DelChat(testUID4, 2)
|
||||||
|
err = SetUserMaxSeq(testUID4, 12000)
|
||||||
|
userChat = GenUserChat(1, 4999, 5000, 0, testUID4)
|
||||||
|
userChat2 = GenUserChat(5000, 9999, 10000, 1, testUID4)
|
||||||
|
userChat3 := GenUserChat(10000, 12000, 11000, 2, testUID4)
|
||||||
|
err = CreateChat(userChat)
|
||||||
|
err = CreateChat(userChat2)
|
||||||
|
err = CreateChat(userChat3)
|
||||||
|
if err := DeleteMongoMsgAndResetRedisSeq(operationID, testUID4); err != nil {
|
||||||
|
t.Error("checkMaxSeqWithMongo failed", testUID4)
|
||||||
|
}
|
||||||
|
if err := checkMaxSeqWithMongo(operationID, testUID4, constant.WriteDiffusion); err != nil {
|
||||||
|
t.Error("checkMaxSeqWithMongo failed", testUID4)
|
||||||
|
}
|
||||||
|
minSeq, err = GetUserMinSeq(testUID4)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("err is not nil", testUID4, err.Error())
|
||||||
|
}
|
||||||
|
if minSeq != 11001 {
|
||||||
|
t.Error("test4 is not the same", "minSeq:", minSeq, "targetSeq", 11001)
|
||||||
|
}
|
||||||
|
|
||||||
|
testUID5 := "test_del_id5"
|
||||||
|
err = DelChat(testUID5, 0)
|
||||||
|
err = DelChat(testUID5, 1)
|
||||||
|
err = SetUserMaxSeq(testUID5, 9999)
|
||||||
|
userChat = GenUserChat(1, 4999, 5000, 0, testUID5)
|
||||||
|
userChat2 = GenUserChat(5000, 9999, 10000, 1, testUID5)
|
||||||
|
err = CreateChat(userChat)
|
||||||
|
err = CreateChat(userChat2)
|
||||||
|
if err := DeleteMongoMsgAndResetRedisSeq(operationID, testUID5); err != nil {
|
||||||
|
t.Error("checkMaxSeqWithMongo failed", testUID4)
|
||||||
|
}
|
||||||
|
if err := checkMaxSeqWithMongo(operationID, testUID5, constant.WriteDiffusion); err != nil {
|
||||||
|
t.Error("checkMaxSeqWithMongo failed", testUID5)
|
||||||
|
}
|
||||||
|
minSeq, err = GetUserMinSeq(testUID5)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("err is not nil", testUID5, err.Error())
|
||||||
|
}
|
||||||
|
if minSeq != 10000 {
|
||||||
|
t.Error("test5 is not the same", "minSeq:", minSeq, "targetSeq", 10000)
|
||||||
|
}
|
||||||
|
|
||||||
|
testUID6 := "test_del_id6"
|
||||||
|
err = DelChat(testUID5, 0)
|
||||||
|
err = DelChat(testUID5, 1)
|
||||||
|
err = DelChat(testUID5, 2)
|
||||||
|
err = DelChat(testUID5, 3)
|
||||||
|
userChat = GenUserChat(1, 4999, 5000, 0, testUID6)
|
||||||
|
userChat2 = GenUserChat(5000, 9999, 10000, 1, testUID6)
|
||||||
|
userChat3 = GenUserChat(10000, 14999, 13000, 2, testUID6)
|
||||||
|
userChat4 := GenUserChat(15000, 19999, 0, 3, testUID6)
|
||||||
|
err = CreateChat(userChat)
|
||||||
|
err = CreateChat(userChat2)
|
||||||
|
err = CreateChat(userChat3)
|
||||||
|
err = CreateChat(userChat4)
|
||||||
|
if err := DeleteMongoMsgAndResetRedisSeq(operationID, testUID6); err != nil {
|
||||||
|
t.Error("checkMaxSeqWithMongo failed", testUID6)
|
||||||
|
}
|
||||||
|
if err := checkMaxSeqWithMongo(operationID, testUID6, constant.WriteDiffusion); err != nil {
|
||||||
|
t.Error("checkMaxSeqWithMongo failed", testUID6)
|
||||||
|
}
|
||||||
|
minSeq, err = GetUserMinSeq(testUID6)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("err is not nil", testUID6, err.Error())
|
||||||
|
}
|
||||||
|
if minSeq != 13001 {
|
||||||
|
t.Error("test3 is not the same", "minSeq:", minSeq, "targetSeq", 13001)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
//
|
|
||||||
//func main() {
|
|
||||||
// db.DB.BatchInsertChat()
|
|
||||||
//}
|
|
||||||
@@ -269,6 +269,7 @@ func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
|
|||||||
mReplyData.ClientMsgID = pb.GetClientMsgID()
|
mReplyData.ClientMsgID = pb.GetClientMsgID()
|
||||||
mReplyData.ServerMsgID = pb.GetServerMsgID()
|
mReplyData.ServerMsgID = pb.GetServerMsgID()
|
||||||
mReplyData.SendTime = pb.GetSendTime()
|
mReplyData.SendTime = pb.GetSendTime()
|
||||||
|
mReplyData.Ex = pb.GetEx()
|
||||||
b, _ := proto.Marshal(&mReplyData)
|
b, _ := proto.Marshal(&mReplyData)
|
||||||
mReply := Resp{
|
mReply := Resp{
|
||||||
ReqIdentifier: m.ReqIdentifier,
|
ReqIdentifier: m.ReqIdentifier,
|
||||||
|
|||||||
@@ -101,47 +101,48 @@ func (r *RPCServer) run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (r *RPCServer) OnlinePushMsg(_ context.Context, in *pbRelay.OnlinePushMsgReq) (*pbRelay.OnlinePushMsgResp, error) {
|
func (r *RPCServer) OnlinePushMsg(_ context.Context, in *pbRelay.OnlinePushMsgReq) (*pbRelay.OnlinePushMsgResp, error) {
|
||||||
log.NewInfo(in.OperationID, "PushMsgToUser is arriving", in.String())
|
//log.NewInfo(in.OperationID, "PushMsgToUser is arriving", in.String())
|
||||||
var resp []*pbRelay.SingleMsgToUserPlatform
|
//var resp []*pbRelay.SingleMsgToUserPlatform
|
||||||
msgBytes, _ := proto.Marshal(in.MsgData)
|
//msgBytes, _ := proto.Marshal(in.MsgData)
|
||||||
mReply := Resp{
|
//mReply := Resp{
|
||||||
ReqIdentifier: constant.WSPushMsg,
|
// ReqIdentifier: constant.WSPushMsg,
|
||||||
OperationID: in.OperationID,
|
// OperationID: in.OperationID,
|
||||||
Data: msgBytes,
|
// Data: msgBytes,
|
||||||
}
|
//}
|
||||||
var replyBytes bytes.Buffer
|
//var replyBytes bytes.Buffer
|
||||||
enc := gob.NewEncoder(&replyBytes)
|
//enc := gob.NewEncoder(&replyBytes)
|
||||||
err := enc.Encode(mReply)
|
//err := enc.Encode(mReply)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
log.NewError(in.OperationID, "data encode err", err.Error())
|
// log.NewError(in.OperationID, "data encode err", err.Error())
|
||||||
}
|
//}
|
||||||
var tag bool
|
//var tag bool
|
||||||
recvID := in.PushToUserID
|
//recvID := in.PushToUserID
|
||||||
for _, v := range r.platformList {
|
//for _, v := range r.platformList {
|
||||||
if conn := ws.getUserConn(recvID, v); conn != nil {
|
// if conn := ws.getUserConn(recvID, v); conn != nil {
|
||||||
tag = true
|
// tag = true
|
||||||
resultCode := sendMsgToUser(conn, replyBytes.Bytes(), in, v, recvID)
|
// resultCode := sendMsgToUser(conn, replyBytes.Bytes(), in, v, recvID)
|
||||||
temp := &pbRelay.SingleMsgToUserPlatform{
|
// temp := &pbRelay.SingleMsgToUserPlatform{
|
||||||
ResultCode: resultCode,
|
// ResultCode: resultCode,
|
||||||
RecvID: recvID,
|
// RecvID: recvID,
|
||||||
RecvPlatFormID: int32(v),
|
// RecvPlatFormID: int32(v),
|
||||||
}
|
// }
|
||||||
resp = append(resp, temp)
|
// resp = append(resp, temp)
|
||||||
} else {
|
// } else {
|
||||||
temp := &pbRelay.SingleMsgToUserPlatform{
|
// temp := &pbRelay.SingleMsgToUserPlatform{
|
||||||
ResultCode: -1,
|
// ResultCode: -1,
|
||||||
RecvID: recvID,
|
// RecvID: recvID,
|
||||||
RecvPlatFormID: int32(v),
|
// RecvPlatFormID: int32(v),
|
||||||
}
|
// }
|
||||||
resp = append(resp, temp)
|
// resp = append(resp, temp)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
if !tag {
|
//if !tag {
|
||||||
log.NewDebug(in.OperationID, "push err ,no matched ws conn not in map", in.String())
|
// log.NewDebug(in.OperationID, "push err ,no matched ws conn not in map", in.String())
|
||||||
}
|
//}
|
||||||
return &pbRelay.OnlinePushMsgResp{
|
//return &pbRelay.OnlinePushMsgResp{
|
||||||
Resp: resp,
|
// Resp: resp,
|
||||||
}, nil
|
//}, nil
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUsersOnlineStatusReq) (*pbRelay.GetUsersOnlineStatusResp, error) {
|
func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUsersOnlineStatusReq) (*pbRelay.GetUsersOnlineStatusResp, error) {
|
||||||
log.NewInfo(req.OperationID, "rpc GetUsersOnlineStatus arrived server", req.String())
|
log.NewInfo(req.OperationID, "rpc GetUsersOnlineStatus arrived server", req.String())
|
||||||
@@ -154,13 +155,13 @@ func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUser
|
|||||||
temp := new(pbRelay.GetUsersOnlineStatusResp_SuccessResult)
|
temp := new(pbRelay.GetUsersOnlineStatusResp_SuccessResult)
|
||||||
temp.UserID = userID
|
temp.UserID = userID
|
||||||
userConnMap := ws.getUserAllCons(userID)
|
userConnMap := ws.getUserAllCons(userID)
|
||||||
for platform, userConn := range userConnMap {
|
for platform, userConns := range userConnMap {
|
||||||
if userConn != nil {
|
if len(userConns) != 0 {
|
||||||
ps := new(pbRelay.GetUsersOnlineStatusResp_SuccessDetail)
|
ps := new(pbRelay.GetUsersOnlineStatusResp_SuccessDetail)
|
||||||
ps.Platform = constant.PlatformIDToName(platform)
|
ps.Platform = constant.PlatformIDToName(platform)
|
||||||
ps.Status = constant.OnlineStatus
|
ps.Status = constant.OnlineStatus
|
||||||
ps.ConnID = userConn.connID
|
ps.ConnID = userConns[0].connID
|
||||||
ps.IsBackground = userConn.IsBackground
|
ps.IsBackground = userConns[0].IsBackground
|
||||||
temp.Status = constant.OnlineStatus
|
temp.Status = constant.OnlineStatus
|
||||||
temp.DetailPlatformStatus = append(temp.DetailPlatformStatus, ps)
|
temp.DetailPlatformStatus = append(temp.DetailPlatformStatus, ps)
|
||||||
}
|
}
|
||||||
@@ -196,13 +197,73 @@ func (r *RPCServer) SuperGroupOnlineBatchPushOneMsg(_ context.Context, req *pbRe
|
|||||||
UserID: v,
|
UserID: v,
|
||||||
}
|
}
|
||||||
userConnMap := ws.getUserAllCons(v)
|
userConnMap := ws.getUserAllCons(v)
|
||||||
for platform, userConn := range userConnMap {
|
for platform, userConns := range userConnMap {
|
||||||
if userConn != nil {
|
if len(userConns) != 0 {
|
||||||
|
log.NewWarn(req.OperationID, "conns is ", len(userConns), platform, userConns)
|
||||||
|
for _, userConn := range userConns {
|
||||||
|
temp := &pbRelay.SingleMsgToUserPlatform{
|
||||||
|
RecvID: v,
|
||||||
|
RecvPlatFormID: int32(platform),
|
||||||
|
}
|
||||||
|
if !userConn.IsBackground || req.MsgData.ContentType == constant.SuperGroupUpdateNotification || req.MsgData.ContentType == constant.SignalingNotification {
|
||||||
|
resultCode := sendMsgBatchToUser(userConn, replyBytes.Bytes(), req, platform, v)
|
||||||
|
if resultCode == 0 && utils.IsContainInt(platform, r.pushTerminal) {
|
||||||
|
tempT.OnlinePush = true
|
||||||
|
promePkg.PromeInc(promePkg.MsgOnlinePushSuccessCounter)
|
||||||
|
log.Info(req.OperationID, "PushSuperMsgToUser is success By Ws", "args", req.String(), "recvPlatForm", constant.PlatformIDToName(platform), "recvID", v, "background status", userConn.IsBackground, userConn.userID)
|
||||||
|
temp.ResultCode = resultCode
|
||||||
|
if req.MsgData.ContentType == constant.SignalingNotification && userConn.IsBackground {
|
||||||
|
log.Info(req.OperationID, "recv signalingNotification backgroud", req.MsgData.String())
|
||||||
|
temp.ResultCode = -2
|
||||||
|
tempT.OnlinePush = false
|
||||||
|
}
|
||||||
|
resp = append(resp, temp)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
temp.ResultCode = -2
|
||||||
|
resp = append(resp, temp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tempT.Resp = resp
|
||||||
|
singleUserResult = append(singleUserResult, tempT)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &pbRelay.OnlineBatchPushOneMsgResp{
|
||||||
|
SinglePushResult: singleUserResult,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
func (r *RPCServer) SuperGroupBackgroundOnlinePush(_ context.Context, req *pbRelay.OnlineBatchPushOneMsgReq) (*pbRelay.OnlineBatchPushOneMsgResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, "BatchPushMsgToUser is arriving", req.String())
|
||||||
|
var singleUserResult []*pbRelay.SingelMsgToUserResultList
|
||||||
|
//r.GetBatchMsgForPush(req.OperationID,req.MsgData,req.PushToUserIDList,)
|
||||||
|
msgBytes, _ := proto.Marshal(req.MsgData)
|
||||||
|
mReply := Resp{
|
||||||
|
ReqIdentifier: constant.WSPushMsg,
|
||||||
|
OperationID: req.OperationID,
|
||||||
|
Data: msgBytes,
|
||||||
|
}
|
||||||
|
var replyBytes bytes.Buffer
|
||||||
|
enc := gob.NewEncoder(&replyBytes)
|
||||||
|
err := enc.Encode(mReply)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "data encode err", err.Error())
|
||||||
|
}
|
||||||
|
for _, v := range req.PushToUserIDList {
|
||||||
|
var resp []*pbRelay.SingleMsgToUserPlatform
|
||||||
|
tempT := &pbRelay.SingelMsgToUserResultList{
|
||||||
|
UserID: v,
|
||||||
|
}
|
||||||
|
userConnMap := ws.getUserAllCons(v)
|
||||||
|
for platform, userConns := range userConnMap {
|
||||||
|
if len(userConns) != 0 {
|
||||||
|
for _, userConn := range userConns {
|
||||||
temp := &pbRelay.SingleMsgToUserPlatform{
|
temp := &pbRelay.SingleMsgToUserPlatform{
|
||||||
RecvID: v,
|
RecvID: v,
|
||||||
RecvPlatFormID: int32(platform),
|
RecvPlatFormID: int32(platform),
|
||||||
}
|
}
|
||||||
if !userConn.IsBackground {
|
|
||||||
resultCode := sendMsgBatchToUser(userConn, replyBytes.Bytes(), req, platform, v)
|
resultCode := sendMsgBatchToUser(userConn, replyBytes.Bytes(), req, platform, v)
|
||||||
if resultCode == 0 && utils.IsContainInt(platform, r.pushTerminal) {
|
if resultCode == 0 && utils.IsContainInt(platform, r.pushTerminal) {
|
||||||
tempT.OnlinePush = true
|
tempT.OnlinePush = true
|
||||||
@@ -211,10 +272,8 @@ func (r *RPCServer) SuperGroupOnlineBatchPushOneMsg(_ context.Context, req *pbRe
|
|||||||
temp.ResultCode = resultCode
|
temp.ResultCode = resultCode
|
||||||
resp = append(resp, temp)
|
resp = append(resp, temp)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
temp.ResultCode = -2
|
|
||||||
resp = append(resp, temp)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tempT.Resp = resp
|
tempT.Resp = resp
|
||||||
@@ -226,76 +285,77 @@ func (r *RPCServer) SuperGroupOnlineBatchPushOneMsg(_ context.Context, req *pbRe
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
func (r *RPCServer) OnlineBatchPushOneMsg(_ context.Context, req *pbRelay.OnlineBatchPushOneMsgReq) (*pbRelay.OnlineBatchPushOneMsgResp, error) {
|
func (r *RPCServer) OnlineBatchPushOneMsg(_ context.Context, req *pbRelay.OnlineBatchPushOneMsgReq) (*pbRelay.OnlineBatchPushOneMsgResp, error) {
|
||||||
log.NewInfo(req.OperationID, "BatchPushMsgToUser is arriving", req.String())
|
//log.NewInfo(req.OperationID, "BatchPushMsgToUser is arriving", req.String())
|
||||||
var singleUserResult []*pbRelay.SingelMsgToUserResultList
|
//var singleUserResult []*pbRelay.SingelMsgToUserResultList
|
||||||
|
//
|
||||||
for _, v := range req.PushToUserIDList {
|
//for _, v := range req.PushToUserIDList {
|
||||||
var resp []*pbRelay.SingleMsgToUserPlatform
|
// var resp []*pbRelay.SingleMsgToUserPlatform
|
||||||
tempT := &pbRelay.SingelMsgToUserResultList{
|
// tempT := &pbRelay.SingelMsgToUserResultList{
|
||||||
UserID: v,
|
// UserID: v,
|
||||||
}
|
// }
|
||||||
userConnMap := ws.getUserAllCons(v)
|
// userConnMap := ws.getUserAllCons(v)
|
||||||
var platformList []int
|
// var platformList []int
|
||||||
for k, _ := range userConnMap {
|
// for k, _ := range userConnMap {
|
||||||
platformList = append(platformList, k)
|
// platformList = append(platformList, k)
|
||||||
}
|
// }
|
||||||
log.Debug(req.OperationID, "GetSingleUserMsgForPushPlatforms begin", req.MsgData.Seq, v, platformList, req.MsgData.String())
|
// log.Debug(req.OperationID, "GetSingleUserMsgForPushPlatforms begin", req.MsgData.Seq, v, platformList, req.MsgData.String())
|
||||||
needPushMapList := r.GetSingleUserMsgForPushPlatforms(req.OperationID, req.MsgData, v, platformList)
|
// needPushMapList := r.GetSingleUserMsgForPushPlatforms(req.OperationID, req.MsgData, v, platformList)
|
||||||
log.Debug(req.OperationID, "GetSingleUserMsgForPushPlatforms end", req.MsgData.Seq, v, platformList, len(needPushMapList))
|
// log.Debug(req.OperationID, "GetSingleUserMsgForPushPlatforms end", req.MsgData.Seq, v, platformList, len(needPushMapList))
|
||||||
for platform, list := range needPushMapList {
|
// for platform, list := range needPushMapList {
|
||||||
if list != nil {
|
// if list != nil {
|
||||||
log.Debug(req.OperationID, "needPushMapList ", "userID: ", v, "platform: ", platform, "push msg num:")
|
// log.Debug(req.OperationID, "needPushMapList ", "userID: ", v, "platform: ", platform, "push msg num:")
|
||||||
//for _, v := range list {
|
// //for _, v := range list {
|
||||||
// log.Debug(req.OperationID, "req.MsgData.MsgDataList begin", "len: ", len(req.MsgData.MsgDataList), v.String())
|
// // log.Debug(req.OperationID, "req.MsgData.MsgDataList begin", "len: ", len(req.MsgData.MsgDataList), v.String())
|
||||||
// req.MsgData.MsgDataList = append(req.MsgData.MsgDataList, v)
|
// // req.MsgData.MsgDataList = append(req.MsgData.MsgDataList, v)
|
||||||
// log.Debug(req.OperationID, "req.MsgData.MsgDataList end", "len: ", len(req.MsgData.MsgDataList))
|
// // log.Debug(req.OperationID, "req.MsgData.MsgDataList end", "len: ", len(req.MsgData.MsgDataList))
|
||||||
|
// //}
|
||||||
|
// msgBytes, err := proto.Marshal(list)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Error(req.OperationID, "proto marshal err", err.Error())
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
|
// req.MsgData.MsgDataList = msgBytes
|
||||||
|
// //req.MsgData.MsgDataList = append(req.MsgData.MsgDataList, v)
|
||||||
|
// log.Debug(req.OperationID, "r.encodeWsData no string")
|
||||||
|
// //log.Debug(req.OperationID, "r.encodeWsData data0 list ", req.MsgData.MsgDataList[0].String())
|
||||||
|
//
|
||||||
|
// log.Debug(req.OperationID, "r.encodeWsData ", req.MsgData.String())
|
||||||
|
// replyBytes, err := r.encodeWsData(req.MsgData, req.OperationID)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Error(req.OperationID, "encodeWsData failed ", req.MsgData.String())
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
|
// log.Debug(req.OperationID, "encodeWsData", "len: ", replyBytes.Len())
|
||||||
|
// resultCode := sendMsgBatchToUser(userConnMap[platform], replyBytes.Bytes(), req, platform, v)
|
||||||
|
// if resultCode == 0 && utils.IsContainInt(platform, r.pushTerminal) {
|
||||||
|
// tempT.OnlinePush = true
|
||||||
|
// log.Info(req.OperationID, "PushSuperMsgToUser is success By Ws", "args", req.String(), "recv PlatForm", constant.PlatformIDToName(platform), "recvID", v)
|
||||||
|
// temp := &pbRelay.SingleMsgToUserPlatform{
|
||||||
|
// ResultCode: resultCode,
|
||||||
|
// RecvID: v,
|
||||||
|
// RecvPlatFormID: int32(platform),
|
||||||
|
// }
|
||||||
|
// resp = append(resp, temp)
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// if utils.IsContainInt(platform, r.pushTerminal) {
|
||||||
|
// tempT.OnlinePush = true
|
||||||
|
// temp := &pbRelay.SingleMsgToUserPlatform{
|
||||||
|
// ResultCode: 0,
|
||||||
|
// RecvID: v,
|
||||||
|
// RecvPlatFormID: int32(platform),
|
||||||
|
// }
|
||||||
|
// resp = append(resp, temp)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// tempT.Resp = resp
|
||||||
|
// singleUserResult = append(singleUserResult, tempT)
|
||||||
//}
|
//}
|
||||||
msgBytes, err := proto.Marshal(list)
|
//return &pbRelay.OnlineBatchPushOneMsgResp{
|
||||||
if err != nil {
|
// SinglePushResult: singleUserResult,
|
||||||
log.Error(req.OperationID, "proto marshal err", err.Error())
|
//}, nil
|
||||||
continue
|
return nil, nil
|
||||||
}
|
|
||||||
req.MsgData.MsgDataList = msgBytes
|
|
||||||
//req.MsgData.MsgDataList = append(req.MsgData.MsgDataList, v)
|
|
||||||
log.Debug(req.OperationID, "r.encodeWsData no string")
|
|
||||||
//log.Debug(req.OperationID, "r.encodeWsData data0 list ", req.MsgData.MsgDataList[0].String())
|
|
||||||
|
|
||||||
log.Debug(req.OperationID, "r.encodeWsData ", req.MsgData.String())
|
|
||||||
replyBytes, err := r.encodeWsData(req.MsgData, req.OperationID)
|
|
||||||
if err != nil {
|
|
||||||
log.Error(req.OperationID, "encodeWsData failed ", req.MsgData.String())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
log.Debug(req.OperationID, "encodeWsData", "len: ", replyBytes.Len())
|
|
||||||
resultCode := sendMsgBatchToUser(userConnMap[platform], replyBytes.Bytes(), req, platform, v)
|
|
||||||
if resultCode == 0 && utils.IsContainInt(platform, r.pushTerminal) {
|
|
||||||
tempT.OnlinePush = true
|
|
||||||
log.Info(req.OperationID, "PushSuperMsgToUser is success By Ws", "args", req.String(), "recv PlatForm", constant.PlatformIDToName(platform), "recvID", v)
|
|
||||||
temp := &pbRelay.SingleMsgToUserPlatform{
|
|
||||||
ResultCode: resultCode,
|
|
||||||
RecvID: v,
|
|
||||||
RecvPlatFormID: int32(platform),
|
|
||||||
}
|
|
||||||
resp = append(resp, temp)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if utils.IsContainInt(platform, r.pushTerminal) {
|
|
||||||
tempT.OnlinePush = true
|
|
||||||
temp := &pbRelay.SingleMsgToUserPlatform{
|
|
||||||
ResultCode: 0,
|
|
||||||
RecvID: v,
|
|
||||||
RecvPlatFormID: int32(platform),
|
|
||||||
}
|
|
||||||
resp = append(resp, temp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tempT.Resp = resp
|
|
||||||
singleUserResult = append(singleUserResult, tempT)
|
|
||||||
}
|
|
||||||
return &pbRelay.OnlineBatchPushOneMsgResp{
|
|
||||||
SinglePushResult: singleUserResult,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
func (r *RPCServer) encodeWsData(wsData *sdk_ws.MsgData, operationID string) (bytes.Buffer, error) {
|
func (r *RPCServer) encodeWsData(wsData *sdk_ws.MsgData, operationID string) (bytes.Buffer, error) {
|
||||||
log.Debug(operationID, "encodeWsData begin", wsData.String())
|
log.Debug(operationID, "encodeWsData begin", wsData.String())
|
||||||
@@ -326,10 +386,11 @@ func (r *RPCServer) KickUserOffline(_ context.Context, req *pbRelay.KickUserOffl
|
|||||||
log.NewWarn(req.OperationID, "SetTokenKicked ", v, req.PlatformID, req.OperationID)
|
log.NewWarn(req.OperationID, "SetTokenKicked ", v, req.PlatformID, req.OperationID)
|
||||||
SetTokenKicked(v, int(req.PlatformID), req.OperationID)
|
SetTokenKicked(v, int(req.PlatformID), req.OperationID)
|
||||||
oldConnMap := ws.getUserAllCons(v)
|
oldConnMap := ws.getUserAllCons(v)
|
||||||
if conn, ok := oldConnMap[int(req.PlatformID)]; ok { // user->map[platform->conn]
|
if conns, ok := oldConnMap[int(req.PlatformID)]; ok { // user->map[platform->conn]
|
||||||
log.NewWarn(req.OperationID, "send kick msg, close connection ", req.PlatformID, v)
|
log.NewWarn(req.OperationID, "send kick msg, close connection ", req.PlatformID, v)
|
||||||
ws.sendKickMsg(conn)
|
for _, conn := range conns {
|
||||||
conn.Close()
|
ws.sendKickMsg(conn, req.OperationID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &pbRelay.KickUserOfflineResp{}, nil
|
return &pbRelay.KickUserOfflineResp{}, nil
|
||||||
|
|||||||
@@ -45,15 +45,13 @@ type WServer struct {
|
|||||||
wsAddr string
|
wsAddr string
|
||||||
wsMaxConnNum int
|
wsMaxConnNum int
|
||||||
wsUpGrader *websocket.Upgrader
|
wsUpGrader *websocket.Upgrader
|
||||||
wsConnToUser map[*UserConn]map[int]string
|
wsUserToConn map[string]map[int][]*UserConn
|
||||||
wsUserToConn map[string]map[int]*UserConn
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WServer) onInit(wsPort int) {
|
func (ws *WServer) onInit(wsPort int) {
|
||||||
ws.wsAddr = ":" + utils.IntToString(wsPort)
|
ws.wsAddr = ":" + utils.IntToString(wsPort)
|
||||||
ws.wsMaxConnNum = config.Config.LongConnSvr.WebsocketMaxConnNum
|
ws.wsMaxConnNum = config.Config.LongConnSvr.WebsocketMaxConnNum
|
||||||
ws.wsConnToUser = make(map[*UserConn]map[int]string)
|
ws.wsUserToConn = make(map[string]map[int][]*UserConn)
|
||||||
ws.wsUserToConn = make(map[string]map[int]*UserConn)
|
|
||||||
ws.wsUpGrader = &websocket.Upgrader{
|
ws.wsUpGrader = &websocket.Upgrader{
|
||||||
HandshakeTimeout: time.Duration(config.Config.LongConnSvr.WebsocketTimeOut) * time.Second,
|
HandshakeTimeout: time.Duration(config.Config.LongConnSvr.WebsocketTimeOut) * time.Second,
|
||||||
ReadBufferSize: config.Config.LongConnSvr.WebsocketMaxMsgLen,
|
ReadBufferSize: config.Config.LongConnSvr.WebsocketMaxMsgLen,
|
||||||
@@ -84,7 +82,7 @@ func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Error(operationID, "upgrade http conn err", err.Error(), query)
|
log.Error(operationID, "upgrade http conn err", err.Error(), query)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
newConn := &UserConn{conn, new(sync.Mutex), utils.StringToInt32(query["platformID"][0]), 0, compression, query["sendID"][0], false, query["token"][0], conn.RemoteAddr().String() + "_" + strconv.Itoa(int(utils.GetCurrentTimestampByMill()))}
|
newConn := &UserConn{conn, new(sync.Mutex), utils.StringToInt32(query["platformID"][0]), 0, compression, query["sendID"][0], false, query["token"][0], utils.Md5(conn.RemoteAddr().String() + "_" + strconv.Itoa(int(utils.GetCurrentTimestampByMill())))}
|
||||||
userCount++
|
userCount++
|
||||||
ws.addUserConn(query["sendID"][0], utils.StringToInt(query["platformID"][0]), newConn, query["token"][0], newConn.connID, operationID)
|
ws.addUserConn(query["sendID"][0], utils.StringToInt(query["platformID"][0]), newConn, query["token"][0], newConn.connID, operationID)
|
||||||
go ws.readMsg(newConn)
|
go ws.readMsg(newConn)
|
||||||
@@ -106,6 +104,12 @@ func (ws *WServer) readMsg(conn *UserConn) {
|
|||||||
ws.delUserConn(conn)
|
ws.delUserConn(conn)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if messageType == websocket.CloseMessage {
|
||||||
|
log.NewWarn("", "WS receive error ", " userIP", conn.RemoteAddr().String(), "userUid", "platform", "error", string(msg))
|
||||||
|
userCount--
|
||||||
|
ws.delUserConn(conn)
|
||||||
|
return
|
||||||
|
}
|
||||||
log.NewDebug("", "size", utils.ByteSize(uint64(len(msg))))
|
log.NewDebug("", "size", utils.ByteSize(uint64(len(msg))))
|
||||||
if conn.IsCompress {
|
if conn.IsCompress {
|
||||||
buff := bytes.NewBuffer(msg)
|
buff := bytes.NewBuffer(msg)
|
||||||
@@ -189,6 +193,7 @@ func (ws *WServer) MultiTerminalLoginCheckerWithLock(uid string, platformID int,
|
|||||||
defer rwLock.Unlock()
|
defer rwLock.Unlock()
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), " rpc args: ", uid, platformID, token)
|
log.NewInfo(operationID, utils.GetSelfFuncName(), " rpc args: ", uid, platformID, token)
|
||||||
switch config.Config.MultiLoginPolicy {
|
switch config.Config.MultiLoginPolicy {
|
||||||
|
case constant.DefalutNotKick:
|
||||||
case constant.PCAndOther:
|
case constant.PCAndOther:
|
||||||
if constant.PlatformNameToClass(constant.PlatformIDToName(platformID)) == constant.TerminalPC {
|
if constant.PlatformNameToClass(constant.PlatformIDToName(platformID)) == constant.TerminalPC {
|
||||||
return
|
return
|
||||||
@@ -196,8 +201,11 @@ func (ws *WServer) MultiTerminalLoginCheckerWithLock(uid string, platformID int,
|
|||||||
fallthrough
|
fallthrough
|
||||||
case constant.AllLoginButSameTermKick:
|
case constant.AllLoginButSameTermKick:
|
||||||
if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn]
|
if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn]
|
||||||
if oldConn, ok := oldConnMap[platformID]; ok {
|
if oldConns, ok := oldConnMap[platformID]; ok {
|
||||||
log.NewDebug(operationID, uid, platformID, "kick old conn")
|
log.NewDebug(operationID, uid, platformID, "kick old conn")
|
||||||
|
for _, conn := range oldConns {
|
||||||
|
ws.sendKickMsg(conn, operationID)
|
||||||
|
}
|
||||||
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
|
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
|
||||||
if err != nil && err != go_redis.Nil {
|
if err != nil && err != go_redis.Nil {
|
||||||
log.NewError(operationID, "get token from redis err", err.Error(), uid, constant.PlatformIDToName(platformID))
|
log.NewError(operationID, "get token from redis err", err.Error(), uid, constant.PlatformIDToName(platformID))
|
||||||
@@ -220,16 +228,12 @@ func (ws *WServer) MultiTerminalLoginCheckerWithLock(uid string, platformID int,
|
|||||||
log.NewError(operationID, "SetTokenMapByUidPid err", err.Error(), uid, platformID, m)
|
log.NewError(operationID, "SetTokenMapByUidPid err", err.Error(), uid, platformID, m)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = oldConn.Close()
|
|
||||||
//delete(oldConnMap, platformID)
|
delete(oldConnMap, platformID)
|
||||||
ws.wsUserToConn[uid] = oldConnMap
|
ws.wsUserToConn[uid] = oldConnMap
|
||||||
if len(oldConnMap) == 0 {
|
if len(oldConnMap) == 0 {
|
||||||
delete(ws.wsUserToConn, uid)
|
delete(ws.wsUserToConn, uid)
|
||||||
}
|
}
|
||||||
delete(ws.wsConnToUser, oldConn)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(operationID, "conn close err", err.Error(), uid, platformID)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
log.NewWarn(operationID, "abnormal uid-conn ", uid, platformID, oldConnMap[platformID])
|
log.NewWarn(operationID, "abnormal uid-conn ", uid, platformID, oldConnMap[platformID])
|
||||||
}
|
}
|
||||||
@@ -244,6 +248,7 @@ func (ws *WServer) MultiTerminalLoginCheckerWithLock(uid string, platformID int,
|
|||||||
|
|
||||||
func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn *UserConn, token string, operationID string) {
|
func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn *UserConn, token string, operationID string) {
|
||||||
switch config.Config.MultiLoginPolicy {
|
switch config.Config.MultiLoginPolicy {
|
||||||
|
case constant.DefalutNotKick:
|
||||||
case constant.PCAndOther:
|
case constant.PCAndOther:
|
||||||
if constant.PlatformNameToClass(constant.PlatformIDToName(platformID)) == constant.TerminalPC {
|
if constant.PlatformNameToClass(constant.PlatformIDToName(platformID)) == constant.TerminalPC {
|
||||||
return
|
return
|
||||||
@@ -251,9 +256,11 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn
|
|||||||
fallthrough
|
fallthrough
|
||||||
case constant.AllLoginButSameTermKick:
|
case constant.AllLoginButSameTermKick:
|
||||||
if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn]
|
if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn]
|
||||||
if oldConn, ok := oldConnMap[platformID]; ok {
|
if oldConns, ok := oldConnMap[platformID]; ok {
|
||||||
log.NewDebug(operationID, uid, platformID, "kick old conn")
|
log.NewDebug(operationID, uid, platformID, "kick old conn")
|
||||||
ws.sendKickMsg(oldConn)
|
for _, conn := range oldConns {
|
||||||
|
ws.sendKickMsg(conn, operationID)
|
||||||
|
}
|
||||||
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
|
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
|
||||||
if err != nil && err != go_redis.Nil {
|
if err != nil && err != go_redis.Nil {
|
||||||
log.NewError(operationID, "get token from redis err", err.Error(), uid, constant.PlatformIDToName(platformID))
|
log.NewError(operationID, "get token from redis err", err.Error(), uid, constant.PlatformIDToName(platformID))
|
||||||
@@ -276,16 +283,11 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn
|
|||||||
log.NewError(operationID, "SetTokenMapByUidPid err", err.Error(), uid, platformID, m)
|
log.NewError(operationID, "SetTokenMapByUidPid err", err.Error(), uid, platformID, m)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = oldConn.Close()
|
|
||||||
delete(oldConnMap, platformID)
|
delete(oldConnMap, platformID)
|
||||||
ws.wsUserToConn[uid] = oldConnMap
|
ws.wsUserToConn[uid] = oldConnMap
|
||||||
if len(oldConnMap) == 0 {
|
if len(oldConnMap) == 0 {
|
||||||
delete(ws.wsUserToConn, uid)
|
delete(ws.wsUserToConn, uid)
|
||||||
}
|
}
|
||||||
delete(ws.wsConnToUser, oldConn)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(operationID, "conn close err", err.Error(), uid, platformID)
|
|
||||||
}
|
|
||||||
callbackResp := callbackUserKickOff(operationID, uid, platformID)
|
callbackResp := callbackUserKickOff(operationID, uid, platformID)
|
||||||
if callbackResp.ErrCode != 0 {
|
if callbackResp.ErrCode != 0 {
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
|
log.NewError(operationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
|
||||||
@@ -302,11 +304,12 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn
|
|||||||
case constant.WebAndOther:
|
case constant.WebAndOther:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (ws *WServer) sendKickMsg(oldConn *UserConn) {
|
func (ws *WServer) sendKickMsg(oldConn *UserConn, operationID string) {
|
||||||
mReply := Resp{
|
mReply := Resp{
|
||||||
ReqIdentifier: constant.WSKickOnlineMsg,
|
ReqIdentifier: constant.WSKickOnlineMsg,
|
||||||
ErrCode: constant.ErrTokenInvalid.ErrCode,
|
ErrCode: constant.ErrTokenInvalid.ErrCode,
|
||||||
ErrMsg: constant.ErrTokenInvalid.ErrMsg,
|
ErrMsg: constant.ErrTokenInvalid.ErrMsg,
|
||||||
|
OperationID: operationID,
|
||||||
}
|
}
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
enc := gob.NewEncoder(&b)
|
enc := gob.NewEncoder(&b)
|
||||||
@@ -319,6 +322,11 @@ func (ws *WServer) sendKickMsg(oldConn *UserConn) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(mReply.OperationID, mReply.ReqIdentifier, mReply.ErrCode, mReply.ErrMsg, "sendKickMsg WS WriteMsg error", oldConn.RemoteAddr().String(), err.Error())
|
log.NewError(mReply.OperationID, mReply.ReqIdentifier, mReply.ErrCode, mReply.ErrMsg, "sendKickMsg WS WriteMsg error", oldConn.RemoteAddr().String(), err.Error())
|
||||||
}
|
}
|
||||||
|
errClose := oldConn.Close()
|
||||||
|
if errClose != nil {
|
||||||
|
log.NewError(mReply.OperationID, mReply.ReqIdentifier, mReply.ErrCode, mReply.ErrMsg, "close old conn error", oldConn.RemoteAddr().String(), err.Error())
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WServer) addUserConn(uid string, platformID int, conn *UserConn, token string, connID, operationID string) {
|
func (ws *WServer) addUserConn(uid string, platformID int, conn *UserConn, token string, connID, operationID string) {
|
||||||
@@ -332,23 +340,24 @@ func (ws *WServer) addUserConn(uid string, platformID int, conn *UserConn, token
|
|||||||
go ws.MultiTerminalLoginRemoteChecker(uid, int32(platformID), token, operationID)
|
go ws.MultiTerminalLoginRemoteChecker(uid, int32(platformID), token, operationID)
|
||||||
ws.MultiTerminalLoginChecker(uid, platformID, conn, token, operationID)
|
ws.MultiTerminalLoginChecker(uid, platformID, conn, token, operationID)
|
||||||
if oldConnMap, ok := ws.wsUserToConn[uid]; ok {
|
if oldConnMap, ok := ws.wsUserToConn[uid]; ok {
|
||||||
oldConnMap[platformID] = conn
|
if conns, ok := oldConnMap[platformID]; ok {
|
||||||
|
conns = append(conns, conn)
|
||||||
|
oldConnMap[platformID] = conns
|
||||||
|
} else {
|
||||||
|
var conns []*UserConn
|
||||||
|
conns = append(conns, conn)
|
||||||
|
oldConnMap[platformID] = conns
|
||||||
|
}
|
||||||
ws.wsUserToConn[uid] = oldConnMap
|
ws.wsUserToConn[uid] = oldConnMap
|
||||||
log.Debug(operationID, "user not first come in, add conn ", uid, platformID, conn, oldConnMap)
|
log.Debug(operationID, "user not first come in, add conn ", uid, platformID, conn, oldConnMap)
|
||||||
} else {
|
} else {
|
||||||
i := make(map[int]*UserConn)
|
i := make(map[int][]*UserConn)
|
||||||
i[platformID] = conn
|
var conns []*UserConn
|
||||||
|
conns = append(conns, conn)
|
||||||
|
i[platformID] = conns
|
||||||
ws.wsUserToConn[uid] = i
|
ws.wsUserToConn[uid] = i
|
||||||
log.Debug(operationID, "user first come in, new user, conn", uid, platformID, conn, ws.wsUserToConn[uid])
|
log.Debug(operationID, "user first come in, new user, conn", uid, platformID, conn, ws.wsUserToConn[uid])
|
||||||
}
|
}
|
||||||
if oldStringMap, ok := ws.wsConnToUser[conn]; ok {
|
|
||||||
oldStringMap[platformID] = uid
|
|
||||||
ws.wsConnToUser[conn] = oldStringMap
|
|
||||||
} else {
|
|
||||||
i := make(map[int]string)
|
|
||||||
i[platformID] = uid
|
|
||||||
ws.wsConnToUser[conn] = i
|
|
||||||
}
|
|
||||||
count := 0
|
count := 0
|
||||||
for _, v := range ws.wsUserToConn {
|
for _, v := range ws.wsUserToConn {
|
||||||
count = count + len(v)
|
count = count + len(v)
|
||||||
@@ -361,32 +370,40 @@ func (ws *WServer) delUserConn(conn *UserConn) {
|
|||||||
rwLock.Lock()
|
rwLock.Lock()
|
||||||
defer rwLock.Unlock()
|
defer rwLock.Unlock()
|
||||||
operationID := utils.OperationIDGenerator()
|
operationID := utils.OperationIDGenerator()
|
||||||
var uid string
|
platform := int(conn.PlatformID)
|
||||||
var platform int
|
|
||||||
if oldStringMap, okg := ws.wsConnToUser[conn]; okg {
|
if oldConnMap, ok := ws.wsUserToConn[conn.userID]; ok { // only recycle self conn
|
||||||
for k, v := range oldStringMap {
|
if oldconns, okMap := oldConnMap[platform]; okMap {
|
||||||
platform = k
|
|
||||||
uid = v
|
var a []*UserConn
|
||||||
|
|
||||||
|
for _, client := range oldconns {
|
||||||
|
if client != conn {
|
||||||
|
a = append(a, client)
|
||||||
|
|
||||||
}
|
}
|
||||||
if oldConnMap, ok := ws.wsUserToConn[uid]; ok {
|
}
|
||||||
|
if len(a) != 0 {
|
||||||
|
oldConnMap[platform] = a
|
||||||
|
} else {
|
||||||
delete(oldConnMap, platform)
|
delete(oldConnMap, platform)
|
||||||
ws.wsUserToConn[uid] = oldConnMap
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
ws.wsUserToConn[conn.userID] = oldConnMap
|
||||||
if len(oldConnMap) == 0 {
|
if len(oldConnMap) == 0 {
|
||||||
delete(ws.wsUserToConn, uid)
|
delete(ws.wsUserToConn, conn.userID)
|
||||||
}
|
}
|
||||||
count := 0
|
count := 0
|
||||||
for _, v := range ws.wsUserToConn {
|
for _, v := range ws.wsUserToConn {
|
||||||
count = count + len(v)
|
count = count + len(v)
|
||||||
}
|
}
|
||||||
log.Debug(operationID, "WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "disconnection_uid", uid, "disconnection_platform", platform, "online_user_num", len(ws.wsUserToConn), "online_conn_num", count)
|
log.Debug(operationID, "WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "disconnection_uid", conn.userID, "disconnection_platform", platform, "online_user_num", len(ws.wsUserToConn), "online_conn_num", count)
|
||||||
} else {
|
|
||||||
log.Debug(operationID, "WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "disconnection_uid", uid, "disconnection_platform", platform, "online_user_num", len(ws.wsUserToConn))
|
|
||||||
}
|
|
||||||
delete(ws.wsConnToUser, conn)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err := conn.Close()
|
err := conn.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, " close err", "", "uid", uid, "platform", platform)
|
log.Error(operationID, " close err", "", "uid", conn.userID, "platform", platform)
|
||||||
}
|
}
|
||||||
if conn.PlatformID == 0 || conn.connID == "" {
|
if conn.PlatformID == 0 || conn.connID == "" {
|
||||||
log.NewWarn(operationID, utils.GetSelfFuncName(), "PlatformID or connID is null", conn.PlatformID, conn.connID)
|
log.NewWarn(operationID, utils.GetSelfFuncName(), "PlatformID or connID is null", conn.PlatformID, conn.connID)
|
||||||
@@ -399,21 +416,21 @@ func (ws *WServer) delUserConn(conn *UserConn) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WServer) getUserConn(uid string, platform int) *UserConn {
|
// func (ws *WServer) getUserConn(uid string, platform int) *UserConn {
|
||||||
|
// rwLock.RLock()
|
||||||
|
// defer rwLock.RUnlock()
|
||||||
|
// if connMap, ok := ws.wsUserToConn[uid]; ok {
|
||||||
|
// if conn, flag := connMap[platform]; flag {
|
||||||
|
// return conn
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
func (ws *WServer) getUserAllCons(uid string) map[int][]*UserConn {
|
||||||
rwLock.RLock()
|
rwLock.RLock()
|
||||||
defer rwLock.RUnlock()
|
defer rwLock.RUnlock()
|
||||||
if connMap, ok := ws.wsUserToConn[uid]; ok {
|
if connMap, ok := ws.wsUserToConn[uid]; ok {
|
||||||
if conn, flag := connMap[platform]; flag {
|
newConnMap := make(map[int][]*UserConn)
|
||||||
return conn
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func (ws *WServer) getUserAllCons(uid string) map[int]*UserConn {
|
|
||||||
rwLock.RLock()
|
|
||||||
defer rwLock.RUnlock()
|
|
||||||
if connMap, ok := ws.wsUserToConn[uid]; ok {
|
|
||||||
newConnMap := make(map[int]*UserConn)
|
|
||||||
for k, v := range connMap {
|
for k, v := range connMap {
|
||||||
newConnMap[k] = v
|
newConnMap[k] = v
|
||||||
}
|
}
|
||||||
@@ -422,7 +439,7 @@ func (ws *WServer) getUserAllCons(uid string) map[int]*UserConn {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (ws *WServer) getUserUid(conn *UserConn) (uid string, platform int) {
|
// func (ws *WServer) getUserUid(conn *UserConn) (uid string, platform int) {
|
||||||
// rwLock.RLock()
|
// rwLock.RLock()
|
||||||
// defer rwLock.RUnlock()
|
// defer rwLock.RUnlock()
|
||||||
//
|
//
|
||||||
@@ -434,7 +451,7 @@ func (ws *WServer) getUserAllCons(uid string) map[int]*UserConn {
|
|||||||
// return uid, platform
|
// return uid, platform
|
||||||
// }
|
// }
|
||||||
// return "", 0
|
// return "", 0
|
||||||
//}
|
// }
|
||||||
func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request, operationID string) (isPass, compression bool) {
|
func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request, operationID string) (isPass, compression bool) {
|
||||||
status := http.StatusUnauthorized
|
status := http.StatusUnauthorized
|
||||||
query := r.URL.Query()
|
query := r.URL.Query()
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
cbApi "Open_IM/pkg/call_back_struct"
|
||||||
|
"Open_IM/pkg/common/callback"
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/common/http"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
pbChat "Open_IM/pkg/proto/msg"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
http2 "net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func callbackAfterConsumeGroupMsg(msg []*pbChat.MsgDataToMQ, triggerID string) cbApi.CommonCallbackResp {
|
||||||
|
callbackResp := cbApi.CommonCallbackResp{OperationID: triggerID}
|
||||||
|
if !config.Config.Callback.CallbackAfterConsumeGroupMsg.Enable {
|
||||||
|
return callbackResp
|
||||||
|
}
|
||||||
|
for _, v := range msg {
|
||||||
|
if v.MsgData.SessionType == constant.SuperGroupChatType || v.MsgData.SessionType == constant.GroupChatType {
|
||||||
|
commonCallbackReq := copyCallbackCommonReqStruct(v)
|
||||||
|
commonCallbackReq.CallbackCommand = constant.CallbackAfterConsumeGroupMsgCommand
|
||||||
|
req := cbApi.CallbackAfterConsumeGroupMsgReq{
|
||||||
|
CommonCallbackReq: commonCallbackReq,
|
||||||
|
GroupID: v.MsgData.GroupID,
|
||||||
|
}
|
||||||
|
resp := &cbApi.CallbackAfterConsumeGroupMsgResp{CommonCallbackResp: &callbackResp}
|
||||||
|
defer log.NewDebug(triggerID, utils.GetSelfFuncName(), req, *resp)
|
||||||
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAfterConsumeGroupMsgCommand, req, resp, config.Config.Callback.CallbackAfterConsumeGroupMsg.CallbackTimeOut); err != nil {
|
||||||
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
|
callbackResp.ErrMsg = err.Error()
|
||||||
|
return callbackResp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.NewDebug(triggerID, utils.GetSelfFuncName(), msg)
|
||||||
|
|
||||||
|
return callbackResp
|
||||||
|
}
|
||||||
|
func copyCallbackCommonReqStruct(msg *pbChat.MsgDataToMQ) cbApi.CommonCallbackReq {
|
||||||
|
req := cbApi.CommonCallbackReq{
|
||||||
|
SendID: msg.MsgData.SendID,
|
||||||
|
ServerMsgID: msg.MsgData.ServerMsgID,
|
||||||
|
ClientMsgID: msg.MsgData.ClientMsgID,
|
||||||
|
OperationID: msg.OperationID,
|
||||||
|
SenderPlatformID: msg.MsgData.SenderPlatformID,
|
||||||
|
SenderNickname: msg.MsgData.SenderNickname,
|
||||||
|
SessionType: msg.MsgData.SessionType,
|
||||||
|
MsgFrom: msg.MsgData.MsgFrom,
|
||||||
|
ContentType: msg.MsgData.ContentType,
|
||||||
|
Status: msg.MsgData.Status,
|
||||||
|
CreateTime: msg.MsgData.CreateTime,
|
||||||
|
AtUserIDList: msg.MsgData.AtUserIDList,
|
||||||
|
SenderFaceURL: msg.MsgData.SenderFaceURL,
|
||||||
|
Content: callback.GetContent(msg.MsgData),
|
||||||
|
Seq: msg.MsgData.Seq,
|
||||||
|
Ex: msg.MsgData.Ex,
|
||||||
|
}
|
||||||
|
return req
|
||||||
|
}
|
||||||
@@ -68,6 +68,43 @@ func (mmc *ModifyMsgConsumerHandler) ModifyMsg(cMsg *sarama.ConsumerMessage, msg
|
|||||||
log.NewInfo(msgDataToMQ.OperationID, "msg:", notification, "this is external extensions")
|
log.NewInfo(msgDataToMQ.OperationID, "msg:", notification, "this is external extensions")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if msgDataToMQ.MsgData.SessionType == constant.SuperGroupChatType && utils.GetSwitchFromOptions(msgDataToMQ.MsgData.Options, constant.IsHistory) {
|
||||||
|
if msgDataToMQ.MsgData.Seq == 0 {
|
||||||
|
log.NewError(msgDataToMQ.OperationID, "seq==0, error msg", msgDataToMQ.MsgData)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
msg, err := db.DB.GetMsgBySeqIndex(notification.SourceID, notification.Seq, msgDataToMQ.OperationID)
|
||||||
|
if (msg != nil && msg.Seq != notification.Seq) || err != nil {
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(msgDataToMQ.OperationID, "GetMsgBySeqIndex failed", notification, err.Error())
|
||||||
|
}
|
||||||
|
msgs, indexes, err := db.DB.GetSuperGroupMsgBySeqListMongo(notification.SourceID, []uint32{notification.Seq}, msgDataToMQ.OperationID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(msgDataToMQ.OperationID, "GetSuperGroupMsgBySeqListMongo failed", notification, err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var index int
|
||||||
|
if len(msgs) < 1 || len(indexes) < 1 {
|
||||||
|
log.NewError(msgDataToMQ.OperationID, "GetSuperGroupMsgBySeqListMongo failed", notification, "len<1", msgs, indexes)
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
msg = msgs[0]
|
||||||
|
index = indexes[msg.Seq]
|
||||||
|
}
|
||||||
|
msg.IsReact = true
|
||||||
|
if err := db.DB.ReplaceMsgByIndex(notification.SourceID, msg, index); err != nil {
|
||||||
|
log.NewError(msgDataToMQ.OperationID, "ReplaceMsgByIndex failed", notification.SourceID, *msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
msg.IsReact = true
|
||||||
|
if err = db.DB.ReplaceMsgBySeq(notification.SourceID, msg, msgDataToMQ.OperationID); err != nil {
|
||||||
|
log.NewError(msgDataToMQ.OperationID, "ReplaceMsgBySeq failed", notification.SourceID, *msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !notification.IsReact {
|
if !notification.IsReact {
|
||||||
// first time to modify
|
// first time to modify
|
||||||
var reactionExtensionList = make(map[string]db.KeyValue)
|
var reactionExtensionList = make(map[string]db.KeyValue)
|
||||||
@@ -83,11 +120,12 @@ func (mmc *ModifyMsgConsumerHandler) ModifyMsg(cMsg *sarama.ConsumerMessage, msg
|
|||||||
LatestUpdateTime: v.LatestUpdateTime,
|
LatestUpdateTime: v.LatestUpdateTime,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// modify old msg
|
||||||
if err := db.DB.InsertExtendMsg(notification.SourceID, notification.SessionType, &extendMsg); err != nil {
|
if err := db.DB.InsertExtendMsg(notification.SourceID, notification.SessionType, &extendMsg); err != nil {
|
||||||
log.NewError(msgDataToMQ.OperationID, "MsgFirstModify InsertExtendMsg failed", notification.SourceID, notification.SessionType, extendMsg, err.Error())
|
log.NewError(msgDataToMQ.OperationID, "MsgFirstModify InsertExtendMsg failed", notification.SourceID, notification.SessionType, extendMsg, err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var reactionExtensionList = make(map[string]*server_api_params.KeyValue)
|
var reactionExtensionList = make(map[string]*server_api_params.KeyValue)
|
||||||
for _, v := range notification.SuccessReactionExtensionList {
|
for _, v := range notification.SuccessReactionExtensionList {
|
||||||
|
|||||||
@@ -111,6 +111,10 @@ func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) {
|
|||||||
singleMsgSuccessCountMutex.Lock()
|
singleMsgSuccessCountMutex.Lock()
|
||||||
singleMsgSuccessCount += uint64(len(storageMsgList))
|
singleMsgSuccessCount += uint64(len(storageMsgList))
|
||||||
singleMsgSuccessCountMutex.Unlock()
|
singleMsgSuccessCountMutex.Unlock()
|
||||||
|
callbackResp := callbackAfterConsumeGroupMsg(storageMsgList, triggerID)
|
||||||
|
if callbackResp.ErrCode != 0 {
|
||||||
|
log.NewError(triggerID, utils.GetSelfFuncName(), "callbackAfterConsumeGroupMsg resp: ", callbackResp)
|
||||||
|
}
|
||||||
och.SendMessageToMongoCH(msgChannelValue.aggregationID, triggerID, storageMsgList, lastSeq)
|
och.SendMessageToMongoCH(msgChannelValue.aggregationID, triggerID, storageMsgList, lastSeq)
|
||||||
|
|
||||||
for _, v := range storageMsgList {
|
for _, v := range storageMsgList {
|
||||||
|
|||||||
+32
-24
@@ -111,24 +111,41 @@ type Android struct {
|
|||||||
type Notification struct {
|
type Notification struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Body string `json:"body"`
|
Body string `json:"body"`
|
||||||
ChannelID string `json:"channelID"`
|
ChannelID string `json:"channel_id"`
|
||||||
ChannelName string `json:"ChannelName"`
|
ChannelName string `json:"channel_name"`
|
||||||
ClickType string `json:"click_type"`
|
ClickType string `json:"click_type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
HW struct {
|
HW *HW `json:"HW"`
|
||||||
|
XM *XM `json:"XM"`
|
||||||
|
VV *VV `json:"VV"`
|
||||||
|
OP *OP `json:"OP"`
|
||||||
|
HO *HO `json:"HO"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type HW struct {
|
||||||
|
Category string `json:"/message/android/category"`
|
||||||
DefaultSound bool `json:"/message/android/notification/default_sound"`
|
DefaultSound bool `json:"/message/android/notification/default_sound"`
|
||||||
ChannelID string `json:"/message/android/notification/channel_id"`
|
ChannelID string `json:"/message/android/notification/channel_id"`
|
||||||
Sound string `json:"/message/android/notification/sound"`
|
Sound string `json:"/message/android/notification/sound"`
|
||||||
Importance string `json:"/message/android/notification/importance"`
|
Importance string `json:"/message/android/notification/importance"`
|
||||||
} `json:"HW"`
|
}
|
||||||
XM struct {
|
|
||||||
|
type XM struct {
|
||||||
ChannelID string `json:"/extra.channel_id"`
|
ChannelID string `json:"/extra.channel_id"`
|
||||||
} `json:"XM"`
|
}
|
||||||
VV struct {
|
|
||||||
|
type VV struct {
|
||||||
Classification int `json:"/classification"`
|
Classification int `json:"/classification"`
|
||||||
} `json:"VV"`
|
}
|
||||||
|
|
||||||
|
type OP struct {
|
||||||
|
ChannelID string `json:"/channel_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type HO struct {
|
||||||
|
Importance string `json:"/android/notification/importance"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PushResp struct {
|
type PushResp struct {
|
||||||
@@ -264,8 +281,8 @@ func (g *Getui) request(url string, content interface{}, token string, returnStr
|
|||||||
|
|
||||||
func (pushReq *PushReq) setPushChannel(title string, body string) {
|
func (pushReq *PushReq) setPushChannel(title string, body string) {
|
||||||
pushReq.PushChannel = &PushChannel{}
|
pushReq.PushChannel = &PushChannel{}
|
||||||
// autoBadge := "+1"
|
autoBadge := "+1"
|
||||||
pushReq.PushChannel.Ios = &Ios{}
|
pushReq.PushChannel.Ios = &Ios{AutoBadge: &autoBadge}
|
||||||
notify := "notify"
|
notify := "notify"
|
||||||
pushReq.PushChannel.Ios.NotiType = ¬ify
|
pushReq.PushChannel.Ios.NotiType = ¬ify
|
||||||
pushReq.PushChannel.Ios.Aps.Sound = "default"
|
pushReq.PushChannel.Ios.Aps.Sound = "default"
|
||||||
@@ -280,20 +297,11 @@ func (pushReq *PushReq) setPushChannel(title string, body string) {
|
|||||||
ClickType: "startapp",
|
ClickType: "startapp",
|
||||||
}
|
}
|
||||||
pushReq.PushChannel.Android.Ups.Options = Options{
|
pushReq.PushChannel.Android.Ups.Options = Options{
|
||||||
HW: struct {
|
HW: &HW{Category: config.Config.Push.Getui.Channel.HW.Category, ChannelID: "RingRing4", Sound: "/raw/ring001", Importance: "NORMAL"},
|
||||||
DefaultSound bool `json:"/message/android/notification/default_sound"`
|
HO: &HO{Importance: "NORMAL"},
|
||||||
ChannelID string `json:"/message/android/notification/channel_id"`
|
XM: &XM{ChannelID: config.Config.Push.Getui.Channel.XM.ChannelID},
|
||||||
Sound string `json:"/message/android/notification/sound"`
|
OP: &OP{ChannelID: config.Config.Push.Getui.Channel.OPPO.ChannelID},
|
||||||
Importance string `json:"/message/android/notification/importance"`
|
VV: &VV{Classification: 1},
|
||||||
}{ChannelID: "RingRing4", Sound: "/raw/ring001", Importance: "NORMAL"},
|
|
||||||
XM: struct {
|
|
||||||
ChannelID string `json:"/extra.channel_id"`
|
|
||||||
}{ChannelID: "high_system"},
|
|
||||||
VV: struct {
|
|
||||||
Classification int "json:\"/classification\""
|
|
||||||
}{
|
|
||||||
Classification: 1,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
if detailContent == "" {
|
if detailContent == "" {
|
||||||
detailContent = title
|
detailContent = title
|
||||||
}
|
}
|
||||||
|
if pushMsg.MsgData.ContentType == constant.SignalingNotification {
|
||||||
|
go func() {
|
||||||
pushResult, err := offlinePusher.Push(UIDList, title, detailContent, pushMsg.OperationID, opts)
|
pushResult, err := offlinePusher.Push(UIDList, title, detailContent, pushMsg.OperationID, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
promePkg.PromeInc(promePkg.MsgOfflinePushFailedCounter)
|
promePkg.PromeInc(promePkg.MsgOfflinePushFailedCounter)
|
||||||
@@ -151,6 +153,18 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
promePkg.PromeInc(promePkg.MsgOfflinePushSuccessCounter)
|
promePkg.PromeInc(promePkg.MsgOfflinePushSuccessCounter)
|
||||||
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
|
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
} else {
|
||||||
|
pushResult, err := offlinePusher.Push(UIDList, title, detailContent, pushMsg.OperationID, opts)
|
||||||
|
if err != nil {
|
||||||
|
promePkg.PromeInc(promePkg.MsgOfflinePushFailedCounter)
|
||||||
|
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
|
||||||
|
} else {
|
||||||
|
promePkg.PromeInc(promePkg.MsgOfflinePushSuccessCounter)
|
||||||
|
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,11 +213,25 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
successCount++
|
successCount++
|
||||||
if isOfflinePush {
|
if isOfflinePush {
|
||||||
var onlineSuccessUserIDList []string
|
var onlineSuccessUserIDList []string
|
||||||
|
var WebAndPcBackgroundUserIDList []string
|
||||||
onlineSuccessUserIDList = append(onlineSuccessUserIDList, pushMsg.MsgData.SendID)
|
onlineSuccessUserIDList = append(onlineSuccessUserIDList, pushMsg.MsgData.SendID)
|
||||||
for _, v := range wsResult {
|
for _, v := range wsResult {
|
||||||
if v.OnlinePush && v.UserID != pushMsg.MsgData.SendID {
|
if v.OnlinePush && v.UserID != pushMsg.MsgData.SendID {
|
||||||
onlineSuccessUserIDList = append(onlineSuccessUserIDList, v.UserID)
|
onlineSuccessUserIDList = append(onlineSuccessUserIDList, v.UserID)
|
||||||
}
|
}
|
||||||
|
if !v.OnlinePush {
|
||||||
|
if len(v.Resp) != 0 {
|
||||||
|
for _, singleResult := range v.Resp {
|
||||||
|
if singleResult.ResultCode == -2 {
|
||||||
|
if constant.PlatformIDToClass(int(singleResult.RecvPlatFormID)) == constant.TerminalPC ||
|
||||||
|
singleResult.RecvPlatFormID == constant.WebPlatformID {
|
||||||
|
WebAndPcBackgroundUserIDList = append(WebAndPcBackgroundUserIDList, v.UserID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onlineFailedUserIDList := utils.DifferenceString(onlineSuccessUserIDList, pushToUserIDList)
|
onlineFailedUserIDList := utils.DifferenceString(onlineSuccessUserIDList, pushToUserIDList)
|
||||||
//Use offline push messaging
|
//Use offline push messaging
|
||||||
@@ -229,7 +257,17 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
} else {
|
} else {
|
||||||
needOfflinePushUserIDList = onlineFailedUserIDList
|
needOfflinePushUserIDList = onlineFailedUserIDList
|
||||||
}
|
}
|
||||||
|
if pushMsg.MsgData.ContentType != constant.SignalingNotification {
|
||||||
|
notNotificationUserIDList, err := db.DB.GetSuperGroupUserReceiveNotNotifyMessageIDList(pushMsg.MsgData.GroupID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetSuperGroupUserReceiveNotNotifyMessageIDList failed", pushMsg.MsgData.GroupID)
|
||||||
|
} else {
|
||||||
|
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), notNotificationUserIDList)
|
||||||
|
}
|
||||||
|
needOfflinePushUserIDList = utils.RemoveFromSlice(notNotificationUserIDList, needOfflinePushUserIDList)
|
||||||
|
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), needOfflinePushUserIDList)
|
||||||
|
|
||||||
|
}
|
||||||
if offlinePusher == nil {
|
if offlinePusher == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -266,6 +304,8 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
}
|
}
|
||||||
detailContent = title
|
detailContent = title
|
||||||
}
|
}
|
||||||
|
if pushMsg.MsgData.ContentType == constant.SignalingNotification {
|
||||||
|
go func() {
|
||||||
pushResult, err := offlinePusher.Push(needOfflinePushUserIDList, title, detailContent, pushMsg.OperationID, opts)
|
pushResult, err := offlinePusher.Push(needOfflinePushUserIDList, title, detailContent, pushMsg.OperationID, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
promePkg.PromeInc(promePkg.MsgOfflinePushFailedCounter)
|
promePkg.PromeInc(promePkg.MsgOfflinePushFailedCounter)
|
||||||
@@ -274,6 +314,48 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
promePkg.PromeInc(promePkg.MsgOfflinePushSuccessCounter)
|
promePkg.PromeInc(promePkg.MsgOfflinePushSuccessCounter)
|
||||||
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
|
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
|
||||||
}
|
}
|
||||||
|
needBackgroupPushUserID := utils.IntersectString(needOfflinePushUserIDList, WebAndPcBackgroundUserIDList)
|
||||||
|
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), pushMsg.OperationID)
|
||||||
|
if len(needBackgroupPushUserID) > 0 {
|
||||||
|
//Online push message
|
||||||
|
log.Debug(pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String())
|
||||||
|
for _, v := range grpcCons {
|
||||||
|
msgClient := pbRelay.NewRelayClient(v)
|
||||||
|
_, err := msgClient.SuperGroupBackgroundOnlinePush(context.Background(), &pbRelay.OnlineBatchPushOneMsgReq{OperationID: pushMsg.OperationID, MsgData: pushMsg.MsgData,
|
||||||
|
PushToUserIDList: needBackgroupPushUserID})
|
||||||
|
if err != nil {
|
||||||
|
log.NewError("push data to client rpc err", pushMsg.OperationID, "err", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
} else {
|
||||||
|
pushResult, err := offlinePusher.Push(needOfflinePushUserIDList, title, detailContent, pushMsg.OperationID, opts)
|
||||||
|
if err != nil {
|
||||||
|
promePkg.PromeInc(promePkg.MsgOfflinePushFailedCounter)
|
||||||
|
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
|
||||||
|
} else {
|
||||||
|
promePkg.PromeInc(promePkg.MsgOfflinePushSuccessCounter)
|
||||||
|
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
|
||||||
|
}
|
||||||
|
needBackgroupPushUserID := utils.IntersectString(needOfflinePushUserIDList, WebAndPcBackgroundUserIDList)
|
||||||
|
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), pushMsg.OperationID)
|
||||||
|
if len(needBackgroupPushUserID) > 0 {
|
||||||
|
//Online push message
|
||||||
|
log.Debug(pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String())
|
||||||
|
for _, v := range grpcCons {
|
||||||
|
msgClient := pbRelay.NewRelayClient(v)
|
||||||
|
_, err := msgClient.SuperGroupBackgroundOnlinePush(context.Background(), &pbRelay.OnlineBatchPushOneMsgReq{OperationID: pushMsg.OperationID, MsgData: pushMsg.MsgData,
|
||||||
|
PushToUserIDList: needBackgroupPushUserID})
|
||||||
|
if err != nil {
|
||||||
|
log.NewError("push data to client rpc err", pushMsg.OperationID, "err", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,6 +311,7 @@ func (s *adminCMSServer) GetActiveGroup(_ context.Context, req *pbAdminCMS.GetAc
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
||||||
|
toTime = toTime.AddDate(0, 0, 1)
|
||||||
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
|
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveGroups failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveGroups failed", err.Error())
|
||||||
@@ -340,6 +341,7 @@ func (s *adminCMSServer) GetActiveUser(_ context.Context, req *pbAdminCMS.GetAct
|
|||||||
resp.CommonResp.ErrMsg = err.Error()
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
toTime = toTime.AddDate(0, 0, 1)
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
||||||
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
|
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -61,6 +61,21 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
|
|||||||
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
if req.Conversation.ConversationType == constant.SuperGroupChatType {
|
||||||
|
if req.Conversation.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
||||||
|
if err = db.DB.SetSuperGroupUserReceiveNotNotifyMessage(req.Conversation.GroupID, v); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, v)
|
||||||
|
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err = db.DB.SetSuperGroupUserReceiveNotifyMessage(req.Conversation.GroupID, v); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, v)
|
||||||
|
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"recv_msg_opt": conversation.RecvMsgOpt})
|
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"recv_msg_opt": conversation.RecvMsgOpt})
|
||||||
case constant.FieldGroupAtType:
|
case constant.FieldGroupAtType:
|
||||||
@@ -151,6 +166,10 @@ func syncPeerUserConversation(conversation *pbConversation.Conversation, operati
|
|||||||
log.NewError(operationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
err = rocksCache.DelUserConversationIDListFromCache(conversation.UserID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(operationID, utils.GetSelfFuncName(), "DelConversationFromCache failed", err.Error(), conversation.OwnerUserID, conversation.ConversationID)
|
||||||
|
}
|
||||||
err = rocksCache.DelConversationFromCache(conversation.UserID, utils.GetConversationIDBySessionType(conversation.OwnerUserID, constant.SingleChatType))
|
err = rocksCache.DelConversationFromCache(conversation.UserID, utils.GetConversationIDBySessionType(conversation.OwnerUserID, constant.SingleChatType))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "DelConversationFromCache failed", err.Error(), conversation.OwnerUserID, conversation.ConversationID)
|
log.NewError(operationID, utils.GetSelfFuncName(), "DelConversationFromCache failed", err.Error(), conversation.OwnerUserID, conversation.ConversationID)
|
||||||
|
|||||||
+146
-5
@@ -365,6 +365,14 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
var resp pbGroup.InviteUserToGroupResp
|
var resp pbGroup.InviteUserToGroupResp
|
||||||
joinReq := pbGroup.JoinGroupReq{}
|
joinReq := pbGroup.JoinGroupReq{}
|
||||||
for _, v := range req.InvitedUserIDList {
|
for _, v := range req.InvitedUserIDList {
|
||||||
|
if imdb.IsExistGroupMember(req.GroupID, v) {
|
||||||
|
log.NewError(req.OperationID, "IsExistGroupMember ", req.GroupID, v)
|
||||||
|
var resultNode pbGroup.Id2Result
|
||||||
|
resultNode.Result = -1
|
||||||
|
resultNode.UserID = v
|
||||||
|
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
|
||||||
|
continue
|
||||||
|
}
|
||||||
var groupRequest db.GroupRequest
|
var groupRequest db.GroupRequest
|
||||||
groupRequest.UserID = v
|
groupRequest.UserID = v
|
||||||
groupRequest.GroupID = req.GroupID
|
groupRequest.GroupID = req.GroupID
|
||||||
@@ -452,8 +460,19 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
|
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
okUserIDList = req.InvitedUserIDList
|
for _, v := range req.InvitedUserIDList {
|
||||||
if err := db.DB.AddUserToSuperGroup(req.GroupID, req.InvitedUserIDList); err != nil {
|
if imdb.IsExistGroupMember(req.GroupID, v) {
|
||||||
|
log.NewError(req.OperationID, "IsExistGroupMember ", req.GroupID, v)
|
||||||
|
var resultNode pbGroup.Id2Result
|
||||||
|
resultNode.Result = -1
|
||||||
|
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
okUserIDList = append(okUserIDList, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//okUserIDList = req.InvitedUserIDList
|
||||||
|
if err := db.DB.AddUserToSuperGroup(req.GroupID, okUserIDList); err != nil {
|
||||||
log.NewError(req.OperationID, "AddUserToSuperGroup failed ", req.GroupID, err)
|
log.NewError(req.OperationID, "AddUserToSuperGroup failed ", req.GroupID, err)
|
||||||
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}, nil
|
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}, nil
|
||||||
}
|
}
|
||||||
@@ -545,6 +564,35 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *groupServer) InviteUserToGroups(ctx context.Context, req *pbGroup.InviteUserToGroupsReq) (*pbGroup.InviteUserToGroupsResp, error) {
|
||||||
|
if !token_verify.IsManagerUserID(req.OpUserID) {
|
||||||
|
log.NewError(req.OperationID, "no permission InviteUserToGroup ", req.String())
|
||||||
|
return &pbGroup.InviteUserToGroupsResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
|
||||||
|
}
|
||||||
|
for _, v := range req.GroupIDList {
|
||||||
|
groupInfo, err := imdb.GetGroupInfoByGroupID(v)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", v, err)
|
||||||
|
return &pbGroup.InviteUserToGroupsResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error() + v}, nil
|
||||||
|
}
|
||||||
|
if groupInfo.Status == constant.GroupStatusDismissed {
|
||||||
|
errMsg := " group status is dismissed " + v
|
||||||
|
return &pbGroup.InviteUserToGroupsResp{ErrCode: constant.ErrStatus.ErrCode, ErrMsg: errMsg}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := db.DB.AddUserToSuperGroups(req.GroupIDList, req.InvitedUserID); err != nil {
|
||||||
|
log.NewError(req.OperationID, "AddUserToSuperGroups failed ", err.Error())
|
||||||
|
return &pbGroup.InviteUserToGroupsResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}, nil
|
||||||
|
}
|
||||||
|
if err := rocksCache.DelJoinedSuperGroupIDListFromCache(req.InvitedUserID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
}
|
||||||
|
chat.SuperGroupNotification(req.OperationID, req.InvitedUserID, req.InvitedUserID)
|
||||||
|
|
||||||
|
log.NewInfo(req.OperationID, "InviteUserToGroups rpc return ")
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGroupAllMemberReq) (*pbGroup.GetGroupAllMemberResp, error) {
|
func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGroupAllMemberReq) (*pbGroup.GetGroupAllMemberResp, error) {
|
||||||
log.NewInfo(req.OperationID, "GetGroupAllMember, args ", req.String())
|
log.NewInfo(req.OperationID, "GetGroupAllMember, args ", req.String())
|
||||||
var resp pbGroup.GetGroupAllMemberResp
|
var resp pbGroup.GetGroupAllMemberResp
|
||||||
@@ -724,6 +772,33 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
|||||||
resp.ErrMsg = constant.ErrDB.ErrMsg
|
resp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
|
||||||
|
}
|
||||||
|
if err := rocksCache.DelGroupMemberIDListFromCache(req.GroupID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||||
|
}
|
||||||
|
reqPb := pbConversation.ModifyConversationFieldReq{Conversation: &pbConversation.Conversation{}}
|
||||||
|
reqPb.OperationID = req.OperationID
|
||||||
|
reqPb.UserIDList = okUserIDList
|
||||||
|
reqPb.FieldType = constant.FieldUnread
|
||||||
|
reqPb.Conversation.GroupID = req.GroupID
|
||||||
|
reqPb.Conversation.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.SuperGroupChatType)
|
||||||
|
reqPb.Conversation.ConversationType = int32(constant.SuperGroupChatType)
|
||||||
|
reqPb.Conversation.UpdateUnreadCountTime = utils.GetCurrentTimestampByMill()
|
||||||
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, req.OperationID)
|
||||||
|
if etcdConn == nil {
|
||||||
|
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
|
log.NewError(req.OperationID, errMsg)
|
||||||
|
}
|
||||||
|
client := pbConversation.NewConversationClient(etcdConn)
|
||||||
|
respPb, err := client.ModifyConversationField(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ModifyConversationField rpc failed, ", reqPb.String(), err.Error())
|
||||||
|
} else {
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "ModifyConversationField success", respPb.String())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if groupInfo.GroupType != constant.SuperGroup {
|
if groupInfo.GroupType != constant.SuperGroup {
|
||||||
@@ -757,7 +832,15 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
|
|||||||
var resp pbGroup.GetGroupMembersInfoResp
|
var resp pbGroup.GetGroupMembersInfoResp
|
||||||
resp.MemberList = []*open_im_sdk.GroupMemberFullInfo{}
|
resp.MemberList = []*open_im_sdk.GroupMemberFullInfo{}
|
||||||
for _, userID := range req.MemberList {
|
for _, userID := range req.MemberList {
|
||||||
groupMember, err := rocksCache.GetGroupMemberInfoFromCache(req.GroupID, userID)
|
var (
|
||||||
|
groupMember *db.GroupMember
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if req.NoCache {
|
||||||
|
groupMember, err = imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, userID)
|
||||||
|
} else {
|
||||||
|
groupMember, err = rocksCache.GetGroupMemberInfoFromCache(req.GroupID, userID)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, userID, err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, userID, err.Error())
|
||||||
continue
|
continue
|
||||||
@@ -862,6 +945,10 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
|
|||||||
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), req.FromUserID)
|
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), req.FromUserID)
|
||||||
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
|
if imdb.IsExistGroupMember(req.GroupID, req.FromUserID) {
|
||||||
|
log.NewInfo(req.OperationID, "GroupApplicationResponse user in group", req.GroupID, req.FromUserID)
|
||||||
|
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{}}, nil
|
||||||
|
}
|
||||||
member := db.GroupMember{}
|
member := db.GroupMember{}
|
||||||
member.GroupID = req.GroupID
|
member.GroupID = req.GroupID
|
||||||
member.UserID = req.FromUserID
|
member.UserID = req.FromUserID
|
||||||
@@ -977,12 +1064,15 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
|
|||||||
|
|
||||||
func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) (*pbGroup.JoinGroupResp, error) {
|
func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) (*pbGroup.JoinGroupResp, error) {
|
||||||
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
|
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
|
||||||
|
if imdb.IsExistGroupMember(req.GroupID, req.OpUserID) {
|
||||||
|
log.NewInfo(req.OperationID, "IsExistGroupMember", req.GroupID, req.OpUserID)
|
||||||
|
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{}}, nil
|
||||||
|
}
|
||||||
_, err := imdb.GetUserByUserID(req.OpUserID)
|
_, err := imdb.GetUserByUserID(req.OpUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OpUserID)
|
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OpUserID)
|
||||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
groupInfo, err := rocksCache.GetGroupInfoFromCache(req.GroupID)
|
groupInfo, err := rocksCache.GetGroupInfoFromCache(req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", req.GroupID, err)
|
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", req.GroupID, err)
|
||||||
@@ -1275,7 +1365,8 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, "SetGroupInfo rpc return ", pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}})
|
log.NewInfo(req.OperationID, "SetGroupInfo rpc return ", pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}})
|
||||||
if changedType != 0 {
|
if changedType != 0 {
|
||||||
chat.GroupInfoSetNotification(req.OperationID, req.OpUserID, req.GroupInfoForSet.GroupID, groupName, notification, introduction, faceURL, req.GroupInfoForSet.NeedVerification)
|
chat.GroupInfoSetNotification(req.OperationID, req.OpUserID, req.GroupInfoForSet.GroupID, groupName, notification,
|
||||||
|
introduction, faceURL, req.GroupInfoForSet.NeedVerification, req.GroupInfoForSet.ApplyMemberFriend, req.GroupInfoForSet.LookMemberInfo)
|
||||||
}
|
}
|
||||||
if req.GroupInfoForSet.Notification != "" {
|
if req.GroupInfoForSet.Notification != "" {
|
||||||
//get group member user id
|
//get group member user id
|
||||||
@@ -1955,3 +2046,53 @@ func (s *groupServer) DelGroupAndUserCache(operationID, groupID string, userIDLi
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *groupServer) GroupIsExist(c context.Context, req *pbGroup.GroupIsExistReq) (*pbGroup.GroupIsExistResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp := &pbGroup.GroupIsExistResp{CommonResp: &pbGroup.CommonResp{}}
|
||||||
|
groups, err := imdb.GetGroupInfoByGroupIDList(req.GroupIDList)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), "args:", req.GroupIDList)
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
var m = make(map[string]bool)
|
||||||
|
for _, groupID := range req.GroupIDList {
|
||||||
|
m[groupID] = false
|
||||||
|
for _, group := range groups {
|
||||||
|
if groupID == group.GroupID {
|
||||||
|
m[groupID] = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resp.IsExistMap = m
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *groupServer) UserIsInGroup(c context.Context, req *pbGroup.UserIsInGroupReq) (*pbGroup.UserIsInGroupResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp := &pbGroup.UserIsInGroupResp{}
|
||||||
|
groupMemberList, err := imdb.GetGroupMemberByUserIDList(req.GroupID, req.UserIDList)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), "args:", req.GroupID, req.UserIDList)
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
var m = make(map[string]bool)
|
||||||
|
for _, userID := range req.UserIDList {
|
||||||
|
m[userID] = false
|
||||||
|
for _, user := range groupMemberList {
|
||||||
|
if userID == user.UserID {
|
||||||
|
m[userID] = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resp.IsExistMap = m
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -140,13 +140,15 @@ func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp
|
|||||||
func callbackMsgModify(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
|
func callbackMsgModify(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
|
||||||
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
|
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
|
||||||
callbackResp := cbApi.CommonCallbackResp{OperationID: msg.OperationID}
|
callbackResp := cbApi.CommonCallbackResp{OperationID: msg.OperationID}
|
||||||
if !config.Config.Callback.CallbackMsgModify.Enable || msg.MsgData.ContentType != constant.Text {
|
if !config.Config.Callback.CallbackMsgModify.Enable {
|
||||||
return callbackResp
|
return callbackResp
|
||||||
}
|
}
|
||||||
commonCallbackReq := copyCallbackCommonReqStruct(msg)
|
commonCallbackReq := copyCallbackCommonReqStruct(msg)
|
||||||
commonCallbackReq.CallbackCommand = constant.CallbackMsgModifyCommand
|
commonCallbackReq.CallbackCommand = constant.CallbackMsgModifyCommand
|
||||||
req := cbApi.CallbackMsgModifyCommandReq{
|
req := cbApi.CallbackMsgModifyCommandReq{
|
||||||
CommonCallbackReq: commonCallbackReq,
|
CommonCallbackReq: commonCallbackReq,
|
||||||
|
GroupID: msg.MsgData.GroupID,
|
||||||
|
RecvID: msg.MsgData.RecvID,
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackMsgModifyCommandResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackMsgModifyCommandResp{CommonCallbackResp: &callbackResp}
|
||||||
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
|
||||||
"Open_IM/pkg/proto/msg"
|
"Open_IM/pkg/proto/msg"
|
||||||
|
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
@@ -39,14 +39,14 @@ func (rpc *rpcChat) DelSuperGroupMsg(_ context.Context, req *msg.DelSuperGroupMs
|
|||||||
resp := &msg.DelSuperGroupMsgResp{}
|
resp := &msg.DelSuperGroupMsgResp{}
|
||||||
groupMaxSeq, err := db.DB.GetGroupMaxSeq(req.GroupID)
|
groupMaxSeq, err := db.DB.GetGroupMaxSeq(req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetGroupMaxSeq false ", req.OpUserID, req.UserID,req.GroupID)
|
log.NewError(req.OperationID, "GetGroupMaxSeq false ", req.OpUserID, req.UserID, req.GroupID)
|
||||||
resp.ErrCode = constant.ErrDB.ErrCode
|
resp.ErrCode = constant.ErrDB.ErrCode
|
||||||
resp.ErrMsg = err.Error()
|
resp.ErrMsg = err.Error()
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
err = db.DB.SetGroupUserMinSeq(req.GroupID,req.UserID, groupMaxSeq)
|
err = db.DB.SetGroupUserMinSeq(req.GroupID, req.UserID, groupMaxSeq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "SetGroupUserMinSeq false ", req.OpUserID, req.UserID,req.GroupID)
|
log.NewError(req.OperationID, "SetGroupUserMinSeq false ", req.OpUserID, req.UserID, req.GroupID)
|
||||||
resp.ErrCode = constant.ErrDB.ErrCode
|
resp.ErrCode = constant.ErrDB.ErrCode
|
||||||
resp.ErrMsg = err.Error()
|
resp.ErrMsg = err.Error()
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.S
|
|||||||
}
|
}
|
||||||
rResp.MsgFirstModifyTime = callbackResp.MsgFirstModifyTime
|
rResp.MsgFirstModifyTime = callbackResp.MsgFirstModifyTime
|
||||||
rResp.Result = callbackResp.ResultReactionExtensionList
|
rResp.Result = callbackResp.ResultReactionExtensionList
|
||||||
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, isHistory, false)
|
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.OpUserIDPlatformID, req.SessionType, req, &rResp, isHistory, false)
|
||||||
return &rResp, nil
|
return &rResp, nil
|
||||||
}
|
}
|
||||||
for _, v := range callbackResp.ResultReactionExtensionList {
|
for _, v := range callbackResp.ResultReactionExtensionList {
|
||||||
@@ -187,12 +187,12 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.S
|
|||||||
}
|
}
|
||||||
if !isExists {
|
if !isExists {
|
||||||
if !req.IsReact {
|
if !req.IsReact {
|
||||||
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, true, true)
|
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.OpUserIDPlatformID, req.SessionType, req, &rResp, true, true)
|
||||||
} else {
|
} else {
|
||||||
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, false)
|
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.OpUserIDPlatformID, req.SessionType, req, &rResp, false, false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, true)
|
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.OpUserIDPlatformID, req.SessionType, req, &rResp, false, true)
|
||||||
}
|
}
|
||||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc return is:", rResp.String())
|
log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc return is:", rResp.String())
|
||||||
return &rResp, nil
|
return &rResp, nil
|
||||||
@@ -218,6 +218,17 @@ func setDeleteKeyResultInfo(r *msg.DeleteMessageListReactionExtensionsResp, errC
|
|||||||
func (rpc *rpcChat) GetMessageListReactionExtensions(ctx context.Context, req *msg.GetMessageListReactionExtensionsReq) (resp *msg.GetMessageListReactionExtensionsResp, err error) {
|
func (rpc *rpcChat) GetMessageListReactionExtensions(ctx context.Context, req *msg.GetMessageListReactionExtensionsReq) (resp *msg.GetMessageListReactionExtensionsResp, err error) {
|
||||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc args is:", req.String())
|
log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc args is:", req.String())
|
||||||
var rResp msg.GetMessageListReactionExtensionsResp
|
var rResp msg.GetMessageListReactionExtensionsResp
|
||||||
|
if req.IsExternalExtensions {
|
||||||
|
callbackResp := callbackGetMessageListReactionExtensions(req)
|
||||||
|
if callbackResp.ActionCode != constant.ActionAllow || callbackResp.ErrCode != 0 {
|
||||||
|
rResp.ErrCode = int32(callbackResp.ErrCode)
|
||||||
|
rResp.ErrMsg = callbackResp.ErrMsg
|
||||||
|
return &rResp, nil
|
||||||
|
} else {
|
||||||
|
rResp.SingleMessageResult = callbackResp.MessageResultList
|
||||||
|
return &rResp, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, messageValue := range req.MessageReactionKeyList {
|
for _, messageValue := range req.MessageReactionKeyList {
|
||||||
var oneMessage msg.SingleMessageExtensionResult
|
var oneMessage msg.SingleMessageExtensionResult
|
||||||
oneMessage.ClientMsgID = messageValue.ClientMsgID
|
oneMessage.ClientMsgID = messageValue.ClientMsgID
|
||||||
@@ -271,8 +282,50 @@ func (rpc *rpcChat) GetMessageListReactionExtensions(ctx context.Context, req *m
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rpc *rpcChat) AddMessageReactionExtensions(ctx context.Context, req *msg.ModifyMessageReactionExtensionsReq) (resp *msg.ModifyMessageReactionExtensionsResp, err error) {
|
func (rpc *rpcChat) AddMessageReactionExtensions(ctx context.Context, req *msg.AddMessageReactionExtensionsReq) (resp *msg.AddMessageReactionExtensionsResp, err error) {
|
||||||
return
|
log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc args is:", req.String())
|
||||||
|
var rResp msg.AddMessageReactionExtensionsResp
|
||||||
|
rResp.ClientMsgID = req.ClientMsgID
|
||||||
|
rResp.MsgFirstModifyTime = req.MsgFirstModifyTime
|
||||||
|
callbackResp := callbackAddMessageReactionExtensions(req)
|
||||||
|
if callbackResp.ActionCode != constant.ActionAllow || callbackResp.ErrCode != 0 {
|
||||||
|
rResp.ErrCode = int32(callbackResp.ErrCode)
|
||||||
|
rResp.ErrMsg = callbackResp.ErrMsg
|
||||||
|
for _, value := range callbackResp.ResultReactionExtensionList {
|
||||||
|
temp := new(msg.KeyValueResp)
|
||||||
|
temp.KeyValue = value.KeyValue
|
||||||
|
temp.ErrMsg = value.ErrMsg
|
||||||
|
temp.ErrCode = value.ErrCode
|
||||||
|
rResp.Result = append(rResp.Result, temp)
|
||||||
|
}
|
||||||
|
return &rResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//if !req.IsExternalExtensions {
|
||||||
|
// rResp.ErrCode = 200
|
||||||
|
// rResp.ErrMsg = "only extenalextensions message can be used"
|
||||||
|
// for _, value := range req.ReactionExtensionList {
|
||||||
|
// temp := new(msg.KeyValueResp)
|
||||||
|
// temp.KeyValue = value
|
||||||
|
// temp.ErrMsg = callbackResp.ErrMsg
|
||||||
|
// temp.ErrCode = 100
|
||||||
|
// rResp.Result = append(rResp.Result, temp)
|
||||||
|
// }
|
||||||
|
// return &rResp, nil
|
||||||
|
//}
|
||||||
|
//if ExternalExtension
|
||||||
|
var isHistory bool
|
||||||
|
if req.IsReact {
|
||||||
|
isHistory = false
|
||||||
|
} else {
|
||||||
|
isHistory = true
|
||||||
|
}
|
||||||
|
rResp.MsgFirstModifyTime = callbackResp.MsgFirstModifyTime
|
||||||
|
rResp.Result = callbackResp.ResultReactionExtensionList
|
||||||
|
rResp.IsReact = callbackResp.IsReact
|
||||||
|
ExtendMessageAddedNotification(req.OperationID, req.OpUserID, req.SourceID, req.OpUserIDPlatformID, req.SessionType, req, &rResp, isHistory, false)
|
||||||
|
log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc return is:", resp.String())
|
||||||
|
return &rResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *msg.DeleteMessageListReactionExtensionsReq) (resp *msg.DeleteMessageListReactionExtensionsResp, err error) {
|
func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *msg.DeleteMessageListReactionExtensionsReq) (resp *msg.DeleteMessageListReactionExtensionsResp, err error) {
|
||||||
@@ -294,7 +347,7 @@ func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *ms
|
|||||||
//if ExternalExtension
|
//if ExternalExtension
|
||||||
if req.IsExternalExtensions {
|
if req.IsExternalExtensions {
|
||||||
rResp.Result = callbackResp.ResultReactionExtensionList
|
rResp.Result = callbackResp.ResultReactionExtensionList
|
||||||
ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, false)
|
ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.SourceID, req.OpUserIDPlatformID, req.SessionType, req, &rResp, false, false)
|
||||||
return &rResp, nil
|
return &rResp, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -418,7 +471,7 @@ func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *ms
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, isExists)
|
ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.SourceID, req.OpUserIDPlatformID, req.SessionType, req, &rResp, false, isExists)
|
||||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc return is:", rResp.String())
|
log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc return is:", rResp.String())
|
||||||
return &rResp, nil
|
return &rResp, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID string, sessionType int32,
|
func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID string, senderPlatformID, sessionType int32,
|
||||||
req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
||||||
var m base_info.ReactionMessageModifierNotification
|
var m base_info.ReactionMessageModifierNotification
|
||||||
m.SourceID = req.SourceID
|
m.SourceID = req.SourceID
|
||||||
m.OpUserID = req.OpUserID
|
m.OpUserID = req.OpUserID
|
||||||
|
m.Operation = constant.SetMessageExtensions
|
||||||
m.SessionType = req.SessionType
|
m.SessionType = req.SessionType
|
||||||
keyMap := make(map[string]*open_im_sdk.KeyValue)
|
keyMap := make(map[string]*open_im_sdk.KeyValue)
|
||||||
for _, valueResp := range resp.Result {
|
for _, valueResp := range resp.Result {
|
||||||
@@ -34,9 +35,34 @@ func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID strin
|
|||||||
m.IsReact = resp.IsReact
|
m.IsReact = resp.IsReact
|
||||||
m.IsExternalExtensions = req.IsExternalExtensions
|
m.IsExternalExtensions = req.IsExternalExtensions
|
||||||
m.MsgFirstModifyTime = resp.MsgFirstModifyTime
|
m.MsgFirstModifyTime = resp.MsgFirstModifyTime
|
||||||
messageReactionSender(operationID, sendID, sourceID, sessionType, constant.ReactionMessageModifier, utils.StructToJsonString(m), isHistory, isReactionFromCache)
|
messageReactionSender(operationID, sendID, sourceID, senderPlatformID, sessionType, constant.ReactionMessageModifier, utils.StructToJsonString(m), isHistory, isReactionFromCache)
|
||||||
}
|
}
|
||||||
func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string, sessionType int32,
|
func ExtendMessageAddedNotification(operationID, sendID string, sourceID string, senderPlatformID, sessionType int32,
|
||||||
|
req *msg.AddMessageReactionExtensionsReq, resp *msg.AddMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
||||||
|
var m base_info.ReactionMessageModifierNotification
|
||||||
|
m.SourceID = req.SourceID
|
||||||
|
m.OpUserID = req.OpUserID
|
||||||
|
m.Operation = constant.AddMessageExtensions
|
||||||
|
m.SessionType = req.SessionType
|
||||||
|
keyMap := make(map[string]*open_im_sdk.KeyValue)
|
||||||
|
for _, valueResp := range resp.Result {
|
||||||
|
if valueResp.ErrCode == 0 {
|
||||||
|
keyMap[valueResp.KeyValue.TypeKey] = valueResp.KeyValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(keyMap) == 0 {
|
||||||
|
log.NewWarn(operationID, "all key set failed can not send notification", *req)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.SuccessReactionExtensionList = keyMap
|
||||||
|
m.ClientMsgID = req.ClientMsgID
|
||||||
|
m.IsReact = resp.IsReact
|
||||||
|
m.IsExternalExtensions = req.IsExternalExtensions
|
||||||
|
m.Seq = req.Seq
|
||||||
|
m.MsgFirstModifyTime = resp.MsgFirstModifyTime
|
||||||
|
messageReactionSender(operationID, sendID, sourceID, senderPlatformID, sessionType, constant.ReactionMessageModifier, utils.StructToJsonString(m), isHistory, isReactionFromCache)
|
||||||
|
}
|
||||||
|
func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string, senderPlatformID, sessionType int32,
|
||||||
req *msg.DeleteMessageListReactionExtensionsReq, resp *msg.DeleteMessageListReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
req *msg.DeleteMessageListReactionExtensionsReq, resp *msg.DeleteMessageListReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
||||||
var m base_info.ReactionMessageDeleteNotification
|
var m base_info.ReactionMessageDeleteNotification
|
||||||
m.SourceID = req.SourceID
|
m.SourceID = req.SourceID
|
||||||
@@ -56,9 +82,9 @@ func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string
|
|||||||
m.ClientMsgID = req.ClientMsgID
|
m.ClientMsgID = req.ClientMsgID
|
||||||
m.MsgFirstModifyTime = req.MsgFirstModifyTime
|
m.MsgFirstModifyTime = req.MsgFirstModifyTime
|
||||||
|
|
||||||
messageReactionSender(operationID, sendID, sourceID, sessionType, constant.ReactionMessageDeleter, utils.StructToJsonString(m), isHistory, isReactionFromCache)
|
messageReactionSender(operationID, sendID, sourceID, senderPlatformID, sessionType, constant.ReactionMessageDeleter, utils.StructToJsonString(m), isHistory, isReactionFromCache)
|
||||||
}
|
}
|
||||||
func messageReactionSender(operationID, sendID string, sourceID string, sessionType, contentType int32, content string, isHistory bool, isReactionFromCache bool) {
|
func messageReactionSender(operationID, sendID string, sourceID string, senderPlatformID, sessionType, contentType int32, content string, isHistory bool, isReactionFromCache bool) {
|
||||||
options := make(map[string]bool, 5)
|
options := make(map[string]bool, 5)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||||
@@ -73,6 +99,7 @@ func messageReactionSender(operationID, sendID string, sourceID string, sessionT
|
|||||||
OperationID: operationID,
|
OperationID: operationID,
|
||||||
MsgData: &open_im_sdk.MsgData{
|
MsgData: &open_im_sdk.MsgData{
|
||||||
SendID: sendID,
|
SendID: sendID,
|
||||||
|
SenderPlatformID: senderPlatformID,
|
||||||
ClientMsgID: utils.GetMsgID(sendID),
|
ClientMsgID: utils.GetMsgID(sendID),
|
||||||
SessionType: sessionType,
|
SessionType: sessionType,
|
||||||
MsgFrom: constant.SysMsgType,
|
MsgFrom: constant.SysMsgType,
|
||||||
|
|||||||
@@ -58,3 +58,47 @@ func callbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReacti
|
|||||||
}
|
}
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
func callbackGetMessageListReactionExtensions(getReq *msg.GetMessageListReactionExtensionsReq) *cbApi.CallbackGetMessageListReactionExtResp {
|
||||||
|
callbackResp := cbApi.CommonCallbackResp{OperationID: getReq.OperationID}
|
||||||
|
log.NewDebug(getReq.OperationID, utils.GetSelfFuncName(), getReq.String())
|
||||||
|
req := cbApi.CallbackGetMessageListReactionExtReq{
|
||||||
|
OperationID: getReq.OperationID,
|
||||||
|
CallbackCommand: constant.CallbackGetMessageListReactionExtensionsCommand,
|
||||||
|
SourceID: getReq.SourceID,
|
||||||
|
OpUserID: getReq.OpUserID,
|
||||||
|
SessionType: getReq.SessionType,
|
||||||
|
TypeKeyList: getReq.TypeKeyList,
|
||||||
|
MessageKeyList: getReq.MessageReactionKeyList,
|
||||||
|
}
|
||||||
|
resp := &cbApi.CallbackGetMessageListReactionExtResp{CommonCallbackResp: &callbackResp}
|
||||||
|
defer log.NewDebug(getReq.OperationID, utils.GetSelfFuncName(), req, *resp)
|
||||||
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackGetMessageListReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil {
|
||||||
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
|
callbackResp.ErrMsg = err.Error()
|
||||||
|
}
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
func callbackAddMessageReactionExtensions(setReq *msg.AddMessageReactionExtensionsReq) *cbApi.CallbackAddMessageReactionExtResp {
|
||||||
|
callbackResp := cbApi.CommonCallbackResp{OperationID: setReq.OperationID}
|
||||||
|
log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String())
|
||||||
|
req := cbApi.CallbackAddMessageReactionExtReq{
|
||||||
|
OperationID: setReq.OperationID,
|
||||||
|
CallbackCommand: constant.CallbackAddMessageListReactionExtensionsCommand,
|
||||||
|
SourceID: setReq.SourceID,
|
||||||
|
OpUserID: setReq.OpUserID,
|
||||||
|
SessionType: setReq.SessionType,
|
||||||
|
ReactionExtensionList: setReq.ReactionExtensionList,
|
||||||
|
ClientMsgID: setReq.ClientMsgID,
|
||||||
|
IsReact: setReq.IsReact,
|
||||||
|
IsExternalExtensions: setReq.IsExternalExtensions,
|
||||||
|
MsgFirstModifyTime: setReq.MsgFirstModifyTime,
|
||||||
|
}
|
||||||
|
resp := &cbApi.CallbackAddMessageReactionExtResp{CommonCallbackResp: &callbackResp}
|
||||||
|
defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp, *resp.CommonCallbackResp, resp.IsReact, resp.MsgFirstModifyTime)
|
||||||
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAddMessageListReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil {
|
||||||
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
|
callbackResp.ErrMsg = err.Error()
|
||||||
|
}
|
||||||
|
return resp
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -245,12 +245,15 @@ func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberL
|
|||||||
// notification := ""
|
// notification := ""
|
||||||
// introduction := ""
|
// introduction := ""
|
||||||
// faceURL := ""
|
// faceURL := ""
|
||||||
func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, notification, introduction, faceURL string, needVerification *wrapperspb.Int32Value) {
|
func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, notification, introduction, faceURL string, needVerification, applyMemberFriend, lookMemberInfo *wrapperspb.Int32Value) {
|
||||||
GroupInfoChangedTips := open_im_sdk.GroupInfoSetTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
GroupInfoChangedTips := open_im_sdk.GroupInfoSetTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
if err := setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil {
|
if err := setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil {
|
||||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
GroupInfoChangedTips.Group.NeedVerification = 0
|
||||||
|
GroupInfoChangedTips.Group.LookMemberInfo = 0
|
||||||
|
GroupInfoChangedTips.Group.ApplyMemberFriend = 0
|
||||||
GroupInfoChangedTips.Group.GroupName = groupName
|
GroupInfoChangedTips.Group.GroupName = groupName
|
||||||
GroupInfoChangedTips.Group.Notification = notification
|
GroupInfoChangedTips.Group.Notification = notification
|
||||||
GroupInfoChangedTips.Group.Introduction = introduction
|
GroupInfoChangedTips.Group.Introduction = introduction
|
||||||
@@ -258,6 +261,12 @@ func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName,
|
|||||||
if needVerification != nil {
|
if needVerification != nil {
|
||||||
GroupInfoChangedTips.Group.NeedVerification = needVerification.Value
|
GroupInfoChangedTips.Group.NeedVerification = needVerification.Value
|
||||||
}
|
}
|
||||||
|
if applyMemberFriend != nil {
|
||||||
|
GroupInfoChangedTips.Group.ApplyMemberFriend = applyMemberFriend.Value
|
||||||
|
}
|
||||||
|
if lookMemberInfo != nil {
|
||||||
|
GroupInfoChangedTips.Group.LookMemberInfo = lookMemberInfo.Value
|
||||||
|
}
|
||||||
|
|
||||||
if err := setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil {
|
if err := setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil {
|
||||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.Pull
|
|||||||
} else {
|
} else {
|
||||||
log.Debug(in.OperationID, "get message from redis is nil", failedSeqList)
|
log.Debug(in.OperationID, "get message from redis is nil", failedSeqList)
|
||||||
}
|
}
|
||||||
msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(k, failedSeqList, in.OperationID)
|
msgList, _, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(k, failedSeqList, in.OperationID)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList))
|
promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList))
|
||||||
log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err1.Error())
|
log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err1.Error())
|
||||||
@@ -115,12 +115,12 @@ func (s MsgFormats) Len() int {
|
|||||||
return len(s)
|
return len(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Implement the sort.Interface interface comparison element method
|
// Implement the sort.Interface interface comparison element method
|
||||||
func (s MsgFormats) Less(i, j int) bool {
|
func (s MsgFormats) Less(i, j int) bool {
|
||||||
return s[i].SendTime < s[j].SendTime
|
return s[i].SendTime < s[j].SendTime
|
||||||
}
|
}
|
||||||
|
|
||||||
//Implement the sort.Interface interface exchange element method
|
// Implement the sort.Interface interface exchange element method
|
||||||
func (s MsgFormats) Swap(i, j int) {
|
func (s MsgFormats) Swap(i, j int) {
|
||||||
s[i], s[j] = s[j], s[i]
|
s[i], s[j] = s[j], s[i]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func (rpc *rpcChat) GetSuperGroupMsg(context context.Context, req *msg.GetSuperG
|
|||||||
} else {
|
} else {
|
||||||
log.Debug(req.OperationID, "get message from redis is nil", failedSeqList)
|
log.Debug(req.OperationID, "get message from redis is nil", failedSeqList)
|
||||||
}
|
}
|
||||||
msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(req.GroupID, failedSeqList, req.OperationID)
|
msgList, _, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(req.GroupID, failedSeqList, req.OperationID)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList))
|
promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList))
|
||||||
log.Error(req.OperationID, "GetSuperGroupMsg data error", req.String(), err.Error())
|
log.Error(req.OperationID, "GetSuperGroupMsg data error", req.String(), err.Error())
|
||||||
|
|||||||
@@ -145,14 +145,9 @@ func (rpc *rpcChat) runCh() {
|
|||||||
select {
|
select {
|
||||||
case msg := <-rpc.delMsgCh:
|
case msg := <-rpc.delMsgCh:
|
||||||
log.NewInfo(msg.OperationID, utils.GetSelfFuncName(), "delmsgch recv new: ", msg)
|
log.NewInfo(msg.OperationID, utils.GetSelfFuncName(), "delmsgch recv new: ", msg)
|
||||||
|
if len(msg.SeqList) > 0 {
|
||||||
db.DB.DelMsgFromCache(msg.UserID, msg.SeqList, msg.OperationID)
|
db.DB.DelMsgFromCache(msg.UserID, msg.SeqList, msg.OperationID)
|
||||||
unexistSeqList, err := db.DB.DelMsgBySeqList(msg.UserID, msg.SeqList, msg.OperationID)
|
DeleteMessageNotification(msg.OpUserID, msg.UserID, msg.SeqList, msg.OperationID)
|
||||||
if err != nil {
|
|
||||||
log.NewError(msg.OperationID, utils.GetSelfFuncName(), "DelMsgBySeqList args: ", msg.UserID, msg.SeqList, msg.OperationID, err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if len(unexistSeqList) > 0 {
|
|
||||||
DeleteMessageNotification(msg.OpUserID, msg.UserID, unexistSeqList, msg.OperationID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
promePkg "Open_IM/pkg/common/prometheus"
|
promePkg "Open_IM/pkg/common/prometheus"
|
||||||
|
|
||||||
go_redis "github.com/go-redis/redis/v8"
|
go_redis "github.com/go-redis/redis/v8"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//When the number of group members is greater than this value,Online users will be sent first,Guaranteed service availability
|
// When the number of group members is greater than this value,Online users will be sent first,Guaranteed service availability
|
||||||
const GroupMemberNum = 500
|
const GroupMemberNum = 500
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -125,7 +126,7 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s
|
|||||||
if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) {
|
if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) {
|
||||||
return true, 0, "", nil
|
return true, 0, "", nil
|
||||||
}
|
}
|
||||||
if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin {
|
if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin && data.MsgData.ContentType != constant.SignalingNotification {
|
||||||
return true, 0, "", nil
|
return true, 0, "", nil
|
||||||
}
|
}
|
||||||
log.NewDebug(data.OperationID, *config.Config.MessageVerify.FriendVerify)
|
log.NewDebug(data.OperationID, *config.Config.MessageVerify.FriendVerify)
|
||||||
@@ -347,7 +348,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
log.Info(pb.OperationID, "rpc sendMsg come here ", pb.String())
|
log.Info(pb.OperationID, "rpc sendMsg come here ", pb.String())
|
||||||
flag, errCode, errMsg := isMessageHasReadEnabled(pb)
|
flag, errCode, errMsg := isMessageHasReadEnabled(pb)
|
||||||
if !flag {
|
if !flag {
|
||||||
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
|
return returnMsg(&replay, pb, errCode, errMsg, "", 0, "")
|
||||||
}
|
}
|
||||||
t1 := time.Now()
|
t1 := time.Now()
|
||||||
rpc.encapsulateMsgData(pb.MsgData)
|
rpc.encapsulateMsgData(pb.MsgData)
|
||||||
@@ -366,7 +367,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
callbackResp.ErrCode = 201
|
callbackResp.ErrCode = 201
|
||||||
}
|
}
|
||||||
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackMsgModify result", "end rpc and return", pb.MsgData)
|
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackMsgModify result", "end rpc and return", pb.MsgData)
|
||||||
return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0)
|
return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0, "")
|
||||||
}
|
}
|
||||||
switch pb.MsgData.SessionType {
|
switch pb.MsgData.SessionType {
|
||||||
case constant.SingleChatType:
|
case constant.SingleChatType:
|
||||||
@@ -384,13 +385,13 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
}
|
}
|
||||||
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp)
|
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp)
|
||||||
promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter)
|
promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter)
|
||||||
return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0)
|
return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0, "")
|
||||||
}
|
}
|
||||||
t1 = time.Now()
|
t1 = time.Now()
|
||||||
flag, errCode, errMsg, _ = rpc.messageVerification(pb)
|
flag, errCode, errMsg, _ = rpc.messageVerification(pb)
|
||||||
log.Debug(pb.OperationID, "messageVerification ", flag, " cost time: ", time.Since(t1))
|
log.Debug(pb.OperationID, "messageVerification ", flag, " cost time: ", time.Since(t1))
|
||||||
if !flag {
|
if !flag {
|
||||||
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
|
return returnMsg(&replay, pb, errCode, errMsg, "", 0, "")
|
||||||
}
|
}
|
||||||
t1 = time.Now()
|
t1 = time.Now()
|
||||||
isSend := modifyMessageByUserMessageReceiveOpt(pb.MsgData.RecvID, pb.MsgData.SendID, constant.SingleChatType, pb)
|
isSend := modifyMessageByUserMessageReceiveOpt(pb.MsgData.RecvID, pb.MsgData.SendID, constant.SingleChatType, pb)
|
||||||
@@ -404,7 +405,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.NewError(msgToMQSingle.OperationID, "kafka send msg err :RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String(), err1.Error())
|
log.NewError(msgToMQSingle.OperationID, "kafka send msg err :RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String(), err1.Error())
|
||||||
promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter)
|
promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter)
|
||||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself
|
if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself
|
||||||
@@ -414,7 +415,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String())
|
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String())
|
||||||
promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter)
|
promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter)
|
||||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// callback
|
// callback
|
||||||
@@ -425,7 +426,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSingleMsg resp: ", callbackResp)
|
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSingleMsg resp: ", callbackResp)
|
||||||
}
|
}
|
||||||
promePkg.PromeInc(promePkg.SingleChatMsgProcessSuccessCounter)
|
promePkg.PromeInc(promePkg.SingleChatMsgProcessSuccessCounter)
|
||||||
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime)
|
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime, msgToMQSingle.MsgData.Ex)
|
||||||
case constant.GroupChatType:
|
case constant.GroupChatType:
|
||||||
// callback
|
// callback
|
||||||
promePkg.PromeInc(promePkg.GroupChatMsgRecvSuccessCounter)
|
promePkg.PromeInc(promePkg.GroupChatMsgRecvSuccessCounter)
|
||||||
@@ -439,12 +440,12 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
}
|
}
|
||||||
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp)
|
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp)
|
||||||
promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter)
|
promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter)
|
||||||
return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0)
|
return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0, "")
|
||||||
}
|
}
|
||||||
var memberUserIDList []string
|
var memberUserIDList []string
|
||||||
if flag, errCode, errMsg, memberUserIDList = rpc.messageVerification(pb); !flag {
|
if flag, errCode, errMsg, memberUserIDList = rpc.messageVerification(pb); !flag {
|
||||||
promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter)
|
promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter)
|
||||||
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
|
return returnMsg(&replay, pb, errCode, errMsg, "", 0, "")
|
||||||
}
|
}
|
||||||
log.Debug(pb.OperationID, "GetGroupAllMember userID list", memberUserIDList, "len: ", len(memberUserIDList))
|
log.Debug(pb.OperationID, "GetGroupAllMember userID list", memberUserIDList, "len: ", len(memberUserIDList))
|
||||||
var addUidList []string
|
var addUidList []string
|
||||||
@@ -508,7 +509,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
if !sendTag {
|
if !sendTag {
|
||||||
log.NewWarn(pb.OperationID, "send tag is ", sendTag)
|
log.NewWarn(pb.OperationID, "send tag is ", sendTag)
|
||||||
promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter)
|
promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter)
|
||||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0, "")
|
||||||
} else {
|
} else {
|
||||||
if pb.MsgData.ContentType == constant.AtText {
|
if pb.MsgData.ContentType == constant.AtText {
|
||||||
go func() {
|
go func() {
|
||||||
@@ -573,7 +574,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
}
|
}
|
||||||
log.Debug(pb.OperationID, "send msg cost time3 ", time.Since(t1), pb.MsgData.ClientMsgID)
|
log.Debug(pb.OperationID, "send msg cost time3 ", time.Since(t1), pb.MsgData.ClientMsgID)
|
||||||
promePkg.PromeInc(promePkg.GroupChatMsgProcessSuccessCounter)
|
promePkg.PromeInc(promePkg.GroupChatMsgProcessSuccessCounter)
|
||||||
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime)
|
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime, msgToMQSingle.MsgData.Ex)
|
||||||
}
|
}
|
||||||
case constant.NotificationChatType:
|
case constant.NotificationChatType:
|
||||||
t1 = time.Now()
|
t1 = time.Now()
|
||||||
@@ -582,19 +583,19 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
err1 := rpc.sendMsgToWriter(&msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus)
|
err1 := rpc.sendMsgToWriter(&msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String())
|
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String())
|
||||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself
|
if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself
|
||||||
err2 := rpc.sendMsgToWriter(&msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus)
|
err2 := rpc.sendMsgToWriter(&msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String())
|
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String())
|
||||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug(pb.OperationID, "send msg cost time ", time.Since(t1), pb.MsgData.ClientMsgID)
|
log.Debug(pb.OperationID, "send msg cost time ", time.Since(t1), pb.MsgData.ClientMsgID)
|
||||||
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime)
|
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime, msgToMQSingle.MsgData.Ex)
|
||||||
case constant.SuperGroupChatType:
|
case constant.SuperGroupChatType:
|
||||||
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgRecvSuccessCounter)
|
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgRecvSuccessCounter)
|
||||||
// callback
|
// callback
|
||||||
@@ -608,11 +609,11 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
}
|
}
|
||||||
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter)
|
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter)
|
||||||
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSuperGroupMsg result", "end rpc and return", callbackResp)
|
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSuperGroupMsg result", "end rpc and return", callbackResp)
|
||||||
return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0)
|
return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0, "")
|
||||||
}
|
}
|
||||||
if flag, errCode, errMsg, _ = rpc.messageVerification(pb); !flag {
|
if flag, errCode, errMsg, _ = rpc.messageVerification(pb); !flag {
|
||||||
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter)
|
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter)
|
||||||
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
|
return returnMsg(&replay, pb, errCode, errMsg, "", 0, "")
|
||||||
}
|
}
|
||||||
msgToMQSingle.MsgData = pb.MsgData
|
msgToMQSingle.MsgData = pb.MsgData
|
||||||
log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle)
|
log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle)
|
||||||
@@ -620,7 +621,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String())
|
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String())
|
||||||
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter)
|
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter)
|
||||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0, "")
|
||||||
}
|
}
|
||||||
// callback
|
// callback
|
||||||
callbackResp = callbackAfterSendGroupMsg(pb)
|
callbackResp = callbackAfterSendGroupMsg(pb)
|
||||||
@@ -628,10 +629,10 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSuperGroupMsg resp: ", callbackResp)
|
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSuperGroupMsg resp: ", callbackResp)
|
||||||
}
|
}
|
||||||
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessSuccessCounter)
|
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessSuccessCounter)
|
||||||
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime)
|
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime, msgToMQSingle.MsgData.Ex)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return returnMsg(&replay, pb, 203, "unknown sessionType", "", 0)
|
return returnMsg(&replay, pb, 203, "unknown sessionType", "", 0, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -675,12 +676,13 @@ func GetMsgID(sendID string) string {
|
|||||||
return utils.Md5(t + "-" + sendID + "-" + strconv.Itoa(rand.Int()))
|
return utils.Md5(t + "-" + sendID + "-" + strconv.Itoa(rand.Int()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func returnMsg(replay *pbChat.SendMsgResp, pb *pbChat.SendMsgReq, errCode int32, errMsg, serverMsgID string, sendTime int64) (*pbChat.SendMsgResp, error) {
|
func returnMsg(replay *pbChat.SendMsgResp, pb *pbChat.SendMsgReq, errCode int32, errMsg, serverMsgID string, sendTime int64, ex string) (*pbChat.SendMsgResp, error) {
|
||||||
replay.ErrCode = errCode
|
replay.ErrCode = errCode
|
||||||
replay.ErrMsg = errMsg
|
replay.ErrMsg = errMsg
|
||||||
replay.ServerMsgID = serverMsgID
|
replay.ServerMsgID = serverMsgID
|
||||||
replay.ClientMsgID = pb.MsgData.ClientMsgID
|
replay.ClientMsgID = pb.MsgData.ClientMsgID
|
||||||
replay.SendTime = sendTime
|
replay.SendTime = sendTime
|
||||||
|
replay.Ex = ex
|
||||||
return replay, nil
|
return replay, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ func SuperGroupNotification(operationID, sendID, recvID string) {
|
|||||||
SessionType: constant.SingleChatType,
|
SessionType: constant.SingleChatType,
|
||||||
OperationID: operationID,
|
OperationID: operationID,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content))
|
log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content))
|
||||||
Notification(n)
|
Notification(n)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,6 +163,22 @@ func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.Batc
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v.ConversationType == constant.SuperGroupChatType {
|
||||||
|
if v.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
||||||
|
if err := db.DB.SetSuperGroupUserReceiveNotNotifyMessage(v.GroupID, v.OwnerUserID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), v.GroupID, v.OwnerUserID)
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := db.DB.SetSuperGroupUserReceiveNotifyMessage(v.GroupID, v.OwnerUserID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), v.GroupID, err.Error())
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isUpdate, err := imdb.SetConversation(conversation)
|
isUpdate, err := imdb.SetConversation(conversation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
||||||
@@ -251,7 +267,7 @@ func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConvers
|
|||||||
if req.NotificationType == 0 {
|
if req.NotificationType == 0 {
|
||||||
req.NotificationType = constant.ConversationOptChangeNotification
|
req.NotificationType = constant.ConversationOptChangeNotification
|
||||||
}
|
}
|
||||||
if req.Conversation.ConversationType == constant.GroupChatType {
|
if req.Conversation.ConversationType == constant.GroupChatType || req.Conversation.ConversationType == constant.SuperGroupChatType {
|
||||||
groupInfo, err := imdb.GetGroupInfoByGroupID(req.Conversation.GroupID)
|
groupInfo, err := imdb.GetGroupInfoByGroupID(req.Conversation.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", req.Conversation.GroupID, err.Error())
|
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", req.Conversation.GroupID, err.Error())
|
||||||
@@ -264,7 +280,24 @@ func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConvers
|
|||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.Conversation.ConversationType == constant.SuperGroupChatType {
|
||||||
|
if req.Conversation.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
||||||
|
if err = db.DB.SetSuperGroupUserReceiveNotNotifyMessage(req.Conversation.GroupID, req.Conversation.OwnerUserID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, req.Conversation.OwnerUserID)
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if err = db.DB.SetSuperGroupUserReceiveNotifyMessage(req.Conversation.GroupID, req.Conversation.OwnerUserID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, err.Error())
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var conversation db.Conversation
|
var conversation db.Conversation
|
||||||
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
|
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", *req.Conversation, err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", *req.Conversation, err.Error())
|
||||||
@@ -326,6 +359,21 @@ func (s *userServer) SetRecvMsgOpt(ctx context.Context, req *pbUser.SetRecvMsgOp
|
|||||||
case "group":
|
case "group":
|
||||||
conversation.GroupID = stringList[1]
|
conversation.GroupID = stringList[1]
|
||||||
conversation.ConversationType = constant.GroupChatType
|
conversation.ConversationType = constant.GroupChatType
|
||||||
|
case "super_group":
|
||||||
|
conversation.GroupID = stringList[1]
|
||||||
|
if req.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
||||||
|
if err := db.DB.SetSuperGroupUserReceiveNotNotifyMessage(conversation.GroupID, req.OwnerUserID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), conversation.GroupID, req.OwnerUserID)
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := db.DB.SetSuperGroupUserReceiveNotifyMessage(conversation.GroupID, req.OwnerUserID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), conversation.GroupID, req.OwnerUserID)
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isUpdate, err := imdb.SetRecvMsgOpt(conversation)
|
isUpdate, err := imdb.SetRecvMsgOpt(conversation)
|
||||||
@@ -334,6 +382,7 @@ func (s *userServer) SetRecvMsgOpt(ctx context.Context, req *pbUser.SetRecvMsgOp
|
|||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
err = rocksCache.DelConversationFromCache(conversation.OwnerUserID, conversation.ConversationID)
|
err = rocksCache.DelConversationFromCache(conversation.OwnerUserID, conversation.ConversationID)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ type GetGroupMembersInfoReq struct {
|
|||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
MemberList []string `json:"memberList" binding:"required"`
|
MemberList []string `json:"memberList" binding:"required"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
NoCache bool `json:"noCache"`
|
||||||
}
|
}
|
||||||
type GetGroupMembersInfoResp struct {
|
type GetGroupMembersInfoResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
@@ -46,7 +47,15 @@ type InviteUserToGroupResp struct {
|
|||||||
CommResp
|
CommResp
|
||||||
UserIDResultList []*UserIDResult `json:"data"`
|
UserIDResultList []*UserIDResult `json:"data"`
|
||||||
}
|
}
|
||||||
|
type InviteUserToGroupsReq struct {
|
||||||
|
GroupIDList string `json:"groupIDList" binding:"required"`
|
||||||
|
InvitedUserID string `json:"invitedUserID" binding:"required"`
|
||||||
|
Reason string `json:"reason"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
}
|
||||||
|
type InviteUserToGroupsResp struct {
|
||||||
|
CommResp
|
||||||
|
}
|
||||||
type GetJoinedGroupListReq struct {
|
type GetJoinedGroupListReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
FromUserID string `json:"fromUserID" binding:"required"`
|
FromUserID string `json:"fromUserID" binding:"required"`
|
||||||
|
|||||||
+11
-7
@@ -64,6 +64,7 @@ type ModifyMessageReactionExtensionsReq struct {
|
|||||||
IsReact bool `json:"isReact"`
|
IsReact bool `json:"isReact"`
|
||||||
IsExternalExtensions bool `json:"isExternalExtensions"`
|
IsExternalExtensions bool `json:"isExternalExtensions"`
|
||||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||||
|
Seq uint32 `json:"seq"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModifyMessageReactionExtensionsResp struct {
|
type ModifyMessageReactionExtensionsResp struct {
|
||||||
@@ -78,7 +79,9 @@ type ModifyMessageReactionExtensionsResp struct {
|
|||||||
type OperateMessageListReactionExtensionsReq struct {
|
type OperateMessageListReactionExtensionsReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
SourceID string `json:"sourceID" binding:"required"`
|
SourceID string `json:"sourceID" binding:"required"`
|
||||||
SessionType string `json:"sessionType" binding:"required"`
|
SessionType int32 `json:"sessionType" binding:"required"`
|
||||||
|
IsExternalExtensions bool `json:"isExternalExtensions"`
|
||||||
|
TypeKeyList []string `json:"typeKeyList"`
|
||||||
MessageReactionKeyList []*msg.GetMessageListReactionExtensionsReq_MessageReactionKey `json:"messageReactionKeyList" binding:"required"`
|
MessageReactionKeyList []*msg.GetMessageListReactionExtensionsReq_MessageReactionKey `json:"messageReactionKeyList" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,10 +93,13 @@ type OperateMessageListReactionExtensionsResp struct {
|
|||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetMessageReactionExtensionsCallbackReq ModifyMessageReactionExtensionsReq
|
type SetMessageReactionExtensionsReq ModifyMessageReactionExtensionsReq
|
||||||
|
|
||||||
type SetMessageReactionExtensionsCallbackResp ModifyMessageReactionExtensionsResp
|
type SetMessageReactionExtensionsResp ModifyMessageReactionExtensionsResp
|
||||||
|
|
||||||
|
type AddMessageReactionExtensionsReq ModifyMessageReactionExtensionsReq
|
||||||
|
|
||||||
|
type AddMessageReactionExtensionsResp ModifyMessageReactionExtensionsResp
|
||||||
type GetMessageListReactionExtensionsReq OperateMessageListReactionExtensionsReq
|
type GetMessageListReactionExtensionsReq OperateMessageListReactionExtensionsReq
|
||||||
|
|
||||||
type GetMessageListReactionExtensionsResp struct {
|
type GetMessageListReactionExtensionsResp struct {
|
||||||
@@ -101,10 +107,6 @@ type GetMessageListReactionExtensionsResp struct {
|
|||||||
Data []*msg.SingleMessageExtensionResult `json:"data"`
|
Data []*msg.SingleMessageExtensionResult `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddMessageReactionExtensionsReq ModifyMessageReactionExtensionsReq
|
|
||||||
|
|
||||||
type AddMessageReactionExtensionsResp ModifyMessageReactionExtensionsResp
|
|
||||||
|
|
||||||
type DeleteMessageReactionExtensionsReq struct {
|
type DeleteMessageReactionExtensionsReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
SourceID string `json:"sourceID" binding:"required"`
|
SourceID string `json:"sourceID" binding:"required"`
|
||||||
@@ -121,6 +123,7 @@ type DeleteMessageReactionExtensionsResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ReactionMessageModifierNotification struct {
|
type ReactionMessageModifierNotification struct {
|
||||||
|
Operation int `json:"operation" binding:"required"`
|
||||||
SourceID string `json:"sourceID" binding:"required"`
|
SourceID string `json:"sourceID" binding:"required"`
|
||||||
OpUserID string `json:"opUserID" binding:"required"`
|
OpUserID string `json:"opUserID" binding:"required"`
|
||||||
SessionType int32 `json:"sessionType" binding:"required"`
|
SessionType int32 `json:"sessionType" binding:"required"`
|
||||||
@@ -129,6 +132,7 @@ type ReactionMessageModifierNotification struct {
|
|||||||
IsReact bool `json:"isReact"`
|
IsReact bool `json:"isReact"`
|
||||||
IsExternalExtensions bool `json:"isExternalExtensions"`
|
IsExternalExtensions bool `json:"isExternalExtensions"`
|
||||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||||
|
Seq uint32 `json:"seq"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReactionMessageDeleteNotification struct {
|
type ReactionMessageDeleteNotification struct {
|
||||||
|
|||||||
@@ -41,8 +41,18 @@ type CallbackAfterSendGroupMsgResp struct {
|
|||||||
*CommonCallbackResp
|
*CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CallbackAfterConsumeGroupMsgReq struct {
|
||||||
|
CommonCallbackReq
|
||||||
|
GroupID string `json:"groupID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterConsumeGroupMsgResp struct {
|
||||||
|
*CommonCallbackResp
|
||||||
|
}
|
||||||
type CallbackMsgModifyCommandReq struct {
|
type CallbackMsgModifyCommandReq struct {
|
||||||
CommonCallbackReq
|
CommonCallbackReq
|
||||||
|
RecvID string `json:"recvID,omitempty"`
|
||||||
|
GroupID string `json:"groupID,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackMsgModifyCommandResp struct {
|
type CallbackMsgModifyCommandResp struct {
|
||||||
@@ -99,3 +109,35 @@ type CallbackDeleteMessageReactionExtResp struct {
|
|||||||
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
|
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
|
||||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||||
}
|
}
|
||||||
|
type CallbackGetMessageListReactionExtReq struct {
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
CallbackCommand string `json:"callbackCommand"`
|
||||||
|
SourceID string `json:"sourceID"`
|
||||||
|
OpUserID string `json:"opUserID"`
|
||||||
|
SessionType int32 `json:"sessionType"`
|
||||||
|
TypeKeyList []string `json:"typeKeyList"`
|
||||||
|
MessageKeyList []*msg.GetMessageListReactionExtensionsReq_MessageReactionKey `json:"messageKeyList"`
|
||||||
|
}
|
||||||
|
type CallbackGetMessageListReactionExtResp struct {
|
||||||
|
*CommonCallbackResp
|
||||||
|
MessageResultList []*msg.SingleMessageExtensionResult `json:"messageResultList"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAddMessageReactionExtReq struct {
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
CallbackCommand string `json:"callbackCommand"`
|
||||||
|
SourceID string `json:"sourceID"`
|
||||||
|
OpUserID string `json:"opUserID"`
|
||||||
|
SessionType int32 `json:"sessionType"`
|
||||||
|
ReactionExtensionList map[string]*sdk_ws.KeyValue `json:"reactionExtensionList"`
|
||||||
|
ClientMsgID string `json:"clientMsgID"`
|
||||||
|
IsReact bool `json:"isReact"`
|
||||||
|
IsExternalExtensions bool `json:"isExternalExtensions"`
|
||||||
|
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||||
|
}
|
||||||
|
type CallbackAddMessageReactionExtResp struct {
|
||||||
|
*CommonCallbackResp
|
||||||
|
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
|
||||||
|
IsReact bool `json:"isReact"`
|
||||||
|
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -210,6 +210,17 @@ type config struct {
|
|||||||
MasterSecret string `yaml:"masterSecret"`
|
MasterSecret string `yaml:"masterSecret"`
|
||||||
ChannelID string `yaml:"channelID"`
|
ChannelID string `yaml:"channelID"`
|
||||||
ChannelName string `yaml:"channelName"`
|
ChannelName string `yaml:"channelName"`
|
||||||
|
Channel struct {
|
||||||
|
HW struct {
|
||||||
|
Category string `yaml:"category"`
|
||||||
|
} `yaml:"HW"`
|
||||||
|
XM struct {
|
||||||
|
ChannelID string `yaml:"channelID"`
|
||||||
|
} `yaml:"XM"`
|
||||||
|
OPPO struct {
|
||||||
|
ChannelID string `yaml:"channelID"`
|
||||||
|
} `yaml:"OPPO"`
|
||||||
|
} `yaml:"channel"`
|
||||||
}
|
}
|
||||||
Fcm struct {
|
Fcm struct {
|
||||||
ServiceAccount string `yaml:"serviceAccount"`
|
ServiceAccount string `yaml:"serviceAccount"`
|
||||||
@@ -287,6 +298,7 @@ type config struct {
|
|||||||
CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"`
|
CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"`
|
||||||
CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"`
|
CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"`
|
||||||
CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"`
|
CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"`
|
||||||
|
CallbackAfterConsumeGroupMsg callBackConfig `yaml:"callbackAfterConsumeGroupMsg"`
|
||||||
CallbackMsgModify callBackConfig `yaml:"callbackMsgModify"`
|
CallbackMsgModify callBackConfig `yaml:"callbackMsgModify"`
|
||||||
CallbackUserOnline callBackConfig `yaml:"callbackUserOnline"`
|
CallbackUserOnline callBackConfig `yaml:"callbackUserOnline"`
|
||||||
CallbackUserOffline callBackConfig `yaml:"callbackUserOffline"`
|
CallbackUserOffline callBackConfig `yaml:"callbackUserOffline"`
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ const (
|
|||||||
ExpiredToken = 3
|
ExpiredToken = 3
|
||||||
|
|
||||||
//MultiTerminalLogin
|
//MultiTerminalLogin
|
||||||
|
DefalutNotKick = 0
|
||||||
//Full-end login, but the same end is mutually exclusive
|
//Full-end login, but the same end is mutually exclusive
|
||||||
AllLoginButSameTermKick = 1
|
AllLoginButSameTermKick = 1
|
||||||
//Only one of the endpoints can log in
|
//Only one of the endpoints can log in
|
||||||
@@ -209,6 +210,7 @@ const (
|
|||||||
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
||||||
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
||||||
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
|
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
|
||||||
|
CallbackAfterConsumeGroupMsgCommand = "callbackAfterConsumeGroupMsgCommand"
|
||||||
CallbackMsgModifyCommand = "callbackMsgModifyCommand"
|
CallbackMsgModifyCommand = "callbackMsgModifyCommand"
|
||||||
CallbackUserOnlineCommand = "callbackUserOnlineCommand"
|
CallbackUserOnlineCommand = "callbackUserOnlineCommand"
|
||||||
CallbackUserOfflineCommand = "callbackUserOfflineCommand"
|
CallbackUserOfflineCommand = "callbackUserOfflineCommand"
|
||||||
@@ -222,6 +224,11 @@ const (
|
|||||||
CallbackBeforeSetGroupMemberInfoCommand = "CallbackBeforeSetGroupMemberInfoCommand"
|
CallbackBeforeSetGroupMemberInfoCommand = "CallbackBeforeSetGroupMemberInfoCommand"
|
||||||
CallbackBeforeSetMessageReactionExtensionCommand = "callbackBeforeSetMessageReactionExtensionCommand"
|
CallbackBeforeSetMessageReactionExtensionCommand = "callbackBeforeSetMessageReactionExtensionCommand"
|
||||||
CallbackBeforeDeleteMessageReactionExtensionsCommand = "callbackBeforeDeleteMessageReactionExtensionsCommand"
|
CallbackBeforeDeleteMessageReactionExtensionsCommand = "callbackBeforeDeleteMessageReactionExtensionsCommand"
|
||||||
|
CallbackGetMessageListReactionExtensionsCommand = "callbackGetMessageListReactionExtensionsCommand"
|
||||||
|
CallbackAddMessageListReactionExtensionsCommand = "callbackAddMessageListReactionExtensionsCommand"
|
||||||
|
|
||||||
|
SetMessageExtensions = 1
|
||||||
|
AddMessageExtensions = 2
|
||||||
|
|
||||||
//callback actionCode
|
//callback actionCode
|
||||||
ActionAllow = 0
|
ActionAllow = 0
|
||||||
@@ -354,4 +361,4 @@ const StatisticsTimeInterval = 60
|
|||||||
|
|
||||||
const MaxNotificationNum = 500
|
const MaxNotificationNum = 500
|
||||||
|
|
||||||
const CurrentVersion = "v2.3.4-rc0"
|
const CurrentVersion = "v2.3.8-rc0"
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ var PlatformName2ID = map[string]int{
|
|||||||
IPadPlatformStr: IPadPlatformID,
|
IPadPlatformStr: IPadPlatformID,
|
||||||
AdminPlatformStr: AdminPlatformID,
|
AdminPlatformStr: AdminPlatformID,
|
||||||
}
|
}
|
||||||
var Platform2class = map[string]string{
|
var PlatformName2class = map[string]string{
|
||||||
IOSPlatformStr: TerminalMobile,
|
IOSPlatformStr: TerminalMobile,
|
||||||
AndroidPlatformStr: TerminalMobile,
|
AndroidPlatformStr: TerminalMobile,
|
||||||
MiniWebPlatformStr: WebPlatformStr,
|
MiniWebPlatformStr: WebPlatformStr,
|
||||||
@@ -66,6 +66,15 @@ var Platform2class = map[string]string{
|
|||||||
OSXPlatformStr: TerminalPC,
|
OSXPlatformStr: TerminalPC,
|
||||||
LinuxPlatformStr: TerminalPC,
|
LinuxPlatformStr: TerminalPC,
|
||||||
}
|
}
|
||||||
|
var PlatformID2class = map[int]string{
|
||||||
|
IOSPlatformID: TerminalMobile,
|
||||||
|
AndroidPlatformID: TerminalMobile,
|
||||||
|
MiniWebPlatformID: WebPlatformStr,
|
||||||
|
WebPlatformID: WebPlatformStr,
|
||||||
|
WindowsPlatformID: TerminalPC,
|
||||||
|
OSXPlatformID: TerminalPC,
|
||||||
|
LinuxPlatformID: TerminalPC,
|
||||||
|
}
|
||||||
|
|
||||||
func PlatformIDToName(num int) string {
|
func PlatformIDToName(num int) string {
|
||||||
return PlatformID2Name[num]
|
return PlatformID2Name[num]
|
||||||
@@ -74,5 +83,8 @@ func PlatformNameToID(name string) int {
|
|||||||
return PlatformName2ID[name]
|
return PlatformName2ID[name]
|
||||||
}
|
}
|
||||||
func PlatformNameToClass(name string) string {
|
func PlatformNameToClass(name string) string {
|
||||||
return Platform2class[name]
|
return PlatformName2class[name]
|
||||||
|
}
|
||||||
|
func PlatformIDToClass(num int) string {
|
||||||
|
return PlatformID2class[num]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ const (
|
|||||||
sendMsgFailedFlag = "SEND_MSG_FAILED_FLAG:"
|
sendMsgFailedFlag = "SEND_MSG_FAILED_FLAG:"
|
||||||
userBadgeUnreadCountSum = "USER_BADGE_UNREAD_COUNT_SUM:"
|
userBadgeUnreadCountSum = "USER_BADGE_UNREAD_COUNT_SUM:"
|
||||||
exTypeKeyLocker = "EX_LOCK:"
|
exTypeKeyLocker = "EX_LOCK:"
|
||||||
|
|
||||||
|
//temp
|
||||||
|
superGroupUserNotRecvOfflineMsgOptTemp = "SG_RECV_MSG_OPT_TEMP:"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *DataBases) JudgeAccountEXISTS(account string) (bool, error) {
|
func (d *DataBases) JudgeAccountEXISTS(account string) (bool, error) {
|
||||||
@@ -164,6 +167,23 @@ func (d *DataBases) GetSingleConversationRecvMsgOpt(userID, conversationID strin
|
|||||||
result, err := d.RDB.HGet(context.Background(), key, conversationID).Result()
|
result, err := d.RDB.HGet(context.Background(), key, conversationID).Result()
|
||||||
return utils.StringToInt(result), err
|
return utils.StringToInt(result), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) SetSuperGroupUserReceiveNotNotifyMessage(groupID, userID string) error {
|
||||||
|
key := superGroupUserNotRecvOfflineMsgOptTemp + groupID
|
||||||
|
return d.RDB.SAdd(context.Background(), key, userID).Err()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) SetSuperGroupUserReceiveNotifyMessage(groupID, userID string) error {
|
||||||
|
key := superGroupUserNotRecvOfflineMsgOptTemp + groupID
|
||||||
|
return d.RDB.SRem(context.Background(), key, userID).Err()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) GetSuperGroupUserReceiveNotNotifyMessageIDList(groupID string) ([]string, error) {
|
||||||
|
key := superGroupUserNotRecvOfflineMsgOptTemp + groupID
|
||||||
|
userIDs, _ := d.RDB.SMembers(context.Background(), key).Result()
|
||||||
|
return userIDs, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DataBases) SetUserGlobalMsgRecvOpt(userID string, opt int32) error {
|
func (d *DataBases) SetUserGlobalMsgRecvOpt(userID string, opt int32) error {
|
||||||
key := conversationReceiveMessageOpt + userID
|
key := conversationReceiveMessageOpt + userID
|
||||||
return d.RDB.HSet(context.Background(), key, GlobalMsgRecvOpt, opt).Err()
|
return d.RDB.HSet(context.Background(), key, GlobalMsgRecvOpt, opt).Err()
|
||||||
@@ -374,7 +394,7 @@ func (d *DataBases) DelMsgFromCache(uid string, seqList []uint32, operationID st
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var msg pbCommon.MsgData
|
var msg pbCommon.MsgData
|
||||||
if err := utils.String2Pb(result, &msg); err != nil {
|
if err := jsonpb.UnmarshalString(result, &msg); err != nil {
|
||||||
log2.Error(operationID, utils.GetSelfFuncName(), "String2Pb failed", msg, result, key, err.Error())
|
log2.Error(operationID, utils.GetSelfFuncName(), "String2Pb failed", msg, result, key, err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,10 @@ func init() {
|
|||||||
if err := createMongoIndex(mongoClient, cTag, true, "tag_id"); err != nil {
|
if err := createMongoIndex(mongoClient, cTag, true, "tag_id"); err != nil {
|
||||||
panic(err.Error() + "index create failed " + cTag + " tag_id")
|
panic(err.Error() + "index create failed " + cTag + " tag_id")
|
||||||
}
|
}
|
||||||
|
if err := createMongoIndex(mongoClient, cUserToSuperGroup, true, "user_id"); err != nil {
|
||||||
|
panic(err.Error() + "index create failed " + cUserToSuperGroup + " user_id")
|
||||||
|
}
|
||||||
|
|
||||||
DB.mongoClient = mongoClient
|
DB.mongoClient = mongoClient
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
|||||||
@@ -20,17 +20,16 @@ type Invitation struct {
|
|||||||
Status int32 `gorm:"column:status"`
|
Status int32 `gorm:"column:status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// message FriendInfo{
|
||||||
//message FriendInfo{
|
// string OwnerUserID = 1;
|
||||||
//string OwnerUserID = 1;
|
// string Remark = 2;
|
||||||
//string Remark = 2;
|
// int64 CreateTime = 3;
|
||||||
//int64 CreateTime = 3;
|
// UserInfo FriendUser = 4;
|
||||||
//UserInfo FriendUser = 4;
|
// int32 AddSource = 5;
|
||||||
//int32 AddSource = 5;
|
// string OperatorUserID = 6;
|
||||||
//string OperatorUserID = 6;
|
// string Ex = 7;
|
||||||
//string Ex = 7;
|
// }
|
||||||
//}
|
// open_im_sdk.FriendInfo(FriendUser) != imdb.Friend(FriendUserID)
|
||||||
//open_im_sdk.FriendInfo(FriendUser) != imdb.Friend(FriendUserID)
|
|
||||||
type Friend struct {
|
type Friend struct {
|
||||||
OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"`
|
OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"`
|
||||||
FriendUserID string `gorm:"column:friend_user_id;primary_key;size:64"`
|
FriendUserID string `gorm:"column:friend_user_id;primary_key;size:64"`
|
||||||
@@ -41,18 +40,18 @@ type Friend struct {
|
|||||||
Ex string `gorm:"column:ex;size:1024"`
|
Ex string `gorm:"column:ex;size:1024"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//message FriendRequest{
|
// message FriendRequest{
|
||||||
//string FromUserID = 1;
|
// string FromUserID = 1;
|
||||||
//string ToUserID = 2;
|
// string ToUserID = 2;
|
||||||
//int32 HandleResult = 3;
|
// int32 HandleResult = 3;
|
||||||
//string ReqMsg = 4;
|
// string ReqMsg = 4;
|
||||||
//int64 CreateTime = 5;
|
// int64 CreateTime = 5;
|
||||||
//string HandlerUserID = 6;
|
// string HandlerUserID = 6;
|
||||||
//string HandleMsg = 7;
|
// string HandleMsg = 7;
|
||||||
//int64 HandleTime = 8;
|
// int64 HandleTime = 8;
|
||||||
//string Ex = 9;
|
// string Ex = 9;
|
||||||
//}
|
// }
|
||||||
//open_im_sdk.FriendRequest(nickname, farce url ...) != imdb.FriendRequest
|
// open_im_sdk.FriendRequest(nickname, farce url ...) != imdb.FriendRequest
|
||||||
type FriendRequest struct {
|
type FriendRequest struct {
|
||||||
FromUserID string `gorm:"column:from_user_id;primary_key;size:64"`
|
FromUserID string `gorm:"column:from_user_id;primary_key;size:64"`
|
||||||
ToUserID string `gorm:"column:to_user_id;primary_key;size:64"`
|
ToUserID string `gorm:"column:to_user_id;primary_key;size:64"`
|
||||||
@@ -69,7 +68,7 @@ func (FriendRequest) TableName() string {
|
|||||||
return "friend_requests"
|
return "friend_requests"
|
||||||
}
|
}
|
||||||
|
|
||||||
//message GroupInfo{
|
// message GroupInfo{
|
||||||
// string GroupID = 1;
|
// string GroupID = 1;
|
||||||
// string GroupName = 2;
|
// string GroupName = 2;
|
||||||
// string Notification = 3;
|
// string Notification = 3;
|
||||||
@@ -82,7 +81,8 @@ func (FriendRequest) TableName() string {
|
|||||||
// int32 Status = 10;
|
// int32 Status = 10;
|
||||||
// string CreatorUserID = 11;
|
// string CreatorUserID = 11;
|
||||||
// int32 GroupType = 12;
|
// int32 GroupType = 12;
|
||||||
//}
|
// }
|
||||||
|
//
|
||||||
// open_im_sdk.GroupInfo (OwnerUserID , MemberCount )> imdb.Group
|
// open_im_sdk.GroupInfo (OwnerUserID , MemberCount )> imdb.Group
|
||||||
type Group struct {
|
type Group struct {
|
||||||
//`json:"operationID" binding:"required"`
|
//`json:"operationID" binding:"required"`
|
||||||
@@ -104,18 +104,18 @@ type Group struct {
|
|||||||
NotificationUserID string `gorm:"column:notification_user_id;size:64"`
|
NotificationUserID string `gorm:"column:notification_user_id;size:64"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//message GroupMemberFullInfo {
|
// message GroupMemberFullInfo {
|
||||||
//string GroupID = 1 ;
|
// string GroupID = 1 ;
|
||||||
//string UserID = 2 ;
|
// string UserID = 2 ;
|
||||||
//int32 roleLevel = 3;
|
// int32 roleLevel = 3;
|
||||||
//int64 JoinTime = 4;
|
// int64 JoinTime = 4;
|
||||||
//string NickName = 5;
|
// string NickName = 5;
|
||||||
//string FaceUrl = 6;
|
// string FaceUrl = 6;
|
||||||
//int32 JoinSource = 8;
|
// int32 JoinSource = 8;
|
||||||
//string OperatorUserID = 9;
|
// string OperatorUserID = 9;
|
||||||
//string Ex = 10;
|
// string Ex = 10;
|
||||||
//int32 AppMangerLevel = 7; //if >0
|
// int32 AppMangerLevel = 7; //if >0
|
||||||
//} open_im_sdk.GroupMemberFullInfo(AppMangerLevel) > imdb.GroupMember
|
// } open_im_sdk.GroupMemberFullInfo(AppMangerLevel) > imdb.GroupMember
|
||||||
type GroupMember struct {
|
type GroupMember struct {
|
||||||
GroupID string `gorm:"column:group_id;primary_key;size:64"`
|
GroupID string `gorm:"column:group_id;primary_key;size:64"`
|
||||||
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
||||||
@@ -130,17 +130,17 @@ type GroupMember struct {
|
|||||||
Ex string `gorm:"column:ex;size:1024"`
|
Ex string `gorm:"column:ex;size:1024"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//message GroupRequest{
|
// message GroupRequest{
|
||||||
//string UserID = 1;
|
// string UserID = 1;
|
||||||
//string GroupID = 2;
|
// string GroupID = 2;
|
||||||
//string HandleResult = 3;
|
// string HandleResult = 3;
|
||||||
//string ReqMsg = 4;
|
// string ReqMsg = 4;
|
||||||
//string HandleMsg = 5;
|
// string HandleMsg = 5;
|
||||||
//int64 ReqTime = 6;
|
// int64 ReqTime = 6;
|
||||||
//string HandleUserID = 7;
|
// string HandleUserID = 7;
|
||||||
//int64 HandleTime = 8;
|
// int64 HandleTime = 8;
|
||||||
//string Ex = 9;
|
// string Ex = 9;
|
||||||
//}open_im_sdk.GroupRequest == imdb.GroupRequest
|
// }open_im_sdk.GroupRequest == imdb.GroupRequest
|
||||||
type GroupRequest struct {
|
type GroupRequest struct {
|
||||||
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
||||||
GroupID string `gorm:"column:group_id;primary_key;size:64"`
|
GroupID string `gorm:"column:group_id;primary_key;size:64"`
|
||||||
@@ -155,18 +155,18 @@ type GroupRequest struct {
|
|||||||
Ex string `gorm:"column:ex;size:1024"`
|
Ex string `gorm:"column:ex;size:1024"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//string UserID = 1;
|
// string UserID = 1;
|
||||||
//string Nickname = 2;
|
// string Nickname = 2;
|
||||||
//string FaceUrl = 3;
|
// string FaceUrl = 3;
|
||||||
//int32 Gender = 4;
|
// int32 Gender = 4;
|
||||||
//string PhoneNumber = 5;
|
// string PhoneNumber = 5;
|
||||||
//string Birth = 6;
|
// string Birth = 6;
|
||||||
//string Email = 7;
|
// string Email = 7;
|
||||||
//string Ex = 8;
|
// string Ex = 8;
|
||||||
//string CreateIp = 9;
|
// string CreateIp = 9;
|
||||||
//int64 CreateTime = 10;
|
// int64 CreateTime = 10;
|
||||||
//int32 AppMangerLevel = 11;
|
// int32 AppMangerLevel = 11;
|
||||||
//open_im_sdk.User == imdb.User
|
// open_im_sdk.User == imdb.User
|
||||||
type User struct {
|
type User struct {
|
||||||
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
||||||
Nickname string `gorm:"column:name;size:255"`
|
Nickname string `gorm:"column:name;size:255"`
|
||||||
@@ -207,14 +207,14 @@ type UserIpLimit struct {
|
|||||||
CreateTime time.Time `gorm:"column:create_time"`
|
CreateTime time.Time `gorm:"column:create_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//message BlackInfo{
|
// message BlackInfo{
|
||||||
//string OwnerUserID = 1;
|
// string OwnerUserID = 1;
|
||||||
//int64 CreateTime = 2;
|
// int64 CreateTime = 2;
|
||||||
//PublicUserInfo BlackUserInfo = 4;
|
// PublicUserInfo BlackUserInfo = 4;
|
||||||
//int32 AddSource = 5;
|
// int32 AddSource = 5;
|
||||||
//string OperatorUserID = 6;
|
// string OperatorUserID = 6;
|
||||||
//string Ex = 7;
|
// string Ex = 7;
|
||||||
//}
|
// }
|
||||||
// open_im_sdk.BlackInfo(BlackUserInfo) != imdb.Black (BlockUserID)
|
// open_im_sdk.BlackInfo(BlackUserInfo) != imdb.Black (BlockUserID)
|
||||||
type Black struct {
|
type Black struct {
|
||||||
OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"`
|
OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"`
|
||||||
|
|||||||
+85
-13
@@ -94,7 +94,7 @@ func (d *DataBases) GetMinSeqFromMongo2(uid string) (MinSeq uint32, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// deleteMsgByLogic
|
// deleteMsgByLogic
|
||||||
func (d *DataBases) DelMsgBySeqList(userID string, seqList []uint32, operationID string) (totalUnexistSeqList []uint32, err error) {
|
func (d *DataBases) DelMsgBySeqList(userID string, seqList []uint32, operationID string) (totalUnExistSeqList []uint32, err error) {
|
||||||
log.Debug(operationID, utils.GetSelfFuncName(), "args ", userID, seqList)
|
log.Debug(operationID, utils.GetSelfFuncName(), "args ", userID, seqList)
|
||||||
sortkeys.Uint32s(seqList)
|
sortkeys.Uint32s(seqList)
|
||||||
suffixUserID2SubSeqList := func(uid string, seqList []uint32) map[string][]uint32 {
|
suffixUserID2SubSeqList := func(uid string, seqList []uint32) map[string][]uint32 {
|
||||||
@@ -123,11 +123,11 @@ func (d *DataBases) DelMsgBySeqList(userID string, seqList []uint32, operationID
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
totalUnexistSeqList = append(totalUnexistSeqList, unexistSeqList...)
|
totalUnExistSeqList = append(totalUnExistSeqList, unexistSeqList...)
|
||||||
lock.Unlock()
|
lock.Unlock()
|
||||||
}(k, v, operationID)
|
}(k, v, operationID)
|
||||||
}
|
}
|
||||||
return totalUnexistSeqList, err
|
return totalUnExistSeqList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) DelMsgBySeqListInOneDoc(suffixUserID string, seqList []uint32, operationID string) ([]uint32, error) {
|
func (d *DataBases) DelMsgBySeqListInOneDoc(suffixUserID string, seqList []uint32, operationID string) ([]uint32, error) {
|
||||||
@@ -137,7 +137,7 @@ func (d *DataBases) DelMsgBySeqListInOneDoc(suffixUserID string, seqList []uint3
|
|||||||
return nil, utils.Wrap(err, "")
|
return nil, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
for i, v := range seqMsgList {
|
for i, v := range seqMsgList {
|
||||||
if err := d.ReplaceMsgByIndex(suffixUserID, v, operationID, indexList[i]); err != nil {
|
if err := d.DelMsgByIndex(suffixUserID, v, operationID, indexList[i]); err != nil {
|
||||||
return nil, utils.Wrap(err, "")
|
return nil, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ func (d *DataBases) DelMsgLogic(uid string, seqList []uint32, operationID string
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) ReplaceMsgByIndex(suffixUserID string, msg *open_im_sdk.MsgData, operationID string, seqIndex int) error {
|
func (d *DataBases) DelMsgByIndex(suffixUserID string, msg *open_im_sdk.MsgData, operationID string, seqIndex int) error {
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), suffixUserID, *msg)
|
log.NewInfo(operationID, utils.GetSelfFuncName(), suffixUserID, *msg)
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||||
@@ -195,7 +195,6 @@ func (d *DataBases) ReplaceMsgBySeq(uid string, msg *open_im_sdk.MsgData, operat
|
|||||||
log.NewError(operationID, utils.GetSelfFuncName(), "proto marshal", err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), "proto marshal", err.Error())
|
||||||
return utils.Wrap(err, "")
|
return utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
updateResult, err := c.UpdateOne(
|
updateResult, err := c.UpdateOne(
|
||||||
ctx, bson.M{"uid": uid},
|
ctx, bson.M{"uid": uid},
|
||||||
bson.M{"$set": bson.M{s: bytes}})
|
bson.M{"$set": bson.M{s: bytes}})
|
||||||
@@ -207,6 +206,48 @@ func (d *DataBases) ReplaceMsgBySeq(uid string, msg *open_im_sdk.MsgData, operat
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) GetMsgBySeqIndex(uid string, seq uint32, operationID string) (*open_im_sdk.MsgData, error) {
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||||
|
uid = getSeqUid(uid, seq)
|
||||||
|
seqIndex := getMsgIndex(seq)
|
||||||
|
result, err := c.Find(ctx, bson.M{"msg": bson.M{"$slice": []int{seqIndex, 1}}})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var msgInfos []MsgInfo
|
||||||
|
if err := result.Decode(&msgInfos); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(msgInfos) < 1 {
|
||||||
|
return nil, ErrMsgListNotExist
|
||||||
|
}
|
||||||
|
var msg open_im_sdk.MsgData
|
||||||
|
if err := proto.Unmarshal(msgInfos[0].Msg, &msg); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &msg, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) ReplaceMsgByIndex(uid string, msg *open_im_sdk.MsgData, index int) error {
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||||
|
uid = getSeqUid(uid, msg.Seq)
|
||||||
|
seqIndex := getMsgIndex(msg.Seq)
|
||||||
|
s := fmt.Sprintf("msg.%d.msg", seqIndex)
|
||||||
|
bytes, err := proto.Marshal(msg)
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
_, err = c.UpdateOne(
|
||||||
|
ctx, bson.M{"uid": uid},
|
||||||
|
bson.M{"$set": bson.M{s: bytes}})
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DataBases) UpdateOneMsgList(msg *UserChat) error {
|
func (d *DataBases) UpdateOneMsgList(msg *UserChat) error {
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||||
@@ -273,7 +314,7 @@ func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32, operationID st
|
|||||||
func (d *DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, error) {
|
func (d *DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, error) {
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||||
regex := fmt.Sprintf("^%s", ID)
|
regex := fmt.Sprintf("^%s:", ID)
|
||||||
findOpts := options.Find().SetLimit(1).SetSkip(index).SetSort(bson.M{"uid": 1})
|
findOpts := options.Find().SetLimit(1).SetSkip(index).SetSort(bson.M{"uid": 1})
|
||||||
var msgs []UserChat
|
var msgs []UserChat
|
||||||
//primitive.Regex{Pattern: regex}
|
//primitive.Regex{Pattern: regex}
|
||||||
@@ -330,7 +371,7 @@ func (d *DataBases) ReplaceMsgToBlankByIndex(suffixID string, index int) (replac
|
|||||||
func (d *DataBases) GetNewestMsg(ID string) (msg *open_im_sdk.MsgData, err error) {
|
func (d *DataBases) GetNewestMsg(ID string) (msg *open_im_sdk.MsgData, err error) {
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||||
regex := fmt.Sprintf("^%s", ID)
|
regex := fmt.Sprintf("^%s:", ID)
|
||||||
findOpts := options.Find().SetLimit(1).SetSort(bson.M{"uid": -1})
|
findOpts := options.Find().SetLimit(1).SetSort(bson.M{"uid": -1})
|
||||||
var userChats []UserChat
|
var userChats []UserChat
|
||||||
cursor, err := c.Find(ctx, bson.M{"uid": bson.M{"$regex": regex}}, findOpts)
|
cursor, err := c.Find(ctx, bson.M{"uid": bson.M{"$regex": regex}}, findOpts)
|
||||||
@@ -358,7 +399,7 @@ func (d *DataBases) GetNewestMsg(ID string) (msg *open_im_sdk.MsgData, err error
|
|||||||
func (d *DataBases) GetOldestMsg(ID string) (msg *open_im_sdk.MsgData, err error) {
|
func (d *DataBases) GetOldestMsg(ID string) (msg *open_im_sdk.MsgData, err error) {
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||||
regex := fmt.Sprintf("^%s", ID)
|
regex := fmt.Sprintf("^%s:", ID)
|
||||||
findOpts := options.Find().SetLimit(1).SetSort(bson.M{"uid": 1})
|
findOpts := options.Find().SetLimit(1).SetSort(bson.M{"uid": 1})
|
||||||
var userChats []UserChat
|
var userChats []UserChat
|
||||||
cursor, err := c.Find(ctx, bson.M{"uid": bson.M{"$regex": regex}}, findOpts)
|
cursor, err := c.Find(ctx, bson.M{"uid": bson.M{"$regex": regex}}, findOpts)
|
||||||
@@ -441,8 +482,9 @@ func (d *DataBases) GetMsgBySeqListMongo2(uid string, seqList []uint32, operatio
|
|||||||
}
|
}
|
||||||
return seqMsg, nil
|
return seqMsg, nil
|
||||||
}
|
}
|
||||||
func (d *DataBases) GetSuperGroupMsgBySeqListMongo(groupID string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
func (d *DataBases) GetSuperGroupMsgBySeqListMongo(groupID string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, indexes map[uint32]int, err error) {
|
||||||
var hasSeqList []uint32
|
var hasSeqList []uint32
|
||||||
|
indexes = make(map[uint32]int)
|
||||||
singleCount := 0
|
singleCount := 0
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||||
@@ -471,10 +513,11 @@ func (d *DataBases) GetSuperGroupMsgBySeqListMongo(groupID string, seqList []uin
|
|||||||
msg := new(open_im_sdk.MsgData)
|
msg := new(open_im_sdk.MsgData)
|
||||||
if err = proto.Unmarshal(sChat.Msg[i].Msg, msg); err != nil {
|
if err = proto.Unmarshal(sChat.Msg[i].Msg, msg); err != nil {
|
||||||
log.NewError(operationID, "Unmarshal err", seqUid, value, groupID, seqList, err.Error())
|
log.NewError(operationID, "Unmarshal err", seqUid, value, groupID, seqList, err.Error())
|
||||||
return nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if isContainInt32(msg.Seq, value) {
|
if isContainInt32(msg.Seq, value) {
|
||||||
seqMsg = append(seqMsg, msg)
|
seqMsg = append(seqMsg, msg)
|
||||||
|
indexes[msg.Seq] = i
|
||||||
hasSeqList = append(hasSeqList, msg.Seq)
|
hasSeqList = append(hasSeqList, msg.Seq)
|
||||||
singleCount++
|
singleCount++
|
||||||
if singleCount == len(value) {
|
if singleCount == len(value) {
|
||||||
@@ -488,9 +531,8 @@ func (d *DataBases) GetSuperGroupMsgBySeqListMongo(groupID string, seqList []uin
|
|||||||
diff = utils.Difference(hasSeqList, seqList)
|
diff = utils.Difference(hasSeqList, seqList)
|
||||||
exceptionMSg := genExceptionSuperGroupMessageBySeqList(diff, groupID)
|
exceptionMSg := genExceptionSuperGroupMessageBySeqList(diff, groupID)
|
||||||
seqMsg = append(seqMsg, exceptionMSg...)
|
seqMsg = append(seqMsg, exceptionMSg...)
|
||||||
|
|
||||||
}
|
}
|
||||||
return seqMsg, nil
|
return seqMsg, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetMsgAndIndexBySeqListInOneMongo2(suffixUserID string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, indexList []int, unexistSeqList []uint32, err error) {
|
func (d *DataBases) GetMsgAndIndexBySeqListInOneMongo2(suffixUserID string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, indexList []int, unexistSeqList []uint32, err error) {
|
||||||
@@ -1191,6 +1233,36 @@ func (d *DataBases) AddUserToSuperGroup(groupID string, userIDList []string) err
|
|||||||
_ = session.CommitTransaction(ctx)
|
_ = session.CommitTransaction(ctx)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
func (d *DataBases) AddUserToSuperGroups(groupIDList []string, userID string) error {
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup)
|
||||||
|
session, err := d.mongoClient.StartSession()
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, "start session failed")
|
||||||
|
}
|
||||||
|
defer session.EndSession(ctx)
|
||||||
|
sCtx := mongo.NewSessionContext(ctx, session)
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, "start transaction failed")
|
||||||
|
}
|
||||||
|
_, err = c.UpdateMany(sCtx, bson.M{"group_id": bson.M{"$in": groupIDList}}, bson.M{"$addToSet": bson.M{"member_id_list": userID}})
|
||||||
|
if err != nil {
|
||||||
|
_ = session.AbortTransaction(ctx)
|
||||||
|
return utils.Wrap(err, "transaction failed")
|
||||||
|
}
|
||||||
|
c = d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cUserToSuperGroup)
|
||||||
|
upsert := true
|
||||||
|
opts := &options.UpdateOptions{
|
||||||
|
Upsert: &upsert,
|
||||||
|
}
|
||||||
|
_, err = c.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": bson.M{"$each": groupIDList}}}, opts)
|
||||||
|
if err != nil {
|
||||||
|
_ = session.AbortTransaction(ctx)
|
||||||
|
return utils.Wrap(err, "transaction failed")
|
||||||
|
}
|
||||||
|
_ = session.CommitTransaction(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DataBases) RemoverUserFromSuperGroup(groupID string, userIDList []string) error {
|
func (d *DataBases) RemoverUserFromSuperGroup(groupID string, userIDList []string) error {
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user