mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-16 14:59:01 +08:00
Compare commits
98 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d8e5fe367b | |||
| b1244c0a1b | |||
| 7a3b56955c | |||
| 5dcb7f2a80 | |||
| 64e71440e2 | |||
| e7e3b6dd15 | |||
| 06551575b1 | |||
| 912ec51315 | |||
| 1363c98cd8 | |||
| b9e49e37ea | |||
| 4bb64e301e | |||
| 1c9c911373 | |||
| 75a638f728 | |||
| 09fd45346e | |||
| 3329068bcc | |||
| aae6874928 | |||
| 6dacf23312 | |||
| bcc0cd33f1 | |||
| 0daa840eaa | |||
| ea5e69e26d | |||
| 26f0234e3d | |||
| f65e4aad63 | |||
| d7f82196dc | |||
| e88f41323f | |||
| 8f483b498b | |||
| 85a75be30e | |||
| 4b13874d44 | |||
| 46deb5a099 | |||
| 6158ea436d | |||
| 7accffd7cd | |||
| f337b8d7cc | |||
| aeaab0a8d9 | |||
| d81b95d5a6 | |||
| 34e8961601 | |||
| b729cac998 | |||
| a08aeee0c2 | |||
| 90a466ef01 | |||
| ad14e259ba | |||
| 8a92326241 | |||
| 3e45d489b8 | |||
| 04ad424efa | |||
| 7f2270844e | |||
| c97e39fc09 | |||
| 515d7bb318 | |||
| cdf928d64e | |||
| 2440575093 | |||
| 817d2b11a5 | |||
| 4b4dce80cf | |||
| 52e15fc9d4 | |||
| 7dbaa1b8c1 | |||
| 4215d65aa7 | |||
| 62a6195a4f | |||
| 51622e77d4 | |||
| 2e14e0f767 | |||
| b219f8542b | |||
| 6d67bb9d65 | |||
| af37abb394 | |||
| dfd028625d | |||
| a87c16de0d | |||
| e77a156f29 | |||
| 082de2b6b7 | |||
| 7f19f2f046 | |||
| 0cc641d1f8 | |||
| 51cef0bc53 | |||
| d6168cbad9 | |||
| 76f2ea01bf | |||
| 37a8ddbae6 | |||
| 71873f7f0e | |||
| e124a26c52 | |||
| 09b501f7df | |||
| a86980657c | |||
| 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
|
||||||
@@ -1,2 +1,9 @@
|
|||||||
|
bin
|
||||||
|
logs
|
||||||
|
.devcontainer
|
||||||
components
|
components
|
||||||
logs
|
logs
|
||||||
|
out-test
|
||||||
|
.github
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
[submodule "src/Open-IM-SDK-Core"]
|
[submodule "cmd/Open-IM-SDK-Core"]
|
||||||
path = src/Open-IM-SDK-Core
|
path = cmd/Open-IM-SDK-Core
|
||||||
url = https://github.com/OpenIMSDK/Open-IM-SDK-Core.git
|
url = https://github.com/OpenIMSDK/Open-IM-SDK-Core.git
|
||||||
|
|||||||
@@ -154,4 +154,4 @@ All images are available at https://hub.docker.com/r/lyt1123/open_im_server
|
|||||||
|
|
||||||
## License
|
## 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 610fc07d46
@@ -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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
apiAuth "Open_IM/src/api/auth"
|
apiAuth "Open_IM/internal/api/auth"
|
||||||
apiChat "Open_IM/src/api/chat"
|
apiChat "Open_IM/internal/api/chat"
|
||||||
"Open_IM/src/api/friend"
|
"Open_IM/internal/api/friend"
|
||||||
"Open_IM/src/api/group"
|
"Open_IM/internal/api/group"
|
||||||
"Open_IM/src/api/manage"
|
"Open_IM/internal/api/manage"
|
||||||
apiThird "Open_IM/src/api/third"
|
apiThird "Open_IM/internal/api/third"
|
||||||
"Open_IM/src/api/user"
|
"Open_IM/internal/api/user"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -2,13 +2,11 @@
|
|||||||
|
|
||||||
BINARY_NAME=open_im_msg_gateway
|
BINARY_NAME=open_im_msg_gateway
|
||||||
BIN_DIR=../../bin/
|
BIN_DIR=../../bin/
|
||||||
LAN_FILE=.go
|
|
||||||
GO_FILE:=${BINARY_NAME}${LAN_FILE}
|
|
||||||
|
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
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:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/msg_gateway/gate"
|
"Open_IM/internal/msg_gateway/gate"
|
||||||
"flag"
|
"flag"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
rpcPort := flag.Int("rpc_port", 10500, "rpc listening port")
|
rpcPort := flag.Int("rpc_port", 10400, "rpc listening port")
|
||||||
wsPort := flag.Int("ws_port", 10800, "ws listening port")
|
wsPort := flag.Int("ws_port", 17778, "ws listening port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
BINARY_NAME=open_im_msg_transfer
|
BINARY_NAME=open_im_msg_transfer
|
||||||
BIN_DIR=../../bin/
|
BIN_DIR=../../bin/
|
||||||
LAN_FILE=.go
|
|
||||||
GO_FILE:=${BINARY_NAME}${LAN_FILE}
|
|
||||||
|
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
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:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/msg_transfer/logic"
|
"Open_IM/internal/msg_transfer/logic"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -2,13 +2,11 @@
|
|||||||
|
|
||||||
BINARY_NAME=open_im_push
|
BINARY_NAME=open_im_push
|
||||||
BIN_DIR=../../bin/
|
BIN_DIR=../../bin/
|
||||||
LAN_FILE=.go
|
|
||||||
GO_FILE:=${BINARY_NAME}${LAN_FILE}
|
|
||||||
|
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
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:
|
run:
|
||||||
@go run ./
|
@go run ./
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/push/logic"
|
"Open_IM/internal/push/logic"
|
||||||
"flag"
|
"flag"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
rpcPort := flag.Int("port", -1, "rpc listening port")
|
rpcPort := flag.Int("port", 10700, "rpc listening port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
rpcAuth "Open_IM/src/rpc/auth/auth"
|
rpcAuth "Open_IM/internal/rpc/auth"
|
||||||
"flag"
|
"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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/rpc/friend/friend"
|
"Open_IM/internal/rpc/friend"
|
||||||
"flag"
|
"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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/rpc/group/group"
|
"Open_IM/internal/rpc/group"
|
||||||
"flag"
|
"flag"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -2,13 +2,11 @@
|
|||||||
|
|
||||||
BINARY_NAME=open_im_msg
|
BINARY_NAME=open_im_msg
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../../bin/
|
||||||
LAN_FILE=.go
|
|
||||||
GO_FILE:=${BINARY_NAME}${LAN_FILE}
|
|
||||||
|
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
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:
|
run:
|
||||||
@go 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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/rpc/user/user"
|
"Open_IM/internal/rpc/user"
|
||||||
"flag"
|
"flag"
|
||||||
)
|
)
|
||||||
|
|
||||||
+14
-15
@@ -1,14 +1,14 @@
|
|||||||
# The class cannot be named by Pascal or camel case.
|
# The class cannot be named by Pascal or camel case.
|
||||||
# If it is not used, the corresponding structure will not be set,
|
# If it is not used, the corresponding structure will not be set,
|
||||||
# and it will not be read naturally.
|
# and it will not be read naturally.
|
||||||
serverversion: 1.0.0
|
serverversion: 1.0.3
|
||||||
#---------------Infrastructure configuration---------------------#
|
#---------------Infrastructure configuration---------------------#
|
||||||
etcd:
|
etcd:
|
||||||
etcdSchema: openIM
|
etcdSchema: openIM
|
||||||
etcdAddr: [ 127.0.0.1:2379 ]
|
etcdAddr: [ 127.0.0.1:2379 ]
|
||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
dbMysqlAddress: [ 127.0.0.1:3306 ]
|
dbMysqlAddress: [ 127.0.0.1:13306 ]
|
||||||
dbMysqlUserName: root
|
dbMysqlUserName: root
|
||||||
dbMysqlPassword: openIM
|
dbMysqlPassword: openIM
|
||||||
dbMysqlDatabaseName: openIM
|
dbMysqlDatabaseName: openIM
|
||||||
@@ -19,7 +19,7 @@ mysql:
|
|||||||
dbMaxLifeTime: 120
|
dbMaxLifeTime: 120
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
dbAddress: [ 127.0.0.1:27017 ]
|
dbAddress: [ 127.0.0.1:37017 ]
|
||||||
dbDirect: false
|
dbDirect: false
|
||||||
dbTimeout: 10
|
dbTimeout: 10
|
||||||
dbDatabase: openIM
|
dbDatabase: openIM
|
||||||
@@ -30,7 +30,7 @@ mongo:
|
|||||||
dbRetainChatRecords: 7
|
dbRetainChatRecords: 7
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
dbAddress: 127.0.0.1:6379
|
dbAddress: 127.0.0.1:16379
|
||||||
dbMaxIdle: 128
|
dbMaxIdle: 128
|
||||||
dbMaxActive: 0
|
dbMaxActive: 0
|
||||||
dbIdleTimeout: 120
|
dbIdleTimeout: 120
|
||||||
@@ -55,7 +55,7 @@ kafka:
|
|||||||
# The service ip default is empty,
|
# The service ip default is empty,
|
||||||
# automatically obtain the machine's valid network card ip as the service ip,
|
# automatically obtain the machine's valid network card ip as the service ip,
|
||||||
# otherwise the configuration ip is preferred
|
# otherwise the configuration ip is preferred
|
||||||
serverip:
|
serverip: 0.0.0.0
|
||||||
|
|
||||||
api:
|
api:
|
||||||
openImApiPort: [ 10000 ]
|
openImApiPort: [ 10000 ]
|
||||||
@@ -74,7 +74,7 @@ credential:
|
|||||||
rpcport:
|
rpcport:
|
||||||
openImUserPort: [ 10100 ]
|
openImUserPort: [ 10100 ]
|
||||||
openImFriendPort: [ 10200 ]
|
openImFriendPort: [ 10200 ]
|
||||||
openImOfflineMessagePort: [ 10300 ]
|
openImOfflineMessagePort: [ 10300]
|
||||||
openImOnlineRelayPort: [ 10400 ]
|
openImOnlineRelayPort: [ 10400 ]
|
||||||
openImGroupPort: [ 10500 ]
|
openImGroupPort: [ 10500 ]
|
||||||
openImAuthPort: [ 10600 ]
|
openImAuthPort: [ 10600 ]
|
||||||
@@ -120,27 +120,26 @@ push:
|
|||||||
accessID: 111
|
accessID: 111
|
||||||
secretKey: 111
|
secretKey: 111
|
||||||
jpns:
|
jpns:
|
||||||
appKey: 2783339cee4de379cc798fe1
|
appKey: cf47465a368f24c659608e7e
|
||||||
masterSecret: 66e5f309e032c68cc668c28a
|
masterSecret: 02204efe3f3832947a236ee5
|
||||||
pushUrl: "https://api.jpush.cn/v3/push"
|
pushUrl: "https://api.jpush.cn/v3/push"
|
||||||
|
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
|
||||||
manager:
|
manager:
|
||||||
appManagerUid: ["openIM123456","openIM654321"]
|
appManagerUid: ["openIM123456","openIM654321"]
|
||||||
secrets: ["openIM1","openIM2"]
|
secrets: ["openIM1","openIM2"]
|
||||||
|
|
||||||
secret: tuoyun
|
secret: tuoyun
|
||||||
|
|
||||||
multiloginpolicy:
|
multiloginpolicy: 1
|
||||||
onlyOneTerminalAccess: false
|
|
||||||
mobileAndPCTerminalAccessButOtherTerminalKickEachOther: true
|
|
||||||
allTerminalAccess: false
|
|
||||||
|
|
||||||
#token config
|
#token config
|
||||||
tokenpolicy:
|
tokenpolicy:
|
||||||
accessSecret: "open_im_server"
|
accessSecret: "open_im_server"
|
||||||
# Token effective time seconds as a unit
|
# Token effective time day as a unit
|
||||||
#Seven days 7*24*60*60
|
accessExpire: 7
|
||||||
accessExpire: 604800
|
|
||||||
|
|
||||||
messagecallback:
|
messagecallback:
|
||||||
callbackSwitch: false
|
callbackSwitch: false
|
||||||
callbackUrl: "http://www.xxx.com/msg/judge"
|
callbackUrl: "http://www.xxx.com/msg/judge"
|
||||||
|
#TimeOut use second as unit
|
||||||
|
callbackTimeOut: 10
|
||||||
|
|||||||
+17
-35
@@ -5,7 +5,8 @@ services:
|
|||||||
mysql:
|
mysql:
|
||||||
image: mysql:5.7
|
image: mysql:5.7
|
||||||
ports:
|
ports:
|
||||||
- 3306:3306
|
- 13306:3306
|
||||||
|
- 23306:33060
|
||||||
container_name: mysql
|
container_name: mysql
|
||||||
volumes:
|
volumes:
|
||||||
- ./components/mysql/data:/var/lib/mysql
|
- ./components/mysql/data:/var/lib/mysql
|
||||||
@@ -15,20 +16,25 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
mongodb:
|
mongodb:
|
||||||
image: mongo
|
image: mongo:4.0
|
||||||
ports:
|
ports:
|
||||||
- 27017:27017
|
- 37017:27017
|
||||||
container_name: mongo
|
container_name: mongo
|
||||||
volumes:
|
volumes:
|
||||||
- ./components/mongodb/data:/data/db
|
# - ./components/mongodb/data/db:/data/db
|
||||||
|
# - ./components/mongodb/data/logs:/data/logs
|
||||||
|
# - ./components/mongodb/data/conf:/etc/mongo
|
||||||
environment:
|
environment:
|
||||||
TZ: Asia/Shanghai
|
- MONGO_INITDB_ROOT_USERNAME=openIM
|
||||||
|
- MONGO_INITDB_ROOT_PASSWORD=openIM
|
||||||
|
|
||||||
|
#TZ: Asia/Shanghai
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis
|
image: redis
|
||||||
ports:
|
ports:
|
||||||
- 6379:6379
|
- 16379:6379
|
||||||
container_name: redis
|
container_name: redis
|
||||||
volumes:
|
volumes:
|
||||||
- ./components/redis/data:/data
|
- ./components/redis/data:/data
|
||||||
@@ -82,38 +88,14 @@ services:
|
|||||||
restart: always
|
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
|
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
|
||||||
|
|
||||||
|
open_im_server:
|
||||||
#fixme-----build from dockerfile---------
|
image: openim/open_im_server
|
||||||
# open-im-server:
|
container_name: 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
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/Open-IM-Server/logs
|
- ./logs:/Open-IM-Server/logs
|
||||||
- ./config/config.yaml:/Open-IM-Server/config/config.yaml
|
- ./config/config.yaml:/Open-IM-Server/config/config.yaml
|
||||||
|
- ./db/sdk:/Open-IM-Server/db/sdk
|
||||||
|
- ./script:/Open-IM-Server/script
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- kafka
|
- kafka
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 21 KiB |
@@ -6,18 +6,19 @@ require (
|
|||||||
github.com/Shopify/sarama v1.19.0
|
github.com/Shopify/sarama v1.19.0
|
||||||
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
|
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
|
||||||
github.com/antonfisher/nested-logrus-formatter v1.3.0
|
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/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/dustin/go-humanize v1.0.0 // indirect
|
||||||
github.com/eapache/go-resiliency v1.2.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/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
|
||||||
github.com/eapache/queue v1.1.0 // 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/garyburd/redigo v1.6.2
|
||||||
github.com/gin-gonic/gin v1.7.0
|
github.com/gin-gonic/gin v1.7.0
|
||||||
github.com/go-playground/validator/v10 v10.4.1
|
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/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/gorilla/websocket v1.4.2
|
||||||
github.com/jinzhu/gorm v1.9.16
|
github.com/jinzhu/gorm v1.9.16
|
||||||
github.com/jonboulle/clockwork v0.2.2 // indirect
|
github.com/jonboulle/clockwork v0.2.2 // indirect
|
||||||
@@ -28,19 +29,20 @@ require (
|
|||||||
github.com/mitchellh/mapstructure v1.4.1
|
github.com/mitchellh/mapstructure v1.4.1
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||||
github.com/olivere/elastic/v7 v7.0.23
|
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/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
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/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
|
||||||
go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698
|
go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698
|
||||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
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
|
golang.org/x/tools v0.0.0-20210106214847-113979e3529a // indirect
|
||||||
google.golang.org/grpc v1.33.2
|
google.golang.org/grpc v1.33.2
|
||||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
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
|
sigs.k8s.io/yaml v1.2.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,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 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
|
||||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
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/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/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/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=
|
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y=
|
||||||
@@ -25,6 +27,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 h1:XJIw/+VlJ+87J+doOxznsAWIdmWuViOVhkQamW5YV28=
|
||||||
github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
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.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.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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@@ -48,8 +51,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/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 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
|
||||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
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.14.0 h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss=
|
||||||
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
|
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 h1:yE/pwKCrbLpLpQICzYTeZ7JsTA/C53wFTJHaEtRqniM=
|
||||||
github.com/garyburd/redigo v1.6.2/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
|
github.com/garyburd/redigo v1.6.2/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
|
||||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
@@ -74,6 +77,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.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 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
|
||||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
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 h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
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=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
@@ -94,8 +99,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.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
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/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.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
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 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
|
||||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
@@ -103,9 +108,9 @@ 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.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.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.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.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/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
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 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
|
||||||
@@ -141,15 +146,14 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
|
|||||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
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/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.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/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.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
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/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.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 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
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=
|
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8=
|
||||||
@@ -188,8 +192,8 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v
|
|||||||
github.com/olivere/elastic/v7 v7.0.23 h1:b7tjMogDMhf2CisGI+L02LXLVa0ZyE82Z15XfW1e8t8=
|
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/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/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.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM=
|
||||||
github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
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.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/errors v0.8.1/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=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
@@ -214,10 +218,12 @@ 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/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/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.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.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
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.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
github.com/smartystreets/assertions v1.1.1/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
|
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/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=
|
||||||
github.com/smartystreets/gunit v1.4.2/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak=
|
github.com/smartystreets/gunit v1.4.2/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak=
|
||||||
@@ -231,8 +237,9 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
|||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
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.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
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.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
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 h1:G/aIr3WiUesWHL2YGYgEqjM5tCAJ43Ml+0C18wDkWWs=
|
||||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw=
|
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw=
|
||||||
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-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
@@ -289,8 +296,9 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL
|
|||||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/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-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/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-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-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/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-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-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@@ -302,15 +310,20 @@ 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-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-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-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-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-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-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-20200930185726-fdedc70b468f/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.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.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.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 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM=
|
||||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
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-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
@@ -357,8 +370,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.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
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.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-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.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 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
|
||||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package apiAuth
|
package apiAuth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbAuth "Open_IM/src/proto/auth"
|
pbAuth "Open_IM/pkg/proto/auth"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -49,6 +49,10 @@ func UserRegister(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if params.Secret != config.Config.Secret {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
|
||||||
|
return
|
||||||
|
}
|
||||||
pbData := newUserRegisterReq(¶ms)
|
pbData := newUserRegisterReq(¶ms)
|
||||||
|
|
||||||
log.Info("", "", "api user_register is server, [data: %s]", pbData.String())
|
log.Info("", "", "api user_register is server, [data: %s]", pbData.String())
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package apiAuth
|
package apiAuth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbAuth "Open_IM/src/proto/auth"
|
pbAuth "Open_IM/pkg/proto/auth"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -37,6 +37,10 @@ func UserToken(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if params.Secret != config.Config.Secret {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
|
||||||
|
return
|
||||||
|
}
|
||||||
pbData := newUserTokenReq(¶ms)
|
pbData := newUserTokenReq(¶ms)
|
||||||
|
|
||||||
log.Info("", "", "api user_token is server, [data: %s]", pbData.String())
|
log.Info("", "", "api user_token is server, [data: %s]", pbData.String())
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package apiChat
|
package apiChat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/common/token_verify"
|
||||||
pbMsg "Open_IM/src/proto/chat"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
"Open_IM/src/utils"
|
pbMsg "Open_IM/pkg/proto/chat"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -27,8 +27,8 @@ func UserGetSeq(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
token := c.Request.Header.Get("token")
|
||||||
if !utils.VerifyToken(token, params.SendID) {
|
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pbData := pbMsg.GetMaxAndMinSeqReq{}
|
pbData := pbMsg.GetMaxAndMinSeqReq{}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package apiChat
|
package apiChat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/src/proto/chat"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/proto/chat"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -30,8 +30,8 @@ func UserPullMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
token := c.Request.Header.Get("token")
|
||||||
if !utils.VerifyToken(token, params.SendID) {
|
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pbData := pbChat.PullMessageReq{}
|
pbData := pbChat.PullMessageReq{}
|
||||||
@@ -86,8 +86,8 @@ func UserPullMsgBySeqList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
token := c.Request.Header.Get("token")
|
||||||
if !utils.VerifyToken(token, params.SendID) {
|
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pbData := pbChat.PullMessageBySeqListReq{}
|
pbData := pbChat.PullMessageBySeqListReq{}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
package apiChat
|
package apiChat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
pbChat "Open_IM/src/proto/chat"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -67,7 +67,7 @@ func UserSendMsg(c *gin.Context) {
|
|||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
token := c.Request.Header.Get("token")
|
||||||
|
|
||||||
log.InfoByKv("Ws call success to sendMsgReq", params.OperationID, "Parameters", params)
|
log.InfoByKv("api call success to sendMsgReq", params.OperationID, "Parameters", params)
|
||||||
|
|
||||||
pbData := newUserSendMsgReq(token, ¶ms)
|
pbData := newUserSendMsgReq(token, ¶ms)
|
||||||
log.Info("", "", "api UserSendMsg call start..., [data: %s]", pbData.String())
|
log.Info("", "", "api UserSendMsg call start..., [data: %s]", pbData.String())
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -26,7 +26,7 @@ type paramsAddFriend struct {
|
|||||||
//
|
//
|
||||||
func ImportFriend(c *gin.Context) {
|
func ImportFriend(c *gin.Context) {
|
||||||
log.Info("", "", "ImportFriend init ....")
|
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)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
client := pbFriend.NewFriendClient(etcdConn)
|
client := pbFriend.NewFriendClient(etcdConn)
|
||||||
|
|
||||||
@@ -41,18 +41,19 @@ func ImportFriend(c *gin.Context) {
|
|||||||
OwnerUid: params.OwnerUid,
|
OwnerUid: params.OwnerUid,
|
||||||
Token: c.Request.Header.Get("token"),
|
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)
|
RpcResp, err := client.ImportFriend(context.Background(), req)
|
||||||
//log.ErrorByKv("ImportFriend Test end", params.OperationID, "resp", RpcResp, "err", err.Error())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,ImportFriend failed", err)
|
log.NewError(req.OperationID, "rpc importFriend failed", err.Error())
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed" + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.InfoByArgs("ImportFriend success,args=%s", RpcResp.String())
|
failedUidList := make([]string, 0)
|
||||||
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "failedUidList": RpcResp.FailedUidList}
|
for _, v := range RpcResp.FailedUidList {
|
||||||
c.JSON(http.StatusOK, resp)
|
failedUidList = append(failedUidList, v)
|
||||||
log.InfoByArgs("ImportFriend success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
}
|
||||||
|
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) {
|
func AddFriend(c *gin.Context) {
|
||||||
@@ -80,7 +81,8 @@ func AddFriend(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.InfoByArgs("call add friend rpc server success,args=%s", RpcResp.String())
|
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, gin.H{
|
||||||
c.JSON(http.StatusOK, resp)
|
"errCode": RpcResp.ErrorCode,
|
||||||
log.InfoByArgs("api add friend success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
"errMsg": RpcResp.ErrorMsg,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
+4
-4
@@ -1,10 +1,10 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pb "Open_IM/src/proto/group"
|
pb "Open_IM/pkg/proto/group"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
+6
-6
@@ -1,11 +1,11 @@
|
|||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/src/proto/group"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/proto/group"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -56,7 +56,7 @@ func GetGroupApplicationList(c *gin.Context) {
|
|||||||
pbData := newUserRegisterReq(¶ms)
|
pbData := newUserRegisterReq(¶ms)
|
||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
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"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pb "Open_IM/src/proto/group"
|
pb "Open_IM/pkg/proto/group"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pb "Open_IM/src/proto/group"
|
pb "Open_IM/pkg/proto/group"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
+6
-6
@@ -1,11 +1,11 @@
|
|||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/src/proto/group"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/proto/group"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -63,7 +63,7 @@ func ApplicationGroupResponse(c *gin.Context) {
|
|||||||
pbData := newGroupApplicationResponse(¶ms)
|
pbData := newGroupApplicationResponse(¶ms)
|
||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
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"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pb "Open_IM/src/proto/group"
|
pb "Open_IM/pkg/proto/group"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pb "Open_IM/src/proto/group"
|
pb "Open_IM/pkg/proto/group"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pb "Open_IM/src/proto/group"
|
pb "Open_IM/pkg/proto/group"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/src/proto/group"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/proto/group"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -41,7 +41,7 @@ func TransferGroupOwner(c *gin.Context) {
|
|||||||
pbData := newTransferGroupOwnerReq(¶ms)
|
pbData := newTransferGroupOwnerReq(¶ms)
|
||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
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"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@@ -7,12 +7,13 @@
|
|||||||
package manage
|
package manage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/common/token_verify"
|
||||||
pbChat "Open_IM/src/proto/chat"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
"Open_IM/src/utils"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
@@ -24,18 +25,20 @@ import (
|
|||||||
var validate *validator.Validate
|
var validate *validator.Validate
|
||||||
|
|
||||||
type paramsManagementSendMsg struct {
|
type paramsManagementSendMsg struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
SendID string `json:"sendID" binding:"required"`
|
SendID string `json:"sendID" binding:"required"`
|
||||||
RecvID string `json:"recvID" binding:"required"`
|
RecvID string `json:"recvID" binding:"required"`
|
||||||
SenderNickName string `json:"senderNickName" `
|
SenderNickName string `json:"senderNickName" `
|
||||||
SenderFaceURL string `json:"senderFaceURL" `
|
SenderFaceURL string `json:"senderFaceURL" `
|
||||||
ForceList []string `json:"forceList" `
|
SenderPlatformID int32 `json:"senderPlatformID"`
|
||||||
Content map[string]interface{} `json:"content" binding:"required"`
|
ForceList []string `json:"forceList" `
|
||||||
ContentType int32 `json:"contentType" binding:"required"`
|
Content map[string]interface{} `json:"content" binding:"required"`
|
||||||
SessionType int32 `json:"sessionType" binding:"required"`
|
ContentType int32 `json:"contentType" binding:"required"`
|
||||||
|
SessionType int32 `json:"sessionType" binding:"required"`
|
||||||
|
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func newUserSendMsgReq(token string, params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
|
func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
|
||||||
var newContent string
|
var newContent string
|
||||||
switch params.ContentType {
|
switch params.ContentType {
|
||||||
case constant.Text:
|
case constant.Text:
|
||||||
@@ -49,16 +52,19 @@ func newUserSendMsgReq(token string, params *paramsManagementSendMsg) *pbChat.Us
|
|||||||
case constant.File:
|
case constant.File:
|
||||||
newContent = utils.StructToJsonString(params.Content)
|
newContent = utils.StructToJsonString(params.Content)
|
||||||
default:
|
default:
|
||||||
|
}
|
||||||
|
options := make(map[string]int32, 2)
|
||||||
|
if params.IsOnlineOnly {
|
||||||
|
options["history"] = 0
|
||||||
|
options["persistent"] = 0
|
||||||
}
|
}
|
||||||
pbData := pbChat.UserSendMsgReq{
|
pbData := pbChat.UserSendMsgReq{
|
||||||
ReqIdentifier: constant.WSSendMsg,
|
ReqIdentifier: constant.WSSendMsg,
|
||||||
Token: token,
|
|
||||||
SendID: params.SendID,
|
SendID: params.SendID,
|
||||||
SenderNickName: params.SenderNickName,
|
SenderNickName: params.SenderNickName,
|
||||||
SenderFaceURL: params.SenderFaceURL,
|
SenderFaceURL: params.SenderFaceURL,
|
||||||
OperationID: params.OperationID,
|
OperationID: params.OperationID,
|
||||||
PlatformID: 0,
|
PlatformID: params.SenderPlatformID,
|
||||||
SessionType: params.SessionType,
|
SessionType: params.SessionType,
|
||||||
MsgFrom: constant.UserMsgType,
|
MsgFrom: constant.UserMsgType,
|
||||||
ContentType: params.ContentType,
|
ContentType: params.ContentType,
|
||||||
@@ -66,6 +72,7 @@ func newUserSendMsgReq(token string, params *paramsManagementSendMsg) *pbChat.Us
|
|||||||
ForceList: params.ForceList,
|
ForceList: params.ForceList,
|
||||||
Content: newContent,
|
Content: newContent,
|
||||||
ClientMsgID: utils.GetMsgID(params.SendID),
|
ClientMsgID: utils.GetMsgID(params.SendID),
|
||||||
|
Options: utils.MapIntToJsonString(options),
|
||||||
}
|
}
|
||||||
return &pbData
|
return &pbData
|
||||||
}
|
}
|
||||||
@@ -85,8 +92,24 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
data = TextElem{}
|
data = TextElem{}
|
||||||
case constant.Picture:
|
case constant.Picture:
|
||||||
data = PictureElem{}
|
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:
|
case constant.Custom:
|
||||||
data = CustomElem{}
|
data = CustomElem{}
|
||||||
|
//case constant.Revoke:
|
||||||
|
//case constant.HasReadReceipt:
|
||||||
|
//case constant.Typing:
|
||||||
|
//case constant.Quote:
|
||||||
default:
|
default:
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
||||||
log.ErrorByKv("contentType err", c.PostForm("operationID"), "content", c.PostForm("content"))
|
log.ErrorByKv("contentType err", c.PostForm("operationID"), "content", c.PostForm("content"))
|
||||||
@@ -103,15 +126,19 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
token := c.Request.Header.Get("token")
|
||||||
if !utils.IsContain(params.SendID, config.Config.Manager.AppManagerUid) {
|
claims, err := token_verify.ParseToken(token)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "not appManager", "sendTime": 0, "MsgID": ""})
|
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": ""})
|
||||||
|
}
|
||||||
|
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "not authorized", "sendTime": 0, "MsgID": ""})
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfoByKv("Ws call success to ManagementSendMsgReq", params.OperationID, "Parameters", params)
|
log.InfoByKv("Ws call success to ManagementSendMsgReq", params.OperationID, "Parameters", params)
|
||||||
|
|
||||||
pbData := newUserSendMsgReq(token, ¶ms)
|
pbData := newUserSendMsgReq(¶ms)
|
||||||
log.Info("", "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())
|
log.Info("", "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
@@ -7,10 +7,10 @@
|
|||||||
package manage
|
package manage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbUser "Open_IM/src/proto/user"
|
pbUser "Open_IM/pkg/proto/user"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -43,10 +43,14 @@ func DeleteUser(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
RpcResp, err := client.DeleteUsers(context.Background(), req)
|
RpcResp, err := client.DeleteUsers(context.Background(), req)
|
||||||
if err != nil {
|
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"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete users rpc server failed"})
|
||||||
return
|
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())
|
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}
|
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "failedUidList": RpcResp.FailedUidList}
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
+4
-3
@@ -1,8 +1,9 @@
|
|||||||
package apiThird
|
package apiThird
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
log2 "Open_IM/src/common/log"
|
"Open_IM/pkg/common/constant"
|
||||||
|
log2 "Open_IM/pkg/common/log"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
sts "github.com/tencentyun/qcloud-cos-sts-sdk/go"
|
sts "github.com/tencentyun/qcloud-cos-sts-sdk/go"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -70,7 +71,7 @@ func TencentCloudStorageCredential(c *gin.Context) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log2.Error(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential cli.GetCredential err = %s", err.Error())
|
log2.Error(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential cli.GetCredential err = %s", err.Error())
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"errCode": config.ErrTencentCredential.ErrCode,
|
"errCode": constant.ErrTencentCredential.ErrCode,
|
||||||
"errMsg": err.Error(),
|
"errMsg": err.Error(),
|
||||||
"bucket": "",
|
"bucket": "",
|
||||||
"region": "",
|
"region": "",
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbUser "Open_IM/src/proto/user"
|
pbUser "Open_IM/pkg/proto/user"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbUser "Open_IM/src/proto/user"
|
pbUser "Open_IM/pkg/proto/user"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package gate
|
package gate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@@ -1,18 +1,17 @@
|
|||||||
package gate
|
package gate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbChat "Open_IM/src/proto/chat"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
pbWs "Open_IM/src/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -31,7 +30,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
|||||||
dec := gob.NewDecoder(b)
|
dec := gob.NewDecoder(b)
|
||||||
err := dec.Decode(&m)
|
err := dec.Decode(&m)
|
||||||
if err != nil {
|
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, "", "")
|
ws.sendErrMsg(conn, 200, err.Error(), constant.WSDataError, "", "")
|
||||||
err = conn.Close()
|
err = conn.Close()
|
||||||
if err != nil {
|
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)
|
ws.sendErrMsg(conn, 201, err.Error(), m.ReqIdentifier, m.MsgIncr, m.OperationID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//if !utils.VerifyToken(m.Token, m.SendID) {
|
//if !utils.VerifyToken(m.Token, m.SendID) {
|
||||||
// ws.sendErrMsg(conn, 202, "token validate err", m.ReqIdentifier, m.MsgIncr,m.OperationID)
|
// ws.sendErrMsg(conn, 202, "token validate err", m.ReqIdentifier, m.MsgIncr,m.OperationID)
|
||||||
// return
|
// return
|
||||||
@@ -63,12 +61,32 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
|||||||
go ws.pullMsgBySeqListReq(conn, &m)
|
go ws.pullMsgBySeqListReq(conn, &m)
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo("", "goroutine num is ", runtime.NumGoroutine())
|
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) {
|
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.MaxSeq = pb.GetMaxSeq()
|
||||||
mReplyData.MinSeq = pb.GetMinSeq()
|
mReplyData.MinSeq = pb.GetMinSeq()
|
||||||
b, _ := proto.Marshal(&mReplyData)
|
b, _ := proto.Marshal(&mReplyData)
|
||||||
@@ -82,29 +100,38 @@ func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *pbChat.GetMaxAndMinSeq
|
|||||||
}
|
}
|
||||||
ws.sendMsg(conn, mReply)
|
ws.sendMsg(conn, mReply)
|
||||||
}
|
}
|
||||||
func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
func (ws *WServer) pullMsgReq(conn *UserConn, m *Req) {
|
||||||
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier)
|
log.NewInfo(m.OperationID, "Ws call success to pullMsgReq", m.ReqIdentifier, m.MsgIncr, m.SendID)
|
||||||
pbData := pbChat.GetMaxAndMinSeqReq{}
|
nReply := new(pbChat.PullMessageResp)
|
||||||
pbData.UserID = m.SendID
|
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsg)
|
||||||
pbData.OperationID = m.OperationID
|
if isPass {
|
||||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
pbData := pbChat.PullMessageReq{}
|
||||||
if grpcConn == nil {
|
pbData.UserID = m.SendID
|
||||||
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", m)
|
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) {
|
func (ws *WServer) pullMsgResp(conn *UserConn, m *Req, pb *pbChat.PullMessageResp) {
|
||||||
log.NewInfo(m.OperationID, "pullMsgResp come here ", pb.String())
|
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)
|
a, err := json.Marshal(pb.SingleUserMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(m.OperationID, "GetSingleUserMsg,json marshal,err", err.Error())
|
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)
|
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) {
|
func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq start", m.SendID, m.ReqIdentifier, m.MsgIncr)
|
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)
|
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 {
|
if isPass {
|
||||||
pbData := pbChat.PullMessageBySeqListReq{}
|
pbData := pbChat.PullMessageBySeqListReq{}
|
||||||
pbData.SeqList = data.(pbWs.PullMessageBySeqListReq).SeqList
|
pbData.SeqList = data.(open_im_sdk.PullMessageBySeqListReq).SeqList
|
||||||
pbData.UserID = m.SendID
|
pbData.UserID = m.SendID
|
||||||
pbData.OperationID = m.OperationID
|
pbData.OperationID = m.OperationID
|
||||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
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)
|
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(pbData.OperationID, "pullMsgBySeqListReq err", err.Error())
|
log.NewError(pbData.OperationID, "pullMsgBySeqListReq err", err.Error())
|
||||||
reply.ErrCode = 200
|
nReply.ErrCode = 200
|
||||||
reply.ErrMsg = err.Error()
|
nReply.ErrMsg = err.Error()
|
||||||
|
ws.pullMsgResp(conn, m, nReply)
|
||||||
} else {
|
} else {
|
||||||
log.NewInfo(pbData.OperationID, "rpc call success to pullMsgBySeqListReq", reply.String(), reply.GetMaxSeq(), reply.GetMinSeq(), len(reply.GetSingleUserMsg()), len(reply.GetGroupUserMsg()))
|
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 {
|
} else {
|
||||||
reply.ErrCode = errCode
|
nReply.ErrCode = errCode
|
||||||
reply.ErrMsg = errMsg
|
nReply.ErrMsg = errMsg
|
||||||
ws.pullMsgResp(conn, m, reply)
|
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) {
|
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)
|
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)
|
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg)
|
||||||
if isPass {
|
if isPass {
|
||||||
data := pData.(pbWs.UserSendMsgReq)
|
data := pData.(open_im_sdk.UserSendMsgReq)
|
||||||
pbData := pbChat.UserSendMsgReq{
|
pbData := pbChat.UserSendMsgReq{
|
||||||
ReqIdentifier: m.ReqIdentifier,
|
ReqIdentifier: m.ReqIdentifier,
|
||||||
Token: m.Token,
|
Token: m.Token,
|
||||||
@@ -244,27 +224,47 @@ func (ws *WServer) sendMsgReq(conn *UserConn, m *Req, sendTime int64) {
|
|||||||
reply, err := client.UserSendMsg(context.Background(), &pbData)
|
reply, err := client.UserSendMsg(context.Background(), &pbData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(pbData.OperationID, "UserSendMsg err", err.Error())
|
log.NewError(pbData.OperationID, "UserSendMsg err", err.Error())
|
||||||
reply.ErrCode = 200
|
nReply.ErrCode = 200
|
||||||
reply.ErrMsg = err.Error()
|
nReply.ErrMsg = err.Error()
|
||||||
|
ws.sendMsgResp(conn, m, nReply, sendTime)
|
||||||
} else {
|
} else {
|
||||||
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
|
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
|
||||||
|
ws.sendMsgResp(conn, m, reply, sendTime)
|
||||||
}
|
}
|
||||||
ws.sendMsgResp(conn, m, reply, sendTime)
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
reply.ErrCode = errCode
|
nReply.ErrCode = errCode
|
||||||
reply.ErrMsg = errMsg
|
nReply.ErrMsg = errMsg
|
||||||
ws.sendMsgResp(conn, m, reply, sendTime)
|
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{}) {
|
func (ws *WServer) sendMsg(conn *UserConn, mReply interface{}) {
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
enc := gob.NewEncoder(&b)
|
enc := gob.NewEncoder(&b)
|
||||||
err := enc.Encode(mReply)
|
err := enc.Encode(mReply)
|
||||||
if err != nil {
|
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())
|
err = ws.writeMsg(conn, websocket.BinaryMessage, b.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1,22 +1,23 @@
|
|||||||
package gate
|
package gate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbRelay "Open_IM/src/proto/relay"
|
pbRelay "Open_IM/pkg/proto/relay"
|
||||||
pbWs "Open_IM/src/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/gorilla/websocket"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RPCServer struct {
|
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())
|
log.InfoByKv("PushMsgToUser is arriving", in.OperationID, "args", in.String())
|
||||||
var resp []*pbRelay.SingleMsgToUser
|
var resp []*pbRelay.SingleMsgToUser
|
||||||
var RecvID string
|
var RecvID string
|
||||||
msg := pbWs.MsgData{
|
msg := open_im_sdk.MsgData{
|
||||||
SendID: in.SendID,
|
SendID: in.SendID,
|
||||||
RecvID: in.RecvID,
|
RecvID: in.RecvID,
|
||||||
MsgFrom: in.MsgFrom,
|
MsgFrom: in.MsgFrom,
|
||||||
@@ -83,7 +84,7 @@ func (r *RPCServer) MsgToUser(_ context.Context, in *pbRelay.MsgToUserReq) (*pbR
|
|||||||
enc := gob.NewEncoder(&replyBytes)
|
enc := gob.NewEncoder(&replyBytes)
|
||||||
err := enc.Encode(mReply)
|
err := enc.Encode(mReply)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
log.NewError(in.OperationID, "data encode err", err.Error())
|
||||||
}
|
}
|
||||||
switch in.GetSessionType() {
|
switch in.GetSessionType() {
|
||||||
case constant.SingleChatType:
|
case constant.SingleChatType:
|
||||||
@@ -92,22 +93,30 @@ func (r *RPCServer) MsgToUser(_ context.Context, in *pbRelay.MsgToUserReq) (*pbR
|
|||||||
RecvID = strings.Split(in.GetRecvID(), " ")[0]
|
RecvID = strings.Split(in.GetRecvID(), " ")[0]
|
||||||
}
|
}
|
||||||
var tag bool
|
var tag bool
|
||||||
|
var UIDAndPID []string
|
||||||
userIDList := genUidPlatformArray(RecvID)
|
userIDList := genUidPlatformArray(RecvID)
|
||||||
for _, v := range userIDList {
|
for _, v := range userIDList {
|
||||||
|
UIDAndPID = strings.Split(v, " ")
|
||||||
if conn := ws.getUserConn(v); conn != nil {
|
if conn := ws.getUserConn(v); conn != nil {
|
||||||
UIDAndPID := strings.Split(v, " ")
|
|
||||||
tag = true
|
tag = true
|
||||||
resultCode := sendMsgToUser(conn, replyBytes.Bytes(), in, UIDAndPID[1], UIDAndPID[0])
|
resultCode := sendMsgToUser(conn, replyBytes.Bytes(), in, UIDAndPID[1], UIDAndPID[0])
|
||||||
temp := &pbRelay.SingleMsgToUser{
|
temp := &pbRelay.SingleMsgToUser{
|
||||||
ResultCode: resultCode,
|
ResultCode: resultCode,
|
||||||
RecvID: UIDAndPID[0],
|
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: constant.PlatformNameToID(UIDAndPID[1]),
|
||||||
}
|
}
|
||||||
resp = append(resp, temp)
|
resp = append(resp, temp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !tag {
|
if !tag {
|
||||||
log.NewError(in.OperationID, "push err ,ws conn not in map", in.String())
|
log.NewError(in.OperationID, "push err ,no matched ws conn not in map", in.String())
|
||||||
}
|
}
|
||||||
return &pbRelay.MsgToUserResp{
|
return &pbRelay.MsgToUserResp{
|
||||||
Resp: resp,
|
Resp: resp,
|
||||||
@@ -118,7 +127,7 @@ func sendMsgToUser(conn *UserConn, bMsg []byte, in *pbRelay.MsgToUserReq, RecvPl
|
|||||||
err := ws.writeMsg(conn, websocket.BinaryMessage, bMsg)
|
err := ws.writeMsg(conn, websocket.BinaryMessage, bMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("PushMsgToUser is failed By Ws", "", "Addr", conn.RemoteAddr().String(),
|
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
|
ResultCode = -2
|
||||||
return ResultCode
|
return ResultCode
|
||||||
} else {
|
} else {
|
||||||
@@ -129,8 +138,8 @@ func sendMsgToUser(conn *UserConn, bMsg []byte, in *pbRelay.MsgToUserReq, RecvPl
|
|||||||
|
|
||||||
}
|
}
|
||||||
func genUidPlatformArray(uid string) (array []string) {
|
func genUidPlatformArray(uid string) (array []string) {
|
||||||
for i := 1; i <= utils.LinuxPlatformID; i++ {
|
for i := 1; i <= constant.LinuxPlatformID; i++ {
|
||||||
array = append(array, uid+" "+utils.PlatformIDToName(int32(i)))
|
array = append(array, uid+" "+constant.PlatformIDToName(int32(i)))
|
||||||
}
|
}
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,9 @@
|
|||||||
package gate
|
package gate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
pbWs "Open_IM/src/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"github.com/golang/protobuf/proto"
|
"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{}) {
|
func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, errMsg string, returnData interface{}) {
|
||||||
switch r {
|
switch r {
|
||||||
case constant.WSSendMsg:
|
case constant.WSSendMsg:
|
||||||
data := pbWs.UserSendMsgReq{}
|
data := open_im_sdk.UserSendMsgReq{}
|
||||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||||
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
||||||
return false, 203, err.Error(), nil
|
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
|
return true, 0, "", data
|
||||||
case constant.WSPullMsgBySeqList:
|
case constant.WSPullMsgBySeqList:
|
||||||
data := pbWs.PullMessageBySeqListReq{}
|
data := open_im_sdk.PullMessageBySeqListReq{}
|
||||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||||
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
||||||
return false, 203, err.Error(), nil
|
return false, 203, err.Error(), nil
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
package gate
|
package gate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/utils"
|
"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"
|
"github.com/gorilla/websocket"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -53,10 +58,10 @@ func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
} else {
|
} else {
|
||||||
//Connection mapping relationship,
|
//Connection mapping relationship,
|
||||||
//userID+" "+platformID->conn
|
//userID+" "+platformID->conn
|
||||||
SendID := query["sendID"][0] + " " + utils.PlatformIDToName(int32(utils.StringToInt64(query["platformID"][0])))
|
|
||||||
//Initialize a lock for each user
|
//Initialize a lock for each user
|
||||||
newConn := &UserConn{conn, new(sync.Mutex)}
|
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)
|
go ws.readMsg(newConn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,20 +91,70 @@ func (ws *WServer) writeMsg(conn *UserConn, a int, msg []byte) error {
|
|||||||
return conn.WriteMessage(a, msg)
|
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()
|
rwLock.Lock()
|
||||||
defer rwLock.Unlock()
|
defer rwLock.Unlock()
|
||||||
if oldConn, ok := ws.wsUserToConn[uid]; ok {
|
ws.MultiTerminalLoginChecker(uid, platformID, conn, token)
|
||||||
err := oldConn.Close()
|
ws.wsConnToUser[conn] = key
|
||||||
delete(ws.wsConnToUser, oldConn)
|
ws.wsUserToConn[key] = conn
|
||||||
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
|
|
||||||
log.WarnByKv("WS Add operation", "", "wsUser added", ws.wsUserToConn, "uid", uid, "online_num", len(ws.wsUserToConn))
|
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
|
status := http.StatusUnauthorized
|
||||||
query := r.URL.Query()
|
query := r.URL.Query()
|
||||||
if len(query["token"]) != 0 && len(query["sendID"]) != 0 && len(query["platformID"]) != 0 {
|
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)
|
log.ErrorByKv("Token verify failed", "", "query", query)
|
||||||
w.Header().Set("Sec-Websocket-Version", "13")
|
w.Header().Set("Sec-Websocket-Version", "13")
|
||||||
http.Error(w, http.StatusText(status), status)
|
http.Error(w, e.ErrMsg, int(e.ErrCode))
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
log.InfoByKv("Connection Authentication Success", "", "token", query["token"][0], "userID", query["sendID"][0])
|
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
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
pbMsg "Open_IM/src/proto/chat"
|
pbMsg "Open_IM/pkg/proto/chat"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func saveUserChat(uid string, pbMsg *pbMsg.MsgSvrToPushSvrChatMsg) error {
|
func saveUserChat(uid string, pbMsg *pbMsg.MsgSvrToPushSvrChatMsg) error {
|
||||||
+30
-24
@@ -1,14 +1,14 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
kfk "Open_IM/src/common/kafka"
|
kfk "Open_IM/pkg/common/kafka"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbMsg "Open_IM/src/proto/chat"
|
pbMsg "Open_IM/pkg/proto/chat"
|
||||||
pbPush "Open_IM/src/proto/push"
|
pbPush "Open_IM/pkg/proto/push"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"github.com/Shopify/sarama"
|
"github.com/Shopify/sarama"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
@@ -33,7 +33,7 @@ func (mc *HistoryConsumerHandler) Init() {
|
|||||||
|
|
||||||
func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) {
|
func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) {
|
||||||
log.InfoByKv("chat come mongo!!!", "", "chat", string(msg))
|
log.InfoByKv("chat come mongo!!!", "", "chat", string(msg))
|
||||||
time := utils.GetCurrentTimestampBySecond()
|
time := utils.GetCurrentTimestampByNano()
|
||||||
pbData := pbMsg.WSToMsgSvrChatMsg{}
|
pbData := pbMsg.WSToMsgSvrChatMsg{}
|
||||||
err := proto.Unmarshal(msg, &pbData)
|
err := proto.Unmarshal(msg, &pbData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -59,47 +59,53 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string)
|
|||||||
isHistory := utils.GetSwitchFromOptions(Options, "history")
|
isHistory := utils.GetSwitchFromOptions(Options, "history")
|
||||||
//Control whether to store history messages (mysql)
|
//Control whether to store history messages (mysql)
|
||||||
isPersist := utils.GetSwitchFromOptions(Options, "persistent")
|
isPersist := utils.GetSwitchFromOptions(Options, "persistent")
|
||||||
if pbData.SessionType == constant.SingleChatType {
|
switch pbData.SessionType {
|
||||||
log.Info("", "", "msg_transfer chat type = SingleChatType", isHistory, isPersist)
|
case constant.SingleChatType:
|
||||||
|
log.NewDebug(pbSaveData.OperationID, "msg_transfer chat type = SingleChatType", isHistory, isPersist)
|
||||||
if isHistory {
|
if isHistory {
|
||||||
if msgKey == pbSaveData.RecvID {
|
if msgKey == pbSaveData.RecvID {
|
||||||
err := saveUserChat(pbData.RecvID, &pbSaveData)
|
err := saveUserChat(pbData.RecvID, &pbSaveData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("data insert to mongo err", pbSaveData.OperationID, "data", pbSaveData.String(), "err", err.Error())
|
log.NewError(pbSaveData.OperationID, "single data insert to mongo err", err.Error(), pbSaveData.String())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if msgKey == pbSaveData.SendID {
|
} else if msgKey == pbSaveData.SendID {
|
||||||
err := saveUserChat(pbData.SendID, &pbSaveData)
|
err := saveUserChat(pbData.SendID, &pbSaveData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("data insert to mongo err", pbSaveData.OperationID, "data", pbSaveData.String(), "err", err.Error())
|
log.NewError(pbSaveData.OperationID, "single data insert to mongo err", err.Error(), pbSaveData.String())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(pbSaveData.OperationID, "saveUserChat cost time ", utils.GetCurrentTimestampBySecond()-time)
|
log.NewDebug(pbSaveData.OperationID, "saveUserChat cost time ", utils.GetCurrentTimestampByNano()-time)
|
||||||
}
|
}
|
||||||
if msgKey == pbSaveData.RecvID {
|
if msgKey == pbSaveData.RecvID {
|
||||||
pbSaveData.Options = pbData.Options
|
pbSaveData.Options = pbData.Options
|
||||||
pbSaveData.OfflineInfo = pbData.OfflineInfo
|
pbSaveData.OfflineInfo = pbData.OfflineInfo
|
||||||
go sendMessageToPush(&pbSaveData)
|
go sendMessageToPush(&pbSaveData)
|
||||||
log.NewInfo(pbSaveData.OperationID, "sendMessageToPush cost time ", utils.GetCurrentTimestampBySecond()-time)
|
log.NewDebug(pbSaveData.OperationID, "sendMessageToPush cost time ", utils.GetCurrentTimestampByNano()-time)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfoByKv("msg_transfer handle topic success...", "", "")
|
case constant.GroupChatType:
|
||||||
} else if pbData.SessionType == constant.GroupChatType {
|
log.NewDebug(pbSaveData.OperationID, "msg_transfer chat type = GroupChatType", isHistory, isPersist)
|
||||||
log.Info("", "", "msg_transfer chat type = GroupChatType")
|
|
||||||
if isHistory {
|
if isHistory {
|
||||||
uidAndGroupID := strings.Split(pbData.RecvID, " ")
|
uidAndGroupID := strings.Split(pbData.RecvID, " ")
|
||||||
saveUserChat(uidAndGroupID[0], &pbSaveData)
|
err := saveUserChat(uidAndGroupID[0], &pbSaveData)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(pbSaveData.OperationID, "group data insert to mongo err", pbSaveData.String(), uidAndGroupID[0], err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pbSaveData.Options = pbData.Options
|
pbSaveData.Options = pbData.Options
|
||||||
pbSaveData.OfflineInfo = pbData.OfflineInfo
|
pbSaveData.OfflineInfo = pbData.OfflineInfo
|
||||||
sendMessageToPush(&pbSaveData)
|
go sendMessageToPush(&pbSaveData)
|
||||||
log.InfoByKv("msg_transfer handle topic success...", "", "")
|
default:
|
||||||
} else {
|
log.NewError(pbSaveData.OperationID, "SessionType error", pbSaveData.String())
|
||||||
log.Error("", "", "msg_transfer recv chat err, chat.MsgFrom = %d", pbData.SessionType)
|
return
|
||||||
}
|
}
|
||||||
|
log.NewDebug(pbSaveData.OperationID, "msg_transfer handle topic data to database success...", pbSaveData.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (HistoryConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
|
func (HistoryConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/kafka"
|
"Open_IM/pkg/common/kafka"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -20,6 +20,6 @@ func Init() {
|
|||||||
}
|
}
|
||||||
func Run() {
|
func Run() {
|
||||||
//register mysqlConsumerHandler to
|
//register mysqlConsumerHandler to
|
||||||
//go persistentCH.persistentConsumerGroup.RegisterHandleAndConsumer(&persistentCH)
|
go persistentCH.persistentConsumerGroup.RegisterHandleAndConsumer(&persistentCH)
|
||||||
go historyCH.historyConsumerGroup.RegisterHandleAndConsumer(&historyCH)
|
go historyCH.historyConsumerGroup.RegisterHandleAndConsumer(&historyCH)
|
||||||
}
|
}
|
||||||
+7
-7
@@ -7,13 +7,13 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/db/mysql_model/im_mysql_msg_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_msg_model"
|
||||||
kfk "Open_IM/src/common/kafka"
|
kfk "Open_IM/pkg/common/kafka"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
pbMsg "Open_IM/src/proto/chat"
|
pbMsg "Open_IM/pkg/proto/chat"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
"github.com/Shopify/sarama"
|
"github.com/Shopify/sarama"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -1,27 +1,29 @@
|
|||||||
package push
|
package push
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/internal/push/jpush/common"
|
||||||
"Open_IM/src/push/jpush/common"
|
"Open_IM/internal/push/jpush/requestBody"
|
||||||
"Open_IM/src/push/jpush/requestBody"
|
"Open_IM/pkg/common/config"
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type JPushResp struct {
|
type JPushResp struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func JGAccountListPush(accounts []string, jsonCustomContent string, platform string) (*http.Response, error) {
|
func JGAccountListPush(accounts []string, content, detailContent, platform string) ([]byte, error) {
|
||||||
|
|
||||||
var pf requestBody.Platform
|
var pf requestBody.Platform
|
||||||
_ = pf.SetPlatform(platform)
|
_ = pf.SetPlatform(platform)
|
||||||
var au requestBody.Audience
|
var au requestBody.Audience
|
||||||
au.SetAlias(accounts)
|
au.SetAlias(accounts)
|
||||||
var no requestBody.Notification
|
var no requestBody.Notification
|
||||||
no.SetAlert(jsonCustomContent)
|
no.SetAlert(content)
|
||||||
|
no.SetAndroidIntent()
|
||||||
var me requestBody.Message
|
var me requestBody.Message
|
||||||
me.SetMsgContent(jsonCustomContent)
|
me.SetMsgContent(detailContent)
|
||||||
var po requestBody.PushObj
|
var po requestBody.PushObj
|
||||||
po.SetPlatform(&pf)
|
po.SetPlatform(&pf)
|
||||||
po.SetAudience(&au)
|
po.SetAudience(&au)
|
||||||
@@ -42,9 +44,13 @@ func JGAccountListPush(accounts []string, jsonCustomContent string, platform str
|
|||||||
req.Header.Set("Authorization", common.GetAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret))
|
req.Header.Set("Authorization", common.GetAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret))
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
defer resp.Body.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return resp, nil
|
defer resp.Body.Close()
|
||||||
|
result, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
@@ -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
|
package requestBody
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/common/constant"
|
||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -53,9 +53,9 @@ func (p *Platform) Set(os string) error {
|
|||||||
}
|
}
|
||||||
func (p *Platform) SetPlatform(platform string) error {
|
func (p *Platform) SetPlatform(platform string) error {
|
||||||
switch platform {
|
switch platform {
|
||||||
case utils.AndroidPlatformStr:
|
case constant.AndroidPlatformStr:
|
||||||
return p.SetAndroid()
|
return p.SetAndroid()
|
||||||
case utils.IOSPlatformStr:
|
case constant.IOSPlatformStr:
|
||||||
return p.SetIOS()
|
return p.SetIOS()
|
||||||
default:
|
default:
|
||||||
return errors.New("platform err")
|
return errors.New("platform err")
|
||||||
@@ -7,10 +7,10 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/kafka"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/kafka"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/common/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -24,7 +24,7 @@ func Init(rpcPort int) {
|
|||||||
log.NewPrivateLog(config.Config.ModuleName.PushName)
|
log.NewPrivateLog(config.Config.ModuleName.PushName)
|
||||||
rpcServer.Init(rpcPort)
|
rpcServer.Init(rpcPort)
|
||||||
pushCh.Init()
|
pushCh.Init()
|
||||||
pushTerminal = []int32{utils.IOSPlatformID, utils.AndroidPlatformID}
|
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}
|
||||||
}
|
}
|
||||||
func init() {
|
func init() {
|
||||||
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
|
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
|
||||||
@@ -7,11 +7,11 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
kfk "Open_IM/src/common/kafka"
|
kfk "Open_IM/pkg/common/kafka"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
pbChat "Open_IM/src/proto/chat"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
pbRelay "Open_IM/src/proto/relay"
|
pbRelay "Open_IM/pkg/proto/relay"
|
||||||
"github.com/Shopify/sarama"
|
"github.com/Shopify/sarama"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
"Open_IM/src/proto/push"
|
"Open_IM/pkg/proto/push"
|
||||||
pbRelay "Open_IM/src/proto/relay"
|
pbRelay "Open_IM/pkg/proto/relay"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"net"
|
"net"
|
||||||
@@ -7,31 +7,35 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
push "Open_IM/internal/push/jpush"
|
||||||
"Open_IM/src/common/constant"
|
rpcChat "Open_IM/internal/rpc/chat"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/common/constant"
|
||||||
pbChat "Open_IM/src/proto/chat"
|
"Open_IM/pkg/common/log"
|
||||||
pbGroup "Open_IM/src/proto/group"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbRelay "Open_IM/src/proto/relay"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
push "Open_IM/src/push/jpush"
|
pbGroup "Open_IM/pkg/proto/group"
|
||||||
rpcChat "Open_IM/src/rpc/chat/chat"
|
pbRelay "Open_IM/pkg/proto/relay"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EChatContent struct {
|
type OpenIMContent struct {
|
||||||
SessionType int `json:"chatType"`
|
SessionType int `json:"sessionType"`
|
||||||
From string `json:"from"`
|
From string `json:"from"`
|
||||||
To string `json:"to"`
|
To string `json:"to"`
|
||||||
Seq int64 `json:"seq"`
|
Seq int64 `json:"seq"`
|
||||||
}
|
}
|
||||||
|
type AtContent struct {
|
||||||
|
Text string `json:"text"`
|
||||||
|
AtUserList []string `json:"atUserList"`
|
||||||
|
IsAtSelf bool `json:"isAtSelf"`
|
||||||
|
}
|
||||||
|
|
||||||
func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) {
|
func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) {
|
||||||
var wsResult []*pbRelay.SingleMsgToUser
|
var wsResult []*pbRelay.SingleMsgToUser
|
||||||
isShouldOfflinePush := true
|
|
||||||
MOptions := utils.JsonStringToMap(Options) //Control whether to push message to sender's other terminal
|
MOptions := utils.JsonStringToMap(Options) //Control whether to push message to sender's other terminal
|
||||||
//isSenderSync := utils.GetSwitchFromOptions(MOptions, "senderSync")
|
//isSenderSync := utils.GetSwitchFromOptions(MOptions, "senderSync")
|
||||||
isOfflinePush := utils.GetSwitchFromOptions(MOptions, "offlinePush")
|
isOfflinePush := utils.GetSwitchFromOptions(MOptions, "offlinePush")
|
||||||
@@ -50,49 +54,61 @@ func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.InfoByKv("push_result", sendPbData.OperationID, "result", wsResult, "sendData", sendPbData)
|
log.InfoByKv("push_result", sendPbData.OperationID, "result", wsResult, "sendData", sendPbData)
|
||||||
if isOfflinePush {
|
if sendPbData.ContentType != constant.Typing && sendPbData.ContentType != constant.HasReadReceipt {
|
||||||
|
if isOfflinePush {
|
||||||
for _, t := range pushTerminal {
|
|
||||||
for _, v := range wsResult {
|
for _, v := range wsResult {
|
||||||
if v.RecvPlatFormID == t && v.ResultCode == 0 {
|
if v.ResultCode == 0 {
|
||||||
isShouldOfflinePush = false
|
continue
|
||||||
break
|
}
|
||||||
|
//supported terminal
|
||||||
|
for _, t := range pushTerminal {
|
||||||
|
if v.RecvPlatFormID == t {
|
||||||
|
//Use offline push messaging
|
||||||
|
var UIDList []string
|
||||||
|
UIDList = append(UIDList, v.RecvID)
|
||||||
|
customContent := OpenIMContent{
|
||||||
|
SessionType: int(sendPbData.SessionType),
|
||||||
|
From: sendPbData.SendID,
|
||||||
|
To: sendPbData.RecvID,
|
||||||
|
Seq: sendPbData.RecvSeq,
|
||||||
|
}
|
||||||
|
bCustomContent, _ := json.Marshal(customContent)
|
||||||
|
jsonCustomContent := string(bCustomContent)
|
||||||
|
var content string
|
||||||
|
switch sendPbData.ContentType {
|
||||||
|
case constant.Text:
|
||||||
|
content = constant.ContentType2PushContent[constant.Text]
|
||||||
|
case constant.Picture:
|
||||||
|
content = constant.ContentType2PushContent[constant.Picture]
|
||||||
|
case constant.Voice:
|
||||||
|
content = constant.ContentType2PushContent[constant.Voice]
|
||||||
|
case constant.Video:
|
||||||
|
content = constant.ContentType2PushContent[constant.Video]
|
||||||
|
case constant.File:
|
||||||
|
content = constant.ContentType2PushContent[constant.File]
|
||||||
|
case constant.AtText:
|
||||||
|
a := AtContent{}
|
||||||
|
_ = utils.JsonStringToStruct(sendPbData.Content, &a)
|
||||||
|
if utils.IsContain(v.RecvID, a.AtUserList) {
|
||||||
|
content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
||||||
|
} else {
|
||||||
|
content = constant.ContentType2PushContent[constant.GroupMsg]
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
content = constant.ContentType2PushContent[constant.Common]
|
||||||
|
}
|
||||||
|
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 {
|
||||||
|
log.NewDebug(sendPbData.OperationID, "offline push return result is ", string(pushResult), sendPbData, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if isShouldOfflinePush {
|
|
||||||
//Use offline push messaging
|
|
||||||
var UIDList []string
|
|
||||||
UIDList = append(UIDList, sendPbData.RecvID)
|
|
||||||
customContent := EChatContent{
|
|
||||||
SessionType: int(sendPbData.SessionType),
|
|
||||||
From: sendPbData.SendID,
|
|
||||||
To: sendPbData.RecvID,
|
|
||||||
Seq: sendPbData.RecvSeq,
|
|
||||||
}
|
|
||||||
bCustomContent, _ := json.Marshal(customContent)
|
|
||||||
|
|
||||||
jsonCustomContent := string(bCustomContent)
|
|
||||||
//switch sendPbData.ContentType {
|
|
||||||
//case constant.Text:
|
|
||||||
// IOSAccountListPush(UIDList, sendPbData.SenderNickName, sendPbData.Content, jsonCustomContent)
|
|
||||||
//case constant.Picture:
|
|
||||||
// IOSAccountListPush(UIDList, sendPbData.SenderNickName, constant.ContentType2PushContent[constant.Picture], jsonCustomContent)
|
|
||||||
//case constant.Voice:
|
|
||||||
// IOSAccountListPush(UIDList, sendPbData.SenderNickName, constant.ContentType2PushContent[constant.Voice], jsonCustomContent)
|
|
||||||
//case constant.Video:
|
|
||||||
// IOSAccountListPush(UIDList, sendPbData.SenderNickName, constant.ContentType2PushContent[constant.Video], jsonCustomContent)
|
|
||||||
//case constant.File:
|
|
||||||
// IOSAccountListPush(UIDList, sendPbData.SenderNickName, constant.ContentType2PushContent[constant.File], jsonCustomContent)
|
|
||||||
//default:
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
push.JGAccountListPush(UIDList, jsonCustomContent, utils.PlatformIDToName(t))
|
|
||||||
|
|
||||||
} else {
|
|
||||||
isShouldOfflinePush = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
tpns "Open_IM/internal/push/sdk/tpns-server-sdk-go/go"
|
||||||
tpns "Open_IM/src/push/sdk/tpns-server-sdk-go/go"
|
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/auth"
|
||||||
"Open_IM/src/push/sdk/tpns-server-sdk-go/go/auth"
|
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/common"
|
||||||
"Open_IM/src/push/sdk/tpns-server-sdk-go/go/common"
|
"Open_IM/internal/push/sdk/tpns-server-sdk-go/go/req"
|
||||||
"Open_IM/src/push/sdk/tpns-server-sdk-go/go/req"
|
"Open_IM/pkg/common/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
var badgeType = -2
|
var badgeType = -2
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
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"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package req
|
package req
|
||||||
|
|
||||||
import (
|
import (
|
||||||
tpns "Open_IM/src/push/sdk/tpns-server-sdk-go/go"
|
tpns "Open_IM/internal/push/sdk/tpns-server-sdk-go/go"
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
package rpcAuth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
pbAuth "Open_IM/pkg/proto/auth"
|
||||||
pbAuth "Open_IM/src/proto/auth"
|
"Open_IM/pkg/utils"
|
||||||
"Open_IM/src/utils"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -1,15 +1,18 @@
|
|||||||
package rpcAuth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
pbAuth "Open_IM/src/proto/auth"
|
pbAuth "Open_IM/pkg/proto/auth"
|
||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (rpc *rpcAuth) UserRegister(_ context.Context, pb *pbAuth.UserRegisterReq) (*pbAuth.UserRegisterResp, error) {
|
func (rpc *rpcAuth) UserRegister(_ context.Context, pb *pbAuth.UserRegisterReq) (*pbAuth.UserRegisterResp, error) {
|
||||||
log.Info("", "", "rpc user_register start, [data: %s]", pb.String())
|
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 {
|
if err := im_mysql_model.UserRegister(pb); err != nil {
|
||||||
log.Error("", "", "rpc user_register error, [data: %s] [err: %s]", pb.String(), err.Error())
|
log.Error("", "", "rpc user_register error, [data: %s] [err: %s]", pb.String(), err.Error())
|
||||||
return &pbAuth.UserRegisterResp{Success: false}, err
|
return &pbAuth.UserRegisterResp{Success: false}, err
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package rpcAuth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
pbAuth "Open_IM/src/proto/auth"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/src/utils"
|
pbAuth "Open_IM/pkg/proto/auth"
|
||||||
"context"
|
"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")
|
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 {
|
if err != nil {
|
||||||
log.Error("", "", "rpc user_token call..., utils.CreateToken fail [uid: %s] [err: %s]", pb.UID, err.Error())
|
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
|
return &pbAuth.UserTokenResp{ErrCode: 500, ErrMsg: err.Error()}, err
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
package rpcChat
|
package chat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/garyburd/redigo/redis"
|
"github.com/garyburd/redigo/redis"
|
||||||
|
|
||||||
commonDB "Open_IM/src/common/db"
|
commonDB "Open_IM/pkg/common/db"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"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) {
|
func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *pbMsg.GetMaxAndMinSeqReq) (*pbMsg.GetMaxAndMinSeqResp, error) {
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package rpcChat
|
package chat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/kafka"
|
"Open_IM/pkg/common/kafka"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbChat "Open_IM/src/proto/chat"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
package rpcChat
|
package chat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/api/group"
|
"Open_IM/internal/api/group"
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/internal/push/content_struct"
|
||||||
"Open_IM/src/common/constant"
|
"Open_IM/pkg/common/config"
|
||||||
http2 "Open_IM/src/common/http"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/log"
|
http2 "Open_IM/pkg/common/http"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/common/log"
|
||||||
pbChat "Open_IM/src/proto/chat"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbGroup "Open_IM/src/proto/group"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
"Open_IM/src/push/content_struct"
|
pbGroup "Open_IM/pkg/proto/group"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@@ -21,14 +21,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MsgCallBackReq struct {
|
type MsgCallBackReq struct {
|
||||||
SendID string `json:"sendID"`
|
SendID string `json:"sendID"`
|
||||||
RecvID string `json:"recvID"`
|
RecvID string `json:"recvID"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
SendTime int64 `json:"sendTime"`
|
SendTime int64 `json:"sendTime"`
|
||||||
MsgFrom int32 `json:"msgFrom"`
|
MsgFrom int32 `json:"msgFrom"`
|
||||||
ContentType int32 `json:"contentType"`
|
ContentType int32 `json:"contentType"`
|
||||||
SessionType int32 `json:"sessionType"`
|
SessionType int32 `json:"sessionType"`
|
||||||
PlatformID int32 `json:"senderPlatformID"`
|
PlatformID int32 `json:"senderPlatformID"`
|
||||||
|
MsgID string `json:"msgID"`
|
||||||
|
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||||
}
|
}
|
||||||
type MsgCallBackResp struct {
|
type MsgCallBackResp struct {
|
||||||
ErrCode int32 `json:"errCode"`
|
ErrCode int32 `json:"errCode"`
|
||||||
@@ -42,12 +44,9 @@ type MsgCallBackResp struct {
|
|||||||
|
|
||||||
func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (*pbChat.UserSendMsgResp, error) {
|
func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (*pbChat.UserSendMsgResp, error) {
|
||||||
replay := pbChat.UserSendMsgResp{}
|
replay := pbChat.UserSendMsgResp{}
|
||||||
log.InfoByKv("sendMsg", pb.OperationID, "args", pb.String())
|
log.NewDebug(pb.OperationID, "rpc sendMsg come here", pb.String())
|
||||||
time := utils.GetCurrentTimestampByMill()
|
|
||||||
//if !utils.VerifyToken(pb.Token, pb.SendID) {
|
//if !utils.VerifyToken(pb.Token, pb.SendID) {
|
||||||
// return returnMsg(&replay, pb, http.StatusUnauthorized, "token validate err,not authorized", "", 0)
|
// return returnMsg(&replay, pb, http.StatusUnauthorized, "token validate err,not authorized", "", 0)
|
||||||
//}
|
|
||||||
log.NewInfo(pb.OperationID, "VerifyToken cost time ", utils.GetCurrentTimestampByMill()-time)
|
|
||||||
serverMsgID := GetMsgID(pb.SendID)
|
serverMsgID := GetMsgID(pb.SendID)
|
||||||
pbData := pbChat.WSToMsgSvrChatMsg{}
|
pbData := pbChat.WSToMsgSvrChatMsg{}
|
||||||
pbData.MsgFrom = pb.MsgFrom
|
pbData.MsgFrom = pb.MsgFrom
|
||||||
@@ -71,38 +70,43 @@ func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (*
|
|||||||
} else {
|
} else {
|
||||||
pbData.SendTime = pb.SendTime
|
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 {
|
if config.Config.MessageCallBack.CallbackSwitch {
|
||||||
bMsg, err := http2.Post(config.Config.MessageCallBack.CallbackUrl, MsgCallBackReq{
|
bMsg, err := http2.Post(config.Config.MessageCallBack.CallbackUrl, mReq, config.Config.MessageCallBack.CallBackTimeOut)
|
||||||
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")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("callback to Business server err", pb.OperationID, "args", pb.String(), "err", err.Error())
|
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)
|
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())
|
log.ErrorByKv("ws json Unmarshal err", pb.OperationID, "args", pb.String(), "err", err.Error())
|
||||||
return returnMsg(&replay, pb, 200, err.Error(), "", 0)
|
return returnMsg(&replay, pb, 200, err.Error(), "", 0)
|
||||||
} else {
|
} else {
|
||||||
if m.ErrCode != 0 {
|
if mResp.ErrCode != 0 {
|
||||||
return returnMsg(&replay, pb, m.ResponseErrCode, m.ErrMsg, "", 0)
|
return returnMsg(&replay, pb, mResp.ResponseErrCode, mResp.ErrMsg, "", 0)
|
||||||
} else {
|
} else {
|
||||||
pbData.Content = m.ResponseResult.ModifiedMsg
|
pbData.Content = mResp.ResponseResult.ModifiedMsg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch pbData.SessionType {
|
switch pbData.SessionType {
|
||||||
case constant.SingleChatType:
|
case constant.SingleChatType:
|
||||||
time := utils.GetCurrentTimestampByMill()
|
|
||||||
err1 := rpc.sendMsgToKafka(&pbData, pbData.RecvID)
|
err1 := rpc.sendMsgToKafka(&pbData, pbData.RecvID)
|
||||||
err2 := rpc.sendMsgToKafka(&pbData, pbData.SendID)
|
err2 := rpc.sendMsgToKafka(&pbData, pbData.SendID)
|
||||||
log.NewInfo(pb.OperationID, "send kafka cost time ", utils.GetCurrentTimestampByMill()-time)
|
|
||||||
if err1 != nil || err2 != nil {
|
if err1 != nil || err2 != nil {
|
||||||
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,23 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *friendServer) AddBlacklist(ctx context.Context, req *pbFriend.AddBlacklistReq) (*pbFriend.CommonResp, error) {
|
func (s *friendServer) AddBlacklist(ctx context.Context, req *pbFriend.AddBlacklistReq) (*pbFriend.CommonResp, error) {
|
||||||
log.Info(req.Token, req.OperationID, "rpc add blacklist is server,args=%s", req.String())
|
log.Info(req.Token, req.OperationID, "rpc add blacklist is server,args=%s", req.String())
|
||||||
//Parse token, to find current user information
|
//Parse token, to find current user information
|
||||||
claims, err := utils.ParseToken(req.Token)
|
claims, err := token_verify.ParseToken(req.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
||||||
return &pbFriend.CommonResp{ErrorCode: config.ErrParseToken.ErrCode, ErrorMsg: config.ErrParseToken.ErrMsg}, nil
|
return &pbFriend.CommonResp{ErrorCode: constant.ErrParseToken.ErrCode, ErrorMsg: constant.ErrParseToken.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
isMagagerFlag := 0
|
isMagagerFlag := 0
|
||||||
@@ -29,7 +31,7 @@ func (s *friendServer) AddBlacklist(ctx context.Context, req *pbFriend.AddBlackl
|
|||||||
err = im_mysql_model.InsertInToUserBlackList(claims.UID, req.Uid)
|
err = im_mysql_model.InsertInToUserBlackList(claims.UID, req.Uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,Failed to add blacklist", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,Failed to add blacklist", err.Error())
|
||||||
return &pbFriend.CommonResp{ErrorCode: config.ErrMysql.ErrCode, ErrorMsg: config.ErrMysql.ErrMsg}, nil
|
return &pbFriend.CommonResp{ErrorCode: constant.ErrMysql.ErrCode, ErrorMsg: constant.ErrMysql.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
log.Info(req.Token, req.OperationID, "rpc add blacklist success return,uid=%s", req.Uid)
|
log.Info(req.Token, req.OperationID, "rpc add blacklist success return,uid=%s", req.Uid)
|
||||||
return &pbFriend.CommonResp{}, nil
|
return &pbFriend.CommonResp{}, nil
|
||||||
@@ -38,7 +40,7 @@ func (s *friendServer) AddBlacklist(ctx context.Context, req *pbFriend.AddBlackl
|
|||||||
err = im_mysql_model.InsertInToUserBlackList(req.OwnerUid, req.Uid)
|
err = im_mysql_model.InsertInToUserBlackList(req.OwnerUid, req.Uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,Failed to add blacklist", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,Failed to add blacklist", err.Error())
|
||||||
return &pbFriend.CommonResp{ErrorCode: config.ErrMysql.ErrCode, ErrorMsg: config.ErrMysql.ErrMsg}, nil
|
return &pbFriend.CommonResp{ErrorCode: constant.ErrMysql.ErrCode, ErrorMsg: constant.ErrMysql.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
log.Info(req.Token, req.OperationID, "rpc add blacklist success return,uid=%s", req.Uid)
|
log.Info(req.Token, req.OperationID, "rpc add blacklist success return,uid=%s", req.Uid)
|
||||||
return &pbFriend.CommonResp{}, nil
|
return &pbFriend.CommonResp{}, nil
|
||||||
@@ -1,37 +1,38 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/internal/push/content_struct"
|
||||||
"Open_IM/src/common/constant"
|
"Open_IM/internal/push/logic"
|
||||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/constant"
|
||||||
pbChat "Open_IM/src/proto/chat"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/push/content_struct"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/src/push/logic"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
"Open_IM/src/utils"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *friendServer) AddFriend(ctx context.Context, req *pbFriend.AddFriendReq) (*pbFriend.CommonResp, error) {
|
func (s *friendServer) AddFriend(ctx context.Context, req *pbFriend.AddFriendReq) (*pbFriend.CommonResp, error) {
|
||||||
log.Info(req.Token, req.OperationID, "rpc add friend is server,userid=%s", req.Uid)
|
log.Info(req.Token, req.OperationID, "rpc add friend is server,userid=%s", req.Uid)
|
||||||
//Parse token, to find current user information
|
//Parse token, to find current user information
|
||||||
claims, err := utils.ParseToken(req.Token)
|
claims, err := token_verify.ParseToken(req.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
||||||
return &pbFriend.CommonResp{ErrorCode: config.ErrParseToken.ErrCode, ErrorMsg: config.ErrParseToken.ErrMsg}, nil
|
return &pbFriend.CommonResp{ErrorCode: constant.ErrParseToken.ErrCode, ErrorMsg: constant.ErrParseToken.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
//Cannot add non-existent users
|
//Cannot add non-existent users
|
||||||
if _, err = im_mysql_model.FindUserByUID(req.Uid); err != nil {
|
if _, err = im_mysql_model.FindUserByUID(req.Uid); err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "this user not exists,cant not add friend")
|
log.Error(req.Token, req.OperationID, "this user not exists,cant not add friend")
|
||||||
return &pbFriend.CommonResp{ErrorCode: config.ErrAddFriend.ErrCode, ErrorMsg: config.ErrSearchUserInfo.ErrMsg}, nil
|
return &pbFriend.CommonResp{ErrorCode: constant.ErrAddFriend.ErrCode, ErrorMsg: constant.ErrSearchUserInfo.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//Establish a latest relationship in the friend request table
|
//Establish a latest relationship in the friend request table
|
||||||
err = im_mysql_model.ReplaceIntoFriendReq(claims.UID, req.Uid, constant.ApplicationFriendFlag, req.ReqMessage)
|
err = im_mysql_model.ReplaceIntoFriendReq(claims.UID, req.Uid, constant.ApplicationFriendFlag, req.ReqMessage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,create friend request record failed", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,create friend request record failed", err.Error())
|
||||||
return &pbFriend.CommonResp{ErrorCode: config.ErrAddFriend.ErrCode, ErrorMsg: config.ErrAddFriend.ErrMsg}, nil
|
return &pbFriend.CommonResp{ErrorCode: constant.ErrAddFriend.ErrCode, ErrorMsg: constant.ErrAddFriend.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
log.Info(req.Token, req.OperationID, "rpc add friend is success return,uid=%s", req.Uid)
|
log.Info(req.Token, req.OperationID, "rpc add friend is success return,uid=%s", req.Uid)
|
||||||
//Push message when add friend successfully
|
//Push message when add friend successfully
|
||||||
@@ -55,25 +56,32 @@ func (s *friendServer) AddFriend(ctx context.Context, req *pbFriend.AddFriendReq
|
|||||||
func (s *friendServer) ImportFriend(ctx context.Context, req *pbFriend.ImportFriendReq) (*pbFriend.ImportFriendResp, error) {
|
func (s *friendServer) ImportFriend(ctx context.Context, req *pbFriend.ImportFriendReq) (*pbFriend.ImportFriendResp, error) {
|
||||||
log.Info(req.Token, req.OperationID, "ImportFriend come here,args=%s", req.String())
|
log.Info(req.Token, req.OperationID, "ImportFriend come here,args=%s", req.String())
|
||||||
var resp pbFriend.ImportFriendResp
|
var resp pbFriend.ImportFriendResp
|
||||||
|
var c pbFriend.CommonResp
|
||||||
//Parse token, to find current user information
|
//Parse token, to find current user information
|
||||||
claims, err := utils.ParseToken(req.Token)
|
claims, err := token_verify.ParseToken(req.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
log.NewError(req.OperationID, "parse token failed", err.Error())
|
||||||
return &pbFriend.ImportFriendResp{CommonResp: &pbFriend.CommonResp{ErrorCode: config.ErrAddFriend.ErrCode, ErrorMsg: config.ErrParseToken.ErrMsg}, FailedUidList: req.UidList}, nil
|
c.ErrorCode = constant.ErrAddFriend.ErrCode
|
||||||
|
c.ErrorMsg = constant.ErrParseToken.ErrMsg
|
||||||
|
return &pbFriend.ImportFriendResp{CommonResp: &c, FailedUidList: req.UidList}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
||||||
log.Error(req.Token, req.OperationID, "not magager uid", claims.UID)
|
log.NewError(req.OperationID, "not manager uid", claims.UID)
|
||||||
return &pbFriend.ImportFriendResp{CommonResp: &pbFriend.CommonResp{ErrorCode: config.ErrAddFriend.ErrCode, ErrorMsg: "not authorized"}, FailedUidList: req.UidList}, nil
|
c.ErrorCode = constant.ErrAddFriend.ErrCode
|
||||||
|
c.ErrorMsg = "not authorized"
|
||||||
|
return &pbFriend.ImportFriendResp{CommonResp: &c, FailedUidList: req.UidList}, nil
|
||||||
}
|
}
|
||||||
if _, err = im_mysql_model.FindUserByUID(req.OwnerUid); err != nil {
|
if _, err = im_mysql_model.FindUserByUID(req.OwnerUid); err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "this user not exists,cant not add friend", req.OwnerUid)
|
log.NewError(req.OperationID, "this user not exists,cant not add friend", req.OwnerUid)
|
||||||
return &pbFriend.ImportFriendResp{CommonResp: &pbFriend.CommonResp{ErrorCode: config.ErrAddFriend.ErrCode, ErrorMsg: "this user not exists,cant not add friend"}, FailedUidList: req.UidList}, nil
|
c.ErrorCode = constant.ErrAddFriend.ErrCode
|
||||||
|
c.ErrorMsg = "this user not exists,cant not add friend"
|
||||||
|
return &pbFriend.ImportFriendResp{CommonResp: &c, FailedUidList: req.UidList}, nil
|
||||||
}
|
}
|
||||||
for _, v := range req.UidList {
|
for _, v := range req.UidList {
|
||||||
if _, err = im_mysql_model.FindUserByUID(v); err != nil {
|
if _, fErr := im_mysql_model.FindUserByUID(v); fErr != nil {
|
||||||
resp.CommonResp.ErrorMsg = "some uid establish failed"
|
c.ErrorMsg = "some uid establish failed"
|
||||||
resp.CommonResp.ErrorCode = 408
|
c.ErrorCode = 408
|
||||||
resp.FailedUidList = append(resp.FailedUidList, v)
|
resp.FailedUidList = append(resp.FailedUidList, v)
|
||||||
} else {
|
} else {
|
||||||
if _, err = im_mysql_model.FindFriendRelationshipFromFriend(req.OwnerUid, v); err != nil {
|
if _, err = im_mysql_model.FindFriendRelationshipFromFriend(req.OwnerUid, v); err != nil {
|
||||||
@@ -81,18 +89,18 @@ func (s *friendServer) ImportFriend(ctx context.Context, req *pbFriend.ImportFri
|
|||||||
err1 := im_mysql_model.InsertToFriend(req.OwnerUid, v, 1)
|
err1 := im_mysql_model.InsertToFriend(req.OwnerUid, v, 1)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
resp.FailedUidList = append(resp.FailedUidList, v)
|
resp.FailedUidList = append(resp.FailedUidList, v)
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,create friendship failed", err.Error())
|
log.NewError(req.OperationID, "err1,create friendship failed", req.OwnerUid, v, err1.Error())
|
||||||
}
|
}
|
||||||
err2 := im_mysql_model.InsertToFriend(v, req.OwnerUid, 1)
|
err2 := im_mysql_model.InsertToFriend(v, req.OwnerUid, 1)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,create friendship failed", err.Error())
|
log.NewError(req.OperationID, "err2,create friendship failed", v, req.OwnerUid, err2.Error())
|
||||||
}
|
}
|
||||||
if err1 == nil && err2 == nil {
|
if err1 == nil && err2 == nil {
|
||||||
var name, faceUrl string
|
var name, faceUrl string
|
||||||
n := content_struct.NotificationContent{1, constant.FriendAcceptTip, ""}
|
n := content_struct.NotificationContent{IsDisplay: 1, DefaultTips: constant.FriendAcceptTip}
|
||||||
r, err := im_mysql_model.FindUserByUID(v)
|
r, err := im_mysql_model.FindUserByUID(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("get info failed", req.OperationID, "err", err.Error(), "req", req.String())
|
log.NewError(req.OperationID, "get info failed", err.Error(), v)
|
||||||
}
|
}
|
||||||
if r != nil {
|
if r != nil {
|
||||||
name, faceUrl = r.Name, r.Icon
|
name, faceUrl = r.Name, r.Icon
|
||||||
@@ -111,14 +119,15 @@ func (s *friendServer) ImportFriend(ctx context.Context, req *pbFriend.ImportFri
|
|||||||
OperationID: req.OperationID,
|
OperationID: req.OperationID,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
resp.CommonResp.ErrorMsg = "some uid establish failed"
|
c.ErrorMsg = "some uid establish failed"
|
||||||
resp.CommonResp.ErrorCode = 408
|
c.ErrorCode = 408
|
||||||
resp.FailedUidList = append(resp.FailedUidList, v)
|
resp.FailedUidList = append(resp.FailedUidList, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
resp.CommonResp = &c
|
||||||
|
log.NewDebug(req.OperationID, "rpc come end", resp.CommonResp.ErrorCode, resp.CommonResp.ErrorMsg, resp.FailedUidList)
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
+13
-13
@@ -1,36 +1,36 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/internal/push/content_struct"
|
||||||
"Open_IM/src/common/constant"
|
"Open_IM/internal/push/logic"
|
||||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
pbChat "Open_IM/src/proto/chat"
|
"Open_IM/pkg/common/log"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/src/push/content_struct"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
"Open_IM/src/push/logic"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"Open_IM/src/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddFriendResponseReq) (*pbFriend.CommonResp, error) {
|
func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddFriendResponseReq) (*pbFriend.CommonResp, error) {
|
||||||
log.Info(req.Token, req.OperationID, "rpc add friend response is server,args=%s", req.String())
|
log.Info(req.Token, req.OperationID, "rpc add friend response is server,args=%s", req.String())
|
||||||
//Parse token, to find current user information
|
//Parse token, to find current user information
|
||||||
claims, err := utils.ParseToken(req.Token)
|
claims, err := token_verify.ParseToken(req.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
||||||
return &pbFriend.CommonResp{ErrorCode: config.ErrParseToken.ErrCode, ErrorMsg: config.ErrParseToken.ErrMsg}, nil
|
return &pbFriend.CommonResp{ErrorCode: constant.ErrParseToken.ErrCode, ErrorMsg: constant.ErrParseToken.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
//Check there application before agreeing or refuse to a friend's application
|
//Check there application before agreeing or refuse to a friend's application
|
||||||
if _, err = im_mysql_model.FindFriendApplyFromFriendReqByUid(req.Uid, claims.UID); err != nil {
|
if _, err = im_mysql_model.FindFriendApplyFromFriendReqByUid(req.Uid, claims.UID); err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "No such application record")
|
log.Error(req.Token, req.OperationID, "No such application record")
|
||||||
return &pbFriend.CommonResp{ErrorCode: config.ErrAgreeToAddFriend.ErrCode, ErrorMsg: config.ErrAgreeToAddFriend.ErrMsg}, nil
|
return &pbFriend.CommonResp{ErrorCode: constant.ErrAgreeToAddFriend.ErrCode, ErrorMsg: constant.ErrAgreeToAddFriend.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
//Change friend request status flag
|
//Change friend request status flag
|
||||||
err = im_mysql_model.UpdateFriendRelationshipToFriendReq(req.Uid, claims.UID, req.Flag)
|
err = im_mysql_model.UpdateFriendRelationshipToFriendReq(req.Uid, claims.UID, req.Flag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,update friend request table failed", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,update friend request table failed", err.Error())
|
||||||
return &pbFriend.CommonResp{ErrorCode: config.ErrMysql.ErrCode, ErrorMsg: config.ErrAgreeToAddFriend.ErrMsg}, nil
|
return &pbFriend.CommonResp{ErrorCode: constant.ErrMysql.ErrCode, ErrorMsg: constant.ErrAgreeToAddFriend.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
log.Info(req.Token, req.OperationID, "rpc add friend response success return,userid=%s,flag=%d", req.Uid, req.Flag)
|
log.Info(req.Token, req.OperationID, "rpc add friend response success return,userid=%s,flag=%d", req.Uid, req.Flag)
|
||||||
//Change the status of the friend request form
|
//Change the status of the friend request form
|
||||||
@@ -1,26 +1,26 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/src/utils"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFriendReq) (*pbFriend.CommonResp, error) {
|
func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFriendReq) (*pbFriend.CommonResp, error) {
|
||||||
log.Info(req.Token, req.OperationID, "rpc delete friend is server,args=%s", req.String())
|
log.Info(req.Token, req.OperationID, "rpc delete friend is server,args=%s", req.String())
|
||||||
//Parse token, to find current user information
|
//Parse token, to find current user information
|
||||||
claims, err := utils.ParseToken(req.Token)
|
claims, err := token_verify.ParseToken(req.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
||||||
return &pbFriend.CommonResp{ErrorCode: config.ErrParseToken.ErrCode, ErrorMsg: config.ErrParseToken.ErrMsg}, nil
|
return &pbFriend.CommonResp{ErrorCode: constant.ErrParseToken.ErrCode, ErrorMsg: constant.ErrParseToken.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
err = im_mysql_model.DeleteSingleFriendInfo(claims.UID, req.Uid)
|
err = im_mysql_model.DeleteSingleFriendInfo(claims.UID, req.Uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,delete friend failed", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,delete friend failed", err.Error())
|
||||||
return &pbFriend.CommonResp{ErrorCode: config.ErrMysql.ErrCode, ErrorMsg: config.ErrMysql.ErrMsg}, nil
|
return &pbFriend.CommonResp{ErrorCode: constant.ErrMysql.ErrCode, ErrorMsg: constant.ErrMysql.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
log.Info(req.Token, req.OperationID, "rpc delete friend success return")
|
log.Info(req.Token, req.OperationID, "rpc delete friend success return")
|
||||||
return &pbFriend.CommonResp{}, nil
|
return &pbFriend.CommonResp{}, nil
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/src/utils"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,15 +16,15 @@ func (s *friendServer) GetBlacklist(ctx context.Context, req *pbFriend.GetBlackl
|
|||||||
comment string
|
comment string
|
||||||
)
|
)
|
||||||
//Parse token, to find current user information
|
//Parse token, to find current user information
|
||||||
claims, err := utils.ParseToken(req.Token)
|
claims, err := token_verify.ParseToken(req.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
||||||
return &pbFriend.GetBlacklistResp{ErrorCode: config.ErrParseToken.ErrCode, ErrorMsg: config.ErrParseToken.ErrMsg}, nil
|
return &pbFriend.GetBlacklistResp{ErrorCode: constant.ErrParseToken.ErrCode, ErrorMsg: constant.ErrParseToken.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
blackListInfo, err := im_mysql_model.GetBlackListByUID(claims.UID)
|
blackListInfo, err := im_mysql_model.GetBlackListByUID(claims.UID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s get blacklist failed", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s get blacklist failed", err.Error())
|
||||||
return &pbFriend.GetBlacklistResp{ErrorCode: config.ErrGetBlackList.ErrCode, ErrorMsg: config.ErrGetBlackList.ErrMsg}, nil
|
return &pbFriend.GetBlacklistResp{ErrorCode: constant.ErrGetBlackList.ErrCode, ErrorMsg: constant.ErrGetBlackList.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
for _, blackUser := range blackListInfo {
|
for _, blackUser := range blackListInfo {
|
||||||
var blackUserInfo pbFriend.UserInfo
|
var blackUserInfo pbFriend.UserInfo
|
||||||
+11
-10
@@ -1,13 +1,14 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/src/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/src/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/src/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/src/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/common/token_verify"
|
||||||
pbFriend "Open_IM/src/proto/friend"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
"Open_IM/src/utils"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@@ -71,10 +72,10 @@ func (s *friendServer) GetFriendsInfo(ctx context.Context, req *pbFriend.GetFrie
|
|||||||
comment string
|
comment string
|
||||||
)
|
)
|
||||||
//Parse token, to find current user information
|
//Parse token, to find current user information
|
||||||
claims, err := utils.ParseToken(req.Token)
|
claims, err := token_verify.ParseToken(req.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
||||||
return &pbFriend.GetFriendInfoResp{ErrorCode: config.ErrParseToken.ErrCode, ErrorMsg: config.ErrParseToken.ErrMsg}, nil
|
return &pbFriend.GetFriendInfoResp{ErrorCode: constant.ErrParseToken.ErrCode, ErrorMsg: constant.ErrParseToken.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
friendShip, err := im_mysql_model.FindFriendRelationshipFromFriend(claims.UID, req.Uid)
|
friendShip, err := im_mysql_model.FindFriendRelationshipFromFriend(claims.UID, req.Uid)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -84,7 +85,7 @@ func (s *friendServer) GetFriendsInfo(ctx context.Context, req *pbFriend.GetFrie
|
|||||||
friendUserInfo, err := im_mysql_model.FindUserByUID(req.Uid)
|
friendUserInfo, err := im_mysql_model.FindUserByUID(req.Uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.Token, req.OperationID, "err=%s,no this user", err.Error())
|
log.Error(req.Token, req.OperationID, "err=%s,no this user", err.Error())
|
||||||
return &pbFriend.GetFriendInfoResp{ErrorCode: config.ErrSearchUserInfo.ErrCode, ErrorMsg: config.ErrSearchUserInfo.ErrMsg}, nil
|
return &pbFriend.GetFriendInfoResp{ErrorCode: constant.ErrSearchUserInfo.ErrCode, ErrorMsg: constant.ErrSearchUserInfo.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
err = im_mysql_model.FindRelationshipFromBlackList(claims.UID, req.Uid)
|
err = im_mysql_model.FindRelationshipFromBlackList(claims.UID, req.Uid)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user