Compare commits

...

156 Commits

Author SHA1 Message Date
Xinwei Xiong(cubxxw-openim) db081e6a4c feat: add more deployment docs
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-09-06 11:34:46 +08:00
wangchuxiao 6b0a2c9464 update 2023-05-25 16:29:22 +08:00
wangchuxiao 775aba52bd dockerfile add ca 2023-05-17 19:03:27 +08:00
wangchuxiao e1770173ef getui 2023-04-12 15:46:29 +08:00
wangchuxiao c73ce45e9e fix getui req 2023-04-12 15:34:15 +08:00
Gordon 7aefb7fa2b message add ex field to return 2023-04-04 15:55:57 +08:00
wangchuxiao baece7eb3a getui update 2023-03-27 17:56:08 +08:00
soasurs 1b31a07b40 feat: allow modify msg for any content type by callback (#352)
* feat: add recvID/groupID for msg modification callback

Signed-off-by: soasurs <soasurs@gmail.com>

* feat: allow modify msg for any content type by callback

Signed-off-by: soasurs <soasurs@gmail.com>

---------

Signed-off-by: soasurs <soasurs@gmail.com>
2023-03-23 12:53:22 +08:00
wangchuxiao 83ba487c61 add log for bk 2023-03-23 12:23:48 +08:00
wangchuxiao 8dc0b639a2 signal both push 2023-03-22 18:42:42 +08:00
wangchuxiao 9a636a15de redis 2023-03-21 20:18:39 +08:00
wangchuxiao 7b12a8755a fix sync conversation bug 2023-03-21 17:31:30 +08:00
soasurs b67c244bbd feat: add recvID/groupID for msg modification callback (#351)
Signed-off-by: soasurs <soasurs@gmail.com>
2023-03-20 15:27:43 +08:00
Gordon 0bd2c00088 push message update 2023-03-15 18:36:44 +08:00
wangchuxiao cb1487109a Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release 2023-03-13 16:19:08 +08:00
wangchuxiao c9d8625274 connID to md5 2023-03-13 16:18:18 +08:00
Gordon d0b659ccea super group notification 2023-03-07 11:09:17 +08:00
Gordon c182001fcf ws support same terminal login 2023-03-02 19:36:48 +08:00
Gordon c8038213c7 ws support same terminal login 2023-03-02 19:24:24 +08:00
Gordon 40a7bb9d48 test log 2023-03-02 19:08:35 +08:00
Gordon 7e48d1a00f ws support same terminal login 2023-03-02 18:47:11 +08:00
Gordon a64e5a776a Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2023-03-01 14:54:48 +08:00
Gordon 9dc798bc53 ws recycle conn bug fix 2023-03-01 14:54:22 +08:00
wangchuxiao c6ea841064 k8s 2023-03-01 00:38:36 +08:00
Gordon 0e03c5f89e Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2023-02-28 16:36:21 +08:00
Gordon 70502685ce invite user to groups api add 2023-02-28 16:35:53 +08:00
wangchuxiao a2fe6ffc7a Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release 2023-02-28 16:32:15 +08:00
wangchuxiao 1c724aa89b deploy 2023-02-28 16:32:02 +08:00
Gordon 5d307c16b4 Makefile update 2023-02-28 10:21:59 +08:00
Gordon 96c264981e Makefile update 2023-02-27 20:22:28 +08:00
Gordon 60c507ff10 Makefile update 2023-02-27 20:03:06 +08:00
Gordon 33ee58904b callback add 2023-02-27 17:08:34 +08:00
Gordon 0938b11f83 Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2023-02-27 15:42:22 +08:00
Gordon c0d633bc34 message reaction bug fix 2023-02-27 15:41:22 +08:00
wangchuxiao 7a9506f616 modify msg 2023-02-27 12:47:18 +08:00
wangchuxiao 36afd67a2c modify msg 2023-02-27 12:41:29 +08:00
wangchuxiao 59d1090a6d modify msg 2023-02-27 12:29:40 +08:00
wangchuxiao f384bb2aff fix bug 2023-02-24 18:52:58 +08:00
wangchuxiao 4411ba3482 Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release 2023-02-24 18:40:16 +08:00
wangchuxiao 379118e481 fix bug 2023-02-24 18:39:31 +08:00
Gordon 661b1a5e6a not kick user 2023-02-23 14:21:39 +08:00
Gordon fd2d5252c5 Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2023-02-23 12:18:27 +08:00
Gordon 284e89d410 websocket update 2023-02-23 12:14:58 +08:00
wangchuxiao d7a649f699 fix mongoDB bug 2023-02-20 18:58:55 +08:00
wangchuxiao c758628701 fix mongoDB bug 2023-02-20 18:36:30 +08:00
wangchuxiao 28614e4c13 fix mongoDB bug 2023-02-20 16:14:40 +08:00
wangchuxiao beb9a37649 Merge branch 'v2.3.0release' 2023-02-20 16:14:11 +08:00
wangchuxiao 0e9810e9ff fix mongoDB bug 2023-02-20 15:13:03 +08:00
wangchuxiao 0c5cec8413 Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release 2023-02-20 10:25:06 +08:00
wangchuxiao 6135ce0919 fix mongoDB bug 2023-02-20 10:24:51 +08:00
Gordon fdd765f982 extend msg update 2023-02-15 10:45:12 +08:00
Gordon 529821475e ws pb update 2023-02-10 12:37:51 +08:00
Gordon f2b21cbce6 Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2023-02-10 12:31:59 +08:00
Gordon 061ee3abd2 ws pb update 2023-02-10 12:31:35 +08:00
wangchuxiao e2c53754b5 Merge remote-tracking branch 'origin/main' 2023-02-10 11:33:45 +08:00
wangchuxiao f328ebc300 Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release 2023-02-10 11:32:25 +08:00
wangchuxiao 135c2c36aa errcode 2023-02-10 11:32:02 +08:00
Gordon 16cf98213c extend msg update 2023-02-09 15:54:59 +08:00
Gordon 094911bab2 Merge branch 'v2.3.0release'
# Conflicts:
#	README.md
#	config/config.yaml
2023-02-08 11:53:54 +08:00
Gordon 6ee90b60c3 remove super group add kicked user notification 2023-02-08 10:21:59 +08:00
skiffer-git c80b625977 Update config.example.yaml 2023-02-03 13:52:39 +08:00
skiffer-git cc4ae8648e Update README.md 2023-02-03 09:55:38 +08:00
skiffer-git 4f7eead38c Update config.yaml 2023-02-02 18:04:08 +08:00
skiffer-git 386a99edbd Update config.yaml 2023-02-02 17:47:38 +08:00
skiffer-git 982506c2fb Update config.yaml 2023-02-02 17:38:47 +08:00
skiffer-git 5767a0fadc Update config.yaml 2023-02-02 17:33:09 +08:00
skiffer-git a01fec538e Update config.yaml 2023-02-02 17:30:27 +08:00
skiffer-git d451c36b2d Update config.yaml 2023-02-02 17:24:15 +08:00
skiffer-git 0ae8433436 Update README.md 2023-02-02 14:57:57 +08:00
Gordon 863c90e8bd del msg bug fix 2023-02-01 17:44:34 +08:00
Gordon 396a87ab71 Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2023-02-01 17:37:47 +08:00
Gordon a60b584dca kick group member add kicked notification 2023-02-01 17:33:56 +08:00
Gordon 3cb3b6ba2d group update 2023-01-31 10:07:48 +08:00
Gordon 16fbf7c63e set revoke message not to count 2023-01-28 22:29:52 +08:00
Gordon b980c9e751 db update 2023-01-18 11:54:46 +08:00
Gordon 127d45abc9 db update 2023-01-18 11:53:36 +08:00
Gordon e99f441e50 db update 2023-01-18 11:37:10 +08:00
Gordon 186cfa7226 remove notification limit 2023-01-17 15:53:49 +08:00
skiffer-git 7627ebed5c Update README.md 2023-01-16 20:50:42 +08:00
Gordon 1be159b47c resp return update 2023-01-16 17:19:44 +08:00
Gordon 4e3ab62f6c log 2023-01-16 16:24:41 +08:00
Gordon 85cb95602d Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2023-01-16 16:00:49 +08:00
Gordon ff917466eb log 2023-01-16 16:00:11 +08:00
wangchuxiao 1235715c22 push 2023-01-16 15:49:10 +08:00
wangchuxiao 1393e40eb9 Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release
# Conflicts:
#	internal/rpc/user/user.go
2023-01-16 15:17:42 +08:00
wangchuxiao 442c838bda Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release
# Conflicts:
#	internal/rpc/user/user.go
2023-01-16 15:05:07 +08:00
wangchuxiao ea5039d2ae Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release
# Conflicts:
#	internal/rpc/user/user.go
2023-01-16 14:53:29 +08:00
wangchuxiao 8f2e9f5261 sg recv opt 2023-01-16 14:52:12 +08:00
Gordon e1147aff9e user update 2023-01-16 13:26:14 +08:00
wangchuxiao f9b39e91ee Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release 2023-01-13 19:47:47 +08:00
wangchuxiao 4bf73b0a47 sg recv opt 2023-01-13 19:47:32 +08:00
Gordon 05ee20613b reaction message update 2023-01-13 18:28:09 +08:00
Gordon 286163ce18 reaction message update 2023-01-13 17:42:23 +08:00
Gordon f0976c9ade reaction message update 2023-01-13 17:04:52 +08:00
Gordon 1ab7660f0d remove extend msg limit 2023-01-13 13:57:24 +08:00
Gordon 84c7b8827e message 2023-01-13 11:32:02 +08:00
Gordon 5e1aa43793 file update 2023-01-12 10:59:42 +08:00
skiffer-git a9b71e5a96 Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2023-01-11 16:00:56 +08:00
skiffer-git 08ed131e19 sendKickMsg add operationID 2023-01-11 16:00:38 +08:00
Gordon 85e3a81419 super group remove unread message 2023-01-11 14:33:33 +08:00
wangchuxiao 818ed107c6 fix Pb2String 2023-01-10 13:07:42 +08:00
wangchuxiao 4f322254b0 fix Pb2String 2023-01-09 19:11:50 +08:00
wangchuxiao decd6a98be Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release 2023-01-09 18:58:53 +08:00
wangchuxiao 5ae35bfee1 fix Pb2String 2023-01-09 18:58:40 +08:00
Gordon a6ba349cb6 Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2023-01-06 16:13:35 +08:00
Gordon 3e3818d4b5 reaction message update 2023-01-06 16:11:49 +08:00
withchao 6661c5baac group member cache 2023-01-05 16:11:20 +08:00
Gordon e813016402 del msg 2023-01-04 17:14:30 +08:00
wangchuxiao 924aa8ecb5 Merge branch 'main' into v2.3.0release 2023-01-03 18:17:39 +08:00
wangchuxiao 64edd9b7ea fix script 2023-01-03 18:16:32 +08:00
wangchuxiao 4400423fca add group proto 2023-01-03 18:08:59 +08:00
wangchuxiao 0554778c83 add group proto 2023-01-03 17:26:25 +08:00
wangchuxiao 2bc6d77d10 Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release 2023-01-03 17:08:45 +08:00
wangchuxiao 7ac790e4d0 Merge branch 'v2.3.0release' 2023-01-03 17:01:54 +08:00
wangchuxiao 0732fe6171 update version for docker 2023-01-03 17:01:39 +08:00
wangchuxiao d7b3ea0a6e Merge branch 'main' of github.com:OpenIMSDK/Open-IM-Server 2023-01-03 16:58:40 +08:00
Gordon 0a2b6605d7 core version 2023-01-03 16:39:54 +08:00
Gordon f559795ba3 file add 2023-01-03 16:39:27 +08:00
Gordon 6b8b5f7896 push update 2023-01-02 19:07:24 +08:00
Gordon 1bf4fa0d87 push update 2023-01-02 19:07:05 +08:00
Gordon d53507b7b6 callback update 2022-12-30 12:04:48 +08:00
Gordon 787bfccc2c Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2022-12-30 11:44:30 +08:00
Gordon 955bfe3f40 callback update 2022-12-30 11:44:17 +08:00
wangchuxiao 78d7588af7 kfk log 2022-12-29 19:10:43 +08:00
wangchuxiao bbde362570 Merge branch 'v2.3.0release' of https://github.com/OpenIMSDK/Open-IM-Server into v2.3.0release 2022-12-29 11:01:25 +08:00
wangchuxiao 972dd5f531 fix bug 2022-12-29 11:00:41 +08:00
withchao 464320a3ec Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2022-12-28 21:24:51 +08:00
wangchuxiao 2aa49f080e cron 2022-12-28 19:19:26 +08:00
wangchuxiao 9dac12cf2b cron 2022-12-28 18:56:49 +08:00
wangchuxiao d1f3266383 cron 2022-12-28 18:00:09 +08:00
withchao 1e2a60c802 join group 2022-12-28 17:56:13 +08:00
wangchuxiao ee9c3cbde3 cron 2022-12-28 17:49:41 +08:00
wangchuxiao 235be5da0c cron 2022-12-28 17:26:53 +08:00
withchao 29adb5de07 Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release 2022-12-28 17:09:39 +08:00
withchao 4618bf990d invite user to group 2022-12-28 16:17:54 +08:00
wangchuxiao 0a57830925 test cron 2022-12-28 15:42:52 +08:00
wangchuxiao 71a2090363 test cron 2022-12-28 15:41:04 +08:00
withchao e420871e1f agree user join group 2022-12-28 15:38:27 +08:00
wangchuxiao 01b2de80ae test cron 2022-12-28 15:33:53 +08:00
wangchuxiao cdd86349d0 test cron 2022-12-28 15:27:04 +08:00
wangchuxiao 45293152bb test cron 2022-12-28 15:20:04 +08:00
wangchuxiao 7bf7686314 test cron 2022-12-28 14:54:22 +08:00
wangchuxiao 5888dc3b5d test cron 2022-12-28 14:20:17 +08:00
wangchuxiao 3d9355848b test cron 2022-12-28 14:13:16 +08:00
wangchuxiao 7033b603ca test cron 2022-12-28 13:56:07 +08:00
wangchuxiao 71ad683614 test cron 2022-12-28 12:42:17 +08:00
wangchuxiao 1fdc4d06d1 test cron 2022-12-28 12:10:10 +08:00
wangchuxiao cff9ee39be test cron 2022-12-28 12:02:56 +08:00
wangchuxiao 458f872fe3 test cron 2022-12-28 11:47:39 +08:00
wangchuxiao ac99da044a test cron 2022-12-28 11:33:49 +08:00
wangchuxiao a6bd8e5205 test cron 2022-12-28 11:15:15 +08:00
wangchuxiao f9fdd540f9 test cron 2022-12-28 11:03:12 +08:00
wangchuxiao 1706f5df07 test cron 2022-12-28 11:02:14 +08:00
wangchuxiao 40fc3e6c08 test cron 2022-12-28 10:58:30 +08:00
wangchuxiao 2608ae58df test cron 2022-12-28 10:55:00 +08:00
wangchuxiao 0e62deed0a test cron 2022-12-27 22:27:44 +08:00
122 changed files with 6543 additions and 5908 deletions
+396 -15
View File
@@ -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
.devcontainer
components
logs
out-test
.github
.idea
Dockerfile.cross
### Makefile ###
tmp/
bin/
output/
_output/
deploy/open_im_demo
deploy/open_im_api
deploy/open_im_msg_gateway
deploy/open_im_msg_transfer
deploy/open_im_push
deploy/open_im_timer_task
deploy/open_im_rpc_user
deploy/open_im_rpc_friend
deploy/open_im_rpc_group
deploy/open_im_rpc_msg
deploy/open_im_rpc_auth
### OpenIM Config ###
config/config.yaml
./config/config.yaml
.env
./.env
### OpenIM deploy ###
deploy/openim_demo
deploy/openim-api
deploy/openim-rpc-msg_gateway
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
# 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
-2
View File
@@ -26,8 +26,6 @@ By deployment of the Open-IM-Server on the customer's server, developers can int
- Supports multiple protocols
## Community
- Join Slack Community : https://join.slack.com/t/openimcommunity/shared_invite/zt-1jo5m1wm9-ym2qj0LUU5UbO68L6Z1zQg
- 中文官网访问这里:[Open-IM中文开发文档](https://doc.rentsoft.cn/)
## Quick start
+15 -5
View File
@@ -1,13 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_api
NAME=open_im_api
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -16,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+4
View File
@@ -111,6 +111,8 @@ func main() {
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //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("/dismiss_group", group.DismissGroup) //
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
@@ -175,8 +177,10 @@ func main() {
conversationGroup.POST("/get_all_conversations", conversation.GetAllConversations)
conversationGroup.POST("/get_conversation", conversation.GetConversation)
conversationGroup.POST("/get_conversations", conversation.GetConversations)
//deprecated
conversationGroup.POST("/set_conversation", conversation.SetConversation)
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
//deprecated
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
conversationGroup.POST("/modify_conversation_field", conversation.ModifyConversationField)
}
+15 -4
View File
@@ -1,13 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_cms_api
NAME=open_im_cms_api
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -16,8 +28,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,12 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_cron_task
NAME=open_im_cron_task
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,13 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_demo
NAME=open_im_demo
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -16,8 +28,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,12 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_msg_gateway
NAME=open_im_msg_gateway
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,13 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_msg_transfer
NAME=open_im_msg_transfer
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -16,8 +28,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,12 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_push
NAME=open_im_push
BIN_DIR=../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,12 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_admin_cms
NAME=open_im_admin_cms
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,12 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_auth
NAME=open_im_auth
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,12 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_cache
NAME=open_im_cache
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,12 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_conversation
NAME=open_im_conversation
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+1 -1
View File
@@ -14,7 +14,7 @@ func main() {
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")
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)
go func() {
err := promePkg.StartPromeSrv(*prometheusPort)
+16 -4
View File
@@ -1,12 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_friend
NAME=open_im_friend
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +28,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+16 -4
View File
@@ -1,12 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_group
NAME=open_im_group
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +28,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,12 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_msg
NAME=open_im_msg
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,12 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_office
NAME=open_im_office
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,12 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_organization
NAME=open_im_organization
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+15 -4
View File
@@ -1,12 +1,24 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_user
NAME=open_im_user
BIN_DIR=../../../bin/
OS:= $(or $(os),linux)
ARCH:=$(or $(arch),amd64)
all: gotool build
ifeq ($(OS),windows)
BINARY_NAME=${NAME}.exe
else
BINARY_NAME=${NAME}
endif
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:
@go run ./
@@ -15,8 +27,7 @@ gotool:
go fmt ./
go vet ./
install:
make build
install:build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
+62 -52
View File
@@ -36,7 +36,7 @@ mongo:
dbPassword: #mongo密码,建议先不设置
dbMaxPoolSize: 100
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
chatRecordsClearTime: "* * * * *" # 每天凌晨3点清除消息,该配置和linux定时任务一样, 清理操作建议设置在用户活跃少的时候 # 0 3 * * *
chatRecordsClearTime: "0 3 * * *" # 每天凌晨3点清除消息,该配置和linux定时任务一样, 清理操作建议设置在用户活跃少的时候 # 0 3 * * *
redis:
dbAddress: [ 127.0.0.1:16379 ] #redis地址 单机时,填写一个地址即可,使用redis集群时候,填写集群中多个节点地址(主从地址都可以填写,增加容灾能力),默认即可
@@ -115,11 +115,11 @@ sdk:
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
tencent:
appID: 1302656840
region: ap-chengdu
bucket: echat-1302656840
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC1
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe1
appID:
region:
bucket:
secretID:
secretKey:
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
bucket: openim # 存储内容桶
appBucket: app # 存储app的桶
@@ -132,24 +132,24 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
storageTime: 50 #文件在minio中保存的时间
isDistributedMod: false # 是否分布式多硬盘部署 默认docker-compose中为false
ali: # ali oss
regionID: "oss-cn-beijing"
accessKeyID: ""
accessKeySecret: ""
stsEndpoint: "sts.cn-beijing.aliyun.com"
ossEndpoint: "oss-cn-beijing.aliyuncs.com"
bucket: "bucket1"
finalHost: "http://bucket1.oss-cn-beijing.aliyuncs.com"
stsDurationSeconds: 3600
OssRoleArn: "acs:ram::xxx:role/xxx"
regionID:
accessKeyID:
accessKeySecret:
stsEndpoint:
ossEndpoint:
bucket:
finalHost:
stsDurationSeconds:
OssRoleArn:
aws:
accessKeyID: 1 #AssumeRole用户关联的accessKeyID
accessKeySecret: 2 #AssumeRole用户关联的accessKeySecrect
region: ap-southeast-1 #分区
bucket: ouyang #桶
finalHost: ouyang.s3.ap-southeast-1.amazonaws.com #对外Host
roleArn: arn:aws:iam::192209831083:role/AWS_S3_FOR_OUYANG #RoleArn
externalId: AssumeRoleExtend #角色扩展Id
roleSessionName: Required-AWS-ID-OPENIM #角色SESSION名称
accessKeyID: #AssumeRole用户关联的accessKeyID
accessKeySecret: #AssumeRole用户关联的accessKeySecrect
region: #分区
bucket: #桶
finalHost: #对外Host
roleArn: #RoleArn
externalId: #角色扩展Id
roleSessionName: #角色SESSION名称
rpcport: #rpc服务端口 默认即可
@@ -216,17 +216,17 @@ longconnsvr:
push:
tpns: #腾讯推送,暂未测试 暂不要使用
ios:
accessID: 1600018281
secretKey: 3cd68a77a95b89e5089a1aca523f318f
accessID:
secretKey:
android:
accessID: 111
secretKey: 111
accessID:
secretKey:
enable: false # true or false (bool)
jpns: #极光推送 在极光后台申请后,修改以下四项,必须修改
appKey: cf47465a368f24c659608e7e
masterSecret: 02204efe3f3832947a236ee5
pushUrl: "https://api.jpush.cn/v3/push"
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
appKey:
masterSecret:
pushUrl:
pushIntent:
enable: false # true or false (bool)
getui: #个推推送
pushUrl:
@@ -236,14 +236,21 @@ push:
enable: # true or false (bool)
channelID: ""
channelName: ""
channel:
HW:
category:
XM:
channelID:
OPPO:
channelID:
fcm: #firebase cloud message 消息推送
serviceAccount: "openim-5c6c0-firebase-adminsdk-ppwol-8765884a78.json" #帐号文件,此处需要改修配置,并且这个文件放在 config目录下
serviceAccount: #帐号文件,此处需要改修配置,并且这个文件放在 config目录下
enable: false
mob: #袤博推送
appKey: "3377f689a25" #帐号文件,此处需要改修配置,并且这个文件放在 config目录下
pushUrl: "https://api.push.mob.com/v3/push/createPush"
scheme: "dianzhijiaunilinks://dianzhijia.com?page=rent"
appSecret: "77b4e20e94db3a776b87d8693be23e"
appKey: #帐号文件,此处需要改修配置,并且这个文件放在 config目录下
pushUrl:
scheme:
appSecret:
enable: false
@@ -311,6 +318,9 @@ callback:
callbackAfterSendGroupMsg:
enable: false
callbackTimeOut: 2
callbackAfterConsumeGroupMsg:
enable: false
callbackTimeOut: 2
callbackMsgModify:
enable: false
callbackTimeOut: 2
@@ -765,18 +775,18 @@ demo:
#demo对外服务端口,默认即可,需要开放此端口或做nginx转发
openImDemoPort: [ 10004 ]
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,enable为true则必须修改,阿里云为默认短信验证方式
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe7
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV
signName: 托云信息技术
verificationCodeTemplateCode: SMS_226810164
accessKeyId:
accessKeySecret:
signName:
verificationCodeTemplateCode:
enable: false
tencentsms: #腾讯云短信配置,在腾讯云申请成功后,修改以下选项,enable为true则必须修改
appID: 2400000648
region: "ap-singapore"
secretID: IKIDra4JPGsFMDwQedMq42lESQBgwwgBQQAe
secretKey: HI6fz4uUotjJdiX6QUIrAE2buxlKdgU2
signName: ""
verificationCodeTemplateCode: 2902877
appID:
region:
secretID:
secretKey:
signName:
verificationCodeTemplateCode:
enable: true
superCode: 666666 #超级验证码,建议修改掉,收不到短信验证码时可以用此替代
needInvitationCode: false
@@ -784,11 +794,11 @@ demo:
codeTTL: 60
useSuperCode: true
mail: #仅支持qq邮箱,具体操作参考 https://service.mail.qq.com/cgi-bin/help?subtype=1&id=28&no=1001256 必须修改
title: "openIM"
senderMail: "765567899@qq.com"
senderAuthorizationCode: "gxyausfoevlzbfag"
smtpAddr: "smtp.qq.com"
smtpPort: 25 #需开放此端口 出口方向
title:
senderMail:
senderAuthorizationCode:
smtpAddr:
smtpPort: #需开放此端口 出口方向
testDepartMentID: 001
imAPIURL: http://127.0.0.1:10002
onboardProcess: false # 是否开启注册流程
@@ -820,4 +830,4 @@ prometheus:
conversationPrometheusPort: [ 20230 ]
cachePrometheusPort: [ 20240 ]
realTimeCommPrometheusPort: [ 21300 ]
messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # 端口数量和 script/path_info.cfg msg_transfer_service_num保持一致
messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # 端口数量和 script/path_info.cfg msg_transfer_service_num保持一致
+22 -22
View File
@@ -79,11 +79,11 @@ cmsapi:
credential:
tencent:
appID: 1302656840
region: ap-chengdu
bucket: echat-1302656840
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
appID:
region:
bucket:
secretID:
secretKey:
rpcport:
@@ -131,16 +131,16 @@ longconnsvr:
push:
tpns:
ios:
accessID: 1600018281
secretKey: 3cd68a77a95b89e5089a1aca523f318f
accessID:
secretKey:
android:
accessID: 111
secretKey: 111
accessID:
secretKey:
jpns:
appKey: cf47465a368f24c659608e7e
masterSecret: 02204efe3f3832947a236ee5
pushUrl: "https://api.jpush.cn/v3/push"
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
appKey:
masterSecret:
pushUrl:
pushIntent:
manager:
appManagerUid: ["openIM123456","openIM654321"]
secrets: ["openIM1","openIM2"]
@@ -168,16 +168,16 @@ demoswitch: true
demo:
openImDemoPort: [ 42233 ]
alismsverify:
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe71
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV1
signName: OpenIM Corporation
verificationCodeTemplateCode: SMS_2268101641
accessKeyId:
accessKeySecret:
signName:
verificationCodeTemplateCode:
superCode: 666666
mail:
title: "openIM"
senderMail: "1765567899@qq.com"
senderAuthorizationCode: "1gxyausfoevlzbfag"
smtpAddr: "smtp.qq.com"
smtpPort: 25
title:
senderMail:
senderAuthorizationCode:
smtpAddr:
smtpPort:
+2 -1
View File
@@ -12,7 +12,8 @@ ADD ./open_im_admin_cms $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+8 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: admin-cms
image: openim/admin_cms:v2.3.4
image: openim/admin_cms:v2.3.8
# imagePullPolicy: Always #每次启动都重新拉取镜像
ports:
- containerPort: 10200
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,11 +30,13 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
+2 -1
View File
@@ -11,7 +11,8 @@ ADD ./open_im_api $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: api
image: openim/api:v2.3.4
image: openim/api:v2.3.8
# imagePullPolicy: Always
ports:
- containerPort: 10002
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,11 +30,12 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
---
+2 -1
View File
@@ -11,7 +11,8 @@ ADD ./open_im_auth $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: auth
image: openim/auth:v2.3.4
image: openim/auth:v2.3.8
# imagePullPolicy: Always
ports:
- containerPort: 10160
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,10 +30,11 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
+1 -1
View File
@@ -2,7 +2,7 @@
source ./path_info.cfg
# images version
version=v2.3.4
version=v2.3.8
git pull
cd ../script/; ./build_all_service.sh
cd ../deploy_k8s/
+2 -1
View File
@@ -12,7 +12,8 @@ ADD ./open_im_cache $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
WORKDIR $CMDDIR
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: cache
image: openim/cache:v2.3.4
image: openim/cache:v2.3.8
# imagePullPolicy: Always
ports:
- containerPort: 10240
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,10 +30,11 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
+2 -1
View File
@@ -11,7 +11,8 @@ ADD ./open_im_cms_api $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
WORKDIR $CMDDIR
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: cms-api
image: openim/cms_api:v2.3.4
image: openim/cms_api:v2.3.8
imagePullPolicy: Always
ports:
- containerPort: 10006
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,11 +30,12 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
---
@@ -11,7 +11,8 @@ ADD ./open_im_conversation $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
WORKDIR $CMDDIR
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: conversation
image: openim/conversation:v2.3.4
image: openim/conversation:v2.3.8
# imagePullPolicy: Always
ports:
- containerPort: 10230
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -34,11 +31,12 @@ spec:
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
+2 -1
View File
@@ -11,7 +11,8 @@ ADD ./open_im_demo $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: demo
image: openim/demo:v2.3.4
image: openim/demo:v2.3.8
imagePullPolicy: Always
ports:
- containerPort: 10004
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,11 +30,12 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
---
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: friend
image: openim/friend:v2.3.4
image: openim/friend:v2.3.8
# imagePullPolicy: Always
ports:
- containerPort: 10120
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,11 +30,12 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
+2 -1
View File
@@ -12,7 +12,8 @@ ADD ./open_im_friend $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
WORKDIR $CMDDIR
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: group
image: openim/group:v2.3.4
image: openim/group:v2.3.8
# imagePullPolicy: Always
ports:
- containerPort: 10150
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,10 +30,11 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
+2 -1
View File
@@ -11,7 +11,8 @@ ADD ./open_im_group $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+4 -5
View File
@@ -9,18 +9,17 @@
6. 将rpcRegisterIP修改为空, 此地址为每个rpc注册到ETCD的地址, 置空每个rpc将会将pod地址注册到ETCD, 才能正确rpc请求(重要)
7. 如果使用minio作为对象存储, 还需要修改minio的地址
8. 其他如果使用离线推送,需要修改push离线推送配置
9. 修改demo中的imAPIURL字段为openIM api的ingress或者service地址, 需要让demo的pod能正确请求到(重要)
10. 其他非必须配置修改, 如短信,推送等
### 2. 项目根目录创建im configMap到k8s openim namespace
1. 为open-IM项目创建单独命名空间
```
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 usualConfig --from-file=config/usualConfig.yaml
kubectl -n openim create configmap openim-config --from-file=config/config.yaml
kubectl -n openim create configmap openim-usualconfig --from-file=config/usualConfig.yaml
```
查看configmap
```
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: msg
image: openim/msg:v2.3.4
image: openim/msg:v2.3.8
# imagePullPolicy: Always
ports:
- containerPort: 10130
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,10 +30,11 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
+2 -1
View File
@@ -12,7 +12,8 @@ ADD ./open_im_msg $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: msg-gateway
image: openim/msg_gateway:v2.3.4
image: openim/msg_gateway:v2.3.8
# imagePullPolicy: Always
ports:
- name: rpc-port
@@ -26,9 +26,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -36,11 +33,12 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
---
@@ -11,7 +11,8 @@ ADD ./open_im_msg_gateway $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+7 -9
View File
@@ -15,15 +15,12 @@ spec:
spec:
containers:
- name: msg-transfer
image: openim/msg_transfer:v2.3.4
image: openim/msg_transfer:v2.3.8
# imagePullPolicy: Always
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -31,10 +28,11 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
@@ -11,7 +11,8 @@ ADD ./open_im_msg_transfer $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: office
image: openim/office:v2.3.4
image: openim/office:v2.3.8
# imagePullPolicy: Always
ports:
- containerPort: 10210
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,10 +30,11 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
+2 -1
View File
@@ -12,7 +12,8 @@ ADD ./open_im_office $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: organization
image: openim/organization:v2.3.4
image: openim/organization:v2.3.8
# imagePullPolicy: Always
ports:
- containerPort: 10220
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,10 +30,11 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
@@ -12,7 +12,8 @@ ADD ./open_im_organization $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+7 -9
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: push
image: openim/push:v2.3.4
image: openim/push:v2.3.8
# imagePullPolicy: Always
ports:
- containerPort: 10170
@@ -23,9 +23,6 @@ spec:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -33,10 +30,11 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
+2 -1
View File
@@ -12,7 +12,8 @@ ADD ./open_im_push $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+1 -1
View File
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: sdk-server
image: openim/sdk_server:v2.3.4
image: openim/sdk_server:v2.3.8
# imagePullPolicy: Always
ports:
- containerPort: 10003
+2 -1
View File
@@ -11,7 +11,8 @@ ADD ./open_im_sdk_server $WORKDIR/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
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"]
WORKDIR $CMDDIR
+7 -9
View File
@@ -15,15 +15,12 @@ spec:
spec:
containers:
- name: user
image: openim/user:v2.3.4
image: openim/user:v2.3.8
# imagePullPolicy: Always
volumeMounts:
- name: config
mountPath: /Open-IM-Server/config
readOnly: true
- name: usualConfig
mountPath: /Open-IM-Server/config
readOnly: true
env:
- name: CONFIG_NAME
value: "/Open-IM-Server"
@@ -31,10 +28,11 @@ spec:
value: "/Open-IM-Server"
volumes:
- name: config
configMap:
name: openim-config
- name: usualConfig
configMap:
name: openim-usualConfig
projected:
sources:
- configMap:
name: openim-config
- configMap:
name: openim-usualconfig
strategy: #更新策略
type: RollingUpdate # 滚动更新
+2 -1
View File
@@ -11,7 +11,8 @@ ADD ./open_im_user $WORKDIR/cmd/main
# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
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"]
+2 -2
View File
@@ -115,7 +115,7 @@ services:
open_im_server:
image: openim/open_im_server:v2.3.6
image: openim/open_im_server:v2.3.8
container_name: open_im_server
volumes:
- ./logs:/Open-IM-Server/logs
@@ -139,7 +139,7 @@ services:
max-file: "2"
open_im_enterprise:
image: openim/open_im_enterprise:v1.0.2
image: openim/open_im_enterprise:v1.0.3
container_name: open_im_enterprise
volumes:
- ./logs:/Open-IM-Enterprise/logs
+41
View File
@@ -370,6 +370,47 @@ func InviteUserToGroup(c *gin.Context) {
log.NewInfo(req.OperationID, "InviteUserToGroup api return ", resp)
c.JSON(http.StatusOK, resp)
}
func InviteUserToGroups(c *gin.Context) {
params := api.InviteUserToGroupsReq{}
if err := c.BindJSON(&params); 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, &params)
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 创建群组
// @Description 创建群组
+14 -4
View File
@@ -38,6 +38,7 @@ func SetOptions(options map[string]bool, value bool) {
func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
var newContent string
options := make(map[string]bool, 5)
var err error
switch params.ContentType {
case constant.Text:
@@ -56,13 +57,16 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
fallthrough
case constant.CustomOnlineOnly:
fallthrough
case constant.AtText:
fallthrough
case constant.AdvancedRevoke:
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
newContent = utils.StructToJsonString(params.Content)
case constant.Revoke:
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
newContent = params.Content["revokeMsgClientID"].(string)
default:
}
options := make(map[string]bool, 5)
if params.IsOnlineOnly {
SetOptions(options, false)
}
@@ -155,6 +159,8 @@ func ManagementSendMsg(c *gin.Context) {
data = CustomElem{}
case constant.CustomOnlineOnly:
data = CustomElem{}
case constant.AtText:
data = AtElem{}
//case constant.HasReadReceipt:
//case constant.Typing:
//case constant.Quote:
@@ -467,9 +473,13 @@ type FileElem struct {
FileSize int64 `mapstructure:"fileSize"`
}
type AtElem struct {
Text string `mapstructure:"text"`
AtUserList []string `mapstructure:"atUserList"`
IsAtSelf bool `mapstructure:"isAtSelf"`
Text string `mapstructure:"text"`
AtUserList []string `mapstructure:"atUserList"`
AtUsersInfo []struct {
AtUserID string `json:"atUserID,omitempty"`
GroupNickname string `json:"groupNickname,omitempty"`
} `json:"atUsersInfo,omitempty"`
IsAtSelf bool `mapstructure:"isAtSelf"`
}
type LocationElem struct {
Description string `mapstructure:"description"`
+11 -7
View File
@@ -17,8 +17,8 @@ import (
func SetMessageReactionExtensions(c *gin.Context) {
var (
req api.SetMessageReactionExtensionsCallbackReq
resp api.SetMessageReactionExtensionsCallbackResp
req api.SetMessageReactionExtensionsReq
resp api.SetMessageReactionExtensionsResp
reqPb rpc.SetMessageReactionExtensionsReq
)
@@ -33,7 +33,7 @@ func SetMessageReactionExtensions(c *gin.Context) {
}
var ok bool
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 {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
@@ -72,7 +72,7 @@ func GetMessageListReactionExtensions(c *gin.Context) {
reqPb rpc.GetMessageListReactionExtensionsReq
)
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
@@ -86,7 +86,7 @@ func GetMessageListReactionExtensions(c *gin.Context) {
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})
c.JSON(http.StatusOK, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@@ -115,8 +115,9 @@ func AddMessageReactionExtensions(c *gin.Context) {
var (
req api.AddMessageReactionExtensionsReq
resp api.AddMessageReactionExtensionsResp
reqPb rpc.ModifyMessageReactionExtensionsReq
reqPb rpc.AddMessageReactionExtensionsReq
)
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
@@ -128,7 +129,7 @@ func AddMessageReactionExtensions(c *gin.Context) {
}
var ok bool
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 {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
@@ -152,6 +153,9 @@ func AddMessageReactionExtensions(c *gin.Context) {
}
resp.ErrCode = respPb.ErrCode
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)
c.JSON(http.StatusOK, resp)
}
+29 -12
View File
@@ -34,9 +34,7 @@ func ResetUserGroupMinSeq(operationID, groupID string, userIDList []string) erro
log.NewError(operationID, utils.GetSelfFuncName(), "GetGroupUserMinSeq failed", groupID, userID, err.Error())
continue
}
if userMinSeq > uint64(minSeq) {
err = db.DB.SetGroupUserMinSeq(groupID, userID, userMinSeq)
} else {
if userMinSeq < uint64(minSeq) {
err = db.DB.SetGroupUserMinSeq(groupID, userID, uint64(minSeq))
}
if err != nil {
@@ -56,6 +54,19 @@ func DeleteMongoMsgAndResetRedisSeq(operationID, userID string) error {
return nil
}
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)
return utils.Wrap(err, "")
}
@@ -100,13 +111,13 @@ func deleteMongoMsg(operationID string, ID string, index int64, delStruct *delMs
if err != nil {
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))
if len(msgs.Msg) > db.GetSingleGocMsgNum() {
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)
lastMsgPb := &server_api_params.MsgData{}
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)
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 {
var hasMarkDelFlag bool
for _, msg := range msgs.Msg {
for index, msg := range msgs.Msg {
if msg.SendTime == 0 {
continue
}
msgPb := &server_api_params.MsgData{}
err = proto.Unmarshal(msg.Msg, msgPb)
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) {
msgPb.Status = constant.MsgDeleted
bytes, _ := proto.Marshal(msgPb)
msg.Msg = bytes
msg.SendTime = 0
msgs.Msg[index].Msg = bytes
msgs.Msg[index].SendTime = 0
hasMarkDelFlag = true
} else {
if err := delMongoMsgsPhysical(delStruct.delUidList); err != nil {
return 0, err
}
if hasMarkDelFlag {
log.NewInfo(operationID, ID, "hasMarkDelFlag", "index:", index, "msgPb:", msgPb, msgs.UID)
if err := db.DB.UpdateOneMsgList(msgs); err != nil {
return delStruct.getSetMinSeq(), utils.Wrap(err, "")
}
}
return msgPb.Seq + 1, nil
return msgPb.Seq, nil
}
}
}
@@ -172,9 +188,10 @@ func checkMaxSeqWithMongo(operationID, ID string, diffusionType int) error {
}
if err != 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)
if err != nil {
+143 -21
View File
@@ -4,6 +4,7 @@ import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
server_api_params "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"fmt"
"strconv"
@@ -12,6 +13,7 @@ import (
"github.com/golang/protobuf/proto"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"gopkg.in/mgo.v2/bson"
"testing"
"time"
@@ -23,7 +25,7 @@ var (
)
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++ {
msg := server_api_params.MsgData{
SendID: "sendID1",
@@ -44,7 +46,12 @@ func GenUserChat(startSeq, stopSeq, delSeq, index uint32, userID string) *db.Use
Status: 1,
}
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})
}
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()
}
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 {
_, err := mongoClient.InsertOne(context.Background(), userChat)
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) {
operationID := getCronTaskOperationID()
redisClient = redis.NewClient(&redis.Options{
Addr: "127.0.0.1:16379",
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",
"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))
mongoClient = client.Database("openIM").Collection("msg")
testUID1 := "test_del_id1"
//testUID2 := "test_del_id2"
//testUID3 := "test_del_id3"
//testUID4 := "test_del_id4"
//testUID5 := "test_del_id5"
//testUID6 := "test_del_id6"
err = DelChat(testUID1, 0)
err = SetUserMaxSeq(testUID1, 600)
userChat := GenUserChat(1, 500, 200, 0, testUID1)
userChat := GenUserChat(1, 600, 200, 0, testUID1)
err = CreateChat(userChat)
if err := DeleteMongoMsgAndResetRedisSeq(operationID, testUID1); err != nil {
t.Error("checkMaxSeqWithMongo failed", testUID1)
}
if err := checkMaxSeqWithMongo(operationID, testUID1, constant.WriteDiffusion); err != nil {
t.Error("checkMaxSeqWithMongo failed", testUID1)
}
minSeq, err := GetUserMinSeq(testUID1)
if err != nil {
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"}
// for _, groupID := range testWorkingGroupIDList {
// operationID = groupID + "-" + operationID
// log.NewDebug(operationID, utils.GetSelfFuncName(), "groupID:", groupID, "userIDList:", testUserIDList)
// if err := ResetUserGroupMinSeq(operationID, groupID, testUserIDList); err != nil {
// t.Error("checkMaxSeqWithMongo failed", groupID)
// }
// if err := checkMaxSeqWithMongo(operationID, groupID, constant.ReadDiffusion); err != nil {
// t.Error("checkMaxSeqWithMongo failed", groupID)
// }
// }
if minSeq != 201 {
t.Error("test1 is not the same", "minSeq:", minSeq, "targetSeq", 201)
}
testUID2 := "test_del_id2"
err = DelChat(testUID2, 0)
err = DelChat(testUID2, 1)
err = SetUserMaxSeq(testUID2, 7000)
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)
}
}
-6
View File
@@ -1,6 +0,0 @@
package main
//
//func main() {
// db.DB.BatchInsertChat()
//}
+1
View File
@@ -269,6 +269,7 @@ func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
mReplyData.ClientMsgID = pb.GetClientMsgID()
mReplyData.ServerMsgID = pb.GetServerMsgID()
mReplyData.SendTime = pb.GetSendTime()
mReplyData.Ex = pb.GetEx()
b, _ := proto.Marshal(&mReplyData)
mReply := Resp{
ReqIdentifier: m.ReqIdentifier,
+188 -127
View File
@@ -101,47 +101,48 @@ func (r *RPCServer) run() {
}
}
func (r *RPCServer) OnlinePushMsg(_ context.Context, in *pbRelay.OnlinePushMsgReq) (*pbRelay.OnlinePushMsgResp, error) {
log.NewInfo(in.OperationID, "PushMsgToUser is arriving", in.String())
var resp []*pbRelay.SingleMsgToUserPlatform
msgBytes, _ := proto.Marshal(in.MsgData)
mReply := Resp{
ReqIdentifier: constant.WSPushMsg,
OperationID: in.OperationID,
Data: msgBytes,
}
var replyBytes bytes.Buffer
enc := gob.NewEncoder(&replyBytes)
err := enc.Encode(mReply)
if err != nil {
log.NewError(in.OperationID, "data encode err", err.Error())
}
var tag bool
recvID := in.PushToUserID
for _, v := range r.platformList {
if conn := ws.getUserConn(recvID, v); conn != nil {
tag = true
resultCode := sendMsgToUser(conn, replyBytes.Bytes(), in, v, recvID)
temp := &pbRelay.SingleMsgToUserPlatform{
ResultCode: resultCode,
RecvID: recvID,
RecvPlatFormID: int32(v),
}
resp = append(resp, temp)
} else {
temp := &pbRelay.SingleMsgToUserPlatform{
ResultCode: -1,
RecvID: recvID,
RecvPlatFormID: int32(v),
}
resp = append(resp, temp)
}
}
if !tag {
log.NewDebug(in.OperationID, "push err ,no matched ws conn not in map", in.String())
}
return &pbRelay.OnlinePushMsgResp{
Resp: resp,
}, nil
//log.NewInfo(in.OperationID, "PushMsgToUser is arriving", in.String())
//var resp []*pbRelay.SingleMsgToUserPlatform
//msgBytes, _ := proto.Marshal(in.MsgData)
//mReply := Resp{
// ReqIdentifier: constant.WSPushMsg,
// OperationID: in.OperationID,
// Data: msgBytes,
//}
//var replyBytes bytes.Buffer
//enc := gob.NewEncoder(&replyBytes)
//err := enc.Encode(mReply)
//if err != nil {
// log.NewError(in.OperationID, "data encode err", err.Error())
//}
//var tag bool
//recvID := in.PushToUserID
//for _, v := range r.platformList {
// if conn := ws.getUserConn(recvID, v); conn != nil {
// tag = true
// resultCode := sendMsgToUser(conn, replyBytes.Bytes(), in, v, recvID)
// temp := &pbRelay.SingleMsgToUserPlatform{
// ResultCode: resultCode,
// RecvID: recvID,
// RecvPlatFormID: int32(v),
// }
// resp = append(resp, temp)
// } else {
// temp := &pbRelay.SingleMsgToUserPlatform{
// ResultCode: -1,
// RecvID: recvID,
// RecvPlatFormID: int32(v),
// }
// resp = append(resp, temp)
// }
//}
//if !tag {
// log.NewDebug(in.OperationID, "push err ,no matched ws conn not in map", in.String())
//}
//return &pbRelay.OnlinePushMsgResp{
// Resp: resp,
//}, nil
return nil, nil
}
func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUsersOnlineStatusReq) (*pbRelay.GetUsersOnlineStatusResp, error) {
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.UserID = userID
userConnMap := ws.getUserAllCons(userID)
for platform, userConn := range userConnMap {
if userConn != nil {
for platform, userConns := range userConnMap {
if len(userConns) != 0 {
ps := new(pbRelay.GetUsersOnlineStatusResp_SuccessDetail)
ps.Platform = constant.PlatformIDToName(platform)
ps.Status = constant.OnlineStatus
ps.ConnID = userConn.connID
ps.IsBackground = userConn.IsBackground
ps.ConnID = userConns[0].connID
ps.IsBackground = userConns[0].IsBackground
temp.Status = constant.OnlineStatus
temp.DetailPlatformStatus = append(temp.DetailPlatformStatus, ps)
}
@@ -196,13 +197,73 @@ func (r *RPCServer) SuperGroupOnlineBatchPushOneMsg(_ context.Context, req *pbRe
UserID: v,
}
userConnMap := ws.getUserAllCons(v)
for platform, userConn := range userConnMap {
if userConn != nil {
temp := &pbRelay.SingleMsgToUserPlatform{
RecvID: v,
RecvPlatFormID: int32(platform),
for platform, userConns := range userConnMap {
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)
}
}
if !userConn.IsBackground {
}
}
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{
RecvID: v,
RecvPlatFormID: int32(platform),
}
resultCode := sendMsgBatchToUser(userConn, replyBytes.Bytes(), req, platform, v)
if resultCode == 0 && utils.IsContainInt(platform, r.pushTerminal) {
tempT.OnlinePush = true
@@ -211,10 +272,8 @@ func (r *RPCServer) SuperGroupOnlineBatchPushOneMsg(_ context.Context, req *pbRe
temp.ResultCode = resultCode
resp = append(resp, temp)
}
} else {
temp.ResultCode = -2
resp = append(resp, temp)
}
}
}
tempT.Resp = resp
@@ -226,76 +285,77 @@ func (r *RPCServer) SuperGroupOnlineBatchPushOneMsg(_ context.Context, req *pbRe
}, nil
}
func (r *RPCServer) OnlineBatchPushOneMsg(_ context.Context, req *pbRelay.OnlineBatchPushOneMsgReq) (*pbRelay.OnlineBatchPushOneMsgResp, error) {
log.NewInfo(req.OperationID, "BatchPushMsgToUser is arriving", req.String())
var singleUserResult []*pbRelay.SingelMsgToUserResultList
for _, v := range req.PushToUserIDList {
var resp []*pbRelay.SingleMsgToUserPlatform
tempT := &pbRelay.SingelMsgToUserResultList{
UserID: v,
}
userConnMap := ws.getUserAllCons(v)
var platformList []int
for k, _ := range userConnMap {
platformList = append(platformList, k)
}
log.Debug(req.OperationID, "GetSingleUserMsgForPushPlatforms begin", req.MsgData.Seq, v, platformList, req.MsgData.String())
needPushMapList := r.GetSingleUserMsgForPushPlatforms(req.OperationID, req.MsgData, v, platformList)
log.Debug(req.OperationID, "GetSingleUserMsgForPushPlatforms end", req.MsgData.Seq, v, platformList, len(needPushMapList))
for platform, list := range needPushMapList {
if list != nil {
log.Debug(req.OperationID, "needPushMapList ", "userID: ", v, "platform: ", platform, "push msg num:")
//for _, v := range list {
// log.Debug(req.OperationID, "req.MsgData.MsgDataList begin", "len: ", len(req.MsgData.MsgDataList), v.String())
// req.MsgData.MsgDataList = append(req.MsgData.MsgDataList, v)
// 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)
}
return &pbRelay.OnlineBatchPushOneMsgResp{
SinglePushResult: singleUserResult,
}, nil
//log.NewInfo(req.OperationID, "BatchPushMsgToUser is arriving", req.String())
//var singleUserResult []*pbRelay.SingelMsgToUserResultList
//
//for _, v := range req.PushToUserIDList {
// var resp []*pbRelay.SingleMsgToUserPlatform
// tempT := &pbRelay.SingelMsgToUserResultList{
// UserID: v,
// }
// userConnMap := ws.getUserAllCons(v)
// var platformList []int
// for k, _ := range userConnMap {
// platformList = append(platformList, k)
// }
// log.Debug(req.OperationID, "GetSingleUserMsgForPushPlatforms begin", req.MsgData.Seq, v, platformList, req.MsgData.String())
// needPushMapList := r.GetSingleUserMsgForPushPlatforms(req.OperationID, req.MsgData, v, platformList)
// log.Debug(req.OperationID, "GetSingleUserMsgForPushPlatforms end", req.MsgData.Seq, v, platformList, len(needPushMapList))
// for platform, list := range needPushMapList {
// if list != nil {
// log.Debug(req.OperationID, "needPushMapList ", "userID: ", v, "platform: ", platform, "push msg num:")
// //for _, v := range list {
// // log.Debug(req.OperationID, "req.MsgData.MsgDataList begin", "len: ", len(req.MsgData.MsgDataList), v.String())
// // req.MsgData.MsgDataList = append(req.MsgData.MsgDataList, v)
// // 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)
//}
//return &pbRelay.OnlineBatchPushOneMsgResp{
// SinglePushResult: singleUserResult,
//}, nil
return nil, nil
}
func (r *RPCServer) encodeWsData(wsData *sdk_ws.MsgData, operationID string) (bytes.Buffer, error) {
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)
SetTokenKicked(v, int(req.PlatformID), req.OperationID)
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)
ws.sendKickMsg(conn)
conn.Close()
for _, conn := range conns {
ws.sendKickMsg(conn, req.OperationID)
}
}
}
return &pbRelay.KickUserOfflineResp{}, nil
+90 -73
View File
@@ -45,15 +45,13 @@ type WServer struct {
wsAddr string
wsMaxConnNum int
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) {
ws.wsAddr = ":" + utils.IntToString(wsPort)
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{
HandshakeTimeout: time.Duration(config.Config.LongConnSvr.WebsocketTimeOut) * time.Second,
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)
return
} 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++
ws.addUserConn(query["sendID"][0], utils.StringToInt(query["platformID"][0]), newConn, query["token"][0], newConn.connID, operationID)
go ws.readMsg(newConn)
@@ -106,6 +104,12 @@ func (ws *WServer) readMsg(conn *UserConn) {
ws.delUserConn(conn)
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))))
if conn.IsCompress {
buff := bytes.NewBuffer(msg)
@@ -189,6 +193,7 @@ func (ws *WServer) MultiTerminalLoginCheckerWithLock(uid string, platformID int,
defer rwLock.Unlock()
log.NewInfo(operationID, utils.GetSelfFuncName(), " rpc args: ", uid, platformID, token)
switch config.Config.MultiLoginPolicy {
case constant.DefalutNotKick:
case constant.PCAndOther:
if constant.PlatformNameToClass(constant.PlatformIDToName(platformID)) == constant.TerminalPC {
return
@@ -196,8 +201,11 @@ func (ws *WServer) MultiTerminalLoginCheckerWithLock(uid string, platformID int,
fallthrough
case constant.AllLoginButSameTermKick:
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")
for _, conn := range oldConns {
ws.sendKickMsg(conn, operationID)
}
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
if err != nil && err != go_redis.Nil {
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)
return
}
err = oldConn.Close()
//delete(oldConnMap, platformID)
delete(oldConnMap, platformID)
ws.wsUserToConn[uid] = oldConnMap
if len(oldConnMap) == 0 {
delete(ws.wsUserToConn, uid)
}
delete(ws.wsConnToUser, oldConn)
if err != nil {
log.NewError(operationID, "conn close err", err.Error(), uid, platformID)
}
} else {
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) {
switch config.Config.MultiLoginPolicy {
case constant.DefalutNotKick:
case constant.PCAndOther:
if constant.PlatformNameToClass(constant.PlatformIDToName(platformID)) == constant.TerminalPC {
return
@@ -251,9 +256,11 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn
fallthrough
case constant.AllLoginButSameTermKick:
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")
ws.sendKickMsg(oldConn)
for _, conn := range oldConns {
ws.sendKickMsg(conn, operationID)
}
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
if err != nil && err != go_redis.Nil {
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)
return
}
err = oldConn.Close()
delete(oldConnMap, platformID)
ws.wsUserToConn[uid] = oldConnMap
if len(oldConnMap) == 0 {
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)
if callbackResp.ErrCode != 0 {
log.NewError(operationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
@@ -302,11 +304,12 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn
case constant.WebAndOther:
}
}
func (ws *WServer) sendKickMsg(oldConn *UserConn) {
func (ws *WServer) sendKickMsg(oldConn *UserConn, operationID string) {
mReply := Resp{
ReqIdentifier: constant.WSKickOnlineMsg,
ErrCode: constant.ErrTokenInvalid.ErrCode,
ErrMsg: constant.ErrTokenInvalid.ErrMsg,
OperationID: operationID,
}
var b bytes.Buffer
enc := gob.NewEncoder(&b)
@@ -319,6 +322,11 @@ func (ws *WServer) sendKickMsg(oldConn *UserConn) {
if err != nil {
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) {
@@ -332,23 +340,24 @@ func (ws *WServer) addUserConn(uid string, platformID int, conn *UserConn, token
go ws.MultiTerminalLoginRemoteChecker(uid, int32(platformID), token, operationID)
ws.MultiTerminalLoginChecker(uid, platformID, conn, token, operationID)
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
log.Debug(operationID, "user not first come in, add conn ", uid, platformID, conn, oldConnMap)
} else {
i := make(map[int]*UserConn)
i[platformID] = conn
i := make(map[int][]*UserConn)
var conns []*UserConn
conns = append(conns, conn)
i[platformID] = conns
ws.wsUserToConn[uid] = i
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
for _, v := range ws.wsUserToConn {
count = count + len(v)
@@ -361,32 +370,40 @@ func (ws *WServer) delUserConn(conn *UserConn) {
rwLock.Lock()
defer rwLock.Unlock()
operationID := utils.OperationIDGenerator()
var uid string
var platform int
if oldStringMap, okg := ws.wsConnToUser[conn]; okg {
for k, v := range oldStringMap {
platform = k
uid = v
}
if oldConnMap, ok := ws.wsUserToConn[uid]; ok {
delete(oldConnMap, platform)
ws.wsUserToConn[uid] = oldConnMap
if len(oldConnMap) == 0 {
delete(ws.wsUserToConn, uid)
platform := int(conn.PlatformID)
if oldConnMap, ok := ws.wsUserToConn[conn.userID]; ok { // only recycle self conn
if oldconns, okMap := oldConnMap[platform]; okMap {
var a []*UserConn
for _, client := range oldconns {
if client != conn {
a = append(a, client)
}
}
count := 0
for _, v := range ws.wsUserToConn {
count = count + len(v)
if len(a) != 0 {
oldConnMap[platform] = a
} else {
delete(oldConnMap, platform)
}
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)
} 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)
ws.wsUserToConn[conn.userID] = oldConnMap
if len(oldConnMap) == 0 {
delete(ws.wsUserToConn, conn.userID)
}
count := 0
for _, v := range ws.wsUserToConn {
count = count + len(v)
}
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)
}
err := conn.Close()
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 == "" {
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()
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()
defer rwLock.RUnlock()
if connMap, ok := ws.wsUserToConn[uid]; ok {
newConnMap := make(map[int]*UserConn)
newConnMap := make(map[int][]*UserConn)
for k, v := range connMap {
newConnMap[k] = v
}
@@ -422,19 +439,19 @@ func (ws *WServer) getUserAllCons(uid string) map[int]*UserConn {
return nil
}
//func (ws *WServer) getUserUid(conn *UserConn) (uid string, platform int) {
// rwLock.RLock()
// defer rwLock.RUnlock()
// func (ws *WServer) getUserUid(conn *UserConn) (uid string, platform int) {
// rwLock.RLock()
// defer rwLock.RUnlock()
//
// if stringMap, ok := ws.wsConnToUser[conn]; ok {
// for k, v := range stringMap {
// platform = k
// uid = v
// if stringMap, ok := ws.wsConnToUser[conn]; ok {
// for k, v := range stringMap {
// platform = k
// uid = v
// }
// 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) {
status := http.StatusUnauthorized
query := r.URL.Query()
+62
View File
@@ -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")
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 {
// first time to modify
var reactionExtensionList = make(map[string]db.KeyValue)
@@ -83,11 +120,12 @@ func (mmc *ModifyMsgConsumerHandler) ModifyMsg(cMsg *sarama.ConsumerMessage, msg
LatestUpdateTime: v.LatestUpdateTime,
}
}
// modify old msg
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())
continue
}
} else {
var reactionExtensionList = make(map[string]*server_api_params.KeyValue)
for _, v := range notification.SuccessReactionExtensionList {
@@ -111,6 +111,10 @@ func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) {
singleMsgSuccessCountMutex.Lock()
singleMsgSuccessCount += uint64(len(storageMsgList))
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)
for _, v := range storageMsgList {
+38 -30
View File
@@ -111,24 +111,41 @@ type Android struct {
type Notification struct {
Title string `json:"title"`
Body string `json:"body"`
ChannelID string `json:"channelID"`
ChannelName string `json:"ChannelName"`
ChannelID string `json:"channel_id"`
ChannelName string `json:"channel_name"`
ClickType string `json:"click_type"`
}
type Options struct {
HW struct {
DefaultSound bool `json:"/message/android/notification/default_sound"`
ChannelID string `json:"/message/android/notification/channel_id"`
Sound string `json:"/message/android/notification/sound"`
Importance string `json:"/message/android/notification/importance"`
} `json:"HW"`
XM struct {
ChannelID string `json:"/extra.channel_id"`
} `json:"XM"`
VV struct {
Classification int `json:"/classification"`
} `json:"VV"`
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"`
ChannelID string `json:"/message/android/notification/channel_id"`
Sound string `json:"/message/android/notification/sound"`
Importance string `json:"/message/android/notification/importance"`
}
type XM struct {
ChannelID string `json:"/extra.channel_id"`
}
type VV struct {
Classification int `json:"/classification"`
}
type OP struct {
ChannelID string `json:"/channel_id"`
}
type HO struct {
Importance string `json:"/android/notification/importance"`
}
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) {
pushReq.PushChannel = &PushChannel{}
// autoBadge := "+1"
pushReq.PushChannel.Ios = &Ios{}
autoBadge := "+1"
pushReq.PushChannel.Ios = &Ios{AutoBadge: &autoBadge}
notify := "notify"
pushReq.PushChannel.Ios.NotiType = &notify
pushReq.PushChannel.Ios.Aps.Sound = "default"
@@ -280,20 +297,11 @@ func (pushReq *PushReq) setPushChannel(title string, body string) {
ClickType: "startapp",
}
pushReq.PushChannel.Android.Ups.Options = Options{
HW: struct {
DefaultSound bool `json:"/message/android/notification/default_sound"`
ChannelID string `json:"/message/android/notification/channel_id"`
Sound string `json:"/message/android/notification/sound"`
Importance string `json:"/message/android/notification/importance"`
}{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,
},
HW: &HW{Category: config.Config.Push.Getui.Channel.HW.Category, ChannelID: "RingRing4", Sound: "/raw/ring001", Importance: "NORMAL"},
HO: &HO{Importance: "NORMAL"},
XM: &XM{ChannelID: config.Config.Push.Getui.Channel.XM.ChannelID},
OP: &OP{ChannelID: config.Config.Push.Getui.Channel.OPPO.ChannelID},
VV: &VV{Classification: 1},
}
}
+94 -12
View File
@@ -143,14 +143,28 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
if detailContent == "" {
detailContent = title
}
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())
if pushMsg.MsgData.ContentType == constant.SignalingNotification {
go func() {
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)
}
}()
} else {
promePkg.PromeInc(promePkg.MsgOfflinePushSuccessCounter)
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
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++
if isOfflinePush {
var onlineSuccessUserIDList []string
var WebAndPcBackgroundUserIDList []string
onlineSuccessUserIDList = append(onlineSuccessUserIDList, pushMsg.MsgData.SendID)
for _, v := range wsResult {
if v.OnlinePush && v.UserID != pushMsg.MsgData.SendID {
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)
//Use offline push messaging
@@ -229,7 +257,17 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
} else {
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 {
return
}
@@ -266,14 +304,58 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
}
detailContent = title
}
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())
if pushMsg.MsgData.ContentType == constant.SignalingNotification {
go func() {
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
}
}
}
}()
} else {
promePkg.PromeInc(promePkg.MsgOfflinePushSuccessCounter)
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
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
}
}
}
}
}
}
}
+2
View File
@@ -311,6 +311,7 @@ func (s *adminCMSServer) GetActiveGroup(_ context.Context, req *pbAdminCMS.GetAc
return resp, nil
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
toTime = toTime.AddDate(0, 0, 1)
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
if err != nil {
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()
return resp, nil
}
toTime = toTime.AddDate(0, 0, 1)
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
if err != nil {
+19
View File
@@ -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}
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})
case constant.FieldGroupAtType:
@@ -151,6 +166,10 @@ func syncPeerUserConversation(conversation *pbConversation.Conversation, operati
log.NewError(operationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
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))
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "DelConversationFromCache failed", err.Error(), conversation.OwnerUserID, conversation.ConversationID)
+146 -5
View File
@@ -365,6 +365,14 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
var resp pbGroup.InviteUserToGroupResp
joinReq := pbGroup.JoinGroupReq{}
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
groupRequest.UserID = v
groupRequest.GroupID = req.GroupID
@@ -452,8 +460,19 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
}
} else {
okUserIDList = req.InvitedUserIDList
if err := db.DB.AddUserToSuperGroup(req.GroupID, req.InvitedUserIDList); err != nil {
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
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)
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
}
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) {
log.NewInfo(req.OperationID, "GetGroupAllMember, args ", req.String())
var resp pbGroup.GetGroupAllMemberResp
@@ -724,6 +772,33 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
resp.ErrMsg = constant.ErrDB.ErrMsg
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 {
@@ -757,7 +832,15 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
var resp pbGroup.GetGroupMembersInfoResp
resp.MemberList = []*open_im_sdk.GroupMemberFullInfo{}
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 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, userID, err.Error())
continue
@@ -862,6 +945,10 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
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
}
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.GroupID = req.GroupID
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) {
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)
if err != nil {
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
}
groupInfo, err := rocksCache.GetGroupInfoFromCache(req.GroupID)
if err != nil {
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{}})
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 != "" {
//get group member user id
@@ -1955,3 +2046,53 @@ func (s *groupServer) DelGroupAndUserCache(operationID, groupID string, userIDLi
}
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
}
+3 -1
View File
@@ -140,13 +140,15 @@ func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp
func callbackMsgModify(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
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
}
commonCallbackReq := copyCallbackCommonReqStruct(msg)
commonCallbackReq.CallbackCommand = constant.CallbackMsgModifyCommand
req := cbApi.CallbackMsgModifyCommandReq{
CommonCallbackReq: commonCallbackReq,
GroupID: msg.MsgData.GroupID,
RecvID: msg.MsgData.RecvID,
}
resp := &cbApi.CallbackMsgModifyCommandResp{CommonCallbackResp: &callbackResp}
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
+5 -5
View File
@@ -5,8 +5,8 @@ import (
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
commonPb "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/proto/msg"
commonPb "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"time"
@@ -39,18 +39,18 @@ func (rpc *rpcChat) DelSuperGroupMsg(_ context.Context, req *msg.DelSuperGroupMs
resp := &msg.DelSuperGroupMsgResp{}
groupMaxSeq, err := db.DB.GetGroupMaxSeq(req.GroupID)
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.ErrMsg = err.Error()
return resp, nil
}
err = db.DB.SetGroupUserMinSeq(req.GroupID,req.UserID, groupMaxSeq)
err = db.DB.SetGroupUserMinSeq(req.GroupID, req.UserID, groupMaxSeq)
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.ErrMsg = err.Error()
return resp, nil
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}
}
+61 -8
View File
@@ -41,7 +41,7 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.S
}
rResp.MsgFirstModifyTime = callbackResp.MsgFirstModifyTime
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
}
for _, v := range callbackResp.ResultReactionExtensionList {
@@ -187,12 +187,12 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.S
}
if !isExists {
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 {
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 {
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())
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) {
log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc args is:", req.String())
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 {
var oneMessage msg.SingleMessageExtensionResult
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) {
return
func (rpc *rpcChat) AddMessageReactionExtensions(ctx context.Context, req *msg.AddMessageReactionExtensionsReq) (resp *msg.AddMessageReactionExtensionsResp, err error) {
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) {
@@ -294,7 +347,7 @@ func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *ms
//if ExternalExtension
if req.IsExternalExtensions {
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
}
@@ -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())
return &rResp, nil
}
+38 -11
View File
@@ -13,11 +13,12 @@ import (
"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) {
var m base_info.ReactionMessageModifierNotification
m.SourceID = req.SourceID
m.OpUserID = req.OpUserID
m.Operation = constant.SetMessageExtensions
m.SessionType = req.SessionType
keyMap := make(map[string]*open_im_sdk.KeyValue)
for _, valueResp := range resp.Result {
@@ -34,9 +35,34 @@ func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID strin
m.IsReact = resp.IsReact
m.IsExternalExtensions = req.IsExternalExtensions
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) {
var m base_info.ReactionMessageDeleteNotification
m.SourceID = req.SourceID
@@ -56,9 +82,9 @@ func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string
m.ClientMsgID = req.ClientMsgID
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)
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
@@ -72,12 +98,13 @@ func messageReactionSender(operationID, sendID string, sourceID string, sessionT
pbData := msg.SendMsgReq{
OperationID: operationID,
MsgData: &open_im_sdk.MsgData{
SendID: sendID,
ClientMsgID: utils.GetMsgID(sendID),
SessionType: sessionType,
MsgFrom: constant.SysMsgType,
ContentType: contentType,
Content: []byte(content),
SendID: sendID,
SenderPlatformID: senderPlatformID,
ClientMsgID: utils.GetMsgID(sendID),
SessionType: sessionType,
MsgFrom: constant.SysMsgType,
ContentType: contentType,
Content: []byte(content),
// ForceList: params.ForceList,
CreateTime: utils.GetCurrentTimestampByMill(),
Options: options,
+44
View File
@@ -58,3 +58,47 @@ func callbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReacti
}
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
}
+10 -1
View File
@@ -245,12 +245,15 @@ func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberL
// notification := ""
// introduction := ""
// 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{}}
if err := setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil {
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
return
}
GroupInfoChangedTips.Group.NeedVerification = 0
GroupInfoChangedTips.Group.LookMemberInfo = 0
GroupInfoChangedTips.Group.ApplyMemberFriend = 0
GroupInfoChangedTips.Group.GroupName = groupName
GroupInfoChangedTips.Group.Notification = notification
GroupInfoChangedTips.Group.Introduction = introduction
@@ -258,6 +261,12 @@ func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName,
if needVerification != nil {
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 {
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
+3 -3
View File
@@ -85,7 +85,7 @@ func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.Pull
} else {
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 {
promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList))
log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err1.Error())
@@ -115,12 +115,12 @@ func (s MsgFormats) Len() int {
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 {
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) {
s[i], s[j] = s[j], s[i]
}
+1 -1
View File
@@ -21,7 +21,7 @@ func (rpc *rpcChat) GetSuperGroupMsg(context context.Context, req *msg.GetSuperG
} else {
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 {
promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList))
log.Error(req.OperationID, "GetSuperGroupMsg data error", req.String(), err.Error())
+3 -8
View File
@@ -145,14 +145,9 @@ func (rpc *rpcChat) runCh() {
select {
case msg := <-rpc.delMsgCh:
log.NewInfo(msg.OperationID, utils.GetSelfFuncName(), "delmsgch recv new: ", msg)
db.DB.DelMsgFromCache(msg.UserID, msg.SeqList, msg.OperationID)
unexistSeqList, err := db.DB.DelMsgBySeqList(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)
if len(msg.SeqList) > 0 {
db.DB.DelMsgFromCache(msg.UserID, msg.SeqList, msg.OperationID)
DeleteMessageNotification(msg.OpUserID, msg.UserID, msg.SeqList, msg.OperationID)
}
}
}
+24 -22
View File
@@ -25,11 +25,12 @@ import (
"time"
promePkg "Open_IM/pkg/common/prometheus"
go_redis "github.com/go-redis/redis/v8"
"github.com/golang/protobuf/proto"
)
//When the number of group members is greater than this valueOnline users will be sent firstGuaranteed service availability
// When the number of group members is greater than this valueOnline users will be sent firstGuaranteed service availability
const GroupMemberNum = 500
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) {
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
}
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())
flag, errCode, errMsg := isMessageHasReadEnabled(pb)
if !flag {
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
return returnMsg(&replay, pb, errCode, errMsg, "", 0, "")
}
t1 := time.Now()
rpc.encapsulateMsgData(pb.MsgData)
@@ -366,7 +367,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
callbackResp.ErrCode = 201
}
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 {
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)
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()
flag, errCode, errMsg, _ = rpc.messageVerification(pb)
log.Debug(pb.OperationID, "messageVerification ", flag, " cost time: ", time.Since(t1))
if !flag {
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
return returnMsg(&replay, pb, errCode, errMsg, "", 0, "")
}
t1 = time.Now()
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 {
log.NewError(msgToMQSingle.OperationID, "kafka send msg err :RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String(), err1.Error())
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
@@ -414,7 +415,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
if err2 != nil {
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String())
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
@@ -425,7 +426,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSingleMsg resp: ", callbackResp)
}
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:
// callback
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)
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
if flag, errCode, errMsg, memberUserIDList = rpc.messageVerification(pb); !flag {
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))
var addUidList []string
@@ -508,7 +509,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
if !sendTag {
log.NewWarn(pb.OperationID, "send tag is ", sendTag)
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 {
if pb.MsgData.ContentType == constant.AtText {
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)
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:
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)
if err1 != nil {
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
err2 := rpc.sendMsgToWriter(&msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus)
if err2 != nil {
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)
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:
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgRecvSuccessCounter)
// callback
@@ -608,11 +609,11 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
}
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter)
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 {
promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter)
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
return returnMsg(&replay, pb, errCode, errMsg, "", 0, "")
}
msgToMQSingle.MsgData = pb.MsgData
log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle)
@@ -620,7 +621,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
if err1 != nil {
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String())
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
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)
}
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:
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()))
}
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.ErrMsg = errMsg
replay.ServerMsgID = serverMsgID
replay.ClientMsgID = pb.MsgData.ClientMsgID
replay.SendTime = sendTime
replay.Ex = ex
return replay, nil
}
@@ -18,6 +18,7 @@ func SuperGroupNotification(operationID, sendID, recvID string) {
SessionType: constant.SingleChatType,
OperationID: operationID,
}
log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content))
Notification(n)
}
+50 -1
View File
@@ -163,6 +163,22 @@ func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.Batc
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)
if err != nil {
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 {
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)
if err != nil {
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}
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
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
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":
conversation.GroupID = stringList[1]
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)
@@ -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}
return resp, nil
}
if isUpdate {
err = rocksCache.DelConversationFromCache(conversation.OwnerUserID, conversation.ConversationID)
} else {
+10 -1
View File
@@ -29,6 +29,7 @@ type GetGroupMembersInfoReq struct {
GroupID string `json:"groupID" binding:"required"`
MemberList []string `json:"memberList" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
NoCache bool `json:"noCache"`
}
type GetGroupMembersInfoResp struct {
CommResp
@@ -46,7 +47,15 @@ type InviteUserToGroupResp struct {
CommResp
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 {
OperationID string `json:"operationID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"`
+11 -7
View File
@@ -64,6 +64,7 @@ type ModifyMessageReactionExtensionsReq struct {
IsReact bool `json:"isReact"`
IsExternalExtensions bool `json:"isExternalExtensions"`
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
Seq uint32 `json:"seq"`
}
type ModifyMessageReactionExtensionsResp struct {
@@ -78,7 +79,9 @@ type ModifyMessageReactionExtensionsResp struct {
type OperateMessageListReactionExtensionsReq struct {
OperationID string `json:"operationID" 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"`
}
@@ -90,10 +93,13 @@ type OperateMessageListReactionExtensionsResp struct {
} `json:"data"`
}
type SetMessageReactionExtensionsCallbackReq ModifyMessageReactionExtensionsReq
type SetMessageReactionExtensionsReq ModifyMessageReactionExtensionsReq
type SetMessageReactionExtensionsCallbackResp ModifyMessageReactionExtensionsResp
type SetMessageReactionExtensionsResp ModifyMessageReactionExtensionsResp
type AddMessageReactionExtensionsReq ModifyMessageReactionExtensionsReq
type AddMessageReactionExtensionsResp ModifyMessageReactionExtensionsResp
type GetMessageListReactionExtensionsReq OperateMessageListReactionExtensionsReq
type GetMessageListReactionExtensionsResp struct {
@@ -101,10 +107,6 @@ type GetMessageListReactionExtensionsResp struct {
Data []*msg.SingleMessageExtensionResult `json:"data"`
}
type AddMessageReactionExtensionsReq ModifyMessageReactionExtensionsReq
type AddMessageReactionExtensionsResp ModifyMessageReactionExtensionsResp
type DeleteMessageReactionExtensionsReq struct {
OperationID string `json:"operationID" binding:"required"`
SourceID string `json:"sourceID" binding:"required"`
@@ -121,6 +123,7 @@ type DeleteMessageReactionExtensionsResp struct {
}
type ReactionMessageModifierNotification struct {
Operation int `json:"operation" binding:"required"`
SourceID string `json:"sourceID" binding:"required"`
OpUserID string `json:"opUserID" binding:"required"`
SessionType int32 `json:"sessionType" binding:"required"`
@@ -129,6 +132,7 @@ type ReactionMessageModifierNotification struct {
IsReact bool `json:"isReact"`
IsExternalExtensions bool `json:"isExternalExtensions"`
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
Seq uint32 `json:"seq"`
}
type ReactionMessageDeleteNotification struct {
+42
View File
@@ -41,8 +41,18 @@ type CallbackAfterSendGroupMsgResp struct {
*CommonCallbackResp
}
type CallbackAfterConsumeGroupMsgReq struct {
CommonCallbackReq
GroupID string `json:"groupID"`
}
type CallbackAfterConsumeGroupMsgResp struct {
*CommonCallbackResp
}
type CallbackMsgModifyCommandReq struct {
CommonCallbackReq
RecvID string `json:"recvID,omitempty"`
GroupID string `json:"groupID,omitempty"`
}
type CallbackMsgModifyCommandResp struct {
@@ -99,3 +109,35 @@ type CallbackDeleteMessageReactionExtResp struct {
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
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"`
}
+12
View File
@@ -210,6 +210,17 @@ type config struct {
MasterSecret string `yaml:"masterSecret"`
ChannelID string `yaml:"channelID"`
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 {
ServiceAccount string `yaml:"serviceAccount"`
@@ -287,6 +298,7 @@ type config struct {
CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"`
CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"`
CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"`
CallbackAfterConsumeGroupMsg callBackConfig `yaml:"callbackAfterConsumeGroupMsg"`
CallbackMsgModify callBackConfig `yaml:"callbackMsgModify"`
CallbackUserOnline callBackConfig `yaml:"callbackUserOnline"`
CallbackUserOffline callBackConfig `yaml:"callbackUserOffline"`
+23 -16
View File
@@ -140,6 +140,7 @@ const (
ExpiredToken = 3
//MultiTerminalLogin
DefalutNotKick = 0
//Full-end login, but the same end is mutually exclusive
AllLoginButSameTermKick = 1
//Only one of the endpoints can log in
@@ -205,23 +206,29 @@ const (
VerificationCodeForResetSuffix = "_forReset"
//callbackCommand
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
CallbackMsgModifyCommand = "callbackMsgModifyCommand"
CallbackUserOnlineCommand = "callbackUserOnlineCommand"
CallbackUserOfflineCommand = "callbackUserOfflineCommand"
CallbackUserKickOffCommand = "callbackUserKickOffCommand"
CallbackOfflinePushCommand = "callbackOfflinePushCommand"
CallbackOnlinePushCommand = "callbackOnlinePushCommand"
CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand"
CallbackBeforeAddFriendCommand = "callbackBeforeAddFriendCommand"
CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroupCommand"
CallbackBeforeMemberJoinGroupCommand = "callbackBeforeMemberJoinGroupCommand"
CallbackBeforeSetGroupMemberInfoCommand = "CallbackBeforeSetGroupMemberInfoCommand"
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
CallbackAfterConsumeGroupMsgCommand = "callbackAfterConsumeGroupMsgCommand"
CallbackMsgModifyCommand = "callbackMsgModifyCommand"
CallbackUserOnlineCommand = "callbackUserOnlineCommand"
CallbackUserOfflineCommand = "callbackUserOfflineCommand"
CallbackUserKickOffCommand = "callbackUserKickOffCommand"
CallbackOfflinePushCommand = "callbackOfflinePushCommand"
CallbackOnlinePushCommand = "callbackOnlinePushCommand"
CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand"
CallbackBeforeAddFriendCommand = "callbackBeforeAddFriendCommand"
CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroupCommand"
CallbackBeforeMemberJoinGroupCommand = "callbackBeforeMemberJoinGroupCommand"
CallbackBeforeSetGroupMemberInfoCommand = "CallbackBeforeSetGroupMemberInfoCommand"
CallbackBeforeSetMessageReactionExtensionCommand = "callbackBeforeSetMessageReactionExtensionCommand"
CallbackBeforeDeleteMessageReactionExtensionsCommand = "callbackBeforeDeleteMessageReactionExtensionsCommand"
CallbackGetMessageListReactionExtensionsCommand = "callbackGetMessageListReactionExtensionsCommand"
CallbackAddMessageListReactionExtensionsCommand = "callbackAddMessageListReactionExtensionsCommand"
SetMessageExtensions = 1
AddMessageExtensions = 2
//callback actionCode
ActionAllow = 0
@@ -354,4 +361,4 @@ const StatisticsTimeInterval = 60
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,
AdminPlatformStr: AdminPlatformID,
}
var Platform2class = map[string]string{
var PlatformName2class = map[string]string{
IOSPlatformStr: TerminalMobile,
AndroidPlatformStr: TerminalMobile,
MiniWebPlatformStr: WebPlatformStr,
@@ -66,6 +66,15 @@ var Platform2class = map[string]string{
OSXPlatformStr: 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 {
return PlatformID2Name[num]
@@ -74,5 +83,8 @@ func PlatformNameToID(name string) int {
return PlatformName2ID[name]
}
func PlatformNameToClass(name string) string {
return Platform2class[name]
return PlatformName2class[name]
}
func PlatformIDToClass(num int) string {
return PlatformID2class[num]
}
+21 -1
View File
@@ -40,6 +40,9 @@ const (
sendMsgFailedFlag = "SEND_MSG_FAILED_FLAG:"
userBadgeUnreadCountSum = "USER_BADGE_UNREAD_COUNT_SUM:"
exTypeKeyLocker = "EX_LOCK:"
//temp
superGroupUserNotRecvOfflineMsgOptTemp = "SG_RECV_MSG_OPT_TEMP:"
)
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()
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 {
key := conversationReceiveMessageOpt + userID
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
}
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())
continue
}
+4
View File
@@ -112,6 +112,10 @@ func init() {
if err := createMongoIndex(mongoClient, cTag, true, "tag_id"); err != nil {
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
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+81 -81
View File
@@ -20,17 +20,16 @@ type Invitation struct {
Status int32 `gorm:"column:status"`
}
//
//message FriendInfo{
//string OwnerUserID = 1;
//string Remark = 2;
//int64 CreateTime = 3;
//UserInfo FriendUser = 4;
//int32 AddSource = 5;
//string OperatorUserID = 6;
//string Ex = 7;
//}
//open_im_sdk.FriendInfo(FriendUser) != imdb.Friend(FriendUserID)
// message FriendInfo{
// string OwnerUserID = 1;
// string Remark = 2;
// int64 CreateTime = 3;
// UserInfo FriendUser = 4;
// int32 AddSource = 5;
// string OperatorUserID = 6;
// string Ex = 7;
// }
// open_im_sdk.FriendInfo(FriendUser) != imdb.Friend(FriendUserID)
type Friend struct {
OwnerUserID string `gorm:"column:owner_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"`
}
//message FriendRequest{
//string FromUserID = 1;
//string ToUserID = 2;
//int32 HandleResult = 3;
//string ReqMsg = 4;
//int64 CreateTime = 5;
//string HandlerUserID = 6;
//string HandleMsg = 7;
//int64 HandleTime = 8;
//string Ex = 9;
//}
//open_im_sdk.FriendRequest(nickname, farce url ...) != imdb.FriendRequest
// message FriendRequest{
// string FromUserID = 1;
// string ToUserID = 2;
// int32 HandleResult = 3;
// string ReqMsg = 4;
// int64 CreateTime = 5;
// string HandlerUserID = 6;
// string HandleMsg = 7;
// int64 HandleTime = 8;
// string Ex = 9;
// }
// open_im_sdk.FriendRequest(nickname, farce url ...) != imdb.FriendRequest
type FriendRequest struct {
FromUserID string `gorm:"column:from_user_id;primary_key;size:64"`
ToUserID string `gorm:"column:to_user_id;primary_key;size:64"`
@@ -69,21 +68,22 @@ func (FriendRequest) TableName() string {
return "friend_requests"
}
//message GroupInfo{
// string GroupID = 1;
// string GroupName = 2;
// string Notification = 3;
// string Introduction = 4;
// string FaceUrl = 5;
// string OwnerUserID = 6;
// uint32 MemberCount = 8;
// int64 CreateTime = 7;
// string Ex = 9;
// int32 Status = 10;
// string CreatorUserID = 11;
// int32 GroupType = 12;
//}
// open_im_sdk.GroupInfo (OwnerUserID , MemberCount )> imdb.Group
// message GroupInfo{
// string GroupID = 1;
// string GroupName = 2;
// string Notification = 3;
// string Introduction = 4;
// string FaceUrl = 5;
// string OwnerUserID = 6;
// uint32 MemberCount = 8;
// int64 CreateTime = 7;
// string Ex = 9;
// int32 Status = 10;
// string CreatorUserID = 11;
// int32 GroupType = 12;
// }
//
// open_im_sdk.GroupInfo (OwnerUserID , MemberCount )> imdb.Group
type Group struct {
//`json:"operationID" binding:"required"`
//`protobuf:"bytes,1,opt,name=GroupID" json:"GroupID,omitempty"` `json:"operationID" binding:"required"`
@@ -104,18 +104,18 @@ type Group struct {
NotificationUserID string `gorm:"column:notification_user_id;size:64"`
}
//message GroupMemberFullInfo {
//string GroupID = 1 ;
//string UserID = 2 ;
//int32 roleLevel = 3;
//int64 JoinTime = 4;
//string NickName = 5;
//string FaceUrl = 6;
//int32 JoinSource = 8;
//string OperatorUserID = 9;
//string Ex = 10;
//int32 AppMangerLevel = 7; //if >0
//} open_im_sdk.GroupMemberFullInfo(AppMangerLevel) > imdb.GroupMember
// message GroupMemberFullInfo {
// string GroupID = 1 ;
// string UserID = 2 ;
// int32 roleLevel = 3;
// int64 JoinTime = 4;
// string NickName = 5;
// string FaceUrl = 6;
// int32 JoinSource = 8;
// string OperatorUserID = 9;
// string Ex = 10;
// int32 AppMangerLevel = 7; //if >0
// } open_im_sdk.GroupMemberFullInfo(AppMangerLevel) > imdb.GroupMember
type GroupMember struct {
GroupID string `gorm:"column:group_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"`
}
//message GroupRequest{
//string UserID = 1;
//string GroupID = 2;
//string HandleResult = 3;
//string ReqMsg = 4;
//string HandleMsg = 5;
//int64 ReqTime = 6;
//string HandleUserID = 7;
//int64 HandleTime = 8;
//string Ex = 9;
//}open_im_sdk.GroupRequest == imdb.GroupRequest
// message GroupRequest{
// string UserID = 1;
// string GroupID = 2;
// string HandleResult = 3;
// string ReqMsg = 4;
// string HandleMsg = 5;
// int64 ReqTime = 6;
// string HandleUserID = 7;
// int64 HandleTime = 8;
// string Ex = 9;
// }open_im_sdk.GroupRequest == imdb.GroupRequest
type GroupRequest struct {
UserID string `gorm:"column:user_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"`
}
//string UserID = 1;
//string Nickname = 2;
//string FaceUrl = 3;
//int32 Gender = 4;
//string PhoneNumber = 5;
//string Birth = 6;
//string Email = 7;
//string Ex = 8;
//string CreateIp = 9;
//int64 CreateTime = 10;
//int32 AppMangerLevel = 11;
//open_im_sdk.User == imdb.User
// string UserID = 1;
// string Nickname = 2;
// string FaceUrl = 3;
// int32 Gender = 4;
// string PhoneNumber = 5;
// string Birth = 6;
// string Email = 7;
// string Ex = 8;
// string CreateIp = 9;
// int64 CreateTime = 10;
// int32 AppMangerLevel = 11;
// open_im_sdk.User == imdb.User
type User struct {
UserID string `gorm:"column:user_id;primary_key;size:64"`
Nickname string `gorm:"column:name;size:255"`
@@ -207,14 +207,14 @@ type UserIpLimit struct {
CreateTime time.Time `gorm:"column:create_time"`
}
//message BlackInfo{
//string OwnerUserID = 1;
//int64 CreateTime = 2;
//PublicUserInfo BlackUserInfo = 4;
//int32 AddSource = 5;
//string OperatorUserID = 6;
//string Ex = 7;
//}
// message BlackInfo{
// string OwnerUserID = 1;
// int64 CreateTime = 2;
// PublicUserInfo BlackUserInfo = 4;
// int32 AddSource = 5;
// string OperatorUserID = 6;
// string Ex = 7;
// }
// open_im_sdk.BlackInfo(BlackUserInfo) != imdb.Black (BlockUserID)
type Black struct {
OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"`
+85 -13
View File
@@ -94,7 +94,7 @@ func (d *DataBases) GetMinSeqFromMongo2(uid string) (MinSeq uint32, err error) {
}
// 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)
sortkeys.Uint32s(seqList)
suffixUserID2SubSeqList := func(uid string, seqList []uint32) map[string][]uint32 {
@@ -123,11 +123,11 @@ func (d *DataBases) DelMsgBySeqList(userID string, seqList []uint32, operationID
return
}
lock.Lock()
totalUnexistSeqList = append(totalUnexistSeqList, unexistSeqList...)
totalUnExistSeqList = append(totalUnExistSeqList, unexistSeqList...)
lock.Unlock()
}(k, v, operationID)
}
return totalUnexistSeqList, err
return totalUnExistSeqList, err
}
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, "")
}
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, "")
}
}
@@ -161,7 +161,7 @@ func (d *DataBases) DelMsgLogic(uid string, seqList []uint32, operationID string
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)
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
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())
return utils.Wrap(err, "")
}
updateResult, err := c.UpdateOne(
ctx, bson.M{"uid": uid},
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
}
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 {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
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) {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
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})
var msgs []UserChat
//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) {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
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})
var userChats []UserChat
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) {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
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})
var userChats []UserChat
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
}
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
indexes = make(map[uint32]int)
singleCount := 0
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
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)
if err = proto.Unmarshal(sChat.Msg[i].Msg, msg); err != nil {
log.NewError(operationID, "Unmarshal err", seqUid, value, groupID, seqList, err.Error())
return nil, err
return nil, nil, err
}
if isContainInt32(msg.Seq, value) {
seqMsg = append(seqMsg, msg)
indexes[msg.Seq] = i
hasSeqList = append(hasSeqList, msg.Seq)
singleCount++
if singleCount == len(value) {
@@ -488,9 +531,8 @@ func (d *DataBases) GetSuperGroupMsgBySeqListMongo(groupID string, seqList []uin
diff = utils.Difference(hasSeqList, seqList)
exceptionMSg := genExceptionSuperGroupMessageBySeqList(diff, groupID)
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) {
@@ -1191,6 +1233,36 @@ func (d *DataBases) AddUserToSuperGroup(groupID string, userIDList []string) err
_ = session.CommitTransaction(ctx)
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 {
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