mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-30 15:29:20 +08:00
Compare commits
135 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 | |||
| d8e5fe367b | |||
| b1244c0a1b | |||
| 7a3b56955c | |||
| 5dcb7f2a80 | |||
| 64e71440e2 | |||
| e7e3b6dd15 | |||
| 06551575b1 | |||
| 912ec51315 | |||
| 1363c98cd8 | |||
| b9e49e37ea | |||
| 4bb64e301e | |||
| 1c9c911373 | |||
| 75a638f728 | |||
| 09fd45346e | |||
| 3329068bcc | |||
| aae6874928 | |||
| 6dacf23312 | |||
| bcc0cd33f1 | |||
| 0daa840eaa | |||
| ea5e69e26d | |||
| 26f0234e3d | |||
| 95ac2c62e8 | |||
| f65e4aad63 | |||
| d7f82196dc | |||
| e88f41323f | |||
| 8f483b498b | |||
| 85a75be30e | |||
| 4b13874d44 | |||
| ace77e6fd0 | |||
| 46deb5a099 | |||
| 6158ea436d | |||
| 7accffd7cd | |||
| f337b8d7cc | |||
| aeaab0a8d9 | |||
| d81b95d5a6 | |||
| 34e8961601 | |||
| b729cac998 | |||
| a08aeee0c2 | |||
| 90a466ef01 | |||
| ad14e259ba | |||
| 8a92326241 | |||
| 3e45d489b8 | |||
| 04ad424efa | |||
| 7f2270844e | |||
| e77a156f29 | |||
| 0cc641d1f8 | |||
| 51cef0bc53 | |||
| d6168cbad9 | |||
| 76f2ea01bf | |||
| 37a8ddbae6 | |||
| 7c3aa7ee0b | |||
| 65157ede23 | |||
| 8913ca161f | |||
| 3d7fd2c192 | |||
| b2cc597755 | |||
| d6ba0a803d | |||
| 0e6432f95a | |||
| 0dfaa49c97 | |||
| efeba3432c | |||
| f16cd5b8db | |||
| 72b23ca235 | |||
| 1871b616ba | |||
| f21623e1b8 | |||
| a2e204667f | |||
| 1ec9486452 | |||
| 2b66aafdba | |||
| 3169900f80 | |||
| 737edb985b | |||
| bc94d4e0b3 | |||
| 585715adbf | |||
| 1a12eb9703 | |||
| b4195bd81c | |||
| 5fb4ea2aa3 | |||
| 9367ad901d | |||
| c956add8b0 | |||
| 432a91cc64 | |||
| 629a322d1d |
@@ -0,0 +1,71 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ main ]
|
||||
schedule:
|
||||
- cron: '23 2 * * 2'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'go' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
+8
-1
@@ -1,2 +1,9 @@
|
||||
bin
|
||||
logs
|
||||
.devcontainer
|
||||
components
|
||||
logs
|
||||
logs
|
||||
out-test
|
||||
.github
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
|
||||
[submodule "src/Open-IM-SDK-Core"]
|
||||
path = src/Open-IM-SDK-Core
|
||||
[submodule "cmd/Open-IM-SDK-Core"]
|
||||
path = cmd/Open-IM-SDK-Core
|
||||
url = https://github.com/OpenIMSDK/Open-IM-SDK-Core.git
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Open-IM-Server
|
||||
# Open-IM-Server
|
||||
|
||||

