From bb1babad11b1cab2549af92134273c1526415d47 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 10 Nov 2022 14:51:35 +0800 Subject: [PATCH] config --- .env | 2 +- config/config.yaml | 24 ++++++++++-------------- config/usualConfig.yaml | 6 +++--- internal/push/logic/init.go | 2 +- internal/rpc/msg/send_msg.go | 6 +++--- pkg/common/config/config.go | 17 +++++++++-------- 6 files changed, 27 insertions(+), 30 deletions(-) diff --git a/.env b/.env index 8f2a06dcc..30447a405 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ USER=root -PASSWORD=openIM +PASSWORD=openIM123 DATA_DIR=./ diff --git a/config/config.yaml b/config/config.yaml index 55ca979d5..a92f64180 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -10,12 +10,10 @@ etcd: userName: password: -k8sMod: false #开启k8s模式 使用pod里面环境变量请求services调用服务 而并非etcd - mysql: dbMysqlAddress: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可 - dbMysqlUserName: root #mysql用户名,建议修改 - dbMysqlPassword: openIM # mysql密码,建议修改 + dbMysqlUserName: #mysql用户名,建议修改 + dbMysqlPassword: # mysql密码,建议修改 dbMysqlDatabaseName: openIM_v2 #默认即可 dbTableName: eMsg #默认即可 dbMsgTableNum: 1 @@ -33,8 +31,8 @@ mongo: dbTimeout: 60 dbDatabase: openIM #mongo db 默认即可 dbSource: admin - dbUserName: root #mongo用户名,建议先不设置 - dbPassword: openIM #mongo密码,建议先不设置 + dbUserName: #mongo用户名,建议先不设置 + dbPassword: #mongo密码,建议先不设置 dbMaxPoolSize: 100 dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改 chatRecordsClearTime: "* * * * *" # 每天凌晨3点清除消息,该配置和linux定时任务一样, 清理操作建议设置在用户活跃少的时候 # 0 3 * * * @@ -45,7 +43,7 @@ redis: dbMaxActive: 0 dbIdleTimeout: 120 dbUserName: #only redis version 6.0+ need username - dbPassWord: openIM #redis密码 建议修改 + dbPassWord: #redis密码 建议修改 enableCluster: false #如果外部redis以集群方式启动,需要打开此开关 kafka: @@ -125,8 +123,8 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申 endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的 endpointInner: http://127.0.0.1:10005 #minio内网地址 如果im server 可以通过内网访问到 minio就可以 endpointInnerEnable: true #是否启用minio内网地址 启用可以让桶初始化,IM server连接minio走内网地址访问 - accessKeyID: user12345 - secretAccessKey: key12345 + accessKeyID: + secretAccessKey: storageTime: 50 #文件在minio中保存的时间 isDistributedMod: false # 是否分布式多硬盘部署 默认docker-compose中为false ali: # ali oss @@ -149,8 +147,6 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申 externalId: AssumeRoleExtend #角色扩展Id roleSessionName: Required-AWS-ID-OPENIM #角色SESSION名称 -dtm: - serverURL: 127.0.0.1:10007 rpcport: #rpc服务端口 默认即可 openImUserPort: [ 10110 ] @@ -221,19 +217,19 @@ push: android: accessID: 111 secretKey: 111 - enable: false + enable: false # true or false (bool) jpns: #极光推送 在极光后台申请后,修改以下四项,必须修改 appKey: cf47465a368f24c659608e7e masterSecret: 02204efe3f3832947a236ee5 pushUrl: "https://api.jpush.cn/v3/push" pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end" - enable: true + enable: false # true or false (bool) getui: #个推推送 pushUrl: "https://restapi.getui.com/v2/$appId" masterSecret: "" appKey: "" intent: "" - enable: false + enable: # true or false (bool) channelID: "" channelName: "" fcm: #firebase cloud message 消息推送 diff --git a/config/usualConfig.yaml b/config/usualConfig.yaml index 678d7a7c8..cd9ab305d 100644 --- a/config/usualConfig.yaml +++ b/config/usualConfig.yaml @@ -11,7 +11,7 @@ mongo: dbPassword: openIM123 #mongo密码,建议先不设置 redis: - dbUserName: root + dbUserName: dbPassWord: openIM123 #redis密码 建议修改 kafka: @@ -20,8 +20,8 @@ kafka: credential: minio: - accessKeyID: user12345 - secretAccessKey: key12345 + accessKeyID: root + secretAccessKey: openIM123 messageverify: friendVerify: false diff --git a/internal/push/logic/init.go b/internal/push/logic/init.go index b15882541..08ed3057a 100644 --- a/internal/push/logic/init.go +++ b/internal/push/logic/init.go @@ -36,7 +36,7 @@ func Init(rpcPort int) { func init() { producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic) statistics.NewStatistics(&successCount, config.Config.ModuleName.PushName, fmt.Sprintf("%d second push to msg_gateway count", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval) - if config.Config.Push.Getui.Enable { + if *config.Config.Push.Getui.Enable { offlinePusher = getui.GetuiClient } if config.Config.Push.Jpns.Enable { diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 852ffc97f..9a6ed9592 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -105,7 +105,7 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin { return true, 0, "", nil } - log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify) + log.NewDebug(data.OperationID, *config.Config.MessageVerify.FriendVerify) reqGetBlackIDListFromCache := &cacheRpc.GetBlackIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID} etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID) if etcdConn == nil { @@ -127,8 +127,8 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s } } } - log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify) - if config.Config.MessageVerify.FriendVerify { + log.NewDebug(data.OperationID, *config.Config.MessageVerify.FriendVerify) + if *config.Config.MessageVerify.FriendVerify { reqGetFriendIDListFromCache := &cacheRpc.GetFriendIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID} etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID) if etcdConn == nil { diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 11cdfb07c..97a0c4808 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -86,10 +86,6 @@ type config struct { } `yaml:"aws"` } - Dtm struct { - ServerURL string `json:"serverURL"` - } - Mysql struct { DBAddress []string `yaml:"dbMysqlAddress"` DBUserName string `yaml:"dbMysqlUserName"` @@ -206,7 +202,7 @@ type config struct { Getui struct { PushUrl string `yaml:"pushUrl"` AppKey string `yaml:"appKey"` - Enable bool `yaml:"enable"` + Enable *bool `yaml:"enable"` Intent string `yaml:"intent"` MasterSecret string `yaml:"masterSecret"` ChannelID string `yaml:"channelID"` @@ -269,7 +265,7 @@ type config struct { AccessExpire int64 `yaml:"accessExpire"` } MessageVerify struct { - FriendVerify bool `yaml:"friendVerify"` + FriendVerify *bool `yaml:"friendVerify"` } IOSPush struct { PushSound string `yaml:"pushSound"` @@ -685,11 +681,16 @@ func init() { if Config.Credential.Minio.SecretAccessKey == "" { Config.Credential.Minio.SecretAccessKey = UsualConfig.Credential.Minio.SecretAccessKey } - Config.MessageVerify.FriendVerify = UsualConfig.Messageverify.FriendVerify + + if Config.MessageVerify.FriendVerify == nil { + Config.MessageVerify.FriendVerify = &UsualConfig.Messageverify.FriendVerify + } if Config.Push.Getui.MasterSecret == "" { Config.Push.Getui.MasterSecret = UsualConfig.Push.Getui.MasterSecret Config.Push.Getui.AppKey = UsualConfig.Push.Getui.AppKey } - Config.Push.Getui.Enable = UsualConfig.Push.Getui.Enable + if Config.Push.Getui.Enable == nil { + Config.Push.Getui.Enable = &UsualConfig.Push.Getui.Enable + } }