mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-12 21:16:00 +08:00
Compare commits
135 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b03b57b5c | |||
| 77c6120014 | |||
| b82ff7b88d | |||
| a16a75230c | |||
| 0e27b302bc | |||
| c369ab9b1c | |||
| bb267ccae7 | |||
| efe24658a4 | |||
| 5cdf9e7551 | |||
| 4390302384 | |||
| dab00e7fb2 | |||
| 929c5e7a5b | |||
| d600042110 | |||
| 0a58e7433e | |||
| 5639c985df | |||
| 9fbfbfb23b | |||
| ecd2f0e2bf | |||
| 60418276bd | |||
| 170392f0bc | |||
| 6744745152 | |||
| 009ae6a235 | |||
| bf5f72c00b | |||
| 84aca5b9e1 | |||
| 6164266870 | |||
| cc9df9c586 | |||
| 29a268d476 | |||
| 18d7aab703 | |||
| 373e6b6c8e | |||
| 71fab4f6be | |||
| de55c14a16 | |||
| e8517e954d | |||
| 78281fc82c | |||
| bc260fffde | |||
| db00a08bdc | |||
| 85cf7f26ce | |||
| acca147ff2 | |||
| d53da0e422 | |||
| 11eaaab72d | |||
| 475e64fc5b | |||
| 1bd8154ac4 | |||
| d2fa0e7852 | |||
| f2b324abc2 | |||
| d2225dd841 | |||
| 8d26aa86b9 | |||
| 7e937d7d29 | |||
| fe4b534b78 | |||
| d0a65c7c68 | |||
| 416f87f4bb | |||
| 7eeb67be28 | |||
| 7ed6ee5075 | |||
| d3c8215e15 | |||
| 30bc6c274e | |||
| ecb1068f0b | |||
| f6eef21b45 | |||
| 1aeff25316 | |||
| 6de569537f | |||
| 764bc3fead | |||
| a89d617532 | |||
| fef33795d0 | |||
| d2c04b761d | |||
| c5828aba91 | |||
| 1286f9dcb6 | |||
| 391e525fc5 | |||
| afc32b1cfa | |||
| 0797181967 | |||
| 14c5e631ff | |||
| 5cdb039c33 | |||
| a11c4fcb58 | |||
| c67a937d40 | |||
| 03fa7137b9 | |||
| e95400988e | |||
| 942c9c6a63 | |||
| 6c45665fde | |||
| d92ac8f588 | |||
| 169665da32 | |||
| c4d80b4844 | |||
| 7827749453 | |||
| 5e78697a69 | |||
| a0e6a78496 | |||
| af99a93536 | |||
| e9ea117985 | |||
| b9ddb0140f | |||
| dae70371d1 | |||
| 228cbb4082 | |||
| 679c913f3a | |||
| 03fb7947c3 | |||
| c39f5a27b2 | |||
| dbdb516f3c | |||
| c1a97b7356 | |||
| a6d8f7ea24 | |||
| 574c7600e0 | |||
| d1c0205d77 | |||
| 13c29d2c1e | |||
| dc1a0f050e | |||
| e252a00d55 | |||
| 5bedbb7c7d | |||
| e510418152 | |||
| 8197ae6aa7 | |||
| 9d619d520d | |||
| 46605479e9 | |||
| 6d20eddd43 | |||
| c1ee2a0adb | |||
| 9d29d49ada | |||
| e7b95892ff | |||
| 4bf5c77374 | |||
| df4a75f4b0 | |||
| 4bdb4cbbb5 | |||
| 4cdcdee8e4 | |||
| e6c36411cb | |||
| a4788a95af | |||
| b5de638c0b | |||
| c1a210313e | |||
| ab0ed67f81 | |||
| 5d54d5b7d6 | |||
| 1d09ffa529 | |||
| eef9d15aaa | |||
| 8034ddc413 | |||
| e75adb165a | |||
| 09ce0d5285 | |||
| cc1ad41e94 | |||
| 8a38646bc5 | |||
| a2b65f52f6 | |||
| c16d8da784 | |||
| a55582a018 | |||
| ea6d472002 | |||
| 3dc4290f2a | |||
| 6c43f75f9f | |||
| e0c6972bed | |||
| 1ab3e04cba | |||
| 1b8f664c8a | |||
| 7637b2bec2 | |||
| cfab49a7dd | |||
| 91b9e50fd0 | |||
| ebf7a1d40d | |||
| d3a38963ae |
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
name: "\U0001F41E Bug"
|
||||||
|
about: File a bug/issue
|
||||||
|
title: "[BUG] <title>"
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Note: Please search to see if an issue already exists for the bug you encountered.
|
||||||
|
-->
|
||||||
|
|
||||||
|
### Environment:
|
||||||
|
<!-- linux? windows? or Mac?
|
||||||
|
Example:
|
||||||
|
- OS: Ubuntu 20.04 -->
|
||||||
|
|
||||||
|
### Physical Memory Capacity:
|
||||||
|
<!-- 8G or above is better -->
|
||||||
|
|
||||||
|
### Docker Image:
|
||||||
|
<!-- Did you pull the docker image before execute docker images -->
|
||||||
|
|
||||||
|
### Code Version:
|
||||||
|
<!-- Did you pull code from github? Make sure the code is up to date-->
|
||||||
|
|
||||||
|
### Component installation:
|
||||||
|
<!-- Has etcd, mysql, mongodb, redis or Kafka been installed on the server before Open-IM-Server deployment-->
|
||||||
|
|
||||||
|
|
||||||
|
### Log File:
|
||||||
|
<!-- view log file(logs/openIM.log) content. -->
|
||||||
|
|
||||||
|
|
||||||
|
### screenshot:
|
||||||
|
<!---->
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
name: Deployment issues
|
||||||
|
about: Deployment issues
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
If you are deploying OpenIM for the first time
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive
|
||||||
|
```
|
||||||
|
|
||||||
|
screenshot here
|
||||||
|
|
||||||
|
```
|
||||||
|
cd Open-IM-Server/script ; chmod +x *.sh ; ./env_check.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
screenshot here
|
||||||
|
|
||||||
|
```
|
||||||
|
cd .. ; docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
screenshot here
|
||||||
|
|
||||||
|
```
|
||||||
|
cd script ; ./docker_check_service.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
screenshot here
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
name: 'update '
|
||||||
|
about: update docker image
|
||||||
|
title: update docker image
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
cd Open-IM-Server ; docker-compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
screenshot here
|
||||||
|
|
||||||
|
```
|
||||||
|
git pull
|
||||||
|
```
|
||||||
|
|
||||||
|
screenshot here
|
||||||
|
|
||||||
|
```
|
||||||
|
docker-compose pull
|
||||||
|
```
|
||||||
|
|
||||||
|
screenshot here
|
||||||
|
|
||||||
|
```
|
||||||
|
chmod +x script/*.sh ; docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
screenshot here
|
||||||
|
|
||||||
|
```
|
||||||
|
cd script ; ./docker_check_service.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
screenshot here
|
||||||
@@ -7,6 +7,7 @@ out-test
|
|||||||
.github
|
.github
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
|
||||||
deploy/open_im_demo
|
deploy/open_im_demo
|
||||||
deploy/open_im_api
|
deploy/open_im_api
|
||||||
deploy/open_im_msg_gateway
|
deploy/open_im_msg_gateway
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
|
|||||||
4. Start docker-compose with one click(Docker automatically pulls all images)
|
4. Start docker-compose with one click(Docker automatically pulls all images)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
cd Open-IM-Server
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -99,6 +100,7 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
|
|||||||
|
|
||||||
```
|
```
|
||||||
./docker_check_service.sh
|
./docker_check_service.sh
|
||||||
|
./check_all.sh
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
+1
-1
Submodule cmd/Open-IM-SDK-Core updated: a06dfeeda5...7b66c0ab78
+22
-5
@@ -7,8 +7,10 @@ import (
|
|||||||
"Open_IM/internal/api/friend"
|
"Open_IM/internal/api/friend"
|
||||||
"Open_IM/internal/api/group"
|
"Open_IM/internal/api/group"
|
||||||
"Open_IM/internal/api/manage"
|
"Open_IM/internal/api/manage"
|
||||||
|
"Open_IM/internal/api/office"
|
||||||
apiThird "Open_IM/internal/api/third"
|
apiThird "Open_IM/internal/api/third"
|
||||||
"Open_IM/internal/api/user"
|
"Open_IM/internal/api/user"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"flag"
|
"flag"
|
||||||
@@ -66,6 +68,11 @@ func main() {
|
|||||||
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
||||||
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
||||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
|
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
|
||||||
|
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
|
||||||
|
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
|
||||||
|
groupRouterGroup.POST("/cancel_mute_group_member", group.CancelMuteGroupMember) //MuteGroup
|
||||||
|
groupRouterGroup.POST("/mute_group", group.MuteGroup)
|
||||||
|
groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup)
|
||||||
}
|
}
|
||||||
//certificate
|
//certificate
|
||||||
authRouterGroup := r.Group("/auth")
|
authRouterGroup := r.Group("/auth")
|
||||||
@@ -77,7 +84,9 @@ func main() {
|
|||||||
thirdGroup := r.Group("/third")
|
thirdGroup := r.Group("/third")
|
||||||
{
|
{
|
||||||
thirdGroup.POST("/tencent_cloud_storage_credential", apiThird.TencentCloudStorageCredential)
|
thirdGroup.POST("/tencent_cloud_storage_credential", apiThird.TencentCloudStorageCredential)
|
||||||
|
thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential)
|
||||||
thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential)
|
thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential)
|
||||||
|
thirdGroup.POST("/minio_upload", apiThird.MinioUploadFile)
|
||||||
}
|
}
|
||||||
//Message
|
//Message
|
||||||
chatGroup := r.Group("/msg")
|
chatGroup := r.Group("/msg")
|
||||||
@@ -106,12 +115,20 @@ func main() {
|
|||||||
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
||||||
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
||||||
}
|
}
|
||||||
|
// office
|
||||||
|
officeGroup := r.Group("/office")
|
||||||
|
{
|
||||||
|
officeGroup.POST("/get_user_tags", office.GetUserTags)
|
||||||
|
officeGroup.POST("/get_user_tag_by_id", office.GetUserTagByID)
|
||||||
|
officeGroup.POST("/create_tag", office.CreateTag)
|
||||||
|
officeGroup.POST("/delete_tag", office.DeleteTag)
|
||||||
|
officeGroup.POST("/set_tag", office.SetTag)
|
||||||
|
officeGroup.POST("/send_msg_to_tag", office.SendMsg2Tag)
|
||||||
|
officeGroup.POST("/get_send_tag_log", office.GetTagSendLogs)
|
||||||
|
}
|
||||||
apiThird.MinioInit()
|
apiThird.MinioInit()
|
||||||
log.NewPrivateLog("api")
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
|
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
err := r.Run(":" + strconv.Itoa(*ginPort))
|
r.Run(":" + strconv.Itoa(*ginPort))
|
||||||
if err != nil {
|
|
||||||
log.NewError("", utils.GetSelfFuncName(), "start gin failed", err.Error())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/demo/register"
|
"Open_IM/internal/demo/register"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"flag"
|
"flag"
|
||||||
@@ -23,7 +24,7 @@ func main() {
|
|||||||
authRouterGroup.POST("/login", register.Login)
|
authRouterGroup.POST("/login", register.Login)
|
||||||
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||||
}
|
}
|
||||||
log.NewPrivateLog("demo")
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
|
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
r.Run(":" + strconv.Itoa(*ginPort))
|
r.Run(":" + strconv.Itoa(*ginPort))
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
commonDB "Open_IM/pkg/common/db"
|
commonDB "Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
@@ -8,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.NewPrivateLog("timer")
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
//for {
|
//for {
|
||||||
// fmt.Println("start delete mongodb expired record")
|
// fmt.Println("start delete mongodb expired record")
|
||||||
// timeUnixBegin := time.Now().Unix()
|
// timeUnixBegin := time.Now().Unix()
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
|
BINARY_NAME=open_im_office
|
||||||
|
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
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
rpc "Open_IM/internal/rpc/office"
|
||||||
|
"flag"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
rpcPort := flag.Int("port", 11100, "rpc listening port")
|
||||||
|
flag.Parse()
|
||||||
|
rpcServer := rpc.NewOfficeServer(*rpcPort)
|
||||||
|
rpcServer.Run()
|
||||||
|
}
|
||||||
+90
-1
@@ -19,7 +19,8 @@ mysql:
|
|||||||
dbMaxLifeTime: 120
|
dbMaxLifeTime: 120
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
dbAddress: [ 127.0.0.1:37017 ] #redis地址 目前仅支持单机,默认即可
|
dbUri: ""#当dbUri值不为空则直接使用该值
|
||||||
|
dbAddress: [ 127.0.0.1:37017 ] #mongo地址 目前仅支持单机,默认即可
|
||||||
dbDirect: false
|
dbDirect: false
|
||||||
dbTimeout: 10
|
dbTimeout: 10
|
||||||
dbDatabase: openIM #mongo db 默认即可
|
dbDatabase: openIM #mongo db 默认即可
|
||||||
@@ -72,6 +73,7 @@ endpoints:
|
|||||||
rpc_statistic: openim_rpc_statistic
|
rpc_statistic: openim_rpc_statistic
|
||||||
rpc_admin_cms: openim_rpc_admin_cms
|
rpc_admin_cms: openim_rpc_admin_cms
|
||||||
rpc_message_cms: openim_rpc_admin_cms
|
rpc_message_cms: openim_rpc_admin_cms
|
||||||
|
rpc_office: openim_rpc_office
|
||||||
|
|
||||||
api:
|
api:
|
||||||
openImApiPort: [ 10000 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
|
openImApiPort: [ 10000 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||||
@@ -93,6 +95,17 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
|||||||
endpoint: http://127.0.0.1:9000
|
endpoint: http://127.0.0.1:9000
|
||||||
accessKeyID: user12345
|
accessKeyID: user12345
|
||||||
secretAccessKey: key12345
|
secretAccessKey: key12345
|
||||||
|
ali: # ali oss
|
||||||
|
regionID: "oss-cn-beijing"
|
||||||
|
accessKeyID: ""
|
||||||
|
accessKeySecret: ""
|
||||||
|
stsEndpoint: "sts.cn-beijing.aliyun.com"
|
||||||
|
ossEndpoint: "oss-cn-beijing.aliyuncs.com"
|
||||||
|
bucket: "bucket1"
|
||||||
|
finalHost: "http://bucket1.oss-cn-beijing.aliyuncs.com"
|
||||||
|
stsDurationSeconds: 3600
|
||||||
|
OssRoleArn: "acs:ram::xxx:role/xxx"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rpcport: #rpc服务端口 默认即可
|
rpcport: #rpc服务端口 默认即可
|
||||||
@@ -106,6 +119,7 @@ rpcport: #rpc服务端口 默认即可
|
|||||||
openImStatisticsPort: [ 10800 ]
|
openImStatisticsPort: [ 10800 ]
|
||||||
openImMessageCmsPort: [ 10900 ]
|
openImMessageCmsPort: [ 10900 ]
|
||||||
openImAdminCmsPort: [ 11000 ]
|
openImAdminCmsPort: [ 11000 ]
|
||||||
|
openImOfficePort: [ 11100 ]
|
||||||
c2c:
|
c2c:
|
||||||
callbackBeforeSendMsg:
|
callbackBeforeSendMsg:
|
||||||
switch: false
|
switch: false
|
||||||
@@ -127,6 +141,7 @@ rpcregistername: #rpc注册服务名,默认即可
|
|||||||
OpenImStatisticsName: Statistics
|
OpenImStatisticsName: Statistics
|
||||||
OpenImMessageCMSName: MessageCMS
|
OpenImMessageCMSName: MessageCMS
|
||||||
openImAdminCMSName: AdminCMS
|
openImAdminCMSName: AdminCMS
|
||||||
|
openImOfficeName: Office
|
||||||
|
|
||||||
log:
|
log:
|
||||||
storageLocation: ../logs/
|
storageLocation: ../logs/
|
||||||
@@ -340,6 +355,67 @@ notification:
|
|||||||
defaultTips:
|
defaultTips:
|
||||||
tips: "entered the group" # group info changed by xx
|
tips: "entered the group" # group info changed by xx
|
||||||
|
|
||||||
|
groupDismissed:
|
||||||
|
conversation:
|
||||||
|
reliabilityLevel: 3
|
||||||
|
unreadCount: true
|
||||||
|
offlinePush:
|
||||||
|
switch: false
|
||||||
|
title: "groupDismissed title"
|
||||||
|
desc: "groupDismissed desc"
|
||||||
|
ext: "groupDismissed ext"
|
||||||
|
defaultTips:
|
||||||
|
tips: "group dismissed"
|
||||||
|
|
||||||
|
|
||||||
|
groupMuted:
|
||||||
|
conversation:
|
||||||
|
reliabilityLevel: 3
|
||||||
|
unreadCount: true
|
||||||
|
offlinePush:
|
||||||
|
switch: false
|
||||||
|
title: "groupMuted title"
|
||||||
|
desc: "groupMuted desc"
|
||||||
|
ext: "groupMuted ext"
|
||||||
|
defaultTips:
|
||||||
|
tips: "group Muted"
|
||||||
|
|
||||||
|
groupCancelMuted:
|
||||||
|
conversation:
|
||||||
|
reliabilityLevel: 3
|
||||||
|
unreadCount: true
|
||||||
|
offlinePush:
|
||||||
|
switch: false
|
||||||
|
title: "groupCancelMuted title"
|
||||||
|
desc: "groupCancelMuted desc"
|
||||||
|
ext: "groupCancelMuted ext"
|
||||||
|
defaultTips:
|
||||||
|
tips: "group Cancel Muted"
|
||||||
|
|
||||||
|
|
||||||
|
groupMemberMuted:
|
||||||
|
conversation:
|
||||||
|
reliabilityLevel: 3
|
||||||
|
unreadCount: true
|
||||||
|
offlinePush:
|
||||||
|
switch: false
|
||||||
|
title: "groupMemberMuted title"
|
||||||
|
desc: "groupMemberMuted desc"
|
||||||
|
ext: "groupMemberMuted ext"
|
||||||
|
defaultTips:
|
||||||
|
tips: "group Member Muted"
|
||||||
|
|
||||||
|
groupMemberCancelMuted:
|
||||||
|
conversation:
|
||||||
|
reliabilityLevel: 3
|
||||||
|
unreadCount: true
|
||||||
|
offlinePush:
|
||||||
|
switch: false
|
||||||
|
title: "groupMemberCancelMuted title"
|
||||||
|
desc: "groupMemberCancelMuted desc"
|
||||||
|
ext: "groupMemberCancelMuted ext"
|
||||||
|
defaultTips:
|
||||||
|
tips: "group Member Cancel Muted"
|
||||||
#############################friend#################################
|
#############################friend#################################
|
||||||
|
|
||||||
friendApplicationAdded:
|
friendApplicationAdded:
|
||||||
@@ -475,6 +551,19 @@ notification:
|
|||||||
defaultTips:
|
defaultTips:
|
||||||
tips: "conversation opt update"
|
tips: "conversation opt update"
|
||||||
|
|
||||||
|
conversationSetPrivate:
|
||||||
|
conversation:
|
||||||
|
reliabilityLevel: 2
|
||||||
|
unreadCount: true
|
||||||
|
offlinePush:
|
||||||
|
switch: true
|
||||||
|
title: "burn after reading"
|
||||||
|
desc: "burn after reading"
|
||||||
|
ext: "burn after reading"
|
||||||
|
defaultTips:
|
||||||
|
openTips: "burn after reading was opened"
|
||||||
|
closeTips: "burn after reading was closed"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---------------demo configuration---------------------#
|
#---------------demo configuration---------------------#
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ mysql:
|
|||||||
dbMaxLifeTime: 120
|
dbMaxLifeTime: 120
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
|
dbUri: ""#当dbUri值不为空则直接使用该值
|
||||||
dbAddress: [ openim_mongo:27017 ]
|
dbAddress: [ openim_mongo:27017 ]
|
||||||
dbDirect: false
|
dbDirect: false
|
||||||
dbTimeout: 10
|
dbTimeout: 10
|
||||||
|
|||||||
+2
-1
@@ -32,6 +32,7 @@ services:
|
|||||||
# - MONGO_INITDB_ROOT_USERNAME=openIM
|
# - MONGO_INITDB_ROOT_USERNAME=openIM
|
||||||
# - MONGO_INITDB_ROOT_PASSWORD=openIM
|
# - MONGO_INITDB_ROOT_PASSWORD=openIM
|
||||||
|
|
||||||
|
|
||||||
#TZ: Asia/Shanghai
|
#TZ: Asia/Shanghai
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
@@ -93,7 +94,7 @@ services:
|
|||||||
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
|
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
|
||||||
|
|
||||||
open_im_server:
|
open_im_server:
|
||||||
image: openim/open_im_server:v2.0.2
|
image: openim/open_im_server:v2.0.5
|
||||||
container_name: open_im_server
|
container_name: open_im_server
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/Open-IM-Server/logs
|
- ./logs:/Open-IM-Server/logs
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ require (
|
|||||||
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
|
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
|
||||||
github.com/alibabacloud-go/darabonba-openapi v0.1.11
|
github.com/alibabacloud-go/darabonba-openapi v0.1.11
|
||||||
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8
|
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8
|
||||||
|
github.com/alibabacloud-go/sts-20150401 v1.1.0
|
||||||
github.com/alibabacloud-go/tea v1.1.17
|
github.com/alibabacloud-go/tea v1.1.17
|
||||||
github.com/antonfisher/nested-logrus-formatter v1.3.0
|
github.com/antonfisher/nested-logrus-formatter v1.3.0
|
||||||
github.com/bwmarrin/snowflake v0.3.0
|
github.com/bwmarrin/snowflake v0.3.0
|
||||||
@@ -21,7 +22,7 @@ require (
|
|||||||
github.com/gin-gonic/gin v1.7.0
|
github.com/gin-gonic/gin v1.7.0
|
||||||
github.com/go-playground/validator/v10 v10.4.1
|
github.com/go-playground/validator/v10 v10.4.1
|
||||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2
|
||||||
github.com/golang-jwt/jwt/v4 v4.1.0
|
github.com/golang-jwt/jwt/v4 v4.1.0
|
||||||
github.com/golang/protobuf v1.5.2
|
github.com/golang/protobuf v1.5.2
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
@@ -59,6 +60,7 @@ require (
|
|||||||
google.golang.org/protobuf v1.27.1
|
google.golang.org/protobuf v1.27.1
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||||
|
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||||
sigs.k8s.io/yaml v1.2.0 // indirect
|
sigs.k8s.io/yaml v1.2.0 // indirect
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
|
|||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||||
|
github.com/alibabacloud-go/darabonba-openapi v0.1.7/go.mod h1:6FV1Bt1AItYIlC2rVopPTumrRNtkfPBmrPVAZ8v2bLk=
|
||||||
github.com/alibabacloud-go/darabonba-openapi v0.1.11 h1:w59gtSA0s87p0U5NNG/N/PIHsRP3rtj7qCP9hx9+GL8=
|
github.com/alibabacloud-go/darabonba-openapi v0.1.11 h1:w59gtSA0s87p0U5NNG/N/PIHsRP3rtj7qCP9hx9+GL8=
|
||||||
github.com/alibabacloud-go/darabonba-openapi v0.1.11/go.mod h1:MPJMxv7HYrFm5m9uOZWkDYsAWyZztEgnBRfk9Fg0eIU=
|
github.com/alibabacloud-go/darabonba-openapi v0.1.11/go.mod h1:MPJMxv7HYrFm5m9uOZWkDYsAWyZztEgnBRfk9Fg0eIU=
|
||||||
github.com/alibabacloud-go/darabonba-string v1.0.0/go.mod h1:93cTfV3vuPhhEwGGpKKqhVW4jLe7tDpo3LUM0i0g6mA=
|
github.com/alibabacloud-go/darabonba-string v1.0.0/go.mod h1:93cTfV3vuPhhEwGGpKKqhVW4jLe7tDpo3LUM0i0g6mA=
|
||||||
@@ -62,8 +63,11 @@ github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8 h1:KXMiCg99Jx7B6V+DlRFbWw
|
|||||||
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8/go.mod h1:8aL6tSyQIWJygF7W/Vqxdf/QDbN2S+u57k36bEA8hD8=
|
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8/go.mod h1:8aL6tSyQIWJygF7W/Vqxdf/QDbN2S+u57k36bEA8hD8=
|
||||||
github.com/alibabacloud-go/endpoint-util v1.1.0 h1:r/4D3VSw888XGaeNpP994zDUaxdgTSHBbVfZlzf6b5Q=
|
github.com/alibabacloud-go/endpoint-util v1.1.0 h1:r/4D3VSw888XGaeNpP994zDUaxdgTSHBbVfZlzf6b5Q=
|
||||||
github.com/alibabacloud-go/endpoint-util v1.1.0/go.mod h1:O5FuCALmCKs2Ff7JFJMudHs0I5EBgecXXxZRyswlEjE=
|
github.com/alibabacloud-go/endpoint-util v1.1.0/go.mod h1:O5FuCALmCKs2Ff7JFJMudHs0I5EBgecXXxZRyswlEjE=
|
||||||
|
github.com/alibabacloud-go/openapi-util v0.0.8/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
|
||||||
github.com/alibabacloud-go/openapi-util v0.0.9 h1:Z0DP4LFzkM/rW2nxOMiiLoQVZSeE3jVc5jrZ9Fd/UX0=
|
github.com/alibabacloud-go/openapi-util v0.0.9 h1:Z0DP4LFzkM/rW2nxOMiiLoQVZSeE3jVc5jrZ9Fd/UX0=
|
||||||
github.com/alibabacloud-go/openapi-util v0.0.9/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
|
github.com/alibabacloud-go/openapi-util v0.0.9/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
|
||||||
|
github.com/alibabacloud-go/sts-20150401 v1.1.0 h1:1yVyKz02ES6aKo3xVjmoPLBH1OAmmSqPkhKRdjEkmYs=
|
||||||
|
github.com/alibabacloud-go/sts-20150401 v1.1.0/go.mod h1:QW4O/c7Hp4krHYt+6xwnoG8EyZW3V9GYkl6EgIBmxJc=
|
||||||
github.com/alibabacloud-go/tea v1.1.0/go.mod h1:IkGyUSX4Ba1V+k4pCtJUc6jDpZLFph9QMy2VUPTwukg=
|
github.com/alibabacloud-go/tea v1.1.0/go.mod h1:IkGyUSX4Ba1V+k4pCtJUc6jDpZLFph9QMy2VUPTwukg=
|
||||||
github.com/alibabacloud-go/tea v1.1.7/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4=
|
github.com/alibabacloud-go/tea v1.1.7/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4=
|
||||||
github.com/alibabacloud-go/tea v1.1.8/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4=
|
github.com/alibabacloud-go/tea v1.1.8/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4=
|
||||||
@@ -1095,6 +1099,8 @@ gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
|||||||
gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c=
|
gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c=
|
||||||
gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
|
gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=
|
||||||
|
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw=
|
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw=
|
||||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ func GetConversation(c *gin.Context) {
|
|||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetConversation(context.Background(), &reqPb)
|
respPb, err := client.GetConversation(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@ func SetRecvMsgOpt(c *gin.Context) {
|
|||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetRecvMsgOpt rpc failed, ", reqPb.String(), err.Error())
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -201,3 +201,18 @@ func SetRecvMsgOpt(c *gin.Context) {
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
|
func SetReceiveMessageOpt(c *gin.Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
|
func GetReceiveMessageOpt(c *gin.Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
|
func GetAllConversationMessageOpt(c *gin.Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
+161
-1
@@ -259,7 +259,7 @@ func CreateGroup(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.OwnerUserID = req.OpUserID
|
req.OwnerUserID = params.OwnerUserID
|
||||||
req.OperationID = params.OperationID
|
req.OperationID = params.OperationID
|
||||||
log.NewInfo(req.OperationID, "CreateGroup args ", req.String())
|
log.NewInfo(req.OperationID, "CreateGroup args ", req.String())
|
||||||
|
|
||||||
@@ -536,3 +536,163 @@ func TransferGroupOwner(c *gin.Context) {
|
|||||||
log.NewInfo(req.OperationID, "TransferGroupOwner api return ", resp)
|
log.NewInfo(req.OperationID, "TransferGroupOwner api return ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DismissGroup(c *gin.Context) {
|
||||||
|
params := api.DismissGroupReq{}
|
||||||
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
|
log.NewError("0", "BindJSON failed ", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req := &rpc.DismissGroupReq{}
|
||||||
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
var ok bool
|
||||||
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
reply, err := client.DismissGroup(context.Background(), req)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := api.DismissGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func MuteGroupMember(c *gin.Context) {
|
||||||
|
params := api.MuteGroupMemberReq{}
|
||||||
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
|
log.NewError("0", "BindJSON failed ", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req := &rpc.MuteGroupMemberReq{}
|
||||||
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
var ok bool
|
||||||
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
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.OpenImGroupName)
|
||||||
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
reply, err := client.MuteGroupMember(context.Background(), req)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := api.MuteGroupMemberResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CancelMuteGroupMember(c *gin.Context) {
|
||||||
|
params := api.CancelMuteGroupMemberReq{}
|
||||||
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
|
log.NewError("0", "BindJSON failed ", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req := &rpc.CancelMuteGroupMemberReq{}
|
||||||
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
var ok bool
|
||||||
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
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.OpenImGroupName)
|
||||||
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
reply, err := client.CancelMuteGroupMember(context.Background(), req)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := api.CancelMuteGroupMemberResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func MuteGroup(c *gin.Context) {
|
||||||
|
params := api.MuteGroupReq{}
|
||||||
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
|
log.NewError("0", "BindJSON failed ", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req := &rpc.MuteGroupReq{}
|
||||||
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
var ok bool
|
||||||
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
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.OpenImGroupName)
|
||||||
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
reply, err := client.MuteGroup(context.Background(), req)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := api.MuteGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CancelMuteGroup(c *gin.Context) {
|
||||||
|
params := api.CancelMuteGroupReq{}
|
||||||
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
|
log.NewError("0", "BindJSON failed ", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req := &rpc.CancelMuteGroupReq{}
|
||||||
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
var ok bool
|
||||||
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
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.OpenImGroupName)
|
||||||
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
reply, err := client.CancelMuteGroup(context.Background(), req)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := api.CancelMuteGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -29,6 +30,7 @@ var validate *validator.Validate
|
|||||||
|
|
||||||
func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
|
func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||||
var newContent string
|
var newContent string
|
||||||
|
var err error
|
||||||
switch params.ContentType {
|
switch params.ContentType {
|
||||||
case constant.Text:
|
case constant.Text:
|
||||||
newContent = params.Content["text"].(string)
|
newContent = params.Content["text"].(string)
|
||||||
@@ -40,6 +42,9 @@ func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
|
|||||||
fallthrough
|
fallthrough
|
||||||
case constant.File:
|
case constant.File:
|
||||||
newContent = utils.StructToJsonString(params.Content)
|
newContent = utils.StructToJsonString(params.Content)
|
||||||
|
case constant.Revoke:
|
||||||
|
newContent = params.Content["revokeMsgClientID"].(string)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
var options map[string]bool
|
var options map[string]bool
|
||||||
@@ -70,6 +75,14 @@ func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
|
|||||||
OfflinePushInfo: params.OfflinePushInfo,
|
OfflinePushInfo: params.OfflinePushInfo,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
if params.ContentType == constant.OANotification {
|
||||||
|
var tips open_im_sdk.TipsComm
|
||||||
|
tips.JsonDetail = utils.StructToJsonString(params.Content)
|
||||||
|
pbData.MsgData.Content, err = proto.Marshal(&tips)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(params.OperationID, "Marshal failed ", err.Error(), tips.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
return &pbData
|
return &pbData
|
||||||
}
|
}
|
||||||
func init() {
|
func init() {
|
||||||
@@ -103,7 +116,11 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
//case constant.Location:
|
//case constant.Location:
|
||||||
case constant.Custom:
|
case constant.Custom:
|
||||||
data = CustomElem{}
|
data = CustomElem{}
|
||||||
//case constant.Revoke:
|
case constant.Revoke:
|
||||||
|
data = RevokeElem{}
|
||||||
|
case constant.OANotification:
|
||||||
|
data = OANotificationElem{}
|
||||||
|
params.SessionType = constant.NotificationChatType
|
||||||
//case constant.HasReadReceipt:
|
//case constant.HasReadReceipt:
|
||||||
//case constant.Typing:
|
//case constant.Typing:
|
||||||
//case constant.Quote:
|
//case constant.Quote:
|
||||||
@@ -121,12 +138,13 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
log.ErrorByKv("data args validate err", "", "err", err.Error())
|
log.ErrorByKv("data args validate err", "", "err", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", data, params)
|
||||||
token := c.Request.Header.Get("token")
|
token := c.Request.Header.Get("token")
|
||||||
claims, err := token_verify.ParseToken(token)
|
claims, err := token_verify.ParseToken(token, params.OperationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, "parse token failed", err.Error())
|
log.NewError(params.OperationID, "parse token failed", err.Error())
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "parse token failed", "sendTime": 0, "MsgID": ""})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "parse token failed", "sendTime": 0, "MsgID": ""})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "not authorized", "sendTime": 0, "MsgID": ""})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "not authorized", "sendTime": 0, "MsgID": ""})
|
||||||
@@ -138,11 +156,13 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
if len(params.RecvID) == 0 {
|
if len(params.RecvID) == 0 {
|
||||||
log.NewError(params.OperationID, "recvID is a null string")
|
log.NewError(params.OperationID, "recvID is a null string")
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "recvID is a null string", "sendTime": 0, "MsgID": ""})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "recvID is a null string", "sendTime": 0, "MsgID": ""})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
case constant.GroupChatType:
|
case constant.GroupChatType:
|
||||||
if len(params.GroupID) == 0 {
|
if len(params.GroupID) == 0 {
|
||||||
log.NewError(params.OperationID, "groupID is a null string")
|
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": ""})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "groupID is a null string", "sendTime": 0, "MsgID": ""})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -198,16 +218,16 @@ type ManagementSendMsgReq struct {
|
|||||||
|
|
||||||
type PictureBaseInfo struct {
|
type PictureBaseInfo struct {
|
||||||
UUID string `mapstructure:"uuid"`
|
UUID string `mapstructure:"uuid"`
|
||||||
Type string `mapstructure:"type" validate:"required"`
|
Type string `mapstructure:"type" `
|
||||||
Size int64 `mapstructure:"size" validate:"required"`
|
Size int64 `mapstructure:"size" `
|
||||||
Width int32 `mapstructure:"width" validate:"required"`
|
Width int32 `mapstructure:"width" `
|
||||||
Height int32 `mapstructure:"height" validate:"required"`
|
Height int32 `mapstructure:"height"`
|
||||||
Url string `mapstructure:"url" validate:"required"`
|
Url string `mapstructure:"url" `
|
||||||
}
|
}
|
||||||
|
|
||||||
type PictureElem struct {
|
type PictureElem struct {
|
||||||
SourcePath string `mapstructure:"sourcePath"`
|
SourcePath string `mapstructure:"sourcePath"`
|
||||||
SourcePicture PictureBaseInfo `mapstructure:"sourcePicture" validate:"required"`
|
SourcePicture PictureBaseInfo `mapstructure:"sourcePicture"`
|
||||||
BigPicture PictureBaseInfo `mapstructure:"bigPicture" `
|
BigPicture PictureBaseInfo `mapstructure:"bigPicture" `
|
||||||
SnapshotPicture PictureBaseInfo `mapstructure:"snapshotPicture"`
|
SnapshotPicture PictureBaseInfo `mapstructure:"snapshotPicture"`
|
||||||
}
|
}
|
||||||
@@ -257,3 +277,20 @@ type CustomElem struct {
|
|||||||
type TextElem struct {
|
type TextElem struct {
|
||||||
Text string `mapstructure:"text" validate:"required"`
|
Text string `mapstructure:"text" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RevokeElem struct {
|
||||||
|
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
||||||
|
}
|
||||||
|
type OANotificationElem struct {
|
||||||
|
NotificationName string `mapstructure:"notificationName" validate:"required"`
|
||||||
|
NotificationFaceURL string `mapstructure:"notificationFaceURL" validate:"required"`
|
||||||
|
NotificationType int32 `mapstructure:"notificationType" validate:"required"`
|
||||||
|
Text string `mapstructure:"text" validate:"required"`
|
||||||
|
Url string `mapstructure:"url"`
|
||||||
|
MixType int32 `mapstructure:"mixType"`
|
||||||
|
PictureElem PictureElem `mapstructure:"pictureElem"`
|
||||||
|
SoundElem SoundElem `mapstructure:"soundElem"`
|
||||||
|
VideoElem VideoElem `mapstructure:"videoElem"`
|
||||||
|
FileElem FileElem `mapstructure:"fileElem"`
|
||||||
|
Ex string `mapstructure:"ex"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,280 @@
|
|||||||
|
package office
|
||||||
|
|
||||||
|
import (
|
||||||
|
apistruct "Open_IM/pkg/base_info"
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
|
pbOffice "Open_IM/pkg/proto/office"
|
||||||
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetUserTags(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req apistruct.GetUserTagsReq
|
||||||
|
resp apistruct.GetUserTagsResp
|
||||||
|
reqPb pbOffice.GetUserTagsReq
|
||||||
|
respPb *pbOffice.GetUserTagsResp
|
||||||
|
)
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reqPb.UserID = userID
|
||||||
|
reqPb.OperationID = req.OperationID
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
|
respPb, err := client.GetUserTags(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserTags rpc server failed" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
|
}
|
||||||
|
if respPb.Tags != nil {
|
||||||
|
resp.Data.Tags = respPb.Tags
|
||||||
|
} else {
|
||||||
|
resp.Data.Tags = []*pbOffice.Tag{}
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateTag(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req apistruct.CreateTagReq
|
||||||
|
resp apistruct.CreateTagResp
|
||||||
|
reqPb pbOffice.CreateTagReq
|
||||||
|
respPb *pbOffice.CreateTagResp
|
||||||
|
)
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reqPb.UserID = userID
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
|
respPb, err := client.CreateTag(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteTag(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req apistruct.DeleteTagReq
|
||||||
|
resp apistruct.DeleteTagResp
|
||||||
|
reqPb pbOffice.DeleteTagReq
|
||||||
|
respPb *pbOffice.DeleteTagResp
|
||||||
|
)
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reqPb.UserID = userID
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
|
respPb, err := client.DeleteTag(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetTag(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req apistruct.SetTagReq
|
||||||
|
resp apistruct.SetTagResp
|
||||||
|
reqPb pbOffice.SetTagReq
|
||||||
|
respPb *pbOffice.SetTagResp
|
||||||
|
)
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reqPb.UserID = userID
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
|
respPb, err := client.SetTag(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SendMsg2Tag(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req apistruct.SendMsg2TagReq
|
||||||
|
resp apistruct.SendMsg2TagResp
|
||||||
|
reqPb pbOffice.SendMsg2TagReq
|
||||||
|
respPb *pbOffice.SendMsg2TagResp
|
||||||
|
)
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reqPb.SendID = userID
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
|
respPb, err := client.SendMsg2Tag(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetTagSendLogs(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req apistruct.GetTagSendLogsReq
|
||||||
|
resp apistruct.GetTagSendLogsResp
|
||||||
|
reqPb pbOffice.GetTagSendLogsReq
|
||||||
|
respPb *pbOffice.GetTagSendLogsResp
|
||||||
|
)
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reqPb.UserID = userID
|
||||||
|
reqPb.OperationID = req.OperationID
|
||||||
|
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||||
|
PageNumber: req.PageNumber,
|
||||||
|
ShowNumber: req.ShowNumber,
|
||||||
|
}
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
|
respPb, err := client.GetTagSendLogs(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
|
}
|
||||||
|
if respPb.TagSendLogs != nil {
|
||||||
|
resp.Data.Logs = respPb.TagSendLogs
|
||||||
|
} else {
|
||||||
|
resp.Data.Logs = []*pbOffice.TagSendLog{}
|
||||||
|
}
|
||||||
|
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
||||||
|
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserTagByID(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req apistruct.GetUserTagByIDReq
|
||||||
|
resp apistruct.GetUserTagByIDResp
|
||||||
|
reqPb pbOffice.GetUserTagByIDReq
|
||||||
|
respPb *pbOffice.GetUserTagByIDResp
|
||||||
|
)
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
|
respPb, err := client.GetUserTagByID(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTagByID failed", err.Error())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
|
}
|
||||||
|
resp.Data.Tag = respPb.Tag
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package apiThird
|
||||||
|
|
||||||
|
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"
|
||||||
|
"fmt"
|
||||||
|
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
|
||||||
|
sts20150401 "github.com/alibabacloud-go/sts-20150401/client"
|
||||||
|
"github.com/alibabacloud-go/tea/tea"
|
||||||
|
"github.com/fatih/structs"
|
||||||
|
|
||||||
|
//"github.com/fatih/structs"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var stsClient *sts20150401.Client
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用AK&SK初始化账号Client
|
||||||
|
* @param accessKeyId
|
||||||
|
* @param accessKeySecret
|
||||||
|
* @return Client
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
func getStsClient() *sts20150401.Client {
|
||||||
|
if stsClient != nil {
|
||||||
|
return stsClient
|
||||||
|
}
|
||||||
|
conf := &openapi.Config{
|
||||||
|
// 您的AccessKey ID
|
||||||
|
AccessKeyId: tea.String(config.Config.Credential.Ali.AccessKeyID),
|
||||||
|
// 您的AccessKey Secret
|
||||||
|
AccessKeySecret: tea.String(config.Config.Credential.Ali.AccessKeySecret),
|
||||||
|
// Endpoint
|
||||||
|
Endpoint: tea.String(config.Config.Credential.Ali.StsEndpoint),
|
||||||
|
}
|
||||||
|
result, err := sts20150401.NewClient(conf)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError("", "alists client初始化失败 ", err)
|
||||||
|
}
|
||||||
|
stsClient = result
|
||||||
|
return stsClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func AliOSSCredential(c *gin.Context) {
|
||||||
|
req := api.OSSCredentialReq{}
|
||||||
|
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, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, "AliOSSCredential args ", userID)
|
||||||
|
|
||||||
|
stsResp, err := getStsClient().AssumeRole(&sts20150401.AssumeRoleRequest{
|
||||||
|
DurationSeconds: tea.Int64(config.Config.Credential.Ali.StsDurationSeconds),
|
||||||
|
Policy: nil,
|
||||||
|
RoleArn: tea.String(config.Config.Credential.Ali.OssRoleArn),
|
||||||
|
RoleSessionName: tea.String(fmt.Sprintf("%s-%d", userID, time.Now().Unix())),
|
||||||
|
})
|
||||||
|
|
||||||
|
resp := api.OSSCredentialResp{}
|
||||||
|
if err != nil {
|
||||||
|
resp.ErrCode = constant.ErrTencentCredential.ErrCode
|
||||||
|
resp.ErrMsg = err.Error()
|
||||||
|
} else {
|
||||||
|
resp = api.OSSCredentialResp{
|
||||||
|
CommResp: api.CommResp{},
|
||||||
|
OssData: api.OSSCredentialRespData{
|
||||||
|
Endpoint: config.Config.Credential.Ali.OssEndpoint,
|
||||||
|
AccessKeyId: *stsResp.Body.Credentials.AccessKeyId,
|
||||||
|
AccessKeySecret: *stsResp.Body.Credentials.AccessKeySecret,
|
||||||
|
Token: *stsResp.Body.Credentials.SecurityToken,
|
||||||
|
Bucket: config.Config.Credential.Ali.Bucket,
|
||||||
|
FinalHost: config.Config.Credential.Ali.FinalHost,
|
||||||
|
},
|
||||||
|
Data: nil,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.Data = structs.Map(&resp.OssData)
|
||||||
|
log.NewInfo(req.OperationID, "AliOSSCredential return ", resp)
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
@@ -10,13 +10,18 @@ import (
|
|||||||
url2 "net/url"
|
url2 "net/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
minioClient *minio.Client
|
||||||
|
)
|
||||||
|
|
||||||
func MinioInit() {
|
func MinioInit() {
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName())
|
||||||
minioUrl, err := url2.Parse(config.Config.Credential.Minio.Endpoint)
|
minioUrl, err := url2.Parse(config.Config.Credential.Minio.Endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("", utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
|
log.NewError("", utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
minioClient, err := minio.New(minioUrl.Host, &minio.Options{
|
minioClient, err = minio.New(minioUrl.Host, &minio.Options{
|
||||||
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
||||||
Secure: false,
|
Secure: false,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,12 +8,89 @@ import (
|
|||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
_ "Open_IM/pkg/common/token_verify"
|
_ "Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/minio/minio-go/v7"
|
||||||
_ "github.com/minio/minio-go/v7"
|
_ "github.com/minio/minio-go/v7"
|
||||||
cr "github.com/minio/minio-go/v7/pkg/credentials"
|
cr "github.com/minio/minio-go/v7/pkg/credentials"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func MinioUploadFile(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req apiStruct.MinioUploadFileReq
|
||||||
|
resp apiStruct.MinioUploadFileResp
|
||||||
|
)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), r)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file or snapShot args"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err := c.Bind(&req); err != nil {
|
||||||
|
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||||
|
switch req.FileType {
|
||||||
|
// videoType upload snapShot
|
||||||
|
case constant.VideoType:
|
||||||
|
snapShotFile, err := c.FormFile("snapShot")
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing snapshot arg: " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
snapShotFileObj, err := snapShotFile.Open()
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
snapShotNewName, snapShotNewType := utils.GetNewFileNameAndContentType(snapShotFile.Filename, constant.ImageType)
|
||||||
|
log.Debug(req.OperationID, utils.GetSelfFuncName(), snapShotNewName, snapShotNewType)
|
||||||
|
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject snapShotFile error", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp.SnapshotURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.Bucket + "/" + snapShotNewName
|
||||||
|
resp.SnapshotNewName = snapShotNewName
|
||||||
|
}
|
||||||
|
file, err := c.FormFile("file")
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fileObj, err := file.Open()
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file path" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType)
|
||||||
|
log.Debug(req.OperationID, utils.GetSelfFuncName(), newName, newType)
|
||||||
|
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "invalid file path" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp.NewName = newName
|
||||||
|
resp.URL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.Bucket + "/" + newName
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func MinioStorageCredential(c *gin.Context) {
|
func MinioStorageCredential(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req apiStruct.MinioStorageCredentialReq
|
req apiStruct.MinioStorageCredentialReq
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
|
|
||||||
type ParamsSetPassword struct {
|
type ParamsSetPassword struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
|
Name string `json:"name"`
|
||||||
PhoneNumber string `json:"phoneNumber"`
|
PhoneNumber string `json:"phoneNumber"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
VerificationCode string `json:"verificationCode"`
|
VerificationCode string `json:"verificationCode"`
|
||||||
@@ -38,6 +39,9 @@ func SetPassword(c *gin.Context) {
|
|||||||
} else {
|
} else {
|
||||||
account = params.PhoneNumber
|
account = params.PhoneNumber
|
||||||
}
|
}
|
||||||
|
if params.Name == "" {
|
||||||
|
params.Name = account
|
||||||
|
}
|
||||||
if params.VerificationCode != config.Config.Demo.SuperCode {
|
if params.VerificationCode != config.Config.Demo.SuperCode {
|
||||||
accountKey := account + "_" + constant.VerificationCodeForRegisterSuffix
|
accountKey := account + "_" + constant.VerificationCodeForRegisterSuffix
|
||||||
v, err := db.DB.GetAccountCode(accountKey)
|
v, err := db.DB.GetAccountCode(accountKey)
|
||||||
@@ -54,7 +58,7 @@ func SetPassword(c *gin.Context) {
|
|||||||
openIMRegisterReq.OperationID = params.OperationID
|
openIMRegisterReq.OperationID = params.OperationID
|
||||||
openIMRegisterReq.Platform = params.Platform
|
openIMRegisterReq.Platform = params.Platform
|
||||||
openIMRegisterReq.UserID = account
|
openIMRegisterReq.UserID = account
|
||||||
openIMRegisterReq.Nickname = account
|
openIMRegisterReq.Nickname = params.Name
|
||||||
openIMRegisterReq.Secret = config.Config.Secret
|
openIMRegisterReq.Secret = config.Config.Secret
|
||||||
openIMRegisterResp := api.UserRegisterResp{}
|
openIMRegisterResp := api.UserRegisterResp{}
|
||||||
bMsg, err := http2.Post(url, openIMRegisterReq, 2)
|
bMsg, err := http2.Post(url, openIMRegisterReq, 2)
|
||||||
@@ -69,7 +73,7 @@ func SetPassword(c *gin.Context) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: "+openIMRegisterResp.ErrMsg})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: " + openIMRegisterResp.ErrMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info(params.OperationID, "begin store mysql", account, params.Password)
|
log.Info(params.OperationID, "begin store mysql", account, params.Password)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package gate
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/statistics"
|
"Open_IM/pkg/statistics"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -20,7 +21,7 @@ var (
|
|||||||
|
|
||||||
func Init(rpcPort, wsPort int) {
|
func Init(rpcPort, wsPort int) {
|
||||||
//log initialization
|
//log initialization
|
||||||
log.NewPrivateLog(config.Config.ModuleName.LongConnSvrName)
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
rwLock = new(sync.RWMutex)
|
rwLock = new(sync.RWMutex)
|
||||||
validate = validator.New()
|
validate = validator.New()
|
||||||
statistics.NewStatistics(&sendMsgCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", sendMsgCount), 300)
|
statistics.NewStatistics(&sendMsgCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", sendMsgCount), 300)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
|||||||
dec := gob.NewDecoder(b)
|
dec := gob.NewDecoder(b)
|
||||||
err := dec.Decode(&m)
|
err := dec.Decode(&m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("ws Decode err", "", "err", err.Error())
|
log.NewError("", "ws Decode err", err.Error())
|
||||||
ws.sendErrMsg(conn, 200, err.Error(), constant.WSDataError, "", "")
|
ws.sendErrMsg(conn, 200, err.Error(), constant.WSDataError, "", "")
|
||||||
err = conn.Close()
|
err = conn.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -37,7 +37,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := validate.Struct(m); err != nil {
|
if err := validate.Struct(m); err != nil {
|
||||||
log.ErrorByKv("ws args validate err", "", "err", err.Error())
|
log.NewError("", "ws args validate err", err.Error())
|
||||||
ws.sendErrMsg(conn, 201, err.Error(), m.ReqIdentifier, m.MsgIncr, m.OperationID)
|
ws.sendErrMsg(conn, 201, err.Error(), m.ReqIdentifier, m.MsgIncr, m.OperationID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
|||||||
// ws.sendErrMsg(conn, 202, "token validate err", m.ReqIdentifier, m.MsgIncr,m.OperationID)
|
// ws.sendErrMsg(conn, 202, "token validate err", m.ReqIdentifier, m.MsgIncr,m.OperationID)
|
||||||
// return
|
// return
|
||||||
//}
|
//}
|
||||||
log.InfoByKv("Basic Info Authentication Success", m.OperationID, "reqIdentifier", m.ReqIdentifier, "sendID", m.SendID, "msgIncr", m.MsgIncr)
|
log.NewInfo(m.OperationID, "Basic Info Authentication Success", m)
|
||||||
|
|
||||||
switch m.ReqIdentifier {
|
switch m.ReqIdentifier {
|
||||||
case constant.WSGetNewestSeq:
|
case constant.WSGetNewestSeq:
|
||||||
@@ -61,7 +61,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
|||||||
log.NewInfo("", "goroutine num is ", runtime.NumGoroutine())
|
log.NewInfo("", "goroutine num is ", runtime.NumGoroutine())
|
||||||
}
|
}
|
||||||
func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||||
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier)
|
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier, m.Data)
|
||||||
rpcReq := pbChat.GetMaxAndMinSeqReq{}
|
rpcReq := pbChat.GetMaxAndMinSeqReq{}
|
||||||
nReply := new(pbChat.GetMaxAndMinSeqResp)
|
nReply := new(pbChat.GetMaxAndMinSeqResp)
|
||||||
rpcReq.UserID = m.SendID
|
rpcReq.UserID = m.SendID
|
||||||
@@ -99,15 +99,15 @@ func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *pbChat.GetMaxAndMinSeq
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq start", m.SendID, m.ReqIdentifier, m.MsgIncr)
|
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq start", m.SendID, m.ReqIdentifier, m.MsgIncr, m.Data)
|
||||||
nReply := new(sdk_ws.PullMessageBySeqListResp)
|
nReply := new(sdk_ws.PullMessageBySeqListResp)
|
||||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsgBySeqList)
|
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsgBySeqList)
|
||||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdk_ws.PullMessageBySeqListReq).SeqList)
|
|
||||||
if isPass {
|
if isPass {
|
||||||
rpcReq := sdk_ws.PullMessageBySeqListReq{}
|
rpcReq := sdk_ws.PullMessageBySeqListReq{}
|
||||||
rpcReq.SeqList = data.(sdk_ws.PullMessageBySeqListReq).SeqList
|
rpcReq.SeqList = data.(sdk_ws.PullMessageBySeqListReq).SeqList
|
||||||
rpcReq.UserID = m.SendID
|
rpcReq.UserID = m.SendID
|
||||||
rpcReq.OperationID = m.OperationID
|
rpcReq.OperationID = m.OperationID
|
||||||
|
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.OpenImOfflineMessageName)
|
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
msgClient := pbChat.NewChatClient(grpcConn)
|
msgClient := pbChat.NewChatClient(grpcConn)
|
||||||
reply, err := msgClient.PullMessageBySeqList(context.Background(), &rpcReq)
|
reply, err := msgClient.PullMessageBySeqList(context.Background(), &rpcReq)
|
||||||
@@ -145,7 +145,7 @@ func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullM
|
|||||||
}
|
}
|
||||||
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
||||||
sendMsgCount++
|
sendMsgCount++
|
||||||
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID)
|
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, m.Data)
|
||||||
nReply := new(pbChat.SendMsgResp)
|
nReply := new(pbChat.SendMsgResp)
|
||||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg)
|
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg)
|
||||||
if isPass {
|
if isPass {
|
||||||
@@ -196,38 +196,36 @@ func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
||||||
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID)
|
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, m.Data)
|
||||||
nReply := new(pbChat.SendMsgResp)
|
nReply := new(pbChat.SendMsgResp)
|
||||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendSignalMsg)
|
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendSignalMsg)
|
||||||
log.NewInfo(m.OperationID, "args is ", pData.(*sdk_ws.SignalReq))
|
if isPass {
|
||||||
isPass2, errCode2, errMsg2, signalResp, msgData := ws.signalMessageAssemble(pData.(*sdk_ws.SignalReq), m.OperationID)
|
isPass2, errCode2, errMsg2, signalResp, msgData := ws.signalMessageAssemble(pData.(*sdk_ws.SignalReq), m.OperationID)
|
||||||
if isPass && isPass2 {
|
if isPass2 {
|
||||||
pbData := pbChat.SendMsgReq{
|
pbData := pbChat.SendMsgReq{
|
||||||
Token: m.Token,
|
Token: m.Token,
|
||||||
OperationID: m.OperationID,
|
OperationID: m.OperationID,
|
||||||
MsgData: msgData,
|
MsgData: msgData,
|
||||||
}
|
}
|
||||||
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, msgData)
|
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.OpenImOfflineMessageName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
client := pbChat.NewChatClient(etcdConn)
|
client := pbChat.NewChatClient(etcdConn)
|
||||||
reply, err := client.SendMsg(context.Background(), &pbData)
|
reply, err := client.SendMsg(context.Background(), &pbData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(pbData.OperationID, "rpc sendMsg err", err.Error())
|
log.NewError(pbData.OperationID, "rpc sendMsg err", err.Error())
|
||||||
nReply.ErrCode = 200
|
nReply.ErrCode = 200
|
||||||
nReply.ErrMsg = err.Error()
|
nReply.ErrMsg = err.Error()
|
||||||
ws.sendSignalMsgResp(conn, 200, err.Error(), m, signalResp)
|
ws.sendSignalMsgResp(conn, 200, err.Error(), m, signalResp)
|
||||||
|
} else {
|
||||||
|
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
|
||||||
|
ws.sendSignalMsgResp(conn, 0, "", m, signalResp)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
|
|
||||||
ws.sendSignalMsgResp(conn, 0, "", m, signalResp)
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if isPass {
|
|
||||||
log.NewError(m.OperationID, isPass2, errCode2, errMsg2)
|
log.NewError(m.OperationID, isPass2, errCode2, errMsg2)
|
||||||
ws.sendSignalMsgResp(conn, errCode2, errMsg2, m, signalResp)
|
ws.sendSignalMsgResp(conn, errCode2, errMsg2, m, signalResp)
|
||||||
} else {
|
|
||||||
ws.sendSignalMsgResp(conn, errCode, errMsg, m, signalResp)
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ws.sendSignalMsgResp(conn, errCode, errMsg, m, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ func (ws *WServer) signalMessageAssemble(s *open_im_sdk.SignalReq, operationID s
|
|||||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsSenderSync, true)
|
utils.SetSwitchFromOptions(options, constant.IsSenderSync, true)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||||
|
utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, true)
|
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, true)
|
||||||
msg.Options = options
|
msg.Options = options
|
||||||
|
|||||||
@@ -80,6 +80,22 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string)
|
|||||||
mc.groupMsgCount++
|
mc.groupMsgCount++
|
||||||
}
|
}
|
||||||
go sendMessageToPush(&msgFromMQ, msgFromMQ.MsgData.RecvID)
|
go sendMessageToPush(&msgFromMQ, msgFromMQ.MsgData.RecvID)
|
||||||
|
case constant.NotificationChatType:
|
||||||
|
log.NewDebug(msgFromMQ.OperationID, "msg_transfer msg type = NotificationChatType", isHistory, isPersist)
|
||||||
|
if isHistory {
|
||||||
|
err := saveUserChat(msgKey, &msgFromMQ)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(operationID, "single data insert to mongo err", err.Error(), msgFromMQ.String())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
mc.singleMsgCount++
|
||||||
|
log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", utils.GetCurrentTimestampByNano()-time)
|
||||||
|
}
|
||||||
|
if !isSenderSync && msgKey == msgFromMQ.MsgData.SendID {
|
||||||
|
} else {
|
||||||
|
go sendMessageToPush(&msgFromMQ, msgKey)
|
||||||
|
}
|
||||||
|
log.NewDebug(operationID, "saveUserChat cost time ", utils.GetCurrentTimestampByNano()-time)
|
||||||
default:
|
default:
|
||||||
log.NewError(msgFromMQ.OperationID, "SessionType error", msgFromMQ.String())
|
log.NewError(msgFromMQ.OperationID, "SessionType error", msgFromMQ.String())
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/kafka"
|
"Open_IM/pkg/common/kafka"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
)
|
)
|
||||||
@@ -13,7 +14,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
log.NewPrivateLog(config.Config.ModuleName.MsgTransferName)
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
persistentCH.Init()
|
persistentCH.Init()
|
||||||
historyCH.Init()
|
historyCH.Init()
|
||||||
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic)
|
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic)
|
||||||
|
|||||||
@@ -34,26 +34,31 @@ func (pc *PersistentConsumerHandler) Init() {
|
|||||||
|
|
||||||
func (pc *PersistentConsumerHandler) handleChatWs2Mysql(msg []byte, msgKey string) {
|
func (pc *PersistentConsumerHandler) handleChatWs2Mysql(msg []byte, msgKey string) {
|
||||||
log.NewInfo("msg come here mysql!!!", "", "msg", string(msg))
|
log.NewInfo("msg come here mysql!!!", "", "msg", string(msg))
|
||||||
|
var tag bool
|
||||||
msgFromMQ := pbMsg.MsgDataToMQ{}
|
msgFromMQ := pbMsg.MsgDataToMQ{}
|
||||||
err := proto.Unmarshal(msg, &msgFromMQ)
|
err := proto.Unmarshal(msg, &msgFromMQ)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("msg_transfer Unmarshal msg err", "", "msg", string(msg), "err", err.Error())
|
log.NewError(msgFromMQ.OperationID, "msg_transfer Unmarshal msg err", "msg", string(msg), "err", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//Control whether to store history messages (mysql)
|
//Control whether to store history messages (mysql)
|
||||||
isPersist := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsPersistent)
|
isPersist := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsPersistent)
|
||||||
//Only process receiver data
|
//Only process receiver data
|
||||||
if isPersist {
|
if isPersist {
|
||||||
if msgKey == msgFromMQ.MsgData.RecvID && msgFromMQ.MsgData.SessionType == constant.SingleChatType {
|
switch msgFromMQ.MsgData.SessionType {
|
||||||
log.InfoByKv("msg_transfer msg persisting", msgFromMQ.OperationID)
|
case constant.SingleChatType, constant.NotificationChatType:
|
||||||
if err = im_mysql_msg_model.InsertMessageToChatLog(msgFromMQ); err != nil {
|
if msgKey == msgFromMQ.MsgData.RecvID {
|
||||||
log.ErrorByKv("Message insert failed", msgFromMQ.OperationID, "err", err.Error(), "msg", msgFromMQ.String())
|
tag = true
|
||||||
return
|
|
||||||
}
|
}
|
||||||
} else if msgFromMQ.MsgData.SessionType == constant.GroupChatType && msgKey == msgFromMQ.MsgData.SendID {
|
case constant.GroupChatType:
|
||||||
log.InfoByKv("msg_transfer msg persisting", msgFromMQ.OperationID)
|
if msgKey == msgFromMQ.MsgData.SendID || utils.IsContain(msgFromMQ.MsgData.SendID, config.Config.Manager.AppManagerUid) {
|
||||||
|
tag = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if tag {
|
||||||
|
log.NewInfo(msgFromMQ.OperationID, "msg_transfer msg persisting", string(msg))
|
||||||
if err = im_mysql_msg_model.InsertMessageToChatLog(msgFromMQ); err != nil {
|
if err = im_mysql_msg_model.InsertMessageToChatLog(msgFromMQ); err != nil {
|
||||||
log.ErrorByKv("Message insert failed", msgFromMQ.OperationID, "err", err.Error(), "msg", msgFromMQ.String())
|
log.NewError(msgFromMQ.OperationID, "Message insert failed", "err", err.Error(), "msg", msgFromMQ.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Init(rpcPort int) {
|
func Init(rpcPort int) {
|
||||||
log.NewPrivateLog(config.Config.ModuleName.PushName)
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
rpcServer.Init(rpcPort)
|
rpcServer.Init(rpcPort)
|
||||||
pushCh.Init()
|
pushCh.Init()
|
||||||
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}
|
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type adminCMSServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewAdminCMSServer(port int) *adminCMSServer {
|
func NewAdminCMSServer(port int) *adminCMSServer {
|
||||||
log.NewPrivateLog("AdminCMS")
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
return &adminCMSServer{
|
return &adminCMSServer{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImAdminCMSName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImAdminCMSName,
|
||||||
@@ -66,12 +66,12 @@ func (s *adminCMSServer) Run() {
|
|||||||
func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLoginReq) (*pbAdminCMS.AdminLoginResp, error) {
|
func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLoginReq) (*pbAdminCMS.AdminLoginResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbAdminCMS.AdminLoginResp{}
|
resp := &pbAdminCMS.AdminLoginResp{}
|
||||||
for i, adminID := range config.Config.Manager.AppManagerUid{
|
for i, adminID := range config.Config.Manager.AppManagerUid {
|
||||||
if adminID == req.AdminID && config.Config.Manager.Secrets[i] == req.Secret {
|
if adminID == req.AdminID && config.Config.Manager.Secrets[i] == req.Secret {
|
||||||
token, expTime, err := token_verify.CreateToken(adminID, constant.SingleChatType)
|
token, expTime, err := token_verify.CreateToken(adminID, constant.SingleChatType)
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "generate token success", "token: ", token, "expTime:", expTime)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "generate token success", "token: ", token, "expTime:", expTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "adminID: ", adminID, err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "adminID: ", adminID, err.Error())
|
||||||
return resp, openIMHttp.WrapError(constant.ErrTokenUnknown)
|
return resp, openIMHttp.WrapError(constant.ErrTokenUnknown)
|
||||||
}
|
}
|
||||||
resp.Token = token
|
resp.Token = token
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ type rpcAuth struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewRpcAuthServer(port int) *rpcAuth {
|
func NewRpcAuthServer(port int) *rpcAuth {
|
||||||
log.NewPrivateLog("auth")
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
return &rpcAuth{
|
return &rpcAuth{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImAuthName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImAuthName,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ type friendServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewFriendServer(port int) *friendServer {
|
func NewFriendServer(port int) *friendServer {
|
||||||
log.NewPrivateLog("friend")
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
return &friendServer{
|
return &friendServer{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImFriendName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImFriendName,
|
||||||
|
|||||||
+110
-8
@@ -31,7 +31,7 @@ type groupServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewGroupServer(port int) *groupServer {
|
func NewGroupServer(port int) *groupServer {
|
||||||
log.NewPrivateLog("group")
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
return &groupServer{
|
return &groupServer{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImGroupName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImGroupName,
|
||||||
@@ -41,16 +41,16 @@ func NewGroupServer(port int) *groupServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) Run() {
|
func (s *groupServer) Run() {
|
||||||
log.NewInfo("0", "group rpc start ")
|
log.NewInfo("", "group rpc start ")
|
||||||
ip := utils.ServerIP
|
ip := utils.ServerIP
|
||||||
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
|
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
|
||||||
//listener network
|
//listener network
|
||||||
listener, err := net.Listen("tcp", registerAddress)
|
listener, err := net.Listen("tcp", registerAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
|
log.NewError("", "Listen failed ", err.Error(), registerAddress)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo("0", "listen network success, ", registerAddress, listener)
|
log.NewInfo("", "listen network success, ", registerAddress, listener)
|
||||||
defer listener.Close()
|
defer listener.Close()
|
||||||
//grpc server
|
//grpc server
|
||||||
srv := grpc.NewServer()
|
srv := grpc.NewServer()
|
||||||
@@ -59,15 +59,15 @@ func (s *groupServer) Run() {
|
|||||||
pbGroup.RegisterGroupServer(srv, s)
|
pbGroup.RegisterGroupServer(srv, s)
|
||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
log.NewError("", "RegisterEtcd failed ", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", "Serve failed ", err.Error())
|
log.NewError("", "Serve failed ", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo("0", "group rpc success")
|
log.NewInfo("", "group rpc success")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupReq) (*pbGroup.CreateGroupResp, error) {
|
func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupReq) (*pbGroup.CreateGroupResp, error) {
|
||||||
@@ -273,8 +273,11 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range memberList {
|
for _, v := range memberList {
|
||||||
|
log.Debug(req.OperationID, v)
|
||||||
var node open_im_sdk.GroupMemberFullInfo
|
var node open_im_sdk.GroupMemberFullInfo
|
||||||
cp.GroupMemberDBCopyOpenIM(&node, &v)
|
cp.GroupMemberDBCopyOpenIM(&node, &v)
|
||||||
|
log.Debug(req.OperationID, "db value:", v.MuteEndTime, "seconds: ", v.MuteEndTime.Unix())
|
||||||
|
log.Debug(req.OperationID, "cp value: ", node)
|
||||||
resp.MemberList = append(resp.MemberList, &node)
|
resp.MemberList = append(resp.MemberList, &node)
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, "GetGroupAllMember rpc return ", resp.String())
|
log.NewInfo(req.OperationID, "GetGroupAllMember rpc return ", resp.String())
|
||||||
@@ -355,7 +358,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
|||||||
//remove
|
//remove
|
||||||
var resp pbGroup.KickGroupMemberResp
|
var resp pbGroup.KickGroupMemberResp
|
||||||
for _, v := range req.KickedUserIDList {
|
for _, v := range req.KickedUserIDList {
|
||||||
//owner cant kicked
|
//owner can‘t kicked
|
||||||
if v == groupOwnerUserID {
|
if v == groupOwnerUserID {
|
||||||
log.NewError(req.OperationID, "failed, can't kick owner ", v)
|
log.NewError(req.OperationID, "failed, can't kick owner ", v)
|
||||||
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: -1})
|
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: -1})
|
||||||
@@ -937,3 +940,102 @@ func (s *groupServer) GetUserReqApplicationList(_ context.Context, req *pbGroup.
|
|||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGroupReq) (*pbGroup.DismissGroupResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
|
||||||
|
if !token_verify.IsMangerUserID(req.OpUserID) && !imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) {
|
||||||
|
log.NewError(req.OperationID, "verify failed ", req.OpUserID, req.GroupID)
|
||||||
|
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err := imdb.OperateGroupStatus(req.GroupID, constant.GroupStatusDismissed)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "OperateGroupStatus failed ", req.GroupID, constant.GroupStatusDismissed)
|
||||||
|
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
|
}
|
||||||
|
chat.GroupDismissedNotification(req)
|
||||||
|
|
||||||
|
err = imdb.DeleteGroupMemberByGroupID(req.GroupID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "DeleteGroupMemberByGroupID failed ", req.GroupID)
|
||||||
|
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
||||||
|
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// rpc MuteGroupMember(MuteGroupMemberReq) returns(MuteGroupMemberResp);
|
||||||
|
// rpc CancelMuteGroupMember(CancelMuteGroupMemberReq) returns(CancelMuteGroupMemberResp);
|
||||||
|
// rpc MuteGroup(MuteGroupReq) returns(MuteGroupResp);
|
||||||
|
// rpc CancelMuteGroup(CancelMuteGroupReq) returns(CancelMuteGroupResp);
|
||||||
|
|
||||||
|
func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGroupMemberReq) (*pbGroup.MuteGroupMemberResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
|
||||||
|
if !imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) && !token_verify.IsMangerUserID(req.OpUserID) {
|
||||||
|
log.Error(req.OperationID, "verify failed ", req.GroupID, req.UserID)
|
||||||
|
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||||
|
}
|
||||||
|
groupMemberInfo := db.GroupMember{GroupID: req.GroupID, UserID: req.UserID}
|
||||||
|
|
||||||
|
groupMemberInfo.MuteEndTime = time.Unix(int64(time.Now().Second())+int64(req.MutedSeconds), time.Now().UnixNano())
|
||||||
|
err := imdb.UpdateGroupMemberInfo(groupMemberInfo)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo)
|
||||||
|
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
|
}
|
||||||
|
chat.GroupMemberMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, req.MutedSeconds)
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
||||||
|
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.CancelMuteGroupMemberReq) (*pbGroup.CancelMuteGroupMemberResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
|
||||||
|
if !imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) && !token_verify.IsMangerUserID(req.OpUserID) {
|
||||||
|
log.Error(req.OperationID, "verify failed ", req.OpUserID, req.GroupID)
|
||||||
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||||
|
}
|
||||||
|
groupMemberInfo := db.GroupMember{GroupID: req.GroupID, UserID: req.UserID}
|
||||||
|
groupMemberInfo.MuteEndTime = time.Unix(0, 0)
|
||||||
|
err := imdb.UpdateGroupMemberInfo(groupMemberInfo)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo)
|
||||||
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
|
}
|
||||||
|
chat.GroupMemberCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
||||||
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) (*pbGroup.MuteGroupResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
|
||||||
|
if !imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) && !token_verify.IsMangerUserID(req.OpUserID) {
|
||||||
|
log.Error(req.OperationID, "verify failed ", req.GroupID, req.GroupID)
|
||||||
|
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||||
|
}
|
||||||
|
err := imdb.OperateGroupStatus(req.GroupID, constant.GroupStatusMuted)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, "OperateGroupStatus failed ", err.Error(), req.GroupID, constant.GroupStatusMuted)
|
||||||
|
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
|
}
|
||||||
|
chat.GroupMutedNotification(req.OperationID, req.OpUserID, req.GroupID)
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
||||||
|
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMuteGroupReq) (*pbGroup.CancelMuteGroupResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
|
||||||
|
if !imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) && !token_verify.IsMangerUserID(req.OpUserID) {
|
||||||
|
log.Error(req.OperationID, "verify failed ", req.OpUserID, req.GroupID)
|
||||||
|
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err := imdb.UpdateGroupInfoDefaultZero(req.GroupID, map[string]interface{}{"status": constant.GroupOk})
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), req.GroupID)
|
||||||
|
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
|
}
|
||||||
|
chat.GroupCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID)
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
||||||
|
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ type messageCMSServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewMessageCMSServer(port int) *messageCMSServer {
|
func NewMessageCMSServer(port int) *messageCMSServer {
|
||||||
log.NewPrivateLog("MessageCMS")
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
return &messageCMSServer{
|
return &messageCMSServer{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImMessageCMSName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImMessageCMSName,
|
||||||
@@ -84,8 +84,8 @@ func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetC
|
|||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "time string parse error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "time string parse error", err.Error())
|
||||||
}
|
}
|
||||||
chatLog := db.ChatLog{
|
chatLog := db.ChatLog{
|
||||||
Content: req.Content,
|
Content: req.Content,
|
||||||
SendTime: time,
|
SendTime: time,
|
||||||
ContentType: req.ContentType,
|
ContentType: req.ContentType,
|
||||||
SessionType: req.SessionType,
|
SessionType: req.SessionType,
|
||||||
}
|
}
|
||||||
@@ -101,20 +101,20 @@ func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetC
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLogCount", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLogCount", err.Error())
|
||||||
}
|
}
|
||||||
chatLogs, err := imdb.GetChatLog(chatLog, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
chatLogs, err := imdb.GetChatLog(chatLog, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLog", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLog", err.Error())
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
return resp, errors.WrapError(constant.ErrDB)
|
||||||
}
|
}
|
||||||
for _, chatLog := range chatLogs {
|
for _, chatLog := range chatLogs {
|
||||||
pbChatLog := &pbMessageCMS.ChatLogs{
|
pbChatLog := &pbMessageCMS.ChatLogs{
|
||||||
SessionType: chatLog.SessionType,
|
SessionType: chatLog.SessionType,
|
||||||
ContentType: chatLog.ContentType,
|
ContentType: chatLog.ContentType,
|
||||||
SearchContent: req.Content,
|
SearchContent: req.Content,
|
||||||
WholeContent: chatLog.Content,
|
WholeContent: chatLog.Content,
|
||||||
Date: chatLog.CreateTime.String(),
|
Date: chatLog.CreateTime.String(),
|
||||||
SenderNickName: chatLog.SenderNickname,
|
SenderNickName: chatLog.SenderNickname,
|
||||||
SenderId: chatLog.SendID,
|
SenderId: chatLog.SendID,
|
||||||
}
|
}
|
||||||
if chatLog.SenderNickname == "" {
|
if chatLog.SenderNickname == "" {
|
||||||
sendUser, err := imdb.GetUserByUserID(chatLog.SendID)
|
sendUser, err := imdb.GetUserByUserID(chatLog.SendID)
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ import (
|
|||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func conversationNotification(contentType int32, m proto.Message, operationID, userID string) {
|
func SetConversationNotification(operationID, sendID, recvID string, contentType int, m proto.Message, tips open_im_sdk.TipsComm) {
|
||||||
|
log.NewInfo(operationID, "args: ", sendID, recvID, contentType, m.String(), tips.String())
|
||||||
var err error
|
var err error
|
||||||
var tips open_im_sdk.TipsComm
|
|
||||||
tips.Detail, err = proto.Marshal(m)
|
tips.Detail, err = proto.Marshal(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, utils.GetSelfFuncName(), "Marshal failed ", err.Error(), m.String())
|
log.NewError(operationID, "Marshal failed ", err.Error(), m.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
marshaler := jsonpb.Marshaler{
|
marshaler := jsonpb.Marshaler{
|
||||||
@@ -24,15 +24,10 @@ func conversationNotification(contentType int32, m proto.Message, operationID, u
|
|||||||
EmitDefaults: false,
|
EmitDefaults: false,
|
||||||
}
|
}
|
||||||
tips.JsonDetail, _ = marshaler.MarshalToString(m)
|
tips.JsonDetail, _ = marshaler.MarshalToString(m)
|
||||||
cn := config.Config.Notification
|
|
||||||
switch contentType {
|
|
||||||
case constant.ConversationOptChangeNotification:
|
|
||||||
tips.DefaultTips = cn.ConversationOptUpdate.DefaultTips.Tips
|
|
||||||
}
|
|
||||||
var n NotificationMsg
|
var n NotificationMsg
|
||||||
n.SendID = userID
|
n.SendID = sendID
|
||||||
n.RecvID = userID
|
n.RecvID = recvID
|
||||||
n.ContentType = contentType
|
n.ContentType = int32(contentType)
|
||||||
n.SessionType = constant.SingleChatType
|
n.SessionType = constant.SingleChatType
|
||||||
n.MsgFrom = constant.SysMsgType
|
n.MsgFrom = constant.SysMsgType
|
||||||
n.OperationID = operationID
|
n.OperationID = operationID
|
||||||
@@ -44,10 +39,38 @@ func conversationNotification(contentType int32, m proto.Message, operationID, u
|
|||||||
Notification(&n)
|
Notification(&n)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetConversationNotification(operationID, userID string) {
|
// SetPrivate调用
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "userID: ", userID)
|
func ConversationSetPrivateNotification(operationID, sendID, recvID string, isPrivateChat bool) {
|
||||||
conversationUpdateTips := open_im_sdk.ConversationUpdateTips{
|
log.NewInfo(operationID, utils.GetSelfFuncName())
|
||||||
|
conversationSetPrivateTips := &open_im_sdk.ConversationSetPrivateTips{
|
||||||
|
RecvID: recvID,
|
||||||
|
SendID: sendID,
|
||||||
|
IsPrivate: isPrivateChat,
|
||||||
|
}
|
||||||
|
var tips open_im_sdk.TipsComm
|
||||||
|
var tipsMsg string
|
||||||
|
//var senderName string
|
||||||
|
//senderName, err := im_mysql_model.GetUserNameByUserID(sendID)
|
||||||
|
//if err != nil {
|
||||||
|
// log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
// senderName = sendID
|
||||||
|
//}
|
||||||
|
if isPrivateChat == true {
|
||||||
|
tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.OpenTips
|
||||||
|
} else {
|
||||||
|
tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.CloseTips
|
||||||
|
}
|
||||||
|
tips.DefaultTips = tipsMsg
|
||||||
|
SetConversationNotification(operationID, sendID, recvID, constant.ConversationPrivateChatNotification, conversationSetPrivateTips, tips)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 会话改变
|
||||||
|
func ConversationChangeNotification(operationID, userID string) {
|
||||||
|
log.NewInfo(operationID, utils.GetSelfFuncName())
|
||||||
|
ConversationChangedTips := &open_im_sdk.ConversationUpdateTips{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
}
|
}
|
||||||
conversationNotification(constant.ConversationOptChangeNotification, &conversationUpdateTips, operationID, userID)
|
var tips open_im_sdk.TipsComm
|
||||||
|
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
|
||||||
|
SetConversationNotification(operationID, userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func (rpc *rpcChat) DelMsgList(_ context.Context, req *commonPb.DelMsgListReq) (
|
|||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsg failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsg failed", err.Error())
|
||||||
resp.ErrMsg = constant.ErrDB.ErrMsg
|
resp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
resp.ErrCode = constant.ErrDB.ErrCode
|
resp.ErrCode = constant.ErrDB.ErrCode
|
||||||
return resp, err
|
return resp, nil
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
|||||||
@@ -157,7 +157,17 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv
|
|||||||
case constant.MemberInvitedNotification: //
|
case constant.MemberInvitedNotification: //
|
||||||
tips.DefaultTips = toNickname + " " + cn.MemberInvited.DefaultTips.Tips
|
tips.DefaultTips = toNickname + " " + cn.MemberInvited.DefaultTips.Tips
|
||||||
case constant.MemberEnterNotification:
|
case constant.MemberEnterNotification:
|
||||||
tips.DefaultTips = toNickname + " " + cn.MemberInvited.DefaultTips.Tips
|
tips.DefaultTips = toNickname + " " + cn.MemberEnter.DefaultTips.Tips
|
||||||
|
case constant.GroupDismissedNotification:
|
||||||
|
tips.DefaultTips = toNickname + "" + cn.GroupDismissed.DefaultTips.Tips
|
||||||
|
case constant.GroupMutedNotification:
|
||||||
|
tips.DefaultTips = toNickname + "" + cn.GroupMuted.DefaultTips.Tips
|
||||||
|
case constant.GroupCancelMutedNotification:
|
||||||
|
tips.DefaultTips = toNickname + "" + cn.GroupCancelMuted.DefaultTips.Tips
|
||||||
|
case constant.GroupMemberMutedNotification:
|
||||||
|
tips.DefaultTips = toNickname + "" + cn.GroupMemberMuted.DefaultTips.Tips
|
||||||
|
case constant.GroupMemberCancelMutedNotification:
|
||||||
|
tips.DefaultTips = toNickname + "" + cn.GroupMemberCancelMuted.DefaultTips.Tips
|
||||||
default:
|
default:
|
||||||
log.Error(operationID, "contentType failed ", contentType)
|
log.Error(operationID, "contentType failed ", contentType)
|
||||||
return
|
return
|
||||||
@@ -225,6 +235,71 @@ func GroupInfoSetNotification(operationID, opUserID, groupID string) {
|
|||||||
groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID)
|
groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GroupMutedNotification(operationID, opUserID, groupID string) {
|
||||||
|
tips := open_im_sdk.GroupMutedTips{Group: &open_im_sdk.GroupInfo{},
|
||||||
|
OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
|
if err := setGroupInfo(groupID, tips.Group); err != nil {
|
||||||
|
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
|
||||||
|
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
groupNotification(constant.GroupMutedNotification, &tips, opUserID, groupID, "", operationID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GroupCancelMutedNotification(operationID, opUserID, groupID string) {
|
||||||
|
tips := open_im_sdk.GroupCancelMutedTips{Group: &open_im_sdk.GroupInfo{},
|
||||||
|
OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
|
if err := setGroupInfo(groupID, tips.Group); err != nil {
|
||||||
|
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
|
||||||
|
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
groupNotification(constant.GroupCancelMutedNotification, &tips, opUserID, groupID, "", operationID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GroupMemberMutedNotification(operationID, opUserID, groupID, groupMemberUserID string, mutedSeconds uint32) {
|
||||||
|
tips := open_im_sdk.GroupMemberMutedTips{Group: &open_im_sdk.GroupInfo{},
|
||||||
|
OpUser: &open_im_sdk.GroupMemberFullInfo{}, MutedUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
|
tips.MutedSeconds = mutedSeconds
|
||||||
|
if err := setGroupInfo(groupID, tips.Group); err != nil {
|
||||||
|
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
|
||||||
|
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil {
|
||||||
|
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
groupNotification(constant.GroupMemberMutedNotification, &tips, opUserID, groupID, "", operationID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GroupMemberCancelMutedNotification(operationID, opUserID, groupID, groupMemberUserID string) {
|
||||||
|
tips := open_im_sdk.GroupMemberCancelMutedTips{Group: &open_im_sdk.GroupInfo{},
|
||||||
|
OpUser: &open_im_sdk.GroupMemberFullInfo{}, MutedUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
|
if err := setGroupInfo(groupID, tips.Group); err != nil {
|
||||||
|
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
|
||||||
|
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil {
|
||||||
|
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
groupNotification(constant.GroupMemberCancelMutedNotification, &tips, opUserID, groupID, "", operationID)
|
||||||
|
}
|
||||||
|
|
||||||
//message ReceiveJoinApplicationTips{
|
//message ReceiveJoinApplicationTips{
|
||||||
// GroupInfo Group = 1;
|
// GroupInfo Group = 1;
|
||||||
// PublicUserInfo Applicant = 2;
|
// PublicUserInfo Applicant = 2;
|
||||||
@@ -324,6 +399,19 @@ func GroupOwnerTransferredNotification(req *pbGroup.TransferGroupOwnerReq) {
|
|||||||
groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, req.OpUserID, req.GroupID, "", req.OperationID)
|
groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, req.OpUserID, req.GroupID, "", req.OperationID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GroupDismissedNotification(req *pbGroup.DismissGroupReq) {
|
||||||
|
tips := open_im_sdk.GroupDismissedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
|
if err := setGroupInfo(req.GroupID, tips.Group); err != nil {
|
||||||
|
log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := setOpUserInfo(req.OpUserID, req.GroupID, tips.OpUser); err != nil {
|
||||||
|
log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
groupNotification(constant.GroupDismissedNotification, &tips, req.OpUserID, req.GroupID, "", req.OperationID)
|
||||||
|
}
|
||||||
|
|
||||||
//message MemberKickedTips{
|
//message MemberKickedTips{
|
||||||
// GroupInfo Group = 1;
|
// GroupInfo Group = 1;
|
||||||
// GroupMemberFullInfo OpUser = 2;
|
// GroupMemberFullInfo OpUser = 2;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package msg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/kafka"
|
"Open_IM/pkg/common/kafka"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
@@ -22,7 +23,7 @@ type rpcChat struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewRpcChatServer(port int) *rpcChat {
|
func NewRpcChatServer(port int) *rpcChat {
|
||||||
log.NewPrivateLog("msg")
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
rc := rpcChat{
|
rc := rpcChat{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImOfflineMessageName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImOfflineMessageName,
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ func (rpc *rpcChat) encapsulateMsgData(msg *sdk_ws.MsgData) {
|
|||||||
case constant.HasReadReceipt:
|
case constant.HasReadReceipt:
|
||||||
log.Info("", "this is a test start", msg, msg.Options)
|
log.Info("", "this is a test start", msg, msg.Options)
|
||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false)
|
||||||
|
utils.SetSwitchFromOptions(msg.Options, constant.IsSenderConversationUpdate, false)
|
||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsUnreadCount, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsUnreadCount, false)
|
||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, false)
|
||||||
log.Info("", "this is a test end", msg, msg.Options)
|
log.Info("", "this is a test end", msg, msg.Options)
|
||||||
@@ -124,6 +125,7 @@ func (rpc *rpcChat) encapsulateMsgData(msg *sdk_ws.MsgData) {
|
|||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsPersistent, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsPersistent, false)
|
||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsSenderSync, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsSenderSync, false)
|
||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false)
|
||||||
|
utils.SetSwitchFromOptions(msg.Options, constant.IsSenderConversationUpdate, false)
|
||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsUnreadCount, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsUnreadCount, false)
|
||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, false)
|
||||||
|
|
||||||
@@ -279,6 +281,23 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendGroupMsg failed", err.Error())
|
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendGroupMsg failed", err.Error())
|
||||||
}
|
}
|
||||||
return returnMsg(&replay, pb, 0, "", msgToMQ.MsgData.ServerMsgID, msgToMQ.MsgData.SendTime)
|
return returnMsg(&replay, pb, 0, "", msgToMQ.MsgData.ServerMsgID, msgToMQ.MsgData.SendTime)
|
||||||
|
case constant.NotificationChatType:
|
||||||
|
msgToMQ.MsgData = pb.MsgData
|
||||||
|
log.NewInfo(msgToMQ.OperationID, msgToMQ)
|
||||||
|
err1 := rpc.sendMsgToKafka(&msgToMQ, msgToMQ.MsgData.RecvID)
|
||||||
|
if err1 != nil {
|
||||||
|
log.NewError(msgToMQ.OperationID, "kafka send msg err:RecvID", msgToMQ.MsgData.RecvID, msgToMQ.String())
|
||||||
|
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if msgToMQ.MsgData.SendID != msgToMQ.MsgData.RecvID { //Filter messages sent to yourself
|
||||||
|
err2 := rpc.sendMsgToKafka(&msgToMQ, msgToMQ.MsgData.SendID)
|
||||||
|
if err2 != nil {
|
||||||
|
log.NewError(msgToMQ.OperationID, "kafka send msg err:SendID", msgToMQ.MsgData.SendID, msgToMQ.String())
|
||||||
|
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnMsg(&replay, pb, 0, "", msgToMQ.MsgData.ServerMsgID, msgToMQ.MsgData.SendTime)
|
||||||
default:
|
default:
|
||||||
return returnMsg(&replay, pb, 203, "unkonwn sessionType", "", 0)
|
return returnMsg(&replay, pb, 203, "unkonwn sessionType", "", 0)
|
||||||
}
|
}
|
||||||
@@ -503,14 +522,56 @@ func Notification(n *NotificationMsg) {
|
|||||||
ex = config.Config.Notification.ConversationOptUpdate.OfflinePush.Ext
|
ex = config.Config.Notification.ConversationOptUpdate.OfflinePush.Ext
|
||||||
reliabilityLevel = config.Config.Notification.ConversationOptUpdate.Conversation.ReliabilityLevel
|
reliabilityLevel = config.Config.Notification.ConversationOptUpdate.Conversation.ReliabilityLevel
|
||||||
unReadCount = config.Config.Notification.ConversationOptUpdate.Conversation.UnreadCount
|
unReadCount = config.Config.Notification.ConversationOptUpdate.Conversation.UnreadCount
|
||||||
|
|
||||||
|
case constant.GroupDismissedNotification:
|
||||||
|
pushSwitch = config.Config.Notification.GroupDismissed.OfflinePush.PushSwitch
|
||||||
|
title = config.Config.Notification.GroupDismissed.OfflinePush.Title
|
||||||
|
desc = config.Config.Notification.GroupDismissed.OfflinePush.Desc
|
||||||
|
ex = config.Config.Notification.GroupDismissed.OfflinePush.Ext
|
||||||
|
reliabilityLevel = config.Config.Notification.GroupDismissed.Conversation.ReliabilityLevel
|
||||||
|
unReadCount = config.Config.Notification.GroupDismissed.Conversation.UnreadCount
|
||||||
|
|
||||||
|
case constant.GroupMutedNotification:
|
||||||
|
pushSwitch = config.Config.Notification.GroupMuted.OfflinePush.PushSwitch
|
||||||
|
title = config.Config.Notification.GroupMuted.OfflinePush.Title
|
||||||
|
desc = config.Config.Notification.GroupMuted.OfflinePush.Desc
|
||||||
|
ex = config.Config.Notification.GroupMuted.OfflinePush.Ext
|
||||||
|
reliabilityLevel = config.Config.Notification.GroupMuted.Conversation.ReliabilityLevel
|
||||||
|
unReadCount = config.Config.Notification.GroupMuted.Conversation.UnreadCount
|
||||||
|
|
||||||
|
case constant.GroupCancelMutedNotification:
|
||||||
|
pushSwitch = config.Config.Notification.GroupCancelMuted.OfflinePush.PushSwitch
|
||||||
|
title = config.Config.Notification.GroupCancelMuted.OfflinePush.Title
|
||||||
|
desc = config.Config.Notification.GroupCancelMuted.OfflinePush.Desc
|
||||||
|
ex = config.Config.Notification.GroupCancelMuted.OfflinePush.Ext
|
||||||
|
reliabilityLevel = config.Config.Notification.GroupCancelMuted.Conversation.ReliabilityLevel
|
||||||
|
unReadCount = config.Config.Notification.GroupCancelMuted.Conversation.UnreadCount
|
||||||
|
|
||||||
|
case constant.GroupMemberMutedNotification:
|
||||||
|
pushSwitch = config.Config.Notification.GroupMemberMuted.OfflinePush.PushSwitch
|
||||||
|
title = config.Config.Notification.GroupMemberMuted.OfflinePush.Title
|
||||||
|
desc = config.Config.Notification.GroupMemberMuted.OfflinePush.Desc
|
||||||
|
ex = config.Config.Notification.GroupMemberMuted.OfflinePush.Ext
|
||||||
|
reliabilityLevel = config.Config.Notification.GroupMemberMuted.Conversation.ReliabilityLevel
|
||||||
|
unReadCount = config.Config.Notification.GroupMemberMuted.Conversation.UnreadCount
|
||||||
|
|
||||||
|
case constant.GroupMemberCancelMutedNotification:
|
||||||
|
pushSwitch = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.PushSwitch
|
||||||
|
title = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Title
|
||||||
|
desc = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Desc
|
||||||
|
ex = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Ext
|
||||||
|
reliabilityLevel = config.Config.Notification.GroupMemberCancelMuted.Conversation.ReliabilityLevel
|
||||||
|
unReadCount = config.Config.Notification.GroupMemberCancelMuted.Conversation.UnreadCount
|
||||||
}
|
}
|
||||||
switch reliabilityLevel {
|
switch reliabilityLevel {
|
||||||
case constant.UnreliableNotification:
|
case constant.UnreliableNotification:
|
||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsHistory, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsHistory, false)
|
||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsPersistent, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsPersistent, false)
|
||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false)
|
||||||
|
utils.SetSwitchFromOptions(msg.Options, constant.IsSenderConversationUpdate, false)
|
||||||
case constant.ReliableNotificationNoMsg:
|
case constant.ReliableNotificationNoMsg:
|
||||||
utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false)
|
utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false)
|
||||||
|
utils.SetSwitchFromOptions(msg.Options, constant.IsSenderConversationUpdate, false)
|
||||||
case constant.ReliableNotificationMsg:
|
case constant.ReliableNotificationMsg:
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -527,6 +588,6 @@ func Notification(n *NotificationMsg) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), err.Error())
|
log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), err.Error())
|
||||||
} else if reply.ErrCode != 0 {
|
} else if reply.ErrCode != 0 {
|
||||||
log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String())
|
log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), reply.ErrCode, reply.ErrMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package msg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TagSendMessage(operationID, sendID, recvID, content string, senderPlatformID int32) {
|
||||||
|
log.NewInfo(operationID, utils.GetSelfFuncName(), "args: ", sendID, recvID, content)
|
||||||
|
var req pbChat.SendMsgReq
|
||||||
|
var msgData pbCommon.MsgData
|
||||||
|
msgData.SendID = sendID
|
||||||
|
msgData.RecvID = recvID
|
||||||
|
msgData.ContentType = constant.Custom
|
||||||
|
msgData.SessionType = constant.SingleChatType
|
||||||
|
msgData.MsgFrom = constant.UserMsgType
|
||||||
|
msgData.Content = []byte(content)
|
||||||
|
msgData.Options = map[string]bool{}
|
||||||
|
msgData.Options[constant.IsSenderConversationUpdate] = false
|
||||||
|
msgData.SendTime = time.Now().Unix()
|
||||||
|
msgData.CreateTime = time.Now().Unix()
|
||||||
|
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.OpenImOfflineMessageName)
|
||||||
|
client := pbChat.NewChatClient(etcdConn)
|
||||||
|
respPb, err := client.SendMsg(context.Background(), &req)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(operationID, utils.GetSelfFuncName(), "send msg failed", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if respPb.ErrCode != 0 {
|
||||||
|
log.NewError(operationID, utils.GetSelfFuncName(), "send tag msg failed ", respPb)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,263 @@
|
|||||||
|
package office
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/internal/rpc/msg"
|
||||||
|
"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"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
|
pbOffice "Open_IM/pkg/proto/office"
|
||||||
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"net"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type officeServer struct {
|
||||||
|
rpcPort int
|
||||||
|
rpcRegisterName string
|
||||||
|
etcdSchema string
|
||||||
|
etcdAddr []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOfficeServer(port int) *officeServer {
|
||||||
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
|
return &officeServer{
|
||||||
|
rpcPort: port,
|
||||||
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImOfficeName,
|
||||||
|
etcdSchema: config.Config.Etcd.EtcdSchema,
|
||||||
|
etcdAddr: config.Config.Etcd.EtcdAddr,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *officeServer) Run() {
|
||||||
|
log.NewInfo("0", "officeServer rpc start ")
|
||||||
|
ip := utils.ServerIP
|
||||||
|
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
|
||||||
|
//listener network
|
||||||
|
listener, err := net.Listen("tcp", registerAddress)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo("0", "listen network success, ", registerAddress, listener)
|
||||||
|
defer listener.Close()
|
||||||
|
//grpc server
|
||||||
|
srv := grpc.NewServer()
|
||||||
|
defer srv.GracefulStop()
|
||||||
|
//Service registers with etcd
|
||||||
|
pbOffice.RegisterOfficeServiceServer(srv, s)
|
||||||
|
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = srv.Serve(listener)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError("0", "Serve failed ", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo("0", "message cms rpc success")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *officeServer) GetUserTags(_ context.Context, req *pbOffice.GetUserTagsReq) (resp *pbOffice.GetUserTagsResp, err error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req ", req.String())
|
||||||
|
resp = &pbOffice.GetUserTagsResp{
|
||||||
|
CommonResp: &pbOffice.CommonResp{},
|
||||||
|
Tags: []*pbOffice.Tag{},
|
||||||
|
}
|
||||||
|
tags, err := db.DB.GetUserTags(req.UserID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "tags: ", tags)
|
||||||
|
for _, v := range tags {
|
||||||
|
tag := &pbOffice.Tag{
|
||||||
|
TagID: v.TagID,
|
||||||
|
TagName: v.TagName,
|
||||||
|
}
|
||||||
|
for _, userID := range v.UserList {
|
||||||
|
UserName, err := im_mysql_model.GetUserNameByUserID(userID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tag.UserList = append(tag.UserList, &pbOffice.TagUser{
|
||||||
|
UserID: userID,
|
||||||
|
UserName: UserName,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
resp.Tags = append(resp.Tags, tag)
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp ", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *officeServer) CreateTag(_ context.Context, req *pbOffice.CreateTagReq) (resp *pbOffice.CreateTagResp, err error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "CreateTag req", req.String())
|
||||||
|
userIDList := utils.RemoveRepeatedStringInList(req.UserIDList)
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "userIDList: ", userIDList)
|
||||||
|
resp = &pbOffice.CreateTagResp{CommonResp: &pbOffice.CommonResp{}}
|
||||||
|
if err := db.DB.CreateTag(req.UserID, req.TagName, userIDList); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *officeServer) DeleteTag(_ context.Context, req *pbOffice.DeleteTagReq) (resp *pbOffice.DeleteTagResp, err error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp = &pbOffice.DeleteTagResp{CommonResp: &pbOffice.CommonResp{}}
|
||||||
|
if err := db.DB.DeleteTag(req.UserID, req.TagID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DeleteTag failed", err.Error())
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *officeServer) SetTag(_ context.Context, req *pbOffice.SetTagReq) (resp *pbOffice.SetTagResp, err error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp = &pbOffice.SetTagResp{CommonResp: &pbOffice.CommonResp{}}
|
||||||
|
IncreaseUserIDList := utils.RemoveRepeatedStringInList(req.IncreaseUserIDList)
|
||||||
|
reduceUserIDList := utils.RemoveRepeatedStringInList(req.ReduceUserIDList)
|
||||||
|
if err := db.DB.SetTag(req.UserID, req.TagID, req.NewName, IncreaseUserIDList, reduceUserIDList); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetTag failed", err.Error())
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagReq) (resp *pbOffice.SendMsg2TagResp, err error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp = &pbOffice.SendMsg2TagResp{CommonResp: &pbOffice.CommonResp{}}
|
||||||
|
var tagUserIDList []string
|
||||||
|
for _, tagID := range req.TagList {
|
||||||
|
userIDList, err := db.DB.GetUserIDListByTagID(req.SendID, tagID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserIDListByTagID failed", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tagUserIDList = append(tagUserIDList, userIDList...)
|
||||||
|
}
|
||||||
|
var groupUserIDList []string
|
||||||
|
for _, groupID := range req.GroupList {
|
||||||
|
userIDList, err := im_mysql_model.GetGroupMemberIDListByGroupID(groupID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID failed", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), userIDList)
|
||||||
|
groupUserIDList = append(groupUserIDList, userIDList...)
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), groupUserIDList, req.GroupList)
|
||||||
|
var userIDList []string
|
||||||
|
userIDList = append(userIDList, tagUserIDList...)
|
||||||
|
userIDList = append(userIDList, groupUserIDList...)
|
||||||
|
userIDList = append(userIDList, req.UserList...)
|
||||||
|
userIDList = utils.RemoveRepeatedStringInList(userIDList)
|
||||||
|
for i, userID := range userIDList {
|
||||||
|
if userID == req.SendID || userID == "" {
|
||||||
|
userIDList = append(userIDList[:i], userIDList[i+1:]...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "total userIDList result: ", userIDList)
|
||||||
|
for _, userID := range userIDList {
|
||||||
|
msg.TagSendMessage(req.OperationID, req.SendID, userID, req.Content, req.SenderPlatformID)
|
||||||
|
}
|
||||||
|
var tagSendLogs db.TagSendLog
|
||||||
|
for _, userID := range userIDList {
|
||||||
|
userName, err := im_mysql_model.GetUserNameByUserID(userID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tagSendLogs.UserList = append(tagSendLogs.UserList, db.TagUser{
|
||||||
|
UserID: userID,
|
||||||
|
UserName: userName,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
tagSendLogs.SendID = req.SendID
|
||||||
|
tagSendLogs.Content = req.Content
|
||||||
|
tagSendLogs.SenderPlatformID = req.SenderPlatformID
|
||||||
|
tagSendLogs.SendTime = time.Now().Unix()
|
||||||
|
if err := db.DB.SaveTagSendLog(&tagSendLogs); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SaveTagSendLog failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *officeServer) GetTagSendLogs(_ context.Context, req *pbOffice.GetTagSendLogsReq) (resp *pbOffice.GetTagSendLogsResp, err error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp = &pbOffice.GetTagSendLogsResp{
|
||||||
|
CommonResp: &pbOffice.CommonResp{},
|
||||||
|
Pagination: &pbCommon.ResponsePagination{
|
||||||
|
CurrentPage: req.Pagination.PageNumber,
|
||||||
|
ShowNumber: req.Pagination.ShowNumber,
|
||||||
|
},
|
||||||
|
TagSendLogs: []*pbOffice.TagSendLog{},
|
||||||
|
}
|
||||||
|
tagSendLogs, err := db.DB.GetTagSendLogs(req.UserID, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTagSendLogs", err.Error())
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
if err := utils.CopyStructFields(&resp.TagSendLogs, tagSendLogs); err != nil {
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *officeServer) GetUserTagByID(_ context.Context, req *pbOffice.GetUserTagByIDReq) (resp *pbOffice.GetUserTagByIDResp, err error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp = &pbOffice.GetUserTagByIDResp{
|
||||||
|
CommonResp: &pbOffice.CommonResp{},
|
||||||
|
Tag: &pbOffice.Tag{},
|
||||||
|
}
|
||||||
|
tag, err := db.DB.GetTagByID(req.UserID, req.TagID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTagByID failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
for _, userID := range tag.UserList {
|
||||||
|
userName, err := im_mysql_model.GetUserNameByUserID(userID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
resp.Tag.UserList = append(resp.Tag.UserList, &pbOffice.TagUser{
|
||||||
|
UserID: userID,
|
||||||
|
UserName: userName,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
resp.Tag.TagID = tag.TagID
|
||||||
|
resp.Tag.TagName = tag.TagName
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
@@ -19,10 +19,10 @@ import (
|
|||||||
//open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
//open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
//"context"
|
//"context"
|
||||||
|
errors "Open_IM/pkg/common/http"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
errors "Open_IM/pkg/common/http"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
@@ -35,7 +35,7 @@ type statisticsServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewStatisticsServer(port int) *statisticsServer {
|
func NewStatisticsServer(port int) *statisticsServer {
|
||||||
log.NewPrivateLog("Statistics")
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
return &statisticsServer{
|
return &statisticsServer{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImStatisticsName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImStatisticsName,
|
||||||
@@ -164,7 +164,7 @@ func GetRangeDate(from, to time.Time) [][2]time.Time {
|
|||||||
}
|
}
|
||||||
// month
|
// month
|
||||||
case !isInOneMonth(from, to):
|
case !isInOneMonth(from, to):
|
||||||
if to.Sub(from) < time.Hour * 24 * 30 {
|
if to.Sub(from) < time.Hour*24*30 {
|
||||||
for i := 0; ; i++ {
|
for i := 0; ; i++ {
|
||||||
fromTime := from.Add(time.Hour * 24 * time.Duration(i))
|
fromTime := from.Add(time.Hour * 24 * time.Duration(i))
|
||||||
toTime := from.Add(time.Hour * 24 * time.Duration(i+1))
|
toTime := from.Add(time.Hour * 24 * time.Duration(i+1))
|
||||||
@@ -251,7 +251,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
|
|||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
}
|
}
|
||||||
resp.TotalGroupNumList[index] = &pbStatistics.DateNumList{
|
resp.TotalGroupNumList[index] = &pbStatistics.DateNumList{
|
||||||
Date: v[0].String(),
|
Date: v[0].String(),
|
||||||
Num: num,
|
Num: num,
|
||||||
}
|
}
|
||||||
}(wg, i, v)
|
}(wg, i, v)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ type userServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewUserServer(port int) *userServer {
|
func NewUserServer(port int) *userServer {
|
||||||
log.NewPrivateLog("user")
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
return &userServer{
|
return &userServer{
|
||||||
rpcPort: port,
|
rpcPort: port,
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImUserName,
|
rpcRegisterName: config.Config.RpcRegisterName.OpenImUserName,
|
||||||
@@ -72,6 +72,30 @@ func (s *userServer) Run() {
|
|||||||
log.NewInfo("0", "rpc user success")
|
log.NewInfo("0", "rpc user success")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func syncPeerUserConversation(conversation *pbUser.Conversation, operationID string) error {
|
||||||
|
peerUserConversation := db.Conversation{
|
||||||
|
OwnerUserID: conversation.UserID,
|
||||||
|
ConversationID: "single_" + conversation.OwnerUserID,
|
||||||
|
ConversationType: constant.SingleChatType,
|
||||||
|
UserID: conversation.OwnerUserID,
|
||||||
|
GroupID: "",
|
||||||
|
RecvMsgOpt: 0,
|
||||||
|
UnreadCount: 0,
|
||||||
|
DraftTextTime: 0,
|
||||||
|
IsPinned: false,
|
||||||
|
IsPrivateChat: conversation.IsPrivateChat,
|
||||||
|
AttachedInfo: "",
|
||||||
|
Ex: "",
|
||||||
|
}
|
||||||
|
err := imdb.PeerUserSetConversation(peerUserConversation)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(operationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
chat.ConversationSetPrivateNotification(operationID, conversation.OwnerUserID, conversation.UserID, conversation.IsPrivateChat)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *userServer) GetUserInfo(ctx context.Context, req *pbUser.GetUserInfoReq) (*pbUser.GetUserInfoResp, error) {
|
func (s *userServer) GetUserInfo(ctx context.Context, req *pbUser.GetUserInfoReq) (*pbUser.GetUserInfoResp, error) {
|
||||||
log.NewInfo(req.OperationID, "GetUserInfo args ", req.String())
|
log.NewInfo(req.OperationID, "GetUserInfo args ", req.String())
|
||||||
var userInfoList []*sdkws.UserInfo
|
var userInfoList []*sdkws.UserInfo
|
||||||
@@ -96,6 +120,9 @@ func (s *userServer) GetUserInfo(ctx context.Context, req *pbUser.GetUserInfoReq
|
|||||||
|
|
||||||
func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.BatchSetConversationsReq) (*pbUser.BatchSetConversationsResp, error) {
|
func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.BatchSetConversationsReq) (*pbUser.BatchSetConversationsResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
if req.NotificationType == 0 {
|
||||||
|
req.NotificationType = constant.ConversationOptChangeNotification
|
||||||
|
}
|
||||||
resp := &pbUser.BatchSetConversationsResp{}
|
resp := &pbUser.BatchSetConversationsResp{}
|
||||||
for _, v := range req.Conversations {
|
for _, v := range req.Conversations {
|
||||||
conversation := db.Conversation{}
|
conversation := db.Conversation{}
|
||||||
@@ -113,8 +140,14 @@ func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.Batc
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
resp.Success = append(resp.Success, v.ConversationID)
|
resp.Success = append(resp.Success, v.ConversationID)
|
||||||
|
// if is set private chat operation,then peer user need to sync and set tips\
|
||||||
|
if v.ConversationType == constant.SingleChatType && req.NotificationType == constant.ConversationPrivateChatNotification {
|
||||||
|
if err := syncPeerUserConversation(v, req.OperationID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "syncPeerUserConversation", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
chat.SetConversationNotification(req.OperationID, req.OwnerUserID)
|
chat.ConversationChangeNotification(req.OperationID, req.OwnerUserID)
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return", resp.String())
|
||||||
resp.CommonResp = &pbUser.CommonResp{}
|
resp.CommonResp = &pbUser.CommonResp{}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@@ -173,6 +206,9 @@ func (s *userServer) GetConversations(ctx context.Context, req *pbUser.GetConver
|
|||||||
|
|
||||||
func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConversationReq) (*pbUser.SetConversationResp, error) {
|
func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConversationReq) (*pbUser.SetConversationResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
if req.NotificationType == 0 {
|
||||||
|
req.NotificationType = constant.ConversationOptChangeNotification
|
||||||
|
}
|
||||||
resp := &pbUser.SetConversationResp{}
|
resp := &pbUser.SetConversationResp{}
|
||||||
var conversation db.Conversation
|
var conversation db.Conversation
|
||||||
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
|
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
|
||||||
@@ -189,7 +225,17 @@ func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConvers
|
|||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
chat.SetConversationNotification(req.OperationID, req.Conversation.OwnerUserID)
|
// notification
|
||||||
|
if req.Conversation.ConversationType == constant.SingleChatType && req.NotificationType == constant.ConversationPrivateChatNotification {
|
||||||
|
//sync peer user conversation if conversation is singleChatType
|
||||||
|
if err := syncPeerUserConversation(req.Conversation, req.OperationID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "syncPeerUserConversation", err.Error())
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
chat.ConversationChangeNotification(req.OperationID, req.Conversation.OwnerUserID)
|
||||||
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return", resp.String())
|
||||||
resp.CommonResp = &pbUser.CommonResp{}
|
resp.CommonResp = &pbUser.CommonResp{}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@@ -207,13 +253,24 @@ func (s *userServer) SetRecvMsgOpt(ctx context.Context, req *pbUser.SetRecvMsgOp
|
|||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
stringList := strings.Split(req.ConversationID, "_")
|
||||||
|
if len(stringList) > 1 {
|
||||||
|
switch stringList[0] {
|
||||||
|
case "single_":
|
||||||
|
conversation.UserID = stringList[1]
|
||||||
|
conversation.ConversationType = constant.SingleChatType
|
||||||
|
case "group":
|
||||||
|
conversation.GroupID = stringList[1]
|
||||||
|
conversation.ConversationType = constant.GroupChatType
|
||||||
|
}
|
||||||
|
}
|
||||||
err := imdb.SetRecvMsgOpt(conversation)
|
err := imdb.SetRecvMsgOpt(conversation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
chat.SetConversationNotification(req.OperationID, req.OwnerUserID)
|
chat.ConversationChangeNotification(req.OperationID, req.OwnerUserID)
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
resp.CommonResp = &pbUser.CommonResp{}
|
resp.CommonResp = &pbUser.CommonResp{}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ func Test_ParseToken(t *testing.T) {
|
|||||||
uid := "1"
|
uid := "1"
|
||||||
platform := int32(1)
|
platform := int32(1)
|
||||||
tokenString, _, _ := token_verify.CreateToken(uid, platform)
|
tokenString, _, _ := token_verify.CreateToken(uid, platform)
|
||||||
claims, err := token_verify.ParseToken(tokenString)
|
claims, err := token_verify.ParseToken(tokenString, "")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
assert.Equal(t, claims.UID, uid)
|
assert.Equal(t, claims.UID, uid)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ type SetReceiveMessageOptResp struct {
|
|||||||
|
|
||||||
type Conversation struct {
|
type Conversation struct {
|
||||||
OwnerUserID string `json:"ownerUserID" binding:"required"`
|
OwnerUserID string `json:"ownerUserID" binding:"required"`
|
||||||
ConversationID string `json:"conversationID"`
|
ConversationID string `json:"conversationID" binding:"required"`
|
||||||
ConversationType int32 `json:"conversationType"`
|
ConversationType int32 `json:"conversationType" binding:"required"`
|
||||||
UserID string `json:"userID"`
|
UserID string `json:"userID"`
|
||||||
GroupID string `json:"groupID"`
|
GroupID string `json:"groupID"`
|
||||||
RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
|
RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
|
||||||
@@ -49,7 +49,8 @@ type Conversation struct {
|
|||||||
|
|
||||||
type SetConversationReq struct {
|
type SetConversationReq struct {
|
||||||
Conversation
|
Conversation
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
NotificationType int32 `json:"notificationType"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetConversationResp struct {
|
type SetConversationResp struct {
|
||||||
@@ -57,9 +58,10 @@ type SetConversationResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BatchSetConversationsReq struct {
|
type BatchSetConversationsReq struct {
|
||||||
Conversations []Conversation `json:"conversations" binding:"required"`
|
Conversations []Conversation `json:"conversations" binding:"required"`
|
||||||
OwnerUserID string `json:"ownerUserID" binding:"required"`
|
NotificationType int32 `json:"notificationType"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OwnerUserID string `json:"ownerUserID" binding:"required"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BatchSetConversationsResp struct {
|
type BatchSetConversationsResp struct {
|
||||||
@@ -103,10 +105,11 @@ type GetConversationsResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SetRecvMsgOptReq struct {
|
type SetRecvMsgOptReq struct {
|
||||||
OwnerUserID string `json:"ownerUserID" binding:"required"`
|
OwnerUserID string `json:"ownerUserID" binding:"required"`
|
||||||
ConversationID string `json:"conversationID"`
|
ConversationID string `json:"conversationID"`
|
||||||
RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
|
RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
NotificationType int32 `json:"notificationType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetRecvMsgOptResp struct {
|
type SetRecvMsgOptResp struct {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ type ImportFriendReq struct {
|
|||||||
FromUserID string `json:"fromUserID" binding:"required"`
|
FromUserID string `json:"fromUserID" binding:"required"`
|
||||||
}
|
}
|
||||||
type UserIDResult struct {
|
type UserIDResult struct {
|
||||||
UserID string `json:"userID""`
|
UserID string `json:"userID"`
|
||||||
Result int32 `json:"result"`
|
Result int32 `json:"result"`
|
||||||
}
|
}
|
||||||
type ImportFriendResp struct {
|
type ImportFriendResp struct {
|
||||||
|
|||||||
@@ -177,3 +177,46 @@ type TransferGroupOwnerReq struct {
|
|||||||
type TransferGroupOwnerResp struct {
|
type TransferGroupOwnerResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DismissGroupReq struct {
|
||||||
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
}
|
||||||
|
type DismissGroupResp struct {
|
||||||
|
CommResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type MuteGroupMemberReq struct {
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
|
UserID string `json:"userID" binding:"required"`
|
||||||
|
MutedSeconds uint32 `json:"mutedSeconds" binding:"required"`
|
||||||
|
}
|
||||||
|
type MuteGroupMemberResp struct {
|
||||||
|
CommResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type CancelMuteGroupMemberReq struct {
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
|
UserID string `json:"userID" binding:"required"`
|
||||||
|
}
|
||||||
|
type CancelMuteGroupMemberResp struct {
|
||||||
|
CommResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type MuteGroupReq struct {
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
|
}
|
||||||
|
type MuteGroupResp struct {
|
||||||
|
CommResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type CancelMuteGroupReq struct {
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
|
}
|
||||||
|
type CancelMuteGroupResp struct {
|
||||||
|
CommResp
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,8 +6,20 @@ type MinioStorageCredentialReq struct {
|
|||||||
|
|
||||||
type MiniostorageCredentialResp struct {
|
type MiniostorageCredentialResp struct {
|
||||||
SecretAccessKey string `json:"secretAccessKey"`
|
SecretAccessKey string `json:"secretAccessKey"`
|
||||||
AccessKeyID string `json:"accessKeyID"`
|
AccessKeyID string `json:"accessKeyID"`
|
||||||
SessionToken string `json:"sessionToken"`
|
SessionToken string `json:"sessionToken"`
|
||||||
BucketName string `json:"bucketName"`
|
BucketName string `json:"bucketName"`
|
||||||
StsEndpointURL string `json:"stsEndpointURL"`
|
StsEndpointURL string `json:"stsEndpointURL"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MinioUploadFileReq struct {
|
||||||
|
OperationID string `form:"operationID" binding:"required"`
|
||||||
|
FileType int `form:"fileType" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MinioUploadFileResp struct {
|
||||||
|
URL string `json:"URL"`
|
||||||
|
NewName string `json:"newName"`
|
||||||
|
SnapshotURL string `json:"snapshotURL,omitempty"`
|
||||||
|
SnapshotNewName string `json:"snapshotName,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package base_info
|
||||||
|
|
||||||
|
import (
|
||||||
|
pbOffice "Open_IM/pkg/proto/office"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetUserTagsReq struct {
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUserTagsResp struct {
|
||||||
|
CommResp
|
||||||
|
Data struct {
|
||||||
|
Tags []*pbOffice.Tag `json:"tags"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateTagReq struct {
|
||||||
|
TagName string `json:"tagName" binding:"required"`
|
||||||
|
UserIDList []string `json:"userIDList" binding:"required"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateTagResp struct {
|
||||||
|
CommResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteTagReq struct {
|
||||||
|
TagID string `json:"tagID" binding:"required"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteTagResp struct {
|
||||||
|
CommResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetTagReq struct {
|
||||||
|
TagID string `json:"tagID" binding:"required"`
|
||||||
|
NewName string `json:"newName"`
|
||||||
|
IncreaseUserIDList []string `json:"increaseUserIDList"`
|
||||||
|
ReduceUserIDList []string `json:"reduceUserIDList"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetTagResp struct {
|
||||||
|
CommResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type SendMsg2TagReq struct {
|
||||||
|
TagList []string `json:"tagList"`
|
||||||
|
UserList []string `json:"userList"`
|
||||||
|
GroupList []string `json:"groupList"`
|
||||||
|
|
||||||
|
SenderPlatformID int32 `json:"senderPlatformID" binding:"required"`
|
||||||
|
Content string `json:"content" binding:"required"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SendMsg2TagResp struct {
|
||||||
|
CommResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetTagSendLogsReq struct {
|
||||||
|
PageNumber int32 `json:"pageNumber" binding:"required"`
|
||||||
|
ShowNumber int32 `json:"showNumber" binding:"required"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetTagSendLogsResp struct {
|
||||||
|
CommResp
|
||||||
|
Data struct {
|
||||||
|
Logs []*pbOffice.TagSendLog `json:"logs"`
|
||||||
|
CurrentPage int32 `json:"currentPage"`
|
||||||
|
ShowNumber int32 `json:"showNumber"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUserTagByIDReq struct {
|
||||||
|
TagID string `json:"tagID" binding:"required"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUserTagByIDResp struct {
|
||||||
|
CommResp
|
||||||
|
Data struct {
|
||||||
|
Tag *pbOffice.Tag `json:"tag"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package base_info
|
||||||
|
|
||||||
|
type OSSCredentialReq struct {
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
Filename string `json:"filename"`
|
||||||
|
FileType string `json:"file_type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OSSCredentialRespData struct {
|
||||||
|
Endpoint string `json:"endpoint"`
|
||||||
|
AccessKeyId string `json:"access_key_id"`
|
||||||
|
AccessKeySecret string `json:"access_key_secret"`
|
||||||
|
Token string `json:"token"`
|
||||||
|
Bucket string `json:"bucket"`
|
||||||
|
FinalHost string `json:"final_host"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OSSCredentialResp struct {
|
||||||
|
CommResp
|
||||||
|
OssData OSSCredentialRespData `json:"-"`
|
||||||
|
Data map[string]interface{} `json:"data"`
|
||||||
|
}
|
||||||
@@ -45,6 +45,17 @@ type config struct {
|
|||||||
SecretID string `yaml:"secretID"`
|
SecretID string `yaml:"secretID"`
|
||||||
SecretKey string `yaml:"secretKey"`
|
SecretKey string `yaml:"secretKey"`
|
||||||
}
|
}
|
||||||
|
Ali struct {
|
||||||
|
RegionID string `yaml:"regionID"`
|
||||||
|
AccessKeyID string `yaml:"accessKeyID"`
|
||||||
|
AccessKeySecret string `yaml:"accessKeySecret"`
|
||||||
|
StsEndpoint string `yaml:"stsEndpoint"`
|
||||||
|
OssEndpoint string `yaml:"ossEndpoint"`
|
||||||
|
Bucket string `yaml:"bucket"`
|
||||||
|
FinalHost string `yaml:"finalHost"`
|
||||||
|
StsDurationSeconds int64 `yaml:"stsDurationSeconds"`
|
||||||
|
OssRoleArn string `yaml:"OssRoleArn"`
|
||||||
|
}
|
||||||
Minio struct {
|
Minio struct {
|
||||||
Bucket string `yaml:"bucket"`
|
Bucket string `yaml:"bucket"`
|
||||||
Location string `yaml:"location"`
|
Location string `yaml:"location"`
|
||||||
@@ -66,6 +77,7 @@ type config struct {
|
|||||||
DBMaxLifeTime int `yaml:"dbMaxLifeTime"`
|
DBMaxLifeTime int `yaml:"dbMaxLifeTime"`
|
||||||
}
|
}
|
||||||
Mongo struct {
|
Mongo struct {
|
||||||
|
DBUri string `yaml:"dbUri"` // 当dbUri值不为空则直接使用该值
|
||||||
DBAddress []string `yaml:"dbAddress"`
|
DBAddress []string `yaml:"dbAddress"`
|
||||||
DBDirect bool `yaml:"dbDirect"`
|
DBDirect bool `yaml:"dbDirect"`
|
||||||
DBTimeout int `yaml:"dbTimeout"`
|
DBTimeout int `yaml:"dbTimeout"`
|
||||||
@@ -103,6 +115,7 @@ type config struct {
|
|||||||
OpenImAuthName string `yaml:"openImAuthName"`
|
OpenImAuthName string `yaml:"openImAuthName"`
|
||||||
OpenImMessageCMSName string `yaml:"openImMessageCMSName"`
|
OpenImMessageCMSName string `yaml:"openImMessageCMSName"`
|
||||||
OpenImAdminCMSName string `yaml:"openImAdminCMSName"`
|
OpenImAdminCMSName string `yaml:"openImAdminCMSName"`
|
||||||
|
OpenImOfficeName string `yaml:"openImOfficeName"`
|
||||||
}
|
}
|
||||||
Etcd struct {
|
Etcd struct {
|
||||||
EtcdSchema string `yaml:"etcdSchema"`
|
EtcdSchema string `yaml:"etcdSchema"`
|
||||||
@@ -250,6 +263,37 @@ type config struct {
|
|||||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||||
} `yaml:"memberEnter"`
|
} `yaml:"memberEnter"`
|
||||||
|
|
||||||
|
GroupDismissed struct {
|
||||||
|
Conversation PConversation `yaml:"conversation"`
|
||||||
|
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||||
|
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||||
|
} `yaml:"groupDismissed"`
|
||||||
|
|
||||||
|
GroupMuted struct {
|
||||||
|
Conversation PConversation `yaml:"conversation"`
|
||||||
|
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||||
|
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||||
|
} `yaml:"groupMuted"`
|
||||||
|
|
||||||
|
GroupCancelMuted struct {
|
||||||
|
Conversation PConversation `yaml:"conversation"`
|
||||||
|
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||||
|
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||||
|
} `yaml:"groupCancelMuted"`
|
||||||
|
|
||||||
|
GroupMemberMuted struct {
|
||||||
|
Conversation PConversation `yaml:"conversation"`
|
||||||
|
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||||
|
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||||
|
} `yaml:"groupMemberMuted"`
|
||||||
|
|
||||||
|
GroupMemberCancelMuted struct {
|
||||||
|
Conversation PConversation `yaml:"conversation"`
|
||||||
|
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||||
|
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||||
|
} `yaml:"groupMemberCancelMuted"`
|
||||||
|
|
||||||
////////////////////////user///////////////////////
|
////////////////////////user///////////////////////
|
||||||
UserInfoUpdated struct {
|
UserInfoUpdated struct {
|
||||||
Conversation PConversation `yaml:"conversation"`
|
Conversation PConversation `yaml:"conversation"`
|
||||||
@@ -306,6 +350,14 @@ type config struct {
|
|||||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||||
} `yaml:"conversationOptUpdate"`
|
} `yaml:"conversationOptUpdate"`
|
||||||
|
ConversationSetPrivate struct {
|
||||||
|
Conversation PConversation `yaml:"conversation"`
|
||||||
|
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||||
|
DefaultTips struct {
|
||||||
|
OpenTips string `yaml:"openTips"`
|
||||||
|
CloseTips string `yaml:"closeTips"`
|
||||||
|
} `yaml:"defaultTips"`
|
||||||
|
} `yaml:"conversationSetPrivate"`
|
||||||
}
|
}
|
||||||
Demo struct {
|
Demo struct {
|
||||||
Port []int `yaml:"openImDemoPort"`
|
Port []int `yaml:"openImDemoPort"`
|
||||||
|
|||||||
@@ -56,14 +56,13 @@ const (
|
|||||||
FriendRemarkSetNotification = 1206 //set_friend_remark?
|
FriendRemarkSetNotification = 1206 //set_friend_remark?
|
||||||
BlackAddedNotification = 1207 //add_black
|
BlackAddedNotification = 1207 //add_black
|
||||||
BlackDeletedNotification = 1208 //remove_black
|
BlackDeletedNotification = 1208 //remove_black
|
||||||
ConversationOptChangeNotification = 1300 // change conversation opt
|
|
||||||
|
ConversationOptChangeNotification = 1300 // change conversation opt
|
||||||
|
|
||||||
UserNotificationBegin = 1301
|
UserNotificationBegin = 1301
|
||||||
UserInfoUpdatedNotification = 1303 //SetSelfInfoTip = 204
|
UserInfoUpdatedNotification = 1303 //SetSelfInfoTip = 204
|
||||||
ConversationNotification = 1307
|
|
||||||
ConversationNotNotification = 1308
|
|
||||||
ConversationDefault = 0
|
|
||||||
UserNotificationEnd = 1399
|
UserNotificationEnd = 1399
|
||||||
|
OANotification = 1400
|
||||||
|
|
||||||
GroupNotificationBegin = 1500
|
GroupNotificationBegin = 1500
|
||||||
|
|
||||||
@@ -77,11 +76,19 @@ const (
|
|||||||
MemberKickedNotification = 1508
|
MemberKickedNotification = 1508
|
||||||
MemberInvitedNotification = 1509
|
MemberInvitedNotification = 1509
|
||||||
MemberEnterNotification = 1510
|
MemberEnterNotification = 1510
|
||||||
|
GroupDismissedNotification = 1511
|
||||||
|
GroupMemberMutedNotification = 1512
|
||||||
|
GroupMemberCancelMutedNotification = 1513
|
||||||
|
GroupMutedNotification = 1514
|
||||||
|
GroupCancelMutedNotification = 1515
|
||||||
|
|
||||||
SignalingNotificationBegin = 1600
|
SignalingNotificationBegin = 1600
|
||||||
SignalingNotification = 1601
|
SignalingNotification = 1601
|
||||||
SignalingNotificationEnd = 1699
|
SignalingNotificationEnd = 1699
|
||||||
NotificationEnd = 2000
|
|
||||||
|
ConversationPrivateChatNotification = 1701
|
||||||
|
|
||||||
|
NotificationEnd = 2000
|
||||||
|
|
||||||
//status
|
//status
|
||||||
MsgNormal = 1
|
MsgNormal = 1
|
||||||
@@ -94,6 +101,8 @@ const (
|
|||||||
//SessionType
|
//SessionType
|
||||||
SingleChatType = 1
|
SingleChatType = 1
|
||||||
GroupChatType = 2
|
GroupChatType = 2
|
||||||
|
|
||||||
|
NotificationChatType = 4
|
||||||
//token
|
//token
|
||||||
NormalToken = 0
|
NormalToken = 0
|
||||||
InValidToken = 1
|
InValidToken = 1
|
||||||
@@ -121,17 +130,21 @@ const (
|
|||||||
ReceiveNotNotifyMessage = 2
|
ReceiveNotNotifyMessage = 2
|
||||||
|
|
||||||
//OptionsKey
|
//OptionsKey
|
||||||
IsHistory = "history"
|
IsHistory = "history"
|
||||||
IsPersistent = "persistent"
|
IsPersistent = "persistent"
|
||||||
IsOfflinePush = "offlinePush"
|
IsOfflinePush = "offlinePush"
|
||||||
IsUnreadCount = "unreadCount"
|
IsUnreadCount = "unreadCount"
|
||||||
IsConversationUpdate = "conversationUpdate"
|
IsConversationUpdate = "conversationUpdate"
|
||||||
IsSenderSync = "senderSync"
|
IsSenderSync = "senderSync"
|
||||||
|
IsNotPrivate = "notPrivate"
|
||||||
|
IsSenderConversationUpdate = "senderConversationUpdate"
|
||||||
|
|
||||||
//GroupStatus
|
//GroupStatus
|
||||||
GroupOk = 0
|
GroupOk = 0
|
||||||
GroupBanChat = 1
|
GroupBanChat = 1
|
||||||
GroupDisband = 2
|
GroupStatusDismissed = 2
|
||||||
|
GroupStatusMuted = 3
|
||||||
|
|
||||||
GroupBaned = 3
|
GroupBaned = 3
|
||||||
GroupBanPrivateChat = 4
|
GroupBanPrivateChat = 4
|
||||||
|
|
||||||
@@ -159,6 +172,11 @@ const (
|
|||||||
//callback callbackHandleCode
|
//callback callbackHandleCode
|
||||||
CallbackHandleSuccess = 0
|
CallbackHandleSuccess = 0
|
||||||
CallbackHandleFailed = 1
|
CallbackHandleFailed = 1
|
||||||
|
|
||||||
|
// minioUpload
|
||||||
|
OtherType = 1
|
||||||
|
VideoType = 2
|
||||||
|
ImageType = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
var ContentType2PushContent = map[int64]string{
|
var ContentType2PushContent = map[int64]string{
|
||||||
@@ -213,3 +231,5 @@ func GroupIsBanPrivateChat(status int32) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const BigVersion = "v3"
|
const BigVersion = "v3"
|
||||||
|
|
||||||
|
const LogFileName = "OpenIM.log"
|
||||||
|
|||||||
+10
-3
@@ -2,6 +2,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -33,6 +34,7 @@ func key(dbAddress, dbName string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
//var mgoSession *mgo.Session
|
//var mgoSession *mgo.Session
|
||||||
var mongoClient *mongo.Client
|
var mongoClient *mongo.Client
|
||||||
var err1 error
|
var err1 error
|
||||||
@@ -41,9 +43,14 @@ func init() {
|
|||||||
// mongo init
|
// mongo init
|
||||||
// "mongodb://sysop:moon@localhost/records"
|
// "mongodb://sysop:moon@localhost/records"
|
||||||
uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
|
uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
|
||||||
uri = fmt.Sprintf("mongodb://%s/%s/?connect=direct&maxPoolSize=%d",
|
if config.Config.Mongo.DBUri != "" {
|
||||||
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
|
// example: mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$DBMaxPoolSize
|
||||||
config.Config.Mongo.DBMaxPoolSize)
|
uri = config.Config.Mongo.DBUri
|
||||||
|
} else {
|
||||||
|
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
||||||
|
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
|
||||||
|
config.Config.Mongo.DBMaxPoolSize)
|
||||||
|
}
|
||||||
|
|
||||||
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ type GroupMember struct {
|
|||||||
JoinTime time.Time `gorm:"column:join_time"`
|
JoinTime time.Time `gorm:"column:join_time"`
|
||||||
JoinSource int32 `gorm:"column:join_source"`
|
JoinSource int32 `gorm:"column:join_source"`
|
||||||
OperatorUserID string `gorm:"column:operator_user_id;size:64"`
|
OperatorUserID string `gorm:"column:operator_user_id;size:64"`
|
||||||
|
MuteEndTime time.Time `gorm:"column:mute_end_time"`
|
||||||
Ex string `gorm:"column:ex;size:1024"`
|
Ex string `gorm:"column:ex;size:1024"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+148
-4
@@ -11,6 +11,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gogo/protobuf/sortkeys"
|
"github.com/gogo/protobuf/sortkeys"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
//"github.com/garyburd/redigo/redis"
|
//"github.com/garyburd/redigo/redis"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
@@ -22,6 +24,8 @@ import (
|
|||||||
|
|
||||||
const cChat = "msg"
|
const cChat = "msg"
|
||||||
const cGroup = "group"
|
const cGroup = "group"
|
||||||
|
const cTag = "tag"
|
||||||
|
const cSendLog = "send_log"
|
||||||
const singleGocMsgNum = 5000
|
const singleGocMsgNum = 5000
|
||||||
|
|
||||||
type MsgInfo struct {
|
type MsgInfo struct {
|
||||||
@@ -78,9 +82,10 @@ func (d *DataBases) DelMsgLogic(uid string, seqList []uint32, operationID string
|
|||||||
sortkeys.Uint32s(seqList)
|
sortkeys.Uint32s(seqList)
|
||||||
seqMsgs, err := d.GetMsgBySeqListMongo2(uid, seqList, operationID)
|
seqMsgs, err := d.GetMsgBySeqListMongo2(uid, seqList, operationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
for _, seqMsg := range seqMsgs {
|
for _, seqMsg := range seqMsgs {
|
||||||
|
log.NewDebug(operationID, utils.GetSelfFuncName(), *seqMsg)
|
||||||
seqMsg.Status = constant.MsgDeleted
|
seqMsg.Status = constant.MsgDeleted
|
||||||
if err = d.ReplaceMsgBySeq(uid, seqMsg, operationID); err != nil {
|
if err = d.ReplaceMsgBySeq(uid, seqMsg, operationID); err != nil {
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "ReplaceMsgListBySeq error", err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), "ReplaceMsgListBySeq error", err.Error())
|
||||||
@@ -90,20 +95,25 @@ func (d *DataBases) DelMsgLogic(uid string, seqList []uint32, operationID string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) ReplaceMsgBySeq(uid string, msg *open_im_sdk.MsgData, operationID string) error {
|
func (d *DataBases) ReplaceMsgBySeq(uid string, msg *open_im_sdk.MsgData, operationID string) error {
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), uid, msg)
|
log.NewInfo(operationID, utils.GetSelfFuncName(), uid, *msg)
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||||
uid = getSeqUid(uid, msg.Seq)
|
uid = getSeqUid(uid, msg.Seq)
|
||||||
seqIndex := getMsgIndex(msg.Seq)
|
seqIndex := getMsgIndex(msg.Seq)
|
||||||
s := fmt.Sprintf("msg.%d.msg", seqIndex)
|
s := fmt.Sprintf("msg.%d.msg", seqIndex)
|
||||||
log.NewDebug(operationID, utils.GetSelfFuncName(), seqIndex, s)
|
log.NewDebug(operationID, utils.GetSelfFuncName(), seqIndex, s)
|
||||||
|
bytes, err := proto.Marshal(msg)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(operationID, utils.GetSelfFuncName(), "proto marshal", err.Error())
|
||||||
|
return utils.Wrap(err, "")
|
||||||
|
}
|
||||||
updateResult, err := c.UpdateOne(
|
updateResult, err := c.UpdateOne(
|
||||||
ctx, bson.M{"uid": uid},
|
ctx, bson.M{"uid": uid},
|
||||||
bson.M{"$set": bson.M{s: msg}})
|
bson.M{"$set": bson.M{s: bytes}})
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), updateResult)
|
log.NewInfo(operationID, utils.GetSelfFuncName(), updateResult)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "UpdateOne", err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), "UpdateOne", err.Error())
|
||||||
return err
|
return utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -424,9 +434,143 @@ func (d *DataBases) DelGroupMember(groupID, uid string) error {
|
|||||||
//return nil
|
//return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Tag struct {
|
||||||
|
UserID string `bson:"user_id"`
|
||||||
|
TagID string `bson:"tag_id"`
|
||||||
|
TagName string `bson:"tag_name"`
|
||||||
|
UserList []string `bson:"user_list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) GetUserTags(userID string) ([]Tag, error) {
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
||||||
|
var tags []Tag
|
||||||
|
cursor, err := c.Find(ctx, bson.M{"user_id": userID})
|
||||||
|
if err != nil {
|
||||||
|
return tags, err
|
||||||
|
}
|
||||||
|
if err = cursor.All(ctx, &tags); err != nil {
|
||||||
|
return tags, err
|
||||||
|
}
|
||||||
|
return tags, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) CreateTag(userID, tagName string, userList []string) error {
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
||||||
|
tagID := generateTagID(tagName, userID)
|
||||||
|
tag := Tag{
|
||||||
|
UserID: userID,
|
||||||
|
TagID: tagID,
|
||||||
|
TagName: tagName,
|
||||||
|
UserList: userList,
|
||||||
|
}
|
||||||
|
_, err := c.InsertOne(ctx, tag)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) GetTagByID(userID, tagID string) (Tag, error) {
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
||||||
|
var tag Tag
|
||||||
|
err := c.FindOne(ctx, bson.M{"user_id": userID, "tag_id": tagID}).Decode(&tag)
|
||||||
|
return tag, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) DeleteTag(userID, tagID string) error {
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
||||||
|
_, err := c.DeleteOne(ctx, bson.M{"user_id": userID, "tag_id": tagID})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) SetTag(userID, tagID, newName string, increaseUserIDList []string, reduceUserIDList []string) error {
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
||||||
|
var tag Tag
|
||||||
|
if err := c.FindOne(ctx, bson.M{"tag_id": tagID, "user_id": userID}).Decode(&tag); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if newName != "" {
|
||||||
|
_, err := c.UpdateOne(ctx, bson.M{"user_id": userID, "tag_id": tagID}, bson.M{"$set": bson.M{"tag_name": newName}})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tag.UserList = append(tag.UserList, increaseUserIDList...)
|
||||||
|
tag.UserList = utils.RemoveRepeatedStringInList(tag.UserList)
|
||||||
|
for _, v := range reduceUserIDList {
|
||||||
|
for i2, v2 := range tag.UserList {
|
||||||
|
if v == v2 {
|
||||||
|
tag.UserList[i2] = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var newUserList []string
|
||||||
|
for _, v := range tag.UserList {
|
||||||
|
if v != "" {
|
||||||
|
newUserList = append(newUserList, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := c.UpdateOne(ctx, bson.M{"user_id": userID, "tag_id": tagID}, bson.M{"$set": bson.M{"user_list": newUserList}})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) GetUserIDListByTagID(userID, tagID string) ([]string, error) {
|
||||||
|
var tag Tag
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
||||||
|
_ = c.FindOne(ctx, bson.M{"user_id": userID, "tag_id": tagID}).Decode(&tag)
|
||||||
|
return tag.UserList, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type TagUser struct {
|
||||||
|
UserID string `bson:"user_id"`
|
||||||
|
UserName string `bson:"user_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TagSendLog struct {
|
||||||
|
UserList []TagUser `bson:"tag_list"`
|
||||||
|
SendID string `bson:"send_id"`
|
||||||
|
SenderPlatformID int32 `bson:"sender_platform_id"`
|
||||||
|
Content string `bson:"content"`
|
||||||
|
SendTime int64 `bson:"send_time"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) SaveTagSendLog(tagSendLog *TagSendLog) error {
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSendLog)
|
||||||
|
_, err := c.InsertOne(ctx, tagSendLog)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) GetTagSendLogs(userID string, showNumber, pageNumber int32) ([]TagSendLog, error) {
|
||||||
|
var tagSendLogs []TagSendLog
|
||||||
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSendLog)
|
||||||
|
findOpts := options.Find().SetLimit(int64(showNumber)).SetSkip(int64(showNumber) * (int64(pageNumber) - 1)).SetSort(bson.M{"send_time": -1})
|
||||||
|
cursor, err := c.Find(ctx, bson.M{"send_id": userID}, findOpts)
|
||||||
|
if err != nil {
|
||||||
|
return tagSendLogs, err
|
||||||
|
}
|
||||||
|
err = cursor.All(ctx, &tagSendLogs)
|
||||||
|
if err != nil {
|
||||||
|
return tagSendLogs, err
|
||||||
|
}
|
||||||
|
return tagSendLogs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateTagID(tagName, userID string) string {
|
||||||
|
return utils.Md5(tagName + userID + strconv.Itoa(rand.Int()) + time.Now().String())
|
||||||
|
}
|
||||||
|
|
||||||
func getCurrentTimestampByMill() int64 {
|
func getCurrentTimestampByMill() int64 {
|
||||||
return time.Now().UnixNano() / 1e6
|
return time.Now().UnixNano() / 1e6
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSeqUid(uid string, seq uint32) string {
|
func getSeqUid(uid string, seq uint32) string {
|
||||||
seqSuffix := seq / singleGocMsgNum
|
seqSuffix := seq / singleGocMsgNum
|
||||||
return indexGen(uid, seqSuffix)
|
return indexGen(uid, seqSuffix)
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ func InsertIntoGroupMember(toInsertInfo db.GroupMember) error {
|
|||||||
if toInsertInfo.RoleLevel == 0 {
|
if toInsertInfo.RoleLevel == 0 {
|
||||||
toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers
|
toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers
|
||||||
}
|
}
|
||||||
|
toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0)
|
||||||
err = dbConn.Table("group_members").Create(toInsertInfo).Error
|
err = dbConn.Table("group_members").Create(toInsertInfo).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -65,6 +66,24 @@ func GetGroupMemberListByGroupID(groupID string) ([]db.GroupMember, error) {
|
|||||||
return groupMemberList, nil
|
return groupMemberList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetGroupMemberIDListByGroupID(groupID string) ([]string, error) {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dbConn.LogMode(true)
|
||||||
|
var groupMembers []db.GroupMember
|
||||||
|
err = dbConn.Table("group_members").Select("user_id").Where("group_id=?", groupID).Find(&groupMembers).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var groupMemberIDList []string
|
||||||
|
for _, v := range groupMembers {
|
||||||
|
groupMemberIDList = append(groupMemberIDList, v.UserID)
|
||||||
|
}
|
||||||
|
return groupMemberIDList, nil
|
||||||
|
}
|
||||||
|
|
||||||
func GetGroupMemberListByGroupIDAndRoleLevel(groupID string, roleLevel int32) ([]db.GroupMember, error) {
|
func GetGroupMemberListByGroupIDAndRoleLevel(groupID string, roleLevel int32) ([]db.GroupMember, error) {
|
||||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -103,6 +122,18 @@ func DeleteGroupMemberByGroupIDAndUserID(groupID, userID string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeleteGroupMemberByGroupID(groupID string) error {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = dbConn.Table("group_members").Where("group_id=? ", groupID).Delete(db.GroupMember{}).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func UpdateGroupMemberInfo(groupMemberInfo db.GroupMember) error {
|
func UpdateGroupMemberInfo(groupMemberInfo db.GroupMember) error {
|
||||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -255,6 +286,14 @@ func GetGroupMembersCount(groupId, userName string) (int32, error) {
|
|||||||
return count, nil
|
return count, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdateGroupMemberInfoDefaultZero(groupMemberInfo db.GroupMember, args map[string]interface{}) error {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return dbConn.Model(groupMemberInfo).Updates(args).Error
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//func SelectGroupList(groupID string) ([]string, error) {
|
//func SelectGroupList(groupID string) ([]string, error) {
|
||||||
// var groupUserID string
|
// var groupUserID string
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ func SetGroupInfo(groupInfo db.Group) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dbConn.LogMode(true)
|
|
||||||
err = dbConn.Table("groups").Where("group_id=?", groupInfo.GroupID).Update(&groupInfo).Error
|
err = dbConn.Table("groups").Where("group_id=?", groupInfo.GroupID).Update(&groupInfo).Error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -68,7 +67,7 @@ func GetGroupsByName(groupName string, pageNumber, showNumber int32) ([]db.Group
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return groups, err
|
return groups, err
|
||||||
}
|
}
|
||||||
dbConn.LogMode(true)
|
|
||||||
err = dbConn.Table("groups").Where(fmt.Sprintf(" name like '%%%s%%' ", groupName)).Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&groups).Error
|
err = dbConn.Table("groups").Where(fmt.Sprintf(" name like '%%%s%%' ", groupName)).Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&groups).Error
|
||||||
return groups, err
|
return groups, err
|
||||||
}
|
}
|
||||||
@@ -79,7 +78,7 @@ func GetGroups(pageNumber, showNumber int) ([]db.Group, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return groups, err
|
return groups, err
|
||||||
}
|
}
|
||||||
dbConn.LogMode(true)
|
|
||||||
if err = dbConn.Table("groups").Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&groups).Error; err != nil {
|
if err = dbConn.Table("groups").Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&groups).Error; err != nil {
|
||||||
return groups, err
|
return groups, err
|
||||||
}
|
}
|
||||||
@@ -102,7 +101,7 @@ func DeleteGroup(groupId string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dbConn.LogMode(true)
|
|
||||||
var group db.Group
|
var group db.Group
|
||||||
var groupMembers []db.GroupMember
|
var groupMembers []db.GroupMember
|
||||||
if err := dbConn.Table("groups").Where("group_id=?", groupId).Delete(&group).Error; err != nil {
|
if err := dbConn.Table("groups").Where("group_id=?", groupId).Delete(&group).Error; err != nil {
|
||||||
@@ -119,7 +118,6 @@ func OperateGroupRole(userId, groupId string, roleLevel int32) (string, string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
dbConn.LogMode(true)
|
|
||||||
groupMember := db.GroupMember{
|
groupMember := db.GroupMember{
|
||||||
UserID: userId,
|
UserID: userId,
|
||||||
GroupID: groupId,
|
GroupID: groupId,
|
||||||
@@ -182,7 +180,7 @@ func GetGroupsCountNum(group db.Group) (int32, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
dbConn.LogMode(true)
|
|
||||||
var count int32
|
var count int32
|
||||||
if err := dbConn.Table("groups").Where(fmt.Sprintf(" name like '%%%s%%' ", group.GroupName)).Count(&count).Error; err != nil {
|
if err := dbConn.Table("groups").Where(fmt.Sprintf(" name like '%%%s%%' ", group.GroupName)).Count(&count).Error; err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -198,7 +196,7 @@ func GetGroupById(groupId string) (db.Group, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return group, err
|
return group, err
|
||||||
}
|
}
|
||||||
dbConn.LogMode(true)
|
|
||||||
if err := dbConn.Table("groups").Find(&group).Error; err != nil {
|
if err := dbConn.Table("groups").Find(&group).Error; err != nil {
|
||||||
return group, err
|
return group, err
|
||||||
}
|
}
|
||||||
@@ -211,9 +209,17 @@ func GetGroupMaster(groupId string) (db.GroupMember, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return groupMember, err
|
return groupMember, err
|
||||||
}
|
}
|
||||||
dbConn.LogMode(true)
|
|
||||||
if err := dbConn.Table("group_members").Where("role_level=? and group_id=?", constant.GroupOwner, groupId).Find(&groupMember).Error; err != nil {
|
if err := dbConn.Table("group_members").Where("role_level=? and group_id=?", constant.GroupOwner, groupId).Find(&groupMember).Error; err != nil {
|
||||||
return groupMember, err
|
return groupMember, err
|
||||||
}
|
}
|
||||||
return groupMember, nil
|
return groupMember, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdateGroupInfoDefaultZero(groupID string, args map[string]interface{}) error {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return dbConn.Table("groups").Where("group_id = ? ", groupID).Update(args).Error
|
||||||
|
}
|
||||||
|
|||||||
@@ -74,6 +74,19 @@ func GetUserByUserID(userID string) (*db.User, error) {
|
|||||||
return &user, nil
|
return &user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserNameByUserID(userID string) (string, error) {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
var user db.User
|
||||||
|
err = dbConn.Table("users").Select("name").Where("user_id=?", userID).First(&user).Error
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return user.Nickname, nil
|
||||||
|
}
|
||||||
|
|
||||||
func UpdateUserInfo(user db.User) error {
|
func UpdateUserInfo(user db.User) error {
|
||||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -312,6 +325,25 @@ func SetConversation(conversation db.Conversation) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PeerUserSetConversation(conversation db.Conversation) error {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
dbConn.LogMode(true)
|
||||||
|
newConversation := conversation
|
||||||
|
if dbConn.Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 {
|
||||||
|
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create")
|
||||||
|
return dbConn.Model(&db.Conversation{}).Create(conversation).Error
|
||||||
|
// if exist, then update record
|
||||||
|
}
|
||||||
|
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update")
|
||||||
|
//force update
|
||||||
|
return dbConn.Model(conversation).Where("owner_user_id = ? and conversation_id = ?", conversation.OwnerUserID, conversation.ConversationID).
|
||||||
|
Update(map[string]interface{}{"is_private_chat": conversation.IsPrivateChat}).Error
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func SetRecvMsgOpt(conversation db.Conversation) error {
|
func SetRecvMsgOpt(conversation db.Conversation) error {
|
||||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ func loggerInit(moduleName string) *Logger {
|
|||||||
}
|
}
|
||||||
func NewLfsHook(rotationTime time.Duration, maxRemainNum uint, moduleName string) logrus.Hook {
|
func NewLfsHook(rotationTime time.Duration, maxRemainNum uint, moduleName string) logrus.Hook {
|
||||||
lfsHook := lfshook.NewHook(lfshook.WriterMap{
|
lfsHook := lfshook.NewHook(lfshook.WriterMap{
|
||||||
logrus.DebugLevel: initRotateLogs(rotationTime, maxRemainNum, "debug", moduleName),
|
logrus.DebugLevel: initRotateLogs(rotationTime, maxRemainNum, "all", moduleName),
|
||||||
logrus.InfoLevel: initRotateLogs(rotationTime, maxRemainNum, "info", moduleName),
|
logrus.InfoLevel: initRotateLogs(rotationTime, maxRemainNum, "all", moduleName),
|
||||||
logrus.WarnLevel: initRotateLogs(rotationTime, maxRemainNum, "warn", moduleName),
|
logrus.WarnLevel: initRotateLogs(rotationTime, maxRemainNum, "all", moduleName),
|
||||||
logrus.ErrorLevel: initRotateLogs(rotationTime, maxRemainNum, "error", moduleName),
|
logrus.ErrorLevel: initRotateLogs(rotationTime, maxRemainNum, "all", moduleName),
|
||||||
}, &nested.Formatter{
|
}, &nested.Formatter{
|
||||||
TimestampFormat: "2006-01-02 15:04:05.000",
|
TimestampFormat: "2006-01-02 15:04:05.000",
|
||||||
HideKeys: false,
|
HideKeys: false,
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ func GetClaimFromToken(tokensString string) (*Claims, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsAppManagerAccess(token string, OpUserID string) bool {
|
func IsAppManagerAccess(token string, OpUserID string) bool {
|
||||||
claims, err := ParseToken(token)
|
claims, err := ParseToken(token, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ func CheckAccess(OpUserID string, OwnerUserID string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetUserIDFromToken(token string, operationID string) (bool, string) {
|
func GetUserIDFromToken(token string, operationID string) (bool, string) {
|
||||||
claims, err := ParseToken(token)
|
claims, err := ParseToken(token, operationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
|
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
|
||||||
return false, ""
|
return false, ""
|
||||||
@@ -138,31 +138,31 @@ func GetUserIDFromToken(token string, operationID string) (bool, string) {
|
|||||||
return true, claims.UID
|
return true, claims.UID
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseToken(tokensString string) (claims *Claims, err error) {
|
func ParseToken(tokensString, operationID string) (claims *Claims, err error) {
|
||||||
|
|
||||||
claims, err = GetClaimFromToken(tokensString)
|
claims, err = GetClaimFromToken(tokensString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("", "token validate err", err.Error())
|
log.NewError(operationID, "token validate err", err.Error(), tokensString)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
m, err := commonDB.DB.GetTokenMapByUidPid(claims.UID, claims.Platform)
|
m, err := commonDB.DB.GetTokenMapByUidPid(claims.UID, claims.Platform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("", "get token from redis err", err.Error())
|
log.NewError(operationID, "get token from redis err", err.Error(), tokensString)
|
||||||
return nil, &constant.ErrTokenInvalid
|
return nil, &constant.ErrTokenInvalid
|
||||||
}
|
}
|
||||||
if m == nil {
|
if m == nil {
|
||||||
log.NewError("", "get token from redis err", "m is nil")
|
log.NewError(operationID, "get token from redis err", "m is nil", tokensString)
|
||||||
return nil, &constant.ErrTokenInvalid
|
return nil, &constant.ErrTokenInvalid
|
||||||
}
|
}
|
||||||
if v, ok := m[tokensString]; ok {
|
if v, ok := m[tokensString]; ok {
|
||||||
switch v {
|
switch v {
|
||||||
case constant.NormalToken:
|
case constant.NormalToken:
|
||||||
log.NewDebug("", "this is normal return", claims)
|
log.NewDebug(operationID, "this is normal return", claims)
|
||||||
return claims, nil
|
return claims, nil
|
||||||
case constant.InValidToken:
|
case constant.InValidToken:
|
||||||
return nil, &constant.ErrTokenInvalid
|
return nil, &constant.ErrTokenInvalid
|
||||||
case constant.KickedToken:
|
case constant.KickedToken:
|
||||||
|
log.Error(operationID, "this token has been kicked by other same terminal ", constant.ErrTokenKicked)
|
||||||
return nil, &constant.ErrTokenKicked
|
return nil, &constant.ErrTokenKicked
|
||||||
case constant.ExpiredToken:
|
case constant.ExpiredToken:
|
||||||
return nil, &constant.ErrTokenExpired
|
return nil, &constant.ErrTokenExpired
|
||||||
@@ -170,6 +170,7 @@ func ParseToken(tokensString string) (claims *Claims, err error) {
|
|||||||
return nil, &constant.ErrTokenUnknown
|
return nil, &constant.ErrTokenUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.NewError(operationID, "redis token map not find", constant.ErrTokenUnknown)
|
||||||
return nil, &constant.ErrTokenUnknown
|
return nil, &constant.ErrTokenUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +196,7 @@ func ParseRedisInterfaceToken(redisToken interface{}) (*Claims, error) {
|
|||||||
|
|
||||||
//Validation token, false means failure, true means successful verification
|
//Validation token, false means failure, true means successful verification
|
||||||
func VerifyToken(token, uid string) (bool, error) {
|
func VerifyToken(token, uid string) (bool, error) {
|
||||||
claims, err := ParseToken(token)
|
claims, err := ParseToken(token, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -207,7 +208,7 @@ func VerifyToken(token, uid string) (bool, error) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
func WsVerifyToken(token, uid string, platformID string) (bool, error, string) {
|
func WsVerifyToken(token, uid string, platformID string) (bool, error, string) {
|
||||||
claims, err := ParseToken(token)
|
claims, err := ParseToken(token, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err, "parse token err"
|
return false, err, "parse token err"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,14 @@ func GroupMemberDBCopyOpenIM(dst *open_im_sdk.GroupMemberFullInfo, src *db.Group
|
|||||||
dst.AppMangerLevel = 1
|
dst.AppMangerLevel = 1
|
||||||
}
|
}
|
||||||
dst.JoinTime = int32(src.JoinTime.Unix())
|
dst.JoinTime = int32(src.JoinTime.Unix())
|
||||||
|
if src.MuteEndTime.Unix() < 0 {
|
||||||
|
dst.JoinTime = 0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
dst.MuteEndTime = uint32(src.MuteEndTime.Unix())
|
||||||
|
if dst.MuteEndTime < uint32(time.Now().Unix()) {
|
||||||
|
dst.MuteEndTime = 0
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2755
-3811
File diff suppressed because it is too large
Load Diff
@@ -318,6 +318,68 @@ message AddGroupMembersCMSResp {
|
|||||||
repeated string failed = 2;
|
repeated string failed = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message DismissGroupReq{
|
||||||
|
string opUserID = 1; //group or app manager
|
||||||
|
string operationID = 2;
|
||||||
|
string groupID = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DismissGroupResp{
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message MuteGroupMemberReq{
|
||||||
|
string opUserID = 1; //group or app manager
|
||||||
|
string operationID = 2;
|
||||||
|
string groupID = 3;
|
||||||
|
string userID = 4;
|
||||||
|
uint32 mutedSeconds = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MuteGroupMemberResp{
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
message CancelMuteGroupMemberReq{
|
||||||
|
string opUserID = 1; //group or app manager
|
||||||
|
string operationID = 2;
|
||||||
|
string groupID = 3;
|
||||||
|
string userID = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CancelMuteGroupMemberResp{
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message MuteGroupReq{
|
||||||
|
string opUserID = 1; //group or app manager
|
||||||
|
string operationID = 2;
|
||||||
|
string groupID = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MuteGroupResp{
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
message CancelMuteGroupReq{
|
||||||
|
string opUserID = 1; //group or app manager
|
||||||
|
string operationID = 2;
|
||||||
|
string groupID = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CancelMuteGroupResp{
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
service group{
|
service group{
|
||||||
rpc createGroup(CreateGroupReq) returns(CreateGroupResp);
|
rpc createGroup(CreateGroupReq) returns(CreateGroupResp);
|
||||||
@@ -345,6 +407,12 @@ service group{
|
|||||||
rpc GetGroupMembersCMS(GetGroupMembersCMSReq) returns(GetGroupMembersCMSResp);
|
rpc GetGroupMembersCMS(GetGroupMembersCMSReq) returns(GetGroupMembersCMSResp);
|
||||||
rpc RemoveGroupMembersCMS(RemoveGroupMembersCMSReq) returns(RemoveGroupMembersCMSResp);
|
rpc RemoveGroupMembersCMS(RemoveGroupMembersCMSReq) returns(RemoveGroupMembersCMSResp);
|
||||||
rpc AddGroupMembersCMS(AddGroupMembersCMSReq) returns(AddGroupMembersCMSResp);
|
rpc AddGroupMembersCMS(AddGroupMembersCMSReq) returns(AddGroupMembersCMSResp);
|
||||||
|
|
||||||
|
rpc DismissGroup(DismissGroupReq) returns(DismissGroupResp);
|
||||||
|
rpc MuteGroupMember(MuteGroupMemberReq) returns(MuteGroupMemberResp);
|
||||||
|
rpc CancelMuteGroupMember(CancelMuteGroupMemberReq) returns(CancelMuteGroupMemberResp);
|
||||||
|
rpc MuteGroup(MuteGroupReq) returns(MuteGroupResp);
|
||||||
|
rpc CancelMuteGroup(CancelMuteGroupReq) returns(CancelMuteGroupResp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,118 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
import "Open_IM/pkg/proto/sdk_ws/ws.proto";
|
||||||
|
option go_package = "./office;office";
|
||||||
|
package office;
|
||||||
|
|
||||||
|
message CommonResp{
|
||||||
|
int32 errCode = 1;
|
||||||
|
string errMsg = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TagUser {
|
||||||
|
string userID = 1;
|
||||||
|
string userName = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Tag {
|
||||||
|
string tagID = 1;
|
||||||
|
string tagName = 2;
|
||||||
|
repeated TagUser userList = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserTagsReq{
|
||||||
|
string userID = 1;
|
||||||
|
string operationID = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserTagsResp{
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
repeated Tag tags = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CreateTagReq {
|
||||||
|
string tagName = 1;
|
||||||
|
string userID = 2;
|
||||||
|
repeated string userIDList = 3;
|
||||||
|
string operationID = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CreateTagResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteTagReq {
|
||||||
|
string userID = 1;
|
||||||
|
string tagID = 2;
|
||||||
|
string operationID = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteTagResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SetTagReq {
|
||||||
|
string userID = 1;
|
||||||
|
string tagID = 2;
|
||||||
|
string newName = 3;
|
||||||
|
repeated string increaseUserIDList = 4;
|
||||||
|
repeated string reduceUserIDList = 5;
|
||||||
|
string operationID = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SetTagResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SendMsg2TagReq {
|
||||||
|
repeated string tagList = 1;
|
||||||
|
repeated string UserList = 2;
|
||||||
|
repeated string GroupList = 3;
|
||||||
|
string sendID = 4;
|
||||||
|
int32 senderPlatformID = 5;
|
||||||
|
string content = 6;
|
||||||
|
string operationID = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SendMsg2TagResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTagSendLogsReq {
|
||||||
|
server_api_params.RequestPagination Pagination = 1;
|
||||||
|
string userID = 2;
|
||||||
|
string operationID = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TagSendLog {
|
||||||
|
repeated TagUser userList = 1;
|
||||||
|
string content = 2;
|
||||||
|
int64 sendTime = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTagSendLogsResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
server_api_params.ResponsePagination Pagination = 2;
|
||||||
|
repeated TagSendLog tagSendLogs = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserTagByIDReq {
|
||||||
|
string userID = 1;
|
||||||
|
string tagID = 2;
|
||||||
|
string operationID = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserTagByIDResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
Tag tag = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
service OfficeService {
|
||||||
|
rpc GetUserTags(GetUserTagsReq) returns(GetUserTagsResp);
|
||||||
|
rpc CreateTag(CreateTagReq) returns(CreateTagResp);
|
||||||
|
rpc DeleteTag(DeleteTagReq) returns(DeleteTagResp);
|
||||||
|
rpc SetTag(SetTagReq) returns(SetTagResp);
|
||||||
|
rpc SendMsg2Tag(SendMsg2TagReq) returns(SendMsg2TagResp);
|
||||||
|
rpc GetTagSendLogs(GetTagSendLogsReq) returns(GetTagSendLogsResp);
|
||||||
|
rpc GetUserTagByID(GetUserTagByIDReq) returns(GetUserTagByIDResp);
|
||||||
|
}
|
||||||
|
|
||||||
+593
-222
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ message GroupMemberFullInfo {
|
|||||||
int32 joinSource = 8;
|
int32 joinSource = 8;
|
||||||
string operatorUserID = 9;
|
string operatorUserID = 9;
|
||||||
string ex = 10;
|
string ex = 10;
|
||||||
|
uint32 muteEndTime = 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PublicUserInfo{
|
message PublicUserInfo{
|
||||||
@@ -254,6 +255,39 @@ message MemberEnterTips{
|
|||||||
int64 operationTime = 3;
|
int64 operationTime = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GroupDismissedTips{
|
||||||
|
GroupInfo group = 1;
|
||||||
|
GroupMemberFullInfo opUser = 2;
|
||||||
|
int64 operationTime = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GroupMemberMutedTips{
|
||||||
|
GroupInfo group = 1;
|
||||||
|
GroupMemberFullInfo opUser = 2;
|
||||||
|
int64 operationTime = 3;
|
||||||
|
GroupMemberFullInfo mutedUser = 4;
|
||||||
|
uint32 mutedSeconds = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GroupMemberCancelMutedTips{
|
||||||
|
GroupInfo group = 1;
|
||||||
|
GroupMemberFullInfo opUser = 2;
|
||||||
|
int64 operationTime = 3;
|
||||||
|
GroupMemberFullInfo mutedUser = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GroupMutedTips{
|
||||||
|
GroupInfo group = 1;
|
||||||
|
GroupMemberFullInfo opUser = 2;
|
||||||
|
int64 operationTime = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GroupCancelMutedTips{
|
||||||
|
GroupInfo group = 1;
|
||||||
|
GroupMemberFullInfo opUser = 2;
|
||||||
|
int64 operationTime = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////friend/////////////////////
|
//////////////////////friend/////////////////////
|
||||||
//message FriendInfo{
|
//message FriendInfo{
|
||||||
@@ -326,7 +360,12 @@ message UserInfoUpdatedTips{
|
|||||||
//////////////////////conversation/////////////////////
|
//////////////////////conversation/////////////////////
|
||||||
message ConversationUpdateTips{
|
message ConversationUpdateTips{
|
||||||
string UserID = 1;
|
string UserID = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ConversationSetPrivateTips{
|
||||||
|
string recvID = 1;
|
||||||
|
string sendID = 2;
|
||||||
|
bool isPrivate = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2633
-4197
File diff suppressed because it is too large
Load Diff
@@ -84,7 +84,8 @@ message Conversation{
|
|||||||
|
|
||||||
message SetConversationReq{
|
message SetConversationReq{
|
||||||
Conversation Conversation = 1;
|
Conversation Conversation = 1;
|
||||||
string OperationID = 2;
|
int32 notificationType = 2;
|
||||||
|
string OperationID = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SetConversationResp{
|
message SetConversationResp{
|
||||||
@@ -95,7 +96,8 @@ message SetRecvMsgOptReq {
|
|||||||
string OwnerUserID = 1;
|
string OwnerUserID = 1;
|
||||||
string ConversationID = 2;
|
string ConversationID = 2;
|
||||||
int32 RecvMsgOpt = 3;
|
int32 RecvMsgOpt = 3;
|
||||||
string OperationID = 4;
|
int32 notificationType = 4;
|
||||||
|
string OperationID = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SetRecvMsgOptResp {
|
message SetRecvMsgOptResp {
|
||||||
@@ -137,7 +139,8 @@ message GetAllConversationsResp{
|
|||||||
message BatchSetConversationsReq{
|
message BatchSetConversationsReq{
|
||||||
repeated Conversation Conversations = 1;
|
repeated Conversation Conversations = 1;
|
||||||
string OwnerUserID = 2;
|
string OwnerUserID = 2;
|
||||||
string OperationID = 3;
|
int32 notificationType = 3;
|
||||||
|
string OperationID = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message BatchSetConversationsResp{
|
message BatchSetConversationsResp{
|
||||||
|
|||||||
+18
-1
@@ -1,6 +1,13 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import "os"
|
import (
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
// Determine whether the given path is a folder
|
// Determine whether the given path is a folder
|
||||||
func IsDir(path string) bool {
|
func IsDir(path string) bool {
|
||||||
@@ -20,3 +27,13 @@ func IsFile(path string) bool {
|
|||||||
func MkDir(path string) error {
|
func MkDir(path string) error {
|
||||||
return os.MkdirAll(path, os.ModePerm)
|
return os.MkdirAll(path, os.ModePerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetNewFileNameAndContentType(fileName string, fileType int) (string, string) {
|
||||||
|
suffix := path.Ext(fileName)
|
||||||
|
newName := fmt.Sprintf("%d-%d%s", time.Now().UnixNano(), rand.Int(), fileName)
|
||||||
|
contentType := ""
|
||||||
|
if fileType == constant.ImageType {
|
||||||
|
contentType = "image/" + suffix[1:]
|
||||||
|
}
|
||||||
|
return newName, contentType
|
||||||
|
}
|
||||||
|
|||||||
@@ -76,3 +76,16 @@ func Difference(slice1, slice2 []uint32) []uint32 {
|
|||||||
func OperationIDGenerator() string {
|
func OperationIDGenerator() string {
|
||||||
return strconv.FormatInt(time.Now().UnixNano()+int64(rand.Uint32()), 10)
|
return strconv.FormatInt(time.Now().UnixNano()+int64(rand.Uint32()), 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RemoveRepeatedStringInList(slc []string) []string {
|
||||||
|
var result []string
|
||||||
|
tempMap := map[string]byte{}
|
||||||
|
for _, e := range slc {
|
||||||
|
l := len(tempMap)
|
||||||
|
tempMap[e] = 0
|
||||||
|
if len(tempMap) != l {
|
||||||
|
result = append(result, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ service_port_name=(
|
|||||||
openImAdminCmsPort
|
openImAdminCmsPort
|
||||||
openImMessageCmsPort
|
openImMessageCmsPort
|
||||||
openImStatisticsPort
|
openImStatisticsPort
|
||||||
|
openImOfficePort
|
||||||
)
|
)
|
||||||
switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}')
|
switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}')
|
||||||
for i in ${service_port_name[*]}; do
|
for i in ${service_port_name[*]}; do
|
||||||
|
|||||||
@@ -8,3 +8,4 @@ sleep 30
|
|||||||
echo "check OpenIM................................"
|
echo "check OpenIM................................"
|
||||||
./check_all.sh
|
./check_all.sh
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,4 +17,3 @@ if [ $available -lt 2000 ] ; then
|
|||||||
else
|
else
|
||||||
echo -e ${GREEN_PREFIX} "Memory is ok, available is: "$available"m${COLOR_SUFFIX}"
|
echo -e ${GREEN_PREFIX} "Memory is ok, available is: "$available"m${COLOR_SUFFIX}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -9,3 +9,7 @@ sub_s3=${sub_s2#*[}
|
|||||||
sub_s4=${sub_s3%]*}
|
sub_s4=${sub_s3%]*}
|
||||||
ports_array=$sub_s4
|
ports_array=$sub_s4
|
||||||
}
|
}
|
||||||
|
remove_space(){
|
||||||
|
value=$*
|
||||||
|
result=`echo $value | sed 's/ //g'`
|
||||||
|
}
|
||||||
@@ -48,6 +48,7 @@ service_source_root=(
|
|||||||
../cmd/rpc/open_im_admin_cms/
|
../cmd/rpc/open_im_admin_cms/
|
||||||
../cmd/rpc/open_im_message_cms/
|
../cmd/rpc/open_im_message_cms/
|
||||||
../cmd/rpc/open_im_statistics/
|
../cmd/rpc/open_im_statistics/
|
||||||
|
../cmd/rpc/open_im_office/
|
||||||
${msg_gateway_source_root}
|
${msg_gateway_source_root}
|
||||||
${msg_transfer_source_root}
|
${msg_transfer_source_root}
|
||||||
${msg_source_root}
|
${msg_source_root}
|
||||||
@@ -68,6 +69,7 @@ service_names=(
|
|||||||
open_im_admin_cms
|
open_im_admin_cms
|
||||||
open_im_message_cms
|
open_im_message_cms
|
||||||
open_im_statistics
|
open_im_statistics
|
||||||
|
open_im_office
|
||||||
${msg_gateway_name}
|
${msg_gateway_name}
|
||||||
${msg_transfer_name}
|
${msg_transfer_name}
|
||||||
${msg_name}
|
${msg_name}
|
||||||
@@ -78,4 +80,3 @@ service_names=(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,3 @@ for i in ${need_to_start_server_shell[*]}; do
|
|||||||
chmod +x $i
|
chmod +x $i
|
||||||
./$i
|
./$i
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ service_filename=(
|
|||||||
open_im_message_cms
|
open_im_message_cms
|
||||||
open_im_statistics
|
open_im_statistics
|
||||||
${msg_name}
|
${msg_name}
|
||||||
|
open_im_office
|
||||||
)
|
)
|
||||||
|
|
||||||
#service config port name
|
#service config port name
|
||||||
@@ -34,6 +35,7 @@ service_port_name=(
|
|||||||
openImMessageCmsPort
|
openImMessageCmsPort
|
||||||
openImStatisticsPort
|
openImStatisticsPort
|
||||||
openImOfflineMessagePort
|
openImOfflineMessagePort
|
||||||
|
openImOfficePort
|
||||||
)
|
)
|
||||||
|
|
||||||
for ((i = 0; i < ${#service_filename[*]}; i++)); do
|
for ((i = 0; i < ${#service_filename[*]}; i++)); do
|
||||||
|
|||||||
Reference in New Issue
Block a user