From ebf7a1d40d4ba6b82ed518ca6b47e84ea6f61d6a Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Mon, 14 Mar 2022 10:23:44 +0800 Subject: [PATCH 01/21] v2.0.3 image --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index f63b3c125..0f1c5308f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -93,7 +93,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 open_im_server: - image: openim/open_im_server:v2.0.2 + image: openim/open_im_server:v2.0.3 container_name: open_im_server volumes: - ./logs:/Open-IM-Server/logs From 91b9e50fd0f86ceca7a11a6117251d54f7166424 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Fri, 18 Mar 2022 17:21:04 +0800 Subject: [PATCH 02/21] 2.0.4 --- cmd/Open-IM-SDK-Core | 2 +- docker-compose.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/Open-IM-SDK-Core b/cmd/Open-IM-SDK-Core index 1c6c7af53..dd23b4b18 160000 --- a/cmd/Open-IM-SDK-Core +++ b/cmd/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit 1c6c7af5393b3e9eefbaf16b673519ca863a6c2c +Subproject commit dd23b4b185a273d38e73d51990c531e37ab5ba3b diff --git a/docker-compose.yaml b/docker-compose.yaml index 0f1c5308f..4d2495ade 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -93,7 +93,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 open_im_server: - image: openim/open_im_server:v2.0.3 + image: openim/open_im_server:v2.0.4 container_name: open_im_server volumes: - ./logs:/Open-IM-Server/logs From cfab49a7dde13540d606d5b7d8f6686fcbdde56b Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Fri, 18 Mar 2022 17:44:50 +0800 Subject: [PATCH 03/21] friendVerify --- config/config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/config.yaml b/config/config.yaml index dfaeaaed1..16445973d 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -178,7 +178,8 @@ tokenpolicy: accessSecret: "open_im_server" #token生成相关,默认即可 # Token effective time day as a unit accessExpire: 3650 #token过期时间(天) 默认即可 - +messageverify: + friendVerify: false # c2c: # callbackBeforeSendMsg: # switch: false From 7637b2bec24ff152369064e47fdb630a1f791d6b Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Fri, 18 Mar 2022 19:08:31 +0800 Subject: [PATCH 04/21] check shell update --- script/check_all.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/script/check_all.sh b/script/check_all.sh index b94aa893a..d0f48597b 100644 --- a/script/check_all.sh +++ b/script/check_all.sh @@ -52,13 +52,13 @@ else fi -check=$(ps aux | grep -w ./${timer_task_name} | grep -v grep | wc -l) -if [ $check -ge 1 ]; then - echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImMsgTimer"${COLOR_SUFFIX} -else - echo -e ${RED_PREFIX}"openImMsgTimer service does not start normally"${COLOR_SUFFIX} - echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} - exit -1 -fi +#check=$(ps aux | grep -w ./${timer_task_name} | grep -v grep | wc -l) +#if [ $check -ge 1 ]; then +# echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImMsgTimer"${COLOR_SUFFIX} +#else +# echo -e ${RED_PREFIX}"openImMsgTimer service does not start normally"${COLOR_SUFFIX} +# echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} +# exit -1 +#fi echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX} From 1b8f664c8ac5b59d1187213e7d79c9c529a6c076 Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 21 Mar 2022 11:03:46 +0800 Subject: [PATCH 05/21] fix: json tag value of UserIDResult.UserID (#178) Signed-off-by: arthur --- pkg/base_info/friend_api_struct.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/base_info/friend_api_struct.go b/pkg/base_info/friend_api_struct.go index 64b71b284..3c45c393e 100644 --- a/pkg/base_info/friend_api_struct.go +++ b/pkg/base_info/friend_api_struct.go @@ -21,7 +21,7 @@ type ImportFriendReq struct { FromUserID string `json:"fromUserID" binding:"required"` } type UserIDResult struct { - UserID string `json:"userID""` + UserID string `json:"userID"` Result int32 `json:"result"` } type ImportFriendResp struct { From 1ab3e04cba4d6bd9464ba1944e177bff18596231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=AE=88=E8=B6=8A?= Date: Mon, 21 Mar 2022 11:13:17 +0800 Subject: [PATCH 06/21] =?UTF-8?q?=E6=96=B0=E5=A2=9Emongo.dbUrl=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=20(#174)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 当dbUri值不为空则直接使用该值 * 新增支持ali oss Co-authored-by: mashouyue's m1max --- cmd/open_im_api/main.go | 15 ++-- config/config.yaml | 11 +++ deploy/config.example.yaml | 1 + go.mod | 2 + go.sum | 7 +- internal/api/third/ali_oss_credential.go | 95 ++++++++++++++++++++++++ pkg/base_info/oss_api_struct.go | 22 ++++++ pkg/common/config/config.go | 28 +++++-- pkg/common/db/model.go | 11 ++- 9 files changed, 173 insertions(+), 19 deletions(-) create mode 100644 internal/api/third/ali_oss_credential.go create mode 100644 pkg/base_info/oss_api_struct.go diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index 551a37a0e..eff8710e0 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -59,13 +59,13 @@ func main() { groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1 groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1 groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList) - groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1 - groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1 - groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use - groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1 - groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1 - groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1 - groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1 + groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1 + groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1 + groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use + groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1 + groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1 + groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1 + groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1 } //certificate authRouterGroup := r.Group("/auth") @@ -77,6 +77,7 @@ func main() { thirdGroup := r.Group("/third") { thirdGroup.POST("/tencent_cloud_storage_credential", apiThird.TencentCloudStorageCredential) + thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential) thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential) } //Message diff --git a/config/config.yaml b/config/config.yaml index 16445973d..e7c511930 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -19,6 +19,7 @@ mysql: dbMaxLifeTime: 120 mongo: + dbUri: ""#当dbUri值不为空则直接使用该值 dbAddress: [ 127.0.0.1:37017 ] #redis地址 目前仅支持单机,默认即可 dbDirect: false dbTimeout: 10 @@ -93,6 +94,16 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申 endpoint: http://127.0.0.1:9000 accessKeyID: user12345 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服务端口 默认即可 diff --git a/deploy/config.example.yaml b/deploy/config.example.yaml index f0ae8314e..08d8858e4 100644 --- a/deploy/config.example.yaml +++ b/deploy/config.example.yaml @@ -19,6 +19,7 @@ mysql: dbMaxLifeTime: 120 mongo: + dbUri: ""#当dbUri值不为空则直接使用该值 dbAddress: [ openim_mongo:27017 ] dbDirect: false dbTimeout: 10 diff --git a/go.mod b/go.mod index 9fbbf033a..8bb682c49 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect github.com/alibabacloud-go/darabonba-openapi v0.1.11 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/antonfisher/nested-logrus-formatter v1.3.0 github.com/bwmarrin/snowflake v0.3.0 @@ -52,6 +53,7 @@ require ( google.golang.org/protobuf v1.27.1 gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect 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/yaml.v3 v3.0.0-20210107192922-496545a6307b sigs.k8s.io/yaml v1.2.0 // indirect diff --git a/go.sum b/go.sum index 2385d32f5..ab34c4c92 100644 --- a/go.sum +++ b/go.sum @@ -50,6 +50,7 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWso github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +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/go.mod h1:MPJMxv7HYrFm5m9uOZWkDYsAWyZztEgnBRfk9Fg0eIU= github.com/alibabacloud-go/darabonba-string v1.0.0/go.mod h1:93cTfV3vuPhhEwGGpKKqhVW4jLe7tDpo3LUM0i0g6mA= @@ -59,8 +60,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/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/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/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.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= @@ -904,8 +908,9 @@ gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AW gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw= 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.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c= 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/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= diff --git a/internal/api/third/ali_oss_credential.go b/internal/api/third/ali_oss_credential.go new file mode 100644 index 000000000..c07cd5d22 --- /dev/null +++ b/internal/api/third/ali_oss_credential.go @@ -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")) + 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) +} diff --git a/pkg/base_info/oss_api_struct.go b/pkg/base_info/oss_api_struct.go new file mode 100644 index 000000000..621d18820 --- /dev/null +++ b/pkg/base_info/oss_api_struct.go @@ -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"` +} diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 282440672..05ff23020 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -20,8 +20,8 @@ var ( var Config config type callBackConfig struct { - Enable bool `yaml:"enable"` - CallbackTimeOut int `yaml:"callbackTimeOut"` + Enable bool `yaml:"enable"` + CallbackTimeOut int `yaml:"callbackTimeOut"` CallbackFailedContinue bool `CallbackFailedContinue` } @@ -31,7 +31,7 @@ type config struct { Api struct { GinPort []int `yaml:"openImApiPort"` } - CmsApi struct{ + CmsApi struct { GinPort []int `yaml:"openImCmsApiPort"` } Sdk struct { @@ -45,6 +45,17 @@ type config struct { SecretID string `yaml:"secretID"` 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 { Bucket string `yaml:"bucket"` Location string `yaml:"location"` @@ -66,6 +77,7 @@ type config struct { DBMaxLifeTime int `yaml:"dbMaxLifeTime"` } Mongo struct { + DBUri string `yaml:"dbUri"` // 当dbUri值不为空则直接使用该值 DBAddress []string `yaml:"dbAddress"` DBDirect bool `yaml:"dbDirect"` DBTimeout int `yaml:"dbTimeout"` @@ -182,12 +194,12 @@ type config struct { } Callback struct { - CallbackUrl string `yaml:"callbackUrl"` + CallbackUrl string `yaml:"callbackUrl"` CallbackBeforeSendSingleMsg callBackConfig `yaml:"callbackbeforeSendSingleMsg"` - CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"` - CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"` - CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"` - CallbackWordFilter callBackConfig `yaml:"callbackWordFilter"` + CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"` + CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"` + CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"` + CallbackWordFilter callBackConfig `yaml:"callbackWordFilter"` } `yaml:"callback"` Notification struct { ///////////////////////group///////////////////////////// diff --git a/pkg/common/db/model.go b/pkg/common/db/model.go index 0576e6286..e7b03cbd5 100644 --- a/pkg/common/db/model.go +++ b/pkg/common/db/model.go @@ -42,9 +42,14 @@ func init() { // mongo init // "mongodb://sysop:moon@localhost/records" 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) + if config.Config.Mongo.DBUri != "" { + // example: mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$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)) if err != nil{ From e0c6972bed29d8b2ced7d984ebc3a20a460027be Mon Sep 17 00:00:00 2001 From: Sunny Date: Mon, 21 Mar 2022 11:19:10 +0800 Subject: [PATCH 07/21] Update config.yaml (#167) Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --- config/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yaml b/config/config.yaml index e7c511930..344743ec9 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -20,7 +20,7 @@ mysql: mongo: dbUri: ""#当dbUri值不为空则直接使用该值 - dbAddress: [ 127.0.0.1:37017 ] #redis地址 目前仅支持单机,默认即可 + dbAddress: [ 127.0.0.1:37017 ] #mongo地址 目前仅支持单机,默认即可 dbDirect: false dbTimeout: 10 dbDatabase: openIM #mongo db 默认即可 From 6c43f75f9fae80a53eb16a4851c5ee191cd9cc22 Mon Sep 17 00:00:00 2001 From: hxnets <32917172+hxnets@users.noreply.github.com> Date: Mon, 21 Mar 2022 14:43:41 +0800 Subject: [PATCH 08/21] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=98=BF=E9=87=8C?= =?UTF-8?q?=E4=BA=91OSS=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=20(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * configure update * mongo:4.0 * open-im-server -> open_im_server * sleep 15 * 0.0.0.0 * sleep 10 15 * Update config.yaml * config * Update docker-compose.yaml * Update config.yaml * Create ISSUE_TEMPLATE.md * Update ISSUE_TEMPLATE.md * Create ISSUE_TEMPLATE * add issue template * add issue template * add issue template * add issue template * Update README.md * script * script * script * config * script * config update * script update * image: openim/open_im_server:v1.0.6 * script * script * script * version update * sender message sync * version update * 阿里云oss sts上传参数 * 阿里云oss sts上传参数 Co-authored-by: wenxu12345 <44203734@qq.com> Co-authored-by: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Co-authored-by: Gordon <1432970085@qq.com> Co-authored-by: Gordon <46924906+FGadvancer@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md | 37 ++++++++++ .gitignore | 1 + README.md | 2 + config/config.yaml | 3 + docker-compose.yaml | 1 + go.sum | 2 + .../third/aliyun_cloud_storage_credential.go | 72 +++++++++++++++++++ internal/msg_gateway/gate/rpc_server.go | 11 +++ pkg/common/config/config.go | 1 - script/build_image.sh | 11 +++ script/docker_check_service.sh | 1 + script/start_rpc_service.sh | 2 +- 12 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md create mode 100644 internal/api/third/aliyun_cloud_storage_credential.go create mode 100644 script/build_image.sh diff --git a/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..15fe98c2c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md @@ -0,0 +1,37 @@ +--- +name: 🐞 Bug +about: File a bug/issue +title: '[BUG] ' +labels: Bug, Needs Triage +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: +<!----> \ No newline at end of file diff --git a/.gitignore b/.gitignore index e4b74c4e9..3390267f4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ out-test .github .idea + deploy/open_im_demo deploy/open_im_api deploy/open_im_msg_gateway diff --git a/README.md b/README.md index ad3aa2129..4964bacb5 100644 --- a/README.md +++ b/README.md @@ -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) ``` + cd Open-IM-Server 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 + ./check_all.sh ``` ![OpenIMServersondockerpng](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/Open-IM-Servers-on-docker.png) diff --git a/config/config.yaml b/config/config.yaml index 344743ec9..aff4fd24d 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -74,6 +74,7 @@ endpoints: rpc_admin_cms: openim_rpc_admin_cms rpc_message_cms: openim_rpc_admin_cms + api: openImApiPort: [ 10000 ] #api服务端口,默认即可,需要开放此端口或做nginx转发 cmsapi: @@ -106,6 +107,7 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申 OssRoleArn: "acs:ram::xxx:role/xxx" + rpcport: #rpc服务端口 默认即可 openImUserPort: [ 10100 ] openImFriendPort: [ 10200 ] @@ -511,3 +513,4 @@ demo: + diff --git a/docker-compose.yaml b/docker-compose.yaml index 4d2495ade..78e5c1ac2 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -32,6 +32,7 @@ services: # - MONGO_INITDB_ROOT_USERNAME=openIM # - MONGO_INITDB_ROOT_PASSWORD=openIM + #TZ: Asia/Shanghai restart: always diff --git a/go.sum b/go.sum index ab34c4c92..34b43fe72 100644 --- a/go.sum +++ b/go.sum @@ -298,12 +298,14 @@ github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/ github.com/jinzhu/now v1.1.3 h1:PlHq1bSCSZL9K0wUhbm2pGLoTWs2GwVhsP6emvGV/ZI= github.com/jinzhu/now v1.1.3/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= diff --git a/internal/api/third/aliyun_cloud_storage_credential.go b/internal/api/third/aliyun_cloud_storage_credential.go new file mode 100644 index 000000000..940c1c414 --- /dev/null +++ b/internal/api/third/aliyun_cloud_storage_credential.go @@ -0,0 +1,72 @@ +package apiThird + +import ( + "Open_IM/pkg/common/config" + "github.com/aliyun/alibaba-cloud-sdk-go/services/sts" + "github.com/gin-gonic/gin" + "net/http" +) + +type paramsAliyunCloudStorageCredential struct { + Token string `form:"token"` + OperationID string `form:"operationID"` +} + +func AliyunCloudStorageCredential(c *gin.Context) { + params := paramsAliyunCloudStorageCredential{} + if err := c.BindQuery(¶ms); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Parameter parsing error,please check the parameters and request service again"}) + return + } + + credential := config.Config.Credential.Aliyun + if credential.AccessKeyId == "" || credential.AccessKeySecret == "" || credential.Bucket == "" || credential.Region == "" || credential.RegionId == "" || credential.RoleArn == "" { + c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Aliyun OSS config error"}) + return + } + //构建一个阿里云客户端, 用于发起请求。 + //构建阿里云客户端时,需要设置AccessKey ID和AccessKey Secret。 + client, err := sts.NewClientWithAccessKey(credential.RegionId, credential.AccessKeyId, credential.AccessKeySecret) + + //构建请求对象。 + request := sts.CreateAssumeRoleRequest() + request.Scheme = "https" + + type CredentialPolicyStatement struct { + Action []string `json:"action,omitempty"` + Effect string `json:"effect,omitempty"` + Resource []string `json:"resource,omitempty"` + Condition map[string]map[string]interface{} `json:"condition,omitempty"` + } + + type CredentialPolicy struct { + Version string `json:"version,omitempty"` + Statement []CredentialPolicyStatement `json:"statement,omitempty"` + } + + //设置参数。关于参数含义和设置方法,请参见《API参考》。 + request.RoleArn = credential.RoleArn + request.RoleSessionName = params.OperationID + request.Policy = "{\n \"Version\": \"1\",\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"oss:PutObject\"\n ],\n \"Resource\": \"acs:oss:*:*:*\"\n }\n ]\n}" + //request.DurationSeconds = "900" + + //发起请求,并得到响应。 + res, err := client.AssumeRole(request) + if err != nil { + c.JSON(http.StatusOK, gin.H{ + "errCode": config.ErrTencentCredential.ErrCode, + "errMsg": err.Error(), + "bucket": "", + "region": "", + "data": res, + }) + return + } + c.JSON(http.StatusOK, gin.H{ + "errCode": 0, + "errMsg": "", + "region": config.Config.Credential.Aliyun.Region, + "bucket": config.Config.Credential.Aliyun.Bucket, + "data": res, + }) +} diff --git a/internal/msg_gateway/gate/rpc_server.go b/internal/msg_gateway/gate/rpc_server.go index 4c96b9241..fc285b033 100644 --- a/internal/msg_gateway/gate/rpc_server.go +++ b/internal/msg_gateway/gate/rpc_server.go @@ -92,6 +92,17 @@ func (r *RPCServer) OnlinePushMsg(_ context.Context, in *pbRelay.OnlinePushMsgRe resp = append(resp, temp) } } + //Single chat sender synchronization message + if in.GetSessionType() == constant.SingleChatType { + userIDList = genUidPlatformArray(in.SendID) + for _, v := range userIDList { + UIDAndPID = strings.Split(v, " ") + if conn := ws.getUserConn(v); conn != nil { + _ = sendMsgToUser(conn, replyBytes.Bytes(), in, UIDAndPID[1], UIDAndPID[0]) + } + } + } + if !tag { log.NewError(in.OperationID, "push err ,no matched ws conn not in map", in.String()) } diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 05ff23020..deb7f98fd 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -64,7 +64,6 @@ type config struct { SecretAccessKey string `yaml:"secretAccessKey"` } `yaml:"minio"` } - Mysql struct { DBAddress []string `yaml:"dbMysqlAddress"` DBUserName string `yaml:"dbMysqlUserName"` diff --git a/script/build_image.sh b/script/build_image.sh new file mode 100644 index 000000000..ad37e24e4 --- /dev/null +++ b/script/build_image.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +image=openim/open_im_server:v1.0.5 +rm Open-IM-Server -rf +git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive +cd Open-IM-Server +git checkout tuoyun +cd cmd/Open-IM-SDK-Core/ +git checkout tuoyun +cd ../../ +docker build -t $image . -f deploy.Dockerfile +docker push $image \ No newline at end of file diff --git a/script/docker_check_service.sh b/script/docker_check_service.sh index 6579d400c..6236712ba 100644 --- a/script/docker_check_service.sh +++ b/script/docker_check_service.sh @@ -8,3 +8,4 @@ sleep 30 echo "check OpenIM................................" ./check_all.sh + diff --git a/script/start_rpc_service.sh b/script/start_rpc_service.sh index bc5f41e3d..2d685f478 100644 --- a/script/start_rpc_service.sh +++ b/script/start_rpc_service.sh @@ -61,6 +61,6 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 & sleep 1 pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" - echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" + # echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" done done From 3dc4290f2a80a872c1e99b764436e05a96f355af Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Mon, 21 Mar 2022 14:57:35 +0800 Subject: [PATCH 09/21] pr modify and update --- internal/msg_gateway/gate/rpc_server.go | 11 ----------- script/build_image.sh | 11 ----------- script/demo_svr_start.sh | 2 +- script/env_check.sh | 1 - script/path_info.cfg | 3 --- script/start_all.sh | 2 -- script/start_rpc_service.sh | 4 ++-- 7 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 script/build_image.sh diff --git a/internal/msg_gateway/gate/rpc_server.go b/internal/msg_gateway/gate/rpc_server.go index fc285b033..4c96b9241 100644 --- a/internal/msg_gateway/gate/rpc_server.go +++ b/internal/msg_gateway/gate/rpc_server.go @@ -92,17 +92,6 @@ func (r *RPCServer) OnlinePushMsg(_ context.Context, in *pbRelay.OnlinePushMsgRe resp = append(resp, temp) } } - //Single chat sender synchronization message - if in.GetSessionType() == constant.SingleChatType { - userIDList = genUidPlatformArray(in.SendID) - for _, v := range userIDList { - UIDAndPID = strings.Split(v, " ") - if conn := ws.getUserConn(v); conn != nil { - _ = sendMsgToUser(conn, replyBytes.Bytes(), in, UIDAndPID[1], UIDAndPID[0]) - } - } - } - if !tag { log.NewError(in.OperationID, "push err ,no matched ws conn not in map", in.String()) } diff --git a/script/build_image.sh b/script/build_image.sh deleted file mode 100644 index ad37e24e4..000000000 --- a/script/build_image.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -image=openim/open_im_server:v1.0.5 -rm Open-IM-Server -rf -git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive -cd Open-IM-Server -git checkout tuoyun -cd cmd/Open-IM-SDK-Core/ -git checkout tuoyun -cd ../../ -docker build -t $image . -f deploy.Dockerfile -docker push $image \ No newline at end of file diff --git a/script/demo_svr_start.sh b/script/demo_svr_start.sh index 55aaa88b1..85b36ab25 100644 --- a/script/demo_svr_start.sh +++ b/script/demo_svr_start.sh @@ -44,4 +44,4 @@ if [ $check -ge 1 ]; then echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX} else echo -e ${YELLOW_PREFIX}${demo_server_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} -fi +fi \ No newline at end of file diff --git a/script/env_check.sh b/script/env_check.sh index 6af30a37b..a3a9857f6 100644 --- a/script/env_check.sh +++ b/script/env_check.sh @@ -17,4 +17,3 @@ if [ $available -lt 2000 ] ; then else echo -e ${GREEN_PREFIX} "Memory is ok, available is: "$available"m${COLOR_SUFFIX}" fi - diff --git a/script/path_info.cfg b/script/path_info.cfg index 7fe9622b6..5e3b3edc4 100644 --- a/script/path_info.cfg +++ b/script/path_info.cfg @@ -53,7 +53,6 @@ service_source_root=( ${msg_source_root} ${push_source_root} ${sdk_server_source_root} - ${timer_task_source_root} ${demo_server_source_root} ) #service filename @@ -74,10 +73,8 @@ service_names=( ${msg_name} ${push_name} ${sdk_server_name} - ${timer_task_name} ${demo_server_name} ) - diff --git a/script/start_all.sh b/script/start_all.sh index dd9420adc..4125ca50a 100644 --- a/script/start_all.sh +++ b/script/start_all.sh @@ -9,7 +9,6 @@ need_to_start_server_shell=( push_start.sh msg_transfer_start.sh sdk_svr_start.sh - timer_start.sh demo_svr_start.sh ) @@ -17,4 +16,3 @@ for i in ${need_to_start_server_shell[*]}; do chmod +x $i ./$i done - diff --git a/script/start_rpc_service.sh b/script/start_rpc_service.sh index 2d685f478..6e469c7d2 100644 --- a/script/start_rpc_service.sh +++ b/script/start_rpc_service.sh @@ -61,6 +61,6 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 & sleep 1 pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" - # echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" + echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" done -done +done \ No newline at end of file From ea6d47200244edf7b443a776e391ddda47ff5be0 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Mon, 21 Mar 2022 14:59:00 +0800 Subject: [PATCH 10/21] pr modify and update --- .../third/aliyun_cloud_storage_credential.go | 72 ------------------- 1 file changed, 72 deletions(-) delete mode 100644 internal/api/third/aliyun_cloud_storage_credential.go diff --git a/internal/api/third/aliyun_cloud_storage_credential.go b/internal/api/third/aliyun_cloud_storage_credential.go deleted file mode 100644 index 940c1c414..000000000 --- a/internal/api/third/aliyun_cloud_storage_credential.go +++ /dev/null @@ -1,72 +0,0 @@ -package apiThird - -import ( - "Open_IM/pkg/common/config" - "github.com/aliyun/alibaba-cloud-sdk-go/services/sts" - "github.com/gin-gonic/gin" - "net/http" -) - -type paramsAliyunCloudStorageCredential struct { - Token string `form:"token"` - OperationID string `form:"operationID"` -} - -func AliyunCloudStorageCredential(c *gin.Context) { - params := paramsAliyunCloudStorageCredential{} - if err := c.BindQuery(¶ms); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Parameter parsing error,please check the parameters and request service again"}) - return - } - - credential := config.Config.Credential.Aliyun - if credential.AccessKeyId == "" || credential.AccessKeySecret == "" || credential.Bucket == "" || credential.Region == "" || credential.RegionId == "" || credential.RoleArn == "" { - c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Aliyun OSS config error"}) - return - } - //构建一个阿里云客户端, 用于发起请求。 - //构建阿里云客户端时,需要设置AccessKey ID和AccessKey Secret。 - client, err := sts.NewClientWithAccessKey(credential.RegionId, credential.AccessKeyId, credential.AccessKeySecret) - - //构建请求对象。 - request := sts.CreateAssumeRoleRequest() - request.Scheme = "https" - - type CredentialPolicyStatement struct { - Action []string `json:"action,omitempty"` - Effect string `json:"effect,omitempty"` - Resource []string `json:"resource,omitempty"` - Condition map[string]map[string]interface{} `json:"condition,omitempty"` - } - - type CredentialPolicy struct { - Version string `json:"version,omitempty"` - Statement []CredentialPolicyStatement `json:"statement,omitempty"` - } - - //设置参数。关于参数含义和设置方法,请参见《API参考》。 - request.RoleArn = credential.RoleArn - request.RoleSessionName = params.OperationID - request.Policy = "{\n \"Version\": \"1\",\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"oss:PutObject\"\n ],\n \"Resource\": \"acs:oss:*:*:*\"\n }\n ]\n}" - //request.DurationSeconds = "900" - - //发起请求,并得到响应。 - res, err := client.AssumeRole(request) - if err != nil { - c.JSON(http.StatusOK, gin.H{ - "errCode": config.ErrTencentCredential.ErrCode, - "errMsg": err.Error(), - "bucket": "", - "region": "", - "data": res, - }) - return - } - c.JSON(http.StatusOK, gin.H{ - "errCode": 0, - "errMsg": "", - "region": config.Config.Credential.Aliyun.Region, - "bucket": config.Config.Credential.Aliyun.Bucket, - "data": res, - }) -} From a55582a018729f44befd9e24cf92493e6dedff5a Mon Sep 17 00:00:00 2001 From: goubo <goujinbo@outlook.com> Date: Mon, 21 Mar 2022 15:25:41 +0800 Subject: [PATCH 11/21] =?UTF-8?q?=E6=96=B9=E4=BE=BF=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=95=B0=E6=8D=AE=20(#148)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/demo/register/set_password.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/demo/register/set_password.go b/internal/demo/register/set_password.go index 7540d9830..804e8eb11 100644 --- a/internal/demo/register/set_password.go +++ b/internal/demo/register/set_password.go @@ -17,6 +17,7 @@ import ( type ParamsSetPassword struct { Email string `json:"email"` + Name string `json:"name"` PhoneNumber string `json:"phoneNumber"` Password string `json:"password"` VerificationCode string `json:"verificationCode"` @@ -38,6 +39,9 @@ func SetPassword(c *gin.Context) { } else { account = params.PhoneNumber } + if params.Name == "" { + params.Name = account + } if params.VerificationCode != config.Config.Demo.SuperCode { accountKey := account + "_" + constant.VerificationCodeForRegisterSuffix v, err := db.DB.GetAccountCode(accountKey) @@ -54,7 +58,7 @@ func SetPassword(c *gin.Context) { openIMRegisterReq.OperationID = params.OperationID openIMRegisterReq.Platform = params.Platform openIMRegisterReq.UserID = account - openIMRegisterReq.Nickname = account + openIMRegisterReq.Nickname = params.Name openIMRegisterReq.Secret = config.Config.Secret openIMRegisterResp := api.UserRegisterResp{} bMsg, err := http2.Post(url, openIMRegisterReq, 2) @@ -69,7 +73,7 @@ func SetPassword(c *gin.Context) { if err != nil { 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 } log.Info(params.OperationID, "begin store mysql", account, params.Password) From c16d8da7841e57e6fe1b1c3931150f9f444437b3 Mon Sep 17 00:00:00 2001 From: jaonzyx <73813877+jaonzyx@users.noreply.github.com> Date: Mon, 21 Mar 2022 15:43:43 +0800 Subject: [PATCH 12/21] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=BE=A4=E7=BB=84bug=20fix=20(#168)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/api/group/group.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/api/group/group.go b/internal/api/group/group.go index 887a89594..8c2c67947 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -260,6 +260,10 @@ func CreateGroup(c *gin.Context) { return } req.OwnerUserID = req.OpUserID + if params.OwnerUserID != "" { + req.OwnerUserID = params.OwnerUserID + } + req.OperationID = params.OperationID log.NewInfo(req.OperationID, "CreateGroup args ", req.String()) From a2b65f52f6de91f4df82b3412b4ab837487b470a Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Mon, 21 Mar 2022 15:45:26 +0800 Subject: [PATCH 13/21] fix group create bug --- internal/api/group/group.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/api/group/group.go b/internal/api/group/group.go index 8c2c67947..d7c8c93f3 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -260,10 +260,7 @@ func CreateGroup(c *gin.Context) { return } req.OwnerUserID = req.OpUserID - if params.OwnerUserID != "" { - req.OwnerUserID = params.OwnerUserID - } - + req.OwnerUserID = params.OwnerUserID req.OperationID = params.OperationID log.NewInfo(req.OperationID, "CreateGroup args ", req.String()) From 5d54d5b7d6b608972114656d3824fc25b79baa49 Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Wed, 23 Mar 2022 11:25:59 +0800 Subject: [PATCH 14/21] Update issue templates --- .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md | 8 ++++---- .github/ISSUE_TEMPLATE/test.md | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/test.md diff --git a/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md index 15fe98c2c..e5d8ed6fa 100644 --- a/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md @@ -1,8 +1,8 @@ --- -name: 🐞 Bug +name: "\U0001F41E Bug" about: File a bug/issue -title: '[BUG] <title>' -labels: Bug, Needs Triage +title: "[BUG] <title>" +labels: '' assignees: '' --- @@ -34,4 +34,4 @@ Example: ### screenshot: -<!----> \ No newline at end of file +<!----> diff --git a/.github/ISSUE_TEMPLATE/test.md b/.github/ISSUE_TEMPLATE/test.md new file mode 100644 index 000000000..66bc7e421 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/test.md @@ -0,0 +1,10 @@ +--- +name: test +about: Describe this issue template's purpose here. +title: '' +labels: '' +assignees: '' + +--- + + From ab0ed67f814e24a694529d72508b692a4ae41884 Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Wed, 23 Mar 2022 11:26:25 +0800 Subject: [PATCH 15/21] Update issue templates --- .github/ISSUE_TEMPLATE/test.md | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/test.md diff --git a/.github/ISSUE_TEMPLATE/test.md b/.github/ISSUE_TEMPLATE/test.md deleted file mode 100644 index 66bc7e421..000000000 --- a/.github/ISSUE_TEMPLATE/test.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: test -about: Describe this issue template's purpose here. -title: '' -labels: '' -assignees: '' - ---- - - From c1a210313e2920993fea3dbc60a2f616ff229737 Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Wed, 23 Mar 2022 11:28:08 +0800 Subject: [PATCH 16/21] Update issue templates --- .github/ISSUE_TEMPLATE/deployment-issues.md | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/deployment-issues.md diff --git a/.github/ISSUE_TEMPLATE/deployment-issues.md b/.github/ISSUE_TEMPLATE/deployment-issues.md new file mode 100644 index 000000000..57d7cbcb7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/deployment-issues.md @@ -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 From a4788a95af35bb7e9b92ba89ae9fffd49cca4d3b Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Wed, 23 Mar 2022 11:33:35 +0800 Subject: [PATCH 17/21] Update issue templates --- .github/ISSUE_TEMPLATE/update-.md | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/update-.md diff --git a/.github/ISSUE_TEMPLATE/update-.md b/.github/ISSUE_TEMPLATE/update-.md new file mode 100644 index 000000000..ba8da7270 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/update-.md @@ -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 From c1ee2a0adbd4f27d238fbd1334a16509fb5dea2d Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Fri, 25 Mar 2022 12:48:11 +0800 Subject: [PATCH 18/21] Update docker-compose.yaml --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 78e5c1ac2..c67203773 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -94,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 open_im_server: - image: openim/open_im_server:v2.0.4 + image: openim/open_im_server:v2.0.5 container_name: open_im_server volumes: - ./logs:/Open-IM-Server/logs From d2c04b761d99b1e24fd2097a79eb8ef5adff121e Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Tue, 29 Mar 2022 11:01:54 +0800 Subject: [PATCH 19/21] ali cloud oss --- internal/api/third/ali_oss_credential.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/api/third/ali_oss_credential.go b/internal/api/third/ali_oss_credential.go index c07cd5d22..6f5bc7c04 100644 --- a/internal/api/third/ali_oss_credential.go +++ b/internal/api/third/ali_oss_credential.go @@ -54,7 +54,7 @@ func AliOSSCredential(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return } - ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) + 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"}) From fef33795d06e160ab78459fc4109bdae8ec577f8 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Tue, 29 Mar 2022 11:16:03 +0800 Subject: [PATCH 20/21] group add --- internal/api/group/group.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/api/group/group.go b/internal/api/group/group.go index f5e09af2b..41b425d4c 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -259,7 +259,6 @@ func CreateGroup(c *gin.Context) { c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) return } - req.OwnerUserID = req.OpUserID req.OwnerUserID = params.OwnerUserID req.OperationID = params.OperationID log.NewInfo(req.OperationID, "CreateGroup args ", req.String()) From a89d617532846bb6d372f061d6483aed6ac66048 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Tue, 29 Mar 2022 11:27:19 +0800 Subject: [PATCH 21/21] group add --- go.mod | 2 +- go.sum | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 30e4daa6a..f005f9ce0 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/gin-gonic/gin v1.7.0 github.com/go-playground/validator/v10 v10.4.1 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/protobuf v1.5.2 github.com/golang/snappy v0.0.4 // indirect diff --git a/go.sum b/go.sum index 1defffaf3..cec54f0ff 100644 --- a/go.sum +++ b/go.sum @@ -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-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 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/go.mod h1:MPJMxv7HYrFm5m9uOZWkDYsAWyZztEgnBRfk9Fg0eIU= 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/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/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/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.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= @@ -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.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c= 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/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=