|
||||
|
||||
@@ -154,4 +154,4 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
|
||||
|
||||
## License
|
||||
|
||||
Open-IM-Server is under the Apache 2.0 license. See the [LICENSE](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/LICENSE) file for details.
|
||||
Open-IM-Server is under the Apache 2.0 license. See the [LICENSE](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/LICENSE) file for details
|
||||
|
||||
Submodule
+1
Submodule cmd/Open-IM-SDK-Core added at 3699730514
@@ -0,0 +1,25 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_api
|
||||
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
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
apiAuth "Open_IM/src/api/auth"
|
||||
apiChat "Open_IM/src/api/chat"
|
||||
"Open_IM/src/api/friend"
|
||||
"Open_IM/src/api/group"
|
||||
"Open_IM/src/api/manage"
|
||||
apiThird "Open_IM/src/api/third"
|
||||
"Open_IM/src/api/user"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/utils"
|
||||
apiAuth "Open_IM/internal/api/auth"
|
||||
apiChat "Open_IM/internal/api/chat"
|
||||
"Open_IM/internal/api/friend"
|
||||
"Open_IM/internal/api/group"
|
||||
"Open_IM/internal/api/manage"
|
||||
apiThird "Open_IM/internal/api/third"
|
||||
"Open_IM/internal/api/user"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"flag"
|
||||
"github.com/gin-gonic/gin"
|
||||
"strconv"
|
||||
@@ -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))
|
||||
}
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
BINARY_NAME=open_im_msg_gateway
|
||||
BIN_DIR=../../bin/
|
||||
LAN_FILE=.go
|
||||
GO_FILE:=${BINARY_NAME}${LAN_FILE}
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ${BINARY_NAME} ${GO_FILE}
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
@@ -1,14 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/src/msg_gateway/gate"
|
||||
"Open_IM/internal/msg_gateway/gate"
|
||||
"flag"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("rpc_port", 10500, "rpc listening port")
|
||||
wsPort := flag.Int("ws_port", 10800, "ws listening port")
|
||||
rpcPort := flag.Int("rpc_port", 10400, "rpc listening port")
|
||||
wsPort := flag.Int("ws_port", 17778, "ws listening port")
|
||||
flag.Parse()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -2,13 +2,12 @@
|
||||
|
||||
BINARY_NAME=open_im_msg_transfer
|
||||
BIN_DIR=../../bin/
|
||||
LAN_FILE=.go
|
||||
GO_FILE:=${BINARY_NAME}${LAN_FILE}
|
||||
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ${BINARY_NAME} ${GO_FILE}
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/src/msg_transfer/logic"
|
||||
"Open_IM/internal/msg_transfer/logic"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
BINARY_NAME=open_im_push
|
||||
BIN_DIR=../../bin/
|
||||
LAN_FILE=.go
|
||||
GO_FILE:=${BINARY_NAME}${LAN_FILE}
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ${BINARY_NAME} ${GO_FILE}
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
@@ -1,13 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/src/push/logic"
|
||||
"Open_IM/internal/push/logic"
|
||||
"flag"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", -1, "rpc listening port")
|
||||
rpcPort := flag.Int("port", 10700, "rpc listening port")
|
||||
flag.Parse()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -0,0 +1,25 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_timer_task
|
||||
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,65 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
commonDB "Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.NewPrivateLog("timer")
|
||||
//for {
|
||||
// fmt.Println("start delete mongodb expired record")
|
||||
// timeUnixBegin := time.Now().Unix()
|
||||
// count, _ := db.DB.MgoUserCount()
|
||||
// fmt.Println("mongodb record count: ", count)
|
||||
// for i := 0; i < count; i++ {
|
||||
// time.Sleep(1 * time.Millisecond)
|
||||
// uid, _ := db.DB.MgoSkipUID(i)
|
||||
// fmt.Println("operate uid: ", uid)
|
||||
// err := db.DB.DelUserChat(uid)
|
||||
// if err != nil {
|
||||
// fmt.Println("operate uid failed: ", uid, err.Error())
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// timeUnixEnd := time.Now().Unix()
|
||||
// costTime := timeUnixEnd - timeUnixBegin
|
||||
// if costTime > int64(config.Config.Mongo.DBRetainChatRecords*24*3600) {
|
||||
// continue
|
||||
// } else {
|
||||
// sleepTime := 0
|
||||
// if int64(config.Config.Mongo.DBRetainChatRecords*24*3600)-costTime > 24*3600 {
|
||||
// sleepTime = 24 * 3600
|
||||
// } else {
|
||||
// sleepTime = config.Config.Mongo.DBRetainChatRecords*24*3600 - int(costTime)
|
||||
// }
|
||||
// fmt.Println("sleep: ", sleepTime)
|
||||
// time.Sleep(time.Duration(sleepTime) * time.Second)
|
||||
// }
|
||||
//}
|
||||
for {
|
||||
uidList, err := im_mysql_model.SelectAllUID()
|
||||
if err != nil {
|
||||
log.NewError("999999", err.Error())
|
||||
} else {
|
||||
for _, v := range uidList {
|
||||
minSeq, err := commonDB.DB.GetMinSeqFromMongo(v)
|
||||
if err != nil {
|
||||
log.NewError("999999", "get user minSeq err", err.Error(), v)
|
||||
continue
|
||||
} else {
|
||||
err := commonDB.DB.SetUserMinSeq(v, minSeq)
|
||||
if err != nil {
|
||||
log.NewError("999999", "set user minSeq err", err.Error(), v)
|
||||
}
|
||||
}
|
||||
time.Sleep(time.Duration(100) * time.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_auth
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcAuth "Open_IM/src/rpc/auth/auth"
|
||||
rpcAuth "Open_IM/internal/rpc/auth"
|
||||
"flag"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_friend
|
||||
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
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/src/rpc/friend/friend"
|
||||
"Open_IM/internal/rpc/friend"
|
||||
"flag"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_group
|
||||
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
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/src/rpc/group/group"
|
||||
"Open_IM/internal/rpc/group"
|
||||
"flag"
|
||||
)
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
BINARY_NAME=open_im_msg
|
||||
BIN_DIR=../../../bin/
|
||||
LAN_FILE=.go
|
||||
GO_FILE:=${BINARY_NAME}${LAN_FILE}
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ${BINARY_NAME} ${GO_FILE}
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcChat "Open_IM/internal/rpc/chat"
|
||||
"flag"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10300, "rpc listening port")
|
||||
flag.Parse()
|
||||
rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_user
|
||||
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
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/src/rpc/user/user"
|
||||
"Open_IM/internal/rpc/user"
|
||||
"flag"
|
||||
)
|
||||
|
||||
+50
-15
@@ -1,14 +1,14 @@
|
||||
# The class cannot be named by Pascal or camel case.
|
||||
# If it is not used, the corresponding structure will not be set,
|
||||
# and it will not be read naturally.
|
||||
serverversion: 1.0.0
|
||||
serverversion: 1.0.3
|
||||
#---------------Infrastructure configuration---------------------#
|
||||
etcd:
|
||||
etcdSchema: openIM
|
||||
etcdAddr: [ 127.0.0.1:2379 ]
|
||||
|
||||
mysql:
|
||||
dbMysqlAddress: [ 127.0.0.1:3306 ]
|
||||
dbMysqlAddress: [ 127.0.0.1:13306 ]
|
||||
dbMysqlUserName: root
|
||||
dbMysqlPassword: openIM
|
||||
dbMysqlDatabaseName: openIM
|
||||
@@ -19,7 +19,7 @@ mysql:
|
||||
dbMaxLifeTime: 120
|
||||
|
||||
mongo:
|
||||
dbAddress: [ 127.0.0.1:27017 ]
|
||||
dbAddress: [ 127.0.0.1:37017 ]
|
||||
dbDirect: false
|
||||
dbTimeout: 10
|
||||
dbDatabase: openIM
|
||||
@@ -30,7 +30,7 @@ mongo:
|
||||
dbRetainChatRecords: 7
|
||||
|
||||
redis:
|
||||
dbAddress: 127.0.0.1:6379
|
||||
dbAddress: 127.0.0.1:16379
|
||||
dbMaxIdle: 128
|
||||
dbMaxActive: 0
|
||||
dbIdleTimeout: 120
|
||||
@@ -55,7 +55,7 @@ kafka:
|
||||
# The service ip default is empty,
|
||||
# automatically obtain the machine's valid network card ip as the service ip,
|
||||
# otherwise the configuration ip is preferred
|
||||
serverip:
|
||||
serverip: 0.0.0.0
|
||||
|
||||
api:
|
||||
openImApiPort: [ 10000 ]
|
||||
@@ -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
|
||||
@@ -123,24 +131,51 @@ push:
|
||||
appKey: cf47465a368f24c659608e7e
|
||||
masterSecret: 02204efe3f3832947a236ee5
|
||||
pushUrl: "https://api.jpush.cn/v3/push"
|
||||
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
|
||||
manager:
|
||||
appManagerUid: ["openIM123456","openIM654321"]
|
||||
secrets: ["openIM1","openIM2"]
|
||||
|
||||
secret: tuoyun
|
||||
|
||||
multiloginpolicy:
|
||||
onlyOneTerminalAccess: false
|
||||
mobileAndPCTerminalAccessButOtherTerminalKickEachOther: true
|
||||
allTerminalAccess: false
|
||||
multiloginpolicy: 1
|
||||
|
||||
#token config
|
||||
tokenpolicy:
|
||||
accessSecret: "open_im_server"
|
||||
# Token effective time seconds as a unit
|
||||
#Seven days 7*24*60*60
|
||||
accessExpire: 604800
|
||||
# Token effective time day as a unit
|
||||
accessExpire: 7
|
||||
|
||||
messagecallback:
|
||||
callbackSwitch: false
|
||||
callbackUrl: "http://www.xxx.com/msg/judge"
|
||||
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
|
||||
|
||||
|
||||
|
||||
+18
-36
@@ -5,7 +5,8 @@ services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
ports:
|
||||
- 3306:3306
|
||||
- 13306:3306
|
||||
- 23306:33060
|
||||
container_name: mysql
|
||||
volumes:
|
||||
- ./components/mysql/data:/var/lib/mysql
|
||||
@@ -15,20 +16,25 @@ services:
|
||||
restart: always
|
||||
|
||||
mongodb:
|
||||
image: mongo
|
||||
image: mongo:4.0
|
||||
ports:
|
||||
- 27017:27017
|
||||
- 37017:27017
|
||||
container_name: mongo
|
||||
volumes:
|
||||
- ./components/mongodb/data:/data/db
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
- ./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
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- 6379:6379
|
||||
- 16379:6379
|
||||
container_name: redis
|
||||
volumes:
|
||||
- ./components/redis/data:/data
|
||||
@@ -82,38 +88,14 @@ services:
|
||||
restart: always
|
||||
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
|
||||
|
||||
|
||||
#fixme-----build from dockerfile---------
|
||||
# open-im-server:
|
||||
# image: open_im_server
|
||||
# container_name: open-im-server
|
||||
# volumes:
|
||||
# - ./logs:/Open-IM-Server/logs
|
||||
# - ./config/config.yaml:/Open-IM-Server/config/config.yaml
|
||||
# restart: always
|
||||
# build:
|
||||
# context: .
|
||||
# dockerfile: deploy.Dockerfile
|
||||
# depends_on:
|
||||
# - mysql
|
||||
# - mongodb
|
||||
# - redis
|
||||
# - kafka
|
||||
# - etcd
|
||||
# network_mode: "host"
|
||||
# logging:
|
||||
# driver: json-file
|
||||
# options:
|
||||
# max-size: "1g"
|
||||
# max-file: "2"
|
||||
|
||||
#fixme----build from docker hub------
|
||||
open-im-server:
|
||||
image: lyt1123/open_im_server
|
||||
container_name: open-im-server
|
||||
open_im_server:
|
||||
image: openim/open_im_server
|
||||
container_name: open_im_server
|
||||
volumes:
|
||||
- ./logs:/Open-IM-Server/logs
|
||||
- ./config/config.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./db/sdk:/Open-IM-Server/db/sdk
|
||||
- ./script:/Open-IM-Server/script
|
||||
restart: always
|
||||
depends_on:
|
||||
- kafka
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 21 KiB |
@@ -5,19 +5,23 @@ 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
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||
github.com/eapache/go-resiliency v1.2.0 // indirect
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
|
||||
github.com/eapache/queue v1.1.0 // indirect
|
||||
github.com/frankban/quicktest v1.11.3 // indirect
|
||||
github.com/frankban/quicktest v1.14.0 // indirect
|
||||
github.com/garyburd/redigo v1.6.2
|
||||
github.com/gin-gonic/gin v1.7.0
|
||||
github.com/go-playground/validator/v10 v10.4.1
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/golang/snappy v0.0.3 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
github.com/jonboulle/clockwork v0.2.2 // indirect
|
||||
@@ -28,19 +32,22 @@ require (
|
||||
github.com/mitchellh/mapstructure v1.4.1
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/olivere/elastic/v7 v7.0.23
|
||||
github.com/pierrec/lz4 v2.6.0+incompatible // indirect
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||
github.com/sirupsen/logrus v1.6.0
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
|
||||
go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
|
||||
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-20200313102051-9f266ea9e77c
|
||||
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=
|
||||
@@ -15,6 +39,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
|
||||
github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
||||
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y=
|
||||
@@ -25,6 +51,7 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
|
||||
github.com/coreos/go-systemd/v22 v22.0.0 h1:XJIw/+VlJ+87J+doOxznsAWIdmWuViOVhkQamW5YV28=
|
||||
github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@@ -48,8 +75,8 @@ github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
|
||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY=
|
||||
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
|
||||
github.com/frankban/quicktest v1.14.0 h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss=
|
||||
github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og=
|
||||
github.com/garyburd/redigo v1.6.2 h1:yE/pwKCrbLpLpQICzYTeZ7JsTA/C53wFTJHaEtRqniM=
|
||||
github.com/garyburd/redigo v1.6.2/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
@@ -74,6 +101,8 @@ github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0 h1:XUgk2Ex5veyVFVeLm0xhusUTQybEbexJXrvPNOKkSY0=
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
@@ -94,8 +123,8 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
@@ -103,13 +132,16 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
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=
|
||||
@@ -137,19 +169,22 @@ 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=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8=
|
||||
@@ -184,12 +219,14 @@ 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=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A=
|
||||
github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM=
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
@@ -214,12 +251,19 @@ github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnH
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
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=
|
||||
@@ -228,13 +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.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
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=
|
||||
@@ -245,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=
|
||||
@@ -266,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=
|
||||
@@ -275,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=
|
||||
@@ -287,14 +341,19 @@ 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 h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
|
||||
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=
|
||||
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
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=
|
||||
@@ -302,25 +361,33 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
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-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
|
||||
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=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
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=
|
||||
@@ -344,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=
|
||||
@@ -357,8 +432,9 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package apiAuth
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/src/proto/auth"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -1,10 +1,10 @@
|
||||
package apiAuth
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/src/proto/auth"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -1,11 +1,11 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbMsg "Open_IM/src/proto/chat"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -27,8 +27,8 @@ func UserGetSeq(c *gin.Context) {
|
||||
}
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if !utils.VerifyToken(token, params.SendID) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||
return
|
||||
}
|
||||
pbData := pbMsg.GetMaxAndMinSeqReq{}
|
||||
@@ -1,11 +1,11 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/src/proto/chat"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/chat"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -30,8 +30,8 @@ func UserPullMsg(c *gin.Context) {
|
||||
}
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if !utils.VerifyToken(token, params.SendID) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||
return
|
||||
}
|
||||
pbData := pbChat.PullMessageReq{}
|
||||
@@ -86,8 +86,8 @@ func UserPullMsgBySeqList(c *gin.Context) {
|
||||
}
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if !utils.VerifyToken(token, params.SendID) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||
return
|
||||
}
|
||||
pbData := pbChat.PullMessageBySeqListReq{}
|
||||
@@ -1,13 +1,13 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
pbChat "Open_IM/src/proto/chat"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -1,10 +1,10 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -1,10 +1,10 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -26,7 +26,7 @@ type paramsAddFriend struct {
|
||||
//
|
||||
func ImportFriend(c *gin.Context) {
|
||||
log.Info("", "", "ImportFriend init ....")
|
||||
|
||||
log.NewDebug("", "api importFriend start")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
|
||||
@@ -41,18 +41,19 @@ func ImportFriend(c *gin.Context) {
|
||||
OwnerUid: params.OwnerUid,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.ErrorByKv("ImportFriend Test start", params.OperationID)
|
||||
log.NewDebug(req.OperationID, "args is ", req.String())
|
||||
RpcResp, err := client.ImportFriend(context.Background(), req)
|
||||
//log.ErrorByKv("ImportFriend Test end", params.OperationID, "resp", RpcResp, "err", err.Error())
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,ImportFriend failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed" + err.Error()})
|
||||
log.NewError(req.OperationID, "rpc importFriend failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("ImportFriend success,args=%s", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "failedUidList": RpcResp.FailedUidList}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
log.InfoByArgs("ImportFriend success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
failedUidList := make([]string, 0)
|
||||
for _, v := range RpcResp.FailedUidList {
|
||||
failedUidList = append(failedUidList, v)
|
||||
}
|
||||
log.NewDebug(req.OperationID, "rpc importFriend success", RpcResp.CommonResp.ErrorMsg, RpcResp.CommonResp.ErrorCode, RpcResp.FailedUidList)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "failedUidList": failedUidList})
|
||||
}
|
||||
|
||||
func AddFriend(c *gin.Context) {
|
||||
@@ -80,7 +81,8 @@ func AddFriend(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call add friend rpc server success,args=%s", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
log.InfoByArgs("api add friend success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": RpcResp.ErrorCode,
|
||||
"errMsg": RpcResp.ErrorMsg,
|
||||
})
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -1,10 +1,10 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -1,10 +1,10 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -1,10 +1,10 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -1,10 +1,10 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -1,10 +1,10 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -1,10 +1,10 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -1,10 +1,10 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -1,10 +1,10 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/src/proto/group"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -56,7 +56,7 @@ func GetGroupApplicationList(c *gin.Context) {
|
||||
pbData := newUserRegisterReq(¶ms)
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if claims, err := utils.ParseToken(token); err != nil {
|
||||
if claims, err := token_verify.ParseToken(token); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
return
|
||||
} else {
|
||||
@@ -1,10 +1,10 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -1,10 +1,10 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/src/proto/group"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -63,7 +63,7 @@ func ApplicationGroupResponse(c *gin.Context) {
|
||||
pbData := newGroupApplicationResponse(¶ms)
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if claims, err := utils.ParseToken(token); err != nil {
|
||||
if claims, err := token_verify.ParseToken(token); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
return
|
||||
} else {
|
||||
@@ -1,10 +1,10 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -1,10 +1,10 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -1,10 +1,10 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -1,11 +1,11 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/src/proto/group"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -41,7 +41,7 @@ func TransferGroupOwner(c *gin.Context) {
|
||||
pbData := newTransferGroupOwnerReq(¶ms)
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if claims, err := utils.ParseToken(token); err != nil {
|
||||
if claims, err := token_verify.ParseToken(token); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
return
|
||||
} else {
|
||||
@@ -7,12 +7,13 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/constant"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/src/proto/chat"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
@@ -24,15 +25,17 @@ import (
|
||||
var validate *validator.Validate
|
||||
|
||||
type paramsManagementSendMsg struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
RecvID string `json:"recvID" binding:"required"`
|
||||
SenderNickName string `json:"senderNickName" `
|
||||
SenderFaceURL string `json:"senderFaceURL" `
|
||||
ForceList []string `json:"forceList" `
|
||||
Content map[string]interface{} `json:"content" binding:"required"`
|
||||
ContentType int32 `json:"contentType" binding:"required"`
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
RecvID string `json:"recvID" binding:"required"`
|
||||
SenderNickName string `json:"senderNickName" `
|
||||
SenderFaceURL string `json:"senderFaceURL" `
|
||||
SenderPlatformID int32 `json:"senderPlatformID"`
|
||||
ForceList []string `json:"forceList" `
|
||||
Content map[string]interface{} `json:"content" binding:"required"`
|
||||
ContentType int32 `json:"contentType" binding:"required"`
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||
}
|
||||
|
||||
func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
|
||||
@@ -49,7 +52,11 @@ func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
|
||||
case constant.File:
|
||||
newContent = utils.StructToJsonString(params.Content)
|
||||
default:
|
||||
|
||||
}
|
||||
options := make(map[string]int32, 2)
|
||||
if params.IsOnlineOnly {
|
||||
options["history"] = 0
|
||||
options["persistent"] = 0
|
||||
}
|
||||
pbData := pbChat.UserSendMsgReq{
|
||||
ReqIdentifier: constant.WSSendMsg,
|
||||
@@ -57,7 +64,7 @@ func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
|
||||
SenderNickName: params.SenderNickName,
|
||||
SenderFaceURL: params.SenderFaceURL,
|
||||
OperationID: params.OperationID,
|
||||
PlatformID: 0,
|
||||
PlatformID: params.SenderPlatformID,
|
||||
SessionType: params.SessionType,
|
||||
MsgFrom: constant.UserMsgType,
|
||||
ContentType: params.ContentType,
|
||||
@@ -65,6 +72,7 @@ func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
|
||||
ForceList: params.ForceList,
|
||||
Content: newContent,
|
||||
ClientMsgID: utils.GetMsgID(params.SendID),
|
||||
Options: utils.MapIntToJsonString(options),
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
@@ -84,8 +92,24 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
data = TextElem{}
|
||||
case constant.Picture:
|
||||
data = PictureElem{}
|
||||
case constant.Voice:
|
||||
data = SoundElem{}
|
||||
case constant.Video:
|
||||
data = VideoElem{}
|
||||
case constant.File:
|
||||
data = FileElem{}
|
||||
//case constant.AtText:
|
||||
// data = AtElem{}
|
||||
//case constant.Merger:
|
||||
// data =
|
||||
//case constant.Card:
|
||||
//case constant.Location:
|
||||
case constant.Custom:
|
||||
data = CustomElem{}
|
||||
//case constant.Revoke:
|
||||
//case constant.HasReadReceipt:
|
||||
//case constant.Typing:
|
||||
//case constant.Quote:
|
||||
default:
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
||||
log.ErrorByKv("contentType err", c.PostForm("operationID"), "content", c.PostForm("content"))
|
||||
@@ -102,7 +126,7 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
}
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
claims, err := utils.ParseToken(token)
|
||||
claims, err := token_verify.ParseToken(token)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "parse token failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "parse token failed", "sendTime": 0, "MsgID": ""})
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('open-im,www.open-im.io').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/9/15 10:28).
|
||||
*/
|
||||
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"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsDeleteUsers struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
DeleteUidList []string `json:"deleteUidList" binding:"required"`
|
||||
}
|
||||
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{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("DeleteUser req come here", params.OperationID, "DeleteUidList", params.DeleteUidList)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
req := &pbUser.DeleteUsersReq{
|
||||
OperationID: params.OperationID,
|
||||
DeleteUidList: params.DeleteUidList,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
RpcResp, err := client.DeleteUsers(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call delete users rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete users rpc server failed"})
|
||||
return
|
||||
}
|
||||
failedUidList := make([]string, 0)
|
||||
for _, v := range RpcResp.FailedUidList {
|
||||
failedUidList = append(failedUidList, v)
|
||||
}
|
||||
log.InfoByKv("call delete user rpc server is success", params.OperationID, "resp args", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "failedUidList": RpcResp.FailedUidList}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
func GetAllUsersUid(c *gin.Context) {
|
||||
params := paramsGetAllUsersUid{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("GetAllUsersUid req come here", params.OperationID)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
req := &pbUser.GetAllUsersUidReq{
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
RpcResp, err := client.GetAllUsersUid(context.Background(), req)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error(), "uidList": []string{}})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("call GetAllUsersUid rpc server is success", params.OperationID, "resp args", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "uidList": RpcResp.UidList}
|
||||
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)
|
||||
|
||||
}
|
||||
+4
-3
@@ -1,8 +1,9 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
log2 "Open_IM/src/common/log"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
log2 "Open_IM/pkg/common/log"
|
||||
"github.com/gin-gonic/gin"
|
||||
sts "github.com/tencentyun/qcloud-cos-sts-sdk/go"
|
||||
"net/http"
|
||||
@@ -70,7 +71,7 @@ func TencentCloudStorageCredential(c *gin.Context) {
|
||||
if err != nil {
|
||||
log2.Error(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential cli.GetCredential err = %s", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": config.ErrTencentCredential.ErrCode,
|
||||
"errCode": constant.ErrTencentCredential.ErrCode,
|
||||
"errMsg": err.Error(),
|
||||
"bucket": "",
|
||||
"region": "",
|
||||
@@ -0,0 +1,142 @@
|
||||
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"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type userInfo struct {
|
||||
UID string `json:"uid"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Gender int32 `json:"gender"`
|
||||
Mobile string `json:"mobile"`
|
||||
Birth string `json:"birth"`
|
||||
Email string `json:"email"`
|
||||
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...", "")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsStruct{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &pbUser.GetUserInfoReq{
|
||||
UserIDList: params.UIDList,
|
||||
OperationID: params.OperationID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.InfoByKv("api get user info is server", c.PostForm("OperationID"), c.Request.Header.Get("token"))
|
||||
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,call get user info rpc server failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"errorCode": 500,
|
||||
"errorMsg": "call rpc server failed",
|
||||
})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("call get user info rpc server success", params.OperationID)
|
||||
if RpcResp.ErrorCode == 0 {
|
||||
userInfoList := make([]userInfo, 0)
|
||||
for _, user := range RpcResp.Data {
|
||||
var ui userInfo
|
||||
ui.UID = user.Uid
|
||||
ui.Name = user.Name
|
||||
ui.Icon = user.Icon
|
||||
ui.Gender = user.Gender
|
||||
ui.Mobile = user.Mobile
|
||||
ui.Birth = user.Birth
|
||||
ui.Email = user.Email
|
||||
ui.Ex = user.Ex
|
||||
userInfoList = append(userInfoList, ui)
|
||||
}
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg, "data": userInfoList}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.InfoByKv("api get user info return success", params.OperationID, "args=%s", RpcResp.String())
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbUser "Open_IM/src/proto/user"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -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})
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package gate
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"sync"
|
||||
)
|
||||
@@ -1,18 +1,17 @@
|
||||
package gate
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/constant"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/src/proto/chat"
|
||||
pbWs "Open_IM/src/proto/sdk_ws"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/gorilla/websocket"
|
||||
"runtime"
|
||||
@@ -31,7 +30,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
dec := gob.NewDecoder(b)
|
||||
err := dec.Decode(&m)
|
||||
if err != nil {
|
||||
log.ErrorByKv("ws json Unmarshal err", "", "err", err.Error())
|
||||
log.ErrorByKv("ws Decode err", "", "err", err.Error())
|
||||
ws.sendErrMsg(conn, 200, err.Error(), constant.WSDataError, "", "")
|
||||
err = conn.Close()
|
||||
if err != nil {
|
||||
@@ -44,7 +43,6 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
ws.sendErrMsg(conn, 201, err.Error(), m.ReqIdentifier, m.MsgIncr, m.OperationID)
|
||||
return
|
||||
}
|
||||
|
||||
//if !utils.VerifyToken(m.Token, m.SendID) {
|
||||
// ws.sendErrMsg(conn, 202, "token validate err", m.ReqIdentifier, m.MsgIncr,m.OperationID)
|
||||
// return
|
||||
@@ -63,12 +61,32 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
go ws.pullMsgBySeqListReq(conn, &m)
|
||||
default:
|
||||
}
|
||||
|
||||
log.NewInfo("", "goroutine num is ", runtime.NumGoroutine())
|
||||
|
||||
}
|
||||
func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier)
|
||||
pbData := pbChat.GetMaxAndMinSeqReq{}
|
||||
nReply := new(pbChat.GetMaxAndMinSeqResp)
|
||||
pbData.UserID = m.SendID
|
||||
pbData.OperationID = m.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
if grpcConn == nil {
|
||||
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", m)
|
||||
}
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.ErrorByKv("rpc call failed to getSeqReq", pbData.OperationID, "err", err, "pbData", pbData.String())
|
||||
nReply.ErrCode = 200
|
||||
nReply.ErrMsg = err.Error()
|
||||
ws.getSeqResp(conn, m, nReply)
|
||||
} else {
|
||||
log.InfoByKv("rpc call success to getSeqReq", pbData.OperationID, "replyData", reply.String())
|
||||
ws.getSeqResp(conn, m, reply)
|
||||
}
|
||||
}
|
||||
func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *pbChat.GetMaxAndMinSeqResp) {
|
||||
var mReplyData pbWs.GetMaxAndMinSeqResp
|
||||
var mReplyData open_im_sdk.GetMaxAndMinSeqResp
|
||||
mReplyData.MaxSeq = pb.GetMaxSeq()
|
||||
mReplyData.MinSeq = pb.GetMinSeq()
|
||||
b, _ := proto.Marshal(&mReplyData)
|
||||
@@ -82,29 +100,38 @@ func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *pbChat.GetMaxAndMinSeq
|
||||
}
|
||||
ws.sendMsg(conn, mReply)
|
||||
}
|
||||
func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier)
|
||||
pbData := pbChat.GetMaxAndMinSeqReq{}
|
||||
pbData.UserID = m.SendID
|
||||
pbData.OperationID = m.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
if grpcConn == nil {
|
||||
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", m)
|
||||
func (ws *WServer) pullMsgReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgReq", m.ReqIdentifier, m.MsgIncr, m.SendID)
|
||||
nReply := new(pbChat.PullMessageResp)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsg)
|
||||
if isPass {
|
||||
pbData := pbChat.PullMessageReq{}
|
||||
pbData.UserID = m.SendID
|
||||
pbData.OperationID = m.OperationID
|
||||
pbData.SeqBegin = data.(SeqData).SeqBegin
|
||||
pbData.SeqEnd = data.(SeqData).SeqEnd
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.PullMessage(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.ErrorByKv("PullMessage error", pbData.OperationID, "err", err.Error())
|
||||
nReply.ErrCode = 200
|
||||
nReply.ErrMsg = err.Error()
|
||||
ws.pullMsgResp(conn, m, nReply)
|
||||
} else {
|
||||
log.InfoByKv("rpc call success to pullMsgRep", pbData.OperationID, "ReplyArgs", reply.String(), "maxSeq", reply.GetMaxSeq(),
|
||||
"MinSeq", reply.GetMinSeq(), "singLen", len(reply.GetSingleUserMsg()), "groupLen", len(reply.GetGroupUserMsg()))
|
||||
ws.pullMsgResp(conn, m, reply)
|
||||
}
|
||||
} else {
|
||||
nReply.ErrCode = errCode
|
||||
nReply.ErrMsg = errMsg
|
||||
ws.pullMsgResp(conn, m, nReply)
|
||||
}
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.ErrorByKv("rpc call failed to getSeqReq", pbData.OperationID, "err", err, "pbData", pbData.String())
|
||||
return
|
||||
}
|
||||
log.InfoByKv("rpc call success to getSeqReq", pbData.OperationID, "replyData", reply.String())
|
||||
ws.getSeqResp(conn, m, reply)
|
||||
|
||||
}
|
||||
|
||||
func (ws *WServer) pullMsgResp(conn *UserConn, m *Req, pb *pbChat.PullMessageResp) {
|
||||
log.NewInfo(m.OperationID, "pullMsgResp come here ", pb.String())
|
||||
var mReplyData pbWs.PullMessageBySeqListResp
|
||||
var mReplyData open_im_sdk.PullMessageBySeqListResp
|
||||
a, err := json.Marshal(pb.SingleUserMsg)
|
||||
if err != nil {
|
||||
log.NewError(m.OperationID, "GetSingleUserMsg,json marshal,err", err.Error())
|
||||
@@ -139,41 +166,14 @@ func (ws *WServer) pullMsgResp(conn *UserConn, m *Req, pb *pbChat.PullMessageRes
|
||||
ws.sendMsg(conn, mReply)
|
||||
|
||||
}
|
||||
|
||||
func (ws *WServer) pullMsgReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgReq", m.ReqIdentifier, m.MsgIncr, m.SendID)
|
||||
reply := new(pbChat.PullMessageResp)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsg)
|
||||
if isPass {
|
||||
pbData := pbChat.PullMessageReq{}
|
||||
pbData.UserID = m.SendID
|
||||
pbData.OperationID = m.OperationID
|
||||
pbData.SeqBegin = data.(SeqData).SeqBegin
|
||||
pbData.SeqEnd = data.(SeqData).SeqEnd
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.PullMessage(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.ErrorByKv("PullMessage error", pbData.OperationID, "err", err.Error())
|
||||
return
|
||||
}
|
||||
log.InfoByKv("rpc call success to pullMsgRep", pbData.OperationID, "ReplyArgs", reply.String(), "maxSeq", reply.GetMaxSeq(),
|
||||
"MinSeq", reply.GetMinSeq(), "singLen", len(reply.GetSingleUserMsg()), "groupLen", len(reply.GetGroupUserMsg()))
|
||||
ws.pullMsgResp(conn, m, reply)
|
||||
} else {
|
||||
reply.ErrCode = errCode
|
||||
reply.ErrMsg = errMsg
|
||||
ws.pullMsgResp(conn, m, reply)
|
||||
}
|
||||
}
|
||||
func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq start", m.SendID, m.ReqIdentifier, m.MsgIncr)
|
||||
reply := new(pbChat.PullMessageResp)
|
||||
nReply := new(pbChat.PullMessageResp)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsgBySeqList)
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(pbWs.PullMessageBySeqListReq).SeqList)
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(open_im_sdk.PullMessageBySeqListReq).SeqList)
|
||||
if isPass {
|
||||
pbData := pbChat.PullMessageBySeqListReq{}
|
||||
pbData.SeqList = data.(pbWs.PullMessageBySeqListReq).SeqList
|
||||
pbData.SeqList = data.(open_im_sdk.PullMessageBySeqListReq).SeqList
|
||||
pbData.UserID = m.SendID
|
||||
pbData.OperationID = m.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
@@ -181,45 +181,25 @@ func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(pbData.OperationID, "pullMsgBySeqListReq err", err.Error())
|
||||
reply.ErrCode = 200
|
||||
reply.ErrMsg = err.Error()
|
||||
|
||||
nReply.ErrCode = 200
|
||||
nReply.ErrMsg = err.Error()
|
||||
ws.pullMsgResp(conn, m, nReply)
|
||||
} else {
|
||||
log.NewInfo(pbData.OperationID, "rpc call success to pullMsgBySeqListReq", reply.String(), reply.GetMaxSeq(), reply.GetMinSeq(), len(reply.GetSingleUserMsg()), len(reply.GetGroupUserMsg()))
|
||||
ws.pullMsgResp(conn, m, reply)
|
||||
}
|
||||
ws.pullMsgResp(conn, m, reply)
|
||||
} else {
|
||||
reply.ErrCode = errCode
|
||||
reply.ErrMsg = errMsg
|
||||
ws.pullMsgResp(conn, m, reply)
|
||||
nReply.ErrCode = errCode
|
||||
nReply.ErrMsg = errMsg
|
||||
ws.pullMsgResp(conn, m, nReply)
|
||||
}
|
||||
}
|
||||
|
||||
func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.UserSendMsgResp, sendTime int64) {
|
||||
// := make(map[string]interface{})
|
||||
|
||||
var mReplyData pbWs.UserSendMsgResp
|
||||
mReplyData.ClientMsgID = pb.GetClientMsgID()
|
||||
mReplyData.ServerMsgID = pb.GetServerMsgID()
|
||||
mReplyData.SendTime = sendTime
|
||||
b, _ := proto.Marshal(&mReplyData)
|
||||
mReply := Resp{
|
||||
ReqIdentifier: m.ReqIdentifier,
|
||||
MsgIncr: m.MsgIncr,
|
||||
ErrCode: pb.GetErrCode(),
|
||||
ErrMsg: pb.GetErrMsg(),
|
||||
OperationID: m.OperationID,
|
||||
Data: b,
|
||||
}
|
||||
ws.sendMsg(conn, mReply)
|
||||
}
|
||||
|
||||
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req, sendTime int64) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, sendTime)
|
||||
reply := new(pbChat.UserSendMsgResp)
|
||||
nReply := new(pbChat.UserSendMsgResp)
|
||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg)
|
||||
if isPass {
|
||||
data := pData.(pbWs.UserSendMsgReq)
|
||||
data := pData.(open_im_sdk.UserSendMsgReq)
|
||||
pbData := pbChat.UserSendMsgReq{
|
||||
ReqIdentifier: m.ReqIdentifier,
|
||||
Token: m.Token,
|
||||
@@ -244,27 +224,47 @@ func (ws *WServer) sendMsgReq(conn *UserConn, m *Req, sendTime int64) {
|
||||
reply, err := client.UserSendMsg(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(pbData.OperationID, "UserSendMsg err", err.Error())
|
||||
reply.ErrCode = 200
|
||||
reply.ErrMsg = err.Error()
|
||||
nReply.ErrCode = 200
|
||||
nReply.ErrMsg = err.Error()
|
||||
ws.sendMsgResp(conn, m, nReply, sendTime)
|
||||
} else {
|
||||
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
|
||||
ws.sendMsgResp(conn, m, reply, sendTime)
|
||||
}
|
||||
ws.sendMsgResp(conn, m, reply, sendTime)
|
||||
|
||||
} else {
|
||||
reply.ErrCode = errCode
|
||||
reply.ErrMsg = errMsg
|
||||
ws.sendMsgResp(conn, m, reply, sendTime)
|
||||
nReply.ErrCode = errCode
|
||||
nReply.ErrMsg = errMsg
|
||||
ws.sendMsgResp(conn, m, nReply, sendTime)
|
||||
}
|
||||
|
||||
}
|
||||
func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.UserSendMsgResp, sendTime int64) {
|
||||
// := make(map[string]interface{})
|
||||
|
||||
var mReplyData open_im_sdk.UserSendMsgResp
|
||||
mReplyData.ClientMsgID = pb.GetClientMsgID()
|
||||
mReplyData.ServerMsgID = pb.GetServerMsgID()
|
||||
mReplyData.SendTime = sendTime
|
||||
b, _ := proto.Marshal(&mReplyData)
|
||||
mReply := Resp{
|
||||
ReqIdentifier: m.ReqIdentifier,
|
||||
MsgIncr: m.MsgIncr,
|
||||
ErrCode: pb.GetErrCode(),
|
||||
ErrMsg: pb.GetErrMsg(),
|
||||
OperationID: m.OperationID,
|
||||
Data: b,
|
||||
}
|
||||
ws.sendMsg(conn, mReply)
|
||||
}
|
||||
|
||||
func (ws *WServer) sendMsg(conn *UserConn, mReply interface{}) {
|
||||
var b bytes.Buffer
|
||||
enc := gob.NewEncoder(&b)
|
||||
err := enc.Encode(mReply)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
log.NewError(mReply.(Resp).OperationID, mReply.(Resp).ReqIdentifier, mReply.(Resp).ErrCode, mReply.(Resp).ErrMsg, "Encode Msg error", conn.RemoteAddr().String(), ws.getUserUid(conn), err.Error())
|
||||
return
|
||||
}
|
||||
err = ws.writeMsg(conn, websocket.BinaryMessage, b.Bytes())
|
||||
if err != nil {
|
||||
@@ -1,22 +1,23 @@
|
||||
package gate
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/constant"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbRelay "Open_IM/src/proto/relay"
|
||||
pbWs "Open_IM/src/proto/sdk_ws"
|
||||
"Open_IM/src/utils"
|
||||
"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"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/gorilla/websocket"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type RPCServer struct {
|
||||
@@ -58,7 +59,7 @@ func (r *RPCServer) MsgToUser(_ context.Context, in *pbRelay.MsgToUserReq) (*pbR
|
||||
log.InfoByKv("PushMsgToUser is arriving", in.OperationID, "args", in.String())
|
||||
var resp []*pbRelay.SingleMsgToUser
|
||||
var RecvID string
|
||||
msg := pbWs.MsgData{
|
||||
msg := open_im_sdk.MsgData{
|
||||
SendID: in.SendID,
|
||||
RecvID: in.RecvID,
|
||||
MsgFrom: in.MsgFrom,
|
||||
@@ -102,14 +103,14 @@ func (r *RPCServer) MsgToUser(_ context.Context, in *pbRelay.MsgToUserReq) (*pbR
|
||||
temp := &pbRelay.SingleMsgToUser{
|
||||
ResultCode: resultCode,
|
||||
RecvID: UIDAndPID[0],
|
||||
RecvPlatFormID: utils.PlatformNameToID(UIDAndPID[1]),
|
||||
RecvPlatFormID: constant.PlatformNameToID(UIDAndPID[1]),
|
||||
}
|
||||
resp = append(resp, temp)
|
||||
} else {
|
||||
temp := &pbRelay.SingleMsgToUser{
|
||||
ResultCode: -1,
|
||||
RecvID: UIDAndPID[0],
|
||||
RecvPlatFormID: utils.PlatformNameToID(UIDAndPID[1]),
|
||||
RecvPlatFormID: constant.PlatformNameToID(UIDAndPID[1]),
|
||||
}
|
||||
resp = append(resp, temp)
|
||||
}
|
||||
@@ -121,12 +122,36 @@ 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 {
|
||||
log.ErrorByKv("PushMsgToUser is failed By Ws", "", "Addr", conn.RemoteAddr().String(),
|
||||
"error", err, "senderPlatform", utils.PlatformIDToName(in.PlatformID), "recvPlatform", RecvPlatForm, "args", in.String(), "recvID", RecvID)
|
||||
"error", err, "senderPlatform", constant.PlatformIDToName(in.PlatformID), "recvPlatform", RecvPlatForm, "args", in.String(), "recvID", RecvID)
|
||||
ResultCode = -2
|
||||
return ResultCode
|
||||
} else {
|
||||
@@ -137,8 +162,8 @@ func sendMsgToUser(conn *UserConn, bMsg []byte, in *pbRelay.MsgToUserReq, RecvPl
|
||||
|
||||
}
|
||||
func genUidPlatformArray(uid string) (array []string) {
|
||||
for i := 1; i <= utils.LinuxPlatformID; i++ {
|
||||
array = append(array, uid+" "+utils.PlatformIDToName(int32(i)))
|
||||
for i := 1; i <= constant.LinuxPlatformID; i++ {
|
||||
array = append(array, uid+" "+constant.PlatformIDToName(int32(i)))
|
||||
}
|
||||
return array
|
||||
}
|
||||
@@ -7,9 +7,9 @@
|
||||
package gate
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/constant"
|
||||
"Open_IM/src/common/log"
|
||||
pbWs "Open_IM/src/proto/sdk_ws"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -59,7 +59,7 @@ type SeqListData struct {
|
||||
func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, errMsg string, returnData interface{}) {
|
||||
switch r {
|
||||
case constant.WSSendMsg:
|
||||
data := pbWs.UserSendMsgReq{}
|
||||
data := open_im_sdk.UserSendMsgReq{}
|
||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
||||
return false, 203, err.Error(), nil
|
||||
@@ -71,7 +71,7 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
|
||||
}
|
||||
return true, 0, "", data
|
||||
case constant.WSPullMsgBySeqList:
|
||||
data := pbWs.PullMessageBySeqListReq{}
|
||||
data := open_im_sdk.PullMessageBySeqListReq{}
|
||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
||||
return false, 203, err.Error(), nil
|
||||
@@ -1,9 +1,14 @@
|
||||
package gate
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"github.com/gorilla/websocket"
|
||||
"net/http"
|
||||
"sync"
|
||||
@@ -53,10 +58,10 @@ func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
//Connection mapping relationship,
|
||||
//userID+" "+platformID->conn
|
||||
SendID := query["sendID"][0] + " " + utils.PlatformIDToName(int32(utils.StringToInt64(query["platformID"][0])))
|
||||
|
||||
//Initialize a lock for each user
|
||||
newConn := &UserConn{conn, new(sync.Mutex)}
|
||||
ws.addUserConn(SendID, newConn)
|
||||
ws.addUserConn(query["sendID"][0], int32(utils.StringToInt64(query["platformID"][0])), newConn, query["token"][0])
|
||||
go ws.readMsg(newConn)
|
||||
}
|
||||
}
|
||||
@@ -86,20 +91,70 @@ func (ws *WServer) writeMsg(conn *UserConn, a int, msg []byte) error {
|
||||
return conn.WriteMessage(a, msg)
|
||||
|
||||
}
|
||||
func (ws *WServer) addUserConn(uid string, conn *UserConn) {
|
||||
func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int32, newConn *UserConn, token string) {
|
||||
switch config.Config.MultiLoginPolicy {
|
||||
case constant.AllLoginButSameTermKick:
|
||||
if oldConn, ok := ws.wsUserToConn[genMapKey(uid, platformID)]; ok {
|
||||
log.NewDebug("", uid, platformID, "kick old conn")
|
||||
ws.sendKickMsg(oldConn, newConn)
|
||||
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
|
||||
if err != nil {
|
||||
log.NewError("", "get token from redis err", err.Error())
|
||||
return
|
||||
}
|
||||
if m == nil {
|
||||
log.NewError("", "get token from redis err", "m is nil")
|
||||
return
|
||||
}
|
||||
for k, _ := range m {
|
||||
if k != token {
|
||||
m[k] = constant.KickedToken
|
||||
}
|
||||
}
|
||||
log.NewDebug("get map is ", m)
|
||||
err = db.DB.SetTokenMapByUidPid(uid, platformID, m)
|
||||
if err != nil {
|
||||
log.NewError("", "SetTokenMapByUidPid err", err.Error())
|
||||
return
|
||||
}
|
||||
err = oldConn.Close()
|
||||
delete(ws.wsConnToUser, oldConn)
|
||||
if err != nil {
|
||||
log.NewError("", "conn close err", err.Error())
|
||||
}
|
||||
} else {
|
||||
log.NewDebug("no other conn", ws.wsUserToConn)
|
||||
}
|
||||
|
||||
case constant.SingleTerminalLogin:
|
||||
case constant.WebAndOther:
|
||||
}
|
||||
}
|
||||
func (ws *WServer) sendKickMsg(oldConn, newConn *UserConn) {
|
||||
mReply := Resp{
|
||||
ReqIdentifier: constant.WSKickOnlineMsg,
|
||||
ErrCode: constant.ErrTokenInvalid.ErrCode,
|
||||
ErrMsg: constant.ErrTokenInvalid.ErrMsg,
|
||||
}
|
||||
var b bytes.Buffer
|
||||
enc := gob.NewEncoder(&b)
|
||||
err := enc.Encode(mReply)
|
||||
if err != nil {
|
||||
log.NewError(mReply.OperationID, mReply.ReqIdentifier, mReply.ErrCode, mReply.ErrMsg, "Encode Msg error", oldConn.RemoteAddr().String(), newConn.RemoteAddr().String(), err.Error())
|
||||
return
|
||||
}
|
||||
err = ws.writeMsg(oldConn, websocket.BinaryMessage, b.Bytes())
|
||||
if err != nil {
|
||||
log.NewError(mReply.OperationID, mReply.ReqIdentifier, mReply.ErrCode, mReply.ErrMsg, "WS WriteMsg error", oldConn.RemoteAddr().String(), newConn.RemoteAddr().String(), err.Error())
|
||||
}
|
||||
}
|
||||
func (ws *WServer) addUserConn(uid string, platformID int32, conn *UserConn, token string) {
|
||||
key := genMapKey(uid, platformID)
|
||||
rwLock.Lock()
|
||||
defer rwLock.Unlock()
|
||||
if oldConn, ok := ws.wsUserToConn[uid]; ok {
|
||||
err := oldConn.Close()
|
||||
delete(ws.wsConnToUser, oldConn)
|
||||
if err != nil {
|
||||
log.ErrorByKv("close err", "", "uid", uid, "conn", conn)
|
||||
}
|
||||
} else {
|
||||
log.InfoByKv("this user is first login", "", "uid", uid)
|
||||
}
|
||||
ws.wsConnToUser[conn] = uid
|
||||
ws.wsUserToConn[uid] = conn
|
||||
ws.MultiTerminalLoginChecker(uid, platformID, conn, token)
|
||||
ws.wsConnToUser[conn] = key
|
||||
ws.wsUserToConn[key] = conn
|
||||
log.WarnByKv("WS Add operation", "", "wsUser added", ws.wsUserToConn, "uid", uid, "online_num", len(ws.wsUserToConn))
|
||||
|
||||
}
|
||||
@@ -146,10 +201,11 @@ func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request) bool {
|
||||
status := http.StatusUnauthorized
|
||||
query := r.URL.Query()
|
||||
if len(query["token"]) != 0 && len(query["sendID"]) != 0 && len(query["platformID"]) != 0 {
|
||||
if !utils.VerifyToken(query["token"][0], query["sendID"][0]) {
|
||||
if ok, err := token_verify.VerifyToken(query["token"][0], query["sendID"][0]); !ok {
|
||||
e := err.(*constant.ErrInfo)
|
||||
log.ErrorByKv("Token verify failed", "", "query", query)
|
||||
w.Header().Set("Sec-Websocket-Version", "13")
|
||||
http.Error(w, http.StatusText(status), status)
|
||||
http.Error(w, e.ErrMsg, int(e.ErrCode))
|
||||
return false
|
||||
} else {
|
||||
log.InfoByKv("Connection Authentication Success", "", "token", query["token"][0], "userID", query["sendID"][0])
|
||||
@@ -163,3 +219,6 @@ func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request) bool {
|
||||
}
|
||||
|
||||
}
|
||||
func genMapKey(uid string, platformID int32) string {
|
||||
return uid + " " + constant.PlatformIDToName(platformID)
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/db"
|
||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/src/common/log"
|
||||
pbMsg "Open_IM/src/proto/chat"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
)
|
||||
|
||||
func saveUserChat(uid string, pbMsg *pbMsg.MsgSvrToPushSvrChatMsg) error {
|
||||
+8
-8
@@ -1,14 +1,14 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/constant"
|
||||
kfk "Open_IM/src/common/kafka"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbMsg "Open_IM/src/proto/chat"
|
||||
pbPush "Open_IM/src/proto/push"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
kfk "Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/golang/protobuf/proto"
|
||||
@@ -1,9 +1,9 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/kafka"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
)
|
||||
|
||||
var (
|
||||
+7
-7
@@ -7,13 +7,13 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/constant"
|
||||
"Open_IM/src/common/db/mysql_model/im_mysql_msg_model"
|
||||
kfk "Open_IM/src/common/kafka"
|
||||
"Open_IM/src/common/log"
|
||||
pbMsg "Open_IM/src/proto/chat"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_msg_model"
|
||||
kfk "Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"strings"
|
||||
@@ -1,9 +1,9 @@
|
||||
package push
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/push/jpush/common"
|
||||
"Open_IM/src/push/jpush/requestBody"
|
||||
"Open_IM/internal/push/jpush/common"
|
||||
"Open_IM/internal/push/jpush/requestBody"
|
||||
"Open_IM/pkg/common/config"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
@@ -21,6 +21,7 @@ func JGAccountListPush(accounts []string, content, detailContent, platform strin
|
||||
au.SetAlias(accounts)
|
||||
var no requestBody.Notification
|
||||
no.SetAlert(content)
|
||||
no.SetAndroidIntent()
|
||||
var me requestBody.Message
|
||||
me.SetMsgContent(detailContent)
|
||||
var po requestBody.PushObj
|
||||
@@ -0,0 +1,26 @@
|
||||
package requestBody
|
||||
|
||||
import "Open_IM/pkg/common/config"
|
||||
|
||||
type Notification struct {
|
||||
Alert string `json:"alert,omitempty"`
|
||||
Android Android `json:"android,omitempty"`
|
||||
IOS Ios `json:"ios,omitempty"`
|
||||
}
|
||||
|
||||
type Android struct {
|
||||
Alert string `json:"alert,omitempty"`
|
||||
Intent struct {
|
||||
URL string `json:"url,omitempty"`
|
||||
} `json:"intent,omitempty"`
|
||||
}
|
||||
type Ios struct {
|
||||
}
|
||||
|
||||
func (n *Notification) SetAlert(alert string) {
|
||||
n.Alert = alert
|
||||
n.Android.Alert = alert
|
||||
}
|
||||
func (n *Notification) SetAndroidIntent() {
|
||||
n.Android.Intent.URL = config.Config.Push.Jpns.PushIntent
|
||||
}
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package requestBody
|
||||
|
||||
import (
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"errors"
|
||||
)
|
||||
|
||||
@@ -53,9 +53,9 @@ func (p *Platform) Set(os string) error {
|
||||
}
|
||||
func (p *Platform) SetPlatform(platform string) error {
|
||||
switch platform {
|
||||
case utils.AndroidPlatformStr:
|
||||
case constant.AndroidPlatformStr:
|
||||
return p.SetAndroid()
|
||||
case utils.IOSPlatformStr:
|
||||
case constant.IOSPlatformStr:
|
||||
return p.SetIOS()
|
||||
default:
|
||||
return errors.New("platform err")
|
||||
@@ -7,10 +7,10 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/kafka"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -24,7 +24,7 @@ func Init(rpcPort int) {
|
||||
log.NewPrivateLog(config.Config.ModuleName.PushName)
|
||||
rpcServer.Init(rpcPort)
|
||||
pushCh.Init()
|
||||
pushTerminal = []int32{utils.IOSPlatformID, utils.AndroidPlatformID}
|
||||
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}
|
||||
}
|
||||
func init() {
|
||||
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
|
||||
@@ -7,11 +7,11 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
kfk "Open_IM/src/common/kafka"
|
||||
"Open_IM/src/common/log"
|
||||
pbChat "Open_IM/src/proto/chat"
|
||||
pbRelay "Open_IM/src/proto/relay"
|
||||
"Open_IM/pkg/common/config"
|
||||
kfk "Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
@@ -1,12 +1,12 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/src/proto/push"
|
||||
pbRelay "Open_IM/src/proto/relay"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/push"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
@@ -7,16 +7,16 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/constant"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/src/proto/chat"
|
||||
pbGroup "Open_IM/src/proto/group"
|
||||
pbRelay "Open_IM/src/proto/relay"
|
||||
push "Open_IM/src/push/jpush"
|
||||
rpcChat "Open_IM/src/rpc/chat/chat"
|
||||
"Open_IM/src/utils"
|
||||
push "Open_IM/internal/push/jpush"
|
||||
rpcChat "Open_IM/internal/rpc/chat"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
@@ -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...)
|
||||
}
|
||||
}
|
||||
@@ -95,8 +96,9 @@ func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) {
|
||||
content = constant.ContentType2PushContent[constant.GroupMsg]
|
||||
}
|
||||
default:
|
||||
content = constant.ContentType2PushContent[constant.Common]
|
||||
}
|
||||
pushResult, err := push.JGAccountListPush(UIDList, content, jsonCustomContent, utils.PlatformIDToName(t))
|
||||
pushResult, err := push.JGAccountListPush(UIDList, content, jsonCustomContent, constant.PlatformIDToName(t))
|
||||
if err != nil {
|
||||
log.NewError(sendPbData.OperationID, "offline push error", sendPbData.String(), err.Error(), t)
|
||||
} else {
|
||||
@@ -1,11 +1,11 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
tpns "Open_IM/src/push/sdk/tpns-server-sdk-go/go"
|
||||
"Open_IM/src/push/sdk/tpns-server-sdk-go/go/auth"
|
||||
"Open_IM/src/push/sdk/tpns-server-sdk-go/go/common"
|
||||
"Open_IM/src/push/sdk/tpns-server-sdk-go/go/req"
|
||||
tpns "Open_IM/internal/push/sdk/tpns-server-sdk-go/go"
|
||||
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/auth"
|
||||
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/common"
|
||||
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/req"
|
||||
"Open_IM/pkg/common/config"
|
||||
)
|
||||
|
||||
var badgeType = -2
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
tpns "Open_IM/src/push/sdk/tpns-server-sdk-go/go"
|
||||
tpns "Open_IM/internal/push/sdk/tpns-server-sdk-go/go"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package req
|
||||
|
||||
import (
|
||||
tpns "Open_IM/src/push/sdk/tpns-server-sdk-go/go"
|
||||
tpns "Open_IM/internal/push/sdk/tpns-server-sdk-go/go"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
@@ -1,12 +1,11 @@
|
||||
package rpcAuth
|
||||
package auth
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/src/proto/auth"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"Open_IM/pkg/utils"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
@@ -1,15 +1,18 @@
|
||||
package rpcAuth
|
||||
package auth
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/src/common/log"
|
||||
pbAuth "Open_IM/src/proto/auth"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"context"
|
||||
)
|
||||
|
||||
func (rpc *rpcAuth) UserRegister(_ context.Context, pb *pbAuth.UserRegisterReq) (*pbAuth.UserRegisterResp, error) {
|
||||
log.Info("", "", "rpc user_register start, [data: %s]", pb.String())
|
||||
|
||||
//if len(pb.UID) == 0 {
|
||||
// pb.UID = utils.GenID()
|
||||
//}
|
||||
if err := im_mysql_model.UserRegister(pb); err != nil {
|
||||
log.Error("", "", "rpc user_register error, [data: %s] [err: %s]", pb.String(), err.Error())
|
||||
return &pbAuth.UserRegisterResp{Success: false}, err
|
||||
@@ -1,10 +1,10 @@
|
||||
package rpcAuth
|
||||
package auth
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/src/common/log"
|
||||
pbAuth "Open_IM/src/proto/auth"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"context"
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ func (rpc *rpcAuth) UserToken(_ context.Context, pb *pbAuth.UserTokenReq) (*pbAu
|
||||
}
|
||||
log.Info("", "", "rpc user_token call..., im_mysql_model.AppServerFindFromUserByUserID")
|
||||
|
||||
tokens, expTime, err := utils.CreateToken(pb.UID, "", pb.Platform)
|
||||
tokens, expTime, err := token_verify.CreateToken(pb.UID, pb.Platform)
|
||||
if err != nil {
|
||||
log.Error("", "", "rpc user_token call..., utils.CreateToken fail [uid: %s] [err: %s]", pb.UID, err.Error())
|
||||
return &pbAuth.UserTokenResp{ErrCode: 500, ErrMsg: err.Error()}, err
|
||||
@@ -1,16 +1,16 @@
|
||||
package rpcChat
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
|
||||
commonDB "Open_IM/src/common/db"
|
||||
"Open_IM/src/common/log"
|
||||
commonDB "Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
pbMsg "Open_IM/src/proto/chat"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
)
|
||||
|
||||
func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *pbMsg.GetMaxAndMinSeqReq) (*pbMsg.GetMaxAndMinSeqResp, error) {
|
||||
@@ -1,12 +1,12 @@
|
||||
package rpcChat
|
||||
package chat
|
||||
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/kafka"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/src/proto/chat"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
@@ -1,16 +1,16 @@
|
||||
package rpcChat
|
||||
package chat
|
||||
|
||||
import (
|
||||
"Open_IM/src/api/group"
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/constant"
|
||||
http2 "Open_IM/src/common/http"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/src/proto/chat"
|
||||
pbGroup "Open_IM/src/proto/group"
|
||||
"Open_IM/src/push/content_struct"
|
||||
"Open_IM/src/utils"
|
||||
"Open_IM/internal/api/group"
|
||||
"Open_IM/internal/push/content_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
http2 "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
@@ -21,14 +21,16 @@ import (
|
||||
)
|
||||
|
||||
type MsgCallBackReq struct {
|
||||
SendID string `json:"sendID"`
|
||||
RecvID string `json:"recvID"`
|
||||
Content string `json:"content"`
|
||||
SendTime int64 `json:"sendTime"`
|
||||
MsgFrom int32 `json:"msgFrom"`
|
||||
ContentType int32 `json:"contentType"`
|
||||
SessionType int32 `json:"sessionType"`
|
||||
PlatformID int32 `json:"senderPlatformID"`
|
||||
SendID string `json:"sendID"`
|
||||
RecvID string `json:"recvID"`
|
||||
Content string `json:"content"`
|
||||
SendTime int64 `json:"sendTime"`
|
||||
MsgFrom int32 `json:"msgFrom"`
|
||||
ContentType int32 `json:"contentType"`
|
||||
SessionType int32 `json:"sessionType"`
|
||||
PlatformID int32 `json:"senderPlatformID"`
|
||||
MsgID string `json:"msgID"`
|
||||
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||
}
|
||||
type MsgCallBackResp struct {
|
||||
ErrCode int32 `json:"errCode"`
|
||||
@@ -68,29 +70,36 @@ func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (*
|
||||
} else {
|
||||
pbData.SendTime = pb.SendTime
|
||||
}
|
||||
m := MsgCallBackResp{}
|
||||
Options := utils.JsonStringToMap(pbData.Options)
|
||||
isHistory := utils.GetSwitchFromOptions(Options, "history")
|
||||
mReq := MsgCallBackReq{
|
||||
SendID: pb.SendID,
|
||||
RecvID: pb.RecvID,
|
||||
Content: pb.Content,
|
||||
SendTime: pbData.SendTime,
|
||||
MsgFrom: pbData.MsgFrom,
|
||||
ContentType: pb.ContentType,
|
||||
SessionType: pb.SessionType,
|
||||
PlatformID: pb.PlatformID,
|
||||
MsgID: pb.ClientMsgID,
|
||||
}
|
||||
if !isHistory {
|
||||
mReq.IsOnlineOnly = true
|
||||
}
|
||||
mResp := MsgCallBackResp{}
|
||||
if config.Config.MessageCallBack.CallbackSwitch {
|
||||
bMsg, err := http2.Post(config.Config.MessageCallBack.CallbackUrl, MsgCallBackReq{
|
||||
SendID: pb.SendID,
|
||||
RecvID: pb.RecvID,
|
||||
Content: pb.Content,
|
||||
SendTime: pbData.SendTime,
|
||||
MsgFrom: pbData.MsgFrom,
|
||||
ContentType: pb.ContentType,
|
||||
SessionType: pb.SessionType,
|
||||
PlatformID: pb.PlatformID,
|
||||
}, "application/json; charset=utf-8")
|
||||
bMsg, err := http2.Post(config.Config.MessageCallBack.CallbackUrl, mReq, config.Config.MessageCallBack.CallBackTimeOut)
|
||||
if err != nil {
|
||||
log.ErrorByKv("callback to Business server err", pb.OperationID, "args", pb.String(), "err", err.Error())
|
||||
return returnMsg(&replay, pb, http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError), "", 0)
|
||||
} else if err = json.Unmarshal(bMsg, &m); err != nil {
|
||||
} else if err = json.Unmarshal(bMsg, &mResp); err != nil {
|
||||
log.ErrorByKv("ws json Unmarshal err", pb.OperationID, "args", pb.String(), "err", err.Error())
|
||||
return returnMsg(&replay, pb, 200, err.Error(), "", 0)
|
||||
} else {
|
||||
if m.ErrCode != 0 {
|
||||
return returnMsg(&replay, pb, m.ResponseErrCode, m.ErrMsg, "", 0)
|
||||
if mResp.ErrCode != 0 {
|
||||
return returnMsg(&replay, pb, mResp.ResponseErrCode, mResp.ErrMsg, "", 0)
|
||||
} else {
|
||||
pbData.Content = m.ResponseResult.ModifiedMsg
|
||||
pbData.Content = mResp.ResponseResult.ModifiedMsg
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user