mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-29 22:11:46 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
This commit is contained in:
commit
d50248ffd2
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,7 @@ import (
|
|||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/middleware"
|
"Open_IM/pkg/common/middleware"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
"Open_IM/pkg/getcdv3"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -213,7 +214,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
go utils.RegisterConf()
|
go getcdv3.RegisterConf()
|
||||||
go apiThird.MinioInit()
|
go apiThird.MinioInit()
|
||||||
defaultPorts := config.Config.Api.GinPort
|
defaultPorts := config.Config.Api.GinPort
|
||||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10002 as port")
|
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10002 as port")
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
|
||||||
|
|
||||||
BINARY_NAME=open_im_cache
|
|
||||||
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,27 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
rpcCache "Open_IM/internal/rpc/cache"
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
promePkg "Open_IM/pkg/common/prometheus"
|
|
||||||
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
defaultPorts := config.Config.RpcPort.OpenImCachePort
|
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcToken default listen port 10800")
|
|
||||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.CachePrometheusPort[0], "cachePrometheusPort default listen port")
|
|
||||||
flag.Parse()
|
|
||||||
fmt.Println("start cache rpc server, port: ", *rpcPort, ", OpenIM version: ", constant.CurrentVersion, "\n")
|
|
||||||
rpcServer := rpcCache.NewCacheServer(*rpcPort)
|
|
||||||
go func() {
|
|
||||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
rpcServer.Run()
|
|
||||||
}
|
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
mongoUtils "Open_IM/cmdutils/mongo"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
mongo2 "Open_IM/test/mongo"
|
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -26,11 +26,11 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
mongo2.Client, err = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
mongoUtils.Client, err = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
err = mongo2.Client.Ping(context.TODO(), nil)
|
err = mongoUtils.Client.Ping(context.TODO(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -41,5 +41,5 @@ func main() {
|
|||||||
userID := flag.String("userID", "", "userID")
|
userID := flag.String("userID", "", "userID")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("userID:", *userID)
|
fmt.Println("userID:", *userID)
|
||||||
mongo2.GetUserAllChat(*userID)
|
mongoUtils.GetUserAllChat(*userID)
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package apiAuth
|
package apiAuth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package clientInit
|
package clientInit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package conversation
|
package conversation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/getcdv3"
|
"Open_IM/pkg/getcdv3"
|
||||||
|
@ -2,7 +2,7 @@ package friend
|
|||||||
|
|
||||||
//import (
|
//import (
|
||||||
// jsonData "Open_IM/internal/utils"
|
// jsonData "Open_IM/internal/utils"
|
||||||
// api "Open_IM/pkg/base_info"
|
// api "Open_IM/pkg/api_struct"
|
||||||
// "Open_IM/pkg/common/config"
|
// "Open_IM/pkg/common/config"
|
||||||
// "Open_IM/pkg/common/log"
|
// "Open_IM/pkg/common/log"
|
||||||
// "Open_IM/pkg/common/token_verify"
|
// "Open_IM/pkg/common/token_verify"
|
||||||
|
@ -2,7 +2,7 @@ package friend
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
common "Open_IM/internal/api_to_rpc"
|
common "Open_IM/internal/api_to_rpc"
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
rpc "Open_IM/pkg/proto/friend"
|
rpc "Open_IM/pkg/proto/friend"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -2,7 +2,7 @@ package group
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
common "Open_IM/internal/api_to_rpc"
|
common "Open_IM/internal/api_to_rpc"
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
@ -2,7 +2,7 @@ package group
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
jsonData "Open_IM/internal/utils"
|
jsonData "Open_IM/internal/utils"
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
package manage
|
package manage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
package manage
|
package manage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package msg
|
package msg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package msg
|
package msg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package office
|
package office
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package office
|
package office
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package apiThird
|
package apiThird
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package apiThird
|
package apiThird
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package apiThird
|
package apiThird
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package apiThird
|
package apiThird
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package apiThird
|
package apiThird
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package apiThird
|
package apiThird
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package apiThird
|
package apiThird
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
@ -2,7 +2,7 @@ package user
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
jsonData "Open_IM/internal/utils"
|
jsonData "Open_IM/internal/utils"
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/getcdv3"
|
"Open_IM/pkg/getcdv3"
|
||||||
@ -8,7 +9,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ApiToRpc(c *gin.Context, apiReq, apiResp interface{}, rpcName string, rpcClientFunc interface{}, rpcFuncName string) {
|
func ApiToRpc(c *gin.Context, apiReq, apiResp interface{}, rpcName string, rpcClientFunc interface{}, rpcFuncName string) {
|
||||||
@ -16,16 +20,16 @@ func ApiToRpc(c *gin.Context, apiReq, apiResp interface{}, rpcName string, rpcCl
|
|||||||
rpcName = utils2.GetFuncName(1)
|
rpcName = utils2.GetFuncName(1)
|
||||||
}
|
}
|
||||||
logFuncName := fmt.Sprintf("[ApiToRpc: %s]%s", utils2.GetFuncName(1), rpcFuncName)
|
logFuncName := fmt.Sprintf("[ApiToRpc: %s]%s", utils2.GetFuncName(1), rpcFuncName)
|
||||||
ctx := tracelog.NewCtx1(c, rpcFuncName)
|
ctx := tracelog.NewCtx(c, rpcFuncName)
|
||||||
defer log.ShowLog(ctx)
|
defer log.ShowLog(ctx)
|
||||||
if err := c.BindJSON(apiReq); err != nil {
|
if err := c.BindJSON(apiReq); err != nil {
|
||||||
tracelog.WriteErrorResponse(ctx, "BindJSON", err)
|
WriteErrorResponse(ctx, "BindJSON", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tracelog.SetCtxInfo(ctx, logFuncName, nil, "apiReq", apiReq)
|
tracelog.SetCtxInfo(ctx, logFuncName, nil, "apiReq", apiReq)
|
||||||
etcdConn, err := getcdv3.GetConn(ctx, rpcName)
|
etcdConn, err := getcdv3.GetConn(ctx, rpcName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tracelog.WriteErrorResponse(ctx, "GetConn", err)
|
WriteErrorResponse(ctx, "GetConn", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rpcClient := reflect.ValueOf(rpcClientFunc).Call([]reflect.Value{
|
rpcClient := reflect.ValueOf(rpcClientFunc).Call([]reflect.Value{
|
||||||
@ -40,7 +44,7 @@ func ApiToRpc(c *gin.Context, apiReq, apiResp interface{}, rpcName string, rpcCl
|
|||||||
}) // respArr => (apiResp, error)
|
}) // respArr => (apiResp, error)
|
||||||
if !respArr[1].IsNil() { // rpcClient err != nil
|
if !respArr[1].IsNil() { // rpcClient err != nil
|
||||||
err := respArr[1].Interface().(error)
|
err := respArr[1].Interface().(error)
|
||||||
tracelog.WriteErrorResponse(ctx, rpcFuncName, err, "callRpcResp", "error")
|
WriteErrorResponse(ctx, rpcFuncName, err, "callRpcResp", "error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rpcResp := respArr[0].Elem()
|
rpcResp := respArr[0].Elem()
|
||||||
@ -48,7 +52,7 @@ func ApiToRpc(c *gin.Context, apiReq, apiResp interface{}, rpcName string, rpcCl
|
|||||||
if apiResp != nil {
|
if apiResp != nil {
|
||||||
CopyAny(rpcResp.Interface(), apiResp)
|
CopyAny(rpcResp.Interface(), apiResp)
|
||||||
}
|
}
|
||||||
tracelog.SetSuccess(ctx, rpcFuncName, apiResp)
|
SetSuccess(ctx, rpcFuncName, apiResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func rpcString(v interface{}) string {
|
func rpcString(v interface{}) string {
|
||||||
@ -57,3 +61,43 @@ func rpcString(v interface{}) string {
|
|||||||
}
|
}
|
||||||
return fmt.Sprintf("%+v", v)
|
return fmt.Sprintf("%+v", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type baseResp struct {
|
||||||
|
ErrCode int32 `json:"errCode"`
|
||||||
|
ErrMsg string `json:"errMsg"`
|
||||||
|
ErrDtl string `json:"errDtl"`
|
||||||
|
Data interface{} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func WriteErrorResponse(ctx context.Context, funcName string, err error, args ...interface{}) {
|
||||||
|
tracelog.SetCtxInfo(ctx, funcName, err, args)
|
||||||
|
e := tracelog.Unwrap(err)
|
||||||
|
switch t := e.(type) {
|
||||||
|
case *constant.ErrInfo:
|
||||||
|
ctx.Value(tracelog.TraceLogKey).(*tracelog.ApiInfo).GinCtx.JSON(http.StatusOK, baseResp{ErrCode: t.ErrCode, ErrMsg: t.ErrMsg, ErrDtl: t.DetailErrMsg})
|
||||||
|
//ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": t.ErrCode, "errMsg": t.ErrMsg, "errDtl": t.DetailErrMsg})
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
s, ok := status.FromError(e)
|
||||||
|
if !ok {
|
||||||
|
ctx.Value(tracelog.TraceLogKey).(*tracelog.ApiInfo).GinCtx.JSON(http.StatusOK, &baseResp{ErrCode: constant.ErrDefaultOther.ErrCode, ErrMsg: err.Error(), ErrDtl: fmt.Sprintf("%+v", err)})
|
||||||
|
//ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": constant.ErrDefaultOther.ErrCode, "errMsg": err.Error(), "errDtl": fmt.Sprintf("%+v", err)})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var details []string
|
||||||
|
if err != e {
|
||||||
|
details = append(details, fmt.Sprintf("%+v", err))
|
||||||
|
}
|
||||||
|
for _, s := range s.Details() {
|
||||||
|
details = append(details, fmt.Sprintf("%+v", s))
|
||||||
|
}
|
||||||
|
ctx.Value(tracelog.TraceLogKey).(*tracelog.ApiInfo).GinCtx.JSON(http.StatusOK, &baseResp{ErrCode: int32(s.Code()), ErrMsg: s.Message(), ErrDtl: strings.Join(details, "\n")})
|
||||||
|
//ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": s.Code(), "errMsg": s.Message(), "errDtl": strings.Join(details, "\n")})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetSuccess(ctx context.Context, funcName string, data interface{}) {
|
||||||
|
tracelog.SetCtxInfo(ctx, funcName, nil, "data", data)
|
||||||
|
ctx.Value(tracelog.TraceLogKey).(*tracelog.ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "errDtl": "", "data": data})
|
||||||
|
}
|
||||||
|
@ -126,95 +126,3 @@ func AdminLogin(c *gin.Context) {
|
|||||||
resp.Token = respPb.Token
|
resp.Token = respPb.Token
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddUserRegisterAddFriendIDList(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req apiStruct.AddUserRegisterAddFriendIDListRequest
|
|
||||||
// resp apiStruct.AddUserRegisterAddFriendIDListResponse
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
|
||||||
respPb, err := client.AddUserRegisterAddFriendIDList(context.Background(), &pbAdmin.AddUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", respPb.String())
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
|
||||||
}
|
|
||||||
|
|
||||||
func ReduceUserRegisterAddFriendIDList(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req apiStruct.ReduceUserRegisterAddFriendIDListRequest
|
|
||||||
// resp apiStruct.ReduceUserRegisterAddFriendIDListResponse
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
|
||||||
respPb, err := client.ReduceUserRegisterAddFriendIDList(context.Background(), &pbAdmin.ReduceUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList, Operation: req.Operation})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req apiStruct.GetUserRegisterAddFriendIDListRequest
|
|
||||||
resp apiStruct.GetUserRegisterAddFriendIDListResponse
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
|
||||||
respPb, err := client.GetUserRegisterAddFriendIDList(context.Background(), &pbAdmin.GetUserRegisterAddFriendIDListReq{OperationID: req.OperationID, Pagination: &pbCommon.RequestPagination{
|
|
||||||
PageNumber: int32(req.PageNumber),
|
|
||||||
ShowNumber: int32(req.ShowNumber),
|
|
||||||
}})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.Users = respPb.UserInfoList
|
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
|
||||||
}
|
|
||||||
|
@ -17,8 +17,8 @@ import (
|
|||||||
|
|
||||||
func GetUserFriends(c *gin.Context) {
|
func GetUserFriends(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetFriendsReq
|
req cms_struct.GetFriendsReq
|
||||||
resp cms_api_struct.GetFriendsResp
|
resp cms_struct.GetFriendsResp
|
||||||
reqPb pbAdmin.GetUserFriendsReq
|
reqPb pbAdmin.GetUserFriendsReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
@ -49,7 +49,7 @@ func GetUserFriends(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range respPb.FriendInfoList {
|
for _, v := range respPb.FriendInfoList {
|
||||||
friend := &cms_api_struct.FriendInfo{}
|
friend := &cms_struct.FriendInfo{}
|
||||||
utils.CopyStructFields(friend, v)
|
utils.CopyStructFields(friend, v)
|
||||||
friend.Nickname = v.FriendUser.Nickname
|
friend.Nickname = v.FriendUser.Nickname
|
||||||
friend.UserID = v.FriendUser.UserID
|
friend.UserID = v.FriendUser.UserID
|
||||||
|
@ -18,8 +18,8 @@ import (
|
|||||||
|
|
||||||
func GetGroups(c *gin.Context) {
|
func GetGroups(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetGroupsRequest
|
req cms_struct.GetGroupsRequest
|
||||||
resp cms_api_struct.GetGroupsResponse
|
resp cms_struct.GetGroupsResponse
|
||||||
reqPb pbGroup.GetGroupsReq
|
reqPb pbGroup.GetGroupsReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
@ -48,7 +48,7 @@ func GetGroups(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range respPb.CMSGroups {
|
for _, v := range respPb.CMSGroups {
|
||||||
groupResp := cms_api_struct.GroupResponse{}
|
groupResp := cms_struct.GroupResponse{}
|
||||||
utils.CopyStructFields(&groupResp, v.GroupInfo)
|
utils.CopyStructFields(&groupResp, v.GroupInfo)
|
||||||
groupResp.GroupOwnerName = v.GroupOwnerUserName
|
groupResp.GroupOwnerName = v.GroupOwnerUserName
|
||||||
groupResp.GroupOwnerID = v.GroupOwnerUserID
|
groupResp.GroupOwnerID = v.GroupOwnerUserID
|
||||||
@ -63,9 +63,9 @@ func GetGroups(c *gin.Context) {
|
|||||||
|
|
||||||
func GetGroupMembers(c *gin.Context) {
|
func GetGroupMembers(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetGroupMembersRequest
|
req cms_struct.GetGroupMembersRequest
|
||||||
reqPb pbGroup.GetGroupMembersCMSReq
|
reqPb pbGroup.GetGroupMembersCMSReq
|
||||||
resp cms_api_struct.GetGroupMembersResponse
|
resp cms_struct.GetGroupMembersResponse
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
@ -94,13 +94,13 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.ResponsePagination = cms_api_struct.ResponsePagination{
|
resp.ResponsePagination = cms_struct.ResponsePagination{
|
||||||
CurrentPage: int(respPb.Pagination.CurrentPage),
|
CurrentPage: int(respPb.Pagination.CurrentPage),
|
||||||
ShowNumber: int(respPb.Pagination.ShowNumber),
|
ShowNumber: int(respPb.Pagination.ShowNumber),
|
||||||
}
|
}
|
||||||
resp.MemberNums = int(respPb.MemberNums)
|
resp.MemberNums = int(respPb.MemberNums)
|
||||||
for _, groupMember := range respPb.Members {
|
for _, groupMember := range respPb.Members {
|
||||||
memberResp := cms_api_struct.GroupMemberResponse{}
|
memberResp := cms_struct.GroupMemberResponse{}
|
||||||
utils.CopyStructFields(&memberResp, groupMember)
|
utils.CopyStructFields(&memberResp, groupMember)
|
||||||
resp.GroupMembers = append(resp.GroupMembers, memberResp)
|
resp.GroupMembers = append(resp.GroupMembers, memberResp)
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ import (
|
|||||||
|
|
||||||
func GetChatLogs(c *gin.Context) {
|
func GetChatLogs(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetChatLogsReq
|
req cms_struct.GetChatLogsReq
|
||||||
resp cms_api_struct.GetChatLogsResp
|
resp cms_struct.GetChatLogsResp
|
||||||
reqPb pbAdminCMS.GetChatLogsReq
|
reqPb pbAdminCMS.GetChatLogsReq
|
||||||
)
|
)
|
||||||
if err := c.Bind(&req); err != nil {
|
if err := c.Bind(&req); err != nil {
|
||||||
@ -47,7 +47,7 @@ func GetChatLogs(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range respPb.ChatLogs {
|
for _, v := range respPb.ChatLogs {
|
||||||
chatLog := cms_api_struct.ChatLog{}
|
chatLog := cms_struct.ChatLog{}
|
||||||
utils.CopyStructFields(&chatLog, v)
|
utils.CopyStructFields(&chatLog, v)
|
||||||
resp.ChatLogs = append(resp.ChatLogs, &chatLog)
|
resp.ChatLogs = append(resp.ChatLogs, &chatLog)
|
||||||
}
|
}
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CorsHandler() gin.HandlerFunc {
|
|
||||||
return func(context *gin.Context) {
|
|
||||||
context.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
|
||||||
context.Header("Access-Control-Allow-Methods", "*")
|
|
||||||
context.Header("Access-Control-Allow-Headers", "*")
|
|
||||||
context.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar") // 跨域关键设置 让浏览器可以解析
|
|
||||||
context.Header("Access-Control-Max-Age", "172800") // 缓存请求信息 单位为秒
|
|
||||||
context.Header("Access-Control-Allow-Credentials", "false") // 跨域请求是否需要带cookie信息 默认设置为true
|
|
||||||
context.Header("content-type", "application/json") // 设置返回格式是json
|
|
||||||
//Release all option pre-requests
|
|
||||||
if context.Request.Method == http.MethodOptions {
|
|
||||||
context.JSON(http.StatusOK, "Options Request!")
|
|
||||||
}
|
|
||||||
context.Next()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/common/log"
|
|
||||||
"Open_IM/pkg/common/token_verify"
|
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
func JWTAuth() gin.HandlerFunc {
|
|
||||||
return func(c *gin.Context) {
|
|
||||||
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
|
|
||||||
// log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID)
|
|
||||||
c.Set("userID", userID)
|
|
||||||
if !ok {
|
|
||||||
log.NewError("", "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
|
||||||
c.Abort()
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errInfo})
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
if !utils.IsContain(userID, config.Config.Manager.AppManagerUid) {
|
|
||||||
c.Abort()
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": "user is not admin"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package cms_api
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
||||||
)
|
|
||||||
|
|
||||||
func prometheusHandler() gin.HandlerFunc {
|
|
||||||
h := promhttp.Handler()
|
|
||||||
|
|
||||||
return func(c *gin.Context) {
|
|
||||||
h.ServeHTTP(c.Writer, c.Request)
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,7 +8,6 @@ import (
|
|||||||
"Open_IM/internal/cms_api/middleware"
|
"Open_IM/internal/cms_api/middleware"
|
||||||
"Open_IM/internal/cms_api/statistics"
|
"Open_IM/internal/cms_api/statistics"
|
||||||
"Open_IM/internal/cms_api/user"
|
"Open_IM/internal/cms_api/user"
|
||||||
"Open_IM/internal/demo/register"
|
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
|
||||||
promePkg "Open_IM/pkg/common/prometheus"
|
promePkg "Open_IM/pkg/common/prometheus"
|
||||||
@ -30,22 +29,6 @@ func NewGinRouter() *gin.Engine {
|
|||||||
adminRouterGroup.POST("/login", admin.AdminLogin)
|
adminRouterGroup.POST("/login", admin.AdminLogin)
|
||||||
adminRouterGroup.Use(middleware.JWTAuth())
|
adminRouterGroup.Use(middleware.JWTAuth())
|
||||||
adminRouterGroup.POST("/get_user_token", admin.GetUserToken)
|
adminRouterGroup.POST("/get_user_token", admin.GetUserToken)
|
||||||
|
|
||||||
adminRouterGroup.POST("/add_user_register_add_friend_id", admin.AddUserRegisterAddFriendIDList)
|
|
||||||
adminRouterGroup.POST("/reduce_user_register_reduce_friend_id", admin.ReduceUserRegisterAddFriendIDList)
|
|
||||||
adminRouterGroup.POST("/get_user_register_reduce_friend_id_list", admin.GetUserRegisterAddFriendIDList)
|
|
||||||
|
|
||||||
adminRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
|
|
||||||
adminRouterGroup.POST("/query_invitation_code", register.QueryInvitationCode)
|
|
||||||
adminRouterGroup.POST("/get_invitation_codes", register.GetInvitationCodes)
|
|
||||||
|
|
||||||
adminRouterGroup.POST("/query_user_ip_limit_login", register.QueryUserIDLimitLogin)
|
|
||||||
adminRouterGroup.POST("/add_user_ip_limit_login", register.AddUserIPLimitLogin)
|
|
||||||
adminRouterGroup.POST("/remove_user_ip_limit_login", register.RemoveUserIPLimitLogin)
|
|
||||||
|
|
||||||
adminRouterGroup.POST("/query_ip_register", register.QueryIPRegister)
|
|
||||||
adminRouterGroup.POST("/add_ip_limit", register.AddIPLimit)
|
|
||||||
adminRouterGroup.POST("/remove_ip_Limit", register.RemoveIPLimit)
|
|
||||||
}
|
}
|
||||||
r2 := router.Group("")
|
r2 := router.Group("")
|
||||||
r2.Use(middleware.JWTAuth())
|
r2.Use(middleware.JWTAuth())
|
||||||
@ -65,11 +48,6 @@ func NewGinRouter() *gin.Engine {
|
|||||||
userRouterGroup := r2.Group("/user")
|
userRouterGroup := r2.Group("/user")
|
||||||
{
|
{
|
||||||
userRouterGroup.POST("/get_user_id_by_email_phone", user.GetUserIDByEmailAndPhoneNumber)
|
userRouterGroup.POST("/get_user_id_by_email_phone", user.GetUserIDByEmailAndPhoneNumber)
|
||||||
|
|
||||||
userRouterGroup.POST("/add_user", user.AddUser)
|
|
||||||
userRouterGroup.POST("/unblock_user", user.UnblockUser)
|
|
||||||
userRouterGroup.POST("/block_user", user.BlockUser)
|
|
||||||
userRouterGroup.POST("/get_block_users", user.GetBlockUsers)
|
|
||||||
}
|
}
|
||||||
messageCMSRouterGroup := r2.Group("/message")
|
messageCMSRouterGroup := r2.Group("/message")
|
||||||
{
|
{
|
||||||
|
@ -17,8 +17,8 @@ import (
|
|||||||
|
|
||||||
func GetMessagesStatistics(c *gin.Context) {
|
func GetMessagesStatistics(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetMessageStatisticsRequest
|
req cms_struct.GetMessageStatisticsRequest
|
||||||
resp cms_api_struct.GetMessageStatisticsResponse
|
resp cms_struct.GetMessageStatisticsResponse
|
||||||
reqPb admin.GetMessageStatisticsReq
|
reqPb admin.GetMessageStatisticsReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
@ -73,8 +73,8 @@ func GetMessagesStatistics(c *gin.Context) {
|
|||||||
|
|
||||||
func GetUserStatistics(c *gin.Context) {
|
func GetUserStatistics(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetUserStatisticsRequest
|
req cms_struct.GetUserStatisticsRequest
|
||||||
resp cms_api_struct.GetUserStatisticsResponse
|
resp cms_struct.GetUserStatisticsResponse
|
||||||
reqPb admin.GetUserStatisticsReq
|
reqPb admin.GetUserStatisticsReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
@ -138,8 +138,8 @@ func GetUserStatistics(c *gin.Context) {
|
|||||||
|
|
||||||
func GetGroupStatistics(c *gin.Context) {
|
func GetGroupStatistics(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetGroupStatisticsRequest
|
req cms_struct.GetGroupStatisticsRequest
|
||||||
resp cms_api_struct.GetGroupStatisticsResponse
|
resp cms_struct.GetGroupStatisticsResponse
|
||||||
reqPb admin.GetGroupStatisticsReq
|
reqPb admin.GetGroupStatisticsReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
@ -197,8 +197,8 @@ func GetGroupStatistics(c *gin.Context) {
|
|||||||
|
|
||||||
func GetActiveUser(c *gin.Context) {
|
func GetActiveUser(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetActiveUserRequest
|
req cms_struct.GetActiveUserRequest
|
||||||
resp cms_api_struct.GetActiveUserResponse
|
resp cms_struct.GetActiveUserResponse
|
||||||
reqPb admin.GetActiveUserReq
|
reqPb admin.GetActiveUserReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
@ -233,8 +233,8 @@ func GetActiveUser(c *gin.Context) {
|
|||||||
|
|
||||||
func GetActiveGroup(c *gin.Context) {
|
func GetActiveGroup(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetActiveGroupRequest
|
req cms_struct.GetActiveGroupRequest
|
||||||
resp cms_api_struct.GetActiveGroupResponse
|
resp cms_struct.GetActiveGroupResponse
|
||||||
reqPb admin.GetActiveGroupReq
|
reqPb admin.GetActiveGroupReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
|
@ -2,6 +2,7 @@ package user
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/cms_api_struct"
|
"Open_IM/pkg/cms_api_struct"
|
||||||
|
"Open_IM/pkg/cms_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/getcdv3"
|
"Open_IM/pkg/getcdv3"
|
||||||
@ -16,154 +17,10 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AddUser(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.AddUserRequest
|
|
||||||
reqPb pb.AddUserReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.AddUser(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BlockUser(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.BlockUserRequest
|
|
||||||
reqPb pb.BlockUserReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.BlockUser(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
|
||||||
}
|
|
||||||
|
|
||||||
func UnblockUser(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.UnblockUserRequest
|
|
||||||
resp cms_api_struct.UnBlockUserResponse
|
|
||||||
reqPb pb.UnBlockUserReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.UnBlockUser(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetBlockUsers(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetBlockUsersRequest
|
|
||||||
resp cms_api_struct.GetBlockUsersResponse
|
|
||||||
reqPb pb.GetBlockUsersReq
|
|
||||||
respPb *pb.GetBlockUsersResp
|
|
||||||
)
|
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb.Pagination, &req)
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "blockUsers", reqPb.Pagination, req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetBlockUsers(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetBlockUsers rpc", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, v := range respPb.BlockUsers {
|
|
||||||
resp.BlockUsers = append(resp.BlockUsers, cms_api_struct.BlockUser{
|
|
||||||
UserResponse: cms_api_struct.UserResponse{
|
|
||||||
UserID: v.UserInfo.UserID,
|
|
||||||
FaceURL: v.UserInfo.FaceURL,
|
|
||||||
Nickname: v.UserInfo.Nickname,
|
|
||||||
PhoneNumber: v.UserInfo.PhoneNumber,
|
|
||||||
Email: v.UserInfo.Email,
|
|
||||||
Gender: int(v.UserInfo.Gender),
|
|
||||||
},
|
|
||||||
BeginDisableTime: v.BeginDisableTime,
|
|
||||||
EndDisableTime: v.EndDisableTime,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
|
||||||
resp.UserNums = respPb.UserNums
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", resp)
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUserIDByEmailAndPhoneNumber(c *gin.Context) {
|
func GetUserIDByEmailAndPhoneNumber(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetUserIDByEmailAndPhoneNumberRequest
|
req cms_struct.GetUserIDByEmailAndPhoneNumberRequest
|
||||||
resp cms_api_struct.GetUserIDByEmailAndPhoneNumberResponse
|
resp cms_struct.GetUserIDByEmailAndPhoneNumberResponse
|
||||||
reqPb pbAdminCms.GetUserIDByEmailAndPhoneNumberReq
|
reqPb pbAdminCms.GetUserIDByEmailAndPhoneNumberReq
|
||||||
respPb *pbAdminCms.GetUserIDByEmailAndPhoneNumberResp
|
respPb *pbAdminCms.GetUserIDByEmailAndPhoneNumberResp
|
||||||
)
|
)
|
||||||
|
@ -44,13 +44,16 @@ func StartCronTask(userID, workingGroupID string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CronTask struct {
|
||||||
|
}
|
||||||
|
|
||||||
func getCronTaskOperationID() string {
|
func getCronTaskOperationID() string {
|
||||||
return cronTaskOperationID + utils.OperationIDGenerator()
|
return cronTaskOperationID + utils.OperationIDGenerator()
|
||||||
}
|
}
|
||||||
|
|
||||||
func ClearAll() {
|
func ClearAll() {
|
||||||
operationID := getCronTaskOperationID()
|
operationID := getCronTaskOperationID()
|
||||||
log.NewInfo(operationID, "====================== start del cron task ======================")
|
log.NewInfo(operationID, "========================= start del cron task =========================")
|
||||||
var err error
|
var err error
|
||||||
userIDList, err := im_mysql_model.SelectAllUserID()
|
userIDList, err := im_mysql_model.SelectAllUserID()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -67,7 +70,7 @@ func ClearAll() {
|
|||||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(operationID, "====================== start del cron finished ======================")
|
log.NewInfo(operationID, "========================= start del cron finished =========================")
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartClearMsg(operationID string, userIDList []string) {
|
func StartClearMsg(operationID string, userIDList []string) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package register
|
package register
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package register
|
package register
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/base_info"
|
"Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
@ -61,7 +61,7 @@ func (mmc *ModifyMsgConsumerHandler) ModifyMsg(cMsg *sarama.ConsumerMessage, msg
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if msgDataToMQ.MsgData.ContentType == constant.ReactionMessageModifier {
|
if msgDataToMQ.MsgData.ContentType == constant.ReactionMessageModifier {
|
||||||
notification := &base_info.ReactionMessageModifierNotification{}
|
notification := &api_struct.ReactionMessageModifierNotification{}
|
||||||
if err := json.Unmarshal(msgDataToMQ.MsgData.Content, notification); err != nil {
|
if err := json.Unmarshal(msgDataToMQ.MsgData.Content, notification); err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ func (mmc *ModifyMsgConsumerHandler) ModifyMsg(cMsg *sarama.ConsumerMessage, msg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if msgDataToMQ.MsgData.ContentType == constant.ReactionMessageDeleter {
|
} else if msgDataToMQ.MsgData.ContentType == constant.ReactionMessageDeleter {
|
||||||
notification := &base_info.ReactionMessageDeleteNotification{}
|
notification := &api_struct.ReactionMessageDeleteNotification{}
|
||||||
if err := json.Unmarshal(msgDataToMQ.MsgData.Content, notification); err != nil {
|
if err := json.Unmarshal(msgDataToMQ.MsgData.Content, notification); err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ func (mmc *ModifyMsgConsumerHandler) ModifyMsg(cMsg *sarama.ConsumerMessage, msg
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func UnMarshallSetReactionMsgContent(content []byte) (notification *base_info.ReactionMessageModifierNotification, err error) {
|
func UnMarshallSetReactionMsgContent(content []byte) (notification *api_struct.ReactionMessageModifierNotification, err error) {
|
||||||
|
|
||||||
return notification, nil
|
return notification, nil
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/push"
|
"Open_IM/internal/push"
|
||||||
utils2 "Open_IM/internal/utils"
|
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
@ -172,7 +171,7 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "callback userIDList Resp", pushToUserIDList)
|
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "callback userIDList Resp", pushToUserIDList)
|
||||||
}
|
}
|
||||||
if len(pushToUserIDList) == 0 {
|
if len(pushToUserIDList) == 0 {
|
||||||
userIDList, err := utils2.GetGroupMemberUserIDList(context.Background(), pushMsg.MsgData.GroupID, pushMsg.OperationID)
|
userIDList, err := utils.GetGroupMemberUserIDList(context.Background(), pushMsg.MsgData.GroupID, pushMsg.OperationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(pushMsg.OperationID, "GetGroupMemberUserIDList failed ", err.Error(), pushMsg.MsgData.GroupID)
|
log.Error(pushMsg.OperationID, "GetGroupMemberUserIDList failed ", err.Error(), pushMsg.MsgData.GroupID)
|
||||||
return
|
return
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db/controller"
|
"Open_IM/pkg/common/db/controller"
|
||||||
|
"Open_IM/pkg/common/db/relation"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
promePkg "Open_IM/pkg/common/prometheus"
|
promePkg "Open_IM/pkg/common/prometheus"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
@ -115,7 +116,7 @@ func (s *adminCMSServer) AdminLogin(ctx context.Context, req *pbAdminCMS.AdminLo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if resp.Token == "" {
|
if resp.Token == "" {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
|
log.NewError(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "failed")
|
||||||
return nil, constant.ErrInternalServer
|
return nil, constant.ErrInternalServer
|
||||||
}
|
}
|
||||||
admin, err := s.userInterface.Take(ctx, req.AdminID)
|
admin, err := s.userInterface.Take(ctx, req.AdminID)
|
||||||
@ -124,32 +125,23 @@ func (s *adminCMSServer) AdminLogin(ctx context.Context, req *pbAdminCMS.AdminLo
|
|||||||
}
|
}
|
||||||
resp.UserName = admin.Nickname
|
resp.UserName = admin.Nickname
|
||||||
resp.FaceURL = admin.FaceURL
|
resp.FaceURL = admin.FaceURL
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
log.NewInfo(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *adminCMSServer) GetUserToken(_ context.Context, req *pbAdminCMS.GetUserTokenReq) (*pbAdminCMS.GetUserTokenResp, error) {
|
func (s *adminCMSServer) GetUserToken(ctx context.Context, req *pbAdminCMS.GetUserTokenReq) (*pbAdminCMS.GetUserTokenResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
resp := &pbAdminCMS.GetUserTokenResp{}
|
||||||
resp := &pbAdminCMS.GetUserTokenResp{
|
|
||||||
CommonResp: &pbAdminCMS.CommonResp{},
|
|
||||||
}
|
|
||||||
token, expTime, err := token_verify.CreateToken(req.UserID, int(req.PlatformID))
|
token, expTime, err := token_verify.CreateToken(req.UserID, int(req.PlatformID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "userID: ", req.UserID, req.PlatformID, err.Error())
|
|
||||||
resp.CommonResp.ErrCode = constant.ErrTokenUnknown.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
resp.Token = token
|
resp.Token = token
|
||||||
resp.ExpTime = expTime
|
resp.ExpTime = expTime
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", resp.String())
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *adminCMSServer) GetChatLogs(_ context.Context, req *pbAdminCMS.GetChatLogsReq) (*pbAdminCMS.GetChatLogsResp, error) {
|
func (s *adminCMSServer) GetChatLogs(ctx context.Context, req *pbAdminCMS.GetChatLogsReq) (*pbAdminCMS.GetChatLogsResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetChatLogs", req.String())
|
chatLog := relation.ChatLog{
|
||||||
resp := &pbAdminCMS.GetChatLogsResp{CommonResp: &pbAdminCMS.CommonResp{}, Pagination: &server_api_params.ResponsePagination{}}
|
|
||||||
chatLog := imdb.ChatLog{
|
|
||||||
Content: req.Content,
|
Content: req.Content,
|
||||||
ContentType: req.ContentType,
|
ContentType: req.ContentType,
|
||||||
SessionType: req.SessionType,
|
SessionType: req.SessionType,
|
||||||
@ -159,17 +151,13 @@ func (s *adminCMSServer) GetChatLogs(_ context.Context, req *pbAdminCMS.GetChatL
|
|||||||
if req.SendTime != "" {
|
if req.SendTime != "" {
|
||||||
sendTime, err := utils.TimeStringToTime(req.SendTime)
|
sendTime, err := utils.TimeStringToTime(req.SendTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "time string parse error", err.Error())
|
log.NewError(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "time string parse error", err.Error())
|
||||||
resp.CommonResp.ErrCode = constant.ErrArgs.ErrCode
|
return nil, err
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
chatLog.SendTime = sendTime
|
chatLog.SendTime = sendTime
|
||||||
}
|
}
|
||||||
|
resp := &pbAdminCMS.GetChatLogsResp{}
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "chat_log: ", chatLog)
|
num, chatLogs, err := relation.GetChatLog(&chatLog, req.Pagination.PageNumber, req.Pagination.ShowNumber, []int32{
|
||||||
|
|
||||||
num, chatLogs, err := imdb.GetChatLog(&chatLog, req.Pagination.PageNumber, req.Pagination.ShowNumber, []int32{
|
|
||||||
constant.Text,
|
constant.Text,
|
||||||
constant.Picture,
|
constant.Picture,
|
||||||
constant.Voice,
|
constant.Voice,
|
||||||
@ -187,10 +175,7 @@ func (s *adminCMSServer) GetChatLogs(_ context.Context, req *pbAdminCMS.GetChatL
|
|||||||
constant.CustomNotTriggerConversation,
|
constant.CustomNotTriggerConversation,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLog", err.Error())
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
resp.ChatLogsNum = int32(num)
|
resp.ChatLogsNum = int32(num)
|
||||||
for _, chatLog := range chatLogs {
|
for _, chatLog := range chatLogs {
|
||||||
@ -199,38 +184,30 @@ func (s *adminCMSServer) GetChatLogs(_ context.Context, req *pbAdminCMS.GetChatL
|
|||||||
pbChatLog.SendTime = chatLog.SendTime.Unix()
|
pbChatLog.SendTime = chatLog.SendTime.Unix()
|
||||||
pbChatLog.CreateTime = chatLog.CreateTime.Unix()
|
pbChatLog.CreateTime = chatLog.CreateTime.Unix()
|
||||||
if chatLog.SenderNickname == "" {
|
if chatLog.SenderNickname == "" {
|
||||||
sendUser, err := imdb.GetUserByUserID(chatLog.SendID)
|
sendUser, err := s.userInterface.Take(ctx, chatLog.SendID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID failed", err.Error())
|
return nil, err
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
pbChatLog.SenderNickname = sendUser.Nickname
|
pbChatLog.SenderNickname = sendUser.Nickname
|
||||||
}
|
}
|
||||||
switch chatLog.SessionType {
|
switch chatLog.SessionType {
|
||||||
case constant.SingleChatType:
|
case constant.SingleChatType:
|
||||||
recvUser, err := imdb.GetUserByUserID(chatLog.RecvID)
|
recvUser, err := s.userInterface.Take(ctx, chatLog.RecvID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID failed", err.Error())
|
return nil, err
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
pbChatLog.SenderNickname = recvUser.Nickname
|
pbChatLog.SenderNickname = recvUser.Nickname
|
||||||
|
|
||||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||||
group, err := imdb.GetGroupInfoByGroupID(chatLog.RecvID)
|
group, err := s.groupInterface.TakeGroupByID(ctx, chatLog.RecvID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupById failed")
|
return nil, err
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
pbChatLog.RecvID = group.GroupID
|
pbChatLog.RecvID = group.GroupID
|
||||||
pbChatLog.GroupName = group.GroupName
|
pbChatLog.GroupName = group.GroupName
|
||||||
}
|
}
|
||||||
resp.ChatLogs = append(resp.ChatLogs, pbChatLog)
|
resp.ChatLogs = append(resp.ChatLogs, pbChatLog)
|
||||||
}
|
}
|
||||||
resp.Pagination = &server_api_params.ResponsePagination{
|
|
||||||
CurrentPage: req.Pagination.PageNumber,
|
|
||||||
ShowNumber: req.Pagination.ShowNumber,
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp output: ", resp.String())
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,23 +232,16 @@ func (s *adminCMSServer) GetActiveGroup(_ context.Context, req *pbAdminCMS.GetAc
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *adminCMSServer) GetActiveUser(_ context.Context, req *pbAdminCMS.GetActiveUserReq) (*pbAdminCMS.GetActiveUserResp, error) {
|
func (s *adminCMSServer) GetActiveUser(ctx context.Context, req *pbAdminCMS.GetActiveUserReq) (*pbAdminCMS.GetActiveUserResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
resp := &pbAdminCMS.GetActiveUserResp{}
|
||||||
resp := &pbAdminCMS.GetActiveUserResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
log.NewError(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
return nil, err
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
activeUsers, err := s.adminCMSInterface.GetActiveUsers(fromTime, toTime, 12)
|
||||||
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUsers failed", err.Error())
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
for _, activeUser := range activeUsers {
|
for _, activeUser := range activeUsers {
|
||||||
resp.Users = append(resp.Users,
|
resp.Users = append(resp.Users,
|
||||||
@ -282,7 +252,6 @@ func (s *adminCMSServer) GetActiveUser(_ context.Context, req *pbAdminCMS.GetAct
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,35 +341,23 @@ func getFirstDateOfNextNMonth(currentTime time.Time, n int) time.Time {
|
|||||||
return lastOfMonth
|
return lastOfMonth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *adminCMSServer) GetGroupStatistics(_ context.Context, req *pbAdminCMS.GetGroupStatisticsReq) (*pbAdminCMS.GetGroupStatisticsResp, error) {
|
func (s *adminCMSServer) GetGroupStatistics(ctx context.Context, req *pbAdminCMS.GetGroupStatisticsReq) (*pbAdminCMS.GetGroupStatisticsResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
resp := &pbAdminCMS.GetGroupStatisticsResp{}
|
||||||
resp := &pbAdminCMS.GetGroupStatisticsResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
increaseGroupNum, err := imdb.GetIncreaseGroupNum(fromTime, toTime.Add(time.Hour*24))
|
increaseGroupNum, err := s.adminCMSInterface.GetIncreaseGroupNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error(), fromTime, toTime)
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
totalGroupNum, err := imdb.GetTotalGroupNum()
|
totalGroupNum, err := s.adminCMSInterface.GetTotalGroupNum()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
resp.IncreaseGroupNum = increaseGroupNum
|
resp.IncreaseGroupNum = int32(increaseGroupNum)
|
||||||
resp.TotalGroupNum = totalGroupNum
|
resp.TotalGroupNum = int32(totalGroupNum)
|
||||||
times := GetRangeDate(fromTime, toTime)
|
times := GetRangeDate(fromTime, toTime)
|
||||||
log.NewDebug(req.OperationID, "times:", times)
|
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
resp.IncreaseGroupNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
resp.IncreaseGroupNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
resp.TotalGroupNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
resp.TotalGroupNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
@ -408,57 +365,47 @@ func (s *adminCMSServer) GetGroupStatistics(_ context.Context, req *pbAdminCMS.G
|
|||||||
for i, v := range times {
|
for i, v := range times {
|
||||||
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
num, err := imdb.GetIncreaseGroupNum(v[0], v[1])
|
num, err := s.adminCMSInterface.GetIncreaseGroupNum(v[0], v[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
log.NewError(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
}
|
}
|
||||||
resp.IncreaseGroupNumList[index] = &pbAdminCMS.DateNumList{
|
resp.IncreaseGroupNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
Date: v[0].String(),
|
Date: v[0].String(),
|
||||||
Num: num,
|
Num: int32(num),
|
||||||
}
|
}
|
||||||
num, err = imdb.GetGroupNum(v[1])
|
num, err = s.adminCMSInterface.GetGroupNum(v[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
log.NewError(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
}
|
}
|
||||||
resp.TotalGroupNumList[index] = &pbAdminCMS.DateNumList{
|
resp.TotalGroupNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
Date: v[0].String(),
|
Date: v[0].String(),
|
||||||
Num: num,
|
Num: int32(num),
|
||||||
}
|
}
|
||||||
}(wg, i, v)
|
}(wg, i, v)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *adminCMSServer) GetMessageStatistics(_ context.Context, req *pbAdminCMS.GetMessageStatisticsReq) (*pbAdminCMS.GetMessageStatisticsResp, error) {
|
func (s *adminCMSServer) GetMessageStatistics(ctx context.Context, req *pbAdminCMS.GetMessageStatisticsReq) (*pbAdminCMS.GetMessageStatisticsResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
resp := &pbAdminCMS.GetMessageStatisticsResp{}
|
||||||
resp := &pbAdminCMS.GetMessageStatisticsResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "times: ", fromTime, toTime)
|
log.NewDebug(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "times: ", fromTime, toTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
log.NewError(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
return nil, err
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
privateMessageNum, err := imdb.GetSingleChatMessageNum(fromTime, toTime.Add(time.Hour*24))
|
privateMessageNum, err := s.adminCMSInterface.GetSingleChatMessageNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSingleChatMessageNum failed", err.Error())
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
groupMessageNum, err := imdb.GetGroupMessageNum(fromTime, toTime.Add(time.Hour*24))
|
groupMessageNum, err := s.adminCMSInterface.GetGroupMessageNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMessageNum failed", err.Error())
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), privateMessageNum, groupMessageNum)
|
log.NewDebug(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), privateMessageNum, groupMessageNum)
|
||||||
resp.PrivateMessageNum = privateMessageNum
|
resp.PrivateMessageNum = int32(privateMessageNum)
|
||||||
resp.GroupMessageNum = groupMessageNum
|
resp.GroupMessageNum = int32(groupMessageNum)
|
||||||
times := GetRangeDate(fromTime, toTime)
|
times := GetRangeDate(fromTime, toTime)
|
||||||
resp.GroupMessageNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
resp.GroupMessageNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
resp.PrivateMessageNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
resp.PrivateMessageNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
@ -467,22 +414,21 @@ func (s *adminCMSServer) GetMessageStatistics(_ context.Context, req *pbAdminCMS
|
|||||||
for i, v := range times {
|
for i, v := range times {
|
||||||
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
num, err := s.adminCMSInterface.GetSingleChatMessageNum(v[0], v[1])
|
||||||
num, err := imdb.GetSingleChatMessageNum(v[0], v[1])
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
log.NewError(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
}
|
}
|
||||||
resp.PrivateMessageNumList[index] = &pbAdminCMS.DateNumList{
|
resp.PrivateMessageNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
Date: v[0].String(),
|
Date: v[0].String(),
|
||||||
Num: num,
|
Num: int32(num),
|
||||||
}
|
}
|
||||||
num, err = imdb.GetGroupMessageNum(v[0], v[1])
|
num, err = s.adminCMSInterface.GetGroupMessageNum(v[0], v[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
log.NewError(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
}
|
}
|
||||||
resp.GroupMessageNumList[index] = &pbAdminCMS.DateNumList{
|
resp.GroupMessageNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
Date: v[0].String(),
|
Date: v[0].String(),
|
||||||
Num: num,
|
Num: int32(num),
|
||||||
}
|
}
|
||||||
}(wg, i, v)
|
}(wg, i, v)
|
||||||
}
|
}
|
||||||
@ -491,39 +437,27 @@ func (s *adminCMSServer) GetMessageStatistics(_ context.Context, req *pbAdminCMS
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *adminCMSServer) GetUserStatistics(_ context.Context, req *pbAdminCMS.GetUserStatisticsReq) (*pbAdminCMS.GetUserStatisticsResp, error) {
|
func (s *adminCMSServer) GetUserStatistics(_ context.Context, req *pbAdminCMS.GetUserStatisticsReq) (*pbAdminCMS.GetUserStatisticsResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
resp := &pbAdminCMS.GetUserStatisticsResp{}
|
||||||
resp := &pbAdminCMS.GetUserStatisticsResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
return nil, err
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
activeUserNum, err := imdb.GetActiveUserNum(fromTime, toTime.Add(time.Hour*24))
|
activeUserNum, err := s.adminCMSInterface.GetActiveUserNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUserNum failed", err.Error())
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
increaseUserNum, err := imdb.GetIncreaseUserNum(fromTime, toTime.Add(time.Hour*24))
|
increaseUserNum, err := s.adminCMSInterface.GetIncreaseUserNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseUserNum failed", err.Error())
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
totalUserNum, err := imdb.GetTotalUserNum()
|
totalUserNum, err := s.adminCMSInterface.GetTotalUserNum()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTotalUserNum failed", err.Error())
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
resp.ActiveUserNum = activeUserNum
|
resp.ActiveUserNum = int32(activeUserNum)
|
||||||
resp.TotalUserNum = totalUserNum
|
resp.TotalUserNum = int32(totalUserNum)
|
||||||
resp.IncreaseUserNum = increaseUserNum
|
resp.IncreaseUserNum = int32(increaseUserNum)
|
||||||
times := GetRangeDate(fromTime, toTime)
|
times := GetRangeDate(fromTime, toTime)
|
||||||
resp.TotalUserNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
resp.TotalUserNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
resp.ActiveUserNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
resp.ActiveUserNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
@ -533,65 +467,56 @@ func (s *adminCMSServer) GetUserStatistics(_ context.Context, req *pbAdminCMS.Ge
|
|||||||
for i, v := range times {
|
for i, v := range times {
|
||||||
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
num, err := imdb.GetActiveUserNum(v[0], v[1])
|
num, err := s.adminCMSInterface.GetActiveUserNum(v[0], v[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
}
|
}
|
||||||
resp.ActiveUserNumList[index] = &pbAdminCMS.DateNumList{
|
resp.ActiveUserNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
Date: v[0].String(),
|
Date: v[0].String(),
|
||||||
Num: num,
|
Num: int32(num),
|
||||||
}
|
}
|
||||||
|
|
||||||
num, err = imdb.GetTotalUserNumByDate(v[1])
|
num, err = s.adminCMSInterface.GetTotalUserNumByDate(v[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTotalUserNumByDate", v, err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTotalUserNumByDate", v, err.Error())
|
||||||
}
|
}
|
||||||
resp.TotalUserNumList[index] = &pbAdminCMS.DateNumList{
|
resp.TotalUserNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
Date: v[0].String(),
|
Date: v[0].String(),
|
||||||
Num: num,
|
Num: int32(num),
|
||||||
}
|
}
|
||||||
num, err = imdb.GetIncreaseUserNum(v[0], v[1])
|
num, err = s.adminCMSInterface.GetIncreaseUserNum(v[0], v[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseUserNum", v, err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseUserNum", v, err.Error())
|
||||||
}
|
}
|
||||||
resp.IncreaseUserNumList[index] = &pbAdminCMS.DateNumList{
|
resp.IncreaseUserNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
Date: v[0].String(),
|
Date: v[0].String(),
|
||||||
Num: num,
|
Num: int32(num),
|
||||||
}
|
}
|
||||||
}(wg, i, v)
|
}(wg, i, v)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *adminCMSServer) GetUserFriends(_ context.Context, req *pbAdminCMS.GetUserFriendsReq) (*pbAdminCMS.GetUserFriendsResp, error) {
|
func (s *adminCMSServer) GetUserFriends(ctx context.Context, req *pbAdminCMS.GetUserFriendsReq) (*pbAdminCMS.GetUserFriendsResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
resp := &pbAdminCMS.GetUserFriendsResp{}
|
||||||
resp := &pbAdminCMS.GetUserFriendsResp{CommonResp: &pbAdminCMS.CommonResp{}, Pagination: &server_api_params.ResponsePagination{CurrentPage: req.Pagination.PageNumber, ShowNumber: req.Pagination.ShowNumber}}
|
var friendList []*relation.FriendUser
|
||||||
var friendList []*imdb.FriendUser
|
|
||||||
var err error
|
var err error
|
||||||
if req.FriendUserID != "" {
|
if req.FriendUserID != "" {
|
||||||
friend, err := imdb.GetFriendByIDCMS(req.UserID, req.FriendUserID)
|
friend, err := s.adminCMSInterface.GetFriendByIDCMS(req.UserID, req.FriendUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err, req.UserID, req.FriendUserID)
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID, req.FriendUserID)
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
friendList = append(friendList, friend)
|
friendList = append(friendList, friend)
|
||||||
resp.FriendNums = 1
|
resp.FriendNums = 1
|
||||||
} else {
|
} else {
|
||||||
var count int64
|
var count int64
|
||||||
friendList, count, err = imdb.GetUserFriendsCMS(req.UserID, req.FriendUserName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
friendList, count, err = s.adminCMSInterface.GetUserFriendsCMS(req.UserID, req.FriendUserName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID, req.FriendUserName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
return nil, err
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
resp.FriendNums = int32(count)
|
resp.FriendNums = int32(count)
|
||||||
}
|
}
|
||||||
@ -602,21 +527,15 @@ func (s *adminCMSServer) GetUserFriends(_ context.Context, req *pbAdminCMS.GetUs
|
|||||||
friendInfo.FriendUser = userInfo
|
friendInfo.FriendUser = userInfo
|
||||||
resp.FriendInfoList = append(resp.FriendInfoList, friendInfo)
|
resp.FriendInfoList = append(resp.FriendInfoList, friendInfo)
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *adminCMSServer) GetUserIDByEmailAndPhoneNumber(_ context.Context, req *pbAdminCMS.GetUserIDByEmailAndPhoneNumberReq) (*pbAdminCMS.GetUserIDByEmailAndPhoneNumberResp, error) {
|
func (s *adminCMSServer) GetUserIDByEmailAndPhoneNumber(ctx context.Context, req *pbAdminCMS.GetUserIDByEmailAndPhoneNumberReq) (*pbAdminCMS.GetUserIDByEmailAndPhoneNumberResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
resp := &pbAdminCMS.GetUserIDByEmailAndPhoneNumberResp{}
|
||||||
resp := &pbAdminCMS.GetUserIDByEmailAndPhoneNumberResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
userIDList, err := s.userInterface.GetUserIDsByEmailAndID(req.PhoneNumber, req.Email)
|
||||||
userIDList, err := imdb.GetUserIDsByEmailAndID(req.PhoneNumber, req.Email)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.PhoneNumber, req.Email)
|
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
resp.CommonResp.ErrMsg = err.Error()
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
resp.UserIDList = userIDList
|
resp.UserIDList = userIDList
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package group
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
relation "Open_IM/pkg/common/db/mysql"
|
relation "Open_IM/pkg/common/db/mysql"
|
||||||
"Open_IM/pkg/common/tools"
|
|
||||||
pbGroup "Open_IM/pkg/proto/group"
|
pbGroup "Open_IM/pkg/proto/group"
|
||||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
@ -17,7 +16,7 @@ func getDBGroupRequest(ctx context.Context, req *pbGroup.GroupApplicationRespons
|
|||||||
dbGroupRequest = &relation.GroupRequest{}
|
dbGroupRequest = &relation.GroupRequest{}
|
||||||
utils.CopyStructFields(&dbGroupRequest, req)
|
utils.CopyStructFields(&dbGroupRequest, req)
|
||||||
dbGroupRequest.UserID = req.FromUserID
|
dbGroupRequest.UserID = req.FromUserID
|
||||||
dbGroupRequest.HandleUserID = tools.OpUserID(ctx)
|
dbGroupRequest.HandleUserID = utils.OpUserID(ctx)
|
||||||
dbGroupRequest.HandledTime = time.Now()
|
dbGroupRequest.HandledTime = time.Now()
|
||||||
return dbGroupRequest
|
return dbGroupRequest
|
||||||
}
|
}
|
||||||
@ -29,7 +28,7 @@ func getDBGroupMember(ctx context.Context, groupID, userID string) (dbGroupMembe
|
|||||||
member.GroupID = groupID
|
member.GroupID = groupID
|
||||||
member.UserID = userID
|
member.UserID = userID
|
||||||
member.RoleLevel = constant.GroupOrdinaryUsers
|
member.RoleLevel = constant.GroupOrdinaryUsers
|
||||||
member.OperatorUserID = tools.OpUserID(ctx)
|
member.OperatorUserID = utils.OpUserID(ctx)
|
||||||
|
|
||||||
member.FaceURL = user.FaceURL
|
member.FaceURL = user.FaceURL
|
||||||
member.Nickname = user.Nickname
|
member.Nickname = user.Nickname
|
||||||
@ -60,7 +59,7 @@ func genGroupID(ctx context.Context, groupID string) string {
|
|||||||
if groupID != "" {
|
if groupID != "" {
|
||||||
return groupID
|
return groupID
|
||||||
}
|
}
|
||||||
groupID = utils.Md5(tools.OperationID(ctx) + strconv.FormatInt(time.Now().UnixNano(), 10))
|
groupID = utils.Md5(utils.OperationID(ctx) + strconv.FormatInt(time.Now().UnixNano(), 10))
|
||||||
bi := big.NewInt(0)
|
bi := big.NewInt(0)
|
||||||
bi.SetString(groupID[0:8], 16)
|
bi.SetString(groupID[0:8], 16)
|
||||||
groupID = bi.String()
|
groupID = bi.String()
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
"Open_IM/pkg/common/middleware"
|
"Open_IM/pkg/common/middleware"
|
||||||
promePkg "Open_IM/pkg/common/prometheus"
|
promePkg "Open_IM/pkg/common/prometheus"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/common/tools"
|
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
|
|
||||||
cp "Open_IM/internal/utils"
|
cp "Open_IM/internal/utils"
|
||||||
@ -180,12 +179,12 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
opUserID := tools.OpUserID(ctx)
|
opUserID := utils.OpUserID(ctx)
|
||||||
joinGroup := func(userID string, roleLevel int32) error {
|
joinGroup := func(userID string, roleLevel int32) error {
|
||||||
user := userMap[userID]
|
user := userMap[userID]
|
||||||
groupMember := &relation.GroupMember{GroupID: group.GroupID, RoleLevel: roleLevel, OperatorUserID: opUserID, JoinSource: constant.JoinByInvitation, InviterUserID: opUserID}
|
groupMember := &relation.GroupMember{GroupID: group.GroupID, RoleLevel: roleLevel, OperatorUserID: opUserID, JoinSource: constant.JoinByInvitation, InviterUserID: opUserID}
|
||||||
utils.CopyStructFields(&groupMember, user)
|
utils.CopyStructFields(&groupMember, user)
|
||||||
if err := CallbackBeforeMemberJoinGroup(ctx, tools.OperationID(ctx), groupMember, group.Ex); err != nil {
|
if err := CallbackBeforeMemberJoinGroup(ctx, utils.OperationID(ctx), groupMember, group.Ex); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
groupMembers = append(groupMembers, groupMember)
|
groupMembers = append(groupMembers, groupMember)
|
||||||
@ -213,11 +212,11 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
if req.GroupInfo.GroupType == constant.SuperGroup {
|
if req.GroupInfo.GroupType == constant.SuperGroup {
|
||||||
go func() {
|
go func() {
|
||||||
for _, userID := range userIDs {
|
for _, userID := range userIDs {
|
||||||
chat.SuperGroupNotification(tools.OperationID(ctx), userID, userID)
|
chat.SuperGroupNotification(utils.OperationID(ctx), userID, userID)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
chat.GroupCreatedNotification(tools.OperationID(ctx), tools.OpUserID(ctx), group.GroupID, userIDs)
|
chat.GroupCreatedNotification(utils.OperationID(ctx), utils.OpUserID(ctx), group.GroupID, userIDs)
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
@ -301,7 +300,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
}
|
}
|
||||||
if group.NeedVerification == constant.AllNeedVerification {
|
if group.NeedVerification == constant.AllNeedVerification {
|
||||||
if !token_verify.IsAppManagerUid(ctx) {
|
if !token_verify.IsAppManagerUid(ctx) {
|
||||||
opUserID := tools.OpUserID(ctx)
|
opUserID := utils.OpUserID(ctx)
|
||||||
member, ok := memberMap[opUserID]
|
member, ok := memberMap[opUserID]
|
||||||
if ok {
|
if ok {
|
||||||
return nil, constant.ErrNoPermission.Wrap("not in group")
|
return nil, constant.ErrNoPermission.Wrap("not in group")
|
||||||
@ -336,7 +335,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, userID := range req.InvitedUserIDList {
|
for _, userID := range req.InvitedUserIDList {
|
||||||
chat.SuperGroupNotification(tools.OperationID(ctx), userID, userID)
|
chat.SuperGroupNotification(utils.OperationID(ctx), userID, userID)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var groupMembers []*relation.GroupMember
|
var groupMembers []*relation.GroupMember
|
||||||
@ -346,10 +345,10 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
utils.CopyStructFields(&member, user)
|
utils.CopyStructFields(&member, user)
|
||||||
member.GroupID = req.GroupID
|
member.GroupID = req.GroupID
|
||||||
member.RoleLevel = constant.GroupOrdinaryUsers
|
member.RoleLevel = constant.GroupOrdinaryUsers
|
||||||
member.OperatorUserID = tools.OpUserID(ctx)
|
member.OperatorUserID = utils.OpUserID(ctx)
|
||||||
member.InviterUserID = tools.OpUserID(ctx)
|
member.InviterUserID = utils.OpUserID(ctx)
|
||||||
member.JoinSource = constant.JoinByInvitation
|
member.JoinSource = constant.JoinByInvitation
|
||||||
if err := CallbackBeforeMemberJoinGroup(ctx, tools.OperationID(ctx), &member, group.Ex); err != nil {
|
if err := CallbackBeforeMemberJoinGroup(ctx, utils.OperationID(ctx), &member, group.Ex); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groupMembers = append(groupMembers, &member)
|
groupMembers = append(groupMembers, &member)
|
||||||
@ -357,7 +356,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
if err := s.GroupInterface.CreateGroupMember(ctx, groupMembers); err != nil {
|
if err := s.GroupInterface.CreateGroupMember(ctx, groupMembers); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.MemberInvitedNotification(tools.OperationID(ctx), req.GroupID, tools.OpUserID(ctx), req.Reason, req.InvitedUserIDList)
|
chat.MemberInvitedNotification(utils.OperationID(ctx), req.GroupID, utils.OpUserID(ctx), req.Reason, req.InvitedUserIDList)
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
@ -436,8 +435,8 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
|||||||
var okUserIDList []string
|
var okUserIDList []string
|
||||||
if groupInfo.GroupType != constant.SuperGroup {
|
if groupInfo.GroupType != constant.SuperGroup {
|
||||||
opFlag := 0
|
opFlag := 0
|
||||||
if !token_verify.IsManagerUserID(tools.OpUserID(ctx)) {
|
if !token_verify.IsManagerUserID(utils.OpUserID(ctx)) {
|
||||||
opInfo, err := rocksCache.GetGroupMemberInfoFromCache(ctx, req.GroupID, tools.OpUserID(ctx))
|
opInfo, err := rocksCache.GetGroupMemberInfoFromCache(ctx, req.GroupID, utils.OpUserID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -484,7 +483,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
|||||||
err = relation.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, v)
|
err = relation.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, v)
|
||||||
tracelog.SetCtxInfo(ctx, "RemoveGroupMember", err, "groupID", req.GroupID, "userID", v)
|
tracelog.SetCtxInfo(ctx, "RemoveGroupMember", err, "groupID", req.GroupID, "userID", v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(tools.OperationID(ctx), "RemoveGroupMember failed ", err.Error(), req.GroupID, v)
|
log.NewError(utils.OperationID(ctx), "RemoveGroupMember failed ", err.Error(), req.GroupID, v)
|
||||||
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: -1})
|
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: -1})
|
||||||
} else {
|
} else {
|
||||||
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: 0})
|
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: 0})
|
||||||
@ -494,7 +493,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
|||||||
var reqPb pbUser.SetConversationReq
|
var reqPb pbUser.SetConversationReq
|
||||||
var c pbConversation.Conversation
|
var c pbConversation.Conversation
|
||||||
for _, v := range okUserIDList {
|
for _, v := range okUserIDList {
|
||||||
reqPb.OperationID = tools.OperationID(ctx)
|
reqPb.OperationID = utils.OperationID(ctx)
|
||||||
c.OwnerUserID = v
|
c.OwnerUserID = v
|
||||||
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType)
|
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType)
|
||||||
c.ConversationType = constant.GroupChatType
|
c.ConversationType = constant.GroupChatType
|
||||||
@ -531,7 +530,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
|||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
for _, v := range req.KickedUserIDList {
|
for _, v := range req.KickedUserIDList {
|
||||||
chat.SuperGroupNotification(tools.OperationID(ctx), v, v)
|
chat.SuperGroupNotification(utils.OperationID(ctx), v, v)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -587,7 +586,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
|
|||||||
tracelog.SetCtxInfo(ctx, "GetRecvGroupApplicationList", nil, " FromUserID: ", req.FromUserID, "GroupApplicationList: ", reply)
|
tracelog.SetCtxInfo(ctx, "GetRecvGroupApplicationList", nil, " FromUserID: ", req.FromUserID, "GroupApplicationList: ", reply)
|
||||||
for _, v := range reply {
|
for _, v := range reply {
|
||||||
node := open_im_sdk.GroupRequest{UserInfo: &open_im_sdk.PublicUserInfo{}, GroupInfo: &open_im_sdk.GroupInfo{}}
|
node := open_im_sdk.GroupRequest{UserInfo: &open_im_sdk.PublicUserInfo{}, GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||||
err := FillGroupInfoByGroupID(tools.OperationID(ctx), v.GroupID, node.GroupInfo)
|
err := FillGroupInfoByGroupID(utils.OperationID(ctx), v.GroupID, node.GroupInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.Is(errors.Unwrap(err), constant.ErrDismissedAlready) {
|
if !errors.Is(errors.Unwrap(err), constant.ErrDismissedAlready) {
|
||||||
errResult = err
|
errResult = err
|
||||||
@ -595,7 +594,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tracelog.SetCtxInfo(ctx, "FillGroupInfoByGroupID ", nil, " groupID: ", v.GroupID, " groupInfo: ", node.GroupInfo)
|
tracelog.SetCtxInfo(ctx, "FillGroupInfoByGroupID ", nil, " groupID: ", v.GroupID, " groupInfo: ", node.GroupInfo)
|
||||||
err = FillPublicUserInfoByUserID(tools.OperationID(ctx), v.UserID, node.UserInfo)
|
err = FillPublicUserInfoByUserID(utils.OperationID(ctx), v.UserID, node.UserInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errResult = err
|
errResult = err
|
||||||
continue
|
continue
|
||||||
@ -640,7 +639,7 @@ func CheckPermission(ctx context.Context, groupID string, userID string) (err er
|
|||||||
func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (*pbGroup.GroupApplicationResponseResp, error) {
|
func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (*pbGroup.GroupApplicationResponseResp, error) {
|
||||||
resp := &pbGroup.GroupApplicationResponseResp{}
|
resp := &pbGroup.GroupApplicationResponseResp{}
|
||||||
|
|
||||||
if err := CheckPermission(ctx, req.GroupID, tools.OpUserID(ctx)); err != nil {
|
if err := CheckPermission(ctx, req.GroupID, utils.OpUserID(ctx)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groupRequest := getDBGroupRequest(ctx, req)
|
groupRequest := getDBGroupRequest(ctx, req)
|
||||||
@ -656,7 +655,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = CallbackBeforeMemberJoinGroup(ctx, tools.OperationID(ctx), member, groupInfo.Ex)
|
err = CallbackBeforeMemberJoinGroup(ctx, utils.OperationID(ctx), member, groupInfo.Ex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -664,12 +663,12 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
etcdCacheConn, err := fault_tolerant.GetDefaultConn(config.Config.RpcRegisterName.OpenImCacheName, tools.OperationID(ctx))
|
etcdCacheConn, err := fault_tolerant.GetDefaultConn(config.Config.RpcRegisterName.OpenImCacheName, utils.OperationID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cacheClient := pbCache.NewCacheClient(etcdCacheConn)
|
cacheClient := pbCache.NewCacheClient(etcdCacheConn)
|
||||||
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{OperationID: tools.OperationID(ctx), GroupID: req.GroupID})
|
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{OperationID: utils.OperationID(ctx), GroupID: req.GroupID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -696,7 +695,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
|||||||
func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) (*pbGroup.JoinGroupResp, error) {
|
func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) (*pbGroup.JoinGroupResp, error) {
|
||||||
resp := &pbGroup.JoinGroupResp{}
|
resp := &pbGroup.JoinGroupResp{}
|
||||||
|
|
||||||
if _, err := relation.GetUserByUserID(tools.OpUserID(ctx)); err != nil {
|
if _, err := relation.GetUserByUserID(utils.OpUserID(ctx)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groupInfo, err := rocksCache.GetGroupInfoFromCache(ctx, req.GroupID)
|
groupInfo, err := rocksCache.GetGroupInfoFromCache(ctx, req.GroupID)
|
||||||
@ -709,17 +708,17 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
|||||||
|
|
||||||
if groupInfo.NeedVerification == constant.Directly {
|
if groupInfo.NeedVerification == constant.Directly {
|
||||||
if groupInfo.GroupType != constant.SuperGroup {
|
if groupInfo.GroupType != constant.SuperGroup {
|
||||||
us, err := relation.GetUserByUserID(tools.OpUserID(ctx))
|
us, err := relation.GetUserByUserID(utils.OpUserID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
//to group member
|
//to group member
|
||||||
groupMember := relation.GroupMember{GroupID: req.GroupID, RoleLevel: constant.GroupOrdinaryUsers, OperatorUserID: tools.OpUserID(ctx)}
|
groupMember := relation.GroupMember{GroupID: req.GroupID, RoleLevel: constant.GroupOrdinaryUsers, OperatorUserID: utils.OpUserID(ctx)}
|
||||||
utils.CopyStructFields(&groupMember, us)
|
utils.CopyStructFields(&groupMember, us)
|
||||||
if err := CallbackBeforeMemberJoinGroup(ctx, tools.OperationID(ctx), &groupMember, groupInfo.Ex); err != nil {
|
if err := CallbackBeforeMemberJoinGroup(ctx, utils.OperationID(ctx), &groupMember, groupInfo.Ex); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := s.DelGroupAndUserCache(ctx, req.GroupID, []string{tools.OpUserID(ctx)}); err != nil {
|
if err := s.DelGroupAndUserCache(ctx, req.GroupID, []string{utils.OpUserID(ctx)}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = relation.InsertIntoGroupMember(groupMember)
|
err = relation.InsertIntoGroupMember(groupMember)
|
||||||
@ -735,8 +734,8 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
|||||||
}
|
}
|
||||||
var reqPb pbUser.SetConversationReq
|
var reqPb pbUser.SetConversationReq
|
||||||
var c pbConversation.Conversation
|
var c pbConversation.Conversation
|
||||||
reqPb.OperationID = tools.OperationID(ctx)
|
reqPb.OperationID = utils.OperationID(ctx)
|
||||||
c.OwnerUserID = tools.OpUserID(ctx)
|
c.OwnerUserID = utils.OpUserID(ctx)
|
||||||
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, sessionType)
|
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, sessionType)
|
||||||
c.ConversationType = int32(sessionType)
|
c.ConversationType = int32(sessionType)
|
||||||
c.GroupID = req.GroupID
|
c.GroupID = req.GroupID
|
||||||
@ -750,7 +749,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
|||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||||
tracelog.SetCtxInfo(ctx, "SetConversation", err, "req", reqPb, "resp", respPb)
|
tracelog.SetCtxInfo(ctx, "SetConversation", err, "req", reqPb, "resp", respPb)
|
||||||
chat.MemberEnterDirectlyNotification(req.GroupID, tools.OpUserID(ctx), tools.OperationID(ctx))
|
chat.MemberEnterDirectlyNotification(req.GroupID, utils.OpUserID(ctx), utils.OperationID(ctx))
|
||||||
return resp, nil
|
return resp, nil
|
||||||
} else {
|
} else {
|
||||||
constant.SetErrorForResp(constant.ErrGroupTypeNotSupport, resp.CommonResp)
|
constant.SetErrorForResp(constant.ErrGroupTypeNotSupport, resp.CommonResp)
|
||||||
@ -758,7 +757,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var groupRequest relation.GroupRequest
|
var groupRequest relation.GroupRequest
|
||||||
groupRequest.UserID = tools.OpUserID(ctx)
|
groupRequest.UserID = utils.OpUserID(ctx)
|
||||||
groupRequest.ReqMsg = req.ReqMessage
|
groupRequest.ReqMsg = req.ReqMessage
|
||||||
groupRequest.GroupID = req.GroupID
|
groupRequest.GroupID = req.GroupID
|
||||||
groupRequest.JoinSource = req.JoinSource
|
groupRequest.JoinSource = req.JoinSource
|
||||||
@ -778,31 +777,31 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if groupInfo.GroupType != constant.SuperGroup {
|
if groupInfo.GroupType != constant.SuperGroup {
|
||||||
_, err = rocksCache.GetGroupMemberInfoFromCache(ctx, req.GroupID, tools.OpUserID(ctx))
|
_, err = rocksCache.GetGroupMemberInfoFromCache(ctx, req.GroupID, utils.OpUserID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := s.DelGroupAndUserCache(ctx, req.GroupID, []string{tools.OpUserID(ctx)}); err != nil {
|
if err := s.DelGroupAndUserCache(ctx, req.GroupID, []string{utils.OpUserID(ctx)}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = relation.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, tools.OpUserID(ctx))
|
err = relation.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, utils.OpUserID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
okUserIDList := []string{tools.OpUserID(ctx)}
|
okUserIDList := []string{utils.OpUserID(ctx)}
|
||||||
if err := db.DB.RemoverUserFromSuperGroup(req.GroupID, okUserIDList); err != nil {
|
if err := db.DB.RemoverUserFromSuperGroup(req.GroupID, okUserIDList); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if groupInfo.GroupType != constant.SuperGroup {
|
if groupInfo.GroupType != constant.SuperGroup {
|
||||||
_ = rocksCache.DelGroupMemberInfoFromCache(ctx, req.GroupID, tools.OpUserID(ctx))
|
_ = rocksCache.DelGroupMemberInfoFromCache(ctx, req.GroupID, utils.OpUserID(ctx))
|
||||||
chat.MemberQuitNotification(req)
|
chat.MemberQuitNotification(req)
|
||||||
} else {
|
} else {
|
||||||
_ = rocksCache.DelJoinedSuperGroupIDListFromCache(ctx, tools.OpUserID(ctx))
|
_ = rocksCache.DelJoinedSuperGroupIDListFromCache(ctx, utils.OpUserID(ctx))
|
||||||
_ = rocksCache.DelGroupMemberListHashFromCache(ctx, req.GroupID)
|
_ = rocksCache.DelGroupMemberListHashFromCache(ctx, req.GroupID)
|
||||||
chat.SuperGroupNotification(tools.OperationID(ctx), tools.OpUserID(ctx), tools.OpUserID(ctx))
|
chat.SuperGroupNotification(utils.OperationID(ctx), utils.OpUserID(ctx), utils.OpUserID(ctx))
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
@ -871,7 +870,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
var groupInfo relation.Group
|
var groupInfo relation.Group
|
||||||
utils.CopyStructFields(&groupInfo, req.GroupInfoForSet)
|
utils.CopyStructFields(&groupInfo, req.GroupInfoForSet)
|
||||||
if req.GroupInfoForSet.Notification != "" {
|
if req.GroupInfoForSet.Notification != "" {
|
||||||
groupInfo.NotificationUserID = tools.OpUserID(ctx)
|
groupInfo.NotificationUserID = utils.OpUserID(ctx)
|
||||||
groupInfo.NotificationUpdateTime = time.Now()
|
groupInfo.NotificationUpdateTime = time.Now()
|
||||||
}
|
}
|
||||||
if err := rocksCache.DelGroupInfoFromCache(ctx, req.GroupInfoForSet.GroupID); err != nil {
|
if err := rocksCache.DelGroupInfoFromCache(ctx, req.GroupInfoForSet.GroupID); err != nil {
|
||||||
@ -882,11 +881,11 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if changedType != 0 {
|
if changedType != 0 {
|
||||||
chat.GroupInfoSetNotification(tools.OperationID(ctx), tools.OpUserID(ctx), req.GroupInfoForSet.GroupID, groupName, notification, introduction, faceURL, req.GroupInfoForSet.NeedVerification)
|
chat.GroupInfoSetNotification(utils.OperationID(ctx), utils.OpUserID(ctx), req.GroupInfoForSet.GroupID, groupName, notification, introduction, faceURL, req.GroupInfoForSet.NeedVerification)
|
||||||
}
|
}
|
||||||
if req.GroupInfoForSet.Notification != "" {
|
if req.GroupInfoForSet.Notification != "" {
|
||||||
//get group member user id
|
//get group member user id
|
||||||
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: tools.OperationID(ctx), GroupID: req.GroupInfoForSet.GroupID}
|
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: utils.OperationID(ctx), GroupID: req.GroupInfoForSet.GroupID}
|
||||||
etcdConn, err := getcdv3.GetConn(ctx, config.Config.RpcRegisterName.OpenImCacheName)
|
etcdConn, err := getcdv3.GetConn(ctx, config.Config.RpcRegisterName.OpenImCacheName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -901,13 +900,13 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
}
|
}
|
||||||
var conversationReq pbConversation.ModifyConversationFieldReq
|
var conversationReq pbConversation.ModifyConversationFieldReq
|
||||||
conversation := pbConversation.Conversation{
|
conversation := pbConversation.Conversation{
|
||||||
OwnerUserID: tools.OpUserID(ctx),
|
OwnerUserID: utils.OpUserID(ctx),
|
||||||
ConversationID: utils.GetConversationIDBySessionType(req.GroupInfoForSet.GroupID, constant.GroupChatType),
|
ConversationID: utils.GetConversationIDBySessionType(req.GroupInfoForSet.GroupID, constant.GroupChatType),
|
||||||
ConversationType: constant.GroupChatType,
|
ConversationType: constant.GroupChatType,
|
||||||
GroupID: req.GroupInfoForSet.GroupID,
|
GroupID: req.GroupInfoForSet.GroupID,
|
||||||
}
|
}
|
||||||
conversationReq.Conversation = &conversation
|
conversationReq.Conversation = &conversation
|
||||||
conversationReq.OperationID = tools.OperationID(ctx)
|
conversationReq.OperationID = utils.OperationID(ctx)
|
||||||
conversationReq.FieldType = constant.FieldGroupAtType
|
conversationReq.FieldType = constant.FieldGroupAtType
|
||||||
conversation.GroupAtType = constant.GroupNotification
|
conversation.GroupAtType = constant.GroupNotification
|
||||||
conversationReq.UserIDList = cacheResp.UserIDList
|
conversationReq.UserIDList = cacheResp.UserIDList
|
||||||
@ -1020,7 +1019,7 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGr
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.NewInfo(tools.OperationID(ctx), groupMembersCount)
|
log.NewInfo(utils.OperationID(ctx), groupMembersCount)
|
||||||
resp.MemberNums = int32(groupMembersCount)
|
resp.MemberNums = int32(groupMembersCount)
|
||||||
for _, groupMember := range groupMembers {
|
for _, groupMember := range groupMembers {
|
||||||
member := open_im_sdk.GroupMemberFullInfo{}
|
member := open_im_sdk.GroupMemberFullInfo{}
|
||||||
@ -1065,7 +1064,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
|
|||||||
func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGroupReq) (*pbGroup.DismissGroupResp, error) {
|
func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGroupReq) (*pbGroup.DismissGroupResp, error) {
|
||||||
resp := &pbGroup.DismissGroupResp{}
|
resp := &pbGroup.DismissGroupResp{}
|
||||||
|
|
||||||
if !token_verify.IsManagerUserID(tools.OpUserID(ctx)) && !relation.IsGroupOwnerAdmin(req.GroupID, tools.OpUserID(ctx)) {
|
if !token_verify.IsManagerUserID(utils.OpUserID(ctx)) && !relation.IsGroupOwnerAdmin(req.GroupID, utils.OpUserID(ctx)) {
|
||||||
return nil, utils.Wrap(constant.ErrIdentity, "")
|
return nil, utils.Wrap(constant.ErrIdentity, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1093,7 +1092,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
|||||||
var reqPb pbUser.SetConversationReq
|
var reqPb pbUser.SetConversationReq
|
||||||
var c pbConversation.Conversation
|
var c pbConversation.Conversation
|
||||||
for _, v := range memberList {
|
for _, v := range memberList {
|
||||||
reqPb.OperationID = tools.OperationID(ctx)
|
reqPb.OperationID = utils.OperationID(ctx)
|
||||||
c.OwnerUserID = v.UserID
|
c.OwnerUserID = v.UserID
|
||||||
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType)
|
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType)
|
||||||
c.ConversationType = constant.GroupChatType
|
c.ConversationType = constant.GroupChatType
|
||||||
@ -1122,7 +1121,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
|||||||
func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGroupMemberReq) (*pbGroup.MuteGroupMemberResp, error) {
|
func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGroupMemberReq) (*pbGroup.MuteGroupMemberResp, error) {
|
||||||
resp := &pbGroup.MuteGroupMemberResp{}
|
resp := &pbGroup.MuteGroupMemberResp{}
|
||||||
|
|
||||||
opFlag, err := s.getGroupUserLevel(req.GroupID, tools.OpUserID(ctx))
|
opFlag, err := s.getGroupUserLevel(req.GroupID, utils.OpUserID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1150,14 +1149,14 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.GroupMemberMutedNotification(tools.OperationID(ctx), tools.OpUserID(ctx), req.GroupID, req.UserID, req.MutedSeconds)
|
chat.GroupMemberMutedNotification(utils.OperationID(ctx), utils.OpUserID(ctx), req.GroupID, req.UserID, req.MutedSeconds)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.CancelMuteGroupMemberReq) (*pbGroup.CancelMuteGroupMemberResp, error) {
|
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.CancelMuteGroupMemberReq) (*pbGroup.CancelMuteGroupMemberResp, error) {
|
||||||
resp := &pbGroup.CancelMuteGroupMemberResp{}
|
resp := &pbGroup.CancelMuteGroupMemberResp{}
|
||||||
|
|
||||||
opFlag, err := s.getGroupUserLevel(req.GroupID, tools.OpUserID(ctx))
|
opFlag, err := s.getGroupUserLevel(req.GroupID, utils.OpUserID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1185,14 +1184,14 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.GroupMemberCancelMutedNotification(tools.OperationID(ctx), tools.OpUserID(ctx), req.GroupID, req.UserID)
|
chat.GroupMemberCancelMutedNotification(utils.OperationID(ctx), utils.OpUserID(ctx), req.GroupID, req.UserID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) (*pbGroup.MuteGroupResp, error) {
|
func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) (*pbGroup.MuteGroupResp, error) {
|
||||||
resp := &pbGroup.MuteGroupResp{}
|
resp := &pbGroup.MuteGroupResp{}
|
||||||
|
|
||||||
opFlag, err := s.getGroupUserLevel(req.GroupID, tools.OpUserID(ctx))
|
opFlag, err := s.getGroupUserLevel(req.GroupID, utils.OpUserID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1225,14 +1224,14 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
chat.GroupMutedNotification(tools.OperationID(ctx), tools.OpUserID(ctx), req.GroupID)
|
chat.GroupMutedNotification(utils.OperationID(ctx), utils.OpUserID(ctx), req.GroupID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMuteGroupReq) (*pbGroup.CancelMuteGroupResp, error) {
|
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMuteGroupReq) (*pbGroup.CancelMuteGroupResp, error) {
|
||||||
resp := &pbGroup.CancelMuteGroupResp{}
|
resp := &pbGroup.CancelMuteGroupResp{}
|
||||||
|
|
||||||
opFlag, err := s.getGroupUserLevel(req.GroupID, tools.OpUserID(ctx))
|
opFlag, err := s.getGroupUserLevel(req.GroupID, utils.OpUserID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1252,7 +1251,7 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
|
|||||||
// errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.OpUserID + err.Error()
|
// errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.OpUserID + err.Error()
|
||||||
// return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
// return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
//}
|
//}
|
||||||
log.Debug(tools.OperationID(ctx), "UpdateGroupInfoDefaultZero ", req.GroupID, map[string]interface{}{"status": constant.GroupOk})
|
log.Debug(utils.OperationID(ctx), "UpdateGroupInfoDefaultZero ", req.GroupID, map[string]interface{}{"status": constant.GroupOk})
|
||||||
if err := rocksCache.DelGroupInfoFromCache(ctx, req.GroupID); err != nil {
|
if err := rocksCache.DelGroupInfoFromCache(ctx, req.GroupID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1260,14 +1259,14 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.GroupCancelMutedNotification(tools.OperationID(ctx), tools.OpUserID(ctx), req.GroupID)
|
chat.GroupCancelMutedNotification(utils.OperationID(ctx), utils.OpUserID(ctx), req.GroupID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.SetGroupMemberNicknameReq) (*pbGroup.SetGroupMemberNicknameResp, error) {
|
func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.SetGroupMemberNicknameReq) (*pbGroup.SetGroupMemberNicknameResp, error) {
|
||||||
resp := &pbGroup.SetGroupMemberNicknameResp{}
|
resp := &pbGroup.SetGroupMemberNicknameResp{}
|
||||||
|
|
||||||
if tools.OpUserID(ctx) != req.UserID && !token_verify.IsManagerUserID(tools.OpUserID(ctx)) {
|
if utils.OpUserID(ctx) != req.UserID && !token_verify.IsManagerUserID(utils.OpUserID(ctx)) {
|
||||||
return nil, utils.Wrap(constant.ErrIdentity, "")
|
return nil, utils.Wrap(constant.ErrIdentity, "")
|
||||||
}
|
}
|
||||||
cbReq := &pbGroup.SetGroupMemberInfoReq{
|
cbReq := &pbGroup.SetGroupMemberInfoReq{
|
||||||
@ -1299,7 +1298,7 @@ func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.S
|
|||||||
if err := relation.UpdateGroupMemberInfo(groupMemberInfo); err != nil {
|
if err := relation.UpdateGroupMemberInfo(groupMemberInfo); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.GroupMemberInfoSetNotification(tools.OperationID(ctx), tools.OpUserID(ctx), req.GroupID, req.UserID)
|
chat.GroupMemberInfoSetNotification(utils.OperationID(ctx), utils.OpUserID(ctx), req.GroupID, req.UserID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1338,13 +1337,13 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
|||||||
switch req.RoleLevel.Value {
|
switch req.RoleLevel.Value {
|
||||||
case constant.GroupOrdinaryUsers:
|
case constant.GroupOrdinaryUsers:
|
||||||
//msg.GroupMemberRoleLevelChangeNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, constant.GroupMemberSetToOrdinaryUserNotification)
|
//msg.GroupMemberRoleLevelChangeNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, constant.GroupMemberSetToOrdinaryUserNotification)
|
||||||
chat.GroupMemberInfoSetNotification(tools.OperationID(ctx), tools.OpUserID(ctx), req.GroupID, req.UserID)
|
chat.GroupMemberInfoSetNotification(utils.OperationID(ctx), utils.OpUserID(ctx), req.GroupID, req.UserID)
|
||||||
case constant.GroupAdmin, constant.GroupOwner:
|
case constant.GroupAdmin, constant.GroupOwner:
|
||||||
//msg.GroupMemberRoleLevelChangeNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, constant.GroupMemberSetToAdminNotification)
|
//msg.GroupMemberRoleLevelChangeNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, constant.GroupMemberSetToAdminNotification)
|
||||||
chat.GroupMemberInfoSetNotification(tools.OperationID(ctx), tools.OpUserID(ctx), req.GroupID, req.UserID)
|
chat.GroupMemberInfoSetNotification(utils.OperationID(ctx), utils.OpUserID(ctx), req.GroupID, req.UserID)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chat.GroupMemberInfoSetNotification(tools.OperationID(ctx), tools.OpUserID(ctx), req.GroupID, req.UserID)
|
chat.GroupMemberInfoSetNotification(utils.OperationID(ctx), utils.OpUserID(ctx), req.GroupID, req.UserID)
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package msg
|
package msg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/base_info"
|
"Open_IM/pkg/api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID string, sessionType int32,
|
func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID string, sessionType int32,
|
||||||
req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
||||||
var m base_info.ReactionMessageModifierNotification
|
var m api_struct.ReactionMessageModifierNotification
|
||||||
m.SourceID = req.SourceID
|
m.SourceID = req.SourceID
|
||||||
m.OpUserID = req.OpUserID
|
m.OpUserID = req.OpUserID
|
||||||
m.SessionType = req.SessionType
|
m.SessionType = req.SessionType
|
||||||
@ -37,7 +37,7 @@ func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID strin
|
|||||||
}
|
}
|
||||||
func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string, sessionType int32,
|
func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string, sessionType int32,
|
||||||
req *msg.DeleteMessageListReactionExtensionsReq, resp *msg.DeleteMessageListReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
req *msg.DeleteMessageListReactionExtensionsReq, resp *msg.DeleteMessageListReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
||||||
var m base_info.ReactionMessageDeleteNotification
|
var m api_struct.ReactionMessageDeleteNotification
|
||||||
m.SourceID = req.SourceID
|
m.SourceID = req.SourceID
|
||||||
m.OpUserID = req.OpUserID
|
m.OpUserID = req.OpUserID
|
||||||
m.SessionType = req.SessionType
|
m.SessionType = req.SessionType
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/common/tools"
|
|
||||||
utils2 "Open_IM/pkg/common/utils"
|
utils2 "Open_IM/pkg/common/utils"
|
||||||
pbGroup "Open_IM/pkg/proto/group"
|
pbGroup "Open_IM/pkg/proto/group"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
@ -389,23 +388,23 @@ func JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGrou
|
|||||||
JoinGroupApplicationTips := open_im_sdk.JoinGroupApplicationTips{Group: &open_im_sdk.GroupInfo{}, Applicant: &open_im_sdk.PublicUserInfo{}}
|
JoinGroupApplicationTips := open_im_sdk.JoinGroupApplicationTips{Group: &open_im_sdk.GroupInfo{}, Applicant: &open_im_sdk.PublicUserInfo{}}
|
||||||
err := setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group)
|
err := setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(tools.OperationID(ctx), "setGroupInfo failed ", err.Error(), req.GroupID)
|
log.Error(utils.OperationID(ctx), "setGroupInfo failed ", err.Error(), req.GroupID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = setPublicUserInfo(tools.OpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil {
|
if err = setPublicUserInfo(utils.OpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil {
|
||||||
log.Error(tools.OperationID(ctx), "setPublicUserInfo failed ", err.Error(), tools.OpUserID(ctx))
|
log.Error(utils.OperationID(ctx), "setPublicUserInfo failed ", err.Error(), utils.OpUserID(ctx))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
JoinGroupApplicationTips.ReqMsg = req.ReqMessage
|
JoinGroupApplicationTips.ReqMsg = req.ReqMessage
|
||||||
|
|
||||||
managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID)
|
managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(tools.OperationID(ctx), "GetOwnerManagerByGroupId failed ", err.Error(), req.GroupID)
|
log.NewError(utils.OperationID(ctx), "GetOwnerManagerByGroupId failed ", err.Error(), req.GroupID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range managerList {
|
for _, v := range managerList {
|
||||||
groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, tools.OpUserID(ctx), "", v.UserID, tools.OperationID(ctx))
|
groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, utils.OpUserID(ctx), "", v.UserID, utils.OperationID(ctx))
|
||||||
log.NewInfo(tools.OperationID(ctx), "Notification ", v)
|
log.NewInfo(utils.OperationID(ctx), "Notification ", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package msg
|
package msg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
utils2 "Open_IM/internal/utils"
|
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
@ -177,7 +176,7 @@ func (rpc *rpcChat) messageVerification(ctx context.Context, data *pbChat.SendMs
|
|||||||
return true, 0, "", nil
|
return true, 0, "", nil
|
||||||
}
|
}
|
||||||
case constant.GroupChatType:
|
case constant.GroupChatType:
|
||||||
userIDList, err := utils2.GetGroupMemberUserIDList(ctx, data.MsgData.GroupID, data.OperationID)
|
userIDList, err := utils.GetGroupMemberUserIDList(ctx, data.MsgData.GroupID, data.OperationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := data.OperationID + err.Error()
|
errMsg := data.OperationID + err.Error()
|
||||||
log.NewError(data.OperationID, errMsg)
|
log.NewError(data.OperationID, errMsg)
|
||||||
@ -251,7 +250,7 @@ func (rpc *rpcChat) messageVerification(ctx context.Context, data *pbChat.SendMs
|
|||||||
if groupInfo.GroupType == constant.SuperGroup {
|
if groupInfo.GroupType == constant.SuperGroup {
|
||||||
return true, 0, "", nil
|
return true, 0, "", nil
|
||||||
} else {
|
} else {
|
||||||
userIDList, err := utils2.GetGroupMemberUserIDList(ctx, data.MsgData.GroupID, data.OperationID)
|
userIDList, err := utils.GetGroupMemberUserIDList(ctx, data.MsgData.GroupID, data.OperationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := data.OperationID + err.Error()
|
errMsg := data.OperationID + err.Error()
|
||||||
log.NewError(data.OperationID, errMsg)
|
log.NewError(data.OperationID, errMsg)
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
promePkg "Open_IM/pkg/common/prometheus"
|
promePkg "Open_IM/pkg/common/prometheus"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/common/tools"
|
|
||||||
"Open_IM/pkg/getcdv3"
|
"Open_IM/pkg/getcdv3"
|
||||||
pbFriend "Open_IM/pkg/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
pbGroup "Open_IM/pkg/proto/group"
|
pbGroup "Open_IM/pkg/proto/group"
|
||||||
@ -23,7 +22,6 @@ import (
|
|||||||
|
|
||||||
grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||||
|
|
||||||
utils2 "Open_IM/internal/utils"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -173,7 +171,7 @@ func (s *userServer) GetUsersInfo(ctx context.Context, req *pbUser.GetUsersInfoR
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, v := range users {
|
for _, v := range users {
|
||||||
n, err := utils2.NewDBUser(v).Convert()
|
n, err := utils.NewDBUser(v).Convert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -196,7 +194,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
|
|||||||
}
|
}
|
||||||
oldNickname = u.Nickname
|
oldNickname = u.Nickname
|
||||||
}
|
}
|
||||||
user, err := utils2.NewPBUser(req.UserInfo).Convert()
|
user, err := utils.NewPBUser(req.UserInfo).Convert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -216,16 +214,16 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
|
|||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
for _, v := range rpcResp.FriendInfoList {
|
for _, v := range rpcResp.FriendInfoList {
|
||||||
chat.FriendInfoUpdatedNotification(tools.OperationID(ctx), req.UserInfo.UserID, v.FriendUser.UserID, tools.OpUserID(ctx))
|
chat.FriendInfoUpdatedNotification(utils.OperationID(ctx), req.UserInfo.UserID, v.FriendUser.UserID, utils.OpUserID(ctx))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
chat.UserInfoUpdatedNotification(tools.OperationID(ctx), tools.OpUserID(ctx), req.UserInfo.UserID)
|
chat.UserInfoUpdatedNotification(utils.OperationID(ctx), utils.OpUserID(ctx), req.UserInfo.UserID)
|
||||||
if req.UserInfo.FaceURL != "" {
|
if req.UserInfo.FaceURL != "" {
|
||||||
s.SyncJoinedGroupMemberFaceURL(ctx, req.UserInfo.UserID, req.UserInfo.FaceURL, tools.OperationID(ctx), tools.OpUserID(ctx))
|
s.SyncJoinedGroupMemberFaceURL(ctx, req.UserInfo.UserID, req.UserInfo.FaceURL, utils.OperationID(ctx), utils.OpUserID(ctx))
|
||||||
}
|
}
|
||||||
if req.UserInfo.Nickname != "" {
|
if req.UserInfo.Nickname != "" {
|
||||||
s.SyncJoinedGroupMemberNickname(ctx, req.UserInfo.UserID, req.UserInfo.Nickname, oldNickname, tools.OperationID(ctx), tools.OpUserID(ctx))
|
s.SyncJoinedGroupMemberNickname(ctx, req.UserInfo.UserID, req.UserInfo.Nickname, oldNickname, utils.OperationID(ctx), utils.OpUserID(ctx))
|
||||||
}
|
}
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
@ -238,13 +236,13 @@ func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbUser.Se
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.UserInfoUpdatedNotification(tools.OperationID(ctx), req.UserID, req.UserID)
|
chat.UserInfoUpdatedNotification(utils.OperationID(ctx), req.UserID, req.UserID)
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) AccountCheck(ctx context.Context, req *pbUser.AccountCheckReq) (*pbUser.AccountCheckResp, error) {
|
func (s *userServer) AccountCheck(ctx context.Context, req *pbUser.AccountCheckReq) (*pbUser.AccountCheckResp, error) {
|
||||||
resp := pbUser.AccountCheckResp{}
|
resp := pbUser.AccountCheckResp{}
|
||||||
err := token_verify.CheckManagerUserID(ctx, tools.OpUserID(ctx))
|
err := token_verify.CheckManagerUserID(ctx, utils.OpUserID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -279,7 +277,7 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Total = 1
|
resp.Total = 1
|
||||||
u1, err := utils2.NewDBUser(u).Convert()
|
u1, err := utils.NewDBUser(u).Convert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -294,7 +292,7 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
|||||||
}
|
}
|
||||||
resp.Total = int32(total)
|
resp.Total = int32(total)
|
||||||
for _, v := range usersDB {
|
for _, v := range usersDB {
|
||||||
u1, err := utils2.NewDBUser(v).Convert()
|
u1, err := utils.NewDBUser(v).Convert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -308,7 +306,7 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
|||||||
}
|
}
|
||||||
resp.Total = int32(total)
|
resp.Total = int32(total)
|
||||||
for _, v := range usersDB {
|
for _, v := range usersDB {
|
||||||
u1, err := utils2.NewDBUser(v).Convert()
|
u1, err := utils.NewDBUser(v).Convert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -325,7 +323,7 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
|||||||
resp.Total = int32(total)
|
resp.Total = int32(total)
|
||||||
|
|
||||||
for _, userDB := range usersDB {
|
for _, userDB := range usersDB {
|
||||||
u, err := utils2.NewDBUser(userDB).Convert()
|
u, err := utils.NewDBUser(userDB).Convert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
gin.SetMode(gin.TestMode)
|
|
||||||
}
|
|
||||||
|
|
||||||
func performRequest(r http.Handler, method, origin string) *httptest.ResponseRecorder {
|
|
||||||
return performRequestWithHeaders(r, method, origin, http.Header{})
|
|
||||||
}
|
|
||||||
|
|
||||||
func performRequestWithHeaders(r http.Handler, method, origin string, header http.Header) *httptest.ResponseRecorder {
|
|
||||||
req, _ := http.NewRequest(method, "/", nil)
|
|
||||||
// From go/net/http/request.go:
|
|
||||||
// For incoming requests, the Host header is promoted to the
|
|
||||||
// Request.Host field and removed from the Header map.
|
|
||||||
req.Host = header.Get("Host")
|
|
||||||
header.Del("Host")
|
|
||||||
if len(origin) > 0 {
|
|
||||||
header.Set("Origin", origin)
|
|
||||||
}
|
|
||||||
req.Header = header
|
|
||||||
w := httptest.NewRecorder()
|
|
||||||
r.ServeHTTP(w, req)
|
|
||||||
return w
|
|
||||||
}
|
|
||||||
|
|
||||||
func newTestRouter() *gin.Engine {
|
|
||||||
router := gin.New()
|
|
||||||
router.Use(utils.CorsHandler())
|
|
||||||
router.GET("/", func(c *gin.Context) {
|
|
||||||
c.String(http.StatusOK, "get")
|
|
||||||
})
|
|
||||||
router.POST("/", func(c *gin.Context) {
|
|
||||||
c.String(http.StatusOK, "post")
|
|
||||||
})
|
|
||||||
router.PATCH("/", func(c *gin.Context) {
|
|
||||||
c.String(http.StatusOK, "patch")
|
|
||||||
})
|
|
||||||
|
|
||||||
return router
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_CorsHandler(t *testing.T) {
|
|
||||||
router := newTestRouter()
|
|
||||||
// no CORS request, origin == ""
|
|
||||||
w := performRequest(router, "GET", "")
|
|
||||||
assert.Equal(t, "get", w.Body.String())
|
|
||||||
assert.Equal(t, w.Header().Get("Access-Control-Allow-Origin"), "*")
|
|
||||||
assert.Equal(t, w.Header().Get("Access-Control-Allow-Methods"), "*")
|
|
||||||
assert.Equal(t, w.Header().Get("Access-Control-Allow-Headers"), "*")
|
|
||||||
assert.Equal(t, w.Header().Get("Access-Control-Expose-Headers"), "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar")
|
|
||||||
assert.Equal(t, w.Header().Get("Access-Control-Max-Age"), "172800")
|
|
||||||
assert.Equal(t, w.Header().Get("Access-Control-Allow-Credentials"), "false")
|
|
||||||
assert.Equal(t, w.Header().Get("content-type"), "application/json")
|
|
||||||
|
|
||||||
w = performRequest(router, "OPTIONS", "")
|
|
||||||
assert.Equal(t, w.Body.String(), "\"Options Request!\"")
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
package utils
|
|
@ -1,49 +0,0 @@
|
|||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"github.com/golang/protobuf/jsonpb"
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
func JsonDataList(resp interface{}) []map[string]interface{} {
|
|
||||||
var list []proto.Message
|
|
||||||
if reflect.TypeOf(resp).Kind() == reflect.Slice {
|
|
||||||
s := reflect.ValueOf(resp)
|
|
||||||
for i := 0; i < s.Len(); i++ {
|
|
||||||
ele := s.Index(i)
|
|
||||||
list = append(list, ele.Interface().(proto.Message))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result := make([]map[string]interface{}, 0)
|
|
||||||
for _, v := range list {
|
|
||||||
m := ProtoToMap(v, false)
|
|
||||||
result = append(result, m)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func JsonDataOne(pb proto.Message) map[string]interface{} {
|
|
||||||
return ProtoToMap(pb, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ProtoToMap(pb proto.Message, idFix bool) map[string]interface{} {
|
|
||||||
marshaler := jsonpb.Marshaler{
|
|
||||||
OrigName: true,
|
|
||||||
EnumsAsInts: false,
|
|
||||||
EmitDefaults: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
s, _ := marshaler.MarshalToString(pb)
|
|
||||||
out := make(map[string]interface{})
|
|
||||||
json.Unmarshal([]byte(s), &out)
|
|
||||||
if idFix {
|
|
||||||
if _, ok := out["id"]; ok {
|
|
||||||
out["_id"] = out["id"]
|
|
||||||
delete(out, "id")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
//UserID string `protobuf:"bytes,1,opt,name=UserID" json:"UserID,omitempty"`
|
//UserID string `protobuf:"bytes,1,opt,name=UserID" json:"UserID,omitempty"`
|
||||||
// Nickname string `protobuf:"bytes,2,opt,name=Nickname" json:"Nickname,omitempty"`
|
// Nickname string `protobuf:"bytes,2,opt,name=Nickname" json:"Nickname,omitempty"`
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
type AwsStorageCredentialReq struct {
|
type AwsStorageCredentialReq struct {
|
||||||
OperationID string `json:"operationID"`
|
OperationID string `json:"operationID"`
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
type SetClientInitConfigReq struct {
|
type SetClientInitConfigReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
type RequestPagination struct {
|
type RequestPagination struct {
|
||||||
PageNumber int `json:"pageNumber" binding:"required"`
|
PageNumber int `json:"pageNumber" binding:"required"`
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
type OptResult struct {
|
type OptResult struct {
|
||||||
ConversationID string `json:"conversationID"`
|
ConversationID string `json:"conversationID"`
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
import sts "github.com/tencentyun/qcloud-cos-sts-sdk/go"
|
import sts "github.com/tencentyun/qcloud-cos-sts-sdk/go"
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
//type ParamsCommFriend struct {
|
//type ParamsCommFriend struct {
|
||||||
// OperationID string `json:"operationID" binding:"required"`
|
// OperationID string `json:"operationID" binding:"required"`
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
pbRelay "Open_IM/pkg/proto/relay"
|
pbRelay "Open_IM/pkg/proto/relay"
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/proto/msg"
|
"Open_IM/pkg/proto/msg"
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
pbOffice "Open_IM/pkg/proto/office"
|
pbOffice "Open_IM/pkg/proto/office"
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
import open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
import open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
type OSSCredentialReq struct {
|
type OSSCredentialReq struct {
|
||||||
OperationID string `json:"operationID"`
|
OperationID string `json:"operationID"`
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
type Pagination struct {
|
type Pagination struct {
|
||||||
PageNumber int32 `json:"pageNumber" binding:"required"`
|
PageNumber int32 `json:"pageNumber" binding:"required"`
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
type GetJoinedSuperGroupListReq struct {
|
type GetJoinedSuperGroupListReq struct {
|
||||||
GetJoinedGroupListReq
|
GetJoinedGroupListReq
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
type Swagger400Resp struct {
|
type Swagger400Resp struct {
|
||||||
ErrCode int32 `json:"errCode" example:"400"`
|
ErrCode int32 `json:"errCode" example:"400"`
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
import "mime/multipart"
|
import "mime/multipart"
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
@ -1,4 +1,4 @@
|
|||||||
package base_info
|
package api_struct
|
||||||
|
|
||||||
import "Open_IM/pkg/proto/office"
|
import "Open_IM/pkg/proto/office"
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package cms_api_struct
|
package cms_struct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/base_info"
|
"Open_IM/pkg/api_struct"
|
||||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,10 +47,10 @@ type ReduceUserRegisterAddFriendIDListResponse struct {
|
|||||||
|
|
||||||
type GetUserRegisterAddFriendIDListRequest struct {
|
type GetUserRegisterAddFriendIDListRequest struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
base_info.RequestPagination
|
api_struct.RequestPagination
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUserRegisterAddFriendIDListResponse struct {
|
type GetUserRegisterAddFriendIDListResponse struct {
|
||||||
Users []*server_api_params.UserInfo `json:"users"`
|
Users []*server_api_params.UserInfo `json:"users"`
|
||||||
base_info.ResponsePagination
|
api_struct.ResponsePagination
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package cms_api_struct
|
package cms_struct
|
||||||
|
|
||||||
type RequestPagination struct {
|
type RequestPagination struct {
|
||||||
PageNumber int `json:"pageNumber" binding:"required"`
|
PageNumber int `json:"pageNumber" binding:"required"`
|
@ -1,4 +1,4 @@
|
|||||||
package cms_api_struct
|
package cms_struct
|
||||||
|
|
||||||
type GetFriendsReq struct {
|
type GetFriendsReq struct {
|
||||||
OperationID string `json:"operationID"`
|
OperationID string `json:"operationID"`
|
@ -1,4 +1,4 @@
|
|||||||
package cms_api_struct
|
package cms_struct
|
||||||
|
|
||||||
type GroupResponse struct {
|
type GroupResponse struct {
|
||||||
GroupOwnerName string `json:"GroupOwnerName"`
|
GroupOwnerName string `json:"GroupOwnerName"`
|
@ -1,4 +1,4 @@
|
|||||||
package cms_api_struct
|
package cms_struct
|
||||||
|
|
||||||
import (
|
import (
|
||||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
@ -1,4 +1,4 @@
|
|||||||
package cms_api_struct
|
package cms_struct
|
||||||
|
|
||||||
type GetStatisticsRequest struct {
|
type GetStatisticsRequest struct {
|
||||||
From string `json:"from" binding:"required"`
|
From string `json:"from" binding:"required"`
|
@ -1,4 +1,4 @@
|
|||||||
package cms_api_struct
|
package cms_struct
|
||||||
|
|
||||||
type UserResponse struct {
|
type UserResponse struct {
|
||||||
FaceURL string `json:"faceURL"`
|
FaceURL string `json:"faceURL"`
|
@ -158,13 +158,15 @@ func (g *GroupDataBase) FindGroupsByID(ctx context.Context, groupIDs []string) (
|
|||||||
return g.cache.GetGroupsInfo(ctx, groupIDs)
|
return g.cache.GetGroupsInfo(ctx, groupIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation.Group, groupMember []*relation.GroupMember) error {
|
func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation.Group, groupMembers []*relation.GroupMember) error {
|
||||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||||
|
if len(groups) > 0 {
|
||||||
if err := g.groupDB.Create(ctx, groups, tx); err != nil {
|
if err := g.groupDB.Create(ctx, groups, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(groupMember) > 0 {
|
}
|
||||||
if err := g.groupMemberDB.Create(ctx, groupMember, tx); err != nil {
|
if len(groupMembers) > 0 {
|
||||||
|
if err := g.groupMemberDB.Create(ctx, groupMembers, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,11 @@ type Friend struct {
|
|||||||
DB *gorm.DB `gorm:"-"`
|
DB *gorm.DB `gorm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FriendUser struct {
|
||||||
|
Friend
|
||||||
|
Nickname string `gorm:"column:name;size:255"`
|
||||||
|
}
|
||||||
|
|
||||||
func NewFriendDB(db *gorm.DB) *Friend {
|
func NewFriendDB(db *gorm.DB) *Friend {
|
||||||
var friend Friend
|
var friend Friend
|
||||||
friend.DB = initModel(db, friend)
|
friend.DB = initModel(db, friend)
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -8,6 +12,44 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func JWTAuth() gin.HandlerFunc {
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
|
||||||
|
// log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID)
|
||||||
|
c.Set("userID", userID)
|
||||||
|
if !ok {
|
||||||
|
log.NewError("", "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
c.Abort()
|
||||||
|
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errInfo})
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
if !utils.IsContain(userID, config.Config.Manager.AppManagerUid) {
|
||||||
|
c.Abort()
|
||||||
|
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": "user is not admin"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CorsHandler() gin.HandlerFunc {
|
||||||
|
return func(context *gin.Context) {
|
||||||
|
context.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
|
context.Header("Access-Control-Allow-Methods", "*")
|
||||||
|
context.Header("Access-Control-Allow-Headers", "*")
|
||||||
|
context.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar") // 跨域关键设置 让浏览器可以解析
|
||||||
|
context.Header("Access-Control-Max-Age", "172800") // 缓存请求信息 单位为秒
|
||||||
|
context.Header("Access-Control-Allow-Credentials", "false") // 跨域请求是否需要带cookie信息 默认设置为true
|
||||||
|
context.Header("content-type", "application/json") // 设置返回格式是json
|
||||||
|
//Release all option pre-requests
|
||||||
|
if context.Request.Method == http.MethodOptions {
|
||||||
|
context.JSON(http.StatusOK, "Options Request!")
|
||||||
|
}
|
||||||
|
context.Next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func GinParseOperationID(c *gin.Context) {
|
func GinParseOperationID(c *gin.Context) {
|
||||||
if c.Request.Method == http.MethodPost {
|
if c.Request.Method == http.MethodPost {
|
||||||
operationID := c.Request.Header.Get("operationID")
|
operationID := c.Request.Header.Get("operationID")
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
commonDB "Open_IM/pkg/common/db"
|
commonDB "Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/tools"
|
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
@ -160,7 +159,7 @@ func CheckAccess(ctx context.Context, OpUserID string, OwnerUserID string) bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) {
|
func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) {
|
||||||
opUserID := tools.OpUserID(ctx)
|
opUserID := utils.OpUserID(ctx)
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "OpUserID", opUserID, "ownerUserID", ownerUserID)
|
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "OpUserID", opUserID, "ownerUserID", ownerUserID)
|
||||||
}()
|
}()
|
||||||
@ -174,11 +173,11 @@ func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsAppManagerUid(ctx context.Context) bool {
|
func IsAppManagerUid(ctx context.Context) bool {
|
||||||
return utils.IsContain(tools.OpUserID(ctx), config.Config.Manager.AppManagerUid)
|
return utils.IsContain(utils.OpUserID(ctx), config.Config.Manager.AppManagerUid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckAdmin(ctx context.Context) error {
|
func CheckAdmin(ctx context.Context) error {
|
||||||
if utils.IsContain(tools.OpUserID(ctx), config.Config.Manager.AppManagerUid) {
|
if utils.IsContain(utils.OpUserID(ctx), config.Config.Manager.AppManagerUid) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return constant.ErrIdentity.Wrap()
|
return constant.ErrIdentity.Wrap()
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package tools
|
|
||||||
|
|
||||||
import "context"
|
|
||||||
|
|
||||||
func OperationID(ctx context.Context) string {
|
|
||||||
s, _ := ctx.Value("operationID").(string)
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
func OpUserID(ctx context.Context) string {
|
|
||||||
s, _ := ctx.Value("opUserID").(string)
|
|
||||||
return s
|
|
||||||
}
|
|
@ -1,28 +1,20 @@
|
|||||||
package tracelog
|
package tracelog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
//"errors"
|
//"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const TraceLogKey = "tracelog"
|
const TraceLogKey = "tracelog"
|
||||||
|
|
||||||
func NewCtx(c *gin.Context, api string) context.Context {
|
func NewCtx(c *gin.Context, api string) context.Context {
|
||||||
req := &ApiInfo{ApiName: api, GinCtx: c, Funcs: &[]FuncInfo{}}
|
|
||||||
return context.WithValue(c, TraceLogKey, req)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCtx1(c *gin.Context, api string) context.Context {
|
|
||||||
req := &ApiInfo{ApiName: api, GinCtx: c, OperationID: c.GetHeader("operationID"), Funcs: &[]FuncInfo{}}
|
req := &ApiInfo{ApiName: api, GinCtx: c, OperationID: c.GetHeader("operationID"), Funcs: &[]FuncInfo{}}
|
||||||
return context.WithValue(c, TraceLogKey, req)
|
return context.WithValue(c, TraceLogKey, req)
|
||||||
}
|
}
|
||||||
@ -42,77 +34,11 @@ func GetOperationID(ctx context.Context) string {
|
|||||||
return ctx.Value(TraceLogKey).(*ApiInfo).OperationID
|
return ctx.Value(TraceLogKey).(*ApiInfo).OperationID
|
||||||
}
|
}
|
||||||
|
|
||||||
//func ShowLog(ctx context.Context) {
|
func GetOpUserID(ctx context.Context) string {
|
||||||
// t := ctx.Value(TraceLogKey).(*ApiInfo)
|
s, _ := ctx.Value("opUserID").(string)
|
||||||
// if ctx.Value(TraceLogKey).(*ApiInfo).GinCtx != nil {
|
return s
|
||||||
// log.Info(t.OperationID, "api: ", t.ApiName)
|
|
||||||
// } else {
|
|
||||||
// log.Info(t.OperationID, "rpc: ", t.ApiName)
|
|
||||||
// }
|
|
||||||
// for _, v := range *t.Funcs {
|
|
||||||
// if v.Err != nil {
|
|
||||||
// log.Error(t.OperationID, "func: ", v.FuncName, " args: ", v.Args, v.Err.Error())
|
|
||||||
// } else {
|
|
||||||
// switch v.LogLevel {
|
|
||||||
// case logrus.InfoLevel:
|
|
||||||
// log.Info(t.OperationID, "func: ", v.FuncName, " args: ", v.Args)
|
|
||||||
// case logrus.DebugLevel:
|
|
||||||
// log.Debug(t.OperationID, "func: ", v.FuncName, " args: ", v.Args)
|
|
||||||
// case logrus.WarnLevel:
|
|
||||||
// log.Debug(t.OperationID, "func: ", v.FuncName, " args: ", v.Args)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
func WriteErrorResponse(ctx context.Context, funcName string, err error, args ...interface{}) {
|
|
||||||
SetCtxInfo(ctx, funcName, err, args)
|
|
||||||
e := Unwrap(err)
|
|
||||||
switch t := e.(type) {
|
|
||||||
case *constant.ErrInfo:
|
|
||||||
ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, baseResp{ErrCode: t.ErrCode, ErrMsg: t.ErrMsg, ErrDtl: t.DetailErrMsg})
|
|
||||||
//ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": t.ErrCode, "errMsg": t.ErrMsg, "errDtl": t.DetailErrMsg})
|
|
||||||
return
|
|
||||||
default:
|
|
||||||
s, ok := status.FromError(e)
|
|
||||||
if !ok {
|
|
||||||
ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, &baseResp{ErrCode: constant.ErrDefaultOther.ErrCode, ErrMsg: err.Error(), ErrDtl: fmt.Sprintf("%+v", err)})
|
|
||||||
//ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": constant.ErrDefaultOther.ErrCode, "errMsg": err.Error(), "errDtl": fmt.Sprintf("%+v", err)})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var details []string
|
|
||||||
if err != e {
|
|
||||||
details = append(details, fmt.Sprintf("%+v", err))
|
|
||||||
}
|
|
||||||
for _, s := range s.Details() {
|
|
||||||
details = append(details, fmt.Sprintf("%+v", s))
|
|
||||||
}
|
|
||||||
ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, &baseResp{ErrCode: int32(s.Code()), ErrMsg: s.Message(), ErrDtl: strings.Join(details, "\n")})
|
|
||||||
//ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": s.Code(), "errMsg": s.Message(), "errDtl": strings.Join(details, "\n")})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type baseResp struct {
|
|
||||||
ErrCode int32 `json:"errCode"`
|
|
||||||
ErrMsg string `json:"errMsg"`
|
|
||||||
ErrDtl string `json:"errDtl"`
|
|
||||||
Data interface{} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
//func WriteErrorResponse(ctx context.Context, funcName string, err error, args ...interface{}) {
|
|
||||||
// SetCtxInfo(ctx, funcName, err, args)
|
|
||||||
// e := new(constant.ErrInfo)
|
|
||||||
// switch {
|
|
||||||
// case errors.As(err, &e):
|
|
||||||
// ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": e.ErrCode, "errMsg": e.ErrMsg})
|
|
||||||
// return
|
|
||||||
// default:
|
|
||||||
// ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": constant.ErrDefaultOther.ErrCode, "errMsg": constant.ErrDefaultOther.ErrMsg, "errDtl": err.Error()})
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
func Unwrap(err error) error {
|
func Unwrap(err error) error {
|
||||||
for err != nil {
|
for err != nil {
|
||||||
unwrap, ok := err.(interface {
|
unwrap, ok := err.(interface {
|
||||||
@ -211,11 +137,6 @@ func SetRpcRespInfo(ctx context.Context, funcName string, resp string) {
|
|||||||
*t.Funcs = append(*t.Funcs, funcInfo)
|
*t.Funcs = append(*t.Funcs, funcInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetSuccess(ctx context.Context, funcName string, data interface{}) {
|
|
||||||
SetCtxInfo(ctx, funcName, nil, "data", data)
|
|
||||||
ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "errDtl": "", "data": data})
|
|
||||||
}
|
|
||||||
|
|
||||||
func argsHandle(args []interface{}, fields map[string]interface{}) {
|
func argsHandle(args []interface{}, fields map[string]interface{}) {
|
||||||
for i := 0; i < len(args); i += 2 {
|
for i := 0; i < len(args); i += 2 {
|
||||||
if i+1 < len(args) {
|
if i+1 < len(args) {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package utils
|
package getcdv3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/OpenIMSDK/getcdv3"
|
"github.com/OpenIMSDK/getcdv3"
|
||||||
@ -32,8 +33,8 @@ func RegisterConf() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
secretMD5 := Md5(config.Config.Etcd.Secret)
|
secretMD5 := utils.Md5(config.Config.Etcd.Secret)
|
||||||
confBytes, err := AesEncrypt(bytes, []byte(secretMD5[0:16]))
|
confBytes, err := utils.AesEncrypt(bytes, []byte(secretMD5[0:16]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package callback
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
@ -10,11 +10,6 @@ func GetContent(msg *server_api_params.MsgData) string {
|
|||||||
if msg.ContentType >= constant.NotificationBegin && msg.ContentType <= constant.NotificationEnd {
|
if msg.ContentType >= constant.NotificationBegin && msg.ContentType <= constant.NotificationEnd {
|
||||||
var tips server_api_params.TipsComm
|
var tips server_api_params.TipsComm
|
||||||
_ = proto.Unmarshal(msg.Content, &tips)
|
_ = proto.Unmarshal(msg.Content, &tips)
|
||||||
//marshaler := jsonpb.Marshaler{
|
|
||||||
// OrigName: true,
|
|
||||||
// EnumsAsInts: false,
|
|
||||||
// EmitDefaults: false,
|
|
||||||
//}
|
|
||||||
content := tips.JsonDetail
|
content := tips.JsonDetail
|
||||||
return content
|
return content
|
||||||
} else {
|
} else {
|
@ -3,7 +3,6 @@ package utils
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
sdk "Open_IM/pkg/proto/sdk_ws"
|
sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
utils2 "Open_IM/pkg/utils"
|
|
||||||
utils "github.com/OpenIMSDK/open_utils"
|
utils "github.com/OpenIMSDK/open_utils"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
@ -1,24 +0,0 @@
|
|||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CorsHandler() gin.HandlerFunc {
|
|
||||||
return func(context *gin.Context) {
|
|
||||||
context.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
|
||||||
context.Header("Access-Control-Allow-Methods", "*")
|
|
||||||
context.Header("Access-Control-Allow-Headers", "*")
|
|
||||||
context.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar") // 跨域关键设置 让浏览器可以解析
|
|
||||||
context.Header("Access-Control-Max-Age", "172800") // 缓存请求信息 单位为秒
|
|
||||||
context.Header("Access-Control-Allow-Credentials", "false") // 跨域请求是否需要带cookie信息 默认设置为true
|
|
||||||
context.Header("content-type", "application/json") // 设置返回格式是json
|
|
||||||
//Release all option pre-requests
|
|
||||||
if context.Request.Method == http.MethodOptions {
|
|
||||||
context.JSON(http.StatusOK, "Options Request!")
|
|
||||||
}
|
|
||||||
context.Next()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
@ -17,12 +16,12 @@ var (
|
|||||||
|
|
||||||
func Test_GenSmallImage(t *testing.T) {
|
func Test_GenSmallImage(t *testing.T) {
|
||||||
println(Root)
|
println(Root)
|
||||||
err := utils.GenSmallImage(Root+"/docs/open-im-logo.png", Root+"/out-test/open-im-logo-test.png")
|
err := GenSmallImage(Root+"/docs/open-im-logo.png", Root+"/out-test/open-im-logo-test.png")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
err = utils.GenSmallImage(Root+"/docs/open-im-logo.png", "out-test/open-im-logo-test.png")
|
err = GenSmallImage(Root+"/docs/open-im-logo.png", "out-test/open-im-logo-test.png")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
err = utils.GenSmallImage(Root+"/docs/Architecture.jpg", "out-test/Architecture-test.jpg")
|
err = GenSmallImage(Root+"/docs/Architecture.jpg", "out-test/Architecture-test.jpg")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
}
|
}
|
@ -6,7 +6,6 @@ import (
|
|||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/getcdv3"
|
"Open_IM/pkg/getcdv3"
|
||||||
pbCache "Open_IM/pkg/proto/cache"
|
pbCache "Open_IM/pkg/proto/cache"
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
@ -27,7 +26,7 @@ func GetGroupMemberUserIDList(ctx context.Context, groupID string, operationID s
|
|||||||
defer CacheGroupMtx.Unlock()
|
defer CacheGroupMtx.Unlock()
|
||||||
delete(CacheGroupMemberUserIDList, groupID)
|
delete(CacheGroupMemberUserIDList, groupID)
|
||||||
log.Error(operationID, "GetGroupMemberUserIDListHashFromRemote failed ", err.Error(), groupID)
|
log.Error(operationID, "GetGroupMemberUserIDListHashFromRemote failed ", err.Error(), groupID)
|
||||||
return nil, utils.Wrap(err, groupID)
|
return nil, Wrap(err, groupID)
|
||||||
}
|
}
|
||||||
|
|
||||||
CacheGroupMtx.Lock()
|
CacheGroupMtx.Lock()
|
||||||
@ -48,7 +47,7 @@ func GetGroupMemberUserIDList(ctx context.Context, groupID string, operationID s
|
|||||||
memberUserIDListRemote, err := GetGroupMemberUserIDListFromRemote(groupID, operationID)
|
memberUserIDListRemote, err := GetGroupMemberUserIDListFromRemote(groupID, operationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, "GetGroupMemberUserIDListFromRemote failed ", err.Error(), groupID)
|
log.Error(operationID, "GetGroupMemberUserIDListFromRemote failed ", err.Error(), groupID)
|
||||||
return nil, utils.Wrap(err, groupID)
|
return nil, Wrap(err, groupID)
|
||||||
}
|
}
|
||||||
CacheGroupMemberUserIDList[groupID] = &GroupMemberUserIDListHash{MemberListHash: groupHashRemote, UserIDList: memberUserIDListRemote}
|
CacheGroupMemberUserIDList[groupID] = &GroupMemberUserIDListHash{MemberListHash: groupHashRemote, UserIDList: memberUserIDListRemote}
|
||||||
return memberUserIDListRemote, nil
|
return memberUserIDListRemote, nil
|
||||||
@ -68,7 +67,7 @@ func GetGroupMemberUserIDListFromRemote(groupID string, operationID string) ([]s
|
|||||||
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(operationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
|
log.NewError(operationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
|
||||||
return nil, utils.Wrap(err, "GetGroupMemberIDListFromCache rpc call failed")
|
return nil, Wrap(err, "GetGroupMemberIDListFromCache rpc call failed")
|
||||||
}
|
}
|
||||||
if cacheResp.CommonResp.ErrCode != 0 {
|
if cacheResp.CommonResp.ErrCode != 0 {
|
||||||
errMsg := operationID + "GetGroupMemberIDListFromCache rpc logic call failed " + cacheResp.CommonResp.ErrMsg
|
errMsg := operationID + "GetGroupMemberIDListFromCache rpc logic call failed " + cacheResp.CommonResp.ErrMsg
|
@ -1,16 +1,15 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_Md5(t *testing.T) {
|
func Test_Md5(t *testing.T) {
|
||||||
result := utils.Md5("go")
|
result := Md5("go")
|
||||||
assert.Equal(t, result, "34d1f91fb2e514b8576fab1a75a89a6b")
|
assert.Equal(t, result, "34d1f91fb2e514b8576fab1a75a89a6b")
|
||||||
|
|
||||||
result2 := utils.Md5("go")
|
result2 := Md5("go")
|
||||||
assert.Equal(t, result, result2)
|
assert.Equal(t, result, result2)
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user