mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-26 03:26:57 +08:00
Merge remote-tracking branch 'origin/v2.3.0release' into main
# Conflicts: # config/config.yaml
This commit is contained in:
commit
dd8e42ef71
@ -155,13 +155,6 @@ const docTemplate = `{
|
||||
"summary": "用户注册",
|
||||
"operationId": "UserRegister",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "im token",
|
||||
"name": "token",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "secret为openIM密钥, 详细见服务端config.yaml secret字段 \u003cbr\u003e platform为平台ID \u003cbr\u003e ex为拓展字段 \u003cbr\u003e gender为性别, 0为女, 1为男",
|
||||
"name": "req",
|
||||
@ -209,13 +202,6 @@ const docTemplate = `{
|
||||
"summary": "用户登录",
|
||||
"operationId": "UserToken",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "im token",
|
||||
"name": "token",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "secret为openIM密钥, 详细见服务端config.yaml secret字段 \u003cbr\u003e platform为平台ID",
|
||||
"name": "req",
|
||||
@ -4596,7 +4582,6 @@ const docTemplate = `{
|
||||
"Open_IM_internal_api_manage.OANotificationElem": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"notificationFaceURL",
|
||||
"notificationName",
|
||||
"notificationType",
|
||||
"text"
|
||||
@ -5946,13 +5931,21 @@ const docTemplate = `{
|
||||
"base_info.GetGroupAllMemberReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"count",
|
||||
"groupID",
|
||||
"offset",
|
||||
"operationID"
|
||||
],
|
||||
"properties": {
|
||||
"count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"offset": {
|
||||
"type": "integer"
|
||||
},
|
||||
"operationID": {
|
||||
"type": "string"
|
||||
}
|
||||
@ -6521,7 +6514,11 @@ const docTemplate = `{
|
||||
],
|
||||
"properties": {
|
||||
"roleLevel": {
|
||||
"type": "integer"
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
1,
|
||||
3
|
||||
]
|
||||
},
|
||||
"userID": {
|
||||
"type": "string"
|
||||
@ -6652,6 +6649,12 @@ const docTemplate = `{
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
"operationID": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -6751,6 +6754,9 @@ const docTemplate = `{
|
||||
"sessionType"
|
||||
],
|
||||
"properties": {
|
||||
"businessOperationID": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -6760,6 +6766,9 @@ const docTemplate = `{
|
||||
"isOnlineOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"notOfflinePush": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"offlinePushInfo": {
|
||||
"$ref": "#/definitions/server_api_params.OfflinePushInfo"
|
||||
},
|
||||
@ -6798,6 +6807,9 @@ const docTemplate = `{
|
||||
"sessionType"
|
||||
],
|
||||
"properties": {
|
||||
"businessOperationID": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -6807,6 +6819,9 @@ const docTemplate = `{
|
||||
"isOnlineOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"notOfflinePush": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"offlinePushInfo": {
|
||||
"$ref": "#/definitions/server_api_params.OfflinePushInfo"
|
||||
},
|
||||
@ -7063,7 +7078,6 @@ const docTemplate = `{
|
||||
"required": [
|
||||
"fromUserID",
|
||||
"operationID",
|
||||
"remark",
|
||||
"toUserID"
|
||||
],
|
||||
"properties": {
|
||||
@ -7129,6 +7143,9 @@ const docTemplate = `{
|
||||
"operationID"
|
||||
],
|
||||
"properties": {
|
||||
"applyMemberFriend": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ex": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -7144,6 +7161,9 @@ const docTemplate = `{
|
||||
"introduction": {
|
||||
"type": "string"
|
||||
},
|
||||
"lookMemberInfo": {
|
||||
"type": "integer"
|
||||
},
|
||||
"needVerification": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -7747,7 +7767,6 @@ const docTemplate = `{
|
||||
"internal_api_manage.OANotificationElem": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"notificationFaceURL",
|
||||
"notificationName",
|
||||
"notificationType",
|
||||
"text"
|
||||
@ -8231,6 +8250,9 @@ const docTemplate = `{
|
||||
"server_api_params.GroupInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"applyMemberFriend": {
|
||||
"type": "integer"
|
||||
},
|
||||
"createTime": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -8255,6 +8277,9 @@ const docTemplate = `{
|
||||
"introduction": {
|
||||
"type": "string"
|
||||
},
|
||||
"lookMemberInfo": {
|
||||
"type": "integer"
|
||||
},
|
||||
"memberCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -8264,6 +8289,12 @@ const docTemplate = `{
|
||||
"notification": {
|
||||
"type": "string"
|
||||
},
|
||||
"notificationUpdateTime": {
|
||||
"type": "integer"
|
||||
},
|
||||
"notificationUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"ownerUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -8287,6 +8318,9 @@ const docTemplate = `{
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -8331,6 +8365,12 @@ const docTemplate = `{
|
||||
"handleUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
"reqMsg": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -147,13 +147,6 @@
|
||||
"summary": "用户注册",
|
||||
"operationId": "UserRegister",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "im token",
|
||||
"name": "token",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "secret为openIM密钥, 详细见服务端config.yaml secret字段 \u003cbr\u003e platform为平台ID \u003cbr\u003e ex为拓展字段 \u003cbr\u003e gender为性别, 0为女, 1为男",
|
||||
"name": "req",
|
||||
@ -201,13 +194,6 @@
|
||||
"summary": "用户登录",
|
||||
"operationId": "UserToken",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "im token",
|
||||
"name": "token",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "secret为openIM密钥, 详细见服务端config.yaml secret字段 \u003cbr\u003e platform为平台ID",
|
||||
"name": "req",
|
||||
@ -4588,7 +4574,6 @@
|
||||
"Open_IM_internal_api_manage.OANotificationElem": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"notificationFaceURL",
|
||||
"notificationName",
|
||||
"notificationType",
|
||||
"text"
|
||||
@ -5938,13 +5923,21 @@
|
||||
"base_info.GetGroupAllMemberReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"count",
|
||||
"groupID",
|
||||
"offset",
|
||||
"operationID"
|
||||
],
|
||||
"properties": {
|
||||
"count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"offset": {
|
||||
"type": "integer"
|
||||
},
|
||||
"operationID": {
|
||||
"type": "string"
|
||||
}
|
||||
@ -6513,7 +6506,11 @@
|
||||
],
|
||||
"properties": {
|
||||
"roleLevel": {
|
||||
"type": "integer"
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
1,
|
||||
3
|
||||
]
|
||||
},
|
||||
"userID": {
|
||||
"type": "string"
|
||||
@ -6644,6 +6641,12 @@
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
"operationID": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -6743,6 +6746,9 @@
|
||||
"sessionType"
|
||||
],
|
||||
"properties": {
|
||||
"businessOperationID": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -6752,6 +6758,9 @@
|
||||
"isOnlineOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"notOfflinePush": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"offlinePushInfo": {
|
||||
"$ref": "#/definitions/server_api_params.OfflinePushInfo"
|
||||
},
|
||||
@ -6790,6 +6799,9 @@
|
||||
"sessionType"
|
||||
],
|
||||
"properties": {
|
||||
"businessOperationID": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -6799,6 +6811,9 @@
|
||||
"isOnlineOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"notOfflinePush": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"offlinePushInfo": {
|
||||
"$ref": "#/definitions/server_api_params.OfflinePushInfo"
|
||||
},
|
||||
@ -7055,7 +7070,6 @@
|
||||
"required": [
|
||||
"fromUserID",
|
||||
"operationID",
|
||||
"remark",
|
||||
"toUserID"
|
||||
],
|
||||
"properties": {
|
||||
@ -7121,6 +7135,9 @@
|
||||
"operationID"
|
||||
],
|
||||
"properties": {
|
||||
"applyMemberFriend": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ex": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -7136,6 +7153,9 @@
|
||||
"introduction": {
|
||||
"type": "string"
|
||||
},
|
||||
"lookMemberInfo": {
|
||||
"type": "integer"
|
||||
},
|
||||
"needVerification": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -7739,7 +7759,6 @@
|
||||
"internal_api_manage.OANotificationElem": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"notificationFaceURL",
|
||||
"notificationName",
|
||||
"notificationType",
|
||||
"text"
|
||||
@ -8223,6 +8242,9 @@
|
||||
"server_api_params.GroupInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"applyMemberFriend": {
|
||||
"type": "integer"
|
||||
},
|
||||
"createTime": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -8247,6 +8269,9 @@
|
||||
"introduction": {
|
||||
"type": "string"
|
||||
},
|
||||
"lookMemberInfo": {
|
||||
"type": "integer"
|
||||
},
|
||||
"memberCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -8256,6 +8281,12 @@
|
||||
"notification": {
|
||||
"type": "string"
|
||||
},
|
||||
"notificationUpdateTime": {
|
||||
"type": "integer"
|
||||
},
|
||||
"notificationUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"ownerUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -8279,6 +8310,9 @@
|
||||
"groupID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -8323,6 +8357,12 @@
|
||||
"handleUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviterUserID": {
|
||||
"type": "string"
|
||||
},
|
||||
"joinSource": {
|
||||
"type": "integer"
|
||||
},
|
||||
"reqMsg": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -38,7 +38,6 @@ definitions:
|
||||
videoElem:
|
||||
$ref: '#/definitions/Open_IM_internal_api_manage.VideoElem'
|
||||
required:
|
||||
- notificationFaceURL
|
||||
- notificationName
|
||||
- notificationType
|
||||
- text
|
||||
@ -910,12 +909,18 @@ definitions:
|
||||
type: object
|
||||
base_info.GetGroupAllMemberReq:
|
||||
properties:
|
||||
count:
|
||||
type: integer
|
||||
groupID:
|
||||
type: string
|
||||
offset:
|
||||
type: integer
|
||||
operationID:
|
||||
type: string
|
||||
required:
|
||||
- count
|
||||
- groupID
|
||||
- offset
|
||||
- operationID
|
||||
type: object
|
||||
base_info.GetGroupAllMemberResp:
|
||||
@ -1285,6 +1290,9 @@ definitions:
|
||||
base_info.GroupAddMemberInfo:
|
||||
properties:
|
||||
roleLevel:
|
||||
enum:
|
||||
- 1
|
||||
- 3
|
||||
type: integer
|
||||
userID:
|
||||
type: string
|
||||
@ -1372,6 +1380,10 @@ definitions:
|
||||
properties:
|
||||
groupID:
|
||||
type: string
|
||||
inviterUserID:
|
||||
type: string
|
||||
joinSource:
|
||||
type: integer
|
||||
operationID:
|
||||
type: string
|
||||
reqMessage:
|
||||
@ -1436,12 +1448,16 @@ definitions:
|
||||
type: object
|
||||
base_info.ManagementBatchSendMsgReq:
|
||||
properties:
|
||||
businessOperationID:
|
||||
type: string
|
||||
contentType:
|
||||
type: integer
|
||||
groupID:
|
||||
type: string
|
||||
isOnlineOnly:
|
||||
type: boolean
|
||||
notOfflinePush:
|
||||
type: boolean
|
||||
offlinePushInfo:
|
||||
$ref: '#/definitions/server_api_params.OfflinePushInfo'
|
||||
operationID:
|
||||
@ -1468,12 +1484,16 @@ definitions:
|
||||
type: object
|
||||
base_info.ManagementSendMsgReq:
|
||||
properties:
|
||||
businessOperationID:
|
||||
type: string
|
||||
contentType:
|
||||
type: integer
|
||||
groupID:
|
||||
type: string
|
||||
isOnlineOnly:
|
||||
type: boolean
|
||||
notOfflinePush:
|
||||
type: boolean
|
||||
offlinePushInfo:
|
||||
$ref: '#/definitions/server_api_params.OfflinePushInfo'
|
||||
operationID:
|
||||
@ -1657,7 +1677,6 @@ definitions:
|
||||
required:
|
||||
- fromUserID
|
||||
- operationID
|
||||
- remark
|
||||
- toUserID
|
||||
type: object
|
||||
base_info.SetFriendRemarkResp:
|
||||
@ -1689,6 +1708,8 @@ definitions:
|
||||
type: object
|
||||
base_info.SetGroupInfoReq:
|
||||
properties:
|
||||
applyMemberFriend:
|
||||
type: integer
|
||||
ex:
|
||||
type: string
|
||||
faceURL:
|
||||
@ -1699,6 +1720,8 @@ definitions:
|
||||
type: string
|
||||
introduction:
|
||||
type: string
|
||||
lookMemberInfo:
|
||||
type: integer
|
||||
needVerification:
|
||||
type: integer
|
||||
notification:
|
||||
@ -2134,7 +2157,6 @@ definitions:
|
||||
videoElem:
|
||||
$ref: '#/definitions/internal_api_manage.VideoElem'
|
||||
required:
|
||||
- notificationFaceURL
|
||||
- notificationName
|
||||
- notificationType
|
||||
- text
|
||||
@ -2428,6 +2450,8 @@ definitions:
|
||||
type: object
|
||||
server_api_params.GroupInfo:
|
||||
properties:
|
||||
applyMemberFriend:
|
||||
type: integer
|
||||
createTime:
|
||||
type: integer
|
||||
creatorUserID:
|
||||
@ -2444,12 +2468,18 @@ definitions:
|
||||
type: integer
|
||||
introduction:
|
||||
type: string
|
||||
lookMemberInfo:
|
||||
type: integer
|
||||
memberCount:
|
||||
type: integer
|
||||
needVerification:
|
||||
type: integer
|
||||
notification:
|
||||
type: string
|
||||
notificationUpdateTime:
|
||||
type: integer
|
||||
notificationUserID:
|
||||
type: string
|
||||
ownerUserID:
|
||||
type: string
|
||||
status:
|
||||
@ -2465,6 +2495,8 @@ definitions:
|
||||
type: string
|
||||
groupID:
|
||||
type: string
|
||||
inviterUserID:
|
||||
type: string
|
||||
joinSource:
|
||||
type: integer
|
||||
joinTime:
|
||||
@ -2494,6 +2526,10 @@ definitions:
|
||||
type: integer
|
||||
handleUserID:
|
||||
type: string
|
||||
inviterUserID:
|
||||
type: string
|
||||
joinSource:
|
||||
type: integer
|
||||
reqMsg:
|
||||
type: string
|
||||
reqTime:
|
||||
@ -2702,11 +2738,6 @@ paths:
|
||||
description: 用户注册
|
||||
operationId: UserRegister
|
||||
parameters:
|
||||
- description: im token
|
||||
in: header
|
||||
name: token
|
||||
required: true
|
||||
type: string
|
||||
- description: secret为openIM密钥, 详细见服务端config.yaml secret字段 <br> platform为平台ID
|
||||
<br> ex为拓展字段 <br> gender为性别, 0为女, 1为男
|
||||
in: body
|
||||
@ -2739,11 +2770,6 @@ paths:
|
||||
description: 获取用户的token
|
||||
operationId: UserToken
|
||||
parameters:
|
||||
- description: im token
|
||||
in: header
|
||||
name: token
|
||||
required: true
|
||||
type: string
|
||||
- description: secret为openIM密钥, 详细见服务端config.yaml secret字段 <br> platform为平台ID
|
||||
in: body
|
||||
name: req
|
||||
|
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
_ "Open_IM/cmd/open_im_api/docs"
|
||||
apiAuth "Open_IM/internal/api/auth"
|
||||
clientInit "Open_IM/internal/api/client_init"
|
||||
"Open_IM/internal/api/conversation"
|
||||
"Open_IM/internal/api/friend"
|
||||
"Open_IM/internal/api/group"
|
||||
@ -43,7 +44,7 @@ func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
f, _ := os.Create("../logs/api.log")
|
||||
gin.DefaultWriter = io.MultiWriter(f)
|
||||
gin.SetMode(gin.DebugMode)
|
||||
// gin.SetMode(gin.DebugMode)
|
||||
r := gin.Default()
|
||||
r.Use(utils.CorsHandler())
|
||||
|
||||
@ -108,6 +109,8 @@ func main() {
|
||||
groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup)
|
||||
groupRouterGroup.POST("/set_group_member_nickname", group.SetGroupMemberNickname)
|
||||
groupRouterGroup.POST("/set_group_member_info", group.SetGroupMemberInfo)
|
||||
groupRouterGroup.POST("/get_group_abstract_info", group.GetGroupAbstractInfo)
|
||||
//groupRouterGroup.POST("/get_group_all_member_list_by_split", group.GetGroupAllMemberListBySplit)
|
||||
}
|
||||
superGroupRouterGroup := r.Group("/super_group")
|
||||
{
|
||||
@ -204,6 +207,12 @@ func main() {
|
||||
|
||||
}
|
||||
|
||||
initGroup := r.Group("/init")
|
||||
{
|
||||
initGroup.POST("/set_client_config", clientInit.SetClientInitConfig)
|
||||
initGroup.POST("/get_client_config", clientInit.GetClientInitConfig)
|
||||
}
|
||||
|
||||
go apiThird.MinioInit()
|
||||
defaultPorts := config.Config.Api.GinPort
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10002 as port")
|
||||
|
23
cmd/open_im_cron_task/Makefile
Normal file
23
cmd/open_im_cron_task/Makefile
Normal file
@ -0,0 +1,23 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_cron_task
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:
|
||||
make build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
11
cmd/open_im_cron_task/main.go
Normal file
11
cmd/open_im_cron_task/main.go
Normal file
@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/cron_task"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("start cronTask")
|
||||
cronTask.StartCronTask()
|
||||
}
|
@ -40,8 +40,22 @@ func main() {
|
||||
demoRouterGroup.POST("/login", register.Login)
|
||||
demoRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||
}
|
||||
cmsRouterGroup := r.Group("/cms_admin")
|
||||
{
|
||||
cmsRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
|
||||
cmsRouterGroup.POST("/query_invitation_code", register.QueryInvitationCode)
|
||||
cmsRouterGroup.POST("/get_invitation_codes", register.GetInvitationCodes)
|
||||
|
||||
cmsRouterGroup.POST("/query_user_ip_limit_login", register.QueryUserIDLimitLogin)
|
||||
cmsRouterGroup.POST("/add_user_ip_limit_login", register.AddUserIPLimitLogin)
|
||||
cmsRouterGroup.POST("/remove_user_ip_limit_login", register.RemoveUserIPLimitLogin)
|
||||
|
||||
cmsRouterGroup.POST("/query_ip_register", register.QueryIPRegister)
|
||||
cmsRouterGroup.POST("/add_ip_limit", register.AddIPLimit)
|
||||
cmsRouterGroup.POST("/remove_ip_Limit", register.RemoveIPLimit)
|
||||
}
|
||||
defaultPorts := config.Config.Demo.Port
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 42233 as port")
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10004 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start demo api server, port: ", *ginPort)
|
||||
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
|
||||
@ -51,6 +65,7 @@ func main() {
|
||||
address = config.Config.CmsApi.ListenIP + ":" + strconv.Itoa(*ginPort)
|
||||
fmt.Println("start demo api server address: ", address)
|
||||
go register.OnboardingProcessRoutine()
|
||||
go register.ImportFriendRoutine()
|
||||
err := r.Run(address)
|
||||
if err != nil {
|
||||
log.Error("", "run failed ", *ginPort, err.Error())
|
||||
|
@ -17,8 +17,8 @@ mysql:
|
||||
dbMysqlDatabaseName: openIM_v2 #默认即可
|
||||
dbTableName: eMsg #默认即可
|
||||
dbMsgTableNum: 1
|
||||
dbMaxOpenConns: 20
|
||||
dbMaxIdleConns: 10
|
||||
dbMaxOpenConns: 200
|
||||
dbMaxIdleConns: 100
|
||||
dbMaxLifeTime: 120
|
||||
|
||||
mongo:
|
||||
@ -32,6 +32,7 @@ mongo:
|
||||
dbPassword: #mongo密码,建议先不设置
|
||||
dbMaxPoolSize: 100
|
||||
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
||||
chatRecordsClearTime: "* * * * *" # 每天凌晨3点清除消息,该配置和linux定时任务一样, 清理操作建议设置在用户活跃少的时候 # 0 3 * * *
|
||||
|
||||
redis:
|
||||
dbAddress: [ 127.0.0.1:16379 ] #redis地址 单机时,填写一个地址即可,使用redis集群时候,填写集群中多个节点地址(主从地址都可以填写,增加容灾能力),默认即可
|
||||
@ -46,9 +47,9 @@ kafka:
|
||||
ws2mschat:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ws2ms_chat" #用于mongo和mysql保存消息
|
||||
ws2mschatoffline:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ws2ms_chat_offline" #原为离线用户消息处理,目前暂时弃用
|
||||
# ws2mschatoffline:
|
||||
# addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
# topic: "ws2ms_chat_offline" #原为离线用户消息处理,目前暂时弃用
|
||||
msgtomongo:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "msg_to_mongo"
|
||||
@ -63,7 +64,6 @@ kafka:
|
||||
|
||||
|
||||
|
||||
|
||||
#---------------Internal service configuration---------------------#
|
||||
|
||||
# The service ip default is empty,
|
||||
@ -72,7 +72,7 @@ kafka:
|
||||
#如果是单机模式,用0.0.0.0或者不填,默认即可
|
||||
serverip: 0.0.0.0
|
||||
|
||||
#作为rpc时,注册到etcd的地址,单机或内网集群调用默认为空即可(会默认注册本机ip),如果需要注册外网ip,需要修改(目的是api/gateway能访问到)
|
||||
#作为rpc时,注册到etcd的地址,单机默认即可,如果是集群部署,需要修改(具体使用内网地址还是外网地址,要依情况而定,目的是api/gateway能访问到)
|
||||
rpcRegisterIP:
|
||||
#默认即可
|
||||
listenIP: 0.0.0.0
|
||||
@ -102,6 +102,9 @@ cmsapi:
|
||||
sdk:
|
||||
openImSdkWsPort: [ 10003 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
|
||||
dataDir: [ ../db/sdk/ ]
|
||||
openImWsAddress: ws://127.0.0.1:10001
|
||||
openImApiAddress: http://127.0.0.1:10002
|
||||
|
||||
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
|
||||
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
|
||||
tencent:
|
||||
@ -120,6 +123,7 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
||||
accessKeyID: user12345
|
||||
secretAccessKey: key12345
|
||||
storageTime: 50 #文件在minio中保存的时间
|
||||
isDistributedMod: false # 是否分布式多硬盘部署 默认docker-compose中为false
|
||||
ali: # ali oss
|
||||
regionID: "oss-cn-beijing"
|
||||
accessKeyID: ""
|
||||
@ -131,14 +135,15 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
||||
stsDurationSeconds: 3600
|
||||
OssRoleArn: "acs:ram::xxx:role/xxx"
|
||||
aws:
|
||||
accessKeyID: AKIASZQEZISVRBN4UEWJ #AssumeRole用户关联的accessKeyID
|
||||
accessKeySecret: eBS3RyCRD8yUa7I7EGPbxjyBlKtdzN5a6tDnY/wZ #AssumeRole用户关联的accessKeySecrect
|
||||
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名称
|
||||
|
||||
dtm:
|
||||
serverURL: 127.0.0.1:10007
|
||||
|
||||
@ -157,6 +162,7 @@ rpcport: #rpc服务端口 默认即可
|
||||
openImOrganizationPort: [ 10220 ]
|
||||
openImConversationPort: [ 10230 ]
|
||||
openImCachePort: [ 10240 ]
|
||||
openImRealTimeCommPort: [ 11300 ]
|
||||
c2c:
|
||||
callbackBeforeSendMsg:
|
||||
switch: false
|
||||
@ -259,7 +265,7 @@ singleMessageHasReadReceiptEnable: true
|
||||
tokenpolicy:
|
||||
accessSecret: "open_im_server" #token生成相关,默认即可
|
||||
# Token effective time day as a unit
|
||||
accessExpire: 3650 #token过期时间(天) 默认即可
|
||||
accessExpire: 90 #token过期时间(天) 默认即可
|
||||
messageverify:
|
||||
friendVerify: false
|
||||
|
||||
@ -306,6 +312,9 @@ callback:
|
||||
callbackUserOffline:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackUserKickOff:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackOfflinePush:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
@ -728,6 +737,7 @@ demo:
|
||||
verificationCodeTemplateCode: 2902877
|
||||
enable: true
|
||||
superCode: 666666 #超级验证码,建议修改掉,收不到短信验证码时可以用此替代
|
||||
needInvitationCode: false
|
||||
# second
|
||||
codeTTL: 60
|
||||
useSuperCode: true
|
||||
@ -739,6 +749,10 @@ demo:
|
||||
smtpPort: 25 #需开放此端口 出口方向
|
||||
testDepartMentID: 001
|
||||
imAPIURL: http://127.0.0.1:10002
|
||||
onboardProcess: false # 是否开启注册流程
|
||||
joinDepartmentIDList: [] # 用户注册进来默认加的部门ID列表 不填就随机
|
||||
joinDepartmentGroups: false # 注册是否加部门群
|
||||
oaNotification: false # 注册是否发送OA通知
|
||||
|
||||
rtc:
|
||||
signalTimeout: 35
|
||||
|
4
go.mod
4
go.mod
@ -39,6 +39,7 @@ require (
|
||||
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/stretchr/testify v1.7.2
|
||||
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe
|
||||
@ -47,6 +48,7 @@ require (
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.428
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.428
|
||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca
|
||||
github.com/xuri/excelize/v2 v2.6.0
|
||||
go.etcd.io/etcd/api/v3 v3.5.4
|
||||
go.etcd.io/etcd/client/v3 v3.5.4
|
||||
go.mongodb.org/mongo-driver v1.8.3
|
||||
@ -54,7 +56,7 @@ require (
|
||||
go.uber.org/multierr v1.7.0 // indirect
|
||||
go.uber.org/zap v1.19.1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
|
||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305
|
||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 // indirect
|
||||
golang.org/x/tools v0.1.11 // indirect
|
||||
|
20
go.sum
20
go.sum
@ -446,6 +446,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
@ -504,8 +506,14 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
|
||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
|
||||
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
|
||||
github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9M9xC1o=
|
||||
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo=
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
@ -571,6 +579,12 @@ github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyh
|
||||
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
|
||||
github.com/xdg/scram v1.0.3/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
|
||||
github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
|
||||
github.com/xuri/efp v0.0.0-20220407160117-ad0f7a785be8 h1:3X7aE0iLKJ5j+tz58BpvIZkXNV7Yq4jC93Z/rbN2Fxk=
|
||||
github.com/xuri/efp v0.0.0-20220407160117-ad0f7a785be8/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
|
||||
github.com/xuri/excelize/v2 v2.6.0 h1:m/aXAzSAqxgt74Nfd+sNzpzVKhTGl7+S9nbG4A57mF4=
|
||||
github.com/xuri/excelize/v2 v2.6.0/go.mod h1:Q1YetlHesXEKwGFfeJn7PfEZz2IvHb6wdOeYjBxVcVs=
|
||||
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 h1:OAmKAfT06//esDdpi/DZ8Qsdt4+M5+ltca05dA5bG2M=
|
||||
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
@ -625,6 +639,7 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220408190544-5352b0902921/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM=
|
||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@ -639,8 +654,8 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb h1:fqpd0EBDzlHRCjiphRR5Zo/RSWWQlWv34418dnEixWk=
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
@ -714,6 +729,7 @@ golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qx
|
||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305 h1:dAgbJ2SP4jD6XYfMNLVj0BF21jo2PjChrtGaAvF5M3I=
|
||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
|
@ -3,6 +3,7 @@ package apiAuth
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
@ -10,10 +11,11 @@ import (
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/fatih/structs"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Summary 用户注册
|
||||
@ -47,9 +49,9 @@ func UserRegister(c *gin.Context) {
|
||||
//copier.Copy(req.UserInfo, ¶ms)
|
||||
req.OperationID = params.OperationID
|
||||
log.NewInfo(req.OperationID, "UserRegister args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -65,11 +67,17 @@ func UserRegister(c *gin.Context) {
|
||||
if reply.CommonResp.ErrCode != 0 {
|
||||
errMsg := req.OperationID + " " + " UserRegister failed " + reply.CommonResp.ErrMsg + req.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
if reply.CommonResp.ErrCode == constant.RegisterLimit {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterLimit, "errMsg": "用户注册被限制"})
|
||||
} else if reply.CommonResp.ErrCode == constant.InvitationError {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
||||
} else {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID, LoginIp: params.CreateIp}
|
||||
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + " client.UserToken failed " + err.Error() + pbDataToken.String()
|
||||
@ -110,11 +118,11 @@ func UserToken(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID, LoginIp: params.LoginIp}
|
||||
log.NewInfo(req.OperationID, "UserToken args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -206,9 +214,9 @@ func ForceLogout(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "ForceLogout args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
75
internal/api/client_init/init_config.go
Normal file
75
internal/api/client_init/init_config.go
Normal file
@ -0,0 +1,75 @@
|
||||
package clientInit
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/utils"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
func SetClientInitConfig(c *gin.Context) {
|
||||
var req api.SetClientInitConfigReq
|
||||
var resp api.SetClientInitConfigResp
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
err, _ := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
|
||||
if err != nil {
|
||||
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
m := make(map[string]interface{})
|
||||
if req.DiscoverPageURL != nil {
|
||||
m["discover_page_url"] = *req.DiscoverPageURL
|
||||
}
|
||||
if len(m) > 0 {
|
||||
err := imdb.SetClientInitConfig(m)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetClientInitConfig(c *gin.Context) {
|
||||
var req api.GetClientInitConfigReq
|
||||
var resp api.GetClientInitConfigResp
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
err, _ := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
|
||||
if err != nil {
|
||||
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
config, err := imdb.GetClientInitConfig()
|
||||
if err != nil {
|
||||
if !gorm.IsRecordNotFoundError(err) {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
resp.Data.DiscoverPageURL = config.DiscoverPageURL
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
@ -26,15 +26,15 @@ func SetConversation(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.Conversation = &pbUser.Conversation{}
|
||||
reqPb.Conversation = &pbConversation.Conversation{}
|
||||
err := utils.CopyStructFields(&reqPb, req)
|
||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
||||
if err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -69,9 +69,9 @@ func ModifyConversationField(c *gin.Context) {
|
||||
if err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -104,9 +104,9 @@ func BatchSetConversations(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -154,9 +154,9 @@ func GetAllConversations(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -204,9 +204,9 @@ func GetConversation(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -254,9 +254,9 @@ func GetConversations(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -292,9 +292,9 @@ func SetRecvMsgOpt(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -48,7 +48,7 @@ func AddBlack(c *gin.Context) {
|
||||
}
|
||||
log.NewInfo(params.OperationID, "AddBlacklist args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.AddBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
@ -93,9 +93,9 @@ func ImportFriend(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "ImportFriend args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -156,9 +156,9 @@ func AddFriend(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -213,9 +213,9 @@ func AddFriendResponse(c *gin.Context) {
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriendResponse args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -268,9 +268,9 @@ func DeleteFriend(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "DeleteFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -322,9 +322,9 @@ func GetBlacklist(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "GetBlacklist args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -383,9 +383,9 @@ func SetFriendRemark(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "SetFriendComment args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -436,9 +436,9 @@ func RemoveBlack(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "RemoveBlacklist args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -490,9 +490,9 @@ func IsFriend(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "IsFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -545,9 +545,9 @@ func GetFriendList(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -601,9 +601,9 @@ func GetFriendApplyList(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -657,9 +657,9 @@ func GetSelfFriendApplyList(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/golang/protobuf/ptypes/wrappers"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@ -56,9 +57,9 @@ func KickGroupMember(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "KickGroupMember args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -119,9 +120,9 @@ func GetGroupMembersInfo(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -163,9 +164,9 @@ func GetGroupMemberList(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "GetGroupMemberList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -220,24 +221,25 @@ func GetGroupAllMemberList(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
maxSizeOption := grpc.MaxCallRecvMsgSize(1024 * 1024 * constant.GroupRPCRecvSize)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.GetGroupAllMember(context.Background(), req)
|
||||
RpcResp, err := client.GetGroupAllMember(context.Background(), req, maxSizeOption)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupAllMember failed ", err.Error(), req.String())
|
||||
log.NewError(req.OperationID, "GetGroupAllMember failed err", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList}
|
||||
memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember api return ", memberListResp)
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember api return ", len(memberListResp.MemberList))
|
||||
c.JSON(http.StatusOK, memberListResp)
|
||||
}
|
||||
|
||||
@ -275,9 +277,9 @@ func GetJoinedGroupList(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "GetJoinedGroupList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -335,9 +337,9 @@ func InviteUserToGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -405,9 +407,9 @@ func CreateGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "CreateGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -461,9 +463,9 @@ func GetRecvGroupApplicationList(c *gin.Context) {
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupApplicationList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -513,9 +515,9 @@ func GetUserReqGroupApplicationList(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -567,9 +569,9 @@ func GetGroupsInfo(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -637,9 +639,9 @@ func ApplicationGroupResponse(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "ApplicationGroupResponse args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -690,9 +692,9 @@ func JoinGroup(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -744,9 +746,9 @@ func QuitGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "QuitGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -798,9 +800,9 @@ func SetGroupInfo(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "SetGroupInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -865,9 +867,9 @@ func TransferGroupOwner(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, "TransferGroupOwner args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -919,9 +921,9 @@ func DismissGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -973,9 +975,9 @@ func MuteGroupMember(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -1027,9 +1029,9 @@ func CancelMuteGroupMember(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -1081,9 +1083,9 @@ func MuteGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -1135,9 +1137,9 @@ func CancelMuteGroup(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -1179,9 +1181,9 @@ func SetGroupMemberNickname(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -1249,10 +1251,10 @@ func SetGroupMemberInfo(c *gin.Context) {
|
||||
if req.RoleLevel != nil {
|
||||
reqPb.RoleLevel = &wrappers.Int32Value{Value: *req.RoleLevel}
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", reqPb.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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -1267,6 +1269,52 @@ func SetGroupMemberInfo(c *gin.Context) {
|
||||
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", resp)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetGroupAbstractInfo(c *gin.Context) {
|
||||
var (
|
||||
req api.GetGroupAbstractInfoReq
|
||||
resp api.GetGroupAbstractInfoResp
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
ok, 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
|
||||
}
|
||||
|
||||
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)
|
||||
respPb, err := client.GetGroupAbstractInfo(context.Background(), &rpc.GetGroupAbstractInfoReq{
|
||||
GroupID: req.GroupID,
|
||||
OpUserID: opUserID,
|
||||
OperationID: req.OperationID,
|
||||
})
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", respPb.String())
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
resp.GroupMemberNumber = respPb.GroupMemberNumber
|
||||
resp.GroupMemberListHash = respPb.GroupMemberListHash
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
|
@ -31,9 +31,9 @@ func GetJoinedSuperGroupList(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
reqPb := rpc.GetJoinedSuperGroupListReq{OperationID: req.OperationID, OpUserID: opUserID, UserID: req.FromUserID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -67,9 +67,9 @@ func GetSuperGroupsInfo(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
reqPb := rpc.GetSuperGroupsInfoReq{OperationID: req.OperationID, OpUserID: opUserID, GroupIDList: req.GroupIDList}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -10,20 +10,21 @@ import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
"Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var validate *validator.Validate
|
||||
@ -50,6 +51,8 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
case constant.Video:
|
||||
fallthrough
|
||||
case constant.File:
|
||||
fallthrough
|
||||
case constant.AdvancedRevoke:
|
||||
newContent = utils.StructToJsonString(params.Content)
|
||||
case constant.Revoke:
|
||||
newContent = params.Content["revokeMsgClientID"].(string)
|
||||
@ -145,6 +148,8 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
data = CustomElem{}
|
||||
case constant.Revoke:
|
||||
data = RevokeElem{}
|
||||
case constant.AdvancedRevoke:
|
||||
data = MessageRevoked{}
|
||||
case constant.OANotification:
|
||||
data = OANotificationElem{}
|
||||
params.SessionType = constant.NotificationChatType
|
||||
@ -189,7 +194,7 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "recvID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
case constant.GroupChatType:
|
||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||
if len(params.GroupID) == 0 {
|
||||
log.NewError(params.OperationID, "groupID is a null string")
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "groupID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
@ -202,9 +207,9 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
pbData := newUserSendMsgReq(¶ms)
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -227,7 +232,7 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: server_api_params.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
||||
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: open_im_sdk.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
||||
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
@ -315,9 +320,9 @@ func ManagementBatchSendMsg(c *gin.Context) {
|
||||
log.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
|
||||
var msgSendFailedFlag bool
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
//resp.Data.FailedIDList = params.RecvIDList
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "rpc server error: etcdConn == nil"})
|
||||
@ -328,7 +333,17 @@ func ManagementBatchSendMsg(c *gin.Context) {
|
||||
ManagementSendMsg: params.ManagementSendMsg,
|
||||
}
|
||||
pbData := newUserSendMsgReq(req)
|
||||
for _, recvID := range params.RecvIDList {
|
||||
var recvList []string
|
||||
if params.IsSendAll {
|
||||
recvList, err = im_mysql_model.SelectAllUserID()
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
}
|
||||
} else {
|
||||
recvList = params.RecvIDList
|
||||
}
|
||||
for _, recvID := range recvList {
|
||||
pbData.MsgData.RecvID = recvID
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., ", pbData.String())
|
||||
|
||||
@ -374,9 +389,9 @@ func CheckMsgIsSendSuccess(c *gin.Context) {
|
||||
log.Error(c.PostForm("operationID"), "json unmarshal err", err.Error(), c.PostForm("content"))
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -473,3 +488,10 @@ type OANotificationElem struct {
|
||||
FileElem FileElem `mapstructure:"fileElem" json:"fileElem"`
|
||||
Ex string `mapstructure:"ex" json:"ex"`
|
||||
}
|
||||
type MessageRevoked struct {
|
||||
RevokerID string `mapstructure:"notificationName" json:"revokerID" validate:"required"`
|
||||
RevokerRole int32 `mapstructure:"notificationName" json:"revokerRole" validate:"required"`
|
||||
ClientMsgID string `mapstructure:"notificationName" json:"clientMsgID" validate:"required"`
|
||||
RevokerNickname string `mapstructure:"notificationName" json:"revokerNickname"`
|
||||
SessionType int32 `mapstructure:"notificationName" json:"sessionType" validate:"required"`
|
||||
}
|
||||
|
@ -17,9 +17,10 @@ import (
|
||||
rpc "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func DeleteUser(c *gin.Context) {
|
||||
@ -42,9 +43,9 @@ func DeleteUser(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(params.OperationID, "DeleteUser args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -97,9 +98,9 @@ func GetAllUsersUid(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(params.OperationID, "GetAllUsersUid args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -152,9 +153,9 @@ func AccountCheck(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(params.OperationID, "AccountCheck args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -198,7 +199,7 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
||||
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
flag := false
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRelayName)
|
||||
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), params.OperationID)
|
||||
for _, v := range grpcCons {
|
||||
client := pbRelay.NewRelayClient(v)
|
||||
reply, err := client.GetUsersOnlineStatus(context.Background(), req)
|
||||
|
@ -54,9 +54,9 @@ func DelMsg(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -79,11 +79,11 @@ func DelSuperGroupMsg(c *gin.Context) {
|
||||
resp api.DelSuperGroupMsgResp
|
||||
)
|
||||
rpcReq := &rpc.DelSuperGroupMsgReq{}
|
||||
utils.CopyStructFields(req, &req)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(rpcReq, &req)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
@ -130,9 +130,9 @@ func DelSuperGroupMsg(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call start..., [data: %s]", pbData.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -203,9 +203,9 @@ func ClearMsg(c *gin.Context) {
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -251,9 +251,9 @@ func SetMsgMinSeq(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -35,9 +35,9 @@ func GetSeq(c *gin.Context) {
|
||||
pbData := sdk_ws.GetMaxAndMinSeqReq{}
|
||||
pbData.UserID = params.SendID
|
||||
pbData.OperationID = params.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := pbData.OperationID + " getcdv3.GetConn == nil"
|
||||
errMsg := pbData.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(pbData.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -51,9 +51,9 @@ func PullMsgBySeqList(c *gin.Context) {
|
||||
pbData.OperationID = params.OperationID
|
||||
pbData.SeqList = params.SeqList
|
||||
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := pbData.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := pbData.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(pbData.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -71,9 +71,9 @@ func SendMsg(c *gin.Context) {
|
||||
pbData := newUserSendMsgReq(token, ¶ms)
|
||||
log.Info(params.OperationID, "", "api SendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -54,9 +54,9 @@ func GetUserTags(c *gin.Context) {
|
||||
|
||||
reqPb.UserID = userID
|
||||
reqPb.OperationID = req.OperationID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -119,9 +119,9 @@ func CreateTag(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -179,9 +179,9 @@ func DeleteTag(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -239,9 +239,9 @@ func SetTag(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -299,9 +299,9 @@ func SendMsg2Tag(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqPb.SendID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -361,9 +361,9 @@ func GetTagSendLogs(c *gin.Context) {
|
||||
PageNumber: req.PageNumber,
|
||||
ShowNumber: req.ShowNumber,
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -428,9 +428,9 @@ func GetUserTagByID(c *gin.Context) {
|
||||
reqPb.UserID = userID
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.TagID = req.TagID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -56,9 +56,9 @@ func CreateOneWorkMoment(c *gin.Context) {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.WorkMoment.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -120,9 +120,9 @@ func DeleteOneWorkMoment(c *gin.Context) {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -183,9 +183,9 @@ func LikeOneWorkMoment(c *gin.Context) {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -245,9 +245,9 @@ func CommentOneWorkMoment(c *gin.Context) {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -305,9 +305,9 @@ func DeleteComment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -366,9 +366,9 @@ func GetWorkMomentByID(c *gin.Context) {
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.OpUserID = userID
|
||||
reqPb.WorkMomentID = req.WorkMomentID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -436,9 +436,9 @@ func GetUserWorkMoments(c *gin.Context) {
|
||||
}
|
||||
reqPb.OpUserID = opUserID
|
||||
reqPb.UserID = req.UserID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -548,9 +548,9 @@ func GetUserFriendWorkMoments(c *gin.Context) {
|
||||
ShowNumber: req.ShowNumber,
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -649,9 +649,9 @@ func SetUserWorkMomentsLevel(c *gin.Context) {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -48,9 +48,9 @@ func CreateDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -103,9 +103,9 @@ func UpdateDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -156,9 +156,9 @@ func GetSubDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -212,9 +212,9 @@ func DeleteDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -266,9 +266,9 @@ func CreateOrganizationUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -319,9 +319,9 @@ func UpdateOrganizationUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -372,9 +372,9 @@ func CreateDepartmentMember(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -425,9 +425,9 @@ func GetUserInDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -479,9 +479,9 @@ func UpdateUserInDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -532,9 +532,9 @@ func DeleteOrganizationUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -584,9 +584,9 @@ func GetDepartmentMember(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -637,9 +637,9 @@ func DeleteUserInDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -1,6 +1,7 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
@ -10,18 +11,10 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
/**
|
||||
* FCM第三方上报Token
|
||||
*/
|
||||
type FcmUpdateTokenReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
Platform int `json:"platform" binding:"required,min=1,max=2"` //only for ios + android
|
||||
FcmToken string `json:"fcmToken"`
|
||||
}
|
||||
|
||||
func FcmUpdateToken(c *gin.Context) {
|
||||
var (
|
||||
req FcmUpdateTokenReq
|
||||
req api.FcmUpdateTokenReq
|
||||
resp api.FcmUpdateTokenResp
|
||||
)
|
||||
if err := c.Bind(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
@ -34,7 +27,9 @@ func FcmUpdateToken(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.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
resp.ErrCode = 500
|
||||
resp.ErrMsg = errMsg
|
||||
c.JSON(http.StatusInternalServerError, resp)
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req, UserId)
|
||||
@ -43,10 +38,12 @@ func FcmUpdateToken(c *gin.Context) {
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "SetFcmToken failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
resp.ErrCode = 500
|
||||
resp.ErrMsg = errMsg
|
||||
c.JSON(http.StatusInternalServerError, resp)
|
||||
return
|
||||
}
|
||||
//逻辑处理完毕
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||
c.JSON(http.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ func MinioInit() {
|
||||
}
|
||||
opts := &minio.Options{
|
||||
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
||||
//Region: config.Config.Credential.Minio.Location,
|
||||
}
|
||||
if minioUrl.Scheme == "http" {
|
||||
opts.Secure = false
|
||||
@ -47,7 +48,9 @@ func MinioInit() {
|
||||
}
|
||||
opt := minio.MakeBucketOptions{
|
||||
Region: config.Config.Credential.Minio.Location,
|
||||
ObjectLocking: false,
|
||||
}
|
||||
if config.Config.Credential.Minio.IsDistributedMod == true {
|
||||
opt.ObjectLocking = true
|
||||
}
|
||||
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
|
||||
if err != nil {
|
||||
@ -78,6 +81,9 @@ func MinioInit() {
|
||||
return
|
||||
}
|
||||
}
|
||||
policy, err := MinioClient.GetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket)
|
||||
log.NewInfo("", utils.GetSelfFuncName(), policy)
|
||||
|
||||
// 自动化桶public的代码
|
||||
policyJsonString := fmt.Sprintf(`{"Version": "2012-10-17","Statement": [{"Action": ["s3:GetObject","s3:PutObject"],
|
||||
"Effect": "Allow","Principal": {"AWS": ["*"]},"Resource": ["arn:aws:s3:::%s/*"],"Sid": ""}]}`, config.Config.Credential.Minio.Bucket)
|
||||
|
@ -15,6 +15,8 @@ import (
|
||||
_ "github.com/minio/minio-go/v7"
|
||||
cr "github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary minio上传文件(web api)
|
||||
@ -161,6 +163,7 @@ func MinioStorageCredential(c *gin.Context) {
|
||||
resp.BucketName = config.Config.Credential.Minio.Bucket
|
||||
resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint
|
||||
resp.StorageTime = config.Config.Credential.Minio.StorageTime
|
||||
resp.IsDistributedMod = config.Config.Credential.Minio.IsDistributedMod
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
@ -175,6 +178,7 @@ func UploadUpdateApp(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var yamlName string
|
||||
if req.Yaml == nil {
|
||||
yamlName = ""
|
||||
@ -217,6 +221,13 @@ func UploadUpdateApp(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func version2Int(version string) (int, error) {
|
||||
versions := strings.Split(version, ".")
|
||||
s := strings.Join(versions, "")
|
||||
versionInt, err := strconv.Atoi(s)
|
||||
return versionInt, err
|
||||
}
|
||||
|
||||
func GetDownloadURL(c *gin.Context) {
|
||||
var (
|
||||
req api.GetDownloadURLReq
|
||||
@ -237,7 +248,13 @@ func GetDownloadURL(c *gin.Context) {
|
||||
}
|
||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), "app: ", app)
|
||||
if app != nil {
|
||||
if app.Version != req.Version && app.Version != "" {
|
||||
appVersion, err := version2Int(app.Version)
|
||||
reqVersion, err := version2Int(req.Version)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), "req version", req.Version, "app version", app.Version)
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "req version:", reqVersion, "app version:", appVersion)
|
||||
if appVersion > reqVersion && app.Version != "" {
|
||||
resp.Data.HasNewVersion = true
|
||||
if app.ForceUpdate == true {
|
||||
resp.Data.ForceUpdate = true
|
||||
|
@ -14,9 +14,10 @@ import (
|
||||
rpc "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetUsersInfoFromCache(c *gin.Context) {
|
||||
@ -38,9 +39,9 @@ func GetUsersInfoFromCache(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -86,9 +87,9 @@ func GetFriendIDListFromCache(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -128,9 +129,9 @@ func GetBlackIDListFromCache(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -181,9 +182,9 @@ func GetUsersInfo(c *gin.Context) {
|
||||
|
||||
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -239,9 +240,9 @@ func UpdateUserInfo(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "UpdateUserInfo args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -290,9 +291,9 @@ func SetGlobalRecvMessageOpt(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "SetGlobalRecvMessageOpt args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -325,8 +326,8 @@ func GetSelfUserInfo(c *gin.Context) {
|
||||
params := api.GetSelfUserInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
errMsg := " BindJSON failed " + err.Error()
|
||||
log.NewError("0", "BindJSON failed ", errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError("0", errMsg)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 1001, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetUserInfoReq{}
|
||||
@ -338,17 +339,17 @@ func GetSelfUserInfo(c *gin.Context) {
|
||||
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})
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 1001, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
req.UserIDList = append(req.UserIDList, req.OpUserID)
|
||||
req.UserIDList = append(req.UserIDList, params.UserID)
|
||||
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -366,11 +367,10 @@ func GetSelfUserInfo(c *gin.Context) {
|
||||
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @Summary 获取用户在线状态
|
||||
@ -415,7 +415,7 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
||||
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
flag := false
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRelayName)
|
||||
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), params.OperationID)
|
||||
for _, v := range grpcCons {
|
||||
log.Debug(params.OperationID, "get node ", *v, v.Target())
|
||||
client := pbRelay.NewRelayClient(v)
|
||||
|
@ -8,15 +8,18 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
|
||||
url2 "net/url"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -63,16 +66,16 @@ func AdminLogin(c *gin.Context) {
|
||||
reqPb pbAdmin.AdminLoginReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewInfo("0", utils.GetSelfFuncName(), err.Error())
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.Secret = req.Secret
|
||||
reqPb.AdminID = req.AdminName
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -87,3 +90,94 @@ func AdminLogin(c *gin.Context) {
|
||||
resp.Token = respPb.Token
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func AddUserRegisterAddFriendIDList(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.AddUserRegisterAddFriendIDListRequest
|
||||
resp apiStruct.AddUserRegisterAddFriendIDListResponse
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
_, err := client.AddUserRegisterAddFriendIDList(context.Background(), &pbAdmin.AddUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func ReduceUserRegisterAddFriendIDList(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.ReduceUserRegisterAddFriendIDListRequest
|
||||
resp apiStruct.ReduceUserRegisterAddFriendIDListResponse
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
_, err := client.ReduceUserRegisterAddFriendIDList(context.Background(), &pbAdmin.ReduceUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList, Operation: req.Operation})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.GetUserRegisterAddFriendIDListRequest
|
||||
resp apiStruct.GetUserRegisterAddFriendIDListResponse
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
respPb, err := client.GetUserRegisterAddFriendIDList(context.Background(), &pbAdmin.GetUserRegisterAddFriendIDListReq{OperationID: req.OperationID, Pagination: &pbCommon.RequestPagination{
|
||||
PageNumber: int32(req.PageNumber),
|
||||
ShowNumber: int32(req.ShowNumber),
|
||||
}})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
resp.Users = respPb.UserInfoList
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
@ -18,11 +18,11 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetGroupById(c *gin.Context) {
|
||||
func GetGroupByID(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupByIdRequest
|
||||
resp cms_api_struct.GetGroupByIdResponse
|
||||
reqPb pbGroup.GetGroupByIdReq
|
||||
req cms_api_struct.GetGroupByIDRequest
|
||||
resp cms_api_struct.GetGroupByIDResponse
|
||||
reqPb pbGroup.GetGroupByIDReq
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||
@ -31,28 +31,25 @@ func GetGroupById(c *gin.Context) {
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
reqPb.GroupID = req.GroupID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.GetGroupById(context.Background(), &reqPb)
|
||||
respPb, err := client.GetGroupByID(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupById failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
resp.GroupName = respPb.CMSGroup.GroupInfo.GroupName
|
||||
resp.GroupID = respPb.CMSGroup.GroupInfo.GroupID
|
||||
resp.CreateTime = (utils.UnixSecondToTime(int64(respPb.CMSGroup.GroupInfo.CreateTime))).String()
|
||||
resp.ProfilePhoto = respPb.CMSGroup.GroupInfo.FaceURL
|
||||
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
|
||||
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
|
||||
resp.IsBanChat = constant.GroupIsBanChat(respPb.CMSGroup.GroupInfo.Status)
|
||||
utils.CopyStructFields(&resp, respPb.CMSGroup.GroupInfo)
|
||||
resp.GroupOwnerID = respPb.CMSGroup.GroupOwnerUserID
|
||||
resp.GroupOwnerName = respPb.CMSGroup.GroupOwnerUserName
|
||||
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
@ -72,9 +69,9 @@ func GetGroups(c *gin.Context) {
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -87,16 +84,11 @@ func GetGroups(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.CMSGroups {
|
||||
resp.Groups = append(resp.Groups, cms_api_struct.GroupResponse{
|
||||
GroupName: v.GroupInfo.GroupName,
|
||||
GroupID: v.GroupInfo.GroupID,
|
||||
GroupMasterName: v.GroupMasterName,
|
||||
GroupMasterId: v.GroupMasterId,
|
||||
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
|
||||
IsBanChat: constant.GroupIsBanChat(v.GroupInfo.Status),
|
||||
IsBanPrivateChat: false,
|
||||
ProfilePhoto: v.GroupInfo.FaceURL,
|
||||
})
|
||||
groupResp := cms_api_struct.GroupResponse{}
|
||||
utils.CopyStructFields(&groupResp, v.GroupInfo)
|
||||
groupResp.GroupOwnerName = v.GroupOwnerUserName
|
||||
groupResp.GroupOwnerID = v.GroupOwnerUserID
|
||||
resp.Groups = append(resp.Groups, groupResp)
|
||||
}
|
||||
resp.GroupNums = int(respPb.GroupNum)
|
||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||
@ -121,9 +113,9 @@ func GetGroupByName(c *gin.Context) {
|
||||
reqPb.GroupName = req.GroupName
|
||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -136,16 +128,11 @@ func GetGroupByName(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.CMSGroups {
|
||||
resp.Groups = append(resp.Groups, cms_api_struct.GroupResponse{
|
||||
GroupName: v.GroupInfo.GroupName,
|
||||
GroupID: v.GroupInfo.GroupID,
|
||||
GroupMasterName: v.GroupMasterName,
|
||||
GroupMasterId: v.GroupMasterId,
|
||||
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
|
||||
IsBanChat: constant.GroupIsBanChat(v.GroupInfo.Status),
|
||||
IsBanPrivateChat: false,
|
||||
ProfilePhoto: v.GroupInfo.FaceURL,
|
||||
})
|
||||
groupResp := cms_api_struct.GroupResponse{}
|
||||
utils.CopyStructFields(&groupResp, v.GroupInfo)
|
||||
groupResp.GroupOwnerName = v.GroupOwnerUserName
|
||||
groupResp.GroupOwnerID = v.GroupOwnerUserID
|
||||
resp.Groups = append(resp.Groups, groupResp)
|
||||
}
|
||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
@ -178,9 +165,9 @@ func CreateGroup(c *gin.Context) {
|
||||
RoleLevel: 1,
|
||||
})
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -195,133 +182,6 @@ func CreateGroup(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func BanGroupChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanGroupChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupBanChat
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BanGroupChat failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
|
||||
}
|
||||
|
||||
func BanPrivateChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupBanPrivateChat
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func OpenGroupChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupOk
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func OpenPrivateChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OpenPrivateChat failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupOk
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func GetGroupMembers(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupMembersRequest
|
||||
@ -339,11 +199,11 @@ func GetGroupMembers(c *gin.Context) {
|
||||
PageNumber: int32(req.PageNumber),
|
||||
ShowNumber: int32(req.ShowNumber),
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.GroupID = req.GroupID
|
||||
reqPb.UserName = req.UserName
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -360,13 +220,10 @@ func GetGroupMembers(c *gin.Context) {
|
||||
ShowNumber: int(respPb.Pagination.ShowNumber),
|
||||
}
|
||||
resp.MemberNums = int(respPb.MemberNums)
|
||||
for _, groupMembers := range respPb.Members {
|
||||
resp.GroupMembers = append(resp.GroupMembers, cms_api_struct.GroupMemberResponse{
|
||||
MemberPosition: int(groupMembers.RoleLevel),
|
||||
MemberNickName: groupMembers.Nickname,
|
||||
MemberId: groupMembers.UserID,
|
||||
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
|
||||
})
|
||||
for _, groupMember := range respPb.Members {
|
||||
memberResp := cms_api_struct.GroupMemberResponse{}
|
||||
utils.CopyStructFields(&memberResp, groupMember)
|
||||
resp.GroupMembers = append(resp.GroupMembers, memberResp)
|
||||
}
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
@ -379,25 +236,25 @@ func AddGroupMembers(c *gin.Context) {
|
||||
reqPb pbGroup.AddGroupMembersCMSReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationId, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationId = utils.OperationIDGenerator()
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.UserIds = req.Members
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationId)
|
||||
reqPb.UserIDList = req.Members
|
||||
reqPb.GroupID = req.GroupId
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationId + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationId, errMsg)
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.AddGroupMembersCMS(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationId, utils.GetSelfFuncName(), "AddGroupMembersCMS failed", err.Error())
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "AddGroupMembersCMS failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
@ -420,11 +277,11 @@ func RemoveGroupMembers(c *gin.Context) {
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.UserIds = req.Members
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
reqPb.UserIDList = req.Members
|
||||
reqPb.GroupID = req.GroupId
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -442,38 +299,7 @@ func RemoveGroupMembers(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func DeleteGroup(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.DeleteGroupRequest
|
||||
_ cms_api_struct.DeleteGroupResponse
|
||||
reqPb pbGroup.DeleteGroupReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.DeleteGroup(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func SetGroupMaster(c *gin.Context) {
|
||||
func SetGroupOwner(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.SetGroupMasterRequest
|
||||
_ cms_api_struct.SetGroupMasterResponse
|
||||
@ -486,12 +312,12 @@ func SetGroupMaster(c *gin.Context) {
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.UserId = req.UserId
|
||||
reqPb.GroupID = req.GroupId
|
||||
reqPb.UserID = req.UserId
|
||||
reqPb.RoleLevel = constant.GroupOwner
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -519,12 +345,12 @@ func SetGroupOrdinaryUsers(c *gin.Context) {
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.UserId = req.UserId
|
||||
reqPb.GroupID = req.GroupId
|
||||
reqPb.UserID = req.UserId
|
||||
reqPb.RoleLevel = constant.GroupOrdinaryUsers
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -559,11 +385,10 @@ func AlterGroupInfo(c *gin.Context) {
|
||||
Introduction: req.Introduction,
|
||||
Notification: req.Notification,
|
||||
FaceURL: req.ProfilePhoto,
|
||||
// GroupType: int32(req.GroupType),
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -23,9 +23,9 @@ func BroadcastMessage(c *gin.Context) {
|
||||
reqPb pbMessage.BoradcastMessageReq
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -45,9 +45,9 @@ func MassSendMassage(c *gin.Context) {
|
||||
reqPb pbMessage.MassSendMessageReq
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -67,9 +67,9 @@ func WithdrawMessage(c *gin.Context) {
|
||||
reqPb pbMessage.WithdrawMessageReq
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -101,9 +101,9 @@ func GetChatLogs(c *gin.Context) {
|
||||
}
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -20,6 +20,10 @@ func NewGinRouter() *gin.Engine {
|
||||
adminRouterGroup := router.Group("/admin")
|
||||
{
|
||||
adminRouterGroup.POST("/login", admin.AdminLogin)
|
||||
adminRouterGroup.Use(middleware.JWTAuth())
|
||||
adminRouterGroup.POST("/add_user_register_add_friend_id", admin.AddUserRegisterAddFriendIDList)
|
||||
adminRouterGroup.POST("/reduce_user_register_reduce_friend_id", admin.ReduceUserRegisterAddFriendIDList)
|
||||
adminRouterGroup.POST("/get_user_register_reduce_friend_id_list", admin.GetUserRegisterAddFriendIDList)
|
||||
}
|
||||
r2 := router.Group("")
|
||||
r2.Use(middleware.JWTAuth())
|
||||
@ -47,20 +51,15 @@ func NewGinRouter() *gin.Engine {
|
||||
}
|
||||
groupRouterGroup := r2.Group("/group")
|
||||
{
|
||||
groupRouterGroup.GET("/get_group_by_id", group.GetGroupById)
|
||||
groupRouterGroup.GET("/get_group_by_id", group.GetGroupByID)
|
||||
groupRouterGroup.GET("/get_groups", group.GetGroups)
|
||||
groupRouterGroup.GET("/get_group_by_name", group.GetGroupByName)
|
||||
groupRouterGroup.GET("/get_group_members", group.GetGroupMembers)
|
||||
groupRouterGroup.POST("/create_group", group.CreateGroup)
|
||||
groupRouterGroup.POST("/add_members", group.AddGroupMembers)
|
||||
groupRouterGroup.POST("/remove_members", group.RemoveGroupMembers)
|
||||
groupRouterGroup.POST("/ban_group_private_chat", group.BanPrivateChat)
|
||||
groupRouterGroup.POST("/open_group_private_chat", group.OpenPrivateChat)
|
||||
groupRouterGroup.POST("/ban_group_chat", group.BanGroupChat)
|
||||
groupRouterGroup.POST("/open_group_chat", group.OpenGroupChat)
|
||||
groupRouterGroup.POST("/delete_group", group.DeleteGroup)
|
||||
groupRouterGroup.POST("/get_members_in_group", group.GetGroupMembers)
|
||||
groupRouterGroup.POST("/set_group_master", group.SetGroupMaster)
|
||||
groupRouterGroup.POST("/set_group_master", group.SetGroupOwner)
|
||||
groupRouterGroup.POST("/set_group_ordinary_user", group.SetGroupOrdinaryUsers)
|
||||
groupRouterGroup.POST("/alter_group_info", group.AlterGroupInfo)
|
||||
}
|
||||
@ -78,12 +77,6 @@ func NewGinRouter() *gin.Engine {
|
||||
userRouterGroup.POST("/delete_user", user.DeleteUser)
|
||||
userRouterGroup.GET("/get_users_by_name", user.GetUsersByName)
|
||||
}
|
||||
friendRouterGroup := r2.Group("/friend")
|
||||
{
|
||||
friendRouterGroup.POST("/get_friends_by_id")
|
||||
friendRouterGroup.POST("/set_friend")
|
||||
friendRouterGroup.POST("/remove_friend")
|
||||
}
|
||||
messageCMSRouterGroup := r2.Group("/message")
|
||||
{
|
||||
messageCMSRouterGroup.GET("/get_chat_logs", messageCMS.GetChatLogs)
|
||||
|
@ -31,9 +31,9 @@ func GetMessagesStatistics(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -85,9 +85,9 @@ func GetUserStatistics(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -149,9 +149,9 @@ func GetGroupStatistics(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -206,9 +206,9 @@ func GetActiveUser(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -240,9 +240,9 @@ func GetActiveGroup(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
@ -32,9 +32,9 @@ func GetUserById(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -74,9 +74,9 @@ func GetUsersByName(c *gin.Context) {
|
||||
PageNumber: int32(req.PageNumber),
|
||||
ShowNumber: int32(req.ShowNumber),
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -111,9 +111,9 @@ func GetUsers(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb.Pagination, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -147,9 +147,9 @@ func ResignUser(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -177,9 +177,9 @@ func AlterUser(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -206,7 +206,7 @@ func AddUser(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
@ -237,9 +237,9 @@ func BlockUser(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -268,9 +268,9 @@ func UnblockUser(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -302,9 +302,9 @@ func GetBlockUsers(c *gin.Context) {
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
utils.CopyStructFields(&reqPb.Pagination, &req)
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "blockUsers", reqPb.Pagination, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -323,6 +323,10 @@ func GetBlockUsers(c *gin.Context) {
|
||||
ProfilePhoto: v.User.ProfilePhoto,
|
||||
Nickname: v.User.Nickname,
|
||||
IsBlock: v.User.IsBlock,
|
||||
Birth: v.User.Birth,
|
||||
PhoneNumber: v.User.PhoneNumber,
|
||||
Email: v.User.Email,
|
||||
Gender: int(v.User.Gender),
|
||||
CreateTime: v.User.CreateTime,
|
||||
},
|
||||
BeginDisableTime: v.BeginDisableTime,
|
||||
@ -350,9 +354,9 @@ func GetBlockUserById(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.UserId = req.UserId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
@ -384,9 +388,9 @@ func DeleteUser(c *gin.Context) {
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.UserId = req.UserId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
|
164
internal/cron_task/clear_msg.go
Normal file
164
internal/cron_task/clear_msg.go
Normal file
@ -0,0 +1,164 @@
|
||||
package cronTask
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
goRedis "github.com/go-redis/redis/v8"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"math"
|
||||
)
|
||||
|
||||
const oldestList = 0
|
||||
const newestList = -1
|
||||
|
||||
func ResetUserGroupMinSeq(operationID, groupID string, userIDList []string) error {
|
||||
var delMsgIDList [][2]interface{}
|
||||
minSeq, err := deleteMongoMsg(operationID, groupID, oldestList, &delMsgIDList)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), groupID, "deleteMongoMsg failed")
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
if minSeq == 0 {
|
||||
return nil
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "delMsgIDList:", delMsgIDList, "minSeq", minSeq)
|
||||
for _, userID := range userIDList {
|
||||
userMinSeq, err := db.DB.GetGroupUserMinSeq(groupID, userID)
|
||||
if err != nil && err != goRedis.Nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "GetGroupUserMinSeq failed", groupID, userID, err.Error())
|
||||
continue
|
||||
}
|
||||
if userMinSeq > uint64(minSeq) {
|
||||
err = db.DB.SetGroupUserMinSeq(groupID, userID, userMinSeq)
|
||||
} else {
|
||||
err = db.DB.SetGroupUserMinSeq(groupID, userID, uint64(minSeq))
|
||||
}
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID, userID, userMinSeq, minSeq)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteMongoMsgAndResetRedisSeq(operationID, userID string) error {
|
||||
var delMsgIDList [][2]interface{}
|
||||
minSeq, err := deleteMongoMsg(operationID, userID, oldestList, &delMsgIDList)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
if minSeq == 0 {
|
||||
return nil
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "delMsgIDMap: ", delMsgIDList, "minSeq", minSeq)
|
||||
err = db.DB.SetUserMinSeq(userID, minSeq)
|
||||
return err
|
||||
}
|
||||
|
||||
func delMongoMsgs(operationID string, delMsgIDList *[][2]interface{}) error {
|
||||
if len(*delMsgIDList) > 0 {
|
||||
var IDList []string
|
||||
for _, v := range *delMsgIDList {
|
||||
IDList = append(IDList, v[0].(string))
|
||||
}
|
||||
err := db.DB.DelMongoMsgs(IDList)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "DelMongoMsgs failed")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// recursion
|
||||
func deleteMongoMsg(operationID string, ID string, index int64, delMsgIDList *[][2]interface{}) (uint32, error) {
|
||||
// 从最旧的列表开始找
|
||||
msgs, err := db.DB.GetUserMsgListByIndex(ID, index)
|
||||
if err != nil || msgs.UID == "" {
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "GetUserMsgListByIndex failed", err.Error(), index, ID)
|
||||
}
|
||||
return getDelMaxSeqByIDList(*delMsgIDList), delMongoMsgs(operationID, delMsgIDList)
|
||||
}
|
||||
if len(msgs.Msg) > db.GetSingleGocMsgNum() {
|
||||
log.NewWarn(operationID, utils.GetSelfFuncName(), "msgs too large", len(msgs.Msg), msgs.UID)
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "get msgs: ", msgs.UID)
|
||||
for i, msg := range msgs.Msg {
|
||||
// 找到列表中不需要删除的消息了
|
||||
if utils.GetCurrentTimestampByMill() < msg.SendTime+int64(config.Config.Mongo.DBRetainChatRecords)*24*60*60*1000 {
|
||||
if err := delMongoMsgs(operationID, delMsgIDList); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
minSeq := getDelMaxSeqByIDList(*delMsgIDList)
|
||||
if i > 0 {
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
err = proto.Unmarshal(msg.Msg, msgPb)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), ID, index)
|
||||
} else {
|
||||
err = db.DB.ReplaceMsgToBlankByIndex(msgs.UID, i-1)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), msgs.UID, i)
|
||||
return minSeq, nil
|
||||
}
|
||||
minSeq = msgPb.Seq
|
||||
}
|
||||
}
|
||||
return minSeq, nil
|
||||
}
|
||||
}
|
||||
if len(msgs.Msg) > 0 {
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
err = proto.Unmarshal(msgs.Msg[len(msgs.Msg)-1].Msg, msgPb)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), len(msgs.Msg)-1, msgs.UID)
|
||||
return 0, utils.Wrap(err, "proto.Unmarshal failed")
|
||||
}
|
||||
*delMsgIDList = append(*delMsgIDList, [2]interface{}{msgs.UID, msgPb.Seq})
|
||||
}
|
||||
// 没有找到 代表需要全部删除掉 继续递归查找下一个比较旧的列表
|
||||
seq, err := deleteMongoMsg(operationID, utils.GetSelfFuncName(), index+1, delMsgIDList)
|
||||
if err != nil {
|
||||
return 0, utils.Wrap(err, "deleteMongoMsg failed")
|
||||
}
|
||||
return seq, nil
|
||||
}
|
||||
|
||||
func getDelMaxSeqByIDList(delMsgIDList [][2]interface{}) uint32 {
|
||||
if len(delMsgIDList) == 0 {
|
||||
return 0
|
||||
}
|
||||
return delMsgIDList[len(delMsgIDList)-1][1].(uint32)
|
||||
}
|
||||
|
||||
func checkMaxSeqWithMongo(operationID, ID string, diffusionType int) error {
|
||||
var maxSeq uint64
|
||||
var err error
|
||||
if diffusionType == constant.WriteDiffusion {
|
||||
maxSeq, err = db.DB.GetUserMaxSeq(ID)
|
||||
} else {
|
||||
maxSeq, err = db.DB.GetGroupMaxSeq(ID)
|
||||
}
|
||||
if err != nil {
|
||||
if err == goRedis.Nil {
|
||||
return nil
|
||||
}
|
||||
return utils.Wrap(err, "GetUserMaxSeq failed")
|
||||
}
|
||||
msg, err := db.DB.GetNewestMsg(ID)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "GetNewestMsg failed")
|
||||
}
|
||||
msgPb := &server_api_params.MsgData{}
|
||||
err = proto.Unmarshal(msg.Msg, msgPb)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
if math.Abs(float64(msgPb.Seq-uint32(maxSeq))) > 10 {
|
||||
log.NewWarn(operationID, utils.GetSelfFuncName(), maxSeq, msgPb.Seq, "redis maxSeq is different with msg.Seq")
|
||||
}
|
||||
return nil
|
||||
}
|
77
internal/cron_task/cron_task.go
Normal file
77
internal/cron_task/cron_task.go
Normal file
@ -0,0 +1,77 @@
|
||||
package cronTask
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"fmt"
|
||||
"github.com/robfig/cron/v3"
|
||||
"time"
|
||||
)
|
||||
|
||||
const cronTaskOperationID = "cronTaskOperationID-"
|
||||
|
||||
func StartCronTask() {
|
||||
log.NewPrivateLog("cron")
|
||||
log.NewInfo(utils.OperationIDGenerator(), "start cron task")
|
||||
c := cron.New()
|
||||
fmt.Println("config", config.Config.Mongo.ChatRecordsClearTime)
|
||||
_, err := c.AddFunc(config.Config.Mongo.ChatRecordsClearTime, func() {
|
||||
operationID := getCronTaskOperationID()
|
||||
log.NewInfo(operationID, "====================== start del cron task ======================")
|
||||
userIDList, err := im_mysql_model.SelectAllUserID()
|
||||
if err == nil {
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "userIDList: ", userIDList)
|
||||
for _, userID := range userIDList {
|
||||
if err := DeleteMongoMsgAndResetRedisSeq(operationID, userID); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), userID)
|
||||
}
|
||||
if err := checkMaxSeqWithMongo(operationID, userID, constant.WriteDiffusion); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), userID, err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
|
||||
workingGroupIDList, err := im_mysql_model.GetGroupIDListByGroupType(constant.WorkingGroup)
|
||||
if err == nil {
|
||||
for _, groupID := range workingGroupIDList {
|
||||
userIDList, err = rocksCache.GetGroupMemberIDListFromCache(groupID)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID)
|
||||
continue
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "groupID:", groupID, "userIDList:", userIDList)
|
||||
if err := ResetUserGroupMinSeq(operationID, groupID, userIDList); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID, userIDList)
|
||||
}
|
||||
if err := checkMaxSeqWithMongo(operationID, groupID, constant.ReadDiffusion); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), groupID, err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(operationID, "====================== start del cron finished ======================")
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println("start cron failed", err.Error())
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c.Start()
|
||||
fmt.Println("start cron task success")
|
||||
for {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
func getCronTaskOperationID() string {
|
||||
return cronTaskOperationID + utils.OperationIDGenerator()
|
||||
}
|
7
internal/cron_task/test/main.go
Normal file
7
internal/cron_task/test/main.go
Normal file
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "Open_IM/pkg/common/db"
|
||||
|
||||
func main() {
|
||||
db.DB.BatchInsertChat()
|
||||
}
|
120
internal/demo/register/invitation_code.go
Normal file
120
internal/demo/register/invitation_code.go
Normal file
@ -0,0 +1,120 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
apiStruct "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/constant"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type InvitationCode struct {
|
||||
InvitationCode string `json:"invitationCode"`
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
UserID string `json:"userID"`
|
||||
LastTime time.Time `json:"lastTime"`
|
||||
Status int32 `json:"status"`
|
||||
}
|
||||
|
||||
type GenerateInvitationCodeReq struct {
|
||||
CodesNum int `json:"codesNum" binding:"required"`
|
||||
CodeLen int `json:"codeLen" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type GenerateInvitationCodeResp struct {
|
||||
Codes []string `json:"codes"`
|
||||
}
|
||||
|
||||
func GenerateInvitationCode(c *gin.Context) {
|
||||
req := GenerateInvitationCodeReq{}
|
||||
resp := GenerateInvitationCodeResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
var err error
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
resp.Codes, err = imdb.BatchCreateInvitationCodes(req.CodesNum, req.CodeLen)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "BatchCreateInvitationCodes failed", req.CodesNum, req.CodeLen)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "Verification code error!"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
type QueryInvitationCodeReq struct {
|
||||
Code string `json:"code" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type QueryInvitationCodeResp struct {
|
||||
InvitationCode
|
||||
}
|
||||
|
||||
func QueryInvitationCode(c *gin.Context) {
|
||||
req := QueryInvitationCodeReq{}
|
||||
resp := QueryInvitationCodeResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
invitation, err := imdb.GetInvitationCode(req.Code)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetInvitationCode failed", req.Code)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "Verification code error!"})
|
||||
return
|
||||
}
|
||||
resp.UserID = invitation.UserID
|
||||
resp.CreateTime = invitation.CreateTime
|
||||
resp.Status = invitation.Status
|
||||
resp.LastTime = invitation.LastTime
|
||||
resp.InvitationCode.InvitationCode = invitation.InvitationCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
type GetInvitationCodesReq struct {
|
||||
Status int32 `json:"status"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
apiStruct.Pagination
|
||||
}
|
||||
|
||||
type GetInvitationCodesResp struct {
|
||||
apiStruct.Pagination
|
||||
Codes []InvitationCode `json:"codes"`
|
||||
}
|
||||
|
||||
func GetInvitationCodes(c *gin.Context) {
|
||||
req := GetInvitationCodesReq{}
|
||||
resp := GetInvitationCodesResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
codes, err := imdb.GetInvitationCodes(req.ShowNumber, req.PageNumber, req.Status)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetInvitationCode failed", req.ShowNumber, req.PageNumber, req.Status)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "Verification code error!"})
|
||||
return
|
||||
}
|
||||
resp.Pagination.PageNumber = req.PageNumber
|
||||
resp.Pagination.ShowNumber = req.ShowNumber
|
||||
for _, v := range codes {
|
||||
resp.Codes = append(resp.Codes, InvitationCode{
|
||||
InvitationCode: v.InvitationCode,
|
||||
CreateTime: v.CreateTime,
|
||||
UserID: v.UserID,
|
||||
LastTime: v.LastTime,
|
||||
Status: v.Status,
|
||||
})
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
223
internal/demo/register/ip_limit.go
Normal file
223
internal/demo/register/ip_limit.go
Normal file
@ -0,0 +1,223 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
//api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
//"github.com/jinzhu/gorm"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type QueryIPRegisterReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
|
||||
type QueryIPRegisterResp struct {
|
||||
IP string `json:"ip"`
|
||||
RegisterNum int `json:"num"`
|
||||
Status int `json:"status"`
|
||||
UserIDList []string `json:"userIDList"`
|
||||
}
|
||||
|
||||
func QueryIPRegister(c *gin.Context) {
|
||||
req := QueryIPRegisterReq{}
|
||||
resp := QueryIPRegisterResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
userIDList, err := imdb.GetRegisterUserNum(req.IP)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetInvitationCode failed", req.IP)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "GetRegisterUserNum error!"})
|
||||
return
|
||||
}
|
||||
resp.IP = req.IP
|
||||
resp.RegisterNum = len(userIDList)
|
||||
resp.UserIDList = userIDList
|
||||
ipLimit, err := imdb.QueryIPLimits(req.IP)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "QueryIPLimits failed", req.IP, err.Error())
|
||||
} else {
|
||||
if ipLimit != nil {
|
||||
if ipLimit.Ip != "" {
|
||||
resp.Status = 1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
type AddIPLimitReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
IP string `json:"ip"`
|
||||
LimitTime int32 `json:"limitTime"`
|
||||
}
|
||||
|
||||
type AddIPLimitResp struct {
|
||||
}
|
||||
|
||||
func AddIPLimit(c *gin.Context) {
|
||||
req := AddIPLimitReq{}
|
||||
//resp := AddIPLimitResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
if err := imdb.InsertOneIntoIpLimits(db.IpLimit{
|
||||
Ip: req.IP,
|
||||
LimitRegister: 1,
|
||||
LimitLogin: 1,
|
||||
CreateTime: time.Now(),
|
||||
LimitTime: utils.UnixSecondToTime(int64(req.LimitTime)),
|
||||
}); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.IP, req.LimitTime)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "InsertOneIntoIpLimits error!"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||
}
|
||||
|
||||
type RemoveIPLimitReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
|
||||
type RemoveIPLimitResp struct {
|
||||
}
|
||||
|
||||
func RemoveIPLimit(c *gin.Context) {
|
||||
req := RemoveIPLimitReq{}
|
||||
//resp := AddIPLimitResp{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrArgs, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
if err := imdb.DeleteOneFromIpLimits(req.IP); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.IP)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "InsertOneIntoIpLimits error!"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||
}
|
||||
|
||||
// ===========================================sk ==========================
|
||||
|
||||
type QueryUserIDIPLimitLoginReq struct {
|
||||
UserID string `json:"userID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
//type QueryUserIDIPLimitLoginResp struct {
|
||||
// UserIpLimit []db.UserIpLimit `json:"userIpLimit"`
|
||||
//}
|
||||
|
||||
func QueryUserIDLimitLogin(c *gin.Context) {
|
||||
req := QueryUserIDIPLimitLoginReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
resp, err := imdb.GetIpLimitsLoginByUserID(req.UserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": "GetIpLimitsByUserID error!"})
|
||||
return
|
||||
}
|
||||
if len(resp) > 0 {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
type AddUserIPLimitLoginReq struct {
|
||||
UserID string `json:"userID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
|
||||
type AddUserIPLimitLoginResp struct {
|
||||
}
|
||||
|
||||
// 添加ip 特定用户才能登录 user_ip_limits 表
|
||||
func AddUserIPLimitLogin(c *gin.Context) {
|
||||
req := AddUserIPLimitLoginReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
userIp := db.UserIpLimit{UserID: req.UserID, Ip: req.IP}
|
||||
err := imdb.UpdateUserInfo(db.User{
|
||||
UserID: req.UserID,
|
||||
LoginLimit: 1,
|
||||
})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "InsertUserIpLimitsLogin error!"})
|
||||
return
|
||||
}
|
||||
err = imdb.InsertUserIpLimitsLogin(&userIp)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "InsertUserIpLimitsLogin error!"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||
}
|
||||
|
||||
type RemoveUserIPLimitReq struct {
|
||||
UserID string `json:"userID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
|
||||
type RemoveUserIPLimitResp struct {
|
||||
}
|
||||
|
||||
// 删除ip 特定用户才能登录 user_ip_limits 表
|
||||
func RemoveUserIPLimitLogin(c *gin.Context) {
|
||||
req := RemoveUserIPLimitReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
err := imdb.DeleteUserIpLimitsLogin(req.UserID, req.IP)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "DeleteUserIpLimitsLogin error!"})
|
||||
return
|
||||
}
|
||||
ips, err := imdb.GetIpLimitsLoginByUserID(req.UserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "GetIpLimitsLoginByUserID error!"})
|
||||
return
|
||||
}
|
||||
if len(ips) == 0 {
|
||||
err := imdb.UpdateUserInfoByMap(db.User{
|
||||
UserID: req.UserID,
|
||||
}, map[string]interface{}{"login_limit": 0})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "UpdateUserInfo error!"})
|
||||
return
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||
}
|
@ -10,8 +10,9 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ParamsLogin struct {
|
||||
@ -56,12 +57,22 @@ func Login(c *gin.Context) {
|
||||
} else {
|
||||
userID = r.Account
|
||||
}
|
||||
ip := c.Request.Header.Get("X-Forward-For")
|
||||
if ip == "" {
|
||||
ip = c.ClientIP()
|
||||
}
|
||||
url := fmt.Sprintf("http://%s:%d/auth/user_token", utils.ServerIP, config.Config.Api.GinPort[0])
|
||||
openIMGetUserToken := api.UserTokenReq{}
|
||||
openIMGetUserToken.OperationID = params.OperationID
|
||||
openIMGetUserToken.Platform = params.Platform
|
||||
openIMGetUserToken.Secret = config.Config.Secret
|
||||
openIMGetUserToken.UserID = userID
|
||||
openIMGetUserToken.LoginIp = ip
|
||||
loginIp := c.Request.Header.Get("X-Forward-For")
|
||||
if loginIp == "" {
|
||||
loginIp = c.ClientIP()
|
||||
}
|
||||
openIMGetUserToken.LoginIp = loginIp
|
||||
openIMGetUserTokenResp := api.UserTokenResp{}
|
||||
bMsg, err := http2.Post(url, openIMGetUserToken, 2)
|
||||
if err != nil {
|
||||
@ -72,7 +83,11 @@ func Login(c *gin.Context) {
|
||||
err = json.Unmarshal(bMsg, &openIMGetUserTokenResp)
|
||||
if err != nil || openIMGetUserTokenResp.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, "request get user token", account, "err", "")
|
||||
if openIMGetUserTokenResp.ErrCode == constant.LoginLimit {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LoginLimit, "errMsg": "用户登录被限制"})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.GetIMTokenErr, "errMsg": ""})
|
||||
}
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMGetUserTokenResp.UserToken})
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
groupRpc "Open_IM/pkg/proto/group"
|
||||
|
||||
organizationRpc "Open_IM/pkg/proto/organization"
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
@ -50,33 +51,48 @@ func onboardingProcess(operationID, userID, userName, faceURL, phoneNumber, emai
|
||||
if err := createOrganizationUser(operationID, userID, userName, phoneNumber, email); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "createOrganizationUser failed", err.Error())
|
||||
}
|
||||
var joinDepartmentIDList []string
|
||||
if len(config.Config.Demo.JoinDepartmentIDList) == 0 {
|
||||
departmentID, err := imdb.GetRandomDepartmentID()
|
||||
|
||||
if err := joinTestDepartment(operationID, userID, departmentID); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error())
|
||||
}
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "random departmentID", departmentID)
|
||||
if err != nil {
|
||||
log.NewError(utils.GetSelfFuncName(), "GetRandomDepartmentID failed", err.Error())
|
||||
return
|
||||
}
|
||||
joinDepartmentIDList = []string{departmentID}
|
||||
} else {
|
||||
joinDepartmentIDList = config.Config.Demo.JoinDepartmentIDList
|
||||
}
|
||||
|
||||
for _, departmentID := range joinDepartmentIDList {
|
||||
if err := joinTestDepartment(operationID, userID, departmentID); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if config.Config.Demo.JoinDepartmentGroups {
|
||||
for _, departmentID := range joinDepartmentIDList {
|
||||
groupIDList, err := GetDepartmentGroupIDList(operationID, departmentID)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
joinGroups(operationID, userID, userName, faceURL, groupIDList)
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "fineshed")
|
||||
}
|
||||
}
|
||||
|
||||
if config.Config.Demo.OaNotification {
|
||||
oaNotification(operationID, userID)
|
||||
}
|
||||
}
|
||||
|
||||
func createOrganizationUser(operationID, userID, userName, phoneNumber, email string) error {
|
||||
defer func() {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), userID)
|
||||
}()
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "start createOrganizationUser")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, operationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, operationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := operationID + "getcdv3.GetConn == nil"
|
||||
errMsg := operationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(operationID, errMsg)
|
||||
return errors.New(errMsg)
|
||||
}
|
||||
@ -113,9 +129,9 @@ func joinTestDepartment(operationID, userID, departmentID string) error {
|
||||
defer func() {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), userID)
|
||||
}()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, operationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, operationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := operationID + "getcdv3.GetConn == nil"
|
||||
errMsg := operationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(operationID, errMsg)
|
||||
return errors.New(errMsg)
|
||||
}
|
||||
@ -145,9 +161,9 @@ func GetDepartmentGroupIDList(operationID, departmentID string) ([]string, error
|
||||
defer func() {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), departmentID)
|
||||
}()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, operationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, operationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := operationID + "getcdv3.GetConn == nil"
|
||||
errMsg := operationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(operationID, errMsg)
|
||||
return nil, errors.New(errMsg)
|
||||
}
|
||||
@ -184,9 +200,9 @@ func joinGroups(operationID, userID, userName, faceURL string, groupIDList []str
|
||||
defer func() {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), userID, groupIDList)
|
||||
}()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, operationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, operationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := operationID + "getcdv3.GetConn == nil"
|
||||
errMsg := operationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(operationID, errMsg)
|
||||
return
|
||||
}
|
||||
|
52
internal/demo/register/register_import_friend.go
Normal file
52
internal/demo/register/register_import_friend.go
Normal file
@ -0,0 +1,52 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var ChImportFriend chan *pbFriend.ImportFriendReq
|
||||
|
||||
func init() {
|
||||
ChImportFriend = make(chan *pbFriend.ImportFriendReq, 1000)
|
||||
}
|
||||
|
||||
func ImportFriendRoutine() {
|
||||
for {
|
||||
req := <-ChImportFriend
|
||||
go func() {
|
||||
friendUserIDList, err := imdb.GetRegisterAddFriendList(0, 0)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req, err.Error())
|
||||
return
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "ImportFriendRoutine IDList", friendUserIDList)
|
||||
if len(friendUserIDList) == 0 {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "len==0")
|
||||
return
|
||||
}
|
||||
req.FriendUserIDList = friendUserIDList
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return
|
||||
}
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
rpcResp, err := client.ImportFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "ImportFriend failed ", err.Error(), req.String())
|
||||
return
|
||||
}
|
||||
if rpcResp.CommonResp.ErrCode != 0 {
|
||||
log.NewError(req.OperationID, "ImportFriend failed ", rpcResp)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
@ -8,12 +8,12 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/utils"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gopkg.in/gomail.v2"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gopkg.in/gomail.v2"
|
||||
)
|
||||
|
||||
var sms SMS
|
||||
@ -39,6 +39,7 @@ type paramsVerificationCode struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UsedFor int `json:"usedFor"`
|
||||
AreaCode string `json:"areaCode"`
|
||||
InvitationCode string `json:"invitationCode"`
|
||||
}
|
||||
|
||||
func SendVerificationCode(c *gin.Context) {
|
||||
@ -72,6 +73,15 @@ func SendVerificationCode(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HasRegistered, "errMsg": "The phone number has been registered"})
|
||||
return
|
||||
}
|
||||
//需要邀请码
|
||||
if config.Config.Demo.NeedInvitationCode {
|
||||
err = im_mysql_model.CheckInvitationCode(params.InvitationCode)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "邀请码错误", params)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
||||
return
|
||||
}
|
||||
}
|
||||
accountKey = accountKey + "_" + constant.VerificationCodeForRegisterSuffix
|
||||
ok, err := db.DB.JudgeAccountEXISTS(accountKey)
|
||||
if ok || err != nil {
|
||||
|
@ -5,16 +5,18 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
http2 "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/utils"
|
||||
"encoding/json"
|
||||
"github.com/gin-gonic/gin"
|
||||
"math/big"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ParamsSetPassword struct {
|
||||
@ -29,6 +31,7 @@ type ParamsSetPassword struct {
|
||||
FaceURL string `json:"faceURL"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
AreaCode string `json:"areaCode"`
|
||||
InvitationCode string `json:"invitationCode"`
|
||||
}
|
||||
|
||||
func SetPassword(c *gin.Context) {
|
||||
@ -38,6 +41,23 @@ func SetPassword(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
ip := c.Request.Header.Get("X-Forward-For")
|
||||
if ip == "" {
|
||||
ip = c.ClientIP()
|
||||
}
|
||||
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "ip:", ip)
|
||||
Limited, LimitError := imdb.IsLimitRegisterIp(ip)
|
||||
if LimitError != nil {
|
||||
log.Error(params.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError.Error()})
|
||||
return
|
||||
}
|
||||
if Limited {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.RegisterLimit, "errMsg": "limited"})
|
||||
return
|
||||
}
|
||||
|
||||
var account string
|
||||
if params.Email != "" {
|
||||
account = params.Email
|
||||
@ -61,6 +81,13 @@ func SetPassword(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if config.Config.Demo.NeedInvitationCode && params.InvitationCode != "" {
|
||||
err := imdb.CheckInvitationCode(params.InvitationCode)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
//userID := utils.Base64Encode(account)
|
||||
var userID string
|
||||
@ -81,6 +108,9 @@ func SetPassword(c *gin.Context) {
|
||||
openIMRegisterReq.Nickname = params.Nickname
|
||||
openIMRegisterReq.Secret = config.Config.Secret
|
||||
openIMRegisterReq.FaceURL = params.FaceURL
|
||||
openIMRegisterReq.CreateIp = ip
|
||||
openIMRegisterReq.LastLoginIp = ip
|
||||
openIMRegisterReq.InvitationCode = params.InvitationCode
|
||||
openIMRegisterResp := api.UserRegisterResp{}
|
||||
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "register req:", openIMRegisterReq)
|
||||
bMsg, err := http2.Post(url, openIMRegisterReq, 2)
|
||||
@ -95,19 +125,35 @@ func SetPassword(c *gin.Context) {
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
if openIMRegisterResp.ErrCode == constant.RegisterLimit {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterLimit, "errMsg": "用户注册被限制"})
|
||||
return
|
||||
} else if openIMRegisterResp.ErrCode == constant.InvitationError {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: " + openIMRegisterResp.ErrMsg})
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Info(params.OperationID, "begin store mysql", account, params.Password, "info", params.FaceURL, params.Nickname)
|
||||
err = im_mysql_model.SetPassword(account, params.Password, params.Ex, userID, params.AreaCode)
|
||||
err = imdb.SetPassword(account, params.Password, params.Ex, userID, params.AreaCode, ip)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "set phone number password error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if config.Config.Demo.NeedInvitationCode && params.InvitationCode != "" {
|
||||
//判断一下验证码的使用情况
|
||||
LockSucc := imdb.TryLockInvitationCode(params.InvitationCode, userID)
|
||||
if LockSucc {
|
||||
imdb.FinishInvitationCode(params.InvitationCode, userID)
|
||||
}
|
||||
}
|
||||
|
||||
log.Info(params.OperationID, "end setPassword", account, params.Password)
|
||||
// demo onboarding
|
||||
if params.UserID == "" {
|
||||
if params.UserID == "" && config.Config.Demo.OnboardProcess {
|
||||
select {
|
||||
case Ch <- OnboardingProcessReq{
|
||||
OperationID: params.OperationID,
|
||||
@ -121,6 +167,17 @@ func SetPassword(c *gin.Context) {
|
||||
log.NewWarn(params.OperationID, utils.GetSelfFuncName(), "to ch timeOut")
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
case ChImportFriend <- &pbFriend.ImportFriendReq{
|
||||
OperationID: params.OperationID,
|
||||
FromUserID: userID,
|
||||
OpUserID: config.Config.Manager.AppManagerUid[0],
|
||||
}:
|
||||
case <-time.After(time.Second * 2):
|
||||
log.NewWarn(params.OperationID, utils.GetSelfFuncName(), "to ChImportFriend timeOut")
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMRegisterResp.UserToken})
|
||||
return
|
||||
}
|
||||
|
@ -89,9 +89,9 @@ func (r *RPCServer) GetSingleUserMsg(operationID string, currentMsgSeq uint32, u
|
||||
rpcReq.SeqList = seqList
|
||||
rpcReq.UserID = userID
|
||||
rpcReq.OperationID = operationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, rpcReq.OperationID)
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, rpcReq.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := "getcdv3.GetConn == nil"
|
||||
errMsg := "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(rpcReq.OperationID, errMsg)
|
||||
return nil
|
||||
}
|
||||
|
@ -59,3 +59,28 @@ func callbackUserOffline(operationID, userID string, platformID int) cbApi.Commo
|
||||
}
|
||||
return callbackResp
|
||||
}
|
||||
|
||||
func callbackUserKickOff(operationID string, userID string, platformID int) cbApi.CommonCallbackResp {
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackUserKickOff.Enable {
|
||||
return callbackResp
|
||||
}
|
||||
callbackUserKickOffReq := cbApi.CallbackUserKickOffReq{
|
||||
UserStatusCallbackReq: cbApi.UserStatusCallbackReq{
|
||||
UserStatusBaseCallback: cbApi.UserStatusBaseCallback{
|
||||
CallbackCommand: constant.CallbackUserKickOffCommand,
|
||||
OperationID: operationID,
|
||||
PlatformID: int32(platformID),
|
||||
Platform: constant.PlatformIDToName(platformID),
|
||||
},
|
||||
UserID: userID,
|
||||
},
|
||||
Seq: int(time.Now().UnixNano() / 1e6),
|
||||
}
|
||||
callbackUserKickOffResp := &cbApi.CallbackUserKickOffResp{CommonCallbackResp: callbackResp}
|
||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackUserKickOffReq, callbackUserKickOffResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil {
|
||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||
callbackResp.ErrMsg = err.Error()
|
||||
}
|
||||
return callbackResp
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
rpcReq.UserID = m.SendID
|
||||
rpcReq.OperationID = m.OperationID
|
||||
log.Debug(m.OperationID, "Ws call success to getMaxAndMinSeq", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdk_ws.GetMaxAndMinSeqReq).GroupIDList)
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, rpcReq.OperationID)
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, rpcReq.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := rpcReq.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := rpcReq.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
nReply.ErrCode = 500
|
||||
nReply.ErrMsg = errMsg
|
||||
log.NewError(rpcReq.OperationID, errMsg)
|
||||
@ -127,9 +127,9 @@ func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||
rpcReq.OperationID = m.OperationID
|
||||
rpcReq.GroupSeqList = data.(sdk_ws.PullMessageBySeqListReq).GroupSeqList
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdk_ws.PullMessageBySeqListReq).SeqList)
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, m.OperationID)
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, m.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := rpcReq.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := rpcReq.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
nReply.ErrCode = 500
|
||||
nReply.ErrMsg = errMsg
|
||||
log.NewError(rpcReq.OperationID, errMsg)
|
||||
@ -186,9 +186,9 @@ func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
||||
MsgData: &data,
|
||||
}
|
||||
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, data.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, m.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, m.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := m.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := m.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
nReply.ErrCode = 500
|
||||
nReply.ErrMsg = errMsg
|
||||
log.NewError(m.OperationID, errMsg)
|
||||
@ -237,9 +237,9 @@ func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendSignalMsg, m.OperationID)
|
||||
if isPass {
|
||||
signalResp := pbRtc.SignalResp{}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRealTimeCommName, m.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRealTimeCommName, m.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := m.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := m.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(m.OperationID, errMsg)
|
||||
ws.sendSignalMsgResp(conn, 204, errMsg, m, &signalResp)
|
||||
return
|
||||
@ -267,9 +267,9 @@ func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
||||
}
|
||||
log.NewInfo(m.OperationID, utils.GetSelfFuncName(), "pbData: ", pbData)
|
||||
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, msgData)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, m.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, m.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := m.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := m.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(m.OperationID, errMsg)
|
||||
ws.sendSignalMsgResp(conn, 200, errMsg, m, &signalResp)
|
||||
return
|
||||
|
@ -291,19 +291,20 @@ func (r *RPCServer) encodeWsData(wsData *sdk_ws.MsgData, operationID string) (by
|
||||
func (r *RPCServer) KickUserOffline(_ context.Context, req *pbRelay.KickUserOfflineReq) (*pbRelay.KickUserOfflineResp, error) {
|
||||
log.NewInfo(req.OperationID, "KickUserOffline is arriving", req.String())
|
||||
for _, v := range req.KickUserIDList {
|
||||
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]
|
||||
log.NewWarn(req.OperationID, "send kick msg, close connection ", req.PlatformID, v)
|
||||
ws.sendKickMsg(conn, &UserConn{})
|
||||
conn.Close()
|
||||
}
|
||||
log.NewWarn(req.OperationID, "SetTokenKicked ", v, req.PlatformID, req.OperationID)
|
||||
SetTokenKicked(v, int(req.PlatformID), req.OperationID)
|
||||
}
|
||||
return &pbRelay.KickUserOfflineResp{}, nil
|
||||
}
|
||||
|
||||
func (r *RPCServer) MultiTerminalLoginCheck(ctx context.Context, req *pbRelay.MultiTerminalLoginCheckReq) (*pbRelay.MultiTerminalLoginCheckResp, error) {
|
||||
|
||||
ws.MultiTerminalLoginCheckerWithLock(req.UserID, int(req.PlatformID), req.Token, req.OperationID)
|
||||
return &pbRelay.MultiTerminalLoginCheckResp{}, nil
|
||||
}
|
||||
|
@ -12,9 +12,10 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"strings"
|
||||
|
||||
go_redis "github.com/go-redis/redis/v8"
|
||||
"github.com/pkg/errors"
|
||||
"strings"
|
||||
|
||||
//"gopkg.in/errgo.v2/errors"
|
||||
"net/http"
|
||||
@ -119,18 +120,21 @@ func (ws *WServer) SetWriteTimeoutWriteMsg(conn *UserConn, a int, msg []byte, ti
|
||||
}
|
||||
|
||||
func (ws *WServer) MultiTerminalLoginRemoteChecker(userID string, platformID int32, token string, operationID string) {
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRelayName)
|
||||
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), operationID)
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "args grpcCons: ", userID, platformID, grpcCons)
|
||||
for _, v := range grpcCons {
|
||||
if v.Target() == rpcSvr.target {
|
||||
log.Debug(operationID, "Filter out this node ", rpcSvr.target)
|
||||
continue
|
||||
}
|
||||
log.Debug(operationID, "call this node ", v.Target(), rpcSvr.target)
|
||||
client := pbRelay.NewRelayClient(v)
|
||||
req := &pbRelay.MultiTerminalLoginCheckReq{OperationID: operationID, PlatformID: platformID, UserID: userID, Token: token}
|
||||
log.NewInfo(operationID, "MultiTerminalLoginCheckReq ", client, req.String())
|
||||
resp, err := client.MultiTerminalLoginCheck(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(operationID, "MultiTerminalLoginCheck failed ", err.Error())
|
||||
continue
|
||||
}
|
||||
if resp.ErrCode != 0 {
|
||||
log.Error(operationID, "MultiTerminalLoginCheck errCode, errMsg: ", resp.ErrCode, resp.ErrMsg)
|
||||
@ -141,7 +145,13 @@ func (ws *WServer) MultiTerminalLoginRemoteChecker(userID string, platformID int
|
||||
func (ws *WServer) MultiTerminalLoginCheckerWithLock(uid string, platformID int, token string, operationID string) {
|
||||
rwLock.Lock()
|
||||
defer rwLock.Unlock()
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), " rpc args: ", uid, platformID, token)
|
||||
switch config.Config.MultiLoginPolicy {
|
||||
case constant.PCAndOther:
|
||||
if constant.PlatformNameToClass(constant.PlatformIDToName(platformID)) == constant.TerminalPC {
|
||||
return
|
||||
}
|
||||
fallthrough
|
||||
case constant.AllLoginButSameTermKick:
|
||||
if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn]
|
||||
if oldConn, ok := oldConnMap[platformID]; ok {
|
||||
@ -192,11 +202,16 @@ 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.PCAndOther:
|
||||
if constant.PlatformNameToClass(constant.PlatformIDToName(platformID)) == constant.TerminalPC {
|
||||
return
|
||||
}
|
||||
fallthrough
|
||||
case constant.AllLoginButSameTermKick:
|
||||
if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn]
|
||||
if oldConn, ok := oldConnMap[platformID]; ok {
|
||||
log.NewDebug(operationID, uid, platformID, "kick old conn")
|
||||
// ws.sendKickMsg(oldConn, newConn)
|
||||
ws.sendKickMsg(oldConn, newConn)
|
||||
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))
|
||||
@ -229,8 +244,12 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn
|
||||
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)
|
||||
}
|
||||
} else {
|
||||
log.NewWarn(operationID, "abnormal uid-conn ", uid, platformID, oldConnMap[platformID])
|
||||
log.Debug(operationID, "normal uid-conn ", uid, platformID, oldConnMap[platformID])
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -263,12 +282,12 @@ func (ws *WServer) sendKickMsg(oldConn, newConn *UserConn) {
|
||||
func (ws *WServer) addUserConn(uid string, platformID int, conn *UserConn, token string, operationID string) {
|
||||
rwLock.Lock()
|
||||
defer rwLock.Unlock()
|
||||
log.Info(operationID, utils.GetSelfFuncName(), " args: ", uid, platformID, conn, token)
|
||||
log.Info(operationID, utils.GetSelfFuncName(), " args: ", uid, platformID, conn, token, "ip: ", conn.RemoteAddr().String())
|
||||
callbackResp := callbackUserOnline(operationID, uid, platformID, token)
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "callbackUserOnline resp:", callbackResp)
|
||||
}
|
||||
//go ws.MultiTerminalLoginRemoteChecker(uid, int32(platformID), token, operationID)
|
||||
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
|
||||
|
@ -36,8 +36,8 @@ var (
|
||||
func Init() {
|
||||
cmdCh = make(chan Cmd2Value, 10000)
|
||||
w = new(sync.Mutex)
|
||||
persistentCH.Init()
|
||||
historyCH.Init(cmdCh)
|
||||
persistentCH.Init() // 订阅ws2mschat 消费到 mysql
|
||||
historyCH.Init(cmdCh) // 订阅ws2mschat 如果可靠性存储 消费到 incrseq 再存入mongo 再push || 非可靠性 直接incr再push 初始化ws2mschat
|
||||
historyMongoCH.Init()
|
||||
onlineTopicStatus = OnlineTopicVacancy
|
||||
//offlineHistoryCH.Init(cmdCh)
|
||||
|
@ -407,7 +407,7 @@ func (och *OnlineHistoryRedisConsumerHandler) ConsumeClaim(sess sarama.ConsumerG
|
||||
rwLock.Unlock()
|
||||
split := 1000
|
||||
triggerID = utils.OperationIDGenerator()
|
||||
log.NewWarn(triggerID, "timer trigger msg consumer start", len(ccMsg))
|
||||
log.Debug(triggerID, "timer trigger msg consumer start", len(ccMsg))
|
||||
for i := 0; i < len(ccMsg)/split; i++ {
|
||||
//log.Debug()
|
||||
och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{
|
||||
@ -419,9 +419,8 @@ func (och *OnlineHistoryRedisConsumerHandler) ConsumeClaim(sess sarama.ConsumerG
|
||||
}
|
||||
//sess.MarkMessage(ccMsg[len(cMsg)-1], "")
|
||||
|
||||
log.NewWarn(triggerID, "timer trigger msg consumer end", len(cMsg))
|
||||
log.Debug(triggerID, "timer trigger msg consumer end", len(cMsg))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -519,7 +518,7 @@ func sendMessageToPush(message *pbMsg.MsgDataToMQ, pushToUserID string) {
|
||||
log.Info(message.OperationID, "msg_transfer send message to push", "message", message.String())
|
||||
rpcPushMsg := pbPush.PushMsgReq{OperationID: message.OperationID, MsgData: message.MsgData, PushToUserID: pushToUserID}
|
||||
mqPushMsg := pbMsg.PushMsgDataToMQ{OperationID: message.OperationID, MsgData: message.MsgData, PushToUserID: pushToUserID}
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImPushName, message.OperationID)
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImPushName, message.OperationID)
|
||||
if grpcConn == nil {
|
||||
log.Error(rpcPushMsg.OperationID, "rpc dial failed", "push data", rpcPushMsg.String())
|
||||
pid, offset, err := producer.SendMessage(&mqPushMsg, mqPushMsg.PushToUserID, rpcPushMsg.OperationID)
|
||||
|
@ -34,6 +34,7 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(cMsg *sarama.Con
|
||||
log.Error("msg_transfer Unmarshal msg err", "", "msg", string(msg), "err", err.Error())
|
||||
return
|
||||
}
|
||||
log.Info(msgFromMQ.TriggerID, "BatchInsertChat2DB userID: ", msgFromMQ.AggregationID, "msgFromMQ.LastSeq: ", msgFromMQ.LastSeq)
|
||||
err = db.DB.BatchInsertChat2DB(msgFromMQ.AggregationID, msgFromMQ.MessageList, msgFromMQ.TriggerID, msgFromMQ.LastSeq)
|
||||
if err != nil {
|
||||
log.NewError(msgFromMQ.TriggerID, "single data insert to mongo err", err.Error(), msgFromMQ.MessageList, msgFromMQ.AggregationID, msgFromMQ.TriggerID)
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/tools"
|
||||
"Open_IM/pkg/tools/splitter"
|
||||
"context"
|
||||
firebase "firebase.google.com/go"
|
||||
"firebase.google.com/go/messaging"
|
||||
@ -62,7 +62,7 @@ func (f *Fcm) Push(accounts []string, alert, detailContent, operationID string,
|
||||
}
|
||||
Success := 0
|
||||
Fail := 0
|
||||
result := tools.NewSplitter(SinglePushCountLimit, Tokens).GetSplitResult()
|
||||
result := splitter.NewSplitter(SinglePushCountLimit, Tokens).GetSplitResult()
|
||||
Msg := new(messaging.MulticastMessage)
|
||||
Msg.Notification = &messaging.Notification{}
|
||||
Msg.Notification.Body = detailContent
|
||||
|
@ -83,6 +83,7 @@ type Alert struct {
|
||||
type Android struct {
|
||||
Ups struct {
|
||||
Notification Notification `json:"notification"`
|
||||
Options Options `json:"options"`
|
||||
} `json:"ups"`
|
||||
}
|
||||
|
||||
@ -92,6 +93,18 @@ type Notification struct {
|
||||
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:""`
|
||||
}
|
||||
|
||||
type PushResp struct {
|
||||
}
|
||||
|
||||
@ -120,7 +133,7 @@ func (g *Getui) Push(userIDList []string, alert, detailContent, operationID stri
|
||||
}
|
||||
pushReq.PushMessage.Notification = Notification{
|
||||
Title: alert,
|
||||
Body: alert,
|
||||
Body: detailContent,
|
||||
ClickType: "startapp",
|
||||
}
|
||||
pushReq.PushChannel.Ios.Aps.Sound = "default"
|
||||
@ -133,6 +146,17 @@ func (g *Getui) Push(userIDList []string, alert, detailContent, operationID stri
|
||||
Body: alert,
|
||||
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"},
|
||||
}
|
||||
pushResp := PushResp{}
|
||||
err = g.request(PushURL, pushReq, token, &pushResp, operationID)
|
||||
switch err {
|
||||
@ -179,7 +203,7 @@ func (g *Getui) request(url string, content interface{}, token string, returnStr
|
||||
return err
|
||||
}
|
||||
client := &http.Client{}
|
||||
log.Debug(operationID, utils.GetSelfFuncName(), "json:", string(con))
|
||||
log.Debug(operationID, utils.GetSelfFuncName(), "json:", string(con), "token:", token)
|
||||
req, err := http.NewRequest("POST", config.Config.Push.Getui.PushUrl+url, bytes.NewBuffer(con))
|
||||
if err != nil {
|
||||
return err
|
||||
@ -197,7 +221,7 @@ func (g *Getui) request(url string, content interface{}, token string, returnStr
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.NewInfo(operationID, "getui", utils.GetSelfFuncName(), "resp, ", string(result))
|
||||
log.NewDebug(operationID, "getui", utils.GetSelfFuncName(), "resp, ", string(result))
|
||||
commonResp := GetuiCommonResp{}
|
||||
commonResp.Data = returnStruct
|
||||
if err := json.Unmarshal(result, &commonResp); err != nil {
|
||||
|
@ -2,6 +2,7 @@ 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"
|
||||
@ -11,7 +12,7 @@ import (
|
||||
http2 "net/http"
|
||||
)
|
||||
|
||||
func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.MsgData, offlinePushUserIDList *[]string) cbApi.CommonCallbackResp {
|
||||
func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.MsgData, offlinePushUserIDList *[]string, offlineInfo *commonPb.OfflinePushInfo) cbApi.CommonCallbackResp {
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackOfflinePush.Enable {
|
||||
return callbackResp
|
||||
@ -32,7 +33,7 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.
|
||||
ContentType: msg.ContentType,
|
||||
SessionType: msg.SessionType,
|
||||
AtUserIDList: msg.AtUserIDList,
|
||||
Content: string(msg.Content),
|
||||
Content: callback.GetContent(msg),
|
||||
}
|
||||
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
|
||||
@ -46,9 +47,14 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.
|
||||
return callbackResp
|
||||
}
|
||||
}
|
||||
if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow && len(resp.UserIDList) != 0 {
|
||||
if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow {
|
||||
if len(resp.UserIDList) != 0 {
|
||||
*offlinePushUserIDList = resp.UserIDList
|
||||
}
|
||||
if resp.OfflinePushInfo != nil {
|
||||
*offlineInfo = *resp.OfflinePushInfo
|
||||
}
|
||||
}
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), offlinePushUserIDList, resp.UserIDList)
|
||||
return callbackResp
|
||||
}
|
||||
@ -74,7 +80,7 @@ func callbackOnlinePush(operationID string, userIDList []string, msg *commonPb.M
|
||||
ContentType: msg.ContentType,
|
||||
SessionType: msg.SessionType,
|
||||
AtUserIDList: msg.AtUserIDList,
|
||||
Content: string(msg.Content),
|
||||
Content: callback.GetContent(msg),
|
||||
}
|
||||
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackOnlinePush.CallbackTimeOut); err != nil {
|
||||
@ -92,6 +98,7 @@ func callbackOnlinePush(operationID string, userIDList []string, msg *commonPb.M
|
||||
}
|
||||
|
||||
func callbackBeforeSuperGroupOnlinePush(operationID string, groupID string, msg *commonPb.MsgData, pushToUserList *[]string) cbApi.CommonCallbackResp {
|
||||
log.Debug(operationID, utils.GetSelfFuncName(), groupID, msg.String(), pushToUserList)
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.Enable {
|
||||
return callbackResp
|
||||
@ -109,7 +116,7 @@ func callbackBeforeSuperGroupOnlinePush(operationID string, groupID string, msg
|
||||
ContentType: msg.ContentType,
|
||||
SessionType: msg.SessionType,
|
||||
AtUserIDList: msg.AtUserIDList,
|
||||
Content: string(msg.Content),
|
||||
Content: callback.GetContent(msg),
|
||||
}
|
||||
resp := &cbApi.CallbackBeforeSuperGroupOnlinePushResp{CommonCallbackResp: &callbackResp}
|
||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackTimeOut); err != nil {
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
@ -43,6 +44,11 @@ func (ms *PushConsumerHandler) handleMs2PsChat(msg []byte) {
|
||||
MsgData: msgFromMQ.MsgData,
|
||||
PushToUserID: msgFromMQ.PushToUserID,
|
||||
}
|
||||
sec := msgFromMQ.MsgData.SendTime / 1000
|
||||
nowSec := utils.GetCurrentTimestampBySecond()
|
||||
if nowSec-sec > 10 {
|
||||
return
|
||||
}
|
||||
switch msgFromMQ.MsgData.SessionType {
|
||||
case constant.SuperGroupChatType:
|
||||
MsgToSuperGroupUser(pbData)
|
||||
@ -59,6 +65,7 @@ func (ms *PushConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
|
||||
for msg := range claim.Messages() {
|
||||
log.NewDebug("", "kafka get info to mysql", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
|
||||
ms.msgHandle[msg.Topic](msg.Value)
|
||||
sess.MarkMessage(msg, "")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -17,12 +17,13 @@ import (
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
pbRtc "Open_IM/pkg/proto/rtc"
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/grpc"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
type OpenIMContent struct {
|
||||
@ -37,16 +38,13 @@ type AtContent struct {
|
||||
IsAtSelf bool `json:"isAtSelf"`
|
||||
}
|
||||
|
||||
var grpcCons []*grpc.ClientConn
|
||||
//var grpcCons []*grpc.ClientConn
|
||||
|
||||
func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
var wsResult []*pbRelay.SingelMsgToUserResultList
|
||||
isOfflinePush := utils.GetSwitchFromOptions(pushMsg.MsgData.Options, constant.IsOfflinePush)
|
||||
log.Debug(pushMsg.OperationID, "Get msg from msg_transfer And push msg", pushMsg.String())
|
||||
if len(grpcCons) == 0 {
|
||||
log.NewWarn(pushMsg.OperationID, "first GetConn4Unique ")
|
||||
grpcCons = getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRelayName)
|
||||
}
|
||||
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), pushMsg.OperationID)
|
||||
|
||||
var UIDList = []string{pushMsg.PushToUserID}
|
||||
callbackResp := callbackOnlinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData)
|
||||
@ -98,8 +96,9 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
var content string
|
||||
if pushMsg.MsgData.OfflinePushInfo != nil {
|
||||
content = pushMsg.MsgData.OfflinePushInfo.Title
|
||||
|
||||
} else {
|
||||
jsonCustomContent = pushMsg.MsgData.OfflinePushInfo.Desc
|
||||
}
|
||||
if content == "" {
|
||||
switch pushMsg.MsgData.ContentType {
|
||||
case constant.Text:
|
||||
content = constant.ContentType2PushContent[constant.Text]
|
||||
@ -126,8 +125,8 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData, &[]string{})
|
||||
var offlineInfo commonPb.OfflinePushInfo
|
||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData, &[]string{}, &offlineInfo)
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
||||
@ -136,6 +135,12 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop")
|
||||
return
|
||||
}
|
||||
if offlineInfo.Title != "" {
|
||||
content = offlineInfo.Title
|
||||
}
|
||||
if offlineInfo.Desc != "" {
|
||||
jsonCustomContent = offlineInfo.Desc
|
||||
}
|
||||
if offlinePusher == nil {
|
||||
return
|
||||
}
|
||||
@ -156,7 +161,7 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
||||
var wsResult []*pbRelay.SingelMsgToUserResultList
|
||||
isOfflinePush := utils.GetSwitchFromOptions(pushMsg.MsgData.Options, constant.IsOfflinePush)
|
||||
log.Debug(pushMsg.OperationID, "Get super group msg from msg_transfer And push msg", pushMsg.String())
|
||||
log.Debug(pushMsg.OperationID, "Get super group msg from msg_transfer And push msg", pushMsg.String(), config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.Enable)
|
||||
var pushToUserIDList []string
|
||||
if config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.Enable {
|
||||
callbackResp := callbackBeforeSuperGroupOnlinePush(pushMsg.OperationID, pushMsg.PushToUserID, pushMsg.MsgData, &pushToUserIDList)
|
||||
@ -172,9 +177,9 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
||||
}
|
||||
if len(pushToUserIDList) == 0 {
|
||||
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pushMsg.OperationID, GroupID: pushMsg.MsgData.GroupID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, pushMsg.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, pushMsg.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := pushMsg.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := pushMsg.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(pushMsg.OperationID, errMsg)
|
||||
return
|
||||
}
|
||||
@ -191,13 +196,10 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
||||
pushToUserIDList = cacheResp.UserIDList
|
||||
}
|
||||
|
||||
if len(grpcCons) == 0 {
|
||||
log.NewWarn(pushMsg.OperationID, "first GetConn4Unique ")
|
||||
grpcCons = getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRelayName)
|
||||
}
|
||||
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), pushMsg.OperationID)
|
||||
|
||||
//Online push message
|
||||
log.Debug("test", pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String())
|
||||
log.Debug(pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String())
|
||||
for _, v := range grpcCons {
|
||||
msgClient := pbRelay.NewRelayClient(v)
|
||||
reply, err := msgClient.SuperGroupOnlineBatchPushOneMsg(context.Background(), &pbRelay.OnlineBatchPushOneMsgReq{OperationID: pushMsg.OperationID, MsgData: pushMsg.MsgData, PushToUserIDList: pushToUserIDList})
|
||||
@ -232,6 +234,7 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
||||
var content string
|
||||
if pushMsg.MsgData.OfflinePushInfo != nil {
|
||||
content = pushMsg.MsgData.OfflinePushInfo.Title
|
||||
jsonCustomContent = pushMsg.MsgData.OfflinePushInfo.Desc
|
||||
|
||||
} else {
|
||||
switch pushMsg.MsgData.ContentType {
|
||||
@ -263,7 +266,8 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
||||
if len(onlineFailedUserIDList) > 0 {
|
||||
var offlinePushUserIDList []string
|
||||
var needOfflinePushUserIDList []string
|
||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, onlineFailedUserIDList, pushMsg.MsgData, &offlinePushUserIDList)
|
||||
var offlineInfo commonPb.OfflinePushInfo
|
||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, onlineFailedUserIDList, pushMsg.MsgData, &offlinePushUserIDList, &offlineInfo)
|
||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
||||
@ -277,6 +281,12 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
||||
} else {
|
||||
needOfflinePushUserIDList = onlineFailedUserIDList
|
||||
}
|
||||
if offlineInfo.Title != "" {
|
||||
content = offlineInfo.Title
|
||||
}
|
||||
if offlineInfo.Desc != "" {
|
||||
jsonCustomContent = offlineInfo.Desc
|
||||
}
|
||||
if offlinePusher == nil {
|
||||
return
|
||||
}
|
||||
@ -321,7 +331,7 @@ func GetOfflinePushOpts(pushMsg *pbPush.PushMsgReq) (opts push.PushOpts, err err
|
||||
// sendMsgToKafka(m, m.SendID, "msgKey--sendID")
|
||||
// sendMsgToKafka(m, m.RecvID, "msgKey--recvID")
|
||||
// case constant.GroupChatType:
|
||||
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
// etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
// client := pbGroup.NewGroupClient(etcdConn)
|
||||
// req := &pbGroup.Req{
|
||||
// GroupID: m.RecvID,
|
||||
|
@ -3,11 +3,13 @@ package admin_cms
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
openIMHttp "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAdminCMS "Open_IM/pkg/proto/admin_cms"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net"
|
||||
@ -100,3 +102,55 @@ func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLogi
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) AddUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.AddUserRegisterAddFriendIDListReq) (*pbAdminCMS.AddUserRegisterAddFriendIDListResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbAdminCMS.AddUserRegisterAddFriendIDListResp{}
|
||||
if err := imdb.AddUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) ReduceUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.ReduceUserRegisterAddFriendIDListReq) (*pbAdminCMS.ReduceUserRegisterAddFriendIDListResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbAdminCMS.ReduceUserRegisterAddFriendIDListResp{}
|
||||
if req.Operation == 0 {
|
||||
if err := imdb.ReduceUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
||||
}
|
||||
} else {
|
||||
if err := imdb.DeleteAllRegisterAddFriendIDList(); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
||||
}
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) GetUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.GetUserRegisterAddFriendIDListReq) (*pbAdminCMS.GetUserRegisterAddFriendIDListResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbAdminCMS.GetUserRegisterAddFriendIDListResp{UserInfoList: []*server_api_params.UserInfo{}}
|
||||
userIDList, err := imdb.GetRegisterAddFriendList(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
||||
}
|
||||
userList, err := imdb.GetUsersByUserIDList(userIDList)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userIDList)
|
||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), userList, userIDList)
|
||||
resp.Pagination = &server_api_params.ResponsePagination{
|
||||
CurrentPage: req.Pagination.PageNumber,
|
||||
ShowNumber: req.Pagination.ShowNumber,
|
||||
}
|
||||
utils.CopyStructFields(&resp.UserInfoList, userList)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -29,8 +29,18 @@ func (rpc *rpcAuth) UserRegister(_ context.Context, req *pbAuth.UserRegisterReq)
|
||||
user.Birth = utils.UnixSecondToTime(int64(req.UserInfo.Birth))
|
||||
}
|
||||
log.Debug(req.OperationID, "copy ", user, req.UserInfo)
|
||||
Limited, LimitError := imdb.IsLimitRegisterIp(req.UserInfo.CreateIp)
|
||||
if LimitError != nil {
|
||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: LimitError.Error()}}, nil
|
||||
}
|
||||
if Limited {
|
||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.RegisterLimit, ErrMsg: "Register Limit"}}, nil
|
||||
}
|
||||
err := imdb.UserRegister(user)
|
||||
if err != nil {
|
||||
if err == constant.InvitationMsg {
|
||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.InvitationError, ErrMsg: "邀请码错误"}}, nil
|
||||
}
|
||||
errMsg := req.OperationID + " imdb.UserRegister failed " + err.Error() + user.UserID
|
||||
log.NewError(req.OperationID, errMsg, user)
|
||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
||||
@ -67,11 +77,11 @@ func (rpc *rpcAuth) ForceLogout(_ context.Context, req *pbAuth.ForceLogoutReq) (
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbAuth.ForceLogoutResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
if err := token_verify.DeleteToken(req.FromUserID, int(req.Platform)); err != nil {
|
||||
errMsg := req.OperationID + " DeleteToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbAuth.ForceLogoutResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
//if err := token_verify.DeleteToken(req.FromUserID, int(req.Platform)); err != nil {
|
||||
// errMsg := req.OperationID + " DeleteToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
|
||||
// log.NewError(req.OperationID, errMsg)
|
||||
// return &pbAuth.ForceLogoutResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
||||
//}
|
||||
if err := rpc.forceKickOff(req.FromUserID, req.Platform, req.OperationID); err != nil {
|
||||
errMsg := req.OperationID + " forceKickOff failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
@ -82,8 +92,8 @@ func (rpc *rpcAuth) ForceLogout(_ context.Context, req *pbAuth.ForceLogoutReq) (
|
||||
}
|
||||
|
||||
func (rpc *rpcAuth) forceKickOff(userID string, platformID int32, operationID string) error {
|
||||
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRelayName)
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), " args ", userID, platformID)
|
||||
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), operationID)
|
||||
for _, v := range grpcCons {
|
||||
client := pbRelay.NewRelayClient(v)
|
||||
kickReq := &pbRelay.KickUserOfflineReq{OperationID: operationID, KickUserIDList: []string{userID}, PlatformID: platformID}
|
||||
@ -91,7 +101,6 @@ func (rpc *rpcAuth) forceKickOff(userID string, platformID int32, operationID st
|
||||
_, err := client.KickUserOffline(context.Background(), kickReq)
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
return errors.New("no rpc node ")
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbConversation "Open_IM/pkg/proto/conversation"
|
||||
@ -30,6 +31,7 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbConversation.ModifyConversationFieldResp{}
|
||||
var err error
|
||||
isSyncConversation := true
|
||||
if req.Conversation.ConversationType == constant.GroupChatType {
|
||||
groupInfo, err := imdb.GetGroupInfoByGroupID(req.Conversation.GroupID)
|
||||
if err != nil {
|
||||
@ -37,7 +39,7 @@ 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 groupInfo.Status == constant.GroupStatusDismissed && !req.Conversation.IsNotInGroup {
|
||||
if groupInfo.Status == constant.GroupStatusDismissed && !req.Conversation.IsNotInGroup && req.FieldType != constant.FieldUnread {
|
||||
errMsg := "group status is dismissed"
|
||||
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}
|
||||
return resp, nil
|
||||
@ -71,8 +73,8 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
|
||||
case constant.FieldAttachedInfo:
|
||||
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"attached_info": conversation.AttachedInfo})
|
||||
case constant.FieldUnread:
|
||||
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"unread_count": conversation.UnreadCount})
|
||||
|
||||
isSyncConversation = false
|
||||
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"update_unread_count_time": utils.GetCurrentTimestampByMill()})
|
||||
}
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateColumnsConversations error", err.Error())
|
||||
@ -81,6 +83,11 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
|
||||
}
|
||||
for _, v := range utils.DifferenceString(haveUserID, req.UserIDList) {
|
||||
conversation.OwnerUserID = v
|
||||
conversation.UpdateUnreadCountTime = utils.GetCurrentTimestampByMill()
|
||||
err = rocksCache.DelUserConversationIDListFromCache(v)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
|
||||
}
|
||||
err := imdb.SetOneConversation(conversation)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
||||
@ -88,6 +95,7 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
|
||||
return resp, nil
|
||||
}
|
||||
}
|
||||
|
||||
// notification
|
||||
if req.Conversation.ConversationType == constant.SingleChatType && req.FieldType == constant.FieldIsPrivateChat {
|
||||
//sync peer user conversation if conversation is singleChatType
|
||||
@ -96,10 +104,24 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
|
||||
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
} else {
|
||||
if isSyncConversation {
|
||||
for _, v := range req.UserIDList {
|
||||
if err = rocksCache.DelConversationFromCache(v, req.Conversation.ConversationID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
|
||||
}
|
||||
chat.ConversationChangeNotification(req.OperationID, v)
|
||||
}
|
||||
} else {
|
||||
for _, v := range req.UserIDList {
|
||||
if err = rocksCache.DelConversationFromCache(v, req.Conversation.ConversationID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
|
||||
}
|
||||
chat.ConversationUnreadChangeNotification(req.OperationID, v, req.Conversation.ConversationID)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return", resp.String())
|
||||
resp.CommonResp = &pbConversation.CommonResp{}
|
||||
@ -125,6 +147,10 @@ func syncPeerUserConversation(conversation *pbConversation.Conversation, operati
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
||||
return err
|
||||
}
|
||||
err = rocksCache.DelConversationFromCache(conversation.UserID, utils.GetConversationIDBySessionType(conversation.OwnerUserID, constant.SingleChatType))
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "DelConversationFromCache failed", err.Error())
|
||||
}
|
||||
chat.ConversationSetPrivateNotification(operationID, conversation.OwnerUserID, conversation.UserID, conversation.IsPrivateChat)
|
||||
return nil
|
||||
}
|
||||
|
@ -100,9 +100,9 @@ func (s *friendServer) AddBlacklist(ctx context.Context, req *pbFriend.AddBlackl
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "AddBlacklist rpc ok ", req.CommID.FromUserID, req.CommID.ToUserID)
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
return &pbFriend.AddBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
@ -211,9 +211,9 @@ func (s *friendServer) ImportFriend(ctx context.Context, req *pbFriend.ImportFri
|
||||
}
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
resp.CommonResp.ErrMsg = errMsg
|
||||
resp.CommonResp.ErrCode = 500
|
||||
@ -315,9 +315,9 @@ func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddF
|
||||
}
|
||||
// cache rpc
|
||||
delFriendIDListFromCacheReq := &pbCache.DelFriendIDListFromCacheReq{OperationID: req.CommID.OperationID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
@ -378,9 +378,9 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFri
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "DeleteFriend rpc ok")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
return &pbFriend.DeleteFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
@ -473,9 +473,9 @@ func (s *friendServer) RemoveBlacklist(ctx context.Context, req *pbFriend.Remove
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "rpc RemoveBlacklist ok ")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
return &pbFriend.RemoveBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
|
@ -61,7 +61,13 @@ func (s *groupServer) Run() {
|
||||
log.NewInfo("", "listen network success, ", address, listener)
|
||||
defer listener.Close()
|
||||
//grpc server
|
||||
srv := grpc.NewServer()
|
||||
recvSize := 1024 * 1024 * constant.GroupRPCRecvSize
|
||||
sendSize := 1024 * 1024 * constant.GroupRPCSendSize
|
||||
var options = []grpc.ServerOption{
|
||||
grpc.MaxRecvMsgSize(recvSize),
|
||||
grpc.MaxSendMsgSize(sendSize),
|
||||
}
|
||||
srv := grpc.NewServer(options...)
|
||||
defer srv.GracefulStop()
|
||||
//Service registers with etcd
|
||||
pbGroup.RegisterGroupServer(srv, s)
|
||||
@ -138,7 +144,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
if req.GroupInfo.GroupType != constant.SuperGroup {
|
||||
//to group member
|
||||
for _, user := range req.InitMemberList {
|
||||
us, err := imdb.GetUserByUserID(user.UserID)
|
||||
us, err := rocksCache.GetUserInfoFromCache(user.UserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), user.UserID)
|
||||
continue
|
||||
@ -158,7 +164,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
}
|
||||
okUserIDList = append(okUserIDList, user.UserID)
|
||||
}
|
||||
group, err := imdb.GetGroupInfoByGroupID(groupId)
|
||||
group, err := rocksCache.GetGroupInfoFromCache(groupId)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", err.Error(), groupId)
|
||||
resp.ErrCode = constant.ErrDB.ErrCode
|
||||
@ -166,7 +172,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
return resp, nil
|
||||
}
|
||||
utils.CopyStructFields(resp.GroupInfo, group)
|
||||
memberCount, err := imdb.GetGroupMemberNumByGroupID(groupId)
|
||||
memberCount, err := rocksCache.GetGroupMemberNumFromCache(groupId)
|
||||
resp.GroupInfo.MemberCount = uint32(memberCount)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupMemberNumByGroupID failed ", err.Error(), groupId)
|
||||
@ -235,7 +241,7 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
||||
var resp pbGroup.GetJoinedGroupListResp
|
||||
for _, v := range joinedGroupList {
|
||||
var groupNode open_im_sdk.GroupInfo
|
||||
num, err := imdb.GetGroupMemberNumByGroupID(v)
|
||||
num, err := rocksCache.GetGroupMemberNumFromCache(v)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), v)
|
||||
continue
|
||||
@ -250,6 +256,9 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), v)
|
||||
continue
|
||||
}
|
||||
if group.GroupType == constant.SuperGroup {
|
||||
continue
|
||||
}
|
||||
if group.Status == constant.GroupStatusDismissed {
|
||||
log.NewError(req.OperationID, "constant.GroupStatusDismissed ", group)
|
||||
continue
|
||||
@ -375,7 +384,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
haveConUserID = append(haveConUserID, v.OwnerUserID)
|
||||
}
|
||||
var reqPb pbUser.SetConversationReq
|
||||
var c pbUser.Conversation
|
||||
var c pbConversation.Conversation
|
||||
for _, v := range conversations {
|
||||
reqPb.OperationID = req.OperationID
|
||||
c.OwnerUserID = v.OwnerUserID
|
||||
@ -390,9 +399,9 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
c.IsNotInGroup = false
|
||||
c.Ex = v.Ex
|
||||
reqPb.Conversation = &c
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}, nil
|
||||
}
|
||||
@ -412,9 +421,9 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
c.GroupID = req.GroupID
|
||||
c.IsNotInGroup = false
|
||||
reqPb.Conversation = &c
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}, nil
|
||||
}
|
||||
@ -434,9 +443,9 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
}
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}, nil
|
||||
}
|
||||
@ -453,7 +462,12 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||
}
|
||||
|
||||
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
|
||||
}
|
||||
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
for _, userID := range okUserIDList {
|
||||
err = rocksCache.DelJoinedGroupIDListFromCache(userID)
|
||||
@ -461,9 +475,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userID)
|
||||
}
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
|
||||
chat.MemberInvitedNotification(req.OperationID, req.GroupID, req.OpUserID, req.Reason, okUserIDList)
|
||||
} else {
|
||||
for _, v := range req.InvitedUserIDList {
|
||||
@ -485,7 +497,6 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
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
|
||||
//groupInfo, err := imdb.GetGroupInfoByGroupID(req.GroupID)
|
||||
groupInfo, err := rocksCache.GetGroupInfoFromCache(req.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
@ -494,7 +505,7 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
|
||||
return &resp, nil
|
||||
}
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
memberList, err := rocksCache.GetAllGroupMembersInfoFromCache(req.GroupID)
|
||||
memberList, err := rocksCache.GetGroupMembersInfoFromCache(req.Count, req.Offset, req.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
resp.ErrCode = constant.ErrDB.ErrCode
|
||||
@ -507,7 +518,7 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
|
||||
resp.MemberList = append(resp.MemberList, &node)
|
||||
}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember rpc return ", resp.String())
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember rpc return ", len(resp.MemberList))
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
@ -560,7 +571,7 @@ func (s *groupServer) getGroupUserLevel(groupID, userID string) (int, error) {
|
||||
|
||||
func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGroupMemberReq) (*pbGroup.KickGroupMemberResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
||||
groupInfo, err := imdb.GetGroupInfoByGroupID(req.GroupID)
|
||||
groupInfo, err := rocksCache.GetGroupInfoFromCache(req.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupInfoByGroupID", req.GroupID, err.Error())
|
||||
return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||
@ -570,7 +581,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
opFlag := 0
|
||||
if !token_verify.IsManagerUserID(req.OpUserID) {
|
||||
opInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.OpUserID)
|
||||
opInfo, err := rocksCache.GetGroupMemberInfoFromCache(req.GroupID, req.OpUserID)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " GetGroupMemberInfoByGroupIDAndUserID failed " + err.Error() + req.GroupID + req.OpUserID
|
||||
log.Error(req.OperationID, errMsg)
|
||||
@ -597,7 +608,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
|
||||
//remove
|
||||
for _, v := range req.KickedUserIDList {
|
||||
kickedInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, v)
|
||||
kickedInfo, err := rocksCache.GetGroupMemberInfoFromCache(req.GroupID, v)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, " GetGroupMemberInfoByGroupIDAndUserID failed ", req.GroupID, v, err.Error())
|
||||
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: -1})
|
||||
@ -615,7 +626,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
continue
|
||||
}
|
||||
|
||||
err = imdb.RemoveGroupMember(req.GroupID, v)
|
||||
err = imdb.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, v)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "RemoveGroupMember failed ", err.Error(), req.GroupID, v)
|
||||
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: -1})
|
||||
@ -626,7 +637,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
}
|
||||
}
|
||||
var reqPb pbUser.SetConversationReq
|
||||
var c pbUser.Conversation
|
||||
var c pbConversation.Conversation
|
||||
for _, v := range okUserIDList {
|
||||
reqPb.OperationID = req.OperationID
|
||||
c.OwnerUserID = v
|
||||
@ -635,9 +646,9 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
c.GroupID = req.GroupID
|
||||
c.IsNotInGroup = true
|
||||
reqPb.Conversation = &c
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
resp.ErrCode = constant.ErrInternal.ErrCode
|
||||
resp.ErrMsg = errMsg
|
||||
@ -661,9 +672,9 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
}
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}, nil
|
||||
}
|
||||
@ -680,6 +691,9 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||
}
|
||||
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
|
||||
}
|
||||
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
for _, userID := range okUserIDList {
|
||||
@ -687,8 +701,11 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userID)
|
||||
}
|
||||
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, userID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
}
|
||||
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
chat.MemberKickedNotification(req, okUserIDList)
|
||||
@ -715,21 +732,34 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
|
||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
|
||||
var resp pbGroup.GetGroupMembersInfoResp
|
||||
resp.MemberList = []*open_im_sdk.GroupMemberFullInfo{}
|
||||
groupMembers, err := rocksCache.GetAllGroupMembersInfoFromCache(req.GroupID)
|
||||
|
||||
for _, userID := range req.MemberList {
|
||||
groupMember, err := rocksCache.GetGroupMemberInfoFromCache(req.GroupID, userID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
|
||||
resp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
return &resp, nil
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, userID, err.Error())
|
||||
continue
|
||||
}
|
||||
for _, member := range groupMembers {
|
||||
if utils.IsContain(member.UserID, req.MemberList) {
|
||||
var memberNode open_im_sdk.GroupMemberFullInfo
|
||||
utils.CopyStructFields(&memberNode, member)
|
||||
memberNode.JoinTime = int32(member.JoinTime.Unix())
|
||||
utils.CopyStructFields(&memberNode, groupMember)
|
||||
memberNode.JoinTime = int32(groupMember.JoinTime.Unix())
|
||||
resp.MemberList = append(resp.MemberList, &memberNode)
|
||||
}
|
||||
}
|
||||
|
||||
//groupMembers, err := rocksCache.GetAllGroupMembersInfoFromCache(req.GroupID)
|
||||
//if err != nil {
|
||||
// log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
|
||||
// resp.ErrCode = constant.ErrDB.ErrCode
|
||||
// resp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
// return &resp, nil
|
||||
//}
|
||||
//for _, member := range groupMembers {
|
||||
// if utils.IsContain(member.UserID, req.MemberList) {
|
||||
// var memberNode open_im_sdk.GroupMemberFullInfo
|
||||
// utils.CopyStructFields(&memberNode, member)
|
||||
// memberNode.JoinTime = int32(member.JoinTime.Unix())
|
||||
// resp.MemberList = append(resp.MemberList, &memberNode)
|
||||
// }
|
||||
//}
|
||||
|
||||
resp.ErrCode = 0
|
||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo rpc return ", resp.String())
|
||||
@ -840,7 +870,7 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
|
||||
}
|
||||
var reqPb pbUser.SetConversationReq
|
||||
reqPb.OperationID = req.OperationID
|
||||
var c pbUser.Conversation
|
||||
var c pbConversation.Conversation
|
||||
conversation, err := imdb.GetConversation(req.FromUserID, utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType))
|
||||
if err != nil {
|
||||
c.OwnerUserID = req.FromUserID
|
||||
@ -862,9 +892,9 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
|
||||
c.Ex = conversation.Ex
|
||||
}
|
||||
reqPb.Conversation = &c
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
@ -876,9 +906,9 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String())
|
||||
}
|
||||
|
||||
etcdCacheConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdCacheConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdCacheConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
@ -892,19 +922,15 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
|
||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
group, err := rocksCache.GetGroupInfoFromCache(req.GroupID)
|
||||
if err != nil {
|
||||
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
|
||||
}
|
||||
if group != nil {
|
||||
if group.GroupType != constant.SuperGroup {
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
if err := rocksCache.DelJoinedGroupIDListFromCache(req.FromUserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.FromUserID, err.Error())
|
||||
}
|
||||
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chat.GroupApplicationAcceptedNotification(req)
|
||||
chat.MemberEnterNotification(req)
|
||||
} else if req.HandleResult == constant.GroupResponseRefuse {
|
||||
@ -951,9 +977,9 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember)
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: constant.ErrInternal.ErrMsg}}, nil
|
||||
}
|
||||
@ -970,22 +996,16 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
//for _, userID := range okUserIDList {
|
||||
// err = rocksCache.DelJoinedGroupIDListFromCache(userID)
|
||||
// if err != nil {
|
||||
// log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userID)
|
||||
// }
|
||||
//}
|
||||
err = rocksCache.DelJoinedGroupIDListFromCache(req.OpUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
|
||||
err = rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
|
||||
}
|
||||
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
|
||||
chat.MemberEnterDirectlyNotification(req.GroupID, req.OpUserID, req.OperationID)
|
||||
log.NewInfo(req.OperationID, "JoinGroup rpc return ")
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||
@ -1044,7 +1064,7 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
||||
}
|
||||
//modify quitter conversation info
|
||||
var reqPb pbUser.SetConversationReq
|
||||
var c pbUser.Conversation
|
||||
var c pbConversation.Conversation
|
||||
reqPb.OperationID = req.OperationID
|
||||
c.OwnerUserID = req.OpUserID
|
||||
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType)
|
||||
@ -1052,9 +1072,9 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
||||
c.GroupID = req.GroupID
|
||||
c.IsNotInGroup = true
|
||||
reqPb.Conversation = &c
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
@ -1073,9 +1093,9 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
||||
}
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: constant.ErrInternal.ErrMsg}}, nil
|
||||
}
|
||||
@ -1092,14 +1112,19 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
|
||||
}
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
if err := rocksCache.DelJoinedGroupIDListFromCache(req.OpUserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.OpUserID)
|
||||
}
|
||||
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.OpUserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
chat.MemberQuitNotification(req)
|
||||
} else {
|
||||
if err := rocksCache.DelJoinedSuperGroupIDListFromCache(req.OpUserID); err != nil {
|
||||
@ -1223,9 +1248,9 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
if req.GroupInfoForSet.Notification != "" {
|
||||
//get group member user id
|
||||
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: req.OperationID, GroupID: req.GroupInfoForSet.GroupID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, http.WrapError(constant.ErrInternal)
|
||||
}
|
||||
@ -1252,9 +1277,9 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
conversationReq.FieldType = constant.FieldGroupAtType
|
||||
conversation.GroupAtType = constant.GroupNotification
|
||||
conversationReq.UserIDList = cacheResp.UserIDList
|
||||
nEtcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, req.OperationID)
|
||||
nEtcdConn := 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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, http.WrapError(constant.ErrInternal)
|
||||
}
|
||||
@ -1298,43 +1323,46 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe
|
||||
log.NewError(req.OperationID, "UpdateGroupMemberInfo failed ", groupMemberInfo)
|
||||
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, err.Error())
|
||||
err = rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.NewOwnerUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "DelGroupMemberInfoFromCache failed ", req.GroupID, req.NewOwnerUserID)
|
||||
}
|
||||
err = rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.OldOwnerUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "DelGroupMemberInfoFromCache failed ", req.GroupID, req.OldOwnerUserID)
|
||||
}
|
||||
chat.GroupOwnerTransferredNotification(req)
|
||||
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupById(_ context.Context, req *pbGroup.GetGroupByIdReq) (*pbGroup.GetGroupByIdResp, error) {
|
||||
func (s *groupServer) GetGroupByID(_ context.Context, req *pbGroup.GetGroupByIDReq) (*pbGroup.GetGroupByIDResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbGroup.GetGroupByIdResp{CMSGroup: &pbGroup.CMSGroup{
|
||||
resp := &pbGroup.GetGroupByIDResp{CMSGroup: &pbGroup.CMSGroup{
|
||||
GroupInfo: &open_im_sdk.GroupInfo{},
|
||||
}}
|
||||
group, err := imdb.GetGroupById(req.GroupId)
|
||||
group, err := imdb.GetGroupInfoByGroupID(req.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupById error", err.Error())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
resp.CMSGroup.GroupInfo = &open_im_sdk.GroupInfo{
|
||||
GroupID: group.GroupID,
|
||||
GroupName: group.GroupName,
|
||||
FaceURL: group.FaceURL,
|
||||
OwnerUserID: group.CreatorUserID,
|
||||
MemberCount: 0,
|
||||
Status: group.Status,
|
||||
CreatorUserID: group.CreatorUserID,
|
||||
GroupType: group.GroupType,
|
||||
CreateTime: uint32(group.CreateTime.Unix()),
|
||||
}
|
||||
groupMember, err := imdb.GetGroupMaster(group.GroupID)
|
||||
utils.CopyStructFields(resp.CMSGroup.GroupInfo, group)
|
||||
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(group.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster", err.Error())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
resp.CMSGroup.GroupMasterName = groupMember.Nickname
|
||||
resp.CMSGroup.GroupMasterId = groupMember.UserID
|
||||
groupMemberNum, err := imdb.GetGroupMemberNumByGroupID(req.GroupID)
|
||||
if err == nil {
|
||||
resp.CMSGroup.GroupInfo.MemberCount = uint32(groupMemberNum)
|
||||
} else {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
resp.CMSGroup.GroupOwnerUserName = groupMember.Nickname
|
||||
resp.CMSGroup.GroupOwnerUserID = groupMember.UserID
|
||||
resp.CMSGroup.GroupInfo.CreatorUserID = group.CreatorUserID
|
||||
resp.CMSGroup.GroupInfo.CreateTime = uint32(group.CreateTime.Unix())
|
||||
utils.CopyStructFields(resp.CMSGroup.GroupInfo, group)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
@ -1346,12 +1374,13 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
|
||||
}
|
||||
groups, err := imdb.GetGroupsByName(req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsByName error", req.String())
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsByName error", req.String(), req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "groups", groups)
|
||||
nums, err := imdb.GetGroupsCountNum(db.Group{GroupName: req.GroupName})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum error", err.Error())
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum error", err.Error(), req.GroupName)
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
resp.GroupNums = nums
|
||||
@ -1360,24 +1389,18 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
|
||||
ShowNumber: req.Pagination.ShowNumber,
|
||||
}
|
||||
for _, v := range groups {
|
||||
groupMember, err := imdb.GetGroupMaster(v.GroupID)
|
||||
group := &pbGroup.CMSGroup{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||
utils.CopyStructFields(group.GroupInfo, v)
|
||||
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(v.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster error", err.Error())
|
||||
continue
|
||||
}
|
||||
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{
|
||||
GroupInfo: &open_im_sdk.GroupInfo{
|
||||
GroupID: v.GroupID,
|
||||
GroupName: v.GroupName,
|
||||
FaceURL: v.FaceURL,
|
||||
OwnerUserID: v.CreatorUserID,
|
||||
Status: v.Status,
|
||||
CreatorUserID: v.CreatorUserID,
|
||||
CreateTime: uint32(v.CreateTime.Unix()),
|
||||
},
|
||||
GroupMasterName: groupMember.Nickname,
|
||||
GroupMasterId: groupMember.UserID,
|
||||
})
|
||||
|
||||
group.GroupInfo.CreateTime = uint32(v.CreateTime.Unix())
|
||||
group.GroupOwnerUserID = groupMember.UserID
|
||||
group.GroupOwnerUserName = groupMember.Nickname
|
||||
resp.CMSGroups = append(resp.CMSGroups, group)
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
@ -1394,78 +1417,49 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroups error", err.Error())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
groupsCountNum, err := imdb.GetGroupsCountNum(db.Group{})
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "groupsCountNum ", groupsCountNum)
|
||||
resp.GroupNum, err = imdb.GetGroupsCountNum(db.Group{})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum", err.Error())
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum error", err.Error())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
resp.GroupNum = int32(groupsCountNum)
|
||||
resp.Pagination.PageNumber = req.Pagination.PageNumber
|
||||
resp.Pagination.ShowNumber = req.Pagination.ShowNumber
|
||||
for _, v := range groups {
|
||||
groupMember, err := imdb.GetGroupMaster(v.GroupID)
|
||||
group := &pbGroup.CMSGroup{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||
utils.CopyStructFields(group.GroupInfo, v)
|
||||
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(v.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error(), v)
|
||||
continue
|
||||
}
|
||||
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{
|
||||
GroupInfo: &open_im_sdk.GroupInfo{
|
||||
GroupID: v.GroupID,
|
||||
GroupName: v.GroupName,
|
||||
FaceURL: v.FaceURL,
|
||||
OwnerUserID: v.CreatorUserID,
|
||||
Status: v.Status,
|
||||
CreatorUserID: v.CreatorUserID,
|
||||
CreateTime: uint32(v.CreateTime.Unix()),
|
||||
},
|
||||
GroupMasterId: groupMember.UserID,
|
||||
GroupMasterName: groupMember.Nickname,
|
||||
})
|
||||
group.GroupInfo.CreateTime = uint32(v.CreateTime.Unix())
|
||||
group.GroupOwnerUserID = groupMember.UserID
|
||||
group.GroupOwnerUserName = groupMember.Nickname
|
||||
resp.CMSGroups = append(resp.CMSGroups, group)
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) OperateGroupStatus(_ context.Context, req *pbGroup.OperateGroupStatusReq) (*pbGroup.OperateGroupStatusResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||
resp := &pbGroup.OperateGroupStatusResp{}
|
||||
if err := imdb.OperateGroupStatus(req.GroupId, req.Status); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus", err.Error())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) DeleteGroup(_ context.Context, req *pbGroup.DeleteGroupReq) (*pbGroup.DeleteGroupResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||
resp := &pbGroup.DeleteGroupResp{}
|
||||
if err := imdb.DeleteGroup(req.GroupId); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DeleteGroup error", err.Error())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) OperateUserRole(_ context.Context, req *pbGroup.OperateUserRoleReq) (*pbGroup.OperateUserRoleResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
||||
resp := &pbGroup.OperateUserRoleResp{}
|
||||
oldOwnerUserID, err := imdb.GetGroupMaster(req.GroupId)
|
||||
oldOwnerUserID, err := imdb.GetGroupOwnerInfoByGroupID(req.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return resp, http.WrapError(constant.ErrInternal)
|
||||
}
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
var reqPb pbGroup.TransferGroupOwnerReq
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.NewOwnerUserID = req.UserId
|
||||
reqPb.GroupID = req.GroupId
|
||||
reqPb.NewOwnerUserID = req.UserID
|
||||
reqPb.GroupID = req.GroupID
|
||||
reqPb.OpUserID = "cms admin"
|
||||
reqPb.OldOwnerUserID = oldOwnerUserID.UserID
|
||||
reply, err := client.TransferGroupOwner(context.Background(), &reqPb)
|
||||
@ -1481,12 +1475,12 @@ func (s *groupServer) OperateUserRole(_ context.Context, req *pbGroup.OperateUse
|
||||
func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
||||
resp := &pbGroup.GetGroupMembersCMSResp{}
|
||||
groupMembers, err := imdb.GetGroupMembersByGroupIdCMS(req.GroupId, req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||
groupMembers, err := imdb.GetGroupMembersByGroupIdCMS(req.GroupID, req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersByGroupIdCMS Error", err.Error())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
groupMembersCount, err := imdb.GetGroupMembersCount(req.GroupId, req.UserName)
|
||||
groupMembersCount, err := imdb.GetGroupMembersCount(req.GroupID, req.UserName)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS Error", err.Error())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
@ -1494,15 +1488,11 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
|
||||
log.NewInfo(req.OperationID, groupMembersCount)
|
||||
resp.MemberNums = int32(groupMembersCount)
|
||||
for _, groupMember := range groupMembers {
|
||||
resp.Members = append(resp.Members, &open_im_sdk.GroupMemberFullInfo{
|
||||
GroupID: req.GroupId,
|
||||
UserID: groupMember.UserID,
|
||||
RoleLevel: groupMember.RoleLevel,
|
||||
JoinTime: int32(groupMember.JoinTime.Unix()),
|
||||
Nickname: groupMember.Nickname,
|
||||
FaceURL: groupMember.FaceURL,
|
||||
JoinSource: groupMember.JoinSource,
|
||||
})
|
||||
member := open_im_sdk.GroupMemberFullInfo{}
|
||||
utils.CopyStructFields(&member, groupMember)
|
||||
member.JoinTime = int32(groupMember.JoinTime.Unix())
|
||||
member.MuteEndTime = uint32(groupMember.MuteEndTime.Unix())
|
||||
resp.Members = append(resp.Members, &member)
|
||||
}
|
||||
resp.Pagination = &open_im_sdk.ResponsePagination{
|
||||
CurrentPage: req.Pagination.PageNumber,
|
||||
@ -1515,8 +1505,8 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
|
||||
func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.RemoveGroupMembersCMSReq) (*pbGroup.RemoveGroupMembersCMSResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
||||
resp := &pbGroup.RemoveGroupMembersCMSResp{}
|
||||
for _, userId := range req.UserIds {
|
||||
err := imdb.RemoveGroupMember(req.GroupId, userId)
|
||||
for _, userId := range req.UserIDList {
|
||||
err := imdb.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, userId)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
resp.Failed = append(resp.Failed, userId)
|
||||
@ -1525,25 +1515,25 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo
|
||||
}
|
||||
}
|
||||
reqKick := &pbGroup.KickGroupMemberReq{
|
||||
GroupID: req.GroupId,
|
||||
GroupID: req.GroupID,
|
||||
KickedUserIDList: resp.Success,
|
||||
Reason: "admin kick",
|
||||
OperationID: req.OperationID,
|
||||
OpUserID: req.OpUserId,
|
||||
OpUserID: req.OpUserID,
|
||||
}
|
||||
var reqPb pbUser.SetConversationReq
|
||||
var c pbUser.Conversation
|
||||
var c pbConversation.Conversation
|
||||
for _, v := range resp.Success {
|
||||
reqPb.OperationID = req.OperationID
|
||||
c.OwnerUserID = v
|
||||
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupId, constant.GroupChatType)
|
||||
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType)
|
||||
c.ConversationType = constant.GroupChatType
|
||||
c.GroupID = req.GroupId
|
||||
c.GroupID = req.GroupID
|
||||
c.IsNotInGroup = true
|
||||
reqPb.Conversation = &c
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return resp, http.WrapError(constant.ErrInternal)
|
||||
}
|
||||
@ -1556,15 +1546,15 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo
|
||||
}
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
cacheClient := pbCache.NewCacheClient(etcdConn)
|
||||
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
|
||||
GroupID: req.GroupId,
|
||||
GroupID: req.GroupID,
|
||||
OperationID: req.OperationID,
|
||||
})
|
||||
if err != nil {
|
||||
@ -1575,8 +1565,17 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo
|
||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupId); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupId)
|
||||
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
|
||||
for _, userID := range resp.Success {
|
||||
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, userID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID, userID)
|
||||
}
|
||||
}
|
||||
|
||||
chat.MemberKickedNotification(reqKick, resp.Success)
|
||||
@ -1585,22 +1584,22 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo
|
||||
}
|
||||
|
||||
func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGroupMembersCMSReq) (*pbGroup.AddGroupMembersCMSResp, error) {
|
||||
log.NewInfo(req.OperationId, utils.GetSelfFuncName(), "args:", req.String())
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
||||
resp := &pbGroup.AddGroupMembersCMSResp{}
|
||||
for _, userId := range req.UserIds {
|
||||
if isExist := imdb.IsExistGroupMember(req.GroupId, userId); isExist {
|
||||
log.NewError(req.OperationId, utils.GetSelfFuncName(), "user is exist in group", userId, req.GroupId)
|
||||
for _, userId := range req.UserIDList {
|
||||
if isExist := imdb.IsExistGroupMember(req.GroupID, userId); isExist {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "user is exist in group", userId, req.GroupID)
|
||||
resp.Failed = append(resp.Failed, userId)
|
||||
continue
|
||||
}
|
||||
user, err := imdb.GetUserByUserID(userId)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationId, utils.GetSelfFuncName(), "GetUserByUserID", err.Error())
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID", err.Error())
|
||||
resp.Failed = append(resp.Failed, userId)
|
||||
continue
|
||||
}
|
||||
groupMember := db.GroupMember{
|
||||
GroupID: req.GroupId,
|
||||
GroupID: req.GroupID,
|
||||
UserID: userId,
|
||||
Nickname: user.Nickname,
|
||||
FaceURL: "",
|
||||
@ -1611,37 +1610,40 @@ func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGrou
|
||||
Ex: "",
|
||||
}
|
||||
if err := imdb.InsertIntoGroupMember(groupMember); err != nil {
|
||||
log.NewError(req.OperationId, utils.GetSelfFuncName(), "InsertIntoGroupMember failed", req.String())
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "InsertIntoGroupMember failed", req.String())
|
||||
resp.Failed = append(resp.Failed, userId)
|
||||
} else {
|
||||
resp.Success = append(resp.Success, userId)
|
||||
}
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationId)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationId + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationId, errMsg)
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
cacheClient := pbCache.NewCacheClient(etcdConn)
|
||||
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
|
||||
GroupID: req.GroupId,
|
||||
OperationID: req.OperationId,
|
||||
GroupID: req.GroupID,
|
||||
OperationID: req.OperationID,
|
||||
})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationId, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
|
||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
if cacheResp.CommonResp.ErrCode != 0 {
|
||||
log.NewError(req.OperationId, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
return resp, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupId); err != nil {
|
||||
log.NewError(req.OperationId, utils.GetSelfFuncName(), err.Error(), req.GroupId)
|
||||
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
|
||||
chat.MemberInvitedNotification(req.OperationId, req.GroupId, req.OpUserId, "admin add you to group", resp.Success)
|
||||
chat.MemberInvitedNotification(req.OperationID, req.GroupID, req.OpUserID, "admin add you to group", resp.Success)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@ -1705,7 +1707,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
||||
}
|
||||
//modify quitter conversation info
|
||||
var reqPb pbUser.SetConversationReq
|
||||
var c pbUser.Conversation
|
||||
var c pbConversation.Conversation
|
||||
for _, v := range memberList {
|
||||
reqPb.OperationID = req.OperationID
|
||||
c.OwnerUserID = v.UserID
|
||||
@ -1714,9 +1716,9 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
||||
c.GroupID = req.GroupID
|
||||
c.IsNotInGroup = true
|
||||
reqPb.Conversation = &c
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
@ -1742,9 +1744,9 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
||||
|
||||
}
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 500, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
@ -1761,7 +1763,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}}, nil
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
if err := rocksCache.DelGroupInfoFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
||||
@ -1809,7 +1811,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
|
||||
log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo)
|
||||
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
chat.GroupMemberMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, req.MutedSeconds)
|
||||
@ -1853,7 +1855,7 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
|
||||
log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo)
|
||||
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
chat.GroupMemberCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
|
||||
@ -1973,7 +1975,7 @@ func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.S
|
||||
log.Error(req.OperationID, errMsg)
|
||||
return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
}
|
||||
chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
|
||||
@ -2008,8 +2010,8 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
||||
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + ":" + err.Error()
|
||||
return resp, nil
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(req.GroupID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID, req.UserID)
|
||||
}
|
||||
if req.RoleLevel != nil {
|
||||
switch req.RoleLevel.Value {
|
||||
@ -2026,3 +2028,26 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupAbstractInfo(c context.Context, req *pbGroup.GetGroupAbstractInfoReq) (*pbGroup.GetGroupAbstractInfoResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbGroup.GetGroupAbstractInfoResp{CommonResp: &pbGroup.CommonResp{}}
|
||||
hashCode, err := rocksCache.GetGroupMemberListHashFromCache(req.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberListHashFromCache failed", req.GroupID, err.Error())
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
}
|
||||
resp.GroupMemberListHash = hashCode
|
||||
num, err := rocksCache.GetGroupMemberNumFromCache(req.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberNumByGroupID failed", req.GroupID, err.Error())
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
}
|
||||
resp.GroupMemberNumber = int32(num)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||
"Open_IM/pkg/common/log"
|
||||
cp "Open_IM/pkg/common/utils"
|
||||
@ -15,7 +14,6 @@ import (
|
||||
func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.GetJoinedSuperGroupListReq) (*pbGroup.GetJoinedSuperGroupListResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbGroup.GetJoinedSuperGroupListResp{CommonResp: &pbGroup.CommonResp{}}
|
||||
//userToSuperGroup, err := db.DB.GetSuperGroupByUserID(req.UserID)
|
||||
groupIDList, err := rocksCache.GetJoinedSuperGroupListFromCache(req.UserID)
|
||||
if err != nil {
|
||||
if err == redis.Nil {
|
||||
@ -23,8 +21,8 @@ func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.
|
||||
return resp, nil
|
||||
}
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSuperGroupByUserID failed ", err.Error(), req.UserID)
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
//resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
//resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
return resp, nil
|
||||
}
|
||||
for _, groupID := range groupIDList {
|
||||
|
@ -150,7 +150,7 @@ func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetC
|
||||
pbChatLog.ReciverNickName = recvUser.Nickname
|
||||
|
||||
case constant.GroupChatType:
|
||||
group, err := imdb.GetGroupById(chatLog.RecvID)
|
||||
group, err := imdb.GetGroupInfoByGroupID(chatLog.RecvID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupById failed")
|
||||
continue
|
||||
|
@ -2,6 +2,7 @@ package msg
|
||||
|
||||
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"
|
||||
@ -12,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbApi.CommonCallbackReq {
|
||||
return cbApi.CommonCallbackReq{
|
||||
req := cbApi.CommonCallbackReq{
|
||||
SendID: msg.MsgData.SendID,
|
||||
ServerMsgID: msg.MsgData.ServerMsgID,
|
||||
ClientMsgID: msg.MsgData.ClientMsgID,
|
||||
@ -24,10 +25,13 @@ func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbApi.CommonCallbackReq
|
||||
ContentType: msg.MsgData.ContentType,
|
||||
Status: msg.MsgData.Status,
|
||||
CreateTime: msg.MsgData.CreateTime,
|
||||
Content: string(msg.MsgData.Content),
|
||||
AtUserIDList: msg.MsgData.AtUserIDList,
|
||||
SenderFaceURL: msg.MsgData.SenderFaceURL,
|
||||
Content: callback.GetContent(msg.MsgData),
|
||||
Seq: msg.MsgData.Seq,
|
||||
Ex: msg.MsgData.Ex,
|
||||
}
|
||||
return req
|
||||
}
|
||||
|
||||
func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
|
||||
@ -134,11 +138,11 @@ func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp
|
||||
}
|
||||
|
||||
func callbackWordFilter(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
|
||||
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: msg.OperationID}
|
||||
if !config.Config.Callback.CallbackWordFilter.Enable || msg.MsgData.ContentType != constant.Text {
|
||||
return callbackResp
|
||||
}
|
||||
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
|
||||
commonCallbackReq := copyCallbackCommonReqStruct(msg)
|
||||
commonCallbackReq.CallbackCommand = constant.CallbackWordFilterCommand
|
||||
req := cbApi.CallbackWordFilterReq{
|
||||
|
@ -68,3 +68,15 @@ func ConversationChangeNotification(operationID, userID string) {
|
||||
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
|
||||
SetConversationNotification(operationID, userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips)
|
||||
}
|
||||
|
||||
//会话未读数同步
|
||||
func ConversationUnreadChangeNotification(operationID, userID, conversationID string) {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName())
|
||||
ConversationChangedTips := &open_im_sdk.ConversationUpdateTips{
|
||||
UserID: userID,
|
||||
ConversationIDList: []string{conversationID},
|
||||
}
|
||||
var tips open_im_sdk.TipsComm
|
||||
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
|
||||
SetConversationNotification(operationID, userID, userID, constant.ConversationUnreadNotification, ConversationChangedTips, tips)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
@ -16,18 +17,21 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"errors"
|
||||
go_redis "github.com/go-redis/redis/v8"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
go_redis "github.com/go-redis/redis/v8"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
//When the number of group members is greater than this value,Online users will be sent first,Guaranteed service availability
|
||||
const GroupMemberNum = 500
|
||||
|
||||
var ExcludeContentType = []int{constant.HasReadReceipt, constant.GroupHasReadReceipt}
|
||||
|
||||
type MsgCallBackReq struct {
|
||||
SendID string `json:"sendID"`
|
||||
RecvID string `json:"recvID"`
|
||||
@ -69,19 +73,19 @@ func isMessageHasReadEnabled(pb *pbChat.SendMsgReq) (bool, int32, string) {
|
||||
}
|
||||
|
||||
func messageVerification(data *pbChat.SendMsgReq) (bool, int32, string, []string) {
|
||||
switch data.MsgData.SessionType {
|
||||
case constant.SingleChatType:
|
||||
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 {
|
||||
return true, 0, "", nil
|
||||
}
|
||||
switch data.MsgData.SessionType {
|
||||
case constant.SingleChatType:
|
||||
log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify)
|
||||
reqGetBlackIDListFromCache := &cacheRpc.GetBlackIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := data.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := data.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(data.OperationID, errMsg)
|
||||
return true, 0, "", nil
|
||||
}
|
||||
@ -102,9 +106,9 @@ func messageVerification(data *pbChat.SendMsgReq) (bool, int32, string, []string
|
||||
log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify)
|
||||
if config.Config.MessageVerify.FriendVerify {
|
||||
reqGetFriendIDListFromCache := &cacheRpc.GetFriendIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := data.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := data.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(data.OperationID, errMsg)
|
||||
return true, 0, "", nil
|
||||
}
|
||||
@ -128,10 +132,17 @@ func messageVerification(data *pbChat.SendMsgReq) (bool, int32, string, []string
|
||||
case constant.GroupChatType:
|
||||
fallthrough
|
||||
case constant.SuperGroupChatType:
|
||||
groupInfo, err := rocksCache.GetGroupInfoFromCache(data.MsgData.GroupID)
|
||||
if err != nil {
|
||||
return false, 201, err.Error(), nil
|
||||
}
|
||||
if groupInfo.GroupType == constant.SuperGroup {
|
||||
return true, 0, "", nil
|
||||
} else {
|
||||
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: data.OperationID, GroupID: data.MsgData.GroupID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := data.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := data.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(data.OperationID, errMsg)
|
||||
//return returnMsg(&replay, pb, 201, errMsg, "", 0)
|
||||
return false, 201, errMsg, nil
|
||||
@ -149,13 +160,16 @@ func messageVerification(data *pbChat.SendMsgReq) (bool, int32, string, []string
|
||||
return false, cacheResp.CommonResp.ErrCode, cacheResp.CommonResp.ErrMsg, nil
|
||||
}
|
||||
if !token_verify.IsManagerUserID(data.MsgData.SendID) {
|
||||
if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin {
|
||||
return true, 0, "", cacheResp.UserIDList
|
||||
}
|
||||
if !utils.IsContain(data.MsgData.SendID, cacheResp.UserIDList) {
|
||||
//return returnMsg(&replay, pb, 202, "you are not in group", "", 0)
|
||||
return false, 202, "you are not in group", nil
|
||||
}
|
||||
}
|
||||
return true, 0, "", cacheResp.UserIDList
|
||||
|
||||
}
|
||||
default:
|
||||
return true, 0, "", nil
|
||||
}
|
||||
@ -212,6 +226,7 @@ func (rpc *rpcChat) encapsulateMsgData(msg *sdk_ws.MsgData) {
|
||||
func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, error) {
|
||||
replay := pbChat.SendMsgResp{}
|
||||
newTime := db.GetCurrentTimestampByMill()
|
||||
t1 := time.Now()
|
||||
log.Info(pb.OperationID, "rpc sendMsg come here ", pb.String())
|
||||
flag, errCode, errMsg := isMessageHasReadEnabled(pb)
|
||||
log.Info(pb.OperationID, "isMessageHasReadEnabled ", flag)
|
||||
@ -219,15 +234,18 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
||||
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
|
||||
}
|
||||
flag, errCode, errMsg, _ = messageVerification(pb)
|
||||
log.Info(pb.OperationID, "userRelationshipVerification ", flag)
|
||||
log.Info(pb.OperationID, "messageVerification ", flag, " cost time: ", time.Since(t1))
|
||||
if !flag {
|
||||
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
|
||||
}
|
||||
t1 = time.Now()
|
||||
rpc.encapsulateMsgData(pb.MsgData)
|
||||
log.Info(pb.OperationID, "encapsulateMsgData ", " cost time: ", time.Since(t1))
|
||||
msgToMQSingle := pbChat.MsgDataToMQ{Token: pb.Token, OperationID: pb.OperationID, MsgData: pb.MsgData}
|
||||
// callback
|
||||
t1 = time.Now()
|
||||
callbackResp := callbackWordFilter(pb)
|
||||
log.Info(pb.OperationID, "callbackWordFilter ", callbackResp)
|
||||
log.Info(pb.OperationID, "callbackWordFilter ", callbackResp, "cost time: ", time.Since(t1))
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.Error(pb.OperationID, utils.GetSelfFuncName(), "callbackWordFilter resp: ", callbackResp)
|
||||
}
|
||||
@ -242,7 +260,9 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
||||
switch pb.MsgData.SessionType {
|
||||
case constant.SingleChatType:
|
||||
// callback
|
||||
t1 = time.Now()
|
||||
callbackResp := callbackBeforeSendSingleMsg(pb)
|
||||
log.Info(pb.OperationID, "callbackBeforeSendSingleMsg ", " cost time: ", time.Since(t1))
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg resp: ", callbackResp)
|
||||
}
|
||||
@ -253,28 +273,37 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
||||
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp)
|
||||
return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0)
|
||||
}
|
||||
t1 = time.Now()
|
||||
isSend := modifyMessageByUserMessageReceiveOpt(pb.MsgData.RecvID, pb.MsgData.SendID, constant.SingleChatType, pb)
|
||||
log.Info(pb.OperationID, "modifyMessageByUserMessageReceiveOpt ", " cost time: ", time.Since(t1))
|
||||
if isSend {
|
||||
msgToMQSingle.MsgData = pb.MsgData
|
||||
log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle)
|
||||
t1 = time.Now()
|
||||
err1 := rpc.sendMsgToKafka(&msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus)
|
||||
log.Info(pb.OperationID, "sendMsgToKafka ", " cost time: ", time.Since(t1))
|
||||
if err1 != nil {
|
||||
log.NewError(msgToMQSingle.OperationID, "kafka send msg err :RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String(), err1.Error())
|
||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
||||
}
|
||||
}
|
||||
if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself
|
||||
t1 = time.Now()
|
||||
err2 := rpc.sendMsgToKafka(&msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus)
|
||||
log.Info(pb.OperationID, "sendMsgToKafka ", " cost time: ", time.Since(t1))
|
||||
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)
|
||||
}
|
||||
}
|
||||
// callback
|
||||
t1 = time.Now()
|
||||
callbackResp = callbackAfterSendSingleMsg(pb)
|
||||
log.Info(pb.OperationID, "callbackAfterSendSingleMsg ", " cost time: ", time.Since(t1))
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSingleMsg resp: ", callbackResp)
|
||||
}
|
||||
log.Debug(pb.OperationID, "send msg cost time all: ", db.GetCurrentTimestampByMill()-newTime, pb.MsgData.ClientMsgID)
|
||||
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime)
|
||||
case constant.GroupChatType:
|
||||
// callback
|
||||
@ -321,7 +350,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
||||
}
|
||||
m := make(map[string][]string, 2)
|
||||
m[constant.OnlineStatus] = memberUserIDList
|
||||
log.Debug(pb.OperationID, "send msg cost time1 ", db.GetCurrentTimestampByMill()-newTime, pb.MsgData.ClientMsgID)
|
||||
log.Debug(pb.OperationID, "send msg cost time1 ", db.GetCurrentTimestampByMill()-newTime, pb.MsgData.ClientMsgID, pb)
|
||||
newTime = db.GetCurrentTimestampByMill()
|
||||
|
||||
//split parallel send
|
||||
@ -386,9 +415,9 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
||||
conversationReq.UserIDList = pb.MsgData.AtUserIDList
|
||||
conversation.GroupAtType = constant.AtMe
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, pb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, pb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := pb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(pb.OperationID, errMsg)
|
||||
return
|
||||
}
|
||||
@ -402,9 +431,9 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
||||
if tag {
|
||||
conversationReq.UserIDList = utils.DifferenceString(atUserID, memberUserIDList)
|
||||
conversation.GroupAtType = constant.AtAll
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, pb.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, pb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := pb.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(pb.OperationID, errMsg)
|
||||
return
|
||||
}
|
||||
@ -464,7 +493,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
||||
}
|
||||
// callback
|
||||
callbackResp = callbackAfterSendSingleMsg(pb)
|
||||
callbackResp = callbackAfterSendGroupMsg(pb)
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSuperGroupMsg resp: ", callbackResp)
|
||||
}
|
||||
@ -535,6 +564,9 @@ func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType i
|
||||
case constant.ReceiveMessage:
|
||||
return true
|
||||
case constant.NotReceiveMessage:
|
||||
if utils.IsContainInt(int(pb.MsgData.ContentType), ExcludeContentType) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
case constant.ReceiveNotNotifyMessage:
|
||||
if pb.MsgData.Options == nil {
|
||||
@ -823,7 +855,7 @@ func Notification(n *NotificationMsg) {
|
||||
unReadCount = config.Config.Notification.ConversationSetPrivate.Conversation.UnreadCount
|
||||
case constant.DeleteMessageNotification:
|
||||
reliabilityLevel = constant.ReliableNotificationNoMsg
|
||||
case constant.SuperGroupUpdateNotification:
|
||||
case constant.ConversationUnreadNotification, constant.SuperGroupUpdateNotification:
|
||||
reliabilityLevel = constant.UnreliableNotification
|
||||
}
|
||||
switch reliabilityLevel {
|
||||
@ -845,9 +877,9 @@ func Notification(n *NotificationMsg) {
|
||||
offlineInfo.Ex = ex
|
||||
msg.OfflinePushInfo = &offlineInfo
|
||||
req.MsgData = &msg
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return
|
||||
}
|
||||
@ -868,7 +900,7 @@ func getOnlineAndOfflineUserIDList(memberList []string, m map[string][]string, o
|
||||
req.OperationID = operationID
|
||||
req.OpUserID = config.Config.Manager.AppManagerUid[0]
|
||||
flag := false
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRelayName)
|
||||
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), operationID)
|
||||
for _, v := range grpcCons {
|
||||
client := pbRelay.NewRelayClient(v)
|
||||
reply, err := client.GetUsersOnlineStatus(context.Background(), req)
|
||||
@ -956,8 +988,17 @@ func (rpc *rpcChat) sendMsgToGroup(list []string, pb pbChat.SendMsgReq, status s
|
||||
|
||||
func (rpc *rpcChat) sendMsgToGroupOptimization(list []string, groupPB *pbChat.SendMsgReq, status string, sendTag *bool, wg *sync.WaitGroup) {
|
||||
msgToMQGroup := pbChat.MsgDataToMQ{Token: groupPB.Token, OperationID: groupPB.OperationID, MsgData: groupPB.MsgData}
|
||||
tempOptions := make(map[string]bool, 1)
|
||||
for k, v := range groupPB.MsgData.Options {
|
||||
tempOptions[k] = v
|
||||
}
|
||||
for _, v := range list {
|
||||
groupPB.MsgData.RecvID = v
|
||||
options := make(map[string]bool, 1)
|
||||
for k, v := range tempOptions {
|
||||
options[k] = v
|
||||
}
|
||||
groupPB.MsgData.Options = options
|
||||
isSend := modifyMessageByUserMessageReceiveOpt(v, groupPB.MsgData.GroupID, constant.GroupChatType, groupPB)
|
||||
if isSend {
|
||||
if v == "" || groupPB.MsgData.SendID == "" {
|
||||
|
@ -33,9 +33,9 @@ func TagSendMessage(operationID string, user *db.User, recvID, content string, s
|
||||
msgData.SenderPlatformID = senderPlatformID
|
||||
req.MsgData = &msgData
|
||||
req.OperationID = operationID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, operationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, operationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return
|
||||
}
|
||||
|
@ -205,9 +205,9 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
|
||||
}
|
||||
var groupUserIDList []string
|
||||
for _, groupID := range req.GroupList {
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
resp.CommonResp.ErrCode = constant.ErrInternal.ErrCode
|
||||
resp.CommonResp.ErrMsg = errMsg
|
||||
|
@ -119,9 +119,9 @@ func (s *organizationServer) CreateDepartment(ctx context.Context, req *rpc.Crea
|
||||
return &rpc.CreateDepartmentResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
|
||||
}
|
||||
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
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.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
resp.ErrCode = constant.ErrInternal.ErrCode
|
||||
resp.ErrMsg = errMsg
|
||||
@ -262,9 +262,9 @@ func (s *organizationServer) CreateOrganizationUser(ctx context.Context, req *rp
|
||||
utils.CopyStructFields(authReq.UserInfo, req.OrganizationUser)
|
||||
authReq.OperationID = req.OperationID
|
||||
if req.IsRegister {
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &rpc.CreateOrganizationUserResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}, nil
|
||||
}
|
||||
@ -305,31 +305,8 @@ func (s *organizationServer) CreateOrganizationUser(ctx context.Context, req *rp
|
||||
}
|
||||
|
||||
func (s *organizationServer) UpdateOrganizationUser(ctx context.Context, req *rpc.UpdateOrganizationUserReq) (*rpc.UpdateOrganizationUserResp, error) {
|
||||
authReq := &pbAuth.UserRegisterReq{UserInfo: &open_im_sdk.UserInfo{}}
|
||||
utils.CopyStructFields(authReq.UserInfo, req.OrganizationUser)
|
||||
authReq.OperationID = req.OperationID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &rpc.UpdateOrganizationUserResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}, nil
|
||||
}
|
||||
client := pbAuth.NewAuthClient(etcdConn)
|
||||
|
||||
reply, err := client.UserRegister(context.Background(), authReq)
|
||||
if err != nil {
|
||||
errMsg := "UserRegister failed " + err.Error()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &rpc.UpdateOrganizationUserResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
|
||||
}
|
||||
if reply.CommonResp.ErrCode != 0 {
|
||||
errMsg := "UserRegister failed " + reply.CommonResp.ErrMsg
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &rpc.UpdateOrganizationUserResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
||||
if !token_verify.IsManagerUserID(req.OpUserID) {
|
||||
if !token_verify.IsManagerUserID(req.OpUserID) && req.OpUserID != req.OrganizationUser.UserID {
|
||||
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
|
||||
log.Error(req.OperationID, errMsg)
|
||||
return &rpc.UpdateOrganizationUserResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}, nil
|
||||
@ -342,7 +319,7 @@ func (s *organizationServer) UpdateOrganizationUser(ctx context.Context, req *rp
|
||||
}
|
||||
|
||||
log.Debug(req.OperationID, "src ", *req.OrganizationUser, "dst ", organizationUser)
|
||||
err = imdb.UpdateOrganizationUser(&organizationUser, nil)
|
||||
err := imdb.UpdateOrganizationUser(&organizationUser, nil)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "CreateOrganizationUser failed " + err.Error()
|
||||
log.Error(req.OperationID, errMsg, organizationUser)
|
||||
|
@ -6,12 +6,14 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/db/rocks_cache"
|
||||
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||
errors "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbConversation "Open_IM/pkg/proto/conversation"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
pbOrganization "Open_IM/pkg/proto/organization"
|
||||
sdkws "Open_IM/pkg/proto/sdk_ws"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
@ -19,6 +21,7 @@ import (
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
@ -83,7 +86,7 @@ func (s *userServer) Run() {
|
||||
log.NewInfo("0", "rpc user success")
|
||||
}
|
||||
|
||||
func syncPeerUserConversation(conversation *pbUser.Conversation, operationID string) error {
|
||||
func syncPeerUserConversation(conversation *pbConversation.Conversation, operationID string) error {
|
||||
peerUserConversation := db.Conversation{
|
||||
OwnerUserID: conversation.UserID,
|
||||
ConversationID: utils.GetConversationIDBySessionType(conversation.OwnerUserID, constant.SingleChatType),
|
||||
@ -109,6 +112,7 @@ func syncPeerUserConversation(conversation *pbUser.Conversation, operationID str
|
||||
|
||||
func (s *userServer) GetUserInfo(ctx context.Context, req *pbUser.GetUserInfoReq) (*pbUser.GetUserInfoResp, error) {
|
||||
log.NewInfo(req.OperationID, "GetUserInfo args ", req.String())
|
||||
|
||||
var userInfoList []*sdkws.UserInfo
|
||||
if len(req.UserIDList) > 0 {
|
||||
for _, userID := range req.UserIDList {
|
||||
@ -146,11 +150,21 @@ func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.Batc
|
||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||
return resp, nil
|
||||
}
|
||||
if err := imdb.SetConversation(conversation); err != nil {
|
||||
|
||||
isUpdate, err := imdb.SetConversation(conversation)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
||||
resp.Failed = append(resp.Failed, v.ConversationID)
|
||||
continue
|
||||
}
|
||||
if isUpdate {
|
||||
err = rocksCache.DelConversationFromCache(v.OwnerUserID, v.ConversationID)
|
||||
} else {
|
||||
err = rocksCache.DelUserConversationIDListFromCache(v.OwnerUserID)
|
||||
}
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), v.ConversationID, v.OwnerUserID)
|
||||
}
|
||||
resp.Success = append(resp.Success, v.ConversationID)
|
||||
// if is set private msg operation,then peer user need to sync and set tips\
|
||||
if v.ConversationType == constant.SingleChatType && req.NotificationType == constant.ConversationPrivateChatNotification {
|
||||
@ -167,8 +181,8 @@ func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.Batc
|
||||
|
||||
func (s *userServer) GetAllConversations(ctx context.Context, req *pbUser.GetAllConversationsReq) (*pbUser.GetAllConversationsResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.GetAllConversationsResp{Conversations: []*pbUser.Conversation{}}
|
||||
conversations, err := imdb.GetUserAllConversations(req.OwnerUserID)
|
||||
resp := &pbUser.GetAllConversationsResp{Conversations: []*pbConversation.Conversation{}}
|
||||
conversations, err := rocksCache.GetUserAllConversationList(req.OwnerUserID)
|
||||
log.NewDebug(req.OperationID, "conversations: ", conversations)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
|
||||
@ -185,8 +199,8 @@ func (s *userServer) GetAllConversations(ctx context.Context, req *pbUser.GetAll
|
||||
|
||||
func (s *userServer) GetConversation(ctx context.Context, req *pbUser.GetConversationReq) (*pbUser.GetConversationResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.GetConversationResp{Conversation: &pbUser.Conversation{}}
|
||||
conversation, err := imdb.GetConversation(req.OwnerUserID, req.ConversationID)
|
||||
resp := &pbUser.GetConversationResp{Conversation: &pbConversation.Conversation{}}
|
||||
conversation, err := rocksCache.GetConversationFromCache(req.OwnerUserID, req.ConversationID)
|
||||
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation error", err.Error())
|
||||
@ -203,8 +217,8 @@ func (s *userServer) GetConversation(ctx context.Context, req *pbUser.GetConvers
|
||||
|
||||
func (s *userServer) GetConversations(ctx context.Context, req *pbUser.GetConversationsReq) (*pbUser.GetConversationsResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.GetConversationsResp{Conversations: []*pbUser.Conversation{}}
|
||||
conversations, err := imdb.GetConversations(req.OwnerUserID, req.ConversationIDs)
|
||||
resp := &pbUser.GetConversationsResp{Conversations: []*pbConversation.Conversation{}}
|
||||
conversations, err := rocksCache.GetConversationsFromCache(req.OwnerUserID, req.ConversationIDs)
|
||||
log.NewDebug("", utils.GetSelfFuncName(), "conversations", conversations)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
|
||||
@ -248,12 +262,21 @@ func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConvers
|
||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||
return resp, nil
|
||||
}
|
||||
err := imdb.SetConversation(conversation)
|
||||
isUpdate, err := imdb.SetConversation(conversation)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||
return resp, nil
|
||||
}
|
||||
if isUpdate {
|
||||
err = rocksCache.DelConversationFromCache(req.Conversation.OwnerUserID, req.Conversation.ConversationID)
|
||||
} else {
|
||||
err = rocksCache.DelUserConversationIDListFromCache(req.Conversation.OwnerUserID)
|
||||
}
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.Conversation.ConversationID, req.Conversation.OwnerUserID)
|
||||
}
|
||||
|
||||
// notification
|
||||
if req.Conversation.ConversationType == constant.SingleChatType && req.NotificationType == constant.ConversationPrivateChatNotification {
|
||||
//sync peer user conversation if conversation is singleChatType
|
||||
@ -293,12 +316,20 @@ func (s *userServer) SetRecvMsgOpt(ctx context.Context, req *pbUser.SetRecvMsgOp
|
||||
conversation.ConversationType = constant.GroupChatType
|
||||
}
|
||||
}
|
||||
err := imdb.SetRecvMsgOpt(conversation)
|
||||
isUpdate, err := imdb.SetRecvMsgOpt(conversation)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
||||
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 {
|
||||
err = rocksCache.DelUserConversationIDListFromCache(conversation.OwnerUserID)
|
||||
}
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), conversation.ConversationID, err.Error())
|
||||
}
|
||||
chat.ConversationChangeNotification(req.OperationID, req.OwnerUserID)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
resp.CommonResp = &pbUser.CommonResp{}
|
||||
@ -397,9 +428,9 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
|
||||
log.NewError(req.OperationID, "UpdateUserInfo failed ", err.Error(), user)
|
||||
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.OperationID)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
@ -430,21 +461,31 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
|
||||
if req.UserInfo.Nickname != "" {
|
||||
go s.SyncJoinedGroupMemberNickname(req.UserInfo.UserID, req.UserInfo.Nickname, oldNickname, req.OperationID, req.OpUserID)
|
||||
}
|
||||
//updateUserInfoToCacheReq := &cache.UpdateUserInfoToCacheReq{
|
||||
// OperationID: req.OperationID,
|
||||
// UserInfoList: []*sdkws.UserInfo{req.UserInfo},
|
||||
//}
|
||||
//cacheEtcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
||||
//cacheClient := cache.NewCacheClient(cacheEtcdConn)
|
||||
//resp, err := cacheClient.UpdateUserInfoToCache(context.Background(), updateUserInfoToCacheReq)
|
||||
//if err != nil {
|
||||
// log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), updateUserInfoToCacheReq.String())
|
||||
// return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrServer.ErrCode, ErrMsg: err.Error()}}, nil
|
||||
//}
|
||||
//if resp.CommonResp.ErrCode != 0 {
|
||||
// log.NewError(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||
// return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrServer.ErrCode, ErrMsg: resp.CommonResp.ErrMsg}}, nil
|
||||
//}
|
||||
etcdConn = getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
clientOrg := pbOrganization.NewOrganizationClient(etcdConn)
|
||||
out, err := clientOrg.UpdateOrganizationUser(context.Background(), &pbOrganization.UpdateOrganizationUserReq{
|
||||
OrganizationUser: &sdkws.OrganizationUser{
|
||||
UserID: req.UserInfo.UserID,
|
||||
Nickname: req.UserInfo.Nickname,
|
||||
EnglishName: req.UserInfo.Nickname,
|
||||
FaceURL: req.UserInfo.FaceURL,
|
||||
Gender: req.UserInfo.Gender,
|
||||
Mobile: req.UserInfo.PhoneNumber,
|
||||
Telephone: req.UserInfo.PhoneNumber,
|
||||
Birth: req.UserInfo.Birth,
|
||||
Email: req.UserInfo.Email,
|
||||
Ex: req.UserInfo.Ex,
|
||||
},
|
||||
OperationID: req.OperationID,
|
||||
OpUserID: req.OpUserID,
|
||||
})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateOrganizationUser failed", err.Error())
|
||||
} else {
|
||||
if out.ErrCode != 0 {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "grpc resp: ", out)
|
||||
}
|
||||
}
|
||||
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{}}, nil
|
||||
}
|
||||
func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbUser.SetGlobalRecvMessageOptReq) (*pbUser.SetGlobalRecvMessageOptResp, error) {
|
||||
@ -466,6 +507,10 @@ func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbUser.Se
|
||||
log.NewError(req.OperationID, "SetGlobalRecvMessageOpt failed ", err.Error(), user)
|
||||
return &pbUser.SetGlobalRecvMessageOptResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
if err := rocksCache.DelUserInfoFromCache(user.UserID); err != nil {
|
||||
log.NewError(req.OperationID, "DelUserInfoFromCache failed ", err.Error(), req.String())
|
||||
return &pbUser.SetGlobalRecvMessageOptResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
|
||||
}
|
||||
chat.UserInfoUpdatedNotification(req.OperationID, req.UserID, req.UserID)
|
||||
return &pbUser.SetGlobalRecvMessageOptResp{CommonResp: &pbUser.CommonResp{}}, nil
|
||||
}
|
||||
@ -482,8 +527,12 @@ func (s *userServer) SyncJoinedGroupMemberFaceURL(userID string, faceURL string,
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupMemberInfo)
|
||||
continue
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(groupID); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID)
|
||||
//if err := rocksCache.DelAllGroupMembersInfoFromCache(groupID); err != nil {
|
||||
// log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID)
|
||||
// continue
|
||||
//}
|
||||
if err := rocksCache.DelGroupMemberInfoFromCache(groupID, userID); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupID, userID)
|
||||
continue
|
||||
}
|
||||
chat.GroupMemberInfoSetNotification(operationID, opUserID, groupID, userID)
|
||||
@ -508,9 +557,12 @@ func (s *userServer) SyncJoinedGroupMemberNickname(userID string, newNickname, o
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), groupMemberInfo)
|
||||
continue
|
||||
}
|
||||
if err := rocksCache.DelAllGroupMembersInfoFromCache(v); err != nil {
|
||||
//if err := rocksCache.DelAllGroupMembersInfoFromCache(v); err != nil {
|
||||
// log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), v)
|
||||
// continue
|
||||
//}
|
||||
if err := rocksCache.DelGroupMemberInfoFromCache(v, userID); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), v)
|
||||
continue
|
||||
}
|
||||
chat.GroupMemberInfoSetNotification(operationID, opUserID, v, userID)
|
||||
}
|
||||
@ -535,8 +587,17 @@ func (s *userServer) GetUsersByName(ctx context.Context, req *pbUser.GetUsersByN
|
||||
ProfilePhoto: user.FaceURL,
|
||||
Nickname: user.Nickname,
|
||||
UserId: user.UserID,
|
||||
CreateTime: user.CreateTime.String(),
|
||||
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
CreateIp: user.CreateIp,
|
||||
IsBlock: isBlock,
|
||||
Birth: user.Birth.Format("2006-01-02"),
|
||||
PhoneNumber: user.PhoneNumber,
|
||||
Email: user.Email,
|
||||
LastLoginIp: user.LastLoginIp,
|
||||
LastLoginTime: user.LastLoginTime.Format("2006-01-02 15:04:05"),
|
||||
LoginTimes: user.LoginTimes,
|
||||
Gender: user.Gender,
|
||||
LoginLimit: user.LoginLimit,
|
||||
})
|
||||
}
|
||||
user := db.User{Nickname: req.UserName}
|
||||
@ -571,8 +632,17 @@ func (s *userServer) GetUserById(ctx context.Context, req *pbUser.GetUserByIdReq
|
||||
ProfilePhoto: user.FaceURL,
|
||||
Nickname: user.Nickname,
|
||||
UserId: user.UserID,
|
||||
CreateTime: user.CreateTime.String(),
|
||||
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
CreateIp: user.CreateIp,
|
||||
IsBlock: isBlock,
|
||||
Birth: user.Birth.Format("2006-01-02"),
|
||||
PhoneNumber: user.PhoneNumber,
|
||||
Email: user.Email,
|
||||
LastLoginIp: user.LastLoginIp,
|
||||
LastLoginTime: user.LastLoginTime.Format("2006-01-02 15:04:05"),
|
||||
LoginTimes: user.LoginTimes,
|
||||
Gender: user.Gender,
|
||||
LoginLimit: user.LoginLimit,
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
@ -586,15 +656,32 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsers failed", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
|
||||
for _, v := range users {
|
||||
isBlock, err := imdb.UserIsBlock(v.UserID)
|
||||
if err == nil {
|
||||
registerIP := ""
|
||||
registerInfo, err := imdb.GetRegisterInfo(v.UserID)
|
||||
if registerInfo != nil && err == nil {
|
||||
registerIP = registerInfo.RegisterIP
|
||||
}
|
||||
|
||||
user := &pbUser.User{
|
||||
ProfilePhoto: v.FaceURL,
|
||||
UserId: v.UserID,
|
||||
CreateTime: v.CreateTime.String(),
|
||||
CreateTime: v.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
CreateIp: v.CreateIp,
|
||||
Nickname: v.Nickname,
|
||||
Birth: v.Birth.Format("2006-01-02"),
|
||||
PhoneNumber: v.PhoneNumber,
|
||||
Email: v.Email,
|
||||
IsBlock: isBlock,
|
||||
LastLoginIp: v.LastLoginIp,
|
||||
LastLoginTime: v.LastLoginTime.Format("2006-01-02 15:04:05"),
|
||||
LoginTimes: v.LoginTimes,
|
||||
Gender: v.Gender,
|
||||
LoginLimit: v.LoginLimit,
|
||||
RegisterIp: registerIP,
|
||||
}
|
||||
resp.User = append(resp.User, user)
|
||||
} else {
|
||||
@ -621,11 +708,19 @@ func (s *userServer) ResignUser(ctx context.Context, req *pbUser.ResignUserReq)
|
||||
func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*pbUser.AlterUserResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.AlterUserResp{}
|
||||
birth, _ := time.ParseInLocation("2006-01-02", req.Birth, time.Local)
|
||||
gender, gendererr := strconv.Atoi(req.Gender)
|
||||
if gendererr != nil {
|
||||
gender = 0
|
||||
}
|
||||
user := db.User{
|
||||
PhoneNumber: strconv.FormatInt(req.PhoneNumber, 10),
|
||||
PhoneNumber: req.PhoneNumber,
|
||||
Nickname: req.Nickname,
|
||||
Email: req.Email,
|
||||
UserID: req.UserId,
|
||||
Gender: int32(gender),
|
||||
FaceURL: req.Photo,
|
||||
Birth: birth,
|
||||
}
|
||||
if err := imdb.UpdateUserInfo(user); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateUserInfo", err.Error())
|
||||
@ -639,7 +734,7 @@ func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*
|
||||
func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUser.AddUserResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.AddUserResp{}
|
||||
err := imdb.AddUser(req.UserId, req.PhoneNumber, req.Name)
|
||||
err := imdb.AddUser(req.UserId, req.PhoneNumber, req.Name, req.Email, req.Gender, req.Photo, req.Birth)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddUser", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
@ -684,6 +779,10 @@ func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUser
|
||||
Nickname: v.User.Nickname,
|
||||
UserId: v.User.UserID,
|
||||
IsBlock: true,
|
||||
Birth: v.User.Birth.Format("2006-01-02"),
|
||||
PhoneNumber: v.User.PhoneNumber,
|
||||
Email: v.User.Email,
|
||||
Gender: v.User.Gender,
|
||||
},
|
||||
BeginDisableTime: (v.BeginDisableTime).String(),
|
||||
EndDisableTime: (v.EndDisableTime).String(),
|
||||
@ -716,6 +815,10 @@ func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUse
|
||||
Nickname: user.User.Nickname,
|
||||
UserId: user.User.UserID,
|
||||
IsBlock: true,
|
||||
Birth: user.User.Birth.Format("2006-01-02"),
|
||||
PhoneNumber: user.User.PhoneNumber,
|
||||
Email: user.User.Email,
|
||||
Gender: user.User.Gender,
|
||||
},
|
||||
BeginDisableTime: (user.BeginDisableTime).String(),
|
||||
EndDisableTime: (user.EndDisableTime).String(),
|
||||
|
@ -1,26 +0,0 @@
|
||||
package timed_task
|
||||
|
||||
type TimeTask struct {
|
||||
delMgoChatChan chan bool
|
||||
}
|
||||
|
||||
var timeTask TimeTask
|
||||
|
||||
func GetInstance() *TimeTask {
|
||||
if timeTask.delMgoChatChan == nil {
|
||||
timeTask.delMgoChatChan = make(chan bool)
|
||||
go func() {
|
||||
timeTask.delMgoChatChan <- true
|
||||
}()
|
||||
}
|
||||
return &timeTask
|
||||
}
|
||||
|
||||
func (t *TimeTask) Run() {
|
||||
for {
|
||||
select {
|
||||
case <-t.delMgoChatChan:
|
||||
t.timedDeleteUserChat()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package timed_task
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (t *TimeTask) timedDeleteUserChat() {
|
||||
now := time.Now()
|
||||
next := now.Add(time.Hour * 24)
|
||||
next = time.Date(next.Year(), next.Month(), next.Day(), 0, 0, 0, 0, next.Location())
|
||||
tm := time.NewTimer(next.Sub(now))
|
||||
|
||||
<-tm.C
|
||||
|
||||
count, _ := db.DB.MgoUserCount()
|
||||
for i := 0; i < count; i++ {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
uid, _ := db.DB.MgoSkipUID(i)
|
||||
db.DB.DelUserChatMongo2(uid)
|
||||
}
|
||||
|
||||
go func() {
|
||||
t.delMgoChatChan <- true
|
||||
}()
|
||||
}
|
@ -28,8 +28,9 @@ type UserRegisterResp struct {
|
||||
|
||||
type UserTokenReq struct {
|
||||
Secret string `json:"secret" binding:"required,max=32"`
|
||||
Platform int32 `json:"platform" binding:"required,min=1,max=8"`
|
||||
Platform int32 `json:"platform" binding:"required,min=1,max=9"`
|
||||
UserID string `json:"userID" binding:"required,min=1,max=64"`
|
||||
LoginIp string `json:"loginIp"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
@ -39,7 +40,7 @@ type UserTokenResp struct {
|
||||
}
|
||||
|
||||
type ForceLogoutReq struct {
|
||||
Platform int32 `json:"platform" binding:"required,min=1,max=8"`
|
||||
Platform int32 `json:"platform" binding:"required,min=1,max=9"`
|
||||
FromUserID string `json:"fromUserID" binding:"required,min=1,max=64"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
21
pkg/base_info/client_init.go
Normal file
21
pkg/base_info/client_init.go
Normal file
@ -0,0 +1,21 @@
|
||||
package base_info
|
||||
|
||||
type SetClientInitConfigReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
DiscoverPageURL *string `json:"discoverPageURL"`
|
||||
}
|
||||
|
||||
type SetClientInitConfigResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type GetClientInitConfigReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type GetClientInitConfigResp struct {
|
||||
CommResp
|
||||
Data struct {
|
||||
DiscoverPageURL string `json:"discoverPageURL"`
|
||||
} `json:"data"`
|
||||
}
|
@ -45,6 +45,7 @@ type Conversation struct {
|
||||
IsPrivateChat bool `json:"isPrivateChat"`
|
||||
GroupAtType int32 `json:"groupAtType"`
|
||||
IsNotInGroup bool `json:"isNotInGroup"`
|
||||
UpdateUnreadCountTime int64 `json:"updateUnreadCountTime"`
|
||||
AttachedInfo string `json:"attachedInfo"`
|
||||
Ex string `json:"ex"`
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ type GetGroupMemberListResp struct {
|
||||
type GetGroupAllMemberReq struct {
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Offset int32 `json:"offset"`
|
||||
Count int32 `json:"count"`
|
||||
}
|
||||
type GetGroupAllMemberResp struct {
|
||||
CommResp
|
||||
@ -80,6 +82,19 @@ type GetGroupAllMemberResp struct {
|
||||
Data []map[string]interface{} `json:"data" swaggerignore:"true"`
|
||||
}
|
||||
|
||||
//
|
||||
//type GetGroupAllMemberListBySplitReq struct {
|
||||
// GroupID string `json:"groupID" binding:"required"`
|
||||
// OperationID string `json:"operationID" binding:"required"`
|
||||
// Offset int32 `json:"offset" binding:"required"`
|
||||
// Count int32 `json:"count" binding:"required"`
|
||||
//}
|
||||
//type GetGroupAllMemberListBySplitResp struct {
|
||||
// CommResp
|
||||
// MemberList []*open_im_sdk.GroupMemberFullInfo `json:"-"`
|
||||
// Data []map[string]interface{} `json:"data" swaggerignore:"true"`
|
||||
//}
|
||||
|
||||
type CreateGroupReq struct {
|
||||
MemberList []*GroupAddMemberInfo `json:"memberList"`
|
||||
OwnerUserID string `json:"ownerUserID"`
|
||||
@ -274,3 +289,14 @@ type SetGroupMemberInfoReq struct {
|
||||
type SetGroupMemberInfoResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type GetGroupAbstractInfoReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
GroupID string `json:"groupID"`
|
||||
}
|
||||
|
||||
type GetGroupAbstractInfoResp struct {
|
||||
CommResp
|
||||
GroupMemberNumber int32 `json:"groupMemberNumber"`
|
||||
GroupMemberListHash uint64 `json:"groupMemberListHash"`
|
||||
}
|
||||
|
@ -2,8 +2,7 @@ package base_info
|
||||
|
||||
import (
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
)
|
||||
|
||||
@ -53,7 +52,7 @@ type ManagementSendMsg struct {
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||
NotOfflinePush bool `json:"notOfflinePush"`
|
||||
OfflinePushInfo *open_im_sdk.OfflinePushInfo `json:"offlinePushInfo"`
|
||||
OfflinePushInfo *server_api_params.OfflinePushInfo `json:"offlinePushInfo"`
|
||||
}
|
||||
|
||||
type ManagementSendMsgReq struct {
|
||||
@ -68,6 +67,7 @@ type ManagementSendMsgResp struct {
|
||||
|
||||
type ManagementBatchSendMsgReq struct {
|
||||
ManagementSendMsg
|
||||
IsSendAll bool `json:"isSendAll"`
|
||||
RecvIDList []string `json:"recvIDList"`
|
||||
}
|
||||
|
||||
|
6
pkg/base_info/pagination.go
Normal file
6
pkg/base_info/pagination.go
Normal file
@ -0,0 +1,6 @@
|
||||
package base_info
|
||||
|
||||
type Pagination struct {
|
||||
PageNumber int32 `json:"pageNumber" binding:"required"`
|
||||
ShowNumber int32 `json:"showNumber" binding:"required"`
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
package base_info
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ApiUserInfo struct {
|
||||
@ -13,7 +14,14 @@ type ApiUserInfo struct {
|
||||
PhoneNumber string `json:"phoneNumber" binding:"omitempty,max=32"`
|
||||
Birth uint32 `json:"birth" binding:"omitempty"`
|
||||
Email string `json:"email" binding:"omitempty,max=64"`
|
||||
CreateIp string `json:"createIp" binding:"omitempty,max=15"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
LastLoginIp string `json:"LastLoginIp" binding:"omitempty,max=15"`
|
||||
LastLoginTime int64 `json:"lastLoginTime"`
|
||||
LoginTimes int32 `json:"loginTimes" binding:"omitempty"`
|
||||
LoginLimit int32 `json:"loginLimit" binding:"omitempty"`
|
||||
Ex string `json:"ex" binding:"omitempty,max=1024"`
|
||||
InvitationCode string `json:"invitationCode" binding:"omitempty"`
|
||||
}
|
||||
|
||||
//type Conversation struct {
|
||||
|
@ -13,6 +13,7 @@ type MiniostorageCredentialResp struct {
|
||||
BucketName string `json:"bucketName"`
|
||||
StsEndpointURL string `json:"stsEndpointURL"`
|
||||
StorageTime int `json:"storageTime"`
|
||||
IsDistributedMod bool `json:"isDistributedMod"`
|
||||
}
|
||||
|
||||
type MinioUploadFileReq struct {
|
||||
@ -98,3 +99,16 @@ type GetRTCInvitationInfoStartAppReq struct {
|
||||
type GetRTCInvitationInfoStartAppResp struct {
|
||||
GetRTCInvitationInfoResp
|
||||
}
|
||||
|
||||
/**
|
||||
* FCM第三方上报Token
|
||||
*/
|
||||
type FcmUpdateTokenReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Platform int `json:"platform" binding:"required,min=1,max=2"` //only for ios + android
|
||||
FcmToken string `json:"fcmToken" binding:"required"`
|
||||
}
|
||||
|
||||
type FcmUpdateTokenResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
@ -14,8 +14,10 @@ type CommonCallbackReq struct {
|
||||
Status int32 `json:"status"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
Content string `json:"content"`
|
||||
Seq uint32 `json:"seq"`
|
||||
AtUserIDList []string `json:"atUserList"`
|
||||
SenderFaceURL string `json:"faceURL"`
|
||||
Ex string `json:"ex"`
|
||||
}
|
||||
|
||||
type CommonCallbackResp struct {
|
||||
|
@ -18,3 +18,12 @@ type CallbackUserOfflineReq struct {
|
||||
type CallbackUserOfflineResp struct {
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackUserKickOffReq struct {
|
||||
UserStatusCallbackReq
|
||||
Seq int `json:"seq"`
|
||||
}
|
||||
|
||||
type CallbackUserKickOffResp struct {
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ type CallbackBeforePushReq struct {
|
||||
type CallbackBeforePushResp struct {
|
||||
*CommonCallbackResp
|
||||
UserIDList []string `json:"userIDList"`
|
||||
OfflinePushInfo *commonPb.OfflinePushInfo `json:"offlinePushInfo"`
|
||||
}
|
||||
|
||||
type CallbackBeforeSuperGroupOnlinePushReq struct {
|
||||
|
@ -1,8 +1,6 @@
|
||||
package cms_api_struct
|
||||
|
||||
import (
|
||||
apiStruct "Open_IM/pkg/base_info"
|
||||
)
|
||||
import server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
|
||||
type AdminLoginRequest struct {
|
||||
AdminName string `json:"admin_name" binding:"required"`
|
||||
@ -13,31 +11,29 @@ type AdminLoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type UploadUpdateAppReq struct {
|
||||
OperationID string `form:"operationID" binding:"required"`
|
||||
Type int `form:"type" binding:"required"`
|
||||
Version string `form:"version" binding:"required"`
|
||||
//File *multipart.FileHeader `form:"file" binding:"required"`
|
||||
//Yaml *multipart.FileHeader `form:"yaml" binding:"required"`
|
||||
ForceUpdate bool `form:"forceUpdate" binding:"required"`
|
||||
}
|
||||
|
||||
type UploadUpdateAppResp struct {
|
||||
apiStruct.CommResp
|
||||
}
|
||||
|
||||
type GetDownloadURLReq struct {
|
||||
type AddUserRegisterAddFriendIDListRequest struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Type int `json:"type" binding:"required"`
|
||||
Version string `json:"version" binding:"required"`
|
||||
UserIDList []string `json:"userIDList" binding:"required"`
|
||||
}
|
||||
|
||||
type GetDownloadURLResp struct {
|
||||
apiStruct.CommResp
|
||||
Data struct {
|
||||
HasNewVersion bool `json:"hasNewVersion"`
|
||||
ForceUpdate bool `json:"forceUpdate"`
|
||||
FileURL string `json:"fileURL"`
|
||||
YamlURL string `json:"yamlURL"`
|
||||
} `json:"data"`
|
||||
type AddUserRegisterAddFriendIDListResponse struct {
|
||||
}
|
||||
|
||||
type ReduceUserRegisterAddFriendIDListRequest struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UserIDList []string `json:"userIDList" binding:"required"`
|
||||
Operation int32 `json:"operation"`
|
||||
}
|
||||
|
||||
type ReduceUserRegisterAddFriendIDListResponse struct {
|
||||
}
|
||||
|
||||
type GetUserRegisterAddFriendIDListRequest struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
RequestPaginationBody
|
||||
}
|
||||
|
||||
type GetUserRegisterAddFriendIDListResponse struct {
|
||||
Users []*server_api_params.UserInfo `json:"users"`
|
||||
ResponsePagination
|
||||
}
|
||||
|
@ -5,6 +5,11 @@ type RequestPagination struct {
|
||||
ShowNumber int `form:"show_number" binding:"required"`
|
||||
}
|
||||
|
||||
type RequestPaginationBody struct {
|
||||
PageNumber int `json:"pageNumber" binding:"required"`
|
||||
ShowNumber int `json:"showNumber" binding:"required"`
|
||||
}
|
||||
|
||||
type ResponsePagination struct {
|
||||
CurrentPage int `json:"current_number" binding:"required"`
|
||||
ShowNumber int `json:"show_number" binding:"required"`
|
||||
|
@ -1,32 +1,44 @@
|
||||
package cms_api_struct
|
||||
|
||||
type GroupResponse struct {
|
||||
GroupName string `json:"group_name"`
|
||||
GroupID string `json:"group_id"`
|
||||
GroupMasterName string `json:"group_master_name"`
|
||||
GroupMasterId string `json:"group_master_id"`
|
||||
CreateTime string `json:"create_time"`
|
||||
IsBanChat bool `json:"is_ban_chat"`
|
||||
IsBanPrivateChat bool `json:"is_ban_private_chat"`
|
||||
ProfilePhoto string `json:"profile_photo"`
|
||||
GroupOwnerName string `json:"GroupOwnerName"`
|
||||
GroupOwnerID string `json:"GroupOwnerID"`
|
||||
//*server_api_params.GroupInfo
|
||||
GroupID string `json:"groupID"`
|
||||
GroupName string `json:"groupName"`
|
||||
Notification string `json:"notification"`
|
||||
Introduction string `json:"introduction"`
|
||||
FaceURL string `json:"faceURL"`
|
||||
OwnerUserID string `json:"ownerUserID"`
|
||||
CreateTime uint32 `json:"createTime"`
|
||||
MemberCount uint32 `json:"memberCount"`
|
||||
Ex string `json:"ex"`
|
||||
Status int32 `json:"status"`
|
||||
CreatorUserID string `json:"creatorUserID"`
|
||||
GroupType int32 `json:"groupType"`
|
||||
NeedVerification int32 `json:"needVerification"`
|
||||
LookMemberInfo int32 `json:"lookMemberInfo"`
|
||||
ApplyMemberFriend int32 `json:"applyMemberFriend"`
|
||||
NotificationUpdateTime uint32 `json:"notificationUpdateTime"`
|
||||
NotificationUserID string `json:"notificationUserID"`
|
||||
}
|
||||
|
||||
type GetGroupByIdRequest struct {
|
||||
GroupId string `form:"group_id" binding:"required"`
|
||||
type GetGroupByIDRequest struct {
|
||||
GroupID string `form:"groupID" binding:"required"`
|
||||
}
|
||||
|
||||
type GetGroupByIdResponse struct {
|
||||
type GetGroupByIDResponse struct {
|
||||
GroupResponse
|
||||
}
|
||||
|
||||
type GetGroupRequest struct {
|
||||
GroupName string `form:"group_name" binding:"required"`
|
||||
GroupName string `form:"groupName" binding:"required"`
|
||||
RequestPagination
|
||||
}
|
||||
|
||||
type GetGroupResponse struct {
|
||||
Groups []GroupResponse `json:"groups"`
|
||||
GroupNums int `json:"group_nums"`
|
||||
GroupNums int `json:"groupNums"`
|
||||
ResponsePagination
|
||||
}
|
||||
|
||||
@ -36,77 +48,85 @@ type GetGroupsRequest struct {
|
||||
|
||||
type GetGroupsResponse struct {
|
||||
Groups []GroupResponse `json:"groups"`
|
||||
GroupNums int `json:"group_nums"`
|
||||
GroupNums int `json:"groupNums"`
|
||||
ResponsePagination
|
||||
}
|
||||
|
||||
type CreateGroupRequest struct {
|
||||
GroupName string `json:"group_name" binding:"required"`
|
||||
GroupMasterId string `json:"group_master_id" binding:"required"`
|
||||
GroupMembers []string `json:"group_members" binding:"required"`
|
||||
GroupName string `json:"groupName" binding:"required"`
|
||||
GroupMasterId string `json:"groupOwnerID" binding:"required"`
|
||||
GroupMembers []string `json:"groupMembers" binding:"required"`
|
||||
}
|
||||
|
||||
type CreateGroupResponse struct {
|
||||
}
|
||||
|
||||
type SetGroupMasterRequest struct {
|
||||
GroupId string `json:"group_id" binding:"required"`
|
||||
UserId string `json:"user_id" binding:"required"`
|
||||
GroupId string `json:"groupID" binding:"required"`
|
||||
UserId string `json:"userID" binding:"required"`
|
||||
}
|
||||
|
||||
type SetGroupMasterResponse struct {
|
||||
}
|
||||
|
||||
type SetGroupMemberRequest struct {
|
||||
GroupId string `json:"group_id" binding:"required"`
|
||||
UserId string `json:"user_id" binding:"required"`
|
||||
GroupId string `json:"groupID" binding:"required"`
|
||||
UserId string `json:"userID" binding:"required"`
|
||||
}
|
||||
|
||||
type SetGroupMemberRespones struct {
|
||||
}
|
||||
|
||||
type BanGroupChatRequest struct {
|
||||
GroupId string `json:"group_id" binding:"required"`
|
||||
GroupId string `json:"groupID" binding:"required"`
|
||||
}
|
||||
|
||||
type BanGroupChatResponse struct {
|
||||
}
|
||||
|
||||
type BanPrivateChatRequest struct {
|
||||
GroupId string `json:"group_id" binding:"required"`
|
||||
GroupId string `json:"groupID" binding:"required"`
|
||||
}
|
||||
|
||||
type BanPrivateChatResponse struct {
|
||||
}
|
||||
|
||||
type DeleteGroupRequest struct {
|
||||
GroupId string `json:"group_id" binding:"required"`
|
||||
GroupId string `json:"groupID" binding:"required"`
|
||||
}
|
||||
|
||||
type DeleteGroupResponse struct {
|
||||
}
|
||||
|
||||
type GetGroupMembersRequest struct {
|
||||
GroupId string `form:"group_id" binding:"required"`
|
||||
UserName string `form:"user_name"`
|
||||
GroupID string `form:"groupID" binding:"required"`
|
||||
UserName string `form:"userName"`
|
||||
RequestPagination
|
||||
}
|
||||
|
||||
type GroupMemberResponse struct {
|
||||
MemberPosition int `json:"member_position"`
|
||||
MemberNickName string `json:"member_nick_name"`
|
||||
MemberId string `json:"member_id"`
|
||||
JoinTime string `json:"join_time"`
|
||||
GroupID string `json:"groupID"`
|
||||
UserID string `json:"userID"`
|
||||
RoleLevel int32 `json:"roleLevel"`
|
||||
JoinTime int32 `json:"joinTime"`
|
||||
Nickname string `json:"nickname"`
|
||||
FaceURL string `json:"faceURL"`
|
||||
AppMangerLevel int32 `json:"appMangerLevel"` //if >0
|
||||
JoinSource int32 `json:"joinSource"`
|
||||
OperatorUserID string `json:"operatorUserID"`
|
||||
Ex string `json:"ex"`
|
||||
MuteEndTime uint32 `json:"muteEndTime"`
|
||||
InviterUserID string `json:"inviterUserID"`
|
||||
}
|
||||
|
||||
type GetGroupMembersResponse struct {
|
||||
GroupMembers []GroupMemberResponse `json:"group_members"`
|
||||
GroupMembers []GroupMemberResponse `json:"groupMembers"`
|
||||
ResponsePagination
|
||||
MemberNums int `json:"member_nums"`
|
||||
MemberNums int `json:"memberNums"`
|
||||
}
|
||||
|
||||
type GroupMemberRequest struct {
|
||||
GroupId string `json:"group_id" binding:"required"`
|
||||
GroupId string `json:"groupID" binding:"required"`
|
||||
Members []string `json:"members" binding:"required"`
|
||||
}
|
||||
|
||||
@ -132,12 +152,12 @@ type RemoveGroupMembersResponse struct {
|
||||
}
|
||||
|
||||
type AlterGroupInfoRequest struct {
|
||||
GroupID string `json:"group_id"`
|
||||
GroupName string `json:"group_name"`
|
||||
GroupID string `json:"groupID"`
|
||||
GroupName string `json:"groupName"`
|
||||
Notification string `json:"notification"`
|
||||
Introduction string `json:"introduction"`
|
||||
ProfilePhoto string `json:"profile_photo"`
|
||||
GroupType int `json:"group_type"`
|
||||
ProfilePhoto string `json:"profilePhoto"`
|
||||
GroupType int `json:"groupType"`
|
||||
}
|
||||
|
||||
type AlterGroupInfoResponse struct {
|
||||
|
@ -5,7 +5,16 @@ type UserResponse struct {
|
||||
Nickname string `json:"nick_name"`
|
||||
UserId string `json:"user_id"`
|
||||
CreateTime string `json:"create_time,omitempty"`
|
||||
CreateIp string `json:"create_ip,omitempty"`
|
||||
LastLoginTime string `json:"last_login_time,omitempty"`
|
||||
LastLoginIp string `json:"last_login_ip,omitempty"`
|
||||
LoginTimes int32 `json:"login_times"`
|
||||
LoginLimit int32 `json:"login_limit"`
|
||||
IsBlock bool `json:"is_block"`
|
||||
PhoneNumber string `json:"phone_number"`
|
||||
Email string `json:"email"`
|
||||
Birth string `json:"birth"`
|
||||
Gender int `json:"gender"`
|
||||
}
|
||||
|
||||
type GetUserRequest struct {
|
||||
@ -47,8 +56,11 @@ type ResignUserResponse struct {
|
||||
type AlterUserRequest struct {
|
||||
UserId string `json:"user_id" binding:"required"`
|
||||
Nickname string `json:"nickname"`
|
||||
PhoneNumber int `json:"phone_number" validate:"len=11"`
|
||||
PhoneNumber string `json:"phone_number" validate:"len=11"`
|
||||
Email string `json:"email"`
|
||||
Birth string `json:"birth"`
|
||||
Gender string `json:"gender"`
|
||||
Photo string `json:"photo"`
|
||||
}
|
||||
|
||||
type AlterUserResponse struct {
|
||||
@ -58,6 +70,10 @@ type AddUserRequest struct {
|
||||
PhoneNumber string `json:"phone_number" binding:"required"`
|
||||
UserId string `json:"user_id" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
Email string `json:"email"`
|
||||
Birth string `json:"birth"`
|
||||
Gender string `json:"gender"`
|
||||
Photo string `json:"photo"`
|
||||
}
|
||||
|
||||
type AddUserResponse struct {
|
||||
|
23
pkg/common/callback/callback.go
Normal file
23
pkg/common/callback/callback.go
Normal file
@ -0,0 +1,23 @@
|
||||
package callback
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
func GetContent(msg *server_api_params.MsgData) string {
|
||||
if msg.ContentType >= constant.NotificationBegin && msg.ContentType <= constant.NotificationEnd {
|
||||
var tips server_api_params.TipsComm
|
||||
_ = proto.Unmarshal(msg.Content, &tips)
|
||||
//marshaler := jsonpb.Marshaler{
|
||||
// OrigName: true,
|
||||
// EnumsAsInts: false,
|
||||
// EmitDefaults: false,
|
||||
//}
|
||||
content := tips.JsonDetail
|
||||
return content
|
||||
} else {
|
||||
return string(msg.Content)
|
||||
}
|
||||
}
|
@ -72,6 +72,7 @@ type config struct {
|
||||
EndpointInner string `yaml:"endpointInner"`
|
||||
EndpointInnerEnable bool `yaml:"endpointInnerEnable"`
|
||||
StorageTime int `yaml:"storageTime"`
|
||||
IsDistributedMod bool `yaml:"isDistributedMod"`
|
||||
} `yaml:"minio"`
|
||||
Aws struct {
|
||||
AccessKeyID string `yaml:"accessKeyID"`
|
||||
@ -111,6 +112,7 @@ type config struct {
|
||||
DBPassword string `yaml:"dbPassword"`
|
||||
DBMaxPoolSize int `yaml:"dbMaxPoolSize"`
|
||||
DBRetainChatRecords int `yaml:"dbRetainChatRecords"`
|
||||
ChatRecordsClearTime string `yaml:"chatRecordsClearTime"`
|
||||
}
|
||||
Redis struct {
|
||||
DBAddress []string `yaml:"dbAddress"`
|
||||
@ -136,6 +138,7 @@ type config struct {
|
||||
OpenImOrganizationPort []int `yaml:"openImOrganizationPort"`
|
||||
OpenImConversationPort []int `yaml:"openImConversationPort"`
|
||||
OpenImCachePort []int `yaml:"openImCachePort"`
|
||||
OpenImRealTimeCommPort []int `yaml:"openImRealTimeCommPort"`
|
||||
}
|
||||
RpcRegisterName struct {
|
||||
OpenImStatisticsName string `yaml:"openImStatisticsName"`
|
||||
@ -272,6 +275,7 @@ type config struct {
|
||||
CallbackWordFilter callBackConfig `yaml:"callbackWordFilter"`
|
||||
CallbackUserOnline callBackConfig `yaml:"callbackUserOnline"`
|
||||
CallbackUserOffline callBackConfig `yaml:"callbackUserOffline"`
|
||||
CallbackUserKickOff callBackConfig `yaml:"callbackUserKickOff"`
|
||||
CallbackOfflinePush callBackConfig `yaml:"callbackOfflinePush"`
|
||||
CallbackOnlinePush callBackConfig `yaml:"callbackOnlinePush"`
|
||||
CallbackBeforeSuperGroupOnlinePush callBackConfig `yaml:"callbackSuperGroupOnlinePush"`
|
||||
@ -499,6 +503,11 @@ type config struct {
|
||||
}
|
||||
TestDepartMentID string `yaml:"testDepartMentID"`
|
||||
ImAPIURL string `yaml:"imAPIURL"`
|
||||
NeedInvitationCode bool `yaml:"needInvitationCode"`
|
||||
OnboardProcess bool `yaml:"onboardProcess"`
|
||||
JoinDepartmentIDList []string `yaml:"joinDepartmentIDList"`
|
||||
JoinDepartmentGroups bool `yaml:"joinDepartmentGroups"`
|
||||
OaNotification bool `yaml:"oaNotification"`
|
||||
}
|
||||
Rtc struct {
|
||||
SignalTimeout string `yaml:"signalTimeout"`
|
||||
@ -521,12 +530,21 @@ type PDefaultTips struct {
|
||||
|
||||
func init() {
|
||||
cfgName := os.Getenv("CONFIG_NAME")
|
||||
fmt.Println("get config path is:", Root, cfgName)
|
||||
|
||||
fmt.Println("GET IM DEFAULT CONFIG PATH :", Root, "ENV PATH:", cfgName)
|
||||
if len(cfgName) != 0 {
|
||||
bytes, err := ioutil.ReadFile(filepath.Join(cfgName, "config", "config.yaml"))
|
||||
if err != nil {
|
||||
bytes, err = ioutil.ReadFile(filepath.Join(Root, "config", "config.yaml"))
|
||||
if err != nil {
|
||||
panic(err.Error() + " config: " + filepath.Join(cfgName, "config", "config.yaml"))
|
||||
}
|
||||
} else {
|
||||
Root = cfgName
|
||||
}
|
||||
|
||||
if err = yaml.Unmarshal(bytes, &Config); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
} else {
|
||||
bytes, err := ioutil.ReadFile(filepath.Join(Root, "config", "config.yaml"))
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
@ -535,3 +553,4 @@ func init() {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,6 @@ const (
|
||||
FriendRemarkSetNotification = 1206 //set_friend_remark?
|
||||
BlackAddedNotification = 1207 //add_black
|
||||
BlackDeletedNotification = 1208 //remove_black
|
||||
MsgDeleteNotification = 1209
|
||||
|
||||
ConversationOptChangeNotification = 1300 // change conversation opt
|
||||
|
||||
@ -100,9 +99,11 @@ const (
|
||||
|
||||
SuperGroupNotificationBegin = 1650
|
||||
SuperGroupUpdateNotification = 1651
|
||||
MsgDeleteNotification = 1652
|
||||
SuperGroupNotificationEnd = 1699
|
||||
|
||||
ConversationPrivateChatNotification = 1701
|
||||
ConversationUnreadNotification = 1702
|
||||
|
||||
OrganizationChangedNotification = 1801
|
||||
|
||||
@ -139,6 +140,8 @@ const (
|
||||
WebAndOther = 3
|
||||
//The PC side is mutually exclusive, and the mobile side is mutually exclusive, but the web side can be online at the same time
|
||||
PcMobileAndWeb = 4
|
||||
//The PC terminal can be online at the same time,but other terminal only one of the endpoints can login
|
||||
PCAndOther = 5
|
||||
|
||||
OnlineStatus = "online"
|
||||
OfflineStatus = "offline"
|
||||
@ -200,6 +203,7 @@ const (
|
||||
CallbackWordFilterCommand = "callbackWordFilterCommand"
|
||||
CallbackUserOnlineCommand = "callbackUserOnlineCommand"
|
||||
CallbackUserOfflineCommand = "callbackUserOfflineCommand"
|
||||
CallbackUserKickOffCommand = "callbackUserKickOffCommand"
|
||||
CallbackOfflinePushCommand = "callbackOfflinePushCommand"
|
||||
CallbackOnlinePushCommand = "callbackOnlinePushCommand"
|
||||
CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand"
|
||||
@ -226,6 +230,12 @@ const (
|
||||
WorkMomentLikeNotification = 1
|
||||
WorkMomentAtUserNotification = 2
|
||||
)
|
||||
|
||||
const (
|
||||
WriteDiffusion = 0
|
||||
ReadDiffusion = 1
|
||||
)
|
||||
|
||||
const (
|
||||
AtAllString = "AtAllTag"
|
||||
AtNormal = 0
|
||||
@ -288,6 +298,11 @@ const (
|
||||
Directly = 2 //直接进群
|
||||
)
|
||||
|
||||
const (
|
||||
GroupRPCRecvSize = 30
|
||||
GroupRPCSendSize = 30
|
||||
)
|
||||
|
||||
const FriendAcceptTip = "You have successfully become friends, so start chatting"
|
||||
|
||||
func GroupIsBanChat(status int32) bool {
|
||||
|
@ -50,6 +50,7 @@ var (
|
||||
DBMsg = errors.New("db failed")
|
||||
ArgsMsg = errors.New("args failed")
|
||||
CallBackMsg = errors.New("callback failed")
|
||||
InvitationMsg = errors.New("invitationCode error")
|
||||
|
||||
ThirdPartyMsg = errors.New("third party error")
|
||||
)
|
||||
@ -67,6 +68,9 @@ const (
|
||||
CodeInvalidOrExpired = 10009
|
||||
RegisterFailed = 10010
|
||||
ResetPasswordFailed = 10011
|
||||
RegisterLimit = 10012
|
||||
LoginLimit = 10013
|
||||
InvitationError = 10014
|
||||
DatabaseError = 10002
|
||||
ServerError = 10004
|
||||
HttpError = 10005
|
||||
|
@ -12,6 +12,8 @@ const (
|
||||
WebPlatformID = 5
|
||||
MiniWebPlatformID = 6
|
||||
LinuxPlatformID = 7
|
||||
AndroidPadPlatformID = 8
|
||||
IPadPlatformID = 9
|
||||
|
||||
//Platform string match to Platform ID
|
||||
IOSPlatformStr = "IOS"
|
||||
@ -21,6 +23,8 @@ const (
|
||||
WebPlatformStr = "Web"
|
||||
MiniWebPlatformStr = "MiniWeb"
|
||||
LinuxPlatformStr = "Linux"
|
||||
AndroidPadPlatformStr = "APad"
|
||||
IPadPlatformStr = "IPad"
|
||||
|
||||
//terminal types
|
||||
TerminalPC = "PC"
|
||||
@ -35,6 +39,8 @@ var PlatformID2Name = map[int]string{
|
||||
WebPlatformID: WebPlatformStr,
|
||||
MiniWebPlatformID: MiniWebPlatformStr,
|
||||
LinuxPlatformID: LinuxPlatformStr,
|
||||
AndroidPadPlatformID: AndroidPadPlatformStr,
|
||||
IPadPlatformID: IPadPlatformStr,
|
||||
}
|
||||
var PlatformName2ID = map[string]int{
|
||||
IOSPlatformStr: IOSPlatformID,
|
||||
@ -44,6 +50,8 @@ var PlatformName2ID = map[string]int{
|
||||
WebPlatformStr: WebPlatformID,
|
||||
MiniWebPlatformStr: MiniWebPlatformID,
|
||||
LinuxPlatformStr: LinuxPlatformID,
|
||||
AndroidPadPlatformStr: AndroidPadPlatformID,
|
||||
IPadPlatformStr: IPadPlatformID,
|
||||
}
|
||||
var Platform2class = map[string]string{
|
||||
IOSPlatformStr: TerminalMobile,
|
||||
|
@ -11,11 +11,12 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
go_redis "github.com/go-redis/redis/v8"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -34,6 +35,7 @@ const (
|
||||
FcmToken = "FCM_TOKEN:"
|
||||
groupUserMinSeq = "GROUP_USER_MIN_SEQ:"
|
||||
groupMaxSeq = "GROUP_MAX_SEQ:"
|
||||
groupMinSeq = "GROUP_MIN_SEQ:"
|
||||
sendMsgFailedFlag = "SEND_MSG_FAILED_FLAG:"
|
||||
)
|
||||
|
||||
@ -115,6 +117,11 @@ func (d *DataBases) SetGroupMaxSeq(groupID string, maxSeq uint64) error {
|
||||
return d.RDB.Set(context.Background(), key, maxSeq, 0).Err()
|
||||
}
|
||||
|
||||
func (d *DataBases) SetGroupMinSeq(groupID string, minSeq uint32) error {
|
||||
key := groupMinSeq + groupID
|
||||
return d.RDB.Set(context.Background(), key, minSeq, 0).Err()
|
||||
}
|
||||
|
||||
//Store userid and platform class to redis
|
||||
func (d *DataBases) AddTokenFlag(userID string, platformID int, token string, flag int) error {
|
||||
key := uidPidToken + userID + ":" + constant.PlatformIDToName(platformID)
|
||||
@ -179,7 +186,7 @@ func (d *DataBases) GetMessageListBySeq(userID string, seqList []uint32, operati
|
||||
if err != nil {
|
||||
errResult = err
|
||||
failedSeqList = append(failedSeqList, v)
|
||||
log2.NewWarn(operationID, "redis get message error:", err.Error(), v)
|
||||
log2.Debug(operationID, "redis get message error: ", err.Error(), v)
|
||||
} else {
|
||||
msg := pbCommon.MsgData{}
|
||||
err = jsonpb.UnmarshalString(result, &msg)
|
||||
@ -196,6 +203,7 @@ func (d *DataBases) GetMessageListBySeq(userID string, seqList []uint32, operati
|
||||
}
|
||||
return seqMsg, failedSeqList, errResult
|
||||
}
|
||||
|
||||
func (d *DataBases) SetMessageToCache(msgList []*pbChat.MsgDataToMQ, uid string, operationID string) error {
|
||||
ctx := context.Background()
|
||||
pipe := d.RDB.Pipeline()
|
||||
@ -223,16 +231,14 @@ func (d *DataBases) SetMessageToCache(msgList []*pbChat.MsgDataToMQ, uid string,
|
||||
}
|
||||
func (d *DataBases) DeleteMessageFromCache(msgList []*pbChat.MsgDataToMQ, uid string, operationID string) error {
|
||||
ctx := context.Background()
|
||||
var keys []string
|
||||
for _, msg := range msgList {
|
||||
key := messageCache + uid + "_" + strconv.Itoa(int(msg.MsgData.Seq))
|
||||
keys = append(keys, key)
|
||||
}
|
||||
err := d.RDB.Del(ctx, keys...).Err()
|
||||
err := d.RDB.Del(ctx, key).Err()
|
||||
if err != nil {
|
||||
log2.NewWarn(operationID, utils.GetSelfFuncName(), "redis failed", "args:", keys, uid, err.Error(), msgList)
|
||||
log2.NewWarn(operationID, utils.GetSelfFuncName(), "redis failed", "args:", key, uid, err.Error(), msgList)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DataBases) CleanUpOneUserAllMsgFromRedis(userID string, operationID string) error {
|
||||
@ -246,8 +252,8 @@ func (d *DataBases) CleanUpOneUserAllMsgFromRedis(userID string, operationID str
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
if err = d.RDB.Del(ctx, vals...).Err(); err != nil {
|
||||
return utils.Wrap(err, "")
|
||||
for _, v := range vals {
|
||||
err = d.RDB.Del(ctx, v).Err()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -353,10 +359,18 @@ func (d *DataBases) DelUserSignalList(userID string) error {
|
||||
func (d *DataBases) DelMsgFromCache(uid string, seqList []uint32, operationID string) {
|
||||
for _, seq := range seqList {
|
||||
key := messageCache + uid + "_" + strconv.Itoa(int(seq))
|
||||
result := d.RDB.Get(context.Background(), key).String()
|
||||
result, err := d.RDB.Get(context.Background(), key).Result()
|
||||
if err != nil {
|
||||
if err == go_redis.Nil {
|
||||
log2.NewDebug(operationID, utils.GetSelfFuncName(), err.Error(), "redis nil")
|
||||
} else {
|
||||
log2.NewError(operationID, utils.GetSelfFuncName(), err.Error(), key)
|
||||
}
|
||||
continue
|
||||
}
|
||||
var msg pbCommon.MsgData
|
||||
if err := utils.String2Pb(result, &msg); err != nil {
|
||||
log2.Error(operationID, utils.GetSelfFuncName(), "String2Pb failed", msg, err.Error())
|
||||
log2.Error(operationID, utils.GetSelfFuncName(), "String2Pb failed", msg, result, key, err.Error())
|
||||
continue
|
||||
}
|
||||
msg.Status = constant.MsgDeleted
|
||||
@ -376,8 +390,8 @@ func (d *DataBases) SetGetuiToken(token string, expireTime int64) error {
|
||||
}
|
||||
|
||||
func (d *DataBases) GetGetuiToken() (string, error) {
|
||||
result := d.RDB.Get(context.Background(), getuiToken)
|
||||
return result.String(), result.Err()
|
||||
result, err := d.RDB.Get(context.Background(), getuiToken).Result()
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (d *DataBases) SetSendMsgFailedFlag(operationID string) error {
|
||||
|
@ -26,12 +26,15 @@ func (d *DataBases) BatchInsertChat2DB(userID string, msgList []*pbMsg.MsgDataTo
|
||||
isInit := false
|
||||
var remain uint64
|
||||
blk0 := uint64(GetSingleGocMsgNum() - 1)
|
||||
//currentMaxSeq 4998
|
||||
if currentMaxSeq < uint64(GetSingleGocMsgNum()) {
|
||||
remain = blk0 - currentMaxSeq
|
||||
remain = blk0 - currentMaxSeq //1
|
||||
} else {
|
||||
excludeBlk0 := currentMaxSeq - blk0
|
||||
excludeBlk0 := currentMaxSeq - blk0 //=1
|
||||
//(5000-1)%5000 == 4999
|
||||
remain = (uint64(GetSingleGocMsgNum()) - (excludeBlk0 % uint64(GetSingleGocMsgNum()))) % uint64(GetSingleGocMsgNum())
|
||||
}
|
||||
//remain=1
|
||||
insertCounter := uint64(0)
|
||||
msgListToMongo := make([]MsgInfo, 0)
|
||||
msgListToMongoNext := make([]MsgInfo, 0)
|
||||
@ -45,6 +48,7 @@ func (d *DataBases) BatchInsertChat2DB(userID string, msgList []*pbMsg.MsgDataTo
|
||||
sMsg := MsgInfo{}
|
||||
sMsg.SendTime = m.MsgData.SendTime
|
||||
m.MsgData.Seq = uint32(currentMaxSeq)
|
||||
log.Debug(operationID, "mongo msg node ", m.String(), m.MsgData.ClientMsgID, "userID: ", userID, "seq: ", currentMaxSeq)
|
||||
if sMsg.Msg, err = proto.Marshal(m.MsgData); err != nil {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
@ -58,11 +62,11 @@ func (d *DataBases) BatchInsertChat2DB(userID string, msgList []*pbMsg.MsgDataTo
|
||||
msgListToMongo = append(msgListToMongo, sMsg)
|
||||
insertCounter++
|
||||
seqUid = getSeqUid(userID, uint32(currentMaxSeq))
|
||||
log.Debug(operationID, "msgListToMongo ", seqUid, m.MsgData.Seq, m.MsgData.ClientMsgID, insertCounter, remain)
|
||||
log.Debug(operationID, "msgListToMongo ", seqUid, m.MsgData.Seq, m.MsgData.ClientMsgID, insertCounter, remain, "userID: ", userID)
|
||||
} else {
|
||||
msgListToMongoNext = append(msgListToMongoNext, sMsg)
|
||||
seqUidNext = getSeqUid(userID, uint32(currentMaxSeq))
|
||||
log.Debug(operationID, "msgListToMongoNext ", seqUidNext, m.MsgData.Seq, m.MsgData.ClientMsgID, insertCounter, remain)
|
||||
log.Debug(operationID, "msgListToMongoNext ", seqUidNext, m.MsgData.Seq, m.MsgData.ClientMsgID, insertCounter, remain, "userID: ", userID)
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +75,7 @@ func (d *DataBases) BatchInsertChat2DB(userID string, msgList []*pbMsg.MsgDataTo
|
||||
|
||||
if seqUid != "" {
|
||||
filter := bson.M{"uid": seqUid}
|
||||
log.NewDebug(operationID, "filter ", seqUid, "list ", msgListToMongo)
|
||||
log.NewDebug(operationID, "filter ", seqUid, "list ", msgListToMongo, "userID: ", userID)
|
||||
err := c.FindOneAndUpdate(ctx, filter, bson.M{"$push": bson.M{"msg": bson.M{"$each": msgListToMongo}}}).Err()
|
||||
if err != nil {
|
||||
if err == mongo.ErrNoDocuments {
|
||||
@ -95,7 +99,7 @@ func (d *DataBases) BatchInsertChat2DB(userID string, msgList []*pbMsg.MsgDataTo
|
||||
sChat := UserChat{}
|
||||
sChat.UID = seqUidNext
|
||||
sChat.Msg = msgListToMongoNext
|
||||
log.NewDebug(operationID, "filter ", seqUidNext, "list ", msgListToMongoNext)
|
||||
log.NewDebug(operationID, "filter ", seqUidNext, "list ", msgListToMongoNext, "userID: ", userID)
|
||||
if _, err = c.InsertOne(ctx, &sChat); err != nil {
|
||||
log.NewError(operationID, "InsertOne failed", filter, err.Error(), sChat)
|
||||
return utils.Wrap(err, "")
|
||||
@ -119,8 +123,10 @@ func (d *DataBases) BatchInsertChat2Cache(insertID string, msgList []*pbMsg.MsgD
|
||||
var err error
|
||||
if msgList[0].MsgData.SessionType == constant.SuperGroupChatType {
|
||||
currentMaxSeq, err = d.GetGroupMaxSeq(insertID)
|
||||
log.Debug(operationID, "constant.SuperGroupChatType lastMaxSeq before add ", currentMaxSeq, "userID ", insertID, err)
|
||||
} else {
|
||||
currentMaxSeq, err = d.GetUserMaxSeq(insertID)
|
||||
log.Debug(operationID, "constant.SingleChatType lastMaxSeq before add ", currentMaxSeq, "userID ", insertID, err)
|
||||
}
|
||||
if err != nil && err != go_redis.Nil {
|
||||
return utils.Wrap(err, ""), 0
|
||||
@ -128,11 +134,12 @@ func (d *DataBases) BatchInsertChat2Cache(insertID string, msgList []*pbMsg.MsgD
|
||||
|
||||
lastMaxSeq := currentMaxSeq
|
||||
for _, m := range msgList {
|
||||
log.Debug(operationID, "msg node ", m.String(), m.MsgData.ClientMsgID)
|
||||
|
||||
currentMaxSeq++
|
||||
sMsg := MsgInfo{}
|
||||
sMsg.SendTime = m.MsgData.SendTime
|
||||
m.MsgData.Seq = uint32(currentMaxSeq)
|
||||
log.Debug(operationID, "cache msg node ", m.String(), m.MsgData.ClientMsgID, "userID: ", insertID, "seq: ", currentMaxSeq)
|
||||
}
|
||||
log.Debug(operationID, "SetMessageToCache ", insertID, len(msgList))
|
||||
err = d.SetMessageToCache(msgList, insertID, operationID)
|
||||
|
@ -8,6 +8,16 @@ type Register struct {
|
||||
Ex string `gorm:"column:ex;size:1024" json:"ex"`
|
||||
UserID string `gorm:"column:user_id;type:varchar(255)" json:"userID"`
|
||||
AreaCode string `gorm:"column:area_code;type:varchar(255)"`
|
||||
InvitationCode string `gorm:"column:invitation_code;type:varchar(255)"`
|
||||
RegisterIP string `gorm:"column:register_ip;type:varchar(255)"`
|
||||
}
|
||||
|
||||
type Invitation struct {
|
||||
InvitationCode string `gorm:"column:invitation_code;primary_key;type:varchar(32)"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
UserID string `gorm:"column:user_id"`
|
||||
LastTime time.Time `gorm:"column:last_time"`
|
||||
Status int32 `gorm:"column:status"`
|
||||
}
|
||||
|
||||
//
|
||||
@ -153,8 +163,9 @@ type GroupRequest struct {
|
||||
//string Birth = 6;
|
||||
//string Email = 7;
|
||||
//string Ex = 8;
|
||||
//int64 CreateTime = 9;
|
||||
//int32 AppMangerLevel = 10;
|
||||
//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"`
|
||||
@ -166,11 +177,31 @@ type User struct {
|
||||
Email string `gorm:"column:email;size:64"`
|
||||
Ex string `gorm:"column:ex;size:1024"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
CreateIp string `gorm:"column:create_ip;size:15"`
|
||||
LastLoginTime time.Time `gorm:"column:last_login_time"`
|
||||
LastLoginIp string `gorm:"column:last_login_ip;size:15"`
|
||||
LoginTimes int32 `gorm:"column:login_times"`
|
||||
LoginLimit int32 `gorm:"column:login_limit"`
|
||||
AppMangerLevel int32 `gorm:"column:app_manger_level"`
|
||||
GlobalRecvMsgOpt int32 `gorm:"column:global_recv_msg_opt"`
|
||||
InvitationCode string `gorm:"column:invitation_code"`
|
||||
status int32 `gorm:"column:status"`
|
||||
}
|
||||
|
||||
type IpLimit struct {
|
||||
Ip string `gorm:"column:ip;primary_key;size:15"`
|
||||
LimitRegister int32 `gorm:"column:limit_register;size:1"`
|
||||
LimitLogin int32 `gorm:"column:limit_login;size:1"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
LimitTime time.Time `gorm:"column:limit_time"`
|
||||
}
|
||||
|
||||
type UserIpLimit struct {
|
||||
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
||||
Ip string `gorm:"column:ip;primary_key;size:15"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
}
|
||||
|
||||
//message BlackInfo{
|
||||
//string OwnerUserID = 1;
|
||||
//int64 CreateTime = 2;
|
||||
@ -229,6 +260,7 @@ type Conversation struct {
|
||||
IsPrivateChat bool `gorm:"column:is_private_chat" json:"isPrivateChat"`
|
||||
GroupAtType int32 `gorm:"column:group_at_type" json:"groupAtType"`
|
||||
IsNotInGroup bool `gorm:"column:is_not_in_group" json:"isNotInGroup"`
|
||||
UpdateUnreadCountTime int64 `gorm:"column:update_unread_count_time" json:"updateUnreadCountTime"`
|
||||
AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
|
||||
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
||||
}
|
||||
@ -299,3 +331,19 @@ type AppVersion struct {
|
||||
func (AppVersion) TableName() string {
|
||||
return "app_version"
|
||||
}
|
||||
|
||||
type RegisterAddFriend struct {
|
||||
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
||||
}
|
||||
|
||||
func (RegisterAddFriend) TableName() string {
|
||||
return "register_add_friend"
|
||||
}
|
||||
|
||||
type ClientInitConfig struct {
|
||||
DiscoverPageURL string `gorm:"column:discover_page_url;size:64" json:"version"`
|
||||
}
|
||||
|
||||
func (ClientInitConfig) TableName() string {
|
||||
return "client_init_config"
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ type MsgInfo struct {
|
||||
|
||||
type UserChat struct {
|
||||
UID string
|
||||
//ListIndex int `bson:"index"`
|
||||
Msg []MsgInfo
|
||||
}
|
||||
|
||||
@ -258,6 +259,75 @@ func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32, operationID st
|
||||
return seqMsg, nil
|
||||
}
|
||||
|
||||
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)
|
||||
findOpts := options.Find().SetLimit(1).SetSkip(index).SetSort(bson.M{"uid": 1})
|
||||
var msgs []UserChat
|
||||
cursor, err := c.Find(ctx, bson.M{"uid": bson.M{"$regex": regex}}, findOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = cursor.Decode(&msgs)
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
if len(msgs) > 0 {
|
||||
return &msgs[0], err
|
||||
} else {
|
||||
return nil, errors.New("get msg list failed")
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DataBases) DelMongoMsgs(IDList []string) error {
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||
_, err := c.DeleteMany(ctx, bson.M{"uid": bson.M{"$in": IDList}})
|
||||
return err
|
||||
}
|
||||
|
||||
func (d *DataBases) ReplaceMsgToBlankByIndex(suffixID string, 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)
|
||||
userChat := &UserChat{}
|
||||
err := c.FindOne(ctx, bson.M{"uid": suffixID}).Decode(&userChat)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for i, msg := range userChat.Msg {
|
||||
if i <= index {
|
||||
msg.Msg = nil
|
||||
msg.SendTime = 0
|
||||
}
|
||||
}
|
||||
_, err = c.UpdateOne(ctx, bson.M{"uid": suffixID}, userChat)
|
||||
return err
|
||||
}
|
||||
|
||||
func (d *DataBases) GetNewestMsg(ID string) (msg *MsgInfo, 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)
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = cursor.Decode(&userChats)
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
if len(userChats) > 0 {
|
||||
if len(userChats[0].Msg) > 0 {
|
||||
return &userChats[0].Msg[len(userChats[0].Msg)], nil
|
||||
}
|
||||
return nil, errors.New("len(userChats[0].Msg) < 0")
|
||||
}
|
||||
return nil, errors.New("len(userChats) < 0")
|
||||
}
|
||||
|
||||
func (d *DataBases) GetMsgBySeqListMongo2(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
||||
var hasSeqList []uint32
|
||||
singleCount := 0
|
||||
@ -945,14 +1015,14 @@ func (d *DataBases) GetUserFriendWorkMoments(showNumber, pageNumber int32, userI
|
||||
}
|
||||
|
||||
type SuperGroup struct {
|
||||
GroupID string `bson:"group_id"`
|
||||
GroupID string `bson:"group_id" json:"groupID"`
|
||||
//MemberNumCount int `bson:"member_num_count"`
|
||||
MemberIDList []string `bson:"member_id_list"`
|
||||
MemberIDList []string `bson:"member_id_list" json:"memberIDList"`
|
||||
}
|
||||
|
||||
type UserToSuperGroup struct {
|
||||
UserID string `bson:"user_id"`
|
||||
GroupIDList []string `bson:"group_id_list"`
|
||||
UserID string `bson:"user_id" json:"userID"`
|
||||
GroupIDList []string `bson:"group_id_list" json:"groupIDList"`
|
||||
}
|
||||
|
||||
func (d *DataBases) CreateSuperGroup(groupID string, initMemberIDList []string, memberNumCount int) error {
|
||||
@ -1074,7 +1144,8 @@ func (d *DataBases) GetSuperGroupByUserID(userID string) (UserToSuperGroup, erro
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cUserToSuperGroup)
|
||||
var user UserToSuperGroup
|
||||
return user, c.FindOne(ctx, bson.M{"user_id": userID}).Decode(&user)
|
||||
_ = c.FindOne(ctx, bson.M{"user_id": userID}).Decode(&user)
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (d *DataBases) DeleteSuperGroup(groupID string) error {
|
||||
@ -1191,6 +1262,7 @@ func isNotContainInt32(target uint32, List []uint32) bool {
|
||||
func indexGen(uid string, seqSuffix uint32) string {
|
||||
return uid + ":" + strconv.FormatInt(int64(seqSuffix), 10)
|
||||
}
|
||||
|
||||
func superGroupIndexGen(groupID string, seqSuffix uint32) string {
|
||||
return "super_group_" + groupID + ":" + strconv.FormatInt(int64(seqSuffix), 10)
|
||||
}
|
||||
|
@ -2,14 +2,13 @@ package db
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"gorm.io/gorm/logger"
|
||||
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
)
|
||||
|
||||
type mysqlDB struct {
|
||||
@ -79,7 +78,8 @@ func initMysqlDB() {
|
||||
&GroupMember{},
|
||||
&GroupRequest{},
|
||||
&User{},
|
||||
&Black{}, &ChatLog{}, &Register{}, &Conversation{}, &AppVersion{}, &Department{})
|
||||
&Black{}, &ChatLog{}, &Register{}, &Conversation{}, &AppVersion{}, &Department{}, &BlackList{}, &IpLimit{}, &UserIpLimit{}, &Invitation{}, &RegisterAddFriend{},
|
||||
&ClientInitConfig{})
|
||||
db.Set("gorm:table_options", "CHARSET=utf8")
|
||||
db.Set("gorm:table_options", "collation=utf8_unicode_ci")
|
||||
|
||||
@ -143,6 +143,33 @@ func initMysqlDB() {
|
||||
fmt.Println("CreateTable DepartmentMember")
|
||||
db.Migrator().CreateTable(&AppVersion{})
|
||||
}
|
||||
if !db.Migrator().HasTable(&BlackList{}) {
|
||||
fmt.Println("CreateTable BlackList")
|
||||
db.Migrator().CreateTable(&BlackList{})
|
||||
}
|
||||
if !db.Migrator().HasTable(&IpLimit{}) {
|
||||
fmt.Println("CreateTable IpLimit")
|
||||
db.Migrator().CreateTable(&IpLimit{})
|
||||
}
|
||||
if !db.Migrator().HasTable(&UserIpLimit{}) {
|
||||
fmt.Println("CreateTable UserIpLimit")
|
||||
db.Migrator().CreateTable(&UserIpLimit{})
|
||||
}
|
||||
|
||||
if !db.Migrator().HasTable(&RegisterAddFriend{}) {
|
||||
fmt.Println("CreateTable RegisterAddFriend")
|
||||
db.Migrator().CreateTable(&RegisterAddFriend{})
|
||||
}
|
||||
if !db.Migrator().HasTable(&Invitation{}) {
|
||||
fmt.Println("CreateTable Invitation")
|
||||
db.Migrator().CreateTable(&Invitation{})
|
||||
}
|
||||
|
||||
if !db.Migrator().HasTable(&ClientInitConfig{}) {
|
||||
fmt.Println("CreateTable ClientInitConfig")
|
||||
db.Migrator().CreateTable(&ClientInitConfig{})
|
||||
}
|
||||
|
||||
DB.MysqlDB.db = db
|
||||
return
|
||||
}
|
||||
|
22
pkg/common/db/mysql_model/im_mysql_model/client_config.go
Normal file
22
pkg/common/db/mysql_model/im_mysql_model/client_config.go
Normal file
@ -0,0 +1,22 @@
|
||||
package im_mysql_model
|
||||
|
||||
import "Open_IM/pkg/common/db"
|
||||
|
||||
func SetClientInitConfig(m map[string]interface{}) error {
|
||||
result := db.DB.MysqlDB.DefaultGormDB().Model(&db.ClientInitConfig{}).Where("1=1").Updates(m)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
if result.RowsAffected == 0 {
|
||||
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.ClientInitConfig{}).Create(m).Error
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetClientInitConfig() (db.ClientInitConfig, error) {
|
||||
var config db.ClientInitConfig
|
||||
err := db.DB.MysqlDB.DefaultGormDB().Model((&db.ClientInitConfig{})).First(&config).Error
|
||||
return config, err
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user