mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-10 04:59:49 +08:00
Merge branch 'tuoyun'
This commit is contained in:
commit
9a1620d51f
@ -1 +1 @@
|
|||||||
Subproject commit 855e893610c905e3105484c3519613b993301bd2
|
Subproject commit 992f76df0ee500a0377523b0780d3a85f2275755
|
@ -4,44 +4,44 @@
|
|||||||
serverversion: 2.0.0
|
serverversion: 2.0.0
|
||||||
#---------------Infrastructure configuration---------------------#
|
#---------------Infrastructure configuration---------------------#
|
||||||
etcd:
|
etcd:
|
||||||
etcdSchema: openIM
|
etcdSchema: openIM #默认即可
|
||||||
etcdAddr: [ 127.0.0.1:2379 ]
|
etcdAddr: [ 127.0.0.1:2379 ] #单机部署时,默认即可
|
||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
dbMysqlAddress: [ 127.0.0.1:13306 ]
|
dbMysqlAddress: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可
|
||||||
dbMysqlUserName: root
|
dbMysqlUserName: root #mysql用户名,建议修改
|
||||||
dbMysqlPassword: openIM
|
dbMysqlPassword: openIM # mysql密码,建议修改
|
||||||
dbMysqlDatabaseName: openIM_v2
|
dbMysqlDatabaseName: openIM_v2 #默认即可
|
||||||
dbTableName: eMsg
|
dbTableName: eMsg #默认即可
|
||||||
dbMsgTableNum: 1
|
dbMsgTableNum: 1
|
||||||
dbMaxOpenConns: 20
|
dbMaxOpenConns: 20
|
||||||
dbMaxIdleConns: 10
|
dbMaxIdleConns: 10
|
||||||
dbMaxLifeTime: 120
|
dbMaxLifeTime: 120
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
dbAddress: [ 127.0.0.1:37017 ]
|
dbAddress: [ 127.0.0.1:37017 ] #redis地址 目前仅支持单机,默认即可
|
||||||
dbDirect: false
|
dbDirect: false
|
||||||
dbTimeout: 10
|
dbTimeout: 10
|
||||||
dbDatabase: openIM
|
dbDatabase: openIM #mongo db 默认即可
|
||||||
dbSource: admin
|
dbSource: admin
|
||||||
dbUserName:
|
dbUserName: #mongo用户名,建议先不设置
|
||||||
dbPassword:
|
dbPassword: #mongo密码,建议先不设置
|
||||||
dbMaxPoolSize: 20
|
dbMaxPoolSize: 20
|
||||||
dbRetainChatRecords: 7
|
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
dbAddress: 127.0.0.1:16379
|
dbAddress: 127.0.0.1:16379 #redis地址 目前仅支持单机,默认即可
|
||||||
dbMaxIdle: 128
|
dbMaxIdle: 128
|
||||||
dbMaxActive: 0
|
dbMaxActive: 0
|
||||||
dbIdleTimeout: 120
|
dbIdleTimeout: 120
|
||||||
dbPassWord: openIM
|
dbPassWord: openIM #redis密码 建议修改
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
ws2mschat:
|
ws2mschat:
|
||||||
addr: [ 127.0.0.1:9092 ]
|
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||||
topic: "ws2ms_chat"
|
topic: "ws2ms_chat"
|
||||||
ms2pschat:
|
ms2pschat:
|
||||||
addr: [ 127.0.0.1:9092 ]
|
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||||
topic: "ms2ps_chat"
|
topic: "ms2ps_chat"
|
||||||
consumergroupid:
|
consumergroupid:
|
||||||
msgToMongo: mongo
|
msgToMongo: mongo
|
||||||
@ -55,6 +55,7 @@ kafka:
|
|||||||
# The service ip default is empty,
|
# The service ip default is empty,
|
||||||
# automatically obtain the machine's valid network card ip as the service ip,
|
# automatically obtain the machine's valid network card ip as the service ip,
|
||||||
# otherwise the configuration ip is preferred
|
# otherwise the configuration ip is preferred
|
||||||
|
#如果是单机模式,用0.0.0.0或者不填,默认即可
|
||||||
serverip: 0.0.0.0
|
serverip: 0.0.0.0
|
||||||
|
|
||||||
# endpoints 内部组件间访问的端点host名称,访问时,可以内部直接访问 host:port 来访问
|
# endpoints 内部组件间访问的端点host名称,访问时,可以内部直接访问 host:port 来访问
|
||||||
@ -73,27 +74,28 @@ endpoints:
|
|||||||
rpc_message_cms: openim_rpc_admin_cms
|
rpc_message_cms: openim_rpc_admin_cms
|
||||||
|
|
||||||
api:
|
api:
|
||||||
openImApiPort: [ 10000 ]
|
openImApiPort: [ 10000 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||||
cmsapi:
|
cmsapi:
|
||||||
openImCmsApiPort: [ 8000 ]
|
openImCmsApiPort: [ 8000 ] #管理后台api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||||
sdk:
|
sdk:
|
||||||
openImSdkWsPort: [ 30000 ]
|
openImSdkWsPort: [ 30000 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
|
||||||
|
|
||||||
credential:
|
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
|
||||||
tencent:
|
tencent:
|
||||||
appID: 1302656840
|
appID: 1302656840
|
||||||
region: ap-chengdu
|
region: ap-chengdu
|
||||||
bucket: echat-1302656840
|
bucket: echat-1302656840
|
||||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
|
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
|
||||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
|
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
|
||||||
minio:
|
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化时相应改动
|
||||||
bucket: openim
|
bucket: openim
|
||||||
location: us-east-1
|
location: us-east-1
|
||||||
endpoint: http://127.0.0.1:9000
|
endpoint: http://127.0.0.1:9000
|
||||||
accessKeyID: minioadmin
|
accessKeyID: minioadmin
|
||||||
secretAccessKey: minioadmin
|
secretAccessKey: minioadmin
|
||||||
|
|
||||||
rpcport:
|
|
||||||
|
rpcport: #rpc服务端口 默认即可
|
||||||
openImUserPort: [ 10100 ]
|
openImUserPort: [ 10100 ]
|
||||||
openImFriendPort: [ 10200 ]
|
openImFriendPort: [ 10200 ]
|
||||||
openImOfflineMessagePort: [ 10300 ]
|
openImOfflineMessagePort: [ 10300 ]
|
||||||
@ -114,7 +116,7 @@ rpcport:
|
|||||||
stateChange:
|
stateChange:
|
||||||
switch: false
|
switch: false
|
||||||
|
|
||||||
rpcregistername:
|
rpcregistername: #rpc注册服务名,默认即可
|
||||||
openImUserName: User
|
openImUserName: User
|
||||||
openImFriendName: Friend
|
openImFriendName: Friend
|
||||||
openImOfflineMessageName: OfflineMessage
|
openImOfflineMessageName: OfflineMessage
|
||||||
@ -129,52 +131,55 @@ rpcregistername:
|
|||||||
log:
|
log:
|
||||||
storageLocation: ../logs/
|
storageLocation: ../logs/
|
||||||
rotationTime: 24
|
rotationTime: 24
|
||||||
remainRotationCount: 5
|
remainRotationCount: 5 #日志数量
|
||||||
remainLogLevel: 6
|
remainLogLevel: 6 #日志级别 6表示全都打印,测试阶段建议设置为6
|
||||||
elasticSearchSwitch: false
|
elasticSearchSwitch: false
|
||||||
elasticSearchAddr: [ 127.0.0.1:9201 ]
|
elasticSearchAddr: [ 127.0.0.1:9201 ]
|
||||||
elasticSearchUser: ""
|
elasticSearchUser: ""
|
||||||
elasticSearchPassword: ""
|
elasticSearchPassword: ""
|
||||||
|
|
||||||
modulename:
|
modulename: #日志文件按模块命名,默认即可
|
||||||
longConnSvrName: msg_gateway
|
longConnSvrName: msg_gateway
|
||||||
msgTransferName: msg_transfer
|
msgTransferName: msg_transfer
|
||||||
pushName: push
|
pushName: push
|
||||||
|
|
||||||
longconnsvr:
|
longconnsvr:
|
||||||
openImWsPort: [ 17778 ]
|
openImWsPort: [ 17778 ] # ws服务端口,默认即可,要开放此端口或做nginx转发
|
||||||
websocketMaxConnNum: 10000
|
websocketMaxConnNum: 10000
|
||||||
websocketMaxMsgLen: 4096
|
websocketMaxMsgLen: 4096
|
||||||
websocketTimeOut: 10
|
websocketTimeOut: 10
|
||||||
|
|
||||||
push:
|
push:
|
||||||
tpns:
|
tpns: #腾讯推送,暂未测试 暂不要使用
|
||||||
ios:
|
ios:
|
||||||
accessID: 1600018281
|
accessID: 1600018281
|
||||||
secretKey: 3cd68a77a95b89e5089a1aca523f318f
|
secretKey: 3cd68a77a95b89e5089a1aca523f318f
|
||||||
android:
|
android:
|
||||||
accessID: 111
|
accessID: 111
|
||||||
secretKey: 111
|
secretKey: 111
|
||||||
jpns:
|
jpns: #极光推送 在极光后台申请后,修改以下四项,必须修改
|
||||||
appKey: cf47465a368f24c659608e7e
|
appKey: cf47465a368f24c659608e7e
|
||||||
masterSecret: 02204efe3f3832947a236ee5
|
masterSecret: 02204efe3f3832947a236ee5
|
||||||
pushUrl: "https://api.jpush.cn/v3/push"
|
pushUrl: "https://api.jpush.cn/v3/push"
|
||||||
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
|
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
|
||||||
manager:
|
manager:
|
||||||
|
#app管理员userID和对应的secret 建议修改。 用于管理后台登录,也可以用户管理后台对应的api
|
||||||
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
|
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
|
||||||
secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"]
|
secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"]
|
||||||
|
|
||||||
secret: tuoyun
|
secret: tuoyun
|
||||||
|
# 多端互踢策略
|
||||||
|
# 1:多平台登录:Android、iOS、Windows、Mac 每种平台只能一个在线,web端可以多个同时在线
|
||||||
multiloginpolicy: 1
|
multiloginpolicy: 1
|
||||||
|
|
||||||
#token config
|
#token config
|
||||||
tokenpolicy:
|
tokenpolicy:
|
||||||
accessSecret: "open_im_server"
|
accessSecret: "open_im_server" #token生成相关,默认即可
|
||||||
# Token effective time day as a unit
|
# Token effective time day as a unit
|
||||||
accessExpire: 7
|
accessExpire: 3650 #token过期时间(天) 默认即可
|
||||||
|
|
||||||
messagecallback:
|
messagecallback:
|
||||||
|
callbackSwitch: false
|
||||||
callbackUrl: "http://www.xxx.com/msg/judge"
|
callbackUrl: "http://www.xxx.com/msg/judge"
|
||||||
#TimeOut use second as unit
|
#TimeOut use second as unit
|
||||||
callbackTimeOut: 10
|
callbackTimeOut: 10
|
||||||
@ -189,7 +194,7 @@ messagejudge:
|
|||||||
# state:
|
# state:
|
||||||
# stateChange:
|
# stateChange:
|
||||||
# switch: false
|
# switch: false
|
||||||
|
#ios系统推送声音以及标记计数
|
||||||
iospush:
|
iospush:
|
||||||
pushSound: "xxx"
|
pushSound: "xxx"
|
||||||
badgeCount: true
|
badgeCount: true
|
||||||
@ -378,11 +383,11 @@ notification:
|
|||||||
unreadCount: false
|
unreadCount: false
|
||||||
offlinePush:
|
offlinePush:
|
||||||
switch: true
|
switch: true
|
||||||
title: "Deleted a friend"
|
title: "deleted a friend"
|
||||||
desc: "Deleted a friend"
|
desc: "deleted a friend"
|
||||||
ext: "Deleted a friend"
|
ext: "deleted a friend"
|
||||||
defaultTips:
|
defaultTips:
|
||||||
tips: "Deleted a friend" #
|
tips: "deleted a friend" #
|
||||||
|
|
||||||
|
|
||||||
friendRemarkSet:
|
friendRemarkSet:
|
||||||
@ -405,11 +410,11 @@ notification:
|
|||||||
unreadCount: false
|
unreadCount: false
|
||||||
offlinePush:
|
offlinePush:
|
||||||
switch: true
|
switch: true
|
||||||
title: "Blocked a user"
|
title: "blocked a user"
|
||||||
desc: "Blocked a user"
|
desc: "blocked a user"
|
||||||
ext: "Blocked a user"
|
ext: "blocked a user"
|
||||||
defaultTips:
|
defaultTips:
|
||||||
tips: "Blocked a user" #
|
tips: "blocked a user" #
|
||||||
|
|
||||||
|
|
||||||
blackDeleted:
|
blackDeleted:
|
||||||
@ -435,7 +440,7 @@ notification:
|
|||||||
desc: "Remove a blocked user"
|
desc: "Remove a blocked user"
|
||||||
ext: "Remove a blocked user"
|
ext: "Remove a blocked user"
|
||||||
defaultTips:
|
defaultTips:
|
||||||
tips: "Remove a blocked user"
|
tips: "remove a blocked user"
|
||||||
|
|
||||||
#####################conversation#########################
|
#####################conversation#########################
|
||||||
conversationOptUpdate:
|
conversationOptUpdate:
|
||||||
@ -454,23 +459,24 @@ notification:
|
|||||||
|
|
||||||
#---------------demo configuration---------------------#
|
#---------------demo configuration---------------------#
|
||||||
#The following configuration items are applied to openIM Demo configuration
|
#The following configuration items are applied to openIM Demo configuration
|
||||||
|
#是否启动demo,如果自身没有账号体系,设置为true
|
||||||
demoswitch: true
|
demoswitch: true
|
||||||
demo:
|
demo:
|
||||||
openImDemoPort: [ 42233 ]
|
openImDemoPort: [ 42233 ] #demo对外服务端口,默认即可,需要开放此端口或做nginx转发
|
||||||
alismsverify:
|
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,必须修改
|
||||||
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe71
|
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe7
|
||||||
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV1
|
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV
|
||||||
signName: OpenIM Corporation
|
signName: 托云信息技术
|
||||||
verificationCodeTemplateCode: SMS_2268101641
|
verificationCodeTemplateCode: SMS_226810164
|
||||||
superCode: 666666
|
superCode: 666666 #超级验证码,建议修改掉,收不到短信验证码时可以用此替代
|
||||||
# second
|
# second
|
||||||
codeTTL: 60
|
codeTTL: 300
|
||||||
mail:
|
mail: #仅支持qq邮箱,具体操作参考 https://service.mail.qq.com/cgi-bin/help?subtype=1&id=28&no=1001256 必须修改
|
||||||
title: "openIM"
|
title: "openIM"
|
||||||
senderMail: "1765567899@qq.com"
|
senderMail: "765567899@qq.com"
|
||||||
senderAuthorizationCode: "1gxyausfoevlzbfag"
|
senderAuthorizationCode: "gxyausfoevlzbfag"
|
||||||
smtpAddr: "smtp.qq.com"
|
smtpAddr: "smtp.qq.com"
|
||||||
smtpPort: 25
|
smtpPort: 25 #需开放此端口 出口方向
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,12 +7,14 @@
|
|||||||
package manage
|
package manage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
api "Open_IM/pkg/base_info"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbChat "Open_IM/pkg/proto/chat"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
|
"Open_IM/pkg/proto/sdk_ws"
|
||||||
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"
|
||||||
@ -40,11 +42,13 @@ func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
|
|||||||
newContent = utils.StructToJsonString(params.Content)
|
newContent = utils.StructToJsonString(params.Content)
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
options := make(map[string]bool, 2)
|
var options map[string]bool
|
||||||
if params.IsOnlineOnly {
|
if params.IsOnlineOnly {
|
||||||
|
options = make(map[string]bool, 5)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
||||||
|
utils.SetSwitchFromOptions(options, constant.IsSenderSync, false)
|
||||||
}
|
}
|
||||||
pbData := pbChat.SendMsgReq{
|
pbData := pbChat.SendMsgReq{
|
||||||
OperationID: params.OperationID,
|
OperationID: params.OperationID,
|
||||||
@ -152,20 +156,16 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
|
|
||||||
log.Info("", "", "api ManagementSendMsg call, api call rpc...")
|
log.Info("", "", "api ManagementSendMsg call, api call rpc...")
|
||||||
|
|
||||||
reply, err := client.SendMsg(context.Background(), pbData)
|
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("", "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
|
log.Info("", "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||||
|
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: server_api_params.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
||||||
c.JSON(http.StatusOK, gin.H{
|
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
||||||
"errCode": reply.ErrCode,
|
c.JSON(http.StatusOK, resp)
|
||||||
"errMsg": reply.ErrMsg,
|
|
||||||
"sendTime": reply.SendTime,
|
|
||||||
"msgID": reply.ClientMsgID,
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ func Login(c *gin.Context) {
|
|||||||
|
|
||||||
r, err := im_mysql_model.GetRegister(account)
|
r, err := im_mysql_model.GetRegister(account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, "user have not register", params.Password, account)
|
log.NewError(params.OperationID, "user have not register", params.Password, account, err.Error())
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NotRegistered, "errMsg": "Mobile phone number is not registered"})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.NotRegistered, "errMsg": "Mobile phone number is not registered"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,16 @@ func Verify(c *gin.Context) {
|
|||||||
log.NewInfo("0", " params.VerificationCode != config.Config.Demo.SuperCode", params.VerificationCode, config.Config.Demo)
|
log.NewInfo("0", " params.VerificationCode != config.Config.Demo.SuperCode", params.VerificationCode, config.Config.Demo)
|
||||||
log.NewInfo(params.OperationID, "begin get form redis", account)
|
log.NewInfo(params.OperationID, "begin get form redis", account)
|
||||||
if params.UsedFor == 0 {
|
if params.UsedFor == 0 {
|
||||||
params.UsedFor = 1
|
params.UsedFor = constant.VerificationCodeForRegister
|
||||||
}
|
}
|
||||||
accountKey := account + "_" + constant.VerificationCodeForRegisterSuffix
|
var accountKey string
|
||||||
|
switch params.UsedFor {
|
||||||
|
case constant.VerificationCodeForRegister:
|
||||||
|
accountKey = account + "_" + constant.VerificationCodeForRegisterSuffix
|
||||||
|
case constant.VerificationCodeForReset:
|
||||||
|
accountKey = account + "_" + constant.VerificationCodeForResetSuffix
|
||||||
|
}
|
||||||
|
|
||||||
code, err := db.DB.GetAccountCode(accountKey)
|
code, err := db.DB.GetAccountCode(accountKey)
|
||||||
log.NewInfo(params.OperationID, "redis phone number and verificating Code", accountKey, code, params)
|
log.NewInfo(params.OperationID, "redis phone number and verificating Code", accountKey, code, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -18,6 +18,6 @@ func saveUserChat(uid string, msg *pbMsg.MsgDataToMQ) error {
|
|||||||
pbSaveData := pbMsg.MsgDataToDB{}
|
pbSaveData := pbMsg.MsgDataToDB{}
|
||||||
pbSaveData.MsgData = msg.MsgData
|
pbSaveData.MsgData = msg.MsgData
|
||||||
log.NewInfo(msg.OperationID, "IncrUserSeq cost time", utils.GetCurrentTimestampByMill()-time)
|
log.NewInfo(msg.OperationID, "IncrUserSeq cost time", utils.GetCurrentTimestampByMill()-time)
|
||||||
return db.DB.SaveUserChat(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
|
return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
|
||||||
// return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
|
// return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
|
||||||
}
|
}
|
||||||
|
@ -746,6 +746,7 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
|
|||||||
OwnerUserID: v.CreatorUserID,
|
OwnerUserID: v.CreatorUserID,
|
||||||
Status: v.Status,
|
Status: v.Status,
|
||||||
CreatorUserID: v.CreatorUserID,
|
CreatorUserID: v.CreatorUserID,
|
||||||
|
CreateTime: uint32(v.CreateTime.Unix()),
|
||||||
},
|
},
|
||||||
GroupMasterId: groupMember.UserID,
|
GroupMasterId: groupMember.UserID,
|
||||||
GroupMasterName: groupMember.Nickname,
|
GroupMasterName: groupMember.Nickname,
|
||||||
@ -890,10 +891,9 @@ func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGrou
|
|||||||
resp.Failed = append(resp.Failed, userId)
|
resp.Failed = append(resp.Failed, userId)
|
||||||
} else {
|
} else {
|
||||||
resp.Success = append(resp.Success, userId)
|
resp.Success = append(resp.Success, userId)
|
||||||
chat.MemberInvitedNotification(req.OperationId, req.GroupId, req.OpUserId, "admin add", resp.Success)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
chat.MemberInvitedNotification(req.OperationId, req.GroupId, req.OpUserId, "admin add you to group", resp.Success)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *pbMsg.GetMaxAndMinSeq
|
|||||||
func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.PullMessageBySeqListReq) (*open_im_sdk.PullMessageBySeqListResp, error) {
|
func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.PullMessageBySeqListReq) (*open_im_sdk.PullMessageBySeqListResp, error) {
|
||||||
log.NewInfo(in.OperationID, "rpc PullMessageBySeqList is arriving", in.String())
|
log.NewInfo(in.OperationID, "rpc PullMessageBySeqList is arriving", in.String())
|
||||||
resp := new(open_im_sdk.PullMessageBySeqListResp)
|
resp := new(open_im_sdk.PullMessageBySeqListResp)
|
||||||
msgList, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList, in.OperationID)
|
//msgList, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList, in.OperationID)
|
||||||
// msgList, err := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, in.SeqList, in.OperationID)
|
msgList, err := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, in.SeqList, in.OperationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("PullMessageBySeqList data error", in.OperationID, in.String())
|
log.ErrorByKv("PullMessageBySeqList data error", in.OperationID, in.String())
|
||||||
resp.ErrCode = 201
|
resp.ErrCode = 201
|
||||||
|
@ -17,7 +17,7 @@ func (t *TimeTask) timedDeleteUserChat() {
|
|||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
uid, _ := db.DB.MgoSkipUID(i)
|
uid, _ := db.DB.MgoSkipUID(i)
|
||||||
db.DB.DelUserChat(uid)
|
db.DB.DelUserChatMongo2(uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -2,6 +2,7 @@ package base_info
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
pbRelay "Open_IM/pkg/proto/relay"
|
pbRelay "Open_IM/pkg/proto/relay"
|
||||||
|
"Open_IM/pkg/proto/sdk_ws"
|
||||||
pbUser "Open_IM/pkg/proto/user"
|
pbUser "Open_IM/pkg/proto/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,3 +37,8 @@ type AccountCheckResp struct {
|
|||||||
CommResp
|
CommResp
|
||||||
ResultList []*pbUser.AccountCheckResp_SingleUserStatus `json:"data"`
|
ResultList []*pbUser.AccountCheckResp_SingleUserStatus `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ManagementSendMsgResp struct {
|
||||||
|
CommResp
|
||||||
|
ResultList server_api_params.UserSendMsgResp `json:"data"`
|
||||||
|
}
|
||||||
|
@ -10,8 +10,8 @@ type GetUsersInfoReq struct {
|
|||||||
}
|
}
|
||||||
type GetUsersInfoResp struct {
|
type GetUsersInfoResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
UserInfoList []*open_im_sdk.PublicUserInfo
|
UserInfoList []*open_im_sdk.PublicUserInfo `json:"-"`
|
||||||
Data []map[string]interface{} `json:"data"`
|
Data []map[string]interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateSelfUserInfoReq struct {
|
type UpdateSelfUserInfoReq struct {
|
||||||
|
1
pkg/call_back_struct/common.go
Normal file
1
pkg/call_back_struct/common.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package call_back_struct
|
1
pkg/call_back_struct/message.go
Normal file
1
pkg/call_back_struct/message.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package call_back_struct
|
@ -54,10 +54,16 @@ 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
|
||||||
|
|
||||||
|
UserNotificationBegin = 1301
|
||||||
UserInfoUpdatedNotification = 1303 //SetSelfInfoTip = 204
|
UserInfoUpdatedNotification = 1303 //SetSelfInfoTip = 204
|
||||||
|
ConversationNotification = 1307
|
||||||
|
ConversationNotNotification = 1308
|
||||||
|
ConversationDefault = 0
|
||||||
|
UserNotificationEnd = 1399
|
||||||
|
|
||||||
ConversationOptChangeNotification = 1300 // change conversation opt
|
GroupNotificationBegin = 1500
|
||||||
|
|
||||||
GroupCreatedNotification = 1501
|
GroupCreatedNotification = 1501
|
||||||
GroupInfoSetNotification = 1502
|
GroupInfoSetNotification = 1502
|
||||||
@ -126,10 +132,10 @@ const (
|
|||||||
MinioDurationTimes = 3600
|
MinioDurationTimes = 3600
|
||||||
|
|
||||||
// verificationCode used for
|
// verificationCode used for
|
||||||
VerificationCodeForRegister = 1
|
VerificationCodeForRegister = 1
|
||||||
VerificationCodeForReset = 2
|
VerificationCodeForReset = 2
|
||||||
VerificationCodeForRegisterSuffix = "_forRegister"
|
VerificationCodeForRegisterSuffix = "_forRegister"
|
||||||
VerificationCodeForResetSuffix = "_forReset"
|
VerificationCodeForResetSuffix = "_forReset"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ContentType2PushContent = map[int64]string{
|
var ContentType2PushContent = map[int64]string{
|
||||||
@ -183,4 +189,4 @@ func GroupIsBanPrivateChat(status int32) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const BigVersion = "v3"
|
const BigVersion = "v3"
|
||||||
|
@ -3,15 +3,20 @@ package db
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
// "context"
|
"Open_IM/pkg/utils"
|
||||||
// "fmt"
|
"fmt"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
|
||||||
|
// "context"
|
||||||
|
// "fmt"
|
||||||
"github.com/garyburd/redigo/redis"
|
"github.com/garyburd/redigo/redis"
|
||||||
"gopkg.in/mgo.v2"
|
"gopkg.in/mgo.v2"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"context"
|
||||||
//"go.mongodb.org/mongo-driver/bson"
|
//"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
// "go.mongodb.org/mongo-driver/mongo/options"
|
// "go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,61 +34,60 @@ func key(dbAddress, dbName string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var mgoSession *mgo.Session
|
//var mgoSession *mgo.Session
|
||||||
var mongoClient *mongo.Client
|
var mongoClient *mongo.Client
|
||||||
var err1 error
|
var err1 error
|
||||||
//mysql init
|
//mysql init
|
||||||
initMysqlDB()
|
initMysqlDB()
|
||||||
// mongo init
|
// mongo init
|
||||||
// "mongodb://sysop:moon@localhost/records"
|
// "mongodb://sysop:moon@localhost/records"
|
||||||
// uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority"
|
uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
|
||||||
//uri := fmt.Sprintf("mongodb://%s:%s@%s/%s/?maxPoolSize=%d",
|
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
||||||
// config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword,
|
config.Config.Mongo.DBAddress[0],config.Config.Mongo.DBDatabase,
|
||||||
// config.Config.Mongo.DBAddress[0],config.Config.Mongo.DBDatabase,
|
config.Config.Mongo.DBMaxPoolSize)
|
||||||
// config.Config.Mongo.DBMaxPoolSize)
|
|
||||||
|
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||||
|
if err != nil{
|
||||||
|
log.NewError(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri)
|
||||||
|
time.Sleep(time.Duration(30) * time.Second)
|
||||||
|
mongoClient, err1 = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||||
|
if err1 != nil {
|
||||||
|
log.NewError(" mongo.Connect retry failed, panic", err.Error(), uri)
|
||||||
|
panic(err1.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.NewInfo("0", utils.GetSelfFuncName(), "mongo driver client init success")
|
||||||
|
DB.mongoClient = mongoClient
|
||||||
|
|
||||||
|
//mgoDailInfo := &mgo.DialInfo{
|
||||||
|
// Addrs: config.Config.Mongo.DBAddress,
|
||||||
|
// Direct: config.Config.Mongo.DBDirect,
|
||||||
|
// Timeout: time.Second * time.Duration(config.Config.Mongo.DBTimeout),
|
||||||
|
// Database: config.Config.Mongo.DBDatabase,
|
||||||
|
// Source: config.Config.Mongo.DBSource,
|
||||||
|
// Username: config.Config.Mongo.DBUserName,
|
||||||
|
// Password: config.Config.Mongo.DBPassword,
|
||||||
|
// PoolLimit: config.Config.Mongo.DBMaxPoolSize,
|
||||||
|
//}
|
||||||
|
//mgoSession, err = mgo.DialWithInfo(mgoDailInfo)
|
||||||
//
|
//
|
||||||
//mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
//if err != nil {
|
||||||
//if err != nil{
|
//
|
||||||
// log.NewError(" mongo.Connect failed, try ", err.Error(), uri)
|
// mgoSession, err1 = mgo.DialWithInfo(mgoDailInfo)
|
||||||
// time.Sleep(time.Duration(30) * time.Second)
|
|
||||||
// mongoClient, err1 = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
|
||||||
// if err1 != nil {
|
// if err1 != nil {
|
||||||
// log.NewError(" mongo.Connect failed, panic", err.Error(), uri)
|
// log.NewError(" mongo.Connect failed, panic", err.Error())
|
||||||
// panic(err1.Error())
|
// panic(err1.Error())
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
//DB.mgoSession = mgoSession
|
||||||
|
//DB.mgoSession.SetMode(mgo.Monotonic, true)
|
||||||
mgoDailInfo := &mgo.DialInfo{
|
//c := DB.mgoSession.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
||||||
Addrs: config.Config.Mongo.DBAddress,
|
//err = c.EnsureIndexKey("uid")
|
||||||
Direct: config.Config.Mongo.DBDirect,
|
//if err != nil {
|
||||||
Timeout: time.Second * time.Duration(config.Config.Mongo.DBTimeout),
|
// panic(err.Error())
|
||||||
Database: config.Config.Mongo.DBDatabase,
|
//}
|
||||||
Source: config.Config.Mongo.DBSource,
|
//
|
||||||
Username: config.Config.Mongo.DBUserName,
|
|
||||||
Password: config.Config.Mongo.DBPassword,
|
|
||||||
PoolLimit: config.Config.Mongo.DBMaxPoolSize,
|
|
||||||
}
|
|
||||||
mgoSession, err := mgo.DialWithInfo(mgoDailInfo)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
|
|
||||||
mgoSession, err1 = mgo.DialWithInfo(mgoDailInfo)
|
|
||||||
if err1 != nil {
|
|
||||||
log.NewError(" mongo.Connect failed, panic", err.Error())
|
|
||||||
panic(err1.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DB.mongoClient = mongoClient
|
|
||||||
DB.mgoSession = mgoSession
|
|
||||||
DB.mgoSession.SetMode(mgo.Monotonic, true)
|
|
||||||
c := DB.mgoSession.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
|
||||||
err = c.EnsureIndexKey("uid")
|
|
||||||
if err != nil {
|
|
||||||
panic(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// redis pool init
|
// redis pool init
|
||||||
DB.redisPool = &redis.Pool{
|
DB.redisPool = &redis.Pool{
|
||||||
|
@ -65,7 +65,12 @@ func (d *DataBases) GetMinSeqFromMongo(uid string) (MinSeq uint32, err error) {
|
|||||||
//return MinSeq, nil
|
//return MinSeq, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) GetMinSeqFromMongo2(uid string) (MinSeq uint32, err error) {
|
||||||
|
return 1, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
||||||
|
log.NewInfo(operationID, utils.GetSelfFuncName(), uid, seqList)
|
||||||
var hasSeqList []uint32
|
var hasSeqList []uint32
|
||||||
singleCount := 0
|
singleCount := 0
|
||||||
session := d.mgoSession.Clone()
|
session := d.mgoSession.Clone()
|
||||||
|
@ -30,7 +30,7 @@ func SetPassword(account, password, ex string) error {
|
|||||||
|
|
||||||
func ResetPassword(account, password string) error {
|
func ResetPassword(account, password string) error {
|
||||||
r := db.Register{
|
r := db.Register{
|
||||||
Password:password,
|
Password: password,
|
||||||
}
|
}
|
||||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
dbConn.LogMode(true)
|
dbConn.LogMode(true)
|
||||||
|
@ -6,7 +6,6 @@ source ./function.sh
|
|||||||
list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}')
|
list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}')
|
||||||
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
||||||
list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}')
|
list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}')
|
||||||
list4=$(cat $config_path | grep openImCmsApiPort | awk - F '[:]' '{print $NF}')
|
|
||||||
list_to_string $list1
|
list_to_string $list1
|
||||||
api_ports=($ports_array)
|
api_ports=($ports_array)
|
||||||
list_to_string $list2
|
list_to_string $list2
|
||||||
@ -14,7 +13,6 @@ ws_ports=($ports_array)
|
|||||||
list_to_string $list3
|
list_to_string $list3
|
||||||
sdk_ws_ports=($ports_array)
|
sdk_ws_ports=($ports_array)
|
||||||
list_to_string $list4
|
list_to_string $list4
|
||||||
cms_api_ports=($ports_array)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user