From d66a567b8f762b0c0ecae0ca2435442ece8bd8ae Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Tue, 22 Feb 2022 19:02:39 +0800 Subject: [PATCH 01/14] shell update --- script/start_rpc_service.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/start_rpc_service.sh b/script/start_rpc_service.sh index bbd7f3c5a..bc5f41e3d 100644 --- a/script/start_rpc_service.sh +++ b/script/start_rpc_service.sh @@ -29,7 +29,7 @@ service_port_name=( openImUserPort openImFriendPort openImGroupPort - + openImAuthPort openImAdminCmsPort openImMessageCmsPort openImStatisticsPort From effb21bc6cd23b9e74292e04ce43d24fc52bf194 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Wed, 23 Feb 2022 10:35:16 +0800 Subject: [PATCH 02/14] dbMysqlDatabaseName: openIM_v2 --- config/config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index ed82b6748..c38960b68 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,7 +1,7 @@ # The class cannot be named by Pascal or camel case. # If it is not used, the corresponding structure will not be set, # and it will not be read naturally. -serverversion: 1.0.3 +serverversion: 2.0.0 #---------------Infrastructure configuration---------------------# etcd: etcdSchema: openIM @@ -11,7 +11,7 @@ mysql: dbMysqlAddress: [ 127.0.0.1:13306 ] dbMysqlUserName: root dbMysqlPassword: openIM - dbMysqlDatabaseName: openIM + dbMysqlDatabaseName: openIM_v2 dbTableName: eMsg dbMsgTableNum: 1 dbMaxOpenConns: 20 From 566c05bcef62b72cec6a144ddd3a3718ef7e2e16 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Wed, 23 Feb 2022 12:00:02 +0800 Subject: [PATCH 03/14] mongodriver test --- internal/msg_transfer/logic/db.go | 2 +- internal/rpc/msg/pull_message.go | 4 ++-- internal/timed_task/timed_task.go | 2 +- pkg/common/db/model.go | 8 ++++---- pkg/common/db/mongoModel.go | 5 +++++ 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/internal/msg_transfer/logic/db.go b/internal/msg_transfer/logic/db.go index edc269f9f..806b782c0 100644 --- a/internal/msg_transfer/logic/db.go +++ b/internal/msg_transfer/logic/db.go @@ -18,6 +18,6 @@ func saveUserChat(uid string, msg *pbMsg.MsgDataToMQ) error { pbSaveData := pbMsg.MsgDataToDB{} pbSaveData.MsgData = msg.MsgData 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) } diff --git a/internal/rpc/msg/pull_message.go b/internal/rpc/msg/pull_message.go index 126c6eb29..10a0978aa 100644 --- a/internal/rpc/msg/pull_message.go +++ b/internal/rpc/msg/pull_message.go @@ -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) { log.NewInfo(in.OperationID, "rpc PullMessageBySeqList is arriving", in.String()) resp := new(open_im_sdk.PullMessageBySeqListResp) - 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.GetMsgBySeqList(in.UserID, in.SeqList, in.OperationID) + msgList, err := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, in.SeqList, in.OperationID) if err != nil { log.ErrorByKv("PullMessageBySeqList data error", in.OperationID, in.String()) resp.ErrCode = 201 diff --git a/internal/timed_task/timed_task.go b/internal/timed_task/timed_task.go index bda907ea7..5b0264123 100644 --- a/internal/timed_task/timed_task.go +++ b/internal/timed_task/timed_task.go @@ -17,7 +17,7 @@ func (t *TimeTask) timedDeleteUserChat() { for i := 0; i < count; i++ { time.Sleep(10 * time.Millisecond) uid, _ := db.DB.MgoSkipUID(i) - db.DB.DelUserChat(uid) + db.DB.DelUserChatMongo2(uid) } go func() { diff --git a/pkg/common/db/model.go b/pkg/common/db/model.go index f990d95a3..8511201fa 100644 --- a/pkg/common/db/model.go +++ b/pkg/common/db/model.go @@ -3,15 +3,15 @@ package db import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" -// "context" -// "fmt" + // "context" + // "fmt" "github.com/garyburd/redigo/redis" "gopkg.in/mgo.v2" "time" //"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" -// "go.mongodb.org/mongo-driver/mongo/options" + // "go.mongodb.org/mongo-driver/mongo/options" ) @@ -36,7 +36,7 @@ func init() { initMysqlDB() // mongo init // "mongodb://sysop:moon@localhost/records" - // uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority" + //uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority" //uri := fmt.Sprintf("mongodb://%s:%s@%s/%s/?maxPoolSize=%d", // config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, // config.Config.Mongo.DBAddress[0],config.Config.Mongo.DBDatabase, diff --git a/pkg/common/db/mongoModel.go b/pkg/common/db/mongoModel.go index 7a9c4b302..3b489af23 100644 --- a/pkg/common/db/mongoModel.go +++ b/pkg/common/db/mongoModel.go @@ -65,7 +65,12 @@ func (d *DataBases) GetMinSeqFromMongo(uid string) (MinSeq uint32, err error) { //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) { + log.NewInfo(operationID, utils.GetSelfFuncName(), uid, seqList) var hasSeqList []uint32 singleCount := 0 session := d.mgoSession.Clone() From f9f36cd1d69cb8468fe89cb3a19d62a290d8b93c Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Wed, 23 Feb 2022 12:27:01 +0800 Subject: [PATCH 04/14] test mongo driver --- pkg/common/db/model.go | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/pkg/common/db/model.go b/pkg/common/db/model.go index 8511201fa..29ebf8c24 100644 --- a/pkg/common/db/model.go +++ b/pkg/common/db/model.go @@ -3,12 +3,17 @@ package db import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/log" + "Open_IM/pkg/utils" + "fmt" + "go.mongodb.org/mongo-driver/mongo/options" + // "context" // "fmt" "github.com/garyburd/redigo/redis" "gopkg.in/mgo.v2" "time" + "context" //"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" // "go.mongodb.org/mongo-driver/mongo/options" @@ -36,23 +41,23 @@ func init() { initMysqlDB() // mongo init // "mongodb://sysop:moon@localhost/records" - //uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority" - //uri := fmt.Sprintf("mongodb://%s:%s@%s/%s/?maxPoolSize=%d", - // config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, - // config.Config.Mongo.DBAddress[0],config.Config.Mongo.DBDatabase, - // config.Config.Mongo.DBMaxPoolSize) - // - //mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri)) - //if err != nil{ - // log.NewError(" mongo.Connect failed, try ", 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 failed, panic", err.Error(), uri) - // panic(err1.Error()) - // } - //} + uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority" + uri = fmt.Sprintf("mongodb://%s:%s@%s/%s/?maxPoolSize=%d", + config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, + config.Config.Mongo.DBAddress[0],config.Config.Mongo.DBDatabase, + 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") mgoDailInfo := &mgo.DialInfo{ From fc11b3c463d64268b933f116ec3e6cfce56785d7 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Wed, 23 Feb 2022 12:30:18 +0800 Subject: [PATCH 05/14] test mongo driver --- pkg/common/db/model.go | 58 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/pkg/common/db/model.go b/pkg/common/db/model.go index 29ebf8c24..c85c948fa 100644 --- a/pkg/common/db/model.go +++ b/pkg/common/db/model.go @@ -58,37 +58,37 @@ func init() { } } log.NewInfo("0", utils.GetSelfFuncName(), "mongo driver client init success") - - - 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) - - 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()) - } + //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) + // + //if err != nil { + // + // mgoSession, err1 = mgo.DialWithInfo(mgoDailInfo) + // if err1 != nil { + // log.NewError(" mongo.Connect failed, panic", err.Error()) + // panic(err1.Error()) + // } + //} + + //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 DB.redisPool = &redis.Pool{ From 1b68363b80611f05fc3ca319a00f791e6eedff9d Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Wed, 23 Feb 2022 12:30:47 +0800 Subject: [PATCH 06/14] test mongo driver --- pkg/common/db/model.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/common/db/model.go b/pkg/common/db/model.go index c85c948fa..eb08d37da 100644 --- a/pkg/common/db/model.go +++ b/pkg/common/db/model.go @@ -34,7 +34,7 @@ func key(dbAddress, dbName string) string { } func init() { - var mgoSession *mgo.Session + //var mgoSession *mgo.Session var mongoClient *mongo.Client var err1 error //mysql init From 541ccda7541ade33bc2095d6cc2933f71cdc72b5 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Wed, 23 Feb 2022 14:30:21 +0800 Subject: [PATCH 07/14] test mongo driver --- pkg/common/db/model.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/common/db/model.go b/pkg/common/db/model.go index eb08d37da..0576e6286 100644 --- a/pkg/common/db/model.go +++ b/pkg/common/db/model.go @@ -41,9 +41,8 @@ func init() { initMysqlDB() // mongo init // "mongodb://sysop:moon@localhost/records" - uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority" - uri = fmt.Sprintf("mongodb://%s:%s@%s/%s/?maxPoolSize=%d", - config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, + uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority" + uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d", config.Config.Mongo.DBAddress[0],config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize) From 1e602975f32b6dce7a613ef3eae93fada225df1c Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 23 Feb 2022 15:27:23 +0800 Subject: [PATCH 08/14] test --- pkg/common/db/mysql_model/im_mysql_model/demo_model.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/common/db/mysql_model/im_mysql_model/demo_model.go b/pkg/common/db/mysql_model/im_mysql_model/demo_model.go index 2e5d7df86..a10218828 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/demo_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/demo_model.go @@ -11,7 +11,7 @@ func GetRegister(account string) (*db.Register, error) { return nil, err } var r db.Register - return &r, dbConn.Table("registers").Where("account = ?", + return &r, dbConn.Debug().Table("registers").Where("account = ?", account).Take(&r).Error } @@ -30,7 +30,7 @@ func SetPassword(account, password, ex string) error { func ResetPassword(account, password string) error { r := db.Register{ - Password:password, + Password: password, } dbConn, err := db.DB.MysqlDB.DefaultGormDB() dbConn.LogMode(true) From d9f5f960a5fbd380139298bbe75e033931beb9e7 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 23 Feb 2022 15:33:22 +0800 Subject: [PATCH 09/14] test --- internal/demo/register/login.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/demo/register/login.go b/internal/demo/register/login.go index b6ec445f6..3a477e12e 100644 --- a/internal/demo/register/login.go +++ b/internal/demo/register/login.go @@ -37,7 +37,7 @@ func Login(c *gin.Context) { r, err := im_mysql_model.GetRegister(account) 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"}) return } From 3b80b747309eb7317fd4ef1c3b03c83ff5a5651b Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Wed, 23 Feb 2022 15:46:02 +0800 Subject: [PATCH 10/14] test mongo driver --- internal/rpc/group/group.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 6e39ab266..2cd5ed4d8 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -890,10 +890,9 @@ func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGrou resp.Failed = append(resp.Failed, userId) } else { 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 } From 0fca91ca37c9b01ccc02ac99c3c2362d0916bf16 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Wed, 23 Feb 2022 18:22:44 +0800 Subject: [PATCH 11/14] config description --- cmd/Open-IM-SDK-Core | 2 +- config/config.yaml | 125 ++++++++++++++++++++++--------------------- 2 files changed, 65 insertions(+), 62 deletions(-) diff --git a/cmd/Open-IM-SDK-Core b/cmd/Open-IM-SDK-Core index 23f31958d..992f76df0 160000 --- a/cmd/Open-IM-SDK-Core +++ b/cmd/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit 23f31958dae08260c5f9631f4937389a8e2d6751 +Subproject commit 992f76df0ee500a0377523b0780d3a85f2275755 diff --git a/config/config.yaml b/config/config.yaml index d39c62b3c..8eaec096c 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -4,44 +4,44 @@ serverversion: 2.0.0 #---------------Infrastructure configuration---------------------# etcd: - etcdSchema: openIM - etcdAddr: [ 127.0.0.1:2379 ] + etcdSchema: openIM #默认即可 + etcdAddr: [ 127.0.0.1:2379 ] #单机部署时,默认即可 mysql: - dbMysqlAddress: [ 127.0.0.1:13306 ] - dbMysqlUserName: root - dbMysqlPassword: openIM - dbMysqlDatabaseName: openIM_v2 - dbTableName: eMsg + dbMysqlAddress: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可 + dbMysqlUserName: root #mysql用户名,建议修改 + dbMysqlPassword: openIM # mysql密码,建议修改 + dbMysqlDatabaseName: openIM_v2 #默认即可 + dbTableName: eMsg #默认即可 dbMsgTableNum: 1 dbMaxOpenConns: 20 dbMaxIdleConns: 10 dbMaxLifeTime: 120 mongo: - dbAddress: [ 127.0.0.1:37017 ] + dbAddress: [ 127.0.0.1:37017 ] #redis地址 目前仅支持单机,默认即可 dbDirect: false dbTimeout: 10 - dbDatabase: openIM + dbDatabase: openIM #mongo db 默认即可 dbSource: admin - dbUserName: - dbPassword: + dbUserName: #mongo用户名,建议先不设置 + dbPassword: #mongo密码,建议先不设置 dbMaxPoolSize: 20 - dbRetainChatRecords: 7 + dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改 redis: - dbAddress: 127.0.0.1:16379 + dbAddress: 127.0.0.1:16379 #redis地址 目前仅支持单机,默认即可 dbMaxIdle: 128 dbMaxActive: 0 dbIdleTimeout: 120 - dbPassWord: openIM + dbPassWord: openIM #redis密码 建议修改 kafka: ws2mschat: - addr: [ 127.0.0.1:9092 ] + addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可 topic: "ws2ms_chat" ms2pschat: - addr: [ 127.0.0.1:9092 ] + addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可 topic: "ms2ps_chat" consumergroupid: msgToMongo: mongo @@ -55,6 +55,7 @@ kafka: # The service ip default is empty, # automatically obtain the machine's valid network card ip as the service ip, # otherwise the configuration ip is preferred +#如果是单机模式,用0.0.0.0或者不填,默认即可 serverip: 0.0.0.0 # endpoints 内部组件间访问的端点host名称,访问时,可以内部直接访问 host:port 来访问 @@ -73,27 +74,28 @@ endpoints: rpc_message_cms: openim_rpc_admin_cms api: - openImApiPort: [ 10000 ] + openImApiPort: [ 10000 ] #api服务端口,默认即可,需要开放此端口或做nginx转发 cmsapi: - openImCmsApiPort: [ 8000 ] + openImCmsApiPort: [ 8000 ] #管理后台api服务端口,默认即可,需要开放此端口或做nginx转发 sdk: - openImSdkWsPort: [ 30000 ] + openImSdkWsPort: [ 30000 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发 -credential: +credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改 tencent: appID: 1302656840 region: ap-chengdu bucket: echat-1302656840 secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe - minio: + minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化时相应改动 bucket: openim location: us-east-1 endpoint: http://127.0.0.1:9000 accessKeyID: minioadmin secretAccessKey: minioadmin -rpcport: + +rpcport: #rpc服务端口 默认即可 openImUserPort: [ 10100 ] openImFriendPort: [ 10200 ] openImOfflineMessagePort: [ 10300 ] @@ -114,7 +116,7 @@ rpcport: stateChange: switch: false -rpcregistername: +rpcregistername: #rpc注册服务名,默认即可 openImUserName: User openImFriendName: Friend openImOfflineMessageName: OfflineMessage @@ -129,57 +131,57 @@ rpcregistername: log: storageLocation: ../logs/ rotationTime: 24 - remainRotationCount: 5 - remainLogLevel: 6 + remainRotationCount: 5 #日志数量 + remainLogLevel: 6 #日志级别 6表示全都打印,测试阶段建议设置为6 elasticSearchSwitch: false elasticSearchAddr: [ 127.0.0.1:9201 ] elasticSearchUser: "" elasticSearchPassword: "" -modulename: +modulename: #日志文件按模块命名,默认即可 longConnSvrName: msg_gateway msgTransferName: msg_transfer pushName: push longconnsvr: - openImWsPort: [ 17778 ] + openImWsPort: [ 17778 ] # ws服务端口,默认即可,要开放此端口或做nginx转发 websocketMaxConnNum: 10000 websocketMaxMsgLen: 4096 websocketTimeOut: 10 push: - tpns: + tpns: #腾讯推送,暂未测试 暂不要使用 ios: accessID: 1600018281 secretKey: 3cd68a77a95b89e5089a1aca523f318f android: accessID: 111 secretKey: 111 - jpns: + 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" manager: + #app管理员userID和对应的secret 建议修改。 用于管理后台登录,也可以用户管理后台对应的api appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"] secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"] secret: tuoyun - +# 多端互踢策略 +# 1:多平台登录:Android、iOS、Windows、Mac 每种平台只能一个在线,web端可以多个同时在线 multiloginpolicy: 1 #token config tokenpolicy: - accessSecret: "open_im_server" + accessSecret: "open_im_server" #token生成相关,默认即可 # Token effective time day as a unit - accessExpire: 7 + accessExpire: 3650 #token过期时间(天) 默认即可 -messagecallback: +messagecallback: #暂时不要使用 还需完善 callbackUrl: "http://www.xxx.com/msg/judge" #TimeOut use second as unit callbackTimeOut: 10 -messagejudge: - isJudgeFriend: true # c2c: # callbackBeforeSendMsg: # switch: false @@ -189,7 +191,7 @@ messagejudge: # state: # stateChange: # switch: false - +#ios系统推送声音以及标记计数 iospush: pushSound: "xxx" badgeCount: true @@ -253,7 +255,7 @@ notification: desc: "groupApplicationAccepted desc" ext: "groupApplicationAccepted ext" defaultTips: - tips: "was allowed to join the group" # group info changed by xx + tips: "allowed to join the group" # group info changed by xx groupApplicationRejected: conversation: @@ -265,7 +267,7 @@ notification: desc: " desc" ext: " ext" defaultTips: - tips: "was rejected into the group" # group info changed by xx + tips: "rejected into the group" # group info changed by xx groupOwnerTransferred: conversation: @@ -289,7 +291,7 @@ notification: desc: "memberKicked desc" ext: "memberKicked ext" defaultTips: - tips: "was kicked out of the group" # group info changed by xx + tips: "kicked out of the group" # group info changed by xx memberInvited: conversation: @@ -301,7 +303,7 @@ notification: desc: "memberInvited desc" ext: "memberInvited ext" defaultTips: - tips: "was invited into the group" # group info changed by xx + tips: "invited into the group" # group info changed by xx memberEnter: conversation: @@ -378,11 +380,11 @@ notification: unreadCount: false offlinePush: switch: true - title: "Deleted a friend" - desc: "Deleted a friend" - ext: "Deleted a friend" + title: "deleted a friend" + desc: "deleted a friend" + ext: "deleted a friend" defaultTips: - tips: "Deleted a friend" # + tips: "deleted a friend" # friendRemarkSet: @@ -405,11 +407,11 @@ notification: unreadCount: false offlinePush: switch: true - title: "Blocked a user" - desc: "Blocked a user" - ext: "Blocked a user" + title: "blocked a user" + desc: "blocked a user" + ext: "blocked a user" defaultTips: - tips: "Blocked a user" # + tips: "blocked a user" # blackDeleted: @@ -435,7 +437,7 @@ notification: desc: "Remove a blocked user" ext: "Remove a blocked user" defaultTips: - tips: "Remove a blocked user" + tips: "remove a blocked user" #####################conversation######################### conversationOptUpdate: @@ -454,23 +456,24 @@ notification: #---------------demo configuration---------------------# #The following configuration items are applied to openIM Demo configuration +#是否启动demo,如果自身没有账号体系,设置为true demoswitch: true demo: - openImDemoPort: [ 42233 ] - alismsverify: - accessKeyId: LTAI5tJPkn4HuuePdiLdGqe7 - accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV - signName: 托云信息技术 - verificationCodeTemplateCode: SMS_226810164 - superCode: 666666 + openImDemoPort: [ 42233 ] #demo对外服务端口,默认即可,需要开放此端口或做nginx转发 + alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,必须修改 + accessKeyId: LTAI5tJPkn4HuuePdiLdGqe71 + accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV1 + signName: OpenIM Corporation + verificationCodeTemplateCode: SMS_2268101641 + superCode: 666666 #超级验证码,建议修改掉,收不到短信验证码时可以用此替代 # second - codeTTL: 300 - mail: + codeTTL: 60 + mail: #仅支持qq邮箱,具体操作参考 https://service.mail.qq.com/cgi-bin/help?subtype=1&id=28&no=1001256 必须修改 title: "openIM" - senderMail: "765567899@qq.com" - senderAuthorizationCode: "gxyausfoevlzbfag" + senderMail: "1765567899@qq.com" + senderAuthorizationCode: "1gxyausfoevlzbfag" smtpAddr: "smtp.qq.com" - smtpPort: 25 + smtpPort: 25 #需开放此端口 出口方向 From e1a0c2fc483864c9c2d2053318a1f30df8bf32bd Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 24 Feb 2022 14:47:21 +0800 Subject: [PATCH 12/14] fix bug --- internal/rpc/group/group.go | 1 + pkg/call_back_struct/common.go | 1 + pkg/call_back_struct/message.go | 1 + 3 files changed, 3 insertions(+) create mode 100644 pkg/call_back_struct/common.go create mode 100644 pkg/call_back_struct/message.go diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 2cd5ed4d8..40255d071 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -746,6 +746,7 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (* OwnerUserID: v.CreatorUserID, Status: v.Status, CreatorUserID: v.CreatorUserID, + CreateTime: uint32(v.CreateTime.Unix()), }, GroupMasterId: groupMember.UserID, GroupMasterName: groupMember.Nickname, diff --git a/pkg/call_back_struct/common.go b/pkg/call_back_struct/common.go new file mode 100644 index 000000000..90b77eda8 --- /dev/null +++ b/pkg/call_back_struct/common.go @@ -0,0 +1 @@ +package call_back_struct diff --git a/pkg/call_back_struct/message.go b/pkg/call_back_struct/message.go new file mode 100644 index 000000000..90b77eda8 --- /dev/null +++ b/pkg/call_back_struct/message.go @@ -0,0 +1 @@ +package call_back_struct From 0410003cebfea6e68455093e5b8a8c531514c917 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 24 Feb 2022 18:08:53 +0800 Subject: [PATCH 13/14] api update --- config/config.yaml | 1 + internal/api/manage/management_chat.go | 20 ++++++++++---------- pkg/base_info/manage_api_struct.go | 6 ++++++ pkg/base_info/user_api_struct.go | 4 ++-- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index d39c62b3c..b7bf188a6 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -175,6 +175,7 @@ tokenpolicy: accessExpire: 7 messagecallback: + callbackSwitch: false callbackUrl: "http://www.xxx.com/msg/judge" #TimeOut use second as unit callbackTimeOut: 10 diff --git a/internal/api/manage/management_chat.go b/internal/api/manage/management_chat.go index f09b9acd7..8ff3e5906 100644 --- a/internal/api/manage/management_chat.go +++ b/internal/api/manage/management_chat.go @@ -7,12 +7,14 @@ package manage import ( + api "Open_IM/pkg/base_info" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" "Open_IM/pkg/common/token_verify" "Open_IM/pkg/grpc-etcdv3/getcdv3" pbChat "Open_IM/pkg/proto/chat" + "Open_IM/pkg/proto/sdk_ws" open_im_sdk "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" "context" @@ -40,11 +42,13 @@ func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq { newContent = utils.StructToJsonString(params.Content) default: } - options := make(map[string]bool, 2) + var options map[string]bool if params.IsOnlineOnly { + options = make(map[string]bool, 5) utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false) utils.SetSwitchFromOptions(options, constant.IsHistory, false) utils.SetSwitchFromOptions(options, constant.IsPersistent, false) + utils.SetSwitchFromOptions(options, constant.IsSenderSync, false) } pbData := pbChat.SendMsgReq{ OperationID: params.OperationID, @@ -152,20 +156,16 @@ func ManagementSendMsg(c *gin.Context) { 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 { 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"}) return } - log.Info("", "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String()) - - c.JSON(http.StatusOK, gin.H{ - "errCode": reply.ErrCode, - "errMsg": reply.ErrMsg, - "sendTime": reply.SendTime, - "msgID": reply.ClientMsgID, - }) + 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}} + log.Info(params.OperationID, "ManagementSendMsg return", resp) + c.JSON(http.StatusOK, resp) } diff --git a/pkg/base_info/manage_api_struct.go b/pkg/base_info/manage_api_struct.go index 61e2bbba4..4b2061b57 100644 --- a/pkg/base_info/manage_api_struct.go +++ b/pkg/base_info/manage_api_struct.go @@ -2,6 +2,7 @@ package base_info import ( pbRelay "Open_IM/pkg/proto/relay" + "Open_IM/pkg/proto/sdk_ws" pbUser "Open_IM/pkg/proto/user" ) @@ -36,3 +37,8 @@ type AccountCheckResp struct { CommResp ResultList []*pbUser.AccountCheckResp_SingleUserStatus `json:"data"` } + +type ManagementSendMsgResp struct { + CommResp + ResultList server_api_params.UserSendMsgResp `json:"data"` +} diff --git a/pkg/base_info/user_api_struct.go b/pkg/base_info/user_api_struct.go index f4be785f2..10f20376c 100644 --- a/pkg/base_info/user_api_struct.go +++ b/pkg/base_info/user_api_struct.go @@ -10,8 +10,8 @@ type GetUsersInfoReq struct { } type GetUsersInfoResp struct { CommResp - UserInfoList []*open_im_sdk.PublicUserInfo - Data []map[string]interface{} `json:"data"` + UserInfoList []*open_im_sdk.PublicUserInfo `json:"-"` + Data []map[string]interface{} `json:"data"` } type UpdateSelfUserInfoReq struct { From aa1a176e82f07a5855ab9f68b294f3de5f26dba7 Mon Sep 17 00:00:00 2001 From: ltf Date: Fri, 25 Feb 2022 09:24:55 +0800 Subject: [PATCH 14/14] =?UTF-8?q?fix=20sdk=E9=83=A8=E7=BD=B2=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/dockerfiles/Dockerfile.sdk | 4 ++-- deploy/openim.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy/dockerfiles/Dockerfile.sdk b/deploy/dockerfiles/Dockerfile.sdk index 27e68bb2f..1cb4bb2c8 100644 --- a/deploy/dockerfiles/Dockerfile.sdk +++ b/deploy/dockerfiles/Dockerfile.sdk @@ -5,10 +5,10 @@ ENV WORKDIR /app ENV CONFIG_NAME $WORKDIR/config/config.yaml # 定义环境变量 -ARG API_ENDPOINT=0.0.0.0:10000 +ARG API_ENDPOINT=http://0.0.0.0:10000 ENV API_ENDPOINT ${API_ENDPOINT} -ARG WS_ENDPOINT=0.0.0.0:17778 +ARG WS_ENDPOINT=ws://0.0.0.0:17778 ENV WS_ENDPOINT ${WS_ENDPOINT} ARG DB_DIR=../db/sdk/ diff --git a/deploy/openim.yaml b/deploy/openim.yaml index 1f6e4ffe6..84bf30a85 100644 --- a/deploy/openim.yaml +++ b/deploy/openim.yaml @@ -39,7 +39,7 @@ services: - 30000:30000 # sdk,必须开 environment: - "API_ENDPOINT=http://openim_api:10000" - - "WS_ENDPOINT=http://openim_msg_gateway:17778" + - "WS_ENDPOINT=ws://openim_msg_gateway:17778" volumes: - ./logs:/app/logs - ./db/sdk:/app/db/sdk