mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-29 06:49:19 +08:00
Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f1b51f9c97 | |||
| 65398fb147 | |||
| a8575b4fc7 | |||
| 67ede12fd8 | |||
| e6b5819099 | |||
| 5cd1af5b48 | |||
| 6d1c70b8d3 | |||
| cda28cb2ee | |||
| aac7a0f5af | |||
| 0501cbcf4c | |||
| f08941c0bd | |||
| c1ed2f14c8 | |||
| 3ae5c9dca1 | |||
| ace6ef0029 | |||
| 140724d665 | |||
| c476c255b8 | |||
| cf069970bd | |||
| a8341ec86d | |||
| 23b965a20a | |||
| 2104ba787a | |||
| 15660663f6 | |||
| 4d3e79281d | |||
| 21ff7a36b8 | |||
| 42e2957bee | |||
| bd62da8e1a | |||
| df592d99dd | |||
| 39f5e13463 | |||
| 58785e9470 | |||
| 3495d75a6f | |||
| bee12423b0 | |||
| a705e595ee | |||
| 45f29c4c6f | |||
| 5f90851458 | |||
| 01515f919d | |||
| a2292b1177 | |||
| b2f5f56fa0 | |||
| 2be1e1a70d | |||
| b416cd380a | |||
| f18f54afc6 | |||
| b02830c891 | |||
| aff733bbd9 | |||
| 4a66911a61 | |||
| c9b3a017a4 | |||
| 6712d65de4 | |||
| c2a45cdbeb | |||
| 0f20e58a46 | |||
| 2f37767899 | |||
| f4c7272305 | |||
| 8a8e33763c | |||
| d55eda0bb3 | |||
| 6c7483733f | |||
| c7590c120d | |||
| b3dec3653a | |||
| 7cb42c49de | |||
| 32dffb0375 | |||
| c3d13c73ce | |||
| 0ea48af892 | |||
| 72b09864ce | |||
| 95ac2c62e8 | |||
| ace77e6fd0 |
+1
-1
Submodule cmd/Open-IM-SDK-Core updated: 610fc07d46...3699730514
@@ -33,6 +33,7 @@ func main() {
|
||||
{
|
||||
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo)
|
||||
userRouterGroup.POST("/get_user_info", user.GetUserInfo)
|
||||
userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus)
|
||||
}
|
||||
//friend routing group
|
||||
friendRouterGroup := r.Group("/friend")
|
||||
@@ -94,7 +95,15 @@ func main() {
|
||||
managementGroup.POST("/delete_user", manage.DeleteUser)
|
||||
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
|
||||
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid)
|
||||
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus)
|
||||
}
|
||||
//Conversation
|
||||
conversationGroup := r.Group("/conversation")
|
||||
{
|
||||
conversationGroup.POST("/delete_user", manage.DeleteUser)
|
||||
|
||||
}
|
||||
|
||||
log.NewPrivateLog("api")
|
||||
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
|
||||
flag.Parse()
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_demo
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:
|
||||
make build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/demo/register"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"flag"
|
||||
"github.com/gin-gonic/gin"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
r := gin.Default()
|
||||
r.Use(utils.CorsHandler())
|
||||
|
||||
authRouterGroup := r.Group("/auth")
|
||||
{
|
||||
authRouterGroup.POST("/code", register.SendVerificationCode)
|
||||
authRouterGroup.POST("/verify", register.Verify)
|
||||
authRouterGroup.POST("/password", register.SetPassword)
|
||||
authRouterGroup.POST("/login", register.Login)
|
||||
}
|
||||
log.NewPrivateLog("demo")
|
||||
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
|
||||
flag.Parse()
|
||||
r.Run(utils.ServerIP + ":" + strconv.Itoa(*ginPort))
|
||||
}
|
||||
+38
-2
@@ -79,7 +79,15 @@ rpcport:
|
||||
openImGroupPort: [ 10500 ]
|
||||
openImAuthPort: [ 10600 ]
|
||||
openImPushPort: [ 10700 ]
|
||||
|
||||
c2c:
|
||||
callbackBeforeSendMsg:
|
||||
switch: false
|
||||
timeoutStrategy: 1 #1:send
|
||||
callbackAfterSendMsg:
|
||||
switch: false
|
||||
state:
|
||||
stateChange:
|
||||
switch: false
|
||||
|
||||
rpcregistername:
|
||||
openImUserName: User
|
||||
@@ -139,7 +147,35 @@ tokenpolicy:
|
||||
accessExpire: 7
|
||||
|
||||
messagecallback:
|
||||
callbackSwitch: false
|
||||
callbackUrl: "http://www.xxx.com/msg/judge"
|
||||
#TimeOut use second as unit
|
||||
callbackTimeOut: 10
|
||||
c2c:
|
||||
callbackBeforeSendMsg:
|
||||
switch: false
|
||||
timeoutStrategy: 1 #1:send
|
||||
callbackAfterSendMsg:
|
||||
switch: false
|
||||
state:
|
||||
stateChange:
|
||||
switch: false
|
||||
|
||||
#---------------demo configuration---------------------#
|
||||
#The following configuration items are applied to openIM Demo configuration
|
||||
demoswitch: true
|
||||
demo:
|
||||
openImDemoPort: [ 42233 ]
|
||||
alismsverify:
|
||||
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe71
|
||||
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV1
|
||||
signName: OpenIM Corporation
|
||||
verificationCodeTemplateCode: SMS_2268101641
|
||||
superCode: 666666
|
||||
mail:
|
||||
title: "openIM"
|
||||
senderMail: "1765567899@qq.com"
|
||||
senderAuthorizationCode: "1gxyausfoevlzbfag"
|
||||
smtpAddr: "smtp.qq.com"
|
||||
smtpPort: 25
|
||||
|
||||
|
||||
|
||||
+6
-6
@@ -21,12 +21,12 @@ services:
|
||||
- 37017:27017
|
||||
container_name: mongo
|
||||
volumes:
|
||||
# - ./components/mongodb/data/db:/data/db
|
||||
# - ./components/mongodb/data/logs:/data/logs
|
||||
# - ./components/mongodb/data/conf:/etc/mongo
|
||||
environment:
|
||||
- MONGO_INITDB_ROOT_USERNAME=openIM
|
||||
- MONGO_INITDB_ROOT_PASSWORD=openIM
|
||||
- ./components/mongodb/data/db:/data/db
|
||||
- ./components/mongodb/data/logs:/data/logs
|
||||
- ./components/mongodb/data/conf:/etc/mongo
|
||||
# environment:
|
||||
# - MONGO_INITDB_ROOT_USERNAME=openIM
|
||||
# - MONGO_INITDB_ROOT_PASSWORD=openIM
|
||||
|
||||
#TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
@@ -5,6 +5,9 @@ go 1.15
|
||||
require (
|
||||
github.com/Shopify/sarama v1.19.0
|
||||
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/tea v1.1.17
|
||||
github.com/antonfisher/nested-logrus-formatter v1.3.0
|
||||
github.com/bwmarrin/snowflake v0.3.0
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
@@ -41,6 +44,8 @@ require (
|
||||
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a // indirect
|
||||
google.golang.org/grpc v1.33.2
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||
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
|
||||
|
||||
@@ -7,6 +7,30 @@ 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.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=
|
||||
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 h1:NqugFkGxx1TXSh/pBcU00Y6bljgDPaFdh5MUSeJ7e50=
|
||||
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY=
|
||||
github.com/alibabacloud-go/dysmsapi-20170525 v1.1.2 h1:AiQv4HpDWV0GAXzauPB2Xdrx4cuBo18bqNzIjMJyWjk=
|
||||
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8 h1:KXMiCg99Jx7B6V+DlRFbWwL9UCGippE5z1wGzhyimiA=
|
||||
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.9 h1:Z0DP4LFzkM/rW2nxOMiiLoQVZSeE3jVc5jrZ9Fd/UX0=
|
||||
github.com/alibabacloud-go/openapi-util v0.0.9/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
|
||||
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=
|
||||
github.com/alibabacloud-go/tea v1.1.11/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4=
|
||||
github.com/alibabacloud-go/tea v1.1.15/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy6cujmKFUq98A=
|
||||
github.com/alibabacloud-go/tea v1.1.17 h1:05R5DnaJXe9sCNIe8KUgWHC/z6w/VZIwczgUwzRnul8=
|
||||
github.com/alibabacloud-go/tea v1.1.17/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy6cujmKFUq98A=
|
||||
github.com/alibabacloud-go/tea-utils v1.3.1/go.mod h1:EI/o33aBfj3hETm4RLiAxF/ThQdSngxrpF8rKUDJjPE=
|
||||
github.com/alibabacloud-go/tea-utils v1.3.9 h1:TtbzxS+BXrisA7wzbAMRtlU8A2eWLg0ufm7m/Tl6fc4=
|
||||
github.com/alibabacloud-go/tea-utils v1.3.9/go.mod h1:EI/o33aBfj3hETm4RLiAxF/ThQdSngxrpF8rKUDJjPE=
|
||||
github.com/aliyun/credentials-go v1.1.2 h1:qU1vwGIBb3UJ8BwunHDRFtAhS6jnQLnde/yk0+Ih2GY=
|
||||
github.com/aliyun/credentials-go v1.1.2/go.mod h1:ozcZaMR5kLM7pwtCMEpVmQ242suV6qTJya2bDq4X1Tw=
|
||||
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||
github.com/antonfisher/nested-logrus-formatter v1.3.0 h1:8zixYquU1Odk+vzAaAQPAdRh1ZjmUXNQ1T+dUBvlhVo=
|
||||
github.com/antonfisher/nested-logrus-formatter v1.3.0/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA=
|
||||
@@ -115,6 +139,9 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
@@ -142,6 +169,10 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
@@ -188,6 +219,8 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/olivere/elastic/v7 v7.0.23 h1:b7tjMogDMhf2CisGI+L02LXLVa0ZyE82Z15XfW1e8t8=
|
||||
github.com/olivere/elastic/v7 v7.0.23/go.mod h1:OuWmD2DiuYhddWegBKPWQuelVKBLrW0fa/VUYgxuGTY=
|
||||
@@ -224,8 +257,13 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/assertions v1.1.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
|
||||
github.com/smartystreets/assertions v1.1.1 h1:T/YLemO5Yp7KPzS+lVtu+WsHn8yoSwTfItdAd1r3cck=
|
||||
github.com/smartystreets/assertions v1.1.1/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
|
||||
github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=
|
||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/smartystreets/gunit v1.4.2/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak=
|
||||
github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
@@ -234,14 +272,18 @@ github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4=
|
||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca h1:G/aIr3WiUesWHL2YGYgEqjM5tCAJ43Ml+0C18wDkWWs=
|
||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw=
|
||||
github.com/tjfoc/gmsm v1.3.2 h1:7JVkAn5bvUJ7HtU08iW6UiD+UTmJTIToHCfeFzkcCxM=
|
||||
github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
@@ -252,6 +294,8 @@ github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLY
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.30/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg=
|
||||
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||
@@ -273,6 +317,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@@ -282,6 +328,7 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -294,7 +341,9 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf h1:R150MpwJIv1MpS0N/pc+NhTM8ajzvlmxlY5OYsrevXQ=
|
||||
@@ -303,6 +352,8 @@ golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAG
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -314,6 +365,7 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
|
||||
@@ -330,10 +382,12 @@ golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGm
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -357,11 +411,19 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
|
||||
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
|
||||
gopkg.in/ini.v1 v1.56.0 h1:DPMeDvGTM54DXbPkVIZsp19fp/I2K7zwA/itHYHKo8Y=
|
||||
gopkg.in/ini.v1 v1.56.0/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=
|
||||
|
||||
@@ -8,9 +8,13 @@ package manage
|
||||
|
||||
import (
|
||||
"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"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -24,6 +28,10 @@ type paramsDeleteUsers struct {
|
||||
type paramsGetAllUsersUid struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
type paramsGetUsersOnlineStatus struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UserIDList []string `json:"userIDList" binding:"required,lte=200"`
|
||||
}
|
||||
|
||||
func DeleteUser(c *gin.Context) {
|
||||
params := paramsDeleteUsers{}
|
||||
@@ -80,3 +88,66 @@ func GetAllUsersUid(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
func GetUsersOnlineStatus(c *gin.Context) {
|
||||
params := paramsGetUsersOnlineStatus{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
|
||||
if err != nil {
|
||||
log.ErrorByKv("parse token failed", params.OperationID, "err", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
||||
log.ErrorByKv(" Authentication failed", params.OperationID, "args", c)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 402, "errMsg": "not authorized"})
|
||||
return
|
||||
}
|
||||
req := &pbRelay.GetUsersOnlineStatusReq{
|
||||
OperationID: params.OperationID,
|
||||
UserIDList: params.UserIDList,
|
||||
}
|
||||
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
flag := false
|
||||
log.NewDebug(params.OperationID, "GetUsersOnlineStatus req come here", params.UserIDList)
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
|
||||
for _, v := range grpcCons {
|
||||
client := pbRelay.NewOnlineMessageRelayServiceClient(v)
|
||||
reply, err := client.GetUsersOnlineStatus(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "GetUsersOnlineStatus rpc err", req.String(), err.Error())
|
||||
continue
|
||||
} else {
|
||||
if reply.ErrCode == 0 {
|
||||
wsResult = append(wsResult, reply.SuccessResult...)
|
||||
}
|
||||
}
|
||||
}
|
||||
log.NewDebug(params.OperationID, "call GetUsersOnlineStatus rpc server is success", wsResult)
|
||||
//Online data merge of each node
|
||||
for _, v1 := range params.UserIDList {
|
||||
flag = false
|
||||
temp := new(pbRelay.GetUsersOnlineStatusResp_SuccessResult)
|
||||
for _, v2 := range wsResult {
|
||||
if v2.UserID == v1 {
|
||||
flag = true
|
||||
temp.UserID = v1
|
||||
temp.Status = constant.OnlineStatus
|
||||
temp.DetailPlatformStatus = append(temp.DetailPlatformStatus, v2.DetailPlatformStatus...)
|
||||
}
|
||||
|
||||
}
|
||||
if !flag {
|
||||
temp.UserID = v1
|
||||
temp.Status = constant.OfflineStatus
|
||||
}
|
||||
respResult = append(respResult, temp)
|
||||
}
|
||||
log.NewDebug(params.OperationID, "Finished merged data", respResult)
|
||||
resp := gin.H{"errCode": 0, "errMsg": "", "successResult": respResult}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package user
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -22,6 +24,72 @@ type userInfo struct {
|
||||
Ex string `json:"ex"`
|
||||
}
|
||||
|
||||
type paramsGetUsersOnlineStatus struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UserIDList []string `json:"userIDList" binding:"required,lte=200"`
|
||||
Secret string `json:"secret" binding:"required,max=32"`
|
||||
}
|
||||
|
||||
func GetUsersOnlineStatus(c *gin.Context) {
|
||||
params := paramsGetUsersOnlineStatus{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if params.Secret != config.Config.Secret {
|
||||
log.NewError(params.OperationID, "parse token failed ", params.Secret, config.Config.Secret)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "secret failed"})
|
||||
return
|
||||
}
|
||||
|
||||
req := &pbRelay.GetUsersOnlineStatusReq{
|
||||
OperationID: params.OperationID,
|
||||
UserIDList: params.UserIDList,
|
||||
}
|
||||
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
flag := false
|
||||
log.NewDebug(params.OperationID, "GetUsersOnlineStatus req come here", params.UserIDList)
|
||||
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
|
||||
for _, v := range grpcCons {
|
||||
client := pbRelay.NewOnlineMessageRelayServiceClient(v)
|
||||
reply, err := client.GetUsersOnlineStatus(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "GetUsersOnlineStatus rpc err", req.String(), err.Error())
|
||||
continue
|
||||
} else {
|
||||
if reply.ErrCode == 0 {
|
||||
wsResult = append(wsResult, reply.SuccessResult...)
|
||||
}
|
||||
}
|
||||
}
|
||||
log.NewDebug(params.OperationID, "call GetUsersOnlineStatus rpc server is success", wsResult)
|
||||
//Online data merge of each node
|
||||
for _, v1 := range params.UserIDList {
|
||||
flag = false
|
||||
temp := new(pbRelay.GetUsersOnlineStatusResp_SuccessResult)
|
||||
for _, v2 := range wsResult {
|
||||
if v2.UserID == v1 {
|
||||
flag = true
|
||||
temp.UserID = v1
|
||||
temp.Status = constant.OnlineStatus
|
||||
temp.DetailPlatformStatus = append(temp.DetailPlatformStatus, v2.DetailPlatformStatus...)
|
||||
}
|
||||
}
|
||||
if !flag {
|
||||
temp.UserID = v1
|
||||
temp.Status = constant.OfflineStatus
|
||||
}
|
||||
respResult = append(respResult, temp)
|
||||
}
|
||||
log.NewDebug(params.OperationID, "Finished merged data", respResult)
|
||||
resp := gin.H{"errCode": 0, "errMsg": "", "successResult": respResult}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetUserInfo(c *gin.Context) {
|
||||
log.InfoByKv("api get userinfo init...", "")
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ParamsLogin struct {
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
Password string `json:"password"`
|
||||
Platform int32 `json:"platform"`
|
||||
}
|
||||
|
||||
func Login(c *gin.Context) {
|
||||
log.NewDebug("Login api is statrting...")
|
||||
params := ParamsLogin{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var account string
|
||||
if params.Email != "" {
|
||||
account = params.Email
|
||||
} else {
|
||||
account = params.PhoneNumber
|
||||
}
|
||||
|
||||
log.InfoByKv("api Login get params", account)
|
||||
|
||||
queryParams := im_mysql_model.Register{
|
||||
Account: account,
|
||||
Password: params.Password,
|
||||
}
|
||||
|
||||
canLogin := im_mysql_model.Login(&queryParams)
|
||||
if canLogin == 1 {
|
||||
log.ErrorByKv("Incorrect phone number password", account, "err", "Mobile phone number is not registered")
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Mobile phone number is not registered"})
|
||||
return
|
||||
}
|
||||
if canLogin == 2 {
|
||||
log.ErrorByKv("Incorrect phone number password", account, "err", "Incorrect password")
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Incorrect password"})
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := OpenIMToken(account, params.Platform)
|
||||
if err != nil {
|
||||
log.ErrorByKv("get token by phone number err", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
response, err := ioutil.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
log.ErrorByKv("Failed to read file", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IoErrot, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
imRep := IMRegisterResp{}
|
||||
err = json.Unmarshal(response, &imRep)
|
||||
if err != nil {
|
||||
log.ErrorByKv("json parsing failed", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if imRep.ErrCode != 0 {
|
||||
log.ErrorByKv("openIM Login request failed", account, "err")
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": imRep.ErrMsg})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": imRep.Data})
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func OpenIMToken(Account string, platform int32) (*http.Response, error) {
|
||||
url := fmt.Sprintf("http://%s:10000/auth/user_token", utils.ServerIP)
|
||||
|
||||
client := &http.Client{}
|
||||
params := make(map[string]interface{})
|
||||
|
||||
params["secret"] = config.Config.Secret
|
||||
params["platform"] = platform
|
||||
params["uid"] = Account
|
||||
con, err := json.Marshal(params)
|
||||
if err != nil {
|
||||
log.ErrorByKv("json parsing failed", Account, "err", err.Error())
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(con)))
|
||||
if err != nil {
|
||||
log.ErrorByKv("request error", "/auth/user_token", "err", err.Error())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
return resp, err
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"fmt"
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
|
||||
dysmsapi20170525 "github.com/alibabacloud-go/dysmsapi-20170525/v2/client"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gopkg.in/gomail.v2"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type paramsVerificationCode struct {
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
}
|
||||
|
||||
func SendVerificationCode(c *gin.Context) {
|
||||
log.InfoByKv("sendCode api is statrting...", "")
|
||||
params := paramsVerificationCode{}
|
||||
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.ErrorByKv("request params json parsing failed", params.PhoneNumber, params.Email, "err", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var account string
|
||||
if params.Email != "" {
|
||||
account = params.Email
|
||||
} else {
|
||||
account = params.PhoneNumber
|
||||
}
|
||||
|
||||
queryParams := im_mysql_model.GetRegisterParams{
|
||||
Account: account,
|
||||
}
|
||||
_, err, rowsAffected := im_mysql_model.GetRegister(&queryParams)
|
||||
|
||||
if err == nil && rowsAffected != 0 {
|
||||
log.ErrorByKv("The phone number has been registered", queryParams.Account, "err")
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "The phone number has been registered"})
|
||||
return
|
||||
}
|
||||
|
||||
log.InfoByKv("begin sendSms", account)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
code := 100000 + rand.Intn(900000)
|
||||
log.NewDebug("", config.Config.Demo)
|
||||
if params.Email != "" {
|
||||
m := gomail.NewMessage()
|
||||
m.SetHeader(`From`, config.Config.Demo.Mail.SenderMail)
|
||||
m.SetHeader(`To`, []string{account}...)
|
||||
m.SetHeader(`Subject`, config.Config.Demo.Mail.Title)
|
||||
m.SetBody(`text/html`, fmt.Sprintf("%d", code))
|
||||
if err := gomail.NewDialer(config.Config.Demo.Mail.SmtpAddr, config.Config.Demo.Mail.SmtpPort, config.Config.Demo.Mail.SenderMail, config.Config.Demo.Mail.SenderAuthorizationCode).DialAndSend(m); err != nil {
|
||||
log.ErrorByKv("send mail error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
} else {
|
||||
client, err := CreateClient(tea.String(config.Config.Demo.AliSMSVerify.AccessKeyID), tea.String(config.Config.Demo.AliSMSVerify.AccessKeySecret))
|
||||
if err != nil {
|
||||
log.ErrorByKv("create sendSms client err", "", "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
|
||||
sendSmsRequest := &dysmsapi20170525.SendSmsRequest{
|
||||
PhoneNumbers: tea.String(account),
|
||||
SignName: tea.String(config.Config.Demo.AliSMSVerify.SignName),
|
||||
TemplateCode: tea.String(config.Config.Demo.AliSMSVerify.VerificationCodeTemplateCode),
|
||||
TemplateParam: tea.String(fmt.Sprintf("{\"code\":\"%d\"}", code)),
|
||||
}
|
||||
|
||||
response, err := client.SendSms(sendSmsRequest)
|
||||
if err != nil {
|
||||
log.ErrorByKv("sendSms error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
if *response.Body.Code != "OK" {
|
||||
log.ErrorByKv("alibabacloud sendSms error", account, "err", response.Body.Code, response.Body.Message)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
log.InfoByKv("begin store redis", account)
|
||||
v, err := redis.Int(db.DB.Exec("TTL", account))
|
||||
if err != nil {
|
||||
log.ErrorByKv("get account from redis error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
switch {
|
||||
case v == -2:
|
||||
_, err = db.DB.Exec("SET", account, code, "EX", 600)
|
||||
if err != nil {
|
||||
log.ErrorByKv("set redis error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enter the superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verification code sent successfully!", "data": data})
|
||||
log.InfoByKv("send new verification code", account)
|
||||
return
|
||||
case v > 540:
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Frequent operation!", "data": data})
|
||||
log.InfoByKv("frequent operation", account)
|
||||
return
|
||||
case v < 540:
|
||||
_, err = db.DB.Exec("SET", account, code, "EX", 600)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IntentionalError, "errMsg": "Enterthe superCode directly in the verification code box, SuperCode can be configured in config.xml"})
|
||||
return
|
||||
}
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verification code has been reset!", "data": data})
|
||||
log.InfoByKv("Reset verification code", account)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func CreateClient(accessKeyId *string, accessKeySecret *string) (result *dysmsapi20170525.Client, err error) {
|
||||
c := &openapi.Config{
|
||||
// 您的AccessKey ID
|
||||
AccessKeyId: accessKeyId,
|
||||
// 您的AccessKey Secret
|
||||
AccessKeySecret: accessKeySecret,
|
||||
}
|
||||
|
||||
// 访问的域名
|
||||
c.Endpoint = tea.String("dysmsapi.aliyuncs.com")
|
||||
result = &dysmsapi20170525.Client{}
|
||||
result, err = dysmsapi20170525.NewClient(c)
|
||||
return result, err
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ParamsSetPassword struct {
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
Password string `json:"password"`
|
||||
VerificationCode string `json:"verificationCode"`
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
ExpiredTime int64 `json:"expiredTime"`
|
||||
Token string `json:"token"`
|
||||
Uid string `json:"uid"`
|
||||
}
|
||||
|
||||
type IMRegisterResp struct {
|
||||
Data Data `json:"data"`
|
||||
ErrCode int32 `json:"errCode"`
|
||||
ErrMsg string `json:"errMsg"`
|
||||
}
|
||||
|
||||
func SetPassword(c *gin.Context) {
|
||||
log.InfoByKv("setPassword api is statrting...", "")
|
||||
params := ParamsSetPassword{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var account string
|
||||
if params.Email != "" {
|
||||
account = params.Email
|
||||
} else {
|
||||
account = params.PhoneNumber
|
||||
}
|
||||
|
||||
log.InfoByKv("begin store redis", account)
|
||||
v, err := redis.String(db.DB.Exec("GET", account))
|
||||
|
||||
if params.VerificationCode == config.Config.Demo.SuperCode {
|
||||
goto openIMRegisterTab
|
||||
}
|
||||
|
||||
fmt.Println("Get Redis:", v, err)
|
||||
if err != nil {
|
||||
log.ErrorByKv("password Verification code expired", account, "err", err.Error())
|
||||
data := make(map[string]interface{})
|
||||
data["phoneNumber"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Verification expired!", "data": data})
|
||||
return
|
||||
}
|
||||
if v != params.VerificationCode {
|
||||
log.InfoByKv("password Verification code error", account, params.VerificationCode)
|
||||
data := make(map[string]interface{})
|
||||
data["PhoneNumber"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Verification code error!", "data": data})
|
||||
return
|
||||
}
|
||||
|
||||
openIMRegisterTab:
|
||||
log.InfoByKv("openIM register begin", account)
|
||||
resp, err := OpenIMRegister(account)
|
||||
|
||||
log.InfoByKv("openIM register resp", account, resp, err)
|
||||
if err != nil {
|
||||
log.ErrorByKv("request openIM register error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
response, err := ioutil.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.IoErrot, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
imrep := IMRegisterResp{}
|
||||
err = json.Unmarshal(response, &imrep)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if imrep.ErrCode != 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HttpError, "errMsg": imrep.ErrMsg})
|
||||
return
|
||||
}
|
||||
|
||||
queryParams := im_mysql_model.SetPasswordParams{
|
||||
Account: account,
|
||||
Password: params.Password,
|
||||
}
|
||||
|
||||
log.InfoByKv("begin store mysql", account, params.Password)
|
||||
_, err = im_mysql_model.SetPassword(&queryParams)
|
||||
if err != nil {
|
||||
log.ErrorByKv("set phone number password error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.DatabaseError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
log.InfoByKv("end setPassword", account)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": imrep.Data})
|
||||
return
|
||||
}
|
||||
|
||||
func OpenIMRegister(account string) (*http.Response, error) {
|
||||
url := fmt.Sprintf("http://%s:10000/auth/user_register", utils.ServerIP)
|
||||
fmt.Println("1:", config.Config.Secret)
|
||||
|
||||
client := &http.Client{}
|
||||
|
||||
params := make(map[string]interface{})
|
||||
|
||||
params["secret"] = config.Config.Secret
|
||||
params["platform"] = 2
|
||||
params["uid"] = account
|
||||
params["name"] = account
|
||||
params["icon"] = ""
|
||||
params["gender"] = 0
|
||||
|
||||
params["mobile"] = ""
|
||||
|
||||
params["email"] = ""
|
||||
params["birth"] = ""
|
||||
params["ex"] = ""
|
||||
con, err := json.Marshal(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.InfoByKv("openIM register params", account, params)
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(con)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type paramsCertification struct {
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
VerificationCode string `json:"verificationCode"`
|
||||
}
|
||||
|
||||
func Verify(c *gin.Context) {
|
||||
log.InfoByKv("Verify api is statrting...", "")
|
||||
params := paramsCertification{}
|
||||
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.ErrorByKv("request params json parsing failed", "", "err", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var account string
|
||||
if params.Email != "" {
|
||||
account = params.Email
|
||||
} else {
|
||||
account = params.PhoneNumber
|
||||
}
|
||||
|
||||
if params.VerificationCode == config.Config.Demo.SuperCode {
|
||||
log.InfoByKv("Super Code Verified successfully", account)
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
data["verificationCode"] = params.VerificationCode
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verified successfully!", "data": data})
|
||||
return
|
||||
}
|
||||
|
||||
log.InfoByKv("begin get form redis", account)
|
||||
v, err := redis.String(db.DB.Exec("GET", account))
|
||||
log.InfoByKv("redis phone number and verificating Code", account, v)
|
||||
if err != nil {
|
||||
log.ErrorByKv("Verification code expired", account, "err", err.Error())
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Verification code expired!", "data": data})
|
||||
return
|
||||
}
|
||||
if params.VerificationCode == v {
|
||||
log.InfoByKv("Verified successfully", account)
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
data["verificationCode"] = params.VerificationCode
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verified successfully!", "data": data})
|
||||
return
|
||||
} else {
|
||||
log.InfoByKv("Verification code error", account, params.VerificationCode)
|
||||
data := make(map[string]interface{})
|
||||
data["account"] = account
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.LogicalError, "errMsg": "Verification code error!", "data": data})
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,31 @@ func (r *RPCServer) MsgToUser(_ context.Context, in *pbRelay.MsgToUserReq) (*pbR
|
||||
Resp: resp,
|
||||
}, nil
|
||||
}
|
||||
func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUsersOnlineStatusReq) (*pbRelay.GetUsersOnlineStatusResp, error) {
|
||||
log.NewDebug(req.OperationID, "rpc GetUsersOnlineStatus arrived server", req.String())
|
||||
var UIDAndPID []string
|
||||
var resp pbRelay.GetUsersOnlineStatusResp
|
||||
for _, v1 := range req.UserIDList {
|
||||
userIDList := genUidPlatformArray(v1)
|
||||
temp := new(pbRelay.GetUsersOnlineStatusResp_SuccessResult)
|
||||
temp.UserID = v1
|
||||
for _, v2 := range userIDList {
|
||||
UIDAndPID = strings.Split(v2, " ")
|
||||
if conn := ws.getUserConn(v2); conn != nil {
|
||||
ps := new(pbRelay.GetUsersOnlineStatusResp_SuccessDetail)
|
||||
ps.Platform = UIDAndPID[1]
|
||||
ps.Status = constant.OnlineStatus
|
||||
temp.Status = constant.OnlineStatus
|
||||
temp.DetailPlatformStatus = append(temp.DetailPlatformStatus, ps)
|
||||
|
||||
}
|
||||
}
|
||||
if temp.Status == constant.OnlineStatus {
|
||||
resp.SuccessResult = append(resp.SuccessResult, temp)
|
||||
}
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
func sendMsgToUser(conn *UserConn, bMsg []byte, in *pbRelay.MsgToUserReq, RecvPlatForm, RecvID string) (ResultCode int64) {
|
||||
err := ws.writeMsg(conn, websocket.BinaryMessage, bMsg)
|
||||
if err != nil {
|
||||
|
||||
@@ -48,8 +48,9 @@ func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) {
|
||||
reply, err := msgClient.MsgToUser(context.Background(), sendPbData)
|
||||
if err != nil {
|
||||
log.InfoByKv("push data to client rpc err", sendPbData.OperationID, "err", err)
|
||||
continue
|
||||
}
|
||||
if reply != nil && reply.Resp != nil && err == nil {
|
||||
if reply != nil && reply.Resp != nil {
|
||||
wsResult = append(wsResult, reply.Resp...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,3 +81,9 @@ func Test_ParseToken(t *testing.T) {
|
||||
assert.Equal(t, claims.UID, uid)
|
||||
}
|
||||
}
|
||||
func Test_GetClaimFromToken(t *testing.T) {
|
||||
token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVSUQiOiJvcGVuSU0xMjM0NTYiLCJQbGF0Zm9ybSI6IiIsImV4cCI6MTYzODg0NjQ3NiwibmJmIjoxNjM4MjQxNjc2LCJpYXQiOjE2MzgyNDE2NzZ9.W8RZB7ec5ySFj-rGE2Aho2z32g3MprQMdCyPiQu_C2I"
|
||||
c, err := token_verify.GetClaimFromToken(token)
|
||||
assert.Nil(t, c)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
@@ -155,6 +155,23 @@ type config struct {
|
||||
CallbackUrl string `yaml:"callbackUrl"`
|
||||
CallBackTimeOut int `yaml:"callbackTimeOut"`
|
||||
}
|
||||
Demo struct {
|
||||
Port []int `yaml:"openImDemoPort"`
|
||||
AliSMSVerify struct {
|
||||
AccessKeyID string `yaml:"accessKeyId"`
|
||||
AccessKeySecret string `yaml:"accessKeySecret"`
|
||||
SignName string `yaml:"signName"`
|
||||
VerificationCodeTemplateCode string `yaml:"verificationCodeTemplateCode"`
|
||||
}
|
||||
SuperCode string `yaml:"superCode"`
|
||||
Mail struct {
|
||||
Title string `yaml:"title"`
|
||||
SenderMail string `yaml:"senderMail"`
|
||||
SenderAuthorizationCode string `yaml:"senderAuthorizationCode"`
|
||||
SmtpAddr string `yaml:"smtpAddr"`
|
||||
SmtpPort int `yaml:"smtpPort"`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -164,10 +181,10 @@ func init() {
|
||||
// it will panic cannot find config/config.yaml
|
||||
bytes, err := ioutil.ReadFile(Root + "/config/config.yaml")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
if err = yaml.Unmarshal(bytes, &Config); err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -86,6 +86,9 @@ const (
|
||||
WebAndOther = 3
|
||||
//Pc端互斥,移动端互斥,但是web端可以同时在线
|
||||
PcMobileAndWeb = 4
|
||||
|
||||
OnlineStatus = "online"
|
||||
OfflineStatus = "offline"
|
||||
)
|
||||
|
||||
var ContentType2PushContent = map[int64]string{
|
||||
|
||||
@@ -60,6 +60,17 @@ var (
|
||||
TokenUnknown = errors.New("couldn't handle this token")
|
||||
)
|
||||
|
||||
const (
|
||||
NoError = 0
|
||||
FormattingError = 10001
|
||||
DatabaseError = 10002
|
||||
LogicalError = 10003
|
||||
ServerError = 10004
|
||||
HttpError = 10005
|
||||
IoErrot = 10006
|
||||
IntentionalError = 10007
|
||||
)
|
||||
|
||||
func (e *ErrInfo) Error() string {
|
||||
return e.ErrMsg
|
||||
}
|
||||
|
||||
+12
-2
@@ -2,6 +2,7 @@ package db
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"gopkg.in/mgo.v2"
|
||||
"time"
|
||||
@@ -20,6 +21,8 @@ func key(dbAddress, dbName string) string {
|
||||
}
|
||||
|
||||
func init() {
|
||||
var mgoSession *mgo.Session
|
||||
var err1 error
|
||||
//mysql init
|
||||
initMysqlDB()
|
||||
// mongo init
|
||||
@@ -35,14 +38,21 @@ func init() {
|
||||
}
|
||||
mgoSession, err := mgo.DialWithInfo(mgoDailInfo)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.NewError("mgo init err", err.Error(), mgoDailInfo)
|
||||
}
|
||||
if err != nil {
|
||||
time.Sleep(time.Duration(30) * time.Second)
|
||||
mgoSession, err1 = mgo.DialWithInfo(mgoDailInfo)
|
||||
if err1 != nil {
|
||||
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)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
// redis pool init
|
||||
|
||||
+30
-14
@@ -19,18 +19,24 @@ func initMysqlDB() {
|
||||
//When there is no open IM database, connect to the mysql built-in database to create openIM database
|
||||
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
|
||||
config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], "mysql")
|
||||
|
||||
var db *gorm.DB
|
||||
var err1 error
|
||||
db, err := gorm.Open("mysql", dsn)
|
||||
if err != nil {
|
||||
log.Error("", "", dsn)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
time.Sleep(time.Duration(30) * time.Second)
|
||||
db, err1 = gorm.Open("mysql", dsn)
|
||||
if err1 != nil {
|
||||
panic(err1.Error())
|
||||
}
|
||||
}
|
||||
//Check the database and table during initialization
|
||||
sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s ;", config.Config.Mysql.DBDatabaseName)
|
||||
err = db.Exec(sql).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
db.Close()
|
||||
|
||||
@@ -38,7 +44,7 @@ func initMysqlDB() {
|
||||
config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName)
|
||||
db, err = gorm.Open("mysql", dsn)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
sqlTable := "CREATE TABLE IF NOT EXISTS `user` (" +
|
||||
@@ -56,7 +62,7 @@ func initMysqlDB() {
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `friend` (" +
|
||||
@@ -69,7 +75,7 @@ func initMysqlDB() {
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `friend_request` (" +
|
||||
@@ -82,7 +88,7 @@ func initMysqlDB() {
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `black_list` (" +
|
||||
@@ -94,7 +100,7 @@ func initMysqlDB() {
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `user_black_list` (" +
|
||||
@@ -105,7 +111,7 @@ func initMysqlDB() {
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `group` (" +
|
||||
@@ -120,7 +126,7 @@ func initMysqlDB() {
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `group_member` (" +
|
||||
@@ -134,7 +140,7 @@ func initMysqlDB() {
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `group_request` (" +
|
||||
@@ -155,7 +161,7 @@ func initMysqlDB() {
|
||||
" ) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8mb4;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `chat_log` (" +
|
||||
@@ -173,7 +179,17 @@ func initMysqlDB() {
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `register` (" +
|
||||
" `account` varchar(255) NOT NULL," +
|
||||
" `password` varchar(255) NOT NULL," +
|
||||
" PRIMARY KEY (`account`) USING BTREE" +
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
_ "github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
type GetRegisterParams struct {
|
||||
Account string `json:"account"`
|
||||
}
|
||||
type Register struct {
|
||||
Account string `gorm:"column:account"`
|
||||
Password string `gorm:"column:password"`
|
||||
}
|
||||
|
||||
func GetRegister(params *GetRegisterParams) (Register, error, int64) {
|
||||
var r Register
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return r, err, 0
|
||||
}
|
||||
result := dbConn.
|
||||
Where(&Register{Account: params.Account}).
|
||||
Find(&r)
|
||||
return r, result.Error, result.RowsAffected
|
||||
}
|
||||
|
||||
type SetPasswordParams struct {
|
||||
Account string `json:"account"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
func SetPassword(params *SetPasswordParams) (Register, error) {
|
||||
r := Register{
|
||||
Account: params.Account,
|
||||
Password: params.Password,
|
||||
}
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return r, err
|
||||
}
|
||||
|
||||
result := dbConn.Create(&r)
|
||||
|
||||
return r, result.Error
|
||||
}
|
||||
|
||||
func Login(params *Register) int64 {
|
||||
var r Register
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return 3
|
||||
}
|
||||
result := dbConn.
|
||||
Where(&Register{Account: params.Account}).
|
||||
Find(&r)
|
||||
if result.Error != nil && result.RowsAffected == 0 {
|
||||
return 1
|
||||
}
|
||||
if r.Password != params.Password {
|
||||
return 2
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func FindGroupMemberInfoByGroupIdAndUserId(groupId, uid string) (*GroupMember, e
|
||||
return nil, err
|
||||
}
|
||||
var groupMember GroupMember
|
||||
err = dbConn.Raw("select * from `group_member` where group_id=? and uid=? limit 1", groupId, uid).Scan(&groupMember).Error
|
||||
err = dbConn.Raw("select * from `group_member` where group_id=? and uid=? limit 1", groupId, uid).Find(&groupMember).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -121,7 +121,10 @@ func SelectAllUID() ([]string, error) {
|
||||
if err != nil {
|
||||
return uid, err
|
||||
}
|
||||
rows, _ := dbConn.Raw("select uid from user").Rows()
|
||||
rows, err := dbConn.Raw("select uid from user").Rows()
|
||||
if err != nil {
|
||||
return uid, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var strUID string
|
||||
for rows.Next() {
|
||||
|
||||
@@ -3,7 +3,6 @@ package db
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
log2 "Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
)
|
||||
|
||||
@@ -12,7 +11,7 @@ const (
|
||||
appleDeviceToken = "DEVICE_TOKEN"
|
||||
lastGetSeq = "LAST_GET_SEQ"
|
||||
userMinSeq = "REDIS_USER_MIN_SEQ:"
|
||||
uidPidToken = "UID_PID_TOKEN:"
|
||||
uidPidToken = "UID_PID_TOKEN_STATUS:"
|
||||
)
|
||||
|
||||
func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (interface{}, error) {
|
||||
@@ -77,38 +76,19 @@ func (d *DataBases) DelAppleDeviceToken(accountAddress string) (err error) {
|
||||
//Store userid and platform class to redis
|
||||
func (d *DataBases) AddTokenFlag(userID string, platformID int32, token string, flag int) error {
|
||||
key := uidPidToken + userID + ":" + constant.PlatformIDToName(platformID)
|
||||
var m map[string]int
|
||||
m = make(map[string]int)
|
||||
ls, err := redis.String(d.Exec("GET", key))
|
||||
if err != nil && err != redis.ErrNil {
|
||||
return err
|
||||
}
|
||||
if err == redis.ErrNil {
|
||||
} else {
|
||||
_ = utils.JsonStringToStruct(ls, &m)
|
||||
}
|
||||
m[token] = flag
|
||||
s := utils.StructToJsonString(m)
|
||||
_, err1 := d.Exec("SET", key, s)
|
||||
log2.NewDebug("", "add token key is ", key)
|
||||
_, err1 := d.Exec("HSet", key, token, flag)
|
||||
return err1
|
||||
}
|
||||
|
||||
func (d *DataBases) GetTokenMapByUidPid(userID, platformID string) (m map[string]int, e error) {
|
||||
func (d *DataBases) GetTokenMapByUidPid(userID, platformID string) (map[string]int, error) {
|
||||
key := uidPidToken + userID + ":" + platformID
|
||||
log2.NewDebug("", "key is ", key)
|
||||
s, e := redis.String(d.Exec("GET", key))
|
||||
if e != nil {
|
||||
return nil, e
|
||||
} else {
|
||||
m = make(map[string]int)
|
||||
_ = utils.JsonStringToStruct(s, &m)
|
||||
return m, nil
|
||||
}
|
||||
log2.NewDebug("", "get token key is ", key)
|
||||
return redis.IntMap(d.Exec("HGETALL", key))
|
||||
}
|
||||
func (d *DataBases) SetTokenMapByUidPid(userID string, platformID int32, m map[string]int) error {
|
||||
key := uidPidToken + userID + ":" + constant.PlatformIDToName(platformID)
|
||||
s := utils.StructToJsonString(m)
|
||||
_, err := d.Exec("SET", key, s)
|
||||
_, err := d.Exec("hmset", key, redis.Args{}.Add().AddFlat(m)...)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_SetTokenMapByUidPid(t *testing.T) {
|
||||
m := make(map[string]int, 0)
|
||||
m["test1"] = 1
|
||||
m["test2"] = 2
|
||||
m["2332"] = 4
|
||||
_ = DB.SetTokenMapByUidPid("1234", 2, m)
|
||||
|
||||
}
|
||||
func Test_GetTokenMapByUidPid(t *testing.T) {
|
||||
m, err := DB.GetTokenMapByUidPid("1234", "Android")
|
||||
assert.Nil(t, err)
|
||||
fmt.Println(m)
|
||||
}
|
||||
@@ -20,14 +20,14 @@ func NewKafkaConsumer(addr []string, topic string) *Consumer {
|
||||
|
||||
consumer, err := sarama.NewConsumer(p.addr, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
return nil
|
||||
}
|
||||
p.Consumer = consumer
|
||||
|
||||
partitionList, err := consumer.Partitions(p.Topic)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
return nil
|
||||
}
|
||||
p.PartitionList = partitionList
|
||||
|
||||
@@ -30,11 +30,11 @@ func NewMConsumerGroup(consumerConfig *MConsumerGroupConfig, topics, addr []stri
|
||||
config.Consumer.Return.Errors = consumerConfig.IsReturnErr
|
||||
client, err := sarama.NewClient(addr, config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
consumerGroup, err := sarama.NewConsumerGroupFromClient(groupID, client)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
return &MConsumerGroup{
|
||||
consumerGroup,
|
||||
@@ -47,7 +47,7 @@ func (mc *MConsumerGroup) RegisterHandleAndConsumer(handler sarama.ConsumerGroup
|
||||
for {
|
||||
err := mc.ConsumerGroup.Consume(ctx, mc.topics, handler)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func NewKafkaProducer(addr []string, topic string) *Producer {
|
||||
|
||||
producer, err := sarama.NewSyncProducer(p.addr, p.config) //Initialize the client
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
return nil
|
||||
}
|
||||
p.producer = producer
|
||||
|
||||
@@ -61,19 +61,18 @@ func newEsHook(moduleName string) *esHook {
|
||||
return &esHook{client: es, moduleName: moduleName}
|
||||
}
|
||||
|
||||
//Fire log hook interface 方法
|
||||
//Fire log hook interface
|
||||
func (hook *esHook) Fire(entry *logrus.Entry) error {
|
||||
doc := newEsLog(entry)
|
||||
go hook.sendEs(doc)
|
||||
return nil
|
||||
}
|
||||
|
||||
//Levels log hook interface 方法,此hook影响的日志
|
||||
func (hook *esHook) Levels() []logrus.Level {
|
||||
return logrus.AllLevels
|
||||
}
|
||||
|
||||
//sendEs 异步发送日志到es
|
||||
//sendEs
|
||||
func (hook *esHook) sendEs(doc appLogDocModel) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -102,7 +101,7 @@ func newEsLog(e *logrus.Entry) appLogDocModel {
|
||||
return ins
|
||||
}
|
||||
|
||||
// indexName es index name 时间分割
|
||||
// indexName es index name
|
||||
func (m *appLogDocModel) indexName() string {
|
||||
return time.Now().Format("2006-01-02")
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func loggerInit(moduleName string) *Logger {
|
||||
//Close std console output
|
||||
src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
writer := bufio.NewWriter(src)
|
||||
logger.SetOutput(writer)
|
||||
@@ -82,7 +82,7 @@ func initRotateLogs(rotationTime time.Duration, maxRemainNum uint, level string,
|
||||
rotatelogs.WithRotationCount(maxRemainNum),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return writer
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func secret() jwt.Keyfunc {
|
||||
}
|
||||
}
|
||||
|
||||
func getClaimFromToken(tokensString string) (*Claims, error) {
|
||||
func GetClaimFromToken(tokensString string) (*Claims, error) {
|
||||
token, err := jwt.ParseWithClaims(tokensString, &Claims{}, secret())
|
||||
if err != nil {
|
||||
if ve, ok := err.(*jwt.ValidationError); ok {
|
||||
@@ -82,7 +82,7 @@ func getClaimFromToken(tokensString string) (*Claims, error) {
|
||||
|
||||
func ParseToken(tokensString string) (claims *Claims, err error) {
|
||||
|
||||
claims, err = getClaimFromToken(tokensString)
|
||||
claims, err = GetClaimFromToken(tokensString)
|
||||
if err != nil {
|
||||
log.NewError("", "token validate err", err.Error())
|
||||
return nil, err
|
||||
@@ -112,7 +112,7 @@ func ParseToken(tokensString string) (claims *Claims, err error) {
|
||||
return nil, &constant.ErrTokenUnknown
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
return nil, &constant.ErrTokenUnknown
|
||||
}
|
||||
|
||||
//func MakeTheTokenInvalid(currentClaims *Claims, platformClass string) (bool, error) {
|
||||
@@ -132,7 +132,7 @@ func ParseToken(tokensString string) (claims *Claims, err error) {
|
||||
//}
|
||||
|
||||
func ParseRedisInterfaceToken(redisToken interface{}) (*Claims, error) {
|
||||
return getClaimFromToken(string(redisToken.([]uint8)))
|
||||
return GetClaimFromToken(string(redisToken.([]uint8)))
|
||||
}
|
||||
|
||||
//Validation token, false means failure, true means successful verification
|
||||
|
||||
+350
-32
@@ -47,7 +47,7 @@ func (m *MsgToUserReq) Reset() { *m = MsgToUserReq{} }
|
||||
func (m *MsgToUserReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgToUserReq) ProtoMessage() {}
|
||||
func (*MsgToUserReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_relay_ff2396ffa84abfa7, []int{0}
|
||||
return fileDescriptor_relay_709d2b3cc3a7ad83, []int{0}
|
||||
}
|
||||
func (m *MsgToUserReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_MsgToUserReq.Unmarshal(m, b)
|
||||
@@ -176,7 +176,7 @@ func (m *MsgToUserResp) Reset() { *m = MsgToUserResp{} }
|
||||
func (m *MsgToUserResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgToUserResp) ProtoMessage() {}
|
||||
func (*MsgToUserResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_relay_ff2396ffa84abfa7, []int{1}
|
||||
return fileDescriptor_relay_709d2b3cc3a7ad83, []int{1}
|
||||
}
|
||||
func (m *MsgToUserResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_MsgToUserResp.Unmarshal(m, b)
|
||||
@@ -227,7 +227,7 @@ func (m *SingleMsgToUser) Reset() { *m = SingleMsgToUser{} }
|
||||
func (m *SingleMsgToUser) String() string { return proto.CompactTextString(m) }
|
||||
func (*SingleMsgToUser) ProtoMessage() {}
|
||||
func (*SingleMsgToUser) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_relay_ff2396ffa84abfa7, []int{2}
|
||||
return fileDescriptor_relay_709d2b3cc3a7ad83, []int{2}
|
||||
}
|
||||
func (m *SingleMsgToUser) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SingleMsgToUser.Unmarshal(m, b)
|
||||
@@ -268,10 +268,281 @@ func (m *SingleMsgToUser) GetRecvPlatFormID() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
type GetUsersOnlineStatusReq struct {
|
||||
UserIDList []string `protobuf:"bytes,1,rep,name=userIDList" json:"userIDList,omitempty"`
|
||||
OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusReq) Reset() { *m = GetUsersOnlineStatusReq{} }
|
||||
func (m *GetUsersOnlineStatusReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetUsersOnlineStatusReq) ProtoMessage() {}
|
||||
func (*GetUsersOnlineStatusReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_relay_709d2b3cc3a7ad83, []int{3}
|
||||
}
|
||||
func (m *GetUsersOnlineStatusReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetUsersOnlineStatusReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetUsersOnlineStatusReq.Merge(dst, src)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusReq) XXX_Size() int {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusReq.Size(m)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetUsersOnlineStatusReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetUsersOnlineStatusReq proto.InternalMessageInfo
|
||||
|
||||
func (m *GetUsersOnlineStatusReq) GetUserIDList() []string {
|
||||
if m != nil {
|
||||
return m.UserIDList
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusReq) GetOperationID() string {
|
||||
if m != nil {
|
||||
return m.OperationID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetUsersOnlineStatusResp struct {
|
||||
ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"`
|
||||
ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"`
|
||||
SuccessResult []*GetUsersOnlineStatusResp_SuccessResult `protobuf:"bytes,3,rep,name=successResult" json:"successResult,omitempty"`
|
||||
FailedResult []*GetUsersOnlineStatusResp_FailedDetail `protobuf:"bytes,4,rep,name=failedResult" json:"failedResult,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp) Reset() { *m = GetUsersOnlineStatusResp{} }
|
||||
func (m *GetUsersOnlineStatusResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetUsersOnlineStatusResp) ProtoMessage() {}
|
||||
func (*GetUsersOnlineStatusResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_relay_709d2b3cc3a7ad83, []int{4}
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetUsersOnlineStatusResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetUsersOnlineStatusResp.Merge(dst, src)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp) XXX_Size() int {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp.Size(m)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetUsersOnlineStatusResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetUsersOnlineStatusResp proto.InternalMessageInfo
|
||||
|
||||
func (m *GetUsersOnlineStatusResp) GetErrCode() int32 {
|
||||
if m != nil {
|
||||
return m.ErrCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp) GetErrMsg() string {
|
||||
if m != nil {
|
||||
return m.ErrMsg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp) GetSuccessResult() []*GetUsersOnlineStatusResp_SuccessResult {
|
||||
if m != nil {
|
||||
return m.SuccessResult
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp) GetFailedResult() []*GetUsersOnlineStatusResp_FailedDetail {
|
||||
if m != nil {
|
||||
return m.FailedResult
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetUsersOnlineStatusResp_SuccessDetail struct {
|
||||
Platform string `protobuf:"bytes,1,opt,name=platform" json:"platform,omitempty"`
|
||||
Status string `protobuf:"bytes,2,opt,name=status" json:"status,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp_SuccessDetail) Reset() {
|
||||
*m = GetUsersOnlineStatusResp_SuccessDetail{}
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_SuccessDetail) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetUsersOnlineStatusResp_SuccessDetail) ProtoMessage() {}
|
||||
func (*GetUsersOnlineStatusResp_SuccessDetail) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_relay_709d2b3cc3a7ad83, []int{4, 0}
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_SuccessDetail) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp_SuccessDetail.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_SuccessDetail) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp_SuccessDetail.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetUsersOnlineStatusResp_SuccessDetail) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetUsersOnlineStatusResp_SuccessDetail.Merge(dst, src)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_SuccessDetail) XXX_Size() int {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp_SuccessDetail.Size(m)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_SuccessDetail) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetUsersOnlineStatusResp_SuccessDetail.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetUsersOnlineStatusResp_SuccessDetail proto.InternalMessageInfo
|
||||
|
||||
func (m *GetUsersOnlineStatusResp_SuccessDetail) GetPlatform() string {
|
||||
if m != nil {
|
||||
return m.Platform
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp_SuccessDetail) GetStatus() string {
|
||||
if m != nil {
|
||||
return m.Status
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetUsersOnlineStatusResp_FailedDetail struct {
|
||||
UserID string `protobuf:"bytes,3,opt,name=userID" json:"userID,omitempty"`
|
||||
ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"`
|
||||
ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp_FailedDetail) Reset() { *m = GetUsersOnlineStatusResp_FailedDetail{} }
|
||||
func (m *GetUsersOnlineStatusResp_FailedDetail) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetUsersOnlineStatusResp_FailedDetail) ProtoMessage() {}
|
||||
func (*GetUsersOnlineStatusResp_FailedDetail) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_relay_709d2b3cc3a7ad83, []int{4, 1}
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_FailedDetail) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp_FailedDetail.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_FailedDetail) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp_FailedDetail.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetUsersOnlineStatusResp_FailedDetail) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetUsersOnlineStatusResp_FailedDetail.Merge(dst, src)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_FailedDetail) XXX_Size() int {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp_FailedDetail.Size(m)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_FailedDetail) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetUsersOnlineStatusResp_FailedDetail.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetUsersOnlineStatusResp_FailedDetail proto.InternalMessageInfo
|
||||
|
||||
func (m *GetUsersOnlineStatusResp_FailedDetail) GetUserID() string {
|
||||
if m != nil {
|
||||
return m.UserID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp_FailedDetail) GetErrCode() int32 {
|
||||
if m != nil {
|
||||
return m.ErrCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp_FailedDetail) GetErrMsg() string {
|
||||
if m != nil {
|
||||
return m.ErrMsg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetUsersOnlineStatusResp_SuccessResult struct {
|
||||
UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"`
|
||||
Status string `protobuf:"bytes,2,opt,name=status" json:"status,omitempty"`
|
||||
DetailPlatformStatus []*GetUsersOnlineStatusResp_SuccessDetail `protobuf:"bytes,3,rep,name=detailPlatformStatus" json:"detailPlatformStatus,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp_SuccessResult) Reset() {
|
||||
*m = GetUsersOnlineStatusResp_SuccessResult{}
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_SuccessResult) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetUsersOnlineStatusResp_SuccessResult) ProtoMessage() {}
|
||||
func (*GetUsersOnlineStatusResp_SuccessResult) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_relay_709d2b3cc3a7ad83, []int{4, 2}
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_SuccessResult) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp_SuccessResult.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_SuccessResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp_SuccessResult.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetUsersOnlineStatusResp_SuccessResult) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetUsersOnlineStatusResp_SuccessResult.Merge(dst, src)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_SuccessResult) XXX_Size() int {
|
||||
return xxx_messageInfo_GetUsersOnlineStatusResp_SuccessResult.Size(m)
|
||||
}
|
||||
func (m *GetUsersOnlineStatusResp_SuccessResult) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetUsersOnlineStatusResp_SuccessResult.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetUsersOnlineStatusResp_SuccessResult proto.InternalMessageInfo
|
||||
|
||||
func (m *GetUsersOnlineStatusResp_SuccessResult) GetUserID() string {
|
||||
if m != nil {
|
||||
return m.UserID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp_SuccessResult) GetStatus() string {
|
||||
if m != nil {
|
||||
return m.Status
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GetUsersOnlineStatusResp_SuccessResult) GetDetailPlatformStatus() []*GetUsersOnlineStatusResp_SuccessDetail {
|
||||
if m != nil {
|
||||
return m.DetailPlatformStatus
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MsgToUserReq)(nil), "relay.MsgToUserReq")
|
||||
proto.RegisterType((*MsgToUserResp)(nil), "relay.MsgToUserResp")
|
||||
proto.RegisterType((*SingleMsgToUser)(nil), "relay.SingleMsgToUser")
|
||||
proto.RegisterType((*GetUsersOnlineStatusReq)(nil), "relay.GetUsersOnlineStatusReq")
|
||||
proto.RegisterType((*GetUsersOnlineStatusResp)(nil), "relay.GetUsersOnlineStatusResp")
|
||||
proto.RegisterType((*GetUsersOnlineStatusResp_SuccessDetail)(nil), "relay.GetUsersOnlineStatusResp.SuccessDetail")
|
||||
proto.RegisterType((*GetUsersOnlineStatusResp_FailedDetail)(nil), "relay.GetUsersOnlineStatusResp.FailedDetail")
|
||||
proto.RegisterType((*GetUsersOnlineStatusResp_SuccessResult)(nil), "relay.GetUsersOnlineStatusResp.SuccessResult")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@@ -286,6 +557,7 @@ const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
type OnlineMessageRelayServiceClient interface {
|
||||
MsgToUser(ctx context.Context, in *MsgToUserReq, opts ...grpc.CallOption) (*MsgToUserResp, error)
|
||||
GetUsersOnlineStatus(ctx context.Context, in *GetUsersOnlineStatusReq, opts ...grpc.CallOption) (*GetUsersOnlineStatusResp, error)
|
||||
}
|
||||
|
||||
type onlineMessageRelayServiceClient struct {
|
||||
@@ -305,10 +577,20 @@ func (c *onlineMessageRelayServiceClient) MsgToUser(ctx context.Context, in *Msg
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *onlineMessageRelayServiceClient) GetUsersOnlineStatus(ctx context.Context, in *GetUsersOnlineStatusReq, opts ...grpc.CallOption) (*GetUsersOnlineStatusResp, error) {
|
||||
out := new(GetUsersOnlineStatusResp)
|
||||
err := grpc.Invoke(ctx, "/relay.OnlineMessageRelayService/GetUsersOnlineStatus", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for OnlineMessageRelayService service
|
||||
|
||||
type OnlineMessageRelayServiceServer interface {
|
||||
MsgToUser(context.Context, *MsgToUserReq) (*MsgToUserResp, error)
|
||||
GetUsersOnlineStatus(context.Context, *GetUsersOnlineStatusReq) (*GetUsersOnlineStatusResp, error)
|
||||
}
|
||||
|
||||
func RegisterOnlineMessageRelayServiceServer(s *grpc.Server, srv OnlineMessageRelayServiceServer) {
|
||||
@@ -333,6 +615,24 @@ func _OnlineMessageRelayService_MsgToUser_Handler(srv interface{}, ctx context.C
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _OnlineMessageRelayService_GetUsersOnlineStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetUsersOnlineStatusReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(OnlineMessageRelayServiceServer).GetUsersOnlineStatus(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/relay.OnlineMessageRelayService/GetUsersOnlineStatus",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(OnlineMessageRelayServiceServer).GetUsersOnlineStatus(ctx, req.(*GetUsersOnlineStatusReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _OnlineMessageRelayService_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "relay.OnlineMessageRelayService",
|
||||
HandlerType: (*OnlineMessageRelayServiceServer)(nil),
|
||||
@@ -341,39 +641,57 @@ var _OnlineMessageRelayService_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "MsgToUser",
|
||||
Handler: _OnlineMessageRelayService_MsgToUser_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetUsersOnlineStatus",
|
||||
Handler: _OnlineMessageRelayService_GetUsersOnlineStatus_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "relay/relay.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("relay/relay.proto", fileDescriptor_relay_ff2396ffa84abfa7) }
|
||||
func init() { proto.RegisterFile("relay/relay.proto", fileDescriptor_relay_709d2b3cc3a7ad83) }
|
||||
|
||||
var fileDescriptor_relay_ff2396ffa84abfa7 = []byte{
|
||||
// 414 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xc1, 0x6b, 0xdb, 0x30,
|
||||
0x14, 0xc6, 0xf1, 0xbc, 0xa4, 0xcd, 0x4b, 0x93, 0xac, 0xda, 0x28, 0x5a, 0x0f, 0xc3, 0x84, 0x51,
|
||||
0xc2, 0x0e, 0x19, 0x74, 0xb0, 0x4b, 0x6f, 0xab, 0x09, 0x18, 0xe6, 0x76, 0xc8, 0xe9, 0x65, 0x37,
|
||||
0xd7, 0x7d, 0x33, 0x62, 0xb6, 0xe4, 0x48, 0x5e, 0xa1, 0xff, 0xdd, 0xfe, 0xb4, 0xa1, 0xa7, 0x64,
|
||||
0xd1, 0x32, 0x7a, 0x31, 0xfe, 0x7e, 0xef, 0xf3, 0xf3, 0xa7, 0xa7, 0x07, 0xa7, 0x06, 0x9b, 0xf2,
|
||||
0xe9, 0x23, 0x3d, 0x97, 0x9d, 0xd1, 0xbd, 0x66, 0x03, 0x12, 0xf3, 0xdf, 0x31, 0x9c, 0xe4, 0xb6,
|
||||
0x5e, 0xeb, 0x3b, 0x8b, 0x46, 0xe0, 0x86, 0x9d, 0xc1, 0xb0, 0x40, 0xf5, 0x90, 0xa5, 0x3c, 0x4a,
|
||||
0xa2, 0xc5, 0x48, 0x6c, 0x95, 0xe3, 0x02, 0xab, 0xc7, 0x2c, 0xe5, 0x2f, 0x3c, 0xf7, 0x8a, 0x71,
|
||||
0x38, 0xba, 0xd6, 0xaa, 0x47, 0xd5, 0xf3, 0x01, 0x15, 0x76, 0xd2, 0x55, 0x9c, 0xa7, 0xc0, 0x0d,
|
||||
0x1f, 0x26, 0xd1, 0x22, 0x16, 0x3b, 0xc9, 0xce, 0xe1, 0xd8, 0x75, 0x5d, 0xcb, 0x16, 0xf9, 0x11,
|
||||
0x95, 0xfe, 0x6a, 0xf7, 0x55, 0x6e, 0xeb, 0x95, 0xd1, 0x2d, 0x3f, 0x4e, 0xa2, 0xc5, 0x40, 0xec,
|
||||
0x24, 0x4b, 0x60, 0xbc, 0x6d, 0xbd, 0x7e, 0xea, 0x90, 0x8f, 0xa8, 0x1a, 0x22, 0xe7, 0x28, 0xd0,
|
||||
0x5a, 0xa9, 0x15, 0x39, 0xc0, 0x3b, 0x02, 0xe4, 0x1c, 0xb7, 0x1d, 0x9a, 0xb2, 0x97, 0x5a, 0x65,
|
||||
0x29, 0x1f, 0x53, 0xe2, 0x10, 0xf9, 0x1e, 0xe6, 0x11, 0x4d, 0x6e, 0xeb, 0x2c, 0xe5, 0x27, 0xde,
|
||||
0x11, 0x20, 0xf6, 0x0e, 0xe0, 0x5b, 0x53, 0xf6, 0x3f, 0xb4, 0x69, 0xb3, 0x94, 0x4f, 0xe8, 0x27,
|
||||
0x01, 0x61, 0x17, 0x30, 0x75, 0xa7, 0x41, 0x73, 0x23, 0xab, 0x9f, 0x37, 0x65, 0x8b, 0x7c, 0x4a,
|
||||
0x4d, 0x0e, 0x28, 0x7b, 0x0f, 0x13, 0x4f, 0x56, 0x65, 0x85, 0x77, 0xe2, 0x2b, 0x9f, 0x91, 0xed,
|
||||
0x5f, 0x48, 0xa7, 0x6e, 0x24, 0xaa, 0xde, 0xe7, 0x79, 0xe5, 0xf3, 0x04, 0x68, 0x7e, 0x05, 0x93,
|
||||
0xe0, 0x06, 0x6d, 0xc7, 0x3e, 0xc0, 0x4b, 0x83, 0xb6, 0xe3, 0x51, 0x12, 0x2f, 0xc6, 0x97, 0x67,
|
||||
0x4b, 0x7f, 0xed, 0x85, 0x54, 0x75, 0x83, 0x7b, 0x27, 0x79, 0xe6, 0x1b, 0x98, 0x1d, 0x14, 0xdc,
|
||||
0xf9, 0x04, 0xda, 0x5f, 0x4d, 0x7f, 0xad, 0x1f, 0x90, 0xb6, 0x20, 0x16, 0x01, 0x79, 0x76, 0x13,
|
||||
0x2e, 0x60, 0xea, 0xde, 0xdc, 0x24, 0x56, 0x7e, 0x36, 0x31, 0xcd, 0xe6, 0x80, 0x5e, 0x16, 0xf0,
|
||||
0xf6, 0x56, 0x35, 0x52, 0x61, 0x8e, 0xd6, 0x96, 0x35, 0x0a, 0x17, 0xcf, 0x0d, 0x58, 0x56, 0xc8,
|
||||
0x3e, 0xc3, 0x68, 0x9f, 0xe4, 0xf5, 0x36, 0x7a, 0xb8, 0xa0, 0xe7, 0x6f, 0xfe, 0x87, 0xb6, 0xfb,
|
||||
0x72, 0xfa, 0x7d, 0xb6, 0xf4, 0xfb, 0x7d, 0xd5, 0xdd, 0x53, 0xc7, 0xfb, 0x21, 0x2d, 0xfa, 0xa7,
|
||||
0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x9b, 0x83, 0x12, 0xfd, 0x02, 0x00, 0x00,
|
||||
var fileDescriptor_relay_709d2b3cc3a7ad83 = []byte{
|
||||
// 628 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x41, 0x6b, 0xdb, 0x4c,
|
||||
0x10, 0x45, 0x9f, 0xe2, 0x24, 0x9e, 0xd8, 0xc9, 0x97, 0x6d, 0x48, 0xb7, 0x3a, 0xa4, 0xc6, 0x94,
|
||||
0x60, 0x4a, 0xeb, 0x42, 0x0a, 0xbd, 0xe4, 0x56, 0x0b, 0x17, 0x41, 0x9c, 0x84, 0x95, 0x43, 0x4b,
|
||||
0x7b, 0x52, 0xe4, 0x89, 0x11, 0x95, 0x25, 0x79, 0x77, 0x1d, 0xc8, 0xdf, 0xe9, 0xb9, 0xf7, 0x5e,
|
||||
0xfb, 0xd3, 0xca, 0xee, 0x4a, 0xf6, 0xda, 0xb5, 0x1b, 0x72, 0x31, 0x7e, 0x6f, 0x66, 0xdf, 0xcc,
|
||||
0xbc, 0xd9, 0x15, 0x1c, 0x72, 0x4c, 0xa3, 0x87, 0x77, 0xfa, 0xb7, 0x5b, 0xf0, 0x5c, 0xe6, 0xa4,
|
||||
0xa6, 0x41, 0xfb, 0xb7, 0x0b, 0x8d, 0x81, 0x18, 0x0f, 0xf3, 0x1b, 0x81, 0x9c, 0xe1, 0x94, 0x1c,
|
||||
0xc3, 0x76, 0x88, 0xd9, 0x28, 0xf0, 0xa9, 0xd3, 0x72, 0x3a, 0x75, 0x56, 0x22, 0xc5, 0x33, 0x8c,
|
||||
0xef, 0x03, 0x9f, 0xfe, 0x67, 0x78, 0x83, 0x08, 0x85, 0x9d, 0x5e, 0x9e, 0x49, 0xcc, 0x24, 0xad,
|
||||
0xe9, 0x40, 0x05, 0x55, 0x44, 0xe5, 0x84, 0x38, 0xa5, 0xdb, 0x2d, 0xa7, 0xe3, 0xb2, 0x0a, 0x12,
|
||||
0x0f, 0x76, 0x95, 0xea, 0x30, 0x99, 0x20, 0xdd, 0xd1, 0xa1, 0x39, 0x56, 0xa7, 0x06, 0x62, 0xdc,
|
||||
0xe7, 0xf9, 0x84, 0xee, 0xb6, 0x9c, 0x4e, 0x8d, 0x55, 0x90, 0xb4, 0x60, 0xaf, 0x94, 0x1e, 0x3e,
|
||||
0x14, 0x48, 0xeb, 0x3a, 0x6a, 0x53, 0x2a, 0x23, 0x44, 0x21, 0x92, 0x3c, 0xd3, 0x19, 0x60, 0x32,
|
||||
0x2c, 0x4a, 0x65, 0x5c, 0x15, 0xc8, 0x23, 0x99, 0xe4, 0x59, 0xe0, 0xd3, 0x3d, 0xdd, 0xb1, 0x4d,
|
||||
0x19, 0x0d, 0x7e, 0x8f, 0x7c, 0x20, 0xc6, 0x81, 0x4f, 0x1b, 0x26, 0xc3, 0xa2, 0xc8, 0x09, 0xc0,
|
||||
0x75, 0x1a, 0xc9, 0xbb, 0x9c, 0x4f, 0x02, 0x9f, 0x36, 0x75, 0x11, 0x8b, 0x21, 0xa7, 0xb0, 0xaf,
|
||||
0xa6, 0x41, 0x7e, 0x99, 0xc4, 0xdf, 0x2f, 0xa3, 0x09, 0xd2, 0x7d, 0x2d, 0xb2, 0xc2, 0x92, 0x57,
|
||||
0xd0, 0x34, 0x4c, 0x3f, 0x8a, 0xf1, 0x86, 0x5d, 0xd0, 0x03, 0x9d, 0xb6, 0x4c, 0xea, 0xa9, 0xd3,
|
||||
0x04, 0x33, 0x69, 0xfa, 0xf9, 0xdf, 0xf4, 0x63, 0x51, 0xed, 0x73, 0x68, 0x5a, 0x1b, 0x14, 0x05,
|
||||
0x79, 0x0d, 0x5b, 0x1c, 0x45, 0x41, 0x9d, 0x96, 0xdb, 0xd9, 0x3b, 0x3b, 0xee, 0x9a, 0xb5, 0x87,
|
||||
0x49, 0x36, 0x4e, 0x71, 0x91, 0xa9, 0x73, 0xda, 0x53, 0x38, 0x58, 0x09, 0xa8, 0xf9, 0x18, 0x8a,
|
||||
0x59, 0x2a, 0x7b, 0xf9, 0x08, 0xf5, 0x2d, 0x70, 0x99, 0xc5, 0x6c, 0xbc, 0x09, 0xa7, 0xb0, 0xaf,
|
||||
0xfe, 0x29, 0x27, 0xfa, 0xc6, 0x1b, 0x57, 0x7b, 0xb3, 0xc2, 0xb6, 0xbf, 0xc1, 0xf3, 0x4f, 0x28,
|
||||
0x55, 0x29, 0x71, 0x95, 0xa5, 0x49, 0x86, 0xa1, 0x8c, 0xe4, 0x4c, 0xa8, 0xcb, 0x77, 0x02, 0x30,
|
||||
0x13, 0xc8, 0x03, 0xff, 0x22, 0x11, 0x52, 0xf7, 0x5f, 0x67, 0x16, 0xa3, 0xcc, 0xc8, 0xad, 0xf5,
|
||||
0x99, 0xfa, 0x36, 0xd5, 0xfe, 0xb5, 0x05, 0x74, 0xbd, 0xba, 0x28, 0xd4, 0xdd, 0x42, 0xce, 0xe7,
|
||||
0x63, 0xd5, 0x58, 0x05, 0xd5, 0x4c, 0xc8, 0xd5, 0x7e, 0xab, 0x99, 0x0c, 0x22, 0x21, 0x34, 0xc5,
|
||||
0x2c, 0x8e, 0x51, 0x08, 0x63, 0x00, 0x75, 0xb5, 0xa7, 0x6f, 0x4b, 0x4f, 0x37, 0x55, 0xea, 0x86,
|
||||
0xf6, 0x21, 0xb6, 0xac, 0x41, 0xae, 0xa1, 0x71, 0x17, 0x25, 0x29, 0x8e, 0x4a, 0xcd, 0x2d, 0xad,
|
||||
0xf9, 0xe6, 0x31, 0xcd, 0xbe, 0x3e, 0xe3, 0xa3, 0x8c, 0x92, 0x94, 0x2d, 0x29, 0x78, 0x3d, 0x68,
|
||||
0x96, 0x15, 0x4d, 0x58, 0xbd, 0xb0, 0xa2, 0xbc, 0x91, 0xe5, 0x3b, 0x9e, 0x63, 0x35, 0xab, 0xd0,
|
||||
0xaa, 0xd5, 0xac, 0x06, 0x79, 0x5f, 0xa0, 0x61, 0x97, 0x50, 0x79, 0xc6, 0x7a, 0xbd, 0xc7, 0x3a,
|
||||
0x2b, 0xd1, 0xd3, 0x5d, 0xf4, 0x7e, 0x38, 0xf3, 0xfe, 0x4a, 0x0b, 0x16, 0xda, 0xce, 0x92, 0xf6,
|
||||
0x86, 0xde, 0x48, 0x04, 0x47, 0x23, 0xdd, 0x55, 0xf5, 0xce, 0x8c, 0x2f, 0x4f, 0x5c, 0x47, 0xe9,
|
||||
0xdd, 0x5a, 0xa9, 0xb3, 0x9f, 0x0e, 0xbc, 0x30, 0x07, 0x07, 0x28, 0x44, 0x34, 0x46, 0xa6, 0x34,
|
||||
0xd5, 0xc3, 0x4f, 0x62, 0x24, 0x1f, 0xa0, 0xbe, 0x78, 0x21, 0xcf, 0xca, 0x7a, 0xf6, 0x87, 0xd3,
|
||||
0x3b, 0xfa, 0x9b, 0x14, 0x05, 0xf9, 0x0c, 0x47, 0xeb, 0xba, 0x22, 0x27, 0xff, 0x6c, 0x79, 0xea,
|
||||
0xbd, 0x7c, 0x64, 0xa4, 0x8f, 0x87, 0x5f, 0x0f, 0xba, 0xe6, 0x83, 0x7e, 0x5e, 0xdc, 0xea, 0x56,
|
||||
0x6f, 0xb7, 0xf5, 0x97, 0xfd, 0xfd, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xe4, 0x7c, 0xdc,
|
||||
0xee, 0x05, 0x00, 0x00,
|
||||
}
|
||||
|
||||
@@ -37,8 +37,34 @@ message SingleMsgToUser{
|
||||
string RecvID = 2;
|
||||
int32 RecvPlatFormID = 3;
|
||||
}
|
||||
message GetUsersOnlineStatusReq{
|
||||
repeated string userIDList = 1;
|
||||
string operationID = 2;
|
||||
}
|
||||
message GetUsersOnlineStatusResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
repeated SuccessResult successResult = 3;
|
||||
repeated FailedDetail failedResult = 4;
|
||||
message SuccessDetail{
|
||||
string platform = 1;
|
||||
string status = 2;
|
||||
}
|
||||
message FailedDetail{
|
||||
string userID = 3;
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
}
|
||||
message SuccessResult{
|
||||
string userID = 1;
|
||||
string status = 2;
|
||||
repeated SuccessDetail detailPlatformStatus = 3;
|
||||
|
||||
}
|
||||
}
|
||||
service OnlineMessageRelayService {
|
||||
rpc MsgToUser(MsgToUserReq) returns(MsgToUserResp);
|
||||
rpc GetUsersOnlineStatus(GetUsersOnlineStatusReq)returns(GetUsersOnlineStatusResp);
|
||||
// rpc SendMsgByWS(SendMsgByWSReq) returns(MsgToUserResp);
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -35,7 +35,7 @@ func (m *CommonResp) Reset() { *m = CommonResp{} }
|
||||
func (m *CommonResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*CommonResp) ProtoMessage() {}
|
||||
func (*CommonResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{0}
|
||||
return fileDescriptor_user_23985c8245c722d0, []int{0}
|
||||
}
|
||||
func (m *CommonResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_CommonResp.Unmarshal(m, b)
|
||||
@@ -81,7 +81,7 @@ func (m *DeleteUsersResp) Reset() { *m = DeleteUsersResp{} }
|
||||
func (m *DeleteUsersResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteUsersResp) ProtoMessage() {}
|
||||
func (*DeleteUsersResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{1}
|
||||
return fileDescriptor_user_23985c8245c722d0, []int{1}
|
||||
}
|
||||
func (m *DeleteUsersResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeleteUsersResp.Unmarshal(m, b)
|
||||
@@ -128,7 +128,7 @@ func (m *DeleteUsersReq) Reset() { *m = DeleteUsersReq{} }
|
||||
func (m *DeleteUsersReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteUsersReq) ProtoMessage() {}
|
||||
func (*DeleteUsersReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{2}
|
||||
return fileDescriptor_user_23985c8245c722d0, []int{2}
|
||||
}
|
||||
func (m *DeleteUsersReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeleteUsersReq.Unmarshal(m, b)
|
||||
@@ -181,7 +181,7 @@ func (m *GetAllUsersUidReq) Reset() { *m = GetAllUsersUidReq{} }
|
||||
func (m *GetAllUsersUidReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetAllUsersUidReq) ProtoMessage() {}
|
||||
func (*GetAllUsersUidReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{3}
|
||||
return fileDescriptor_user_23985c8245c722d0, []int{3}
|
||||
}
|
||||
func (m *GetAllUsersUidReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetAllUsersUidReq.Unmarshal(m, b)
|
||||
@@ -227,7 +227,7 @@ func (m *GetAllUsersUidResp) Reset() { *m = GetAllUsersUidResp{} }
|
||||
func (m *GetAllUsersUidResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetAllUsersUidResp) ProtoMessage() {}
|
||||
func (*GetAllUsersUidResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{4}
|
||||
return fileDescriptor_user_23985c8245c722d0, []int{4}
|
||||
}
|
||||
func (m *GetAllUsersUidResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetAllUsersUidResp.Unmarshal(m, b)
|
||||
@@ -274,7 +274,7 @@ func (m *GetUserInfoReq) Reset() { *m = GetUserInfoReq{} }
|
||||
func (m *GetUserInfoReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetUserInfoReq) ProtoMessage() {}
|
||||
func (*GetUserInfoReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{5}
|
||||
return fileDescriptor_user_23985c8245c722d0, []int{5}
|
||||
}
|
||||
func (m *GetUserInfoReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetUserInfoReq.Unmarshal(m, b)
|
||||
@@ -328,7 +328,7 @@ func (m *GetUserInfoResp) Reset() { *m = GetUserInfoResp{} }
|
||||
func (m *GetUserInfoResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetUserInfoResp) ProtoMessage() {}
|
||||
func (*GetUserInfoResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{6}
|
||||
return fileDescriptor_user_23985c8245c722d0, []int{6}
|
||||
}
|
||||
func (m *GetUserInfoResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetUserInfoResp.Unmarshal(m, b)
|
||||
@@ -387,7 +387,7 @@ func (m *UserInfo) Reset() { *m = UserInfo{} }
|
||||
func (m *UserInfo) String() string { return proto.CompactTextString(m) }
|
||||
func (*UserInfo) ProtoMessage() {}
|
||||
func (*UserInfo) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{7}
|
||||
return fileDescriptor_user_23985c8245c722d0, []int{7}
|
||||
}
|
||||
func (m *UserInfo) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UserInfo.Unmarshal(m, b)
|
||||
@@ -475,7 +475,7 @@ func (m *LogoutReq) Reset() { *m = LogoutReq{} }
|
||||
func (m *LogoutReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*LogoutReq) ProtoMessage() {}
|
||||
func (*LogoutReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{8}
|
||||
return fileDescriptor_user_23985c8245c722d0, []int{8}
|
||||
}
|
||||
func (m *LogoutReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_LogoutReq.Unmarshal(m, b)
|
||||
@@ -529,7 +529,7 @@ func (m *UpdateUserInfoReq) Reset() { *m = UpdateUserInfoReq{} }
|
||||
func (m *UpdateUserInfoReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*UpdateUserInfoReq) ProtoMessage() {}
|
||||
func (*UpdateUserInfoReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{9}
|
||||
return fileDescriptor_user_23985c8245c722d0, []int{9}
|
||||
}
|
||||
func (m *UpdateUserInfoReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UpdateUserInfoReq.Unmarshal(m, b)
|
||||
@@ -803,9 +803,9 @@ var _User_serviceDesc = grpc.ServiceDesc{
|
||||
Metadata: "user/user.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("user/user.proto", fileDescriptor_user_9e1dacb346b997d7) }
|
||||
func init() { proto.RegisterFile("user/user.proto", fileDescriptor_user_23985c8245c722d0) }
|
||||
|
||||
var fileDescriptor_user_9e1dacb346b997d7 = []byte{
|
||||
var fileDescriptor_user_23985c8245c722d0 = []byte{
|
||||
// 562 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4d, 0x6f, 0xd3, 0x40,
|
||||
0x10, 0x95, 0xed, 0x24, 0x8d, 0x27, 0x6a, 0x92, 0xae, 0x0a, 0xac, 0x22, 0x84, 0x22, 0x8b, 0x43,
|
||||
|
||||
@@ -65,9 +65,11 @@ message UpdateUserInfoReq{
|
||||
string Uid = 10;
|
||||
}
|
||||
|
||||
|
||||
service user {
|
||||
rpc getUserInfo(GetUserInfoReq) returns(GetUserInfoResp);
|
||||
rpc UpdateUserInfo(UpdateUserInfoReq) returns(CommonResp);
|
||||
rpc DeleteUsers(DeleteUsersReq)returns(DeleteUsersResp);
|
||||
rpc GetAllUsersUid(GetAllUsersUidReq)returns(GetAllUsersUidResp);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ func init() {
|
||||
// see https://gist.github.com/jniltinho/9787946#gistcomment-3019898
|
||||
conn, err := net.Dial("udp", "8.8.8.8:80")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
|
||||
@@ -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
|
||||
@@ -14,8 +14,15 @@ service_port_name=(
|
||||
openImPushPort
|
||||
openImWsPort
|
||||
openImSdkWsPort
|
||||
openImDemoPort
|
||||
)
|
||||
switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}')
|
||||
for i in ${service_port_name[*]}; do
|
||||
if [ ${switch} != "true" ]; then
|
||||
if [ ${i} == "openImDemoPort"]; then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list
|
||||
for j in ${ports_array}; do
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
#Include shell font styles and some basic information
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}')
|
||||
if [ ${switch} != "true" ]; then
|
||||
echo -e ${YELLOW_PREFIX}" demo service switch is false not start demo "${COLOR_SUFFIX}
|
||||
exit 0
|
||||
fi
|
||||
list1=$(cat $config_path | grep openImDemoPort | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list1
|
||||
api_ports=($ports_array)
|
||||
|
||||
#Check if the service exists
|
||||
#If it is exists,kill this process
|
||||
check=$(ps aux | grep -w ./${demo_server_name} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
oldPid=$(ps aux | grep -w ./${demo_server_name} | grep -v grep | awk '{print $2}')
|
||||
kill -9 $oldPid
|
||||
fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
cd ${demo_server_binary_root}
|
||||
|
||||
for ((i = 0; i < ${#api_ports[@]}; i++)); do
|
||||
nohup ./${demo_server_name} -port ${api_ports[$i]} >>../logs/openIM.log 2>&1 &
|
||||
done
|
||||
|
||||
sleep 3
|
||||
#Check launched service process
|
||||
check=$(ps aux | grep -w ./${demo_server_name} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
newPid=$(ps aux | grep -w ./${demo_server_name} | grep -v grep | awk '{print $2}')
|
||||
ports=$(netstat -netulp | grep -w ${newPid} | awk '{print $4}' | awk -F '[:]' '{print $NF}')
|
||||
allPorts=""
|
||||
|
||||
for i in $ports; do
|
||||
allPorts=${allPorts}"$i "
|
||||
done
|
||||
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${demo_server_name}${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX}
|
||||
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
|
||||
@@ -1,33 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
echo "docker-compose ps..........................."
|
||||
docker-compose ps
|
||||
|
||||
source ./style_info.cfg
|
||||
echo "check OpenIM, waiting 30s...................."
|
||||
sleep 30
|
||||
|
||||
docker_compose_components=(
|
||||
etcd
|
||||
mongo
|
||||
mysql
|
||||
open_im_server
|
||||
redis
|
||||
kafka
|
||||
zookeeper
|
||||
)
|
||||
echo "check OpenIM................................"
|
||||
./check_all.sh
|
||||
|
||||
component_server_count=0
|
||||
|
||||
for ((i = 0; i < ${#docker_compose_components[*]}; i++)); do
|
||||
component_server="docker-compose ps|grep -w ${docker_compose_components[$i]}|grep Up"
|
||||
count="${component_server}|wc -l"
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
echo -e "${SKY_BLUE_PREFIX}docker-compose ${docker_compose_components[$i]} is Up!${COLOR_SUFFIX}"
|
||||
let component_server_count+=1
|
||||
else
|
||||
echo -e "${RED_PREFIX} ${docker_compose_components[$i]} start failed!${COLOR_SUFFIX}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${component_server_count} -eq 7 ]; then
|
||||
echo -e "${YELLOW_PREFIX}\ndocker-compose all services is Up!${COLOR_SUFFIX}"
|
||||
else
|
||||
echo -e "${RED_PREFIX}\nsome docker-compose services start failed,please check red logs on console ${COLOR_SUFFIX}"
|
||||
fi
|
||||
|
||||
@@ -10,9 +10,11 @@ need_to_start_server_shell=(
|
||||
msg_transfer_start.sh
|
||||
sdk_svr_start.sh
|
||||
timer_start.sh
|
||||
demo_svr_start.sh
|
||||
)
|
||||
|
||||
#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started
|
||||
|
||||
sleep 10
|
||||
|
||||
for i in ${need_to_start_server_shell[*]}; do
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
source ./style_info.cfg
|
||||
echo -e "check environment......................................."
|
||||
|
||||
SYSTEM=`uname -s`
|
||||
if [ $SYSTEM != "Linux" ] ; then
|
||||
echo -e ${RED_PREFIX}"Warning: Currently only Linux is supported"${COLOR_SUFFIX}
|
||||
else
|
||||
echo -e ${GREEN_PREFIX} "Linux system is ok"${COLOR_SUFFIX}
|
||||
fi
|
||||
|
||||
echo -e "check memory............................................"
|
||||
available=`free -m | grep Mem | awk '{print $NF}'`
|
||||
if [ $available -lt 2000 ] ; then
|
||||
echo -e ${RED_PREFIX}"Warning: Your memory not enough, available is: " "$available"m${COLOR_SUFFIX}"\c"
|
||||
echo -e ${RED_PREFIX}", must be greater than 2000m"${COLOR_SUFFIX}
|
||||
else
|
||||
echo -e ${GREEN_PREFIX} "Memory is ok, available is: "$available"m${COLOR_SUFFIX}"
|
||||
fi
|
||||
|
||||
@@ -27,6 +27,10 @@ sdk_server_name="open_im_sdk_server"
|
||||
sdk_server_binary_root="../bin/"
|
||||
sdk_server_source_root="../cmd/Open-IM-SDK-Core/"
|
||||
|
||||
demo_server_name="open_im_demo"
|
||||
demo_server_binary_root="../bin/"
|
||||
demo_server_source_root="../cmd/open_im_demo/"
|
||||
|
||||
|
||||
#Global configuration file default dir
|
||||
config_path="../config/config.yaml"
|
||||
@@ -46,6 +50,7 @@ service_source_root=(
|
||||
${push_source_root}
|
||||
${sdk_server_source_root}
|
||||
${timer_task_source_root}
|
||||
${demo_server_source_root}
|
||||
)
|
||||
#service filename
|
||||
service_names=(
|
||||
@@ -62,6 +67,7 @@ service_names=(
|
||||
${push_name}
|
||||
${sdk_server_name}
|
||||
${timer_task_name}
|
||||
${demo_server_name}
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ need_to_start_server_shell=(
|
||||
msg_transfer_start.sh
|
||||
sdk_svr_start.sh
|
||||
timer_start.sh
|
||||
demo_svr_start.sh
|
||||
)
|
||||
|
||||
for i in ${need_to_start_server_shell[*]}; do
|
||||
|
||||
Reference in New Issue
Block a user