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