Merge branch 'tuoyun'

This commit is contained in:
Gordon 2022-05-13 21:15:25 +08:00
commit faf72705cb
92 changed files with 3426 additions and 2137 deletions

View File

@ -97,6 +97,7 @@ func main() {
{
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
authRouterGroup.POST("/parse_token", apiAuth.ParseToken) //1
}
//Third service
thirdGroup := r.Group("/third")
@ -105,6 +106,8 @@ func main() {
thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential)
thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential)
thirdGroup.POST("/minio_upload", apiThird.MinioUploadFile)
thirdGroup.POST("/upload_update_app", apiThird.UploadUpdateApp)
thirdGroup.POST("/get_download_url", apiThird.GetDownloadURL)
}
//Message
chatGroup := r.Group("/msg")
@ -122,6 +125,7 @@ func main() {
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
managementGroup.POST("/account_check", manage.AccountCheck) //1
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
}
//Conversation
conversationGroup := r.Group("/conversation")
@ -153,6 +157,7 @@ func main() {
officeGroup.POST("/get_user_work_moments", office.GetUserWorkMoments)
officeGroup.POST("/get_user_friend_work_moments", office.GetUserFriendWorkMoments)
officeGroup.POST("/set_user_work_moments_level", office.SetUserWorkMomentsLevel)
officeGroup.POST("/delete_comment", office.DeleteComment)
}
organizationGroup := r.Group("/organization")
@ -177,10 +182,15 @@ func main() {
}
go apiThird.MinioInit()
ginPort := flag.Int("port", 10002, "get ginServerPort from cmd,default 10000 as port")
ginPort := flag.Int("port", 10002, "get ginServerPort from cmd,default 10002 as port")
flag.Parse()
fmt.Println("start api server, port: ", *ginPort)
err := r.Run(":" + strconv.Itoa(*ginPort))
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
if config.Config.Api.ListenIP != "" {
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
}
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
fmt.Println("start api server, address: ", address)
err := r.Run(address)
if err != nil {
log.Error("", "run failed ", *ginPort, err.Error())
}

View File

@ -7,6 +7,7 @@ import (
"fmt"
"strconv"
"Open_IM/pkg/common/config"
"github.com/gin-gonic/gin"
)
@ -14,10 +15,13 @@ func main() {
gin.SetMode(gin.ReleaseMode)
router := cms_api.NewGinRouter()
router.Use(utils.CorsHandler())
ginPort := flag.Int("port", 10006, "get ginServerPort from cmd,default 8000 as port")
ginPort := flag.Int("port", 10006, "get ginServerPort from cmd,default 10006 as port")
flag.Parse()
fmt.Println("start cms api server, port: ", ginPort)
router.Run(":" + strconv.Itoa(*ginPort))
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
if config.Config.Api.ListenIP != "" {
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
}
address = config.Config.CmsApi.ListenIP + ":" + strconv.Itoa(*ginPort)
fmt.Println("start cms api server, address: ", address)
router.Run(address)
}
//

View File

@ -9,6 +9,7 @@ import (
"os"
"strconv"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"github.com/gin-gonic/gin"
@ -35,7 +36,13 @@ func main() {
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
flag.Parse()
fmt.Println("start demo api server, port: ", *ginPort)
err := r.Run(":" + strconv.Itoa(*ginPort))
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
if config.Config.Api.ListenIP != "" {
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
}
address = config.Config.CmsApi.ListenIP + ":" + strconv.Itoa(*ginPort)
fmt.Println("start demo api server address: ", address)
err := r.Run(address)
if err != nil {
log.Error("", "run failed ", *ginPort, err.Error())
}

View File

@ -1,25 +0,0 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_timer_task
BIN_DIR=../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi

View File

@ -1,63 +0,0 @@
package main
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
)
func main() {
log.NewPrivateLog(constant.LogFileName)
//for {
// fmt.Println("start delete mongodb expired record")
// timeUnixBegin := time.Now().Unix()
// count, _ := db.DB.MgoUserCount()
// fmt.Println("mongodb record count: ", count)
// for i := 0; i < count; i++ {
// time.Sleep(1 * time.Millisecond)
// uid, _ := db.DB.MgoSkipUID(i)
// fmt.Println("operate uid: ", uid)
// err := db.DB.DelUserChat(uid)
// if err != nil {
// fmt.Println("operate uid failed: ", uid, err.Error())
// }
// }
//
// timeUnixEnd := time.Now().Unix()
// costTime := timeUnixEnd - timeUnixBegin
// if costTime > int64(config.Config.Mongo.DBRetainChatRecords*24*3600) {
// continue
// } else {
// sleepTime := 0
// if int64(config.Config.Mongo.DBRetainChatRecords*24*3600)-costTime > 24*3600 {
// sleepTime = 24 * 3600
// } else {
// sleepTime = config.Config.Mongo.DBRetainChatRecords*24*3600 - int(costTime)
// }
// fmt.Println("sleep: ", sleepTime)
// time.Sleep(time.Duration(sleepTime) * time.Second)
// }
//}
//for {
// uidList, err := im_mysql_model.SelectAllUserID()
// if err != nil {
// //log.NewError("999999", err.Error())
// } else {
// for _, v := range uidList {
// minSeq, err := commonDB.DB.GetMinSeqFromMongo(v)
// if err != nil {
// //log.NewError("999999", "get user minSeq err", err.Error(), v)
// continue
// } else {
// err := commonDB.DB.SetUserMinSeq(v, minSeq)
// if err != nil {
// //log.NewError("999999", "set user minSeq err", err.Error(), v)
// }
// }
// time.Sleep(time.Duration(100) * time.Millisecond)
// }
//
// }
//
//}
}

View File

@ -41,11 +41,15 @@ kafka:
ws2mschat:
addr: [ 127.0.0.1:9092 ] #kafka配置默认即可
topic: "ws2ms_chat"
ws2mschatoffline:
addr: [ 127.0.0.1:9092 ] #kafka配置默认即可
topic: "ws2ms_chat_offline"
ms2pschat:
addr: [ 127.0.0.1:9092 ] #kafka配置默认即可
topic: "ms2ps_chat"
consumergroupid:
msgToMongo: mongo
msgToMongoOffline: mongo_offline
msgToMySql: mysql
msgToPush: push
@ -638,6 +642,19 @@ notification:
openTips: "burn after reading was opened"
closeTips: "burn after reading was closed"
###################organization################
joinDepartmentNotification:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "welcome user join department"
desc: "welcome user join department"
ext: "welcome user join department"
defaultTips:
tips: "welcome user join department"
#---------------demo configuration---------------------#
#The following configuration items are applied to openIM Demo configuration
@ -661,7 +678,8 @@ demo:
senderAuthorizationCode: "gxyausfoevlzbfag"
smtpAddr: "smtp.qq.com"
smtpPort: 25 #需开放此端口 出口方向
testDepartMentID: 001
rtc:
port: 11300
address: 127.0.0.1
address: 127.0.0.1

20
go.mod
View File

@ -3,7 +3,7 @@ module Open_IM
go 1.15
require (
github.com/Shopify/sarama v1.19.0
github.com/Shopify/sarama v1.32.0
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
github.com/alibabacloud-go/darabonba-openapi v0.1.11
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8
@ -11,13 +11,10 @@ require (
github.com/alibabacloud-go/tea v1.1.17
github.com/antonfisher/nested-logrus-formatter v1.3.0
github.com/bwmarrin/snowflake v0.3.0
github.com/coreos/etcd v3.3.27+incompatible // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/fatih/structs v1.1.0
github.com/frankban/quicktest v1.14.0 // indirect
github.com/garyburd/redigo v1.6.2
github.com/gin-gonic/gin v1.7.0
github.com/go-playground/validator/v10 v10.4.1
@ -34,8 +31,6 @@ require (
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
github.com/lestrrat-go/strftime v1.0.4 // indirect
github.com/lib/pq v1.2.0 // indirect
//github.com/livekit/protocol v0.11.14-0.20220223195254-d8c251e13231 // indirect
//github.com/livekit/server-sdk-go v0.9.1
github.com/mattn/go-sqlite3 v1.14.6 // indirect
github.com/minio/minio-go/v7 v7.0.22
github.com/mitchellh/mapstructure v1.4.2
@ -46,24 +41,19 @@ require (
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
github.com/sirupsen/logrus v1.8.1
github.com/spf13/viper v1.9.0
github.com/stretchr/testify v1.7.0
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
//go.etcd.io/etcd v3.3.27+incompatible
go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698
go.etcd.io/etcd/api/v3 v3.5.4
go.etcd.io/etcd/client/v3 v3.5.4
go.mongodb.org/mongo-driver v1.8.3
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
google.golang.org/grpc v1.42.0
google.golang.org/grpc/examples v0.0.0-20220311002955-722367c4a737 // indirect
google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 // indirect
google.golang.org/grpc v1.45.0
google.golang.org/protobuf v1.27.1
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
sigs.k8s.io/yaml v1.2.0 // indirect
)
replace google.golang.org/grpc => google.golang.org/grpc v1.29.0

715
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -4,11 +4,13 @@ import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
rpc "Open_IM/pkg/proto/auth"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"github.com/fatih/structs"
"github.com/gin-gonic/gin"
"net/http"
"strings"
@ -38,13 +40,13 @@ func UserRegister(c *gin.Context) {
client := rpc.NewAuthClient(etcdConn)
reply, err := client.UserRegister(context.Background(), req)
if err != nil {
errMsg := req.OperationID + " " + "client.UserRegister failed " + err.Error() + req.String()
errMsg := req.OperationID + " " + "UserRegister failed " + err.Error() + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if reply.CommonResp.ErrCode != 0 {
errMsg := req.OperationID + " " + " client.UserRegister failed " + reply.CommonResp.ErrMsg + req.String()
errMsg := req.OperationID + " " + " UserRegister failed " + reply.CommonResp.ErrMsg + req.String()
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
@ -96,3 +98,29 @@ func UserToken(c *gin.Context) {
log.NewInfo(req.OperationID, "UserToken return ", resp)
c.JSON(http.StatusOK, resp)
}
func ParseToken(c *gin.Context) {
params := api.ParseTokenReq{}
if err := c.BindJSON(&params); err != nil {
errMsg := " BindJSON failed " + err.Error()
log.NewError("0", errMsg)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
return
}
var ok bool
var errInfo string
var expireTime int64
ok, _, errInfo, expireTime = token_verify.GetUserIDFromTokenExpireTime(c.Request.Header.Get("token"), params.OperationID)
if !ok {
errMsg := params.OperationID + " " + "GetUserIDFromTokenExpireTime failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(params.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
resp := api.ParseTokenResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}, ExpireTime: api.ExpireTime{ExpireTimeSeconds: uint32(expireTime)}}
resp.Data = structs.Map(&resp.ExpireTime)
log.NewInfo(params.OperationID, "ParseToken return ", resp)
c.JSON(http.StatusOK, resp)
}

View File

@ -25,10 +25,10 @@ func DelMsg(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
msgClient := pbChat.NewChatClient(grpcConn)
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
@ -39,5 +39,6 @@ func DelMsg(c *gin.Context) {
}
resp.ErrCode = respPb.ErrCode
resp.ErrMsg = respPb.ErrMsg
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
c.JSON(http.StatusOK, resp)
}

View File

@ -35,10 +35,6 @@ func GetSeq(c *gin.Context) {
pbData.UserID = params.SendID
pbData.OperationID = params.OperationID
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
if grpcConn == nil {
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", params)
}
msgClient := pbMsg.NewChatClient(grpcConn)
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
if err != nil {

View File

@ -55,10 +55,10 @@ func PullMsgBySeqList(c *gin.Context) {
msgClient := pbChat.NewChatClient(grpcConn)
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
if err != nil {
log.ErrorByKv("PullMessageBySeqList error", pbData.OperationID, "err", err.Error())
log.Error(pbData.OperationID, "PullMessageBySeqList error", err.Error())
return
}
log.InfoByKv("rpc call success to PullMessageBySeqList", pbData.OperationID, "ReplyArgs", reply.String(), len(reply.List))
log.NewInfo(pbData.OperationID, "rpc call success to PullMessageBySeqList", reply.String(), len(reply.List))
c.JSON(http.StatusOK, gin.H{
"errCode": reply.ErrCode,
"errMsg": reply.ErrMsg,

View File

@ -62,14 +62,12 @@ func SendMsg(c *gin.Context) {
params := paramsUserSendMsg{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
log.ErrorByKv("json unmarshal err", "", "err", err.Error(), "data", c.PostForm("data"))
log.Error("0", "BindJSON failed ", err.Error())
return
}
token := c.Request.Header.Get("token")
log.InfoByKv("api call success to sendMsgReq", params.OperationID, "Parameters", params)
log.NewInfo(params.OperationID, "api call success to sendMsgReq", params)
pbData := newUserSendMsgReq(token, &params)
log.Info("", "", "api SendMsg call start..., [data: %s]", pbData.String())

View File

@ -25,13 +25,13 @@ func SetConversation(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.Conversation = &pbUser.Conversation{}
err := utils.CopyStructFields(&reqPb, req)
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
if err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.SetConversation(context.Background(), &reqPb)
@ -56,13 +56,13 @@ func ModifyConversationField(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.Conversation = &pbConversation.Conversation{}
err := utils.CopyStructFields(&reqPb, req)
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
if err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName)
client := pbConversation.NewConversationClient(etcdConn)
respPb, err := client.ModifyConversationField(context.Background(), &reqPb)
@ -88,10 +88,10 @@ func BatchSetConversations(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
@ -120,10 +120,10 @@ func GetAllConversations(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
@ -152,10 +152,10 @@ func GetConversation(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.GetConversation(context.Background(), &reqPb)
@ -184,10 +184,10 @@ func GetConversations(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.GetConversations(context.Background(), &reqPb)
@ -216,10 +216,10 @@ func SetRecvMsgOpt(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)

View File

@ -26,10 +26,12 @@ func AddBlack(c *gin.Context) {
req := &rpc.AddBlacklistReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(params.OperationID, "AddBlacklist args ", req.String())
@ -57,12 +59,15 @@ func ImportFriend(c *gin.Context) {
req := &rpc.ImportFriendReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "ImportFriend args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
@ -96,13 +101,17 @@ func AddFriend(c *gin.Context) {
req := &rpc.AddFriendReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
req.ReqMsg = params.ReqMsg
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.CommID.OperationID, "AddFriend args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
@ -130,13 +139,17 @@ func AddFriendResponse(c *gin.Context) {
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
req.HandleMsg = params.HandleMsg
req.HandleResult = params.Flag
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
utils.CopyStructFields(req, &params)
log.NewInfo(req.CommID.OperationID, "AddFriendResponse args ", req.String())
@ -163,13 +176,17 @@ func DeleteFriend(c *gin.Context) {
}
req := &rpc.DeleteFriendReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.CommID.OperationID, "DeleteFriend args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
@ -195,13 +212,17 @@ func GetBlacklist(c *gin.Context) {
}
req := &rpc.GetBlacklistReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.CommID.OperationID, "GetBlacklist args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
@ -234,13 +255,17 @@ func SetFriendRemark(c *gin.Context) {
req := &rpc.SetFriendRemarkReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
req.Remark = params.Remark
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.CommID.OperationID, "SetFriendComment args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
@ -266,11 +291,14 @@ func RemoveBlack(c *gin.Context) {
}
req := &rpc.RemoveBlacklistReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -297,13 +325,17 @@ func IsFriend(c *gin.Context) {
}
req := &rpc.IsFriendReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params.ParamsCommFriend)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.CommID.OperationID, "IsFriend args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
@ -321,40 +353,6 @@ func IsFriend(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
//
//func GetFriendsInfo(c *gin.Context) {
// params := api.GetFriendsInfoReq{}
// if err := c.BindJSON(&params); err != nil {
// log.NewError("0", "BindJSON failed ", err.Error())
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
// return
// }
// req := &rpc.GetFriendsInfoReq{}
// utils.CopyStructFields(req.CommID, params)
// var ok bool
// ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
// if !ok {
// log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
// return
// }
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo args ", req.String())
//
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
// client := rpc.NewFriendClient(etcdConn)
// RpcResp, err := client.GetFriendsInfo(context.Background(), req)
// if err != nil {
// log.NewError(req.CommID.OperationID, "GetFriendsInfo failed ", err.Error(), req.String())
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call search friend rpc server failed"})
// return
// }
//
// resp := api.GetFriendsInfoResp{CommResp:api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
// utils.CopyStructFields(&resp, RpcResp)
// c.JSON(http.StatusOK, resp)
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo api return ", resp)
//}
func GetFriendList(c *gin.Context) {
params := api.GetFriendListReq{}
if err := c.BindJSON(&params); err != nil {
@ -364,13 +362,17 @@ func GetFriendList(c *gin.Context) {
}
req := &rpc.GetFriendListReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.CommID.OperationID, "GetFriendList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
@ -398,13 +400,17 @@ func GetFriendApplyList(c *gin.Context) {
}
req := &rpc.GetFriendApplyListReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
@ -432,13 +438,17 @@ func GetSelfFriendApplyList(c *gin.Context) {
}
req := &rpc.GetSelfApplyListReq{CommID: &rpc.CommID{}}
utils.CopyStructFields(req.CommID, &params)
var ok bool
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
var errInfo string
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
if !ok {
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)

View File

@ -29,11 +29,14 @@ func KickGroupMember(c *gin.Context) {
req := &rpc.KickGroupMemberReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -71,14 +74,17 @@ func GetGroupMembersInfo(c *gin.Context) {
}
req := &rpc.GetGroupMembersInfoReq{}
utils.CopyStructFields(req, params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
//c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
api.SetErrCodeMsg(c, http.StatusInternalServerError)
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -106,13 +112,17 @@ func GetGroupMemberList(c *gin.Context) {
}
req := &rpc.GetGroupMemberListReq{}
utils.CopyStructFields(req, params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "GetGroupMemberList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -141,13 +151,17 @@ func GetGroupAllMemberList(c *gin.Context) {
}
req := &rpc.GetGroupAllMemberReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "GetGroupAllMember args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -174,13 +188,17 @@ func GetJoinedGroupList(c *gin.Context) {
}
req := &rpc.GetJoinedGroupListReq{}
utils.CopyStructFields(req, params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "GetJoinedGroupList args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -207,13 +225,17 @@ func InviteUserToGroup(c *gin.Context) {
}
req := &rpc.InviteUserToGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -252,15 +274,20 @@ func CreateGroup(c *gin.Context) {
for _, v := range params.MemberList {
req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel})
}
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
req.OwnerUserID = params.OwnerUserID
req.OperationID = params.OperationID
log.NewInfo(req.OperationID, "CreateGroup args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -355,13 +382,17 @@ func GetGroupsInfo(c *gin.Context) {
}
req := &rpc.GetGroupsInfoReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
@ -388,13 +419,17 @@ func ApplicationGroupResponse(c *gin.Context) {
}
req := &rpc.GroupApplicationResponseReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "ApplicationGroupResponse args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -420,13 +455,17 @@ func JoinGroup(c *gin.Context) {
}
req := &rpc.JoinGroupReq{}
utils.CopyStructFields(req, params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := rpc.NewGroupClient(etcdConn)
@ -451,13 +490,17 @@ func QuitGroup(c *gin.Context) {
}
req := &rpc.QuitGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "QuitGroup args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -483,13 +526,17 @@ func SetGroupInfo(c *gin.Context) {
req := &rpc.SetGroupInfoReq{GroupInfo: &open_im_sdk.GroupInfo{}}
utils.CopyStructFields(req.GroupInfo, &params)
req.OperationID = params.OperationID
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "SetGroupInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -514,13 +561,17 @@ func TransferGroupOwner(c *gin.Context) {
}
req := &rpc.TransferGroupOwnerReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "TransferGroupOwner args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -546,13 +597,17 @@ func DismissGroup(c *gin.Context) {
}
req := &rpc.DismissGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -578,13 +633,17 @@ func MuteGroupMember(c *gin.Context) {
}
req := &rpc.MuteGroupMemberReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -610,13 +669,17 @@ func CancelMuteGroupMember(c *gin.Context) {
}
req := &rpc.CancelMuteGroupMemberReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -642,13 +705,17 @@ func MuteGroup(c *gin.Context) {
}
req := &rpc.MuteGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -674,13 +741,17 @@ func CancelMuteGroup(c *gin.Context) {
}
req := &rpc.CancelMuteGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -708,13 +779,17 @@ func SetGroupMemberNickname(c *gin.Context) {
}
req := &rpc.SetGroupMemberNicknameReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)

View File

@ -40,11 +40,12 @@ func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
fallthrough
case constant.Voice:
fallthrough
case constant.Video:
fallthrough
case constant.File:
newContent = utils.StructToJsonString(params.Content)
case constant.Revoke:
newContent = params.Content["revokeMsgClientID"].(string)
default:
}
var options map[string]bool
@ -94,7 +95,7 @@ func ManagementSendMsg(c *gin.Context) {
params := ManagementSendMsgReq{}
if err := c.BindJSON(&params); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
log.ErrorByKv("json unmarshal err", c.PostForm("operationID"), "err", err.Error(), "content", c.PostForm("content"))
log.Error(c.PostForm("operationID"), "json unmarshal err", err.Error(), c.PostForm("content"))
return
}
switch params.ContentType {
@ -126,16 +127,16 @@ func ManagementSendMsg(c *gin.Context) {
//case constant.Quote:
default:
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
log.ErrorByKv("contentType err", c.PostForm("operationID"), "content", c.PostForm("content"))
log.Error(c.PostForm("operationID"), "contentType err", c.PostForm("content"))
return
}
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
log.ErrorByKv("content to Data struct err", "", "err", err.Error())
log.Error(c.PostForm("operationID"), "content to Data struct err", err.Error())
return
} else if err := validate.Struct(data); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
log.ErrorByKv("data args validate err", "", "err", err.Error())
log.Error(c.PostForm("operationID"), "data args validate err", err.Error())
return
}
log.NewInfo("", data, params)
@ -166,7 +167,7 @@ func ManagementSendMsg(c *gin.Context) {
}
}
log.InfoByKv("Ws call success to ManagementSendMsgReq", params.OperationID, "Parameters", params)
log.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
pbData := newUserSendMsgReq(&params)
log.Info("", "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())

View File

@ -30,13 +30,17 @@ func DeleteUser(c *gin.Context) {
}
req := &rpc.DeleteUsersReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(params.OperationID, "DeleteUser args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := rpc.NewUserClient(etcdConn)
@ -62,13 +66,17 @@ func GetAllUsersUid(c *gin.Context) {
}
req := &rpc.GetAllUserIDReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(params.OperationID, "GetAllUsersUid args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := rpc.NewUserClient(etcdConn)
@ -94,13 +102,17 @@ func AccountCheck(c *gin.Context) {
}
req := &rpc.AccountCheckReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(params.OperationID, "AccountCheck args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := rpc.NewUserClient(etcdConn)
@ -127,11 +139,14 @@ func GetUsersOnlineStatus(c *gin.Context) {
}
req := &pbRelay.GetUsersOnlineStatusReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}

View File

@ -27,12 +27,18 @@ func GetUserTags(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.UserID = userID
reqPb.OperationID = req.OperationID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
@ -69,12 +75,18 @@ func CreateTag(c *gin.Context) {
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.UserID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
@ -105,12 +117,18 @@ func DeleteTag(c *gin.Context) {
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.UserID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
@ -141,12 +159,18 @@ func SetTag(c *gin.Context) {
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.UserID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
@ -177,12 +201,18 @@ func SendMsg2Tag(c *gin.Context) {
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.SendID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
@ -210,12 +240,18 @@ func GetTagSendLogs(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.UserID = userID
reqPb.OperationID = req.OperationID
reqPb.Pagination = &pbCommon.RequestPagination{
@ -255,12 +291,18 @@ func GetUserTagByID(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.UserID = userID
reqPb.OperationID = req.OperationID
reqPb.TagID = req.TagID

View File

@ -28,12 +28,18 @@ func CreateOneWorkMoment(c *gin.Context) {
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
@ -67,12 +73,18 @@ func DeleteOneWorkMoment(c *gin.Context) {
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
@ -105,12 +117,18 @@ func LikeOneWorkMoment(c *gin.Context) {
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
@ -143,12 +161,18 @@ func CommentOneWorkMoment(c *gin.Context) {
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
@ -168,6 +192,48 @@ func CommentOneWorkMoment(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
func DeleteComment(c *gin.Context) {
var (
req apiStruct.DeleteCommentReq
resp apiStruct.DeleteCommentResp
reqPb pbOffice.DeleteCommentReq
respPb *pbOffice.DeleteCommentResp
)
if err := c.BindJSON(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), err.Error())
}
var ok bool
var errInfo string
ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.DeleteComment(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DeleteComment rpc failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "DeleteComment rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
c.JSON(http.StatusOK, resp)
}
func GetWorkMomentByID(c *gin.Context) {
var (
req apiStruct.GetWorkMomentByIDReq
@ -181,12 +247,18 @@ func GetWorkMomentByID(c *gin.Context) {
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.OperationID = req.OperationID
reqPb.OpUserID = userID
reqPb.WorkMomentID = req.WorkMomentID
@ -201,7 +273,8 @@ func GetWorkMomentByID(c *gin.Context) {
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
resp.Data.WorkMoment = &apiStruct.WorkMoment{LikeUserList: []*apiStruct.WorkMomentUser{}, Comments: []*apiStruct.Comment{}, AtUserList: []*apiStruct.WorkMomentUser{}}
resp.Data.WorkMoment = &apiStruct.WorkMoment{LikeUserList: []*apiStruct.WorkMomentUser{}, Comments: []*apiStruct.Comment{},
AtUserList: []*apiStruct.WorkMomentUser{}, PermissionUserList: []*apiStruct.WorkMomentUser{}}
if err := utils.CopyStructFields(&resp.Data.WorkMoment, respPb.WorkMoment); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
@ -222,12 +295,18 @@ func GetUserWorkMoments(c *gin.Context) {
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
ok, opUserID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var opUserID string
ok, opUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.OperationID = req.OperationID
reqPb.Pagination = &pbCommon.RequestPagination{
PageNumber: req.PageNumber,
@ -252,15 +331,17 @@ func GetUserWorkMoments(c *gin.Context) {
//}
for _, v := range respPb.WorkMoments {
workMoment := apiStruct.WorkMoment{
WorkMomentID: v.WorkMomentID,
UserID: v.UserID,
Content: v.Content,
FaceURL: v.FaceURL,
UserName: v.UserName,
CreateTime: v.CreateTime,
Comments: make([]*apiStruct.Comment, len(v.Comments)),
LikeUserList: make([]*apiStruct.WorkMomentUser, len(v.LikeUserList)),
AtUserList: make([]*apiStruct.WorkMomentUser, len(v.AtUserList)),
WorkMomentID: v.WorkMomentID,
UserID: v.UserID,
Content: v.Content,
FaceURL: v.FaceURL,
UserName: v.UserName,
CreateTime: v.CreateTime,
Comments: make([]*apiStruct.Comment, len(v.Comments)),
LikeUserList: make([]*apiStruct.WorkMomentUser, len(v.LikeUserList)),
AtUserList: make([]*apiStruct.WorkMomentUser, len(v.AtUserList)),
PermissionUserList: make([]*apiStruct.WorkMomentUser, len(v.PermissionUserList)),
Permission: v.Permission,
}
for i, comment := range v.Comments {
workMoment.Comments[i] = &apiStruct.Comment{
@ -285,6 +366,12 @@ func GetUserWorkMoments(c *gin.Context) {
UserName: atUser.UserName,
}
}
for i, permissionUser := range v.PermissionUserList {
workMoment.PermissionUserList[i] = &apiStruct.WorkMomentUser{
UserID: permissionUser.UserID,
UserName: permissionUser.UserName,
}
}
resp.Data.WorkMoments = append(resp.Data.WorkMoments, &workMoment)
}
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
@ -306,12 +393,18 @@ func GetUserFriendWorkMoments(c *gin.Context) {
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
reqPb.OperationID = req.OperationID
reqPb.Pagination = &pbCommon.RequestPagination{
PageNumber: req.PageNumber,
@ -335,15 +428,17 @@ func GetUserFriendWorkMoments(c *gin.Context) {
resp.Data.WorkMoments = []*apiStruct.WorkMoment{}
for _, v := range respPb.WorkMoments {
workMoment := apiStruct.WorkMoment{
WorkMomentID: v.WorkMomentID,
UserID: v.UserID,
Content: v.Content,
FaceURL: v.FaceURL,
UserName: v.UserName,
CreateTime: v.CreateTime,
Comments: make([]*apiStruct.Comment, len(v.Comments)),
LikeUserList: make([]*apiStruct.WorkMomentUser, len(v.LikeUserList)),
AtUserList: make([]*apiStruct.WorkMomentUser, len(v.AtUserList)),
WorkMomentID: v.WorkMomentID,
UserID: v.UserID,
Content: v.Content,
FaceURL: v.FaceURL,
UserName: v.UserName,
CreateTime: v.CreateTime,
Comments: make([]*apiStruct.Comment, len(v.Comments)),
LikeUserList: make([]*apiStruct.WorkMomentUser, len(v.LikeUserList)),
AtUserList: make([]*apiStruct.WorkMomentUser, len(v.AtUserList)),
PermissionUserList: make([]*apiStruct.WorkMomentUser, len(v.PermissionUserList)),
Permission: v.Permission,
}
for i, comment := range v.Comments {
workMoment.Comments[i] = &apiStruct.Comment{
@ -368,6 +463,12 @@ func GetUserFriendWorkMoments(c *gin.Context) {
UserName: atUser.UserName,
}
}
for i, permissionUser := range v.PermissionUserList {
workMoment.PermissionUserList[i] = &apiStruct.WorkMomentUser{
UserID: permissionUser.UserID,
UserName: permissionUser.UserName,
}
}
resp.Data.WorkMoments = append(resp.Data.WorkMoments, &workMoment)
}
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
@ -389,12 +490,18 @@ func SetUserWorkMomentsLevel(c *gin.Context) {
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
var userID string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}

View File

@ -54,12 +54,18 @@ func AliOSSCredential(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var userID string
var errInfo string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "AliOSSCredential args ", userID)
stsResp, err := getStsClient().AssumeRole(&sts20150401.AssumeRoleRequest{

View File

@ -7,12 +7,11 @@ import (
"context"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/minio/minio-go/v7/pkg/policy"
url2 "net/url"
)
var (
minioClient *minio.Client
MinioClient *minio.Client
)
func MinioInit() {
@ -30,11 +29,16 @@ func MinioInit() {
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
return
}
opts := &minio.Options{
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
}
if minioUrl.Scheme == "http" {
opts.Secure = false
} else if minioUrl.Scheme == "https" {
opts.Secure = true
}
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
minioClient, err = minio.New(minioUrl.Host, &minio.Options{
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
Secure: false,
})
MinioClient, err = minio.New(minioUrl.Host, opts)
log.NewInfo(operationID, utils.GetSelfFuncName(), "new ok ", config.Config.Credential.Minio)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
@ -44,10 +48,25 @@ func MinioInit() {
Region: config.Config.Credential.Minio.Location,
ObjectLocking: false,
}
err = minioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
exists, err := minioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
if err == nil && exists {
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
} else {
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
}
log.NewError(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
return
}
}
// make app bucket
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.AppBucket, opt)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
if err == nil && exists {
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
} else {
@ -59,10 +78,11 @@ func MinioInit() {
}
}
// 自动化桶public的代码
err = minioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policy.BucketPolicyReadWrite)
if err != nil {
log.NewDebug("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
return
}
//err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policy.BucketPolicyReadWrite)
//err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.AppBucket, policy.BucketPolicyReadWrite)
//if err != nil {
// log.NewDebug("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
// return
//}
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio create and set policy success")
}

View File

@ -4,6 +4,7 @@ import (
apiStruct "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
_ "Open_IM/pkg/common/token_verify"
@ -33,12 +34,17 @@ func MinioUploadFile(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
var ok bool
var errInfo string
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
switch req.FileType {
// videoType upload snapShot
@ -56,7 +62,7 @@ func MinioUploadFile(c *gin.Context) {
}
snapShotNewName, snapShotNewType := utils.GetNewFileNameAndContentType(snapShotFile.Filename, constant.ImageType)
log.Debug(req.OperationID, utils.GetSelfFuncName(), snapShotNewName, snapShotNewType)
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject snapShotFile error", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
@ -67,6 +73,7 @@ func MinioUploadFile(c *gin.Context) {
}
file, err := c.FormFile("file")
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "FormFile failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
return
}
@ -77,11 +84,11 @@ func MinioUploadFile(c *gin.Context) {
return
}
newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType)
log.Debug(req.OperationID, utils.GetSelfFuncName(), newName, newType)
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
log.Debug(req.OperationID, utils.GetSelfFuncName(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, newType, MinioClient.EndpointURL())
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "invalid file path" + err.Error()})
log.NewError(req.OperationID, utils.GetSelfFuncName(), "upload file error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "upload file error" + err.Error()})
return
}
resp.NewName = newName
@ -101,12 +108,17 @@ func MinioStorageCredential(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
var stsOpts cr.STSAssumeRoleOptions
stsOpts.AccessKey = config.Config.Credential.Minio.AccessKeyID
stsOpts.SecretKey = config.Config.Credential.Minio.SecretAccessKey
@ -136,3 +148,98 @@ func MinioStorageCredential(c *gin.Context) {
resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
}
func UploadUpdateApp(c *gin.Context) {
var (
req apiStruct.UploadUpdateAppReq
resp apiStruct.UploadUpdateAppResp
)
if err := c.Bind(&req); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var yamlName string
if req.Yaml == nil {
yamlName = ""
} else {
yamlName = req.Yaml.Filename
}
fileObj, err := req.File.Open()
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Open file error" + err.Error()})
return
}
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, req.File.Filename, fileObj, req.File.Size, minio.PutObjectOptions{})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject file error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject file error" + err.Error()})
return
}
if yamlName != "" {
yamlObj, err := req.Yaml.Open()
if err == nil {
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, yamlName, yamlObj, req.Yaml.Size, minio.PutObjectOptions{})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject yaml error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject yaml error" + err.Error()})
return
}
} else {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
}
}
if err := imdb.UpdateAppVersion(req.Type, req.Version, req.ForceUpdate, req.File.Filename, yamlName, req.UpdateLog); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateAppVersion error", err.Error())
resp.ErrCode = http.StatusInternalServerError
resp.ErrMsg = err.Error()
c.JSON(http.StatusInternalServerError, resp)
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName())
c.JSON(http.StatusOK, resp)
}
func GetDownloadURL(c *gin.Context) {
var (
req apiStruct.GetDownloadURLReq
resp apiStruct.GetDownloadURLResp
)
defer func() {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
}()
if err := c.Bind(&req); err != nil {
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
app, err := imdb.GetNewestVersion(req.Type)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "getNewestVersion failed", err.Error())
}
log.Debug(req.OperationID, utils.GetSelfFuncName(), "app: ", app)
if app != nil {
if app.Version != req.Version && app.Version != "" {
resp.Data.HasNewVersion = true
if app.ForceUpdate == true {
resp.Data.ForceUpdate = true
}
if app.YamlName != "" {
resp.Data.YamlURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.YamlName
}
resp.Data.FileURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.FileName
resp.Data.Version = app.Version
resp.Data.UpdateLog = app.UpdateLog
c.JSON(http.StatusOK, resp)
return
} else {
resp.Data.HasNewVersion = false
c.JSON(http.StatusOK, resp)
return
}
}
c.JSON(http.StatusBadRequest, gin.H{"errCode": 0, "errMsg": "not found app version"})
}

View File

@ -22,12 +22,18 @@ func TencentCloudStorageCredential(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var userID string
var errInfo string
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(req.OperationID, "TencentCloudStorageCredential args ", userID)
cli := sts.NewClient(

View File

@ -26,17 +26,18 @@ func GetUsersInfoFromCache(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
log.NewInfo(params.OperationID, "GetUsersInfoFromCache req: ", params)
req := &rpc.GetUserInfoReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := rpc.NewUserClient(etcdConn)
RpcResp, err := client.GetUserInfo(context.Background(), req)
@ -50,117 +51,12 @@ func GetUsersInfoFromCache(c *gin.Context) {
publicUserInfoList = append(publicUserInfoList,
&open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
}
resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
resp.Data = jsonData.JsonDataList(resp.UserInfoList)
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
c.JSON(http.StatusOK, resp)
}
//func GetUsersInfoFromCache(c *gin.Context) {
// params := api.GetUsersInfoReq{}
// if err := c.BindJSON(&params); err != nil {
// log.NewError("0", "BindJSON failed ", err.Error())
// c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
// return
// }
// getUserInfoReq := &rpc.GetUserInfoReq{}
// getUserInfoReq.OperationID = params.OperationID
// var ok bool
// ok, getUserInfoReq.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), getUserInfoReq.OperationID)
// if !ok {
// log.NewError(getUserInfoReq.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
// return
// }
// log.NewInfo(params.OperationID, "GetUserInfo args ", getUserInfoReq.String())
// reqCacheGetUserInfo := &cacheRpc.GetUserInfoFromCacheReq{}
// utils.CopyStructFields(reqCacheGetUserInfo, &params)
// var userInfoList []*open_im_sdk.UserInfo
// var publicUserInfoList []*open_im_sdk.PublicUserInfo
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
// cacheClient := cacheRpc.NewCacheClient(etcdConn)
// cacheResp, err := cacheClient.GetUserInfoFromCache(context.Background(), reqCacheGetUserInfo)
// if err != nil {
// log.NewError(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed", err.Error())
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed: " + err.Error()})
// return
// }
// if cacheResp.CommonResp.ErrCode != 0 {
// log.NewError(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed", cacheResp.CommonResp)
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}}
// resp.Data = []map[string]interface{}{}
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
// c.JSON(http.StatusOK, resp)
// return
// }
// log.NewInfo(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "cacheResp:", cacheResp.String())
// userInfoList = cacheResp.UserInfoList
// var needCacheUserIDList []string
// for _, userID := range reqCacheGetUserInfo.UserIDList {
// isGetUserInfoFromCache := false
// for _, cacheUser := range userInfoList {
// if cacheUser.UserID == userID {
// isGetUserInfoFromCache = true
// }
// }
// if !isGetUserInfoFromCache {
// needCacheUserIDList = append(needCacheUserIDList, userID)
// }
// }
// if len(needCacheUserIDList) == 0 {
// log.NewInfo(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "get all userInfo from cache success")
// for _, v := range userInfoList {
// publicUserInfoList = append(publicUserInfoList,
// &open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
// }
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
// resp.Data = jsonData.JsonDataList(resp.UserInfoList)
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
// c.JSON(http.StatusOK, resp)
// return
// }
//
// log.NewDebug(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "need cache user list", needCacheUserIDList)
// getUserInfoReq.UserIDList = needCacheUserIDList
// etcdConn = getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
// client := rpc.NewUserClient(etcdConn)
// rpcResp, err := client.GetUserInfo(context.Background(), getUserInfoReq)
// if err != nil {
// log.NewError(getUserInfoReq.OperationID, "GetUserInfo failed ", err.Error(), getUserInfoReq.String())
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed" + err.Error()})
// return
// }
// if rpcResp.CommonResp.ErrCode != 0 {
// log.NewError(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed", cacheResp.CommonResp)
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}}
// resp.Data = []map[string]interface{}{}
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
// c.JSON(http.StatusOK, resp)
// return
// }
// userInfoList = append(userInfoList, rpcResp.UserInfoList...)
// cacheUpdateUserInfoReq := &cacheRpc.UpdateUserInfoToCacheReq{
// UserInfoList: rpcResp.UserInfoList,
// OperationID: getUserInfoReq.OperationID,
// }
// _, err = cacheClient.UpdateUserInfoToCache(context.Background(), cacheUpdateUserInfoReq)
// if err != nil {
// log.NewError(getUserInfoReq.OperationID, "GetUserInfo failed ", err.Error())
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()})
// return
// }
// userInfoList = rpcResp.UserInfoList
// for _, v := range userInfoList {
// publicUserInfoList = append(publicUserInfoList,
// &open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
// }
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
// resp.Data = jsonData.JsonDataList(resp.UserInfoList)
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
// c.JSON(http.StatusOK, resp)
//}
func GetFriendIDListFromCache(c *gin.Context) {
var (
req api.GetFriendIDListFromCacheReq
@ -173,12 +69,15 @@ func GetFriendIDListFromCache(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
reqPb.OperationID = req.OperationID
var ok bool
ok, reqPb.UserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
@ -206,12 +105,15 @@ func GetBlackIDListFromCache(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.OperationID = req.OperationID
var ok bool
ok, reqPb.UserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
@ -236,13 +138,17 @@ func GetUsersInfo(c *gin.Context) {
}
req := &rpc.GetUserInfoReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
@ -274,13 +180,14 @@ func UpdateUserInfo(c *gin.Context) {
}
req := &rpc.UpdateUserInfoReq{UserInfo: &open_im_sdk.UserInfo{}}
utils.CopyStructFields(req.UserInfo, &params)
req.OperationID = params.OperationID
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(params.OperationID, "UpdateUserInfo args ", req.String())
@ -308,13 +215,17 @@ func GetSelfUserInfo(c *gin.Context) {
req := &rpc.GetUserInfoReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
req.UserIDList = append(req.UserIDList, req.OpUserID)
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
@ -347,13 +258,17 @@ func GetUsersOnlineStatus(c *gin.Context) {
}
req := &pbRelay.GetUsersOnlineStatusReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
if len(config.Config.Manager.AppManagerUid) == 0 {
log.NewError(req.OperationID, "Manager == 0")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "Manager == 0"})

View File

@ -1,7 +1,7 @@
package admin
import (
"Open_IM/pkg/cms_api_struct"
apiStruct "Open_IM/pkg/cms_api_struct"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
openIMHttp "Open_IM/pkg/common/http"
@ -10,16 +10,55 @@ import (
pbAdmin "Open_IM/pkg/proto/admin_cms"
"Open_IM/pkg/utils"
"context"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"strings"
"github.com/gin-gonic/gin"
url2 "net/url"
)
var (
minioClient *minio.Client
)
func init() {
operationID := utils.OperationIDGenerator()
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio config: ", config.Config.Credential.Minio)
var initUrl string
if config.Config.Credential.Minio.EndpointInnerEnable {
initUrl = config.Config.Credential.Minio.EndpointInner
} else {
initUrl = config.Config.Credential.Minio.Endpoint
}
log.NewInfo(operationID, utils.GetSelfFuncName(), "use initUrl: ", initUrl)
minioUrl, err := url2.Parse(initUrl)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
return
}
opts := &minio.Options{
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
}
if minioUrl.Scheme == "http" {
opts.Secure = false
} else if minioUrl.Scheme == "https" {
opts.Secure = true
}
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
minioClient, err = minio.New(minioUrl.Host, opts)
log.NewInfo(operationID, utils.GetSelfFuncName(), "new ok ", config.Config.Credential.Minio)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
return
}
}
// register
func AdminLogin(c *gin.Context) {
var (
req cms_api_struct.AdminLoginRequest
resp cms_api_struct.AdminLoginResponse
req apiStruct.AdminLoginRequest
resp apiStruct.AdminLoginResponse
reqPb pbAdmin.AdminLoginReq
)
if err := c.BindJSON(&req); err != nil {

View File

@ -28,6 +28,7 @@ func GetGroupById(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
@ -44,6 +45,7 @@ func GetGroupById(c *gin.Context) {
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
resp.IsBanChat = constant.GroupIsBanChat(respPb.CMSGroup.GroupInfo.Status)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -58,6 +60,7 @@ func GetGroups(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.Pagination = &commonPb.RequestPagination{}
utils.CopyStructFields(&reqPb.Pagination, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -83,6 +86,7 @@ func GetGroups(c *gin.Context) {
resp.GroupNums = int(respPb.GroupNum)
resp.CurrentPage = int(respPb.Pagination.PageNumber)
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -97,6 +101,7 @@ func GetGroupByName(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupName = req.GroupName
reqPb.Pagination = &commonPb.RequestPagination{}
utils.CopyStructFields(&reqPb.Pagination, req)
@ -123,6 +128,7 @@ func GetGroupByName(c *gin.Context) {
resp.CurrentPage = int(respPb.Pagination.PageNumber)
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.GroupNums = int(respPb.GroupNums)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -137,6 +143,7 @@ func CreateGroup(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupInfo = &commonPb.GroupInfo{}
reqPb.GroupInfo.GroupName = req.GroupName
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
@ -169,6 +176,7 @@ func BanGroupChat(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupBanChat
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -193,6 +201,7 @@ func BanPrivateChat(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupBanPrivateChat
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -216,6 +225,7 @@ func OpenGroupChat(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupOk
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -239,6 +249,7 @@ func OpenPrivateChat(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.Status = constant.GroupOk
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -263,6 +274,7 @@ func GetGroupMembers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.Pagination = &commonPb.RequestPagination{
PageNumber: int32(req.PageNumber),
ShowNumber: int32(req.ShowNumber),
@ -290,6 +302,7 @@ func GetGroupMembers(c *gin.Context) {
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -304,6 +317,7 @@ func AddGroupMembers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.UserIds = req.Members
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -316,6 +330,7 @@ func AddGroupMembers(c *gin.Context) {
}
resp.Success = respPb.Success
resp.Failed = respPb.Failed
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -330,6 +345,7 @@ func RemoveGroupMembers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.UserIds = req.Members
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -342,6 +358,7 @@ func RemoveGroupMembers(c *gin.Context) {
}
resp.Success = respPb.Success
resp.Failed = respPb.Failed
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -356,6 +373,7 @@ func DeleteGroup(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
@ -379,6 +397,7 @@ func SetGroupMaster(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.UserId = req.UserId
reqPb.RoleLevel = constant.GroupOwner
@ -404,6 +423,7 @@ func SetGroupOrdinaryUsers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.UserId = req.UserId
reqPb.RoleLevel = constant.GroupOrdinaryUsers
@ -424,6 +444,7 @@ func AlterGroupInfo(c *gin.Context) {
_ cms_api_struct.SetGroupMasterResponse
reqPb pbGroup.SetGroupInfoReq
)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)

View File

@ -78,6 +78,7 @@ func GetChatLogs(c *gin.Context) {
ShowNumber: int32(req.ShowNumber),
}
utils.CopyStructFields(&reqPb, &req)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
client := pbMessage.NewMessageCMSClient(etcdConn)
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
@ -105,5 +106,6 @@ func GetChatLogs(c *gin.Context) {
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.ChatLogsNum = int(respPb.ChatLogsNum)
log.NewInfo("", utils.GetSelfFuncName(), "resp", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}

View File

@ -11,14 +11,16 @@ import (
func JWTAuth() gin.HandlerFunc {
return func(c *gin.Context) {
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
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"))
log.NewError("", "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.Abort()
http.RespHttp200(c, constant.ErrParseToken, nil)
return
} else {
log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo)
}
}
}

View File

@ -27,6 +27,7 @@ func GetMessagesStatistics(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
@ -57,6 +58,7 @@ func GetMessagesStatistics(c *gin.Context) {
MessageNum: int(v.Num),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -72,6 +74,7 @@ func GetUserStatistics(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
@ -112,6 +115,7 @@ func GetUserStatistics(c *gin.Context) {
TotalUserNum: int(v.Num),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -127,6 +131,7 @@ func GetGroupStatistics(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
@ -160,6 +165,7 @@ func GetGroupStatistics(c *gin.Context) {
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -175,6 +181,7 @@ func GetActiveUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.StatisticsReq, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
@ -185,6 +192,7 @@ func GetActiveUser(c *gin.Context) {
return
}
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -200,6 +208,7 @@ func GetActiveGroup(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.StatisticsReq, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
client := pb.NewUserClient(etcdConn)
@ -220,5 +229,6 @@ func GetActiveGroup(c *gin.Context) {
MessageNum: int(group.MessageNum),
})
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}

View File

@ -29,6 +29,7 @@ func GetUserById(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -43,15 +44,17 @@ func GetUserById(c *gin.Context) {
return
}
utils.CopyStructFields(&resp, respPb.User)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetUsersByName(c *gin.Context) {
var (
req cms_api_struct.GetUsersByNameRequest
resp cms_api_struct.GetUsersByNameResponse
req cms_api_struct.GetUsersByNameRequest
resp cms_api_struct.GetUsersByNameResponse
reqPb pb.GetUsersByNameReq
)
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
@ -74,6 +77,7 @@ func GetUsersByName(c *gin.Context) {
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.UserNums = respPb.UserNums
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -89,6 +93,7 @@ func GetUsers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.Pagination, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -101,6 +106,7 @@ func GetUsers(c *gin.Context) {
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.UserNums = respPb.UserNums
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -116,14 +122,15 @@ func ResignUser(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
fmt.Println(reqPb.UserId)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
_, err := client.ResignUser(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, err, resp)
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -138,6 +145,7 @@ func AlterUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -159,6 +167,7 @@ func AddUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -182,6 +191,7 @@ func BlockUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -205,6 +215,7 @@ func UnblockUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -213,6 +224,7 @@ func UnblockUser(c *gin.Context) {
openIMHttp.RespHttp200(c, err, resp)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -229,6 +241,7 @@ func GetBlockUsers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
utils.CopyStructFields(&reqPb.Pagination, &req)
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "blockUsers", reqPb.Pagination, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
@ -255,6 +268,7 @@ func GetBlockUsers(c *gin.Context) {
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
resp.UserNums = respPb.UserNums
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -269,6 +283,7 @@ func GetBlockUserById(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.UserId = req.UserId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
@ -281,6 +296,7 @@ func GetBlockUserById(c *gin.Context) {
resp.EndDisableTime = respPb.BlockUser.EndDisableTime
resp.BeginDisableTime = respPb.BlockUser.BeginDisableTime
utils.CopyStructFields(&resp, respPb.BlockUser.User)
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
@ -294,6 +310,7 @@ func DeleteUser(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.UserId = req.UserId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)

View File

@ -0,0 +1,197 @@
package register
import (
"Open_IM/internal/rpc/msg"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
groupRpc "Open_IM/pkg/proto/group"
organizationRpc "Open_IM/pkg/proto/organization"
commonPb "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"math/rand"
"strings"
"time"
)
func onboardingProcess(operationID, userID, userName string) {
if err := createOrganizationUser(operationID, userID, userName); err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "createOrganizationUser failed", err.Error())
}
departmentID := config.Config.Demo.TestDepartMentID
if err := joinTestDepartment(operationID, userID, departmentID); err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error())
}
groupIDList, err := GetDepartmentGroupIDList(operationID, departmentID)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
}
joinGroups(operationID, userID, userName, groupIDList)
log.NewInfo(operationID, utils.GetSelfFuncName(), "fineshed")
}
func createOrganizationUser(operationID, userID, userName string) error {
defer func() {
log.NewInfo(operationID, utils.GetSelfFuncName(), userID)
}()
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := organizationRpc.NewOrganizationClient(etcdConn)
req := &organizationRpc.CreateOrganizationUserReq{
OrganizationUser: &commonPb.OrganizationUser{
UserID: userID,
Nickname: userName,
EnglishName: randomEnglishName(),
Gender: constant.Male,
CreateTime: uint32(time.Now().Unix()),
},
OperationID: operationID,
OpUserID: userID,
}
if strings.Contains("@", userID) {
req.OrganizationUser.Email = userID
} else {
req.OrganizationUser.Telephone = userID
}
resp, err := client.CreateOrganizationUser(context.Background(), req)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
return err
}
if resp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), resp)
return errors.New(resp.ErrMsg)
}
return nil
}
func joinTestDepartment(operationID, userID, departmentID string) error {
defer func() {
log.NewInfo(operationID, utils.GetSelfFuncName(), userID)
}()
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := organizationRpc.NewOrganizationClient(etcdConn)
req := &organizationRpc.CreateDepartmentMemberReq{
DepartmentMember: &commonPb.DepartmentMember{
UserID: userID,
DepartmentID: departmentID,
Position: randomPosition(),
},
OperationID: operationID,
OpUserID: config.Config.Manager.AppManagerUid[0],
}
resp, err := client.CreateDepartmentMember(context.Background(), req)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
return err
}
if resp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), resp)
return errors.New(resp.ErrMsg)
}
return nil
}
func GetDepartmentGroupIDList(operationID, departmentID string) ([]string, error) {
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
client := organizationRpc.NewOrganizationClient(etcdConn)
req := organizationRpc.GetDepartmentParentIDListReq{
DepartmentID: departmentID,
OperationID: operationID,
}
resp, err := client.GetDepartmentParentIDList(context.Background(), &req)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), req.String())
return nil, err
}
if resp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), resp)
return nil, errors.New(resp.ErrMsg)
}
resp.ParentIDList = append(resp.ParentIDList, departmentID)
getDepartmentRelatedGroupIDListReq := organizationRpc.GetDepartmentRelatedGroupIDListReq{OperationID: operationID, DepartmentIDList: resp.ParentIDList}
getDepartmentParentIDListResp, err := client.GetDepartmentRelatedGroupIDList(context.Background(), &getDepartmentRelatedGroupIDListReq)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), getDepartmentRelatedGroupIDListReq.String())
return nil, err
}
if getDepartmentParentIDListResp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), getDepartmentParentIDListResp)
return nil, errors.New(getDepartmentParentIDListResp.ErrMsg)
}
return getDepartmentParentIDListResp.GroupIDList, nil
}
func joinGroups(operationID, userID, userName string, groupIDList []string) {
defer func() {
log.NewInfo(operationID, utils.GetSelfFuncName(), userID, groupIDList)
}()
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := groupRpc.NewGroupClient(etcdConn)
for _, groupID := range groupIDList {
req := &groupRpc.InviteUserToGroupReq{
OperationID: operationID,
GroupID: groupID,
Reason: "register auto join",
InvitedUserIDList: []string{userID},
OpUserID: userID,
}
resp, err := client.InviteUserToGroup(context.Background(), req)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), req.String())
continue
}
if resp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), resp)
continue
}
onboardingProcessNotification(operationID, userID, groupID)
}
}
// welcome user join department notification
func onboardingProcessNotification(operationID, userID, groupID string) {
defer func() {
log.NewInfo(operationID, utils.GetSelfFuncName(), userID, groupID)
}()
var tips commonPb.TipsComm
tips.DefaultTips = config.Config.Notification.JoinDepartmentNotification.DefaultTips.Tips
content, err := proto.Marshal(&tips)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error(), "proto marshal failed")
return
}
notification := &msg.NotificationMsg{
SendID: userID,
RecvID: groupID,
Content: content,
MsgFrom: constant.UserMsgType,
ContentType: constant.Text,
SessionType: constant.SingleChatType,
OperationID: operationID,
}
// notification user join group
msg.Notification(notification)
}
func randomEnglishName() string {
l := []string{"abandon", "entail", "nebula", "shrink", "accumulate", "etch", "nostalgia", "slide",
"feudal", "adverse", "exploit", "occupy", "solve", "amazing", "fantasy", "orchid", "spiky", "approve", "flap"}
rand.Seed(time.Now().UnixNano())
index := rand.Intn(len(l) - 1)
fmt.Println(index)
return l[index]
}
func randomPosition() string {
l := []string{"Golang工程师", "前端工程师", "后端工程师", "产品经理", "测试开发工程师", "运维开发工程师"}
rand.Seed(time.Now().UnixNano())
index := rand.Intn(len(l) - 1)
fmt.Println(index)
return l[index]
}

View File

@ -21,7 +21,7 @@ type paramsVerificationCode struct {
Email string `json:"email"`
PhoneNumber string `json:"phoneNumber"`
OperationID string `json:"operationID" binding:"required"`
UsedFor int `json:"usedFor"`
UsedFor int `json:"usedFor"`
}
func SendVerificationCode(c *gin.Context) {
@ -62,7 +62,7 @@ func SendVerificationCode(c *gin.Context) {
}
rand.Seed(time.Now().UnixNano())
code := 100000 + rand.Intn(900000)
log.NewInfo(params.OperationID, params.UsedFor,"begin store redis", accountKey, code)
log.NewInfo(params.OperationID, params.UsedFor, "begin store redis", accountKey, code)
err := db.DB.SetAccountCode(accountKey, code, config.Config.Demo.CodeTTL)
if err != nil {
log.NewError(params.OperationID, "set redis error", accountKey, "err", err.Error())
@ -77,7 +77,7 @@ func SendVerificationCode(c *gin.Context) {
m.SetHeader(`Subject`, config.Config.Demo.Mail.Title)
m.SetBody(`text/html`, fmt.Sprintf("%d", code))
if err := gomail.NewDialer(config.Config.Demo.Mail.SmtpAddr, config.Config.Demo.Mail.SmtpPort, config.Config.Demo.Mail.SenderMail, config.Config.Demo.Mail.SenderAuthorizationCode).DialAndSend(m); err != nil {
log.ErrorByKv("send mail error", account, "err", err.Error())
log.Error(params.OperationID, "send mail error", account, err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.MailSendCodeErr, "errMsg": ""})
return
}

View File

@ -84,6 +84,8 @@ func SetPassword(c *gin.Context) {
return
}
log.Info(params.OperationID, "end setPassword", account, params.Password)
// demo onboarding
onboardingProcess(params.OperationID, account, params.Name)
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMRegisterResp.UserToken})
return
}

View File

@ -35,14 +35,14 @@ func Verify(c *gin.Context) {
}
if params.VerificationCode == config.Config.Demo.SuperCode {
log.InfoByKv("Super Code Verified successfully", account)
log.NewInfo(params.OperationID, "Super Code Verified successfully", account)
data := make(map[string]interface{})
data["account"] = account
data["verificationCode"] = params.VerificationCode
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "Verified successfully!", "data": data})
return
}
log.NewInfo("0", " params.VerificationCode != config.Config.Demo.SuperCode", params.VerificationCode, config.Config.Demo)
log.NewInfo(params.OperationID, " params.VerificationCode != config.Config.Demo.SuperCode", params.VerificationCode, config.Config.Demo)
log.NewInfo(params.OperationID, "begin get form redis", account)
if params.UsedFor == 0 {
params.UsedFor = constant.VerificationCodeForRegister

View File

@ -2,6 +2,7 @@ package gate
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/statistics"
"fmt"
@ -10,12 +11,14 @@ import (
)
var (
rwLock *sync.RWMutex
validate *validator.Validate
ws WServer
rpcSvr RPCServer
sendMsgCount uint64
userCount uint64
rwLock *sync.RWMutex
validate *validator.Validate
ws WServer
rpcSvr RPCServer
sendMsgAllCount uint64
sendMsgFailedCount uint64
sendMsgSuccessCount uint64
userCount uint64
)
func Init(rpcPort, wsPort int) {
@ -23,8 +26,8 @@ func Init(rpcPort, wsPort int) {
rwLock = new(sync.RWMutex)
validate = validator.New()
statistics.NewStatistics(&sendMsgCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", sendMsgCount), 300)
statistics.NewStatistics(&userCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second add user conn", userCount), 300)
statistics.NewStatistics(&sendMsgAllCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
statistics.NewStatistics(&userCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second add user conn", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
ws.onInit(wsPort)
rpcSvr.onInit(rpcPort)
}

View File

@ -14,9 +14,7 @@ import (
"encoding/gob"
"github.com/golang/protobuf/proto"
"github.com/gorilla/websocket"
"google.golang.org/grpc"
"runtime"
"strconv"
"strings"
)
@ -62,7 +60,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
ws.pullMsgBySeqListReq(conn, &m)
default:
}
log.NewInfo("", "goroutine num is ", runtime.NumGoroutine())
log.NewInfo(m.OperationID, "goroutine num is ", runtime.NumGoroutine())
}
func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier, m.Data)
@ -71,9 +69,6 @@ func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
rpcReq.UserID = m.SendID
rpcReq.OperationID = m.OperationID
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
if grpcConn == nil {
log.ErrorByKv("get grpcConn err", rpcReq.OperationID, "args", m)
}
msgClient := pbChat.NewChatClient(grpcConn)
rpcReply, err := msgClient.GetMaxAndMinSeq(context.Background(), &rpcReq)
if err != nil {
@ -82,7 +77,7 @@ func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
nReply.ErrMsg = err.Error()
ws.getSeqResp(conn, m, nReply)
} else {
log.InfoByKv("rpc call success to getSeqReq", rpcReq.OperationID, "replyData", rpcReply.String())
log.NewInfo(rpcReq.OperationID, "rpc call success to getSeqReq", rpcReply.String())
ws.getSeqResp(conn, m, rpcReply)
}
}
@ -148,7 +143,7 @@ func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullM
}
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
sendMsgCount++
sendMsgAllCount++
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, m.Data)
nReply := new(pbChat.SendMsgResp)
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg)
@ -205,21 +200,15 @@ func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendSignalMsg)
if isPass {
signalResp := pbRtc.SignalResp{}
//isPass2, errCode2, errMsg2, signalResp, msgData := ws.signalMessageAssemble(pData.(*sdk_ws.SignalReq), m.OperationID)
connGrpc, err := grpc.Dial(config.Config.Rtc.Address+":"+strconv.Itoa(config.Config.Rtc.Port), grpc.WithInsecure())
if err != nil {
log.NewError(m.OperationID, utils.GetSelfFuncName(), "grpc.Dial failed", err.Error())
ws.sendSignalMsgResp(conn, 204, "create grpc failed"+err.Error(), m, nil)
return
}
rtcClient := pbRtc.NewRtcServiceClient(connGrpc)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImRealTimeCommName)
rtcClient := pbRtc.NewRtcServiceClient(etcdConn)
req := &pbRtc.SignalMessageAssembleReq{
SignalReq: pData.(*pbRtc.SignalReq),
OperationID: m.OperationID,
}
respPb, err := rtcClient.SignalMessageAssemble(context.Background(), req)
if err != nil {
log.NewError(m.OperationID, utils.GetSelfFuncName(), "SignalMessageAssemble", err.Error(), config.Config.Rtc.Address+":"+strconv.Itoa(config.Config.Rtc.Port))
log.NewError(m.OperationID, utils.GetSelfFuncName(), "SignalMessageAssemble", err.Error(), config.Config.RpcRegisterName.OpenImRealTimeCommName)
ws.sendSignalMsgResp(conn, 204, "grpc SignalMessageAssemble failed: "+err.Error(), m, &signalResp)
return
}

View File

@ -11,9 +11,9 @@ import (
"bytes"
"context"
"encoding/gob"
"fmt"
"github.com/golang/protobuf/proto"
"net"
"strconv"
"strings"
"github.com/gorilla/websocket"
@ -34,29 +34,41 @@ func (r *RPCServer) onInit(rpcPort int) {
r.etcdAddr = config.Config.Etcd.EtcdAddr
}
func (r *RPCServer) run() {
ip := utils.ServerIP
registerAddress := ip + ":" + utils.IntToString(r.rpcPort)
listener, err := net.Listen("tcp", registerAddress)
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
address := listenIP + ":" + strconv.Itoa(r.rpcPort)
listener, err := net.Listen("tcp", address)
if err != nil {
log.ErrorByArgs(fmt.Sprintf("fail to listening consumer, err:%v\n", err))
return
panic("listening err:" + err.Error() + r.rpcRegisterName)
}
defer listener.Close()
srv := grpc.NewServer()
defer srv.GracefulStop()
pbRelay.RegisterOnlineMessageRelayServiceServer(srv, r)
err = getcdv3.RegisterEtcd4Unique(r.etcdSchema, strings.Join(r.etcdAddr, ","), ip, r.rpcPort, r.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd4Unique(r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName, 10)
if err != nil {
log.ErrorByKv("register push message rpc to etcd err", "", "err", err.Error())
log.Error("", "register push message rpc to etcd err", "", "err", err.Error(), r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName)
}
err = srv.Serve(listener)
if err != nil {
log.ErrorByKv("push message rpc listening err", "", "err", err.Error())
log.Error("", "push message rpc listening err", "", "err", err.Error())
return
}
}
func (r *RPCServer) OnlinePushMsg(_ context.Context, in *pbRelay.OnlinePushMsgReq) (*pbRelay.OnlinePushMsgResp, error) {
log.InfoByKv("PushMsgToUser is arriving", in.OperationID, "args", in.String())
log.NewInfo(in.OperationID, "PushMsgToUser is arriving", in.String())
var resp []*pbRelay.SingleMsgToUser
msgBytes, _ := proto.Marshal(in.MsgData)
mReply := Resp{
@ -93,7 +105,7 @@ func (r *RPCServer) OnlinePushMsg(_ context.Context, in *pbRelay.OnlinePushMsgRe
}
}
if !tag {
log.NewError(in.OperationID, "push err ,no matched ws conn not in map", in.String())
log.NewDebug(in.OperationID, "push err ,no matched ws conn not in map", in.String())
}
return &pbRelay.OnlinePushMsgResp{
Resp: resp,
@ -130,12 +142,12 @@ func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUser
func sendMsgToUser(conn *UserConn, bMsg []byte, in *pbRelay.OnlinePushMsgReq, RecvPlatForm, RecvID string) (ResultCode int64) {
err := ws.writeMsg(conn, websocket.BinaryMessage, bMsg)
if err != nil {
log.ErrorByKv("PushMsgToUser is failed By Ws", "", "Addr", conn.RemoteAddr().String(),
log.NewError(in.OperationID, "PushMsgToUser is failed By Ws", "Addr", conn.RemoteAddr().String(),
"error", err, "senderPlatform", constant.PlatformIDToName(in.MsgData.SenderPlatformID), "recvPlatform", RecvPlatForm, "args", in.String(), "recvID", RecvID)
ResultCode = -2
return ResultCode
} else {
log.InfoByKv("PushMsgToUser is success By Ws", in.OperationID, "args", in.String(), "recvPlatForm", RecvPlatForm, "recvID", RecvID)
log.NewDebug(in.OperationID, "PushMsgToUser is success By Ws", "args", in.String(), "recvPlatForm", RecvPlatForm, "recvID", RecvID)
ResultCode = 0
return ResultCode
}

View File

@ -62,11 +62,11 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
case constant.WSSendMsg:
data := open_im_sdk.MsgData{}
if err := proto.Unmarshal(m.Data, &data); err != nil {
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "Decode Data struct err", err.Error(), r)
return false, 203, err.Error(), nil
}
if err := validate.Struct(data); err != nil {
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "data args validate err", err.Error(), r)
return false, 204, err.Error(), nil
}
@ -74,11 +74,11 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
case constant.WSSendSignalMsg:
data := pbRtc.SignalReq{}
if err := proto.Unmarshal(m.Data, &data); err != nil {
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "Decode Data struct err", err.Error(), r)
return false, 203, err.Error(), nil
}
if err := validate.Struct(data); err != nil {
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "data args validate err", err.Error(), r)
return false, 204, err.Error(), nil
}
@ -86,11 +86,11 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
case constant.WSPullMsgBySeqList:
data := open_im_sdk.PullMessageBySeqListReq{}
if err := proto.Unmarshal(m.Data, &data); err != nil {
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "Decode Data struct err", err.Error(), r)
return false, 203, err.Error(), nil
}
if err := validate.Struct(data); err != nil {
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
log.Error("", "data args validate err", err.Error(), r)
return false, 204, err.Error(), nil
}
@ -114,140 +114,3 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
//} else
}
//func (ws *WServer) signalMessageAssemble(s *open_im_sdk.SignalReq, operationID string) (isPass bool, errCode int32, errMsg string, r *open_im_sdk.SignalResp, msgData *open_im_sdk.MsgData) {
// var msg open_im_sdk.MsgData
// var resp open_im_sdk.SignalResp
// media := open_im_media.NewMedia()
// msg.MsgFrom = constant.UserMsgType
// msg.ContentType = constant.SignalingNotification
// reqData, e := proto.Marshal(s)
// if e != nil {
// return false, 201, e.Error(), nil, nil
// }
// msg.Content = reqData
// msg.CreateTime = utils.GetCurrentTimestampByMill()
// options := make(map[string]bool, 6)
// utils.SetSwitchFromOptions(options, constant.IsHistory, false)
// utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
// utils.SetSwitchFromOptions(options, constant.IsSenderSync, true)
// utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
// utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false)
// utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
// utils.SetSwitchFromOptions(options, constant.IsOfflinePush, true)
// msg.Options = options
// switch payload := s.Payload.(type) {
// case *open_im_sdk.SignalReq_Invite:
// token, liveURL, err2 := media.GetJoinToken(payload.Invite.Invitation.RoomID, payload.Invite.Invitation.InviterUserID, operationID, payload.Invite.Participant)
// if err2 != nil {
// return false, 202, err2.Error(), nil, nil
// }
// invite := open_im_sdk.SignalResp_Invite{&open_im_sdk.SignalInviteReply{
// Token: token,
// RoomID: payload.Invite.Invitation.RoomID,
// LiveURL: liveURL,
// }}
// resp.Payload = &invite
// msg.SenderPlatformID = payload.Invite.Invitation.PlatformID
// msg.SessionType = payload.Invite.Invitation.SessionType
// msg.OfflinePushInfo = payload.Invite.OfflinePushInfo
// msg.SendID = payload.Invite.Invitation.InviterUserID
// if len(payload.Invite.Invitation.InviteeUserIDList) > 0 {
// msg.RecvID = payload.Invite.Invitation.InviteeUserIDList[0]
// } else {
// return false, 203, errors.New("InviteeUserIDList is null").Error(), nil, nil
// }
// msg.ClientMsgID = utils.GetMsgID(payload.Invite.Invitation.InviterUserID)
// return true, 0, "", &resp, &msg
// case *open_im_sdk.SignalReq_InviteInGroup:
// token, liveURL, err2 := media.GetJoinToken(payload.InviteInGroup.Invitation.RoomID, payload.InviteInGroup.Invitation.InviterUserID, operationID, payload.InviteInGroup.Participant)
// if err2 != nil {
// return false, 204, err2.Error(), nil, nil
// }
// inviteGroup := open_im_sdk.SignalResp_InviteInGroup{&open_im_sdk.SignalInviteInGroupReply{
// RoomID: payload.InviteInGroup.Invitation.RoomID,
// Token: token,
// LiveURL: liveURL,
// }}
// resp.Payload = &inviteGroup
// msg.SenderPlatformID = payload.InviteInGroup.Invitation.PlatformID
// msg.SessionType = payload.InviteInGroup.Invitation.SessionType
// msg.OfflinePushInfo = payload.InviteInGroup.OfflinePushInfo
// msg.SendID = payload.InviteInGroup.Invitation.InviterUserID
// if len(payload.InviteInGroup.Invitation.InviteeUserIDList) > 0 {
// msg.GroupID = payload.InviteInGroup.Invitation.GroupID
// } else {
// return false, 205, errors.New("InviteeUserIDList is null").Error(), nil, nil
// }
// msg.ClientMsgID = utils.GetMsgID(payload.InviteInGroup.Invitation.InviterUserID)
//
// return true, 0, "", &resp, &msg
// case *open_im_sdk.SignalReq_Cancel:
// cancel := open_im_sdk.SignalResp_Cancel{&open_im_sdk.SignalCancelReply{}}
// resp.Payload = &cancel
// msg.OfflinePushInfo = payload.Cancel.OfflinePushInfo
// msg.SendID = payload.Cancel.Invitation.InviterUserID
// msg.SenderPlatformID = payload.Cancel.Invitation.PlatformID
// msg.SessionType = payload.Cancel.Invitation.SessionType
// if len(payload.Cancel.Invitation.InviteeUserIDList) > 0 {
// switch payload.Cancel.Invitation.SessionType {
// case constant.SingleChatType:
// msg.RecvID = payload.Cancel.Invitation.InviteeUserIDList[0]
// case constant.GroupChatType:
// msg.GroupID = payload.Cancel.Invitation.GroupID
// }
// } else {
// return false, 206, errors.New("InviteeUserIDList is null").Error(), nil, nil
// }
// msg.ClientMsgID = utils.GetMsgID(payload.Cancel.OpUserID)
// return true, 0, "", &resp, &msg
// case *open_im_sdk.SignalReq_Accept:
// token, liveURL, err2 := media.GetJoinToken(payload.Accept.Invitation.RoomID, payload.Accept.OpUserID, operationID, payload.Accept.Participant)
// if err2 != nil {
// return false, 207, err2.Error(), nil, nil
// }
// accept := open_im_sdk.SignalResp_Accept{&open_im_sdk.SignalAcceptReply{
// Token: token,
// LiveURL: liveURL,
// RoomID: payload.Accept.Invitation.RoomID,
// }}
// resp.Payload = &accept
// msg.OfflinePushInfo = payload.Accept.OfflinePushInfo
// msg.SendID = payload.Accept.OpUserID
// msg.SenderPlatformID = payload.Accept.Invitation.PlatformID
// msg.SessionType = payload.Accept.Invitation.SessionType
// if len(payload.Accept.Invitation.InviteeUserIDList) > 0 {
// switch payload.Accept.Invitation.SessionType {
// case constant.SingleChatType:
// msg.RecvID = payload.Accept.Invitation.InviterUserID
// case constant.GroupChatType:
// msg.GroupID = payload.Accept.Invitation.GroupID
// }
// } else {
// return false, 208, errors.New("InviteeUserIDList is null").Error(), nil, nil
// }
// msg.ClientMsgID = utils.GetMsgID(payload.Accept.OpUserID)
// return true, 0, "", &resp, &msg
// case *open_im_sdk.SignalReq_HungUp:
// case *open_im_sdk.SignalReq_Reject:
// reject := open_im_sdk.SignalResp_Reject{&open_im_sdk.SignalRejectReply{}}
// resp.Payload = &reject
// msg.OfflinePushInfo = payload.Reject.OfflinePushInfo
// msg.SendID = payload.Reject.OpUserID
// msg.SenderPlatformID = payload.Reject.Invitation.PlatformID
// msg.SessionType = payload.Reject.Invitation.SessionType
// if len(payload.Reject.Invitation.InviteeUserIDList) > 0 {
// switch payload.Reject.Invitation.SessionType {
// case constant.SingleChatType:
// msg.RecvID = payload.Reject.Invitation.InviterUserID
// case constant.GroupChatType:
// msg.GroupID = payload.Reject.Invitation.GroupID
// }
// } else {
// return false, 209, errors.New("InviteeUserIDList is null").Error(), nil, nil
// }
// msg.ClientMsgID = utils.GetMsgID(payload.Reject.OpUserID)
// return true, 0, "", &resp, &msg
// }
// return false, 210, errors.New("InviteeUserIDList is null").Error(), nil, nil
//}

View File

@ -45,7 +45,7 @@ func (ws *WServer) run() {
http.HandleFunc("/", ws.wsHandler) //Get request from client to handle by wsHandler
err := http.ListenAndServe(ws.wsAddr, nil) //Start listening
if err != nil {
log.ErrorByKv("Ws listening err", "", "err", err.Error())
panic("Ws listening err:" + err.Error())
}
}
@ -54,7 +54,7 @@ func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
conn, err := ws.wsUpGrader.Upgrade(w, r, nil) //Conn is obtained through the upgraded escalator
if err != nil {
log.ErrorByKv("upgrade http conn err", "", "err", err, query)
log.Error("", "upgrade http conn err", err, query)
return
} else {
//Connection mapping relationship,
@ -62,6 +62,7 @@ func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
//Initialize a lock for each user
newConn := &UserConn{conn, new(sync.Mutex)}
userCount++
ws.addUserConn(query["sendID"][0], int32(utils.StringToInt64(query["platformID"][0])), newConn, query["token"][0])
go ws.readMsg(newConn)
}
@ -76,7 +77,8 @@ func (ws *WServer) readMsg(conn *UserConn) {
}
if err != nil {
uid, platform := ws.getUserUid(conn)
log.ErrorByKv("WS ReadMsg error", "", "userIP", conn.RemoteAddr().String(), "userUid", uid, "platform", platform, "error", err.Error())
log.Error("", "WS ReadMsg error", "userIP", conn.RemoteAddr().String(), "userUid", uid, "platform", platform, "error", err.Error())
userCount--
ws.delUserConn(conn)
return
} else {
@ -189,7 +191,6 @@ func (ws *WServer) addUserConn(uid string, platformID int32, conn *UserConn, tok
count = count + len(v)
}
log.Debug(operationID, "WS Add operation", "", "wsUser added", ws.wsUserToConn, "connection_uid", uid, "connection_platform", constant.PlatformIDToName(platformID), "online_user_num", len(ws.wsUserToConn), "online_conn_num", count)
userCount = uint64(len(ws.wsUserToConn))
}
@ -213,11 +214,10 @@ func (ws *WServer) delUserConn(conn *UserConn) {
for _, v := range ws.wsUserToConn {
count = count + len(v)
}
log.NewWarn(operationID, "WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "disconnection_uid", uid, "disconnection_platform", platform, "online_user_num", len(ws.wsUserToConn), "online_conn_num", count)
log.Debug(operationID, "WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "disconnection_uid", uid, "disconnection_platform", platform, "online_user_num", len(ws.wsUserToConn), "online_conn_num", count)
} else {
log.NewWarn(operationID, "WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "disconnection_uid", uid, "disconnection_platform", platform, "online_user_num", len(ws.wsUserToConn))
log.Debug(operationID, "WS delete operation", "", "wsUser deleted", ws.wsUserToConn, "disconnection_uid", uid, "disconnection_platform", platform, "online_user_num", len(ws.wsUserToConn))
}
userCount = uint64(len(ws.wsUserToConn))
delete(ws.wsConnToUser, conn)
}

View File

@ -2,20 +2,40 @@ package logic
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/kafka"
"Open_IM/pkg/common/log"
"Open_IM/pkg/statistics"
"fmt"
"sync"
)
const OnlineTopicBusy = 1
const OnlineTopicVacancy = 0
var (
persistentCH PersistentConsumerHandler
historyCH HistoryConsumerHandler
producer *kafka.Producer
persistentCH PersistentConsumerHandler
historyCH OnlineHistoryConsumerHandler
offlineHistoryCH OfflineHistoryConsumerHandler
producer *kafka.Producer
cmdCh chan Cmd2Value
onlineTopicStatus int
w *sync.Mutex
singleMsgSuccessCount uint64
groupMsgCount uint64
singleMsgFailedCount uint64
)
func Init() {
cmdCh = make(chan Cmd2Value, 10000)
w = new(sync.Mutex)
persistentCH.Init()
historyCH.Init()
historyCH.Init(cmdCh)
onlineTopicStatus = OnlineTopicVacancy
log.Debug("come msg transfer ts", config.Config.Kafka.ConsumerGroupID.MsgToMongoOffline, config.Config.Kafka.Ws2mschatOffline.Topic)
offlineHistoryCH.Init(cmdCh)
statistics.NewStatistics(&singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
statistics.NewStatistics(&groupMsgCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d second groupMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic)
}
func Run() {
@ -26,4 +46,15 @@ func Run() {
fmt.Println("not start mysql consumer")
}
go historyCH.historyConsumerGroup.RegisterHandleAndConsumer(&historyCH)
go offlineHistoryCH.historyConsumerGroup.RegisterHandleAndConsumer(&offlineHistoryCH)
}
func SetOnlineTopicStatus(status int) {
w.Lock()
defer w.Unlock()
onlineTopicStatus = status
}
func GetOnlineTopicStatus() int {
w.Lock()
defer w.Unlock()
return onlineTopicStatus
}

View File

@ -0,0 +1,126 @@
package logic
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
kfk "Open_IM/pkg/common/kafka"
"Open_IM/pkg/common/log"
pbMsg "Open_IM/pkg/proto/chat"
"Open_IM/pkg/utils"
"github.com/Shopify/sarama"
"github.com/golang/protobuf/proto"
"time"
)
type OfflineHistoryConsumerHandler struct {
msgHandle map[string]fcb
cmdCh chan Cmd2Value
historyConsumerGroup *kfk.MConsumerGroup
}
func (mc *OfflineHistoryConsumerHandler) Init(cmdCh chan Cmd2Value) {
mc.msgHandle = make(map[string]fcb)
mc.cmdCh = cmdCh
mc.msgHandle[config.Config.Kafka.Ws2mschatOffline.Topic] = mc.handleChatWs2Mongo
mc.historyConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V0_10_2_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.Ws2mschatOffline.Topic},
config.Config.Kafka.Ws2mschatOffline.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMongoOffline)
}
func (mc *OfflineHistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) {
now := time.Now()
msgFromMQ := pbMsg.MsgDataToMQ{}
err := proto.Unmarshal(msg, &msgFromMQ)
if err != nil {
log.Error("msg_transfer Unmarshal msg err", "", "msg", string(msg), "err", err.Error())
return
}
operationID := msgFromMQ.OperationID
log.NewInfo(operationID, "msg come mongo!!!", "", "msg", string(msg))
//Control whether to store offline messages (mongo)
isHistory := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsHistory)
//Control whether to store history messages (mysql)
isPersist := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsPersistent)
isSenderSync := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsSenderSync)
switch msgFromMQ.MsgData.SessionType {
case constant.SingleChatType:
log.NewDebug(msgFromMQ.OperationID, "msg_transfer msg type = SingleChatType", isHistory, isPersist)
if isHistory {
err := saveUserChat(msgKey, &msgFromMQ)
if err != nil {
singleMsgFailedCount++
log.NewError(operationID, "single data insert to mongo err", err.Error(), msgFromMQ.String())
return
}
singleMsgSuccessCount++
log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", time.Since(now))
}
if !isSenderSync && msgKey == msgFromMQ.MsgData.SendID {
} else {
go sendMessageToPush(&msgFromMQ, msgKey)
}
log.NewDebug(operationID, "saveSingleMsg cost time ", time.Since(now))
case constant.GroupChatType:
log.NewDebug(msgFromMQ.OperationID, "msg_transfer msg type = GroupChatType", isHistory, isPersist)
if isHistory {
err := saveUserChat(msgFromMQ.MsgData.RecvID, &msgFromMQ)
if err != nil {
log.NewError(operationID, "group data insert to mongo err", msgFromMQ.String(), msgFromMQ.MsgData.RecvID, err.Error())
return
}
groupMsgCount++
}
go sendMessageToPush(&msgFromMQ, msgFromMQ.MsgData.RecvID)
log.NewDebug(operationID, "saveGroupMsg cost time ", time.Since(now))
case constant.NotificationChatType:
log.NewDebug(msgFromMQ.OperationID, "msg_transfer msg type = NotificationChatType", isHistory, isPersist)
if isHistory {
err := saveUserChat(msgKey, &msgFromMQ)
if err != nil {
log.NewError(operationID, "single data insert to mongo err", err.Error(), msgFromMQ.String())
return
}
log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", time.Since(now))
}
if !isSenderSync && msgKey == msgFromMQ.MsgData.SendID {
} else {
go sendMessageToPush(&msgFromMQ, msgKey)
}
log.NewDebug(operationID, "saveUserChat cost time ", time.Since(now))
default:
log.NewError(msgFromMQ.OperationID, "SessionType error", msgFromMQ.String())
return
}
log.NewDebug(msgFromMQ.OperationID, "msg_transfer handle topic data to database success...", msgFromMQ.String())
}
func (OfflineHistoryConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
func (OfflineHistoryConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
func (mc *OfflineHistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
claim sarama.ConsumerGroupClaim) error { // a instance in the consumer group
//log.NewDebug("", "offline new session msg come", claim.HighWaterMarkOffset(), claim.Topic(), claim.Partition())
//for msg := range claim.Messages() {
// log.NewDebug("", "kafka get info to delay mongo", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "offline")
// //mc.msgHandle[msg.Topic](msg.Value, string(msg.Key))
//}
for msg := range claim.Messages() {
if GetOnlineTopicStatus() == OnlineTopicVacancy {
log.NewDebug("", "vacancy offline kafka get info to mongo", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
mc.msgHandle[msg.Topic](msg.Value, string(msg.Key))
sess.MarkMessage(msg, "")
} else {
select {
case <-mc.cmdCh:
log.NewDebug("", "cmd offline kafka get info to mongo", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
case <-time.After(time.Millisecond * time.Duration(100)):
log.NewDebug("", "timeout offline kafka get info to mongo", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
}
mc.msgHandle[msg.Topic](msg.Value, string(msg.Key))
sess.MarkMessage(msg, "")
}
}
return nil
}

View File

@ -8,9 +8,9 @@ import (
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbMsg "Open_IM/pkg/proto/chat"
pbPush "Open_IM/pkg/proto/push"
"Open_IM/pkg/statistics"
"Open_IM/pkg/utils"
"context"
"errors"
"github.com/Shopify/sarama"
"github.com/golang/protobuf/proto"
"strings"
@ -18,27 +18,50 @@ import (
)
type fcb func(msg []byte, msgKey string)
type HistoryConsumerHandler struct {
type Cmd2Value struct {
Cmd int
Value interface{}
}
type OnlineHistoryConsumerHandler struct {
msgHandle map[string]fcb
historyConsumerGroup *kfk.MConsumerGroup
singleMsgCount uint64
groupMsgCount uint64
cmdCh chan Cmd2Value
}
func (mc *HistoryConsumerHandler) Init() {
statistics.NewStatistics(&mc.singleMsgCount, config.Config.ModuleName.MsgTransferName, "singleMsgCount insert to mongo ", 300)
statistics.NewStatistics(&mc.groupMsgCount, config.Config.ModuleName.MsgTransferName, "groupMsgCount insert to mongo ", 300)
mc.msgHandle = make(map[string]fcb)
mc.msgHandle[config.Config.Kafka.Ws2mschat.Topic] = mc.handleChatWs2Mongo
mc.historyConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V0_10_2_0,
func (och *OnlineHistoryConsumerHandler) Init(cmdCh chan Cmd2Value) {
och.msgHandle = make(map[string]fcb)
och.cmdCh = cmdCh
och.msgHandle[config.Config.Kafka.Ws2mschat.Topic] = och.handleChatWs2Mongo
och.historyConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V0_10_2_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.Ws2mschat.Topic},
config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMongo)
}
func (och *OnlineHistoryConsumerHandler) TriggerCmd(status int) {
operationID := utils.OperationIDGenerator()
err := sendCmd(och.cmdCh, Cmd2Value{Cmd: status, Value: ""}, 1)
if err != nil {
log.Error(operationID, "TriggerCmd failed ", err.Error(), status)
return
}
log.Debug(operationID, "TriggerCmd success", status)
func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) {
}
func sendCmd(ch chan Cmd2Value, value Cmd2Value, timeout int64) error {
var flag = 0
select {
case ch <- value:
flag = 1
case <-time.After(time.Second * time.Duration(timeout)):
flag = 2
}
if flag == 1 {
return nil
} else {
return errors.New("send cmd timeout")
}
}
func (och *OnlineHistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string) {
now := time.Now()
msgFromMQ := pbMsg.MsgDataToMQ{}
err := proto.Unmarshal(msg, &msgFromMQ)
@ -59,10 +82,11 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string)
if isHistory {
err := saveUserChat(msgKey, &msgFromMQ)
if err != nil {
singleMsgFailedCount++
log.NewError(operationID, "single data insert to mongo err", err.Error(), msgFromMQ.String())
return
}
mc.singleMsgCount++
singleMsgSuccessCount++
log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", time.Since(now))
}
if !isSenderSync && msgKey == msgFromMQ.MsgData.SendID {
@ -78,7 +102,7 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string)
log.NewError(operationID, "group data insert to mongo err", msgFromMQ.String(), msgFromMQ.MsgData.RecvID, err.Error())
return
}
mc.groupMsgCount++
groupMsgCount++
}
go sendMessageToPush(&msgFromMQ, msgFromMQ.MsgData.RecvID)
case constant.NotificationChatType:
@ -89,7 +113,6 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string)
log.NewError(operationID, "single data insert to mongo err", err.Error(), msgFromMQ.String())
return
}
mc.singleMsgCount++
log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", time.Since(now))
}
if !isSenderSync && msgKey == msgFromMQ.MsgData.SendID {
@ -104,14 +127,22 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string)
log.NewDebug(msgFromMQ.OperationID, "msg_transfer handle topic data to database success...", msgFromMQ.String())
}
func (HistoryConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
func (HistoryConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
func (mc *HistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
claim sarama.ConsumerGroupClaim) error {
func (OnlineHistoryConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
func (OnlineHistoryConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
func (och *OnlineHistoryConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
claim sarama.ConsumerGroupClaim) error { // a instance in the consumer group
log.NewDebug("", "online new session msg come", claim.HighWaterMarkOffset(), claim.Topic(), claim.Partition())
for msg := range claim.Messages() {
log.InfoByKv("kafka get info to mongo", "", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
mc.msgHandle[msg.Topic](msg.Value, string(msg.Key))
SetOnlineTopicStatus(OnlineTopicBusy)
//och.TriggerCmd(OnlineTopicBusy)
log.NewDebug("", "online kafka get info to mongo", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "online", msg.Offset, claim.HighWaterMarkOffset())
och.msgHandle[msg.Topic](msg.Value, string(msg.Key))
sess.MarkMessage(msg, "")
if claim.HighWaterMarkOffset()-msg.Offset <= 1 {
log.Debug("", "online msg consume end", claim.HighWaterMarkOffset(), msg.Offset)
SetOnlineTopicStatus(OnlineTopicVacancy)
och.TriggerCmd(OnlineTopicVacancy)
}
}
return nil
}
@ -134,10 +165,10 @@ func sendMessageToPush(message *pbMsg.MsgDataToMQ, pushToUserID string) {
log.Error(rpcPushMsg.OperationID, "rpc send failed", rpcPushMsg.OperationID, "push data", rpcPushMsg.String(), "err", err.Error())
pid, offset, err := producer.SendMessage(&mqPushMsg)
if err != nil {
log.Error("kafka send failed", mqPushMsg.OperationID, "send data", mqPushMsg.String(), "pid", pid, "offset", offset, "err", err.Error())
log.Error(message.OperationID, "kafka send failed", mqPushMsg.OperationID, "send data", mqPushMsg.String(), "pid", pid, "offset", offset, "err", err.Error())
}
} else {
log.Info("rpc send success", rpcPushMsg.OperationID, "push data", rpcPushMsg.String())
log.Info(message.OperationID, "rpc send success", rpcPushMsg.OperationID, "push data", rpcPushMsg.String())
}
}

View File

@ -51,7 +51,7 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(msg []byte, msgKey strin
tag = true
}
case constant.GroupChatType:
if msgKey == msgFromMQ.MsgData.SendID || utils.IsContain(msgFromMQ.MsgData.SendID, config.Config.Manager.AppManagerUid) {
if msgKey == msgFromMQ.MsgData.SendID {
tag = true
}
}
@ -70,7 +70,7 @@ func (PersistentConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error {
func (pc *PersistentConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
claim sarama.ConsumerGroupClaim) error {
for msg := range claim.Messages() {
log.InfoByKv("kafka get info to mysql", "", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
log.NewDebug("", "kafka get info to mysql", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
pc.msgHandle[msg.Topic](msg.Value, string(msg.Key))
sess.MarkMessage(msg, "")
}

View File

@ -19,7 +19,7 @@ var (
pushCh PushConsumerHandler
pushTerminal []int32
producer *kafka.Producer
count uint64
successCount uint64
)
func Init(rpcPort int) {
@ -30,7 +30,7 @@ func Init(rpcPort int) {
}
func init() {
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
statistics.NewStatistics(&count, config.Config.ModuleName.PushName, fmt.Sprintf("%d second push to msg_gateway count", 300), 300)
statistics.NewStatistics(&successCount, config.Config.ModuleName.PushName, fmt.Sprintf("%d second push to msg_gateway count", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
}
func Run() {

View File

@ -31,10 +31,10 @@ func (ms *PushConsumerHandler) Init() {
config.Config.Kafka.ConsumerGroupID.MsgToPush)
}
func (ms *PushConsumerHandler) handleMs2PsChat(msg []byte) {
log.InfoByKv("msg come from kafka And push!!!", "", "msg", string(msg))
log.NewDebug("", "msg come from kafka And push!!!", "msg", string(msg))
msgFromMQ := pbChat.PushMsgDataToMQ{}
if err := proto.Unmarshal(msg, &msgFromMQ); err != nil {
log.ErrorByKv("push Unmarshal msg err", "", "msg", string(msg), "err", err.Error())
log.Error("", "push Unmarshal msg err", "msg", string(msg), "err", err.Error())
return
}
//Call push module to send message to the user
@ -45,7 +45,7 @@ func (PushConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return
func (ms *PushConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession,
claim sarama.ConsumerGroupClaim) error {
for msg := range claim.Messages() {
log.InfoByKv("kafka get info to mysql", "", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
log.NewDebug("", "kafka get info to mysql", "msgTopic", msg.Topic, "msgPartition", msg.Partition, "msg", string(msg.Value))
ms.msgHandle[msg.Topic](msg.Value)
}
return nil

View File

@ -9,6 +9,7 @@ import (
"context"
"google.golang.org/grpc"
"net"
"strconv"
"strings"
)
@ -26,24 +27,37 @@ func (r *RPCServer) Init(rpcPort int) {
r.etcdAddr = config.Config.Etcd.EtcdAddr
}
func (r *RPCServer) run() {
ip := utils.ServerIP
registerAddress := ip + ":" + utils.IntToString(r.rpcPort)
listener, err := net.Listen("tcp", registerAddress)
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
address := listenIP + ":" + strconv.Itoa(r.rpcPort)
listener, err := net.Listen("tcp", address)
if err != nil {
log.ErrorByKv("push module rpc listening port err", "", "err", err.Error())
return
panic("listening err:" + err.Error() + r.rpcRegisterName)
}
defer listener.Close()
srv := grpc.NewServer()
defer srv.GracefulStop()
pbPush.RegisterPushMsgServiceServer(srv, r)
err = getcdv3.RegisterEtcd(r.etcdSchema, strings.Join(r.etcdAddr, ","), ip, r.rpcPort, r.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName, 10)
if err != nil {
log.ErrorByKv("register push module rpc to etcd err", "", "err", err.Error())
log.Error("", "register push module rpc to etcd err", err.Error(), r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName)
}
err = srv.Serve(listener)
if err != nil {
log.ErrorByKv("push module rpc start err", "", "err", err.Error())
log.Error("", "push module rpc start err", err.Error())
return
}
}

View File

@ -53,7 +53,7 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
}
}
log.NewInfo(pushMsg.OperationID, "push_result", wsResult, "sendData", pushMsg.MsgData)
count++
successCount++
if isOfflinePush && pushMsg.PushToUserID != pushMsg.MsgData.SendID {
for _, v := range wsResult {
if v.ResultCode == 0 {

View File

@ -35,22 +35,34 @@ func NewAdminCMSServer(port int) *adminCMSServer {
func (s *adminCMSServer) Run() {
log.NewInfo("0", "AdminCMS rpc start ")
ip := utils.ServerIP
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", registerAddress)
if err != nil {
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
return
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
log.NewInfo("0", "listen network success, ", registerAddress, listener)
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", address)
if err != nil {
panic("listening err:" + err.Error() + s.rpcRegisterName)
}
log.NewInfo("0", "listen network success, ", address, listener)
defer listener.Close()
//grpc server
srv := grpc.NewServer()
defer srv.GracefulStop()
//Service registers with etcd
pbAdminCMS.RegisterAdminCMSServer(srv, s)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
if err != nil {
log.NewError("0", "RegisterEtcd failed ", err.Error())
return
@ -83,5 +95,6 @@ func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLogi
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
return resp, openIMHttp.WrapError(constant.ErrTokenMalformed)
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}

View File

@ -79,11 +79,16 @@ func (rpc *rpcAuth) Run() {
operationID := utils.OperationIDGenerator()
log.NewInfo(operationID, "rpc auth start...")
address := utils.ServerIP + ":" + strconv.Itoa(rpc.rpcPort)
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
address := listenIP + ":" + strconv.Itoa(rpc.rpcPort)
listener, err := net.Listen("tcp", address)
if err != nil {
log.NewError(operationID, "listen network failed ", err.Error(), address)
return
panic("listening err:" + err.Error() + rpc.rpcRegisterName)
}
log.NewInfo(operationID, "listen network success, ", address, listener)
//grpc server
@ -92,13 +97,21 @@ func (rpc *rpcAuth) Run() {
//service registers with etcd
pbAuth.RegisterAuthServer(srv, rpc)
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
if err != nil {
log.NewError(operationID, "RegisterEtcd failed ", err.Error(),
rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName)
rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
return
}
log.NewInfo(operationID, "RegisterAuthServer ok ", rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName)
log.NewInfo(operationID, "RegisterAuthServer ok ", rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
err = srv.Serve(listener)
if err != nil {
log.NewError(operationID, "Serve failed ", err.Error())

View File

@ -11,10 +11,11 @@ import (
commonPb "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"google.golang.org/grpc"
"net"
"strconv"
"strings"
"google.golang.org/grpc"
)
type cacheServer struct {
@ -36,15 +37,19 @@ func NewCacheServer(port int) *cacheServer {
func (s *cacheServer) Run() {
log.NewInfo("0", "cacheServer rpc start ")
ip := utils.ServerIP
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", registerAddress)
if err != nil {
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
return
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
log.NewInfo("0", "listen network success, ", registerAddress, listener)
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", address)
if err != nil {
panic("listening err:" + err.Error() + s.rpcRegisterName)
}
log.NewInfo("0", "listen network success, ", address, listener)
defer listener.Close()
//grpc server
@ -58,7 +63,16 @@ func (s *cacheServer) Run() {
srv := grpc.NewServer()
defer srv.GracefulStop()
pbCache.RegisterCacheServer(srv, s)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
if err != nil {
log.NewError("0", "RegisterEtcd failed ", err.Error())
return
@ -75,6 +89,7 @@ func SyncDB2Cache() error {
var err error
log.NewInfo("0", utils.GetSelfFuncName())
userList, err := imdb.GetAllUser()
log.NewDebug("", utils.GetSelfFuncName(), "userList", userList)
if err != nil {
return utils.Wrap(err, "")
}
@ -82,7 +97,7 @@ func SyncDB2Cache() error {
err = updateAllFriendToCache(userList)
err = updateAllBlackListToCache(userList)
err = updateAllGroupMemberListToCache()
return err
return utils.Wrap(err, "")
}
func DelRelationCache() {}
@ -103,10 +118,10 @@ func updateAllUserToCache(userList []db.User) error {
}
m, err := utils.Pb2Map(userInfoPb)
if err != nil {
log.NewError("", utils.GetSelfFuncName(), err.Error())
log.NewWarn("", utils.GetSelfFuncName(), err.Error())
}
if err := db.DB.SetUserInfoToCache(userInfo.UserID, m); err != nil {
log.NewError("0", utils.GetSelfFuncName(), "set userInfo to cache failed", err.Error())
log.NewWarn("0", utils.GetSelfFuncName(), "set userInfo to cache failed", err.Error())
}
}
log.NewInfo("0", utils.GetSelfFuncName(), "ok")
@ -117,18 +132,20 @@ func updateAllGroupMemberListToCache() error {
log.NewInfo("0", utils.GetSelfFuncName())
groupIDList, err := imdb.GetAllGroupIDList()
if err != nil {
log.NewError("0", utils.GetSelfFuncName(), "getAllGroupIDList failed", err.Error())
log.NewWarn("0", utils.GetSelfFuncName(), "getAllGroupIDList failed", err.Error())
panic(err.Error())
}
for _, groupID := range groupIDList {
groupMemberIDList, err := imdb.GetGroupMemberIDListByGroupID(groupID)
if err != nil {
log.NewError("", utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID", err.Error())
log.NewWarn("", utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID", err.Error())
continue
}
log.NewDebug("", utils.GetSelfFuncName(), "groupMemberIDList", groupMemberIDList)
if err := db.DB.AddGroupMemberToCache(groupID, groupMemberIDList...); err != nil {
log.NewError("", utils.GetSelfFuncName(), "AddGroupMemberToCache", err.Error())
//log.NewDebug("", utils.GetSelfFuncName(), "groupMemberIDList", groupMemberIDList)
if len(groupMemberIDList) > 0 {
if err := db.DB.AddGroupMemberToCache(groupID, groupMemberIDList...); err != nil {
log.NewWarn("", utils.GetSelfFuncName(), "AddGroupMemberToCache", err.Error())
}
}
}
log.NewInfo("0", utils.GetSelfFuncName(), "ok")
@ -140,11 +157,13 @@ func updateAllFriendToCache(userList []db.User) error {
for _, user := range userList {
friendIDList, err := imdb.GetFriendIDListByUserID(user.UserID)
if err != nil {
log.NewError("0", utils.GetSelfFuncName(), err.Error())
log.NewWarn("0", utils.GetSelfFuncName(), err.Error())
continue
}
if err := db.DB.AddFriendToCache(user.UserID, friendIDList...); err != nil {
log.NewError("0", utils.GetSelfFuncName(), err.Error())
if len(friendIDList) > 0 {
if err := db.DB.AddFriendToCache(user.UserID, friendIDList...); err != nil {
log.NewWarn("0", utils.GetSelfFuncName(), err.Error(), friendIDList, user.UserID)
}
}
}
log.NewInfo("0", utils.GetSelfFuncName(), "ok")
@ -156,11 +175,13 @@ func updateAllBlackListToCache(userList []db.User) error {
for _, user := range userList {
blackIDList, err := imdb.GetBlackIDListByUserID(user.UserID)
if err != nil {
log.NewError("", utils.GetSelfFuncName(), err.Error())
log.NewWarn("", utils.GetSelfFuncName(), err.Error())
continue
}
if err := db.DB.AddBlackUserToCache(user.UserID, blackIDList...); err != nil {
log.NewError("0", utils.GetSelfFuncName(), err.Error())
if len(blackIDList) > 0 {
if err := db.DB.AddBlackUserToCache(user.UserID, blackIDList...); err != nil {
log.NewWarn("0", utils.GetSelfFuncName(), err.Error())
}
}
}
log.NewInfo("0", utils.GetSelfFuncName(), "ok")
@ -318,7 +339,7 @@ func (s *cacheServer) AddGroupMemberToCache(_ context.Context, req *pbCache.AddG
func (s *cacheServer) ReduceGroupMemberFromCache(_ context.Context, req *pbCache.ReduceGroupMemberFromCacheReq) (resp *pbCache.ReduceGroupMemberFromCacheResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp = &pbCache.ReduceGroupMemberFromCacheResp{}
resp = &pbCache.ReduceGroupMemberFromCacheResp{CommonResp: &pbCache.CommonResp{}}
if err := db.DB.ReduceGroupMemberFromCache(req.GroupID, req.UserIDList...); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ReduceGroupMemberFromCache failed", err.Error())
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode

View File

@ -138,11 +138,17 @@ func NewRpcConversationServer(port int) *rpcConversation {
func (rpc *rpcConversation) Run() {
log.NewInfo("0", "rpc conversation start...")
address := utils.ServerIP + ":" + strconv.Itoa(rpc.rpcPort)
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
address := listenIP + ":" + strconv.Itoa(rpc.rpcPort)
listener, err := net.Listen("tcp", address)
if err != nil {
log.NewError("0", "listen network failed ", err.Error(), address)
return
panic("listening err:" + err.Error() + rpc.rpcRegisterName)
}
log.NewInfo("0", "listen network success, ", address, listener)
//grpc server
@ -151,13 +157,20 @@ func (rpc *rpcConversation) Run() {
//service registers with etcd
pbConversation.RegisterConversationServer(srv, rpc)
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
if err != nil {
log.NewError("0", "RegisterEtcd failed ", err.Error(),
rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName)
rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
return
}
log.NewInfo("0", "RegisterConversationServer ok ", rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName)
log.NewInfo("0", "RegisterConversationServer ok ", rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
err = srv.Serve(listener)
if err != nil {
log.NewError("0", "Serve failed ", err.Error())

View File

@ -42,24 +42,37 @@ func NewFriendServer(port int) *friendServer {
func (s *friendServer) Run() {
log.NewInfo("0", "friendServer run...")
ip := utils.ServerIP
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", registerAddress)
if err != nil {
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
return
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
log.NewInfo("0", "listen ok ", registerAddress)
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", address)
if err != nil {
panic("listening err:" + err.Error() + s.rpcRegisterName)
}
log.NewInfo("0", "listen ok ", address)
defer listener.Close()
//grpc server
srv := grpc.NewServer()
defer srv.GracefulStop()
//User friend related services register to etcd
pbFriend.RegisterFriendServer(srv, s)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
if err != nil {
log.NewError("0", "RegisterEtcd failed ", err.Error(), s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName)
log.NewError("0", "RegisterEtcd failed ", err.Error(), s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName)
return
}
err = srv.Serve(listener)

View File

@ -11,6 +11,7 @@ import (
"Open_IM/pkg/common/token_verify"
cp "Open_IM/pkg/common/utils"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbCache "Open_IM/pkg/proto/cache"
pbGroup "Open_IM/pkg/proto/group"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
pbUser "Open_IM/pkg/proto/user"
@ -43,26 +44,39 @@ func NewGroupServer(port int) *groupServer {
func (s *groupServer) Run() {
log.NewInfo("", "group rpc start ")
ip := utils.ServerIP
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", registerAddress)
if err != nil {
log.NewError("", "Listen failed ", err.Error(), registerAddress)
return
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
log.NewInfo("", "listen network success, ", registerAddress, listener)
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", address)
if err != nil {
panic("listening err:" + err.Error() + s.rpcRegisterName)
}
log.NewInfo("", "listen network success, ", address, listener)
defer listener.Close()
//grpc server
srv := grpc.NewServer()
defer srv.GracefulStop()
//Service registers with etcd
pbGroup.RegisterGroupServer(srv, s)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
rpcRegisterIP := config.Config.RpcRegisterIP
if rpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
if err != nil {
log.NewError("", "RegisterEtcd failed ", err.Error())
return
}
log.Info("", "RegisterEtcd ", s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName)
err = srv.Serve(listener)
if err != nil {
log.NewError("", "Serve failed ", err.Error())
@ -83,8 +97,11 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
log.NewError(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeCreateGroup failed")
}
}
//Time stamp + MD5 to generate group chat id
groupId := utils.Md5(strconv.FormatInt(time.Now().UnixNano(), 10))
groupId := req.GroupInfo.GroupID
if groupId == "" {
groupId = utils.Md5(strconv.FormatInt(time.Now().UnixNano(), 10))
}
//to group
groupInfo := db.Group{}
utils.CopyStructFields(&groupInfo, req.GroupInfo)
@ -95,15 +112,19 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
log.NewError(req.OperationID, "InsertIntoGroup failed, ", err.Error(), groupInfo)
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, http.WrapError(constant.ErrDB)
}
us, err := imdb.GetUserByUserID(req.OwnerUserID)
groupMember := db.GroupMember{}
us := &db.User{}
if req.OwnerUserID == "" {
goto initMemberList
}
us, err = imdb.GetUserByUserID(req.OwnerUserID)
if err != nil {
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OwnerUserID)
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, http.WrapError(constant.ErrDB)
}
//to group member
groupMember := db.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner, OperatorUserID: req.OpUserID}
groupMember = db.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner, OperatorUserID: req.OpUserID}
utils.CopyStructFields(&groupMember, us)
err = imdb.InsertIntoGroupMember(groupMember)
if err != nil {
@ -111,10 +132,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, http.WrapError(constant.ErrDB)
}
err = db.DB.AddGroupMember(groupId, req.OwnerUserID)
if err != nil {
log.NewError(req.OperationID, "AddGroupMember failed ", err.Error(), groupId, req.OwnerUserID)
}
initMemberList:
var okUserIDList []string
//to group member
for _, user := range req.InitMemberList {
@ -134,20 +152,14 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember)
continue
}
okUserIDList = append(okUserIDList, user.UserID)
err = db.DB.AddGroupMember(groupId, user.UserID)
if err != nil {
log.NewError(req.OperationID, "add mongo group member failed, db.DB.AddGroupMember failed ", err.Error())
}
}
resp := &pbGroup.CreateGroupResp{GroupInfo: &open_im_sdk.GroupInfo{}}
group, err := imdb.GetGroupInfoByGroupID(groupId)
if err != nil {
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", err.Error(), groupId)
resp.ErrCode = constant.ErrDB.ErrCode
resp.ErrMsg = constant.ErrDB.ErrMsg
resp.ErrMsg = err.Error()
return resp, nil
}
utils.CopyStructFields(resp.GroupInfo, group)
@ -155,15 +167,39 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
if err != nil {
log.NewError(req.OperationID, "GetGroupMemberNumByGroupID failed ", err.Error(), groupId)
resp.ErrCode = constant.ErrDB.ErrCode
resp.ErrMsg = constant.ErrDB.ErrMsg
resp.ErrMsg = err.Error()
return resp, nil
}
resp.GroupInfo.OwnerUserID = req.OwnerUserID
if req.OwnerUserID != "" {
resp.GroupInfo.OwnerUserID = req.OwnerUserID
okUserIDList = append(okUserIDList, req.OwnerUserID)
}
log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String())
if len(okUserIDList) != 0 {
addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{
UserIDList: okUserIDList,
GroupID: groupId,
OperationID: req.OperationID,
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
cacheClient := pbCache.NewCacheClient(etcdConn)
cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq)
if err != nil {
log.NewError(req.OperationID, "AddGroupMemberToCache rpc call failed ", err.Error())
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "AddGroupMemberToCache rpc logic call failed ", cacheResp.String())
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
}
chat.GroupCreatedNotification(req.OperationID, req.OpUserID, groupId, okUserIDList)
return resp, nil
log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String())
chat.GroupCreatedNotification(req.OperationID, req.OpUserID, groupId, okUserIDList)
return resp, nil
} else {
log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String())
return resp, nil
}
}
func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJoinedGroupListReq) (*pbGroup.GetJoinedGroupListResp, error) {
@ -307,6 +343,24 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String(), v)
}
}
addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{
UserIDList: okUserIDList,
GroupID: req.GroupID,
OperationID: req.OperationID,
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
cacheClient := pbCache.NewCacheClient(etcdConn)
cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq)
if err != nil {
log.NewError(req.OperationID, "AddGroupMemberToCache rpc call failed ", err.Error())
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "AddGroupMemberToCache rpc logic call failed ", cacheResp.String())
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
}
chat.MemberInvitedNotification(req.OperationID, req.GroupID, req.OpUserID, req.Reason, okUserIDList)
resp.ErrCode = 0
log.NewInfo(req.OperationID, "InviteUserToGroup rpc return ", resp.String())
@ -450,6 +504,24 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String(), v)
}
}
reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{
UserIDList: okUserIDList,
GroupID: req.GroupID,
OperationID: req.OperationID,
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
cacheClient := pbCache.NewCacheClient(etcdConn)
cacheResp, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq)
if err != nil {
log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc call failed ", err.Error())
return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc logic call failed ", cacheResp.String())
return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
}
chat.MemberKickedNotification(req, okUserIDList)
log.NewInfo(req.OperationID, "GetGroupMemberList rpc return ", resp.String())
return &resp, nil
@ -526,7 +598,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
}
resp := pbGroup.GetGroupsInfoResp{GroupInfoList: groupsInfoList}
log.NewInfo(req.OperationID, "GetGroupsInfo rpc return ", resp)
log.NewInfo(req.OperationID, "GetGroupsInfo rpc return ", resp.String())
return &resp, nil
}
@ -600,6 +672,18 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
} else {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String())
}
addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{OperationID: req.OperationID, GroupID: req.GroupID, UserIDList: []string{req.FromUserID}}
etcdCacheConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
cacheClient := pbCache.NewCacheClient(etcdCacheConn)
cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq)
if err != nil {
log.NewError(req.OperationID, "AddGroupMemberToCache rpc call failed ", err.Error())
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "AddGroupMemberToCache rpc logic call failed ", cacheResp.String())
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
chat.GroupApplicationAcceptedNotification(req)
chat.MemberEnterNotification(req)
} else if req.HandleResult == constant.GroupResponseRefuse {
@ -691,22 +775,24 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
} else {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String())
}
//reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{
// UserIDList: []string{req.OpUserID},
// GroupID: req.GroupID,
// OperationID: req.OperationID,
//}
//etcdConn = getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
//cacheClient := pbCache.NewCacheClient(etcdConn)
//respCachePb, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq)
//if err != nil {
// log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", err.Error(), reduceGroupMemberFromCacheReq.String())
// return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrServer.ErrCode, ErrMsg: constant.ErrServer.ErrMsg}}, nil
//}
//if respPb.CommonResp.ErrCode != 0 {
// log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", reduceGroupMemberFromCacheReq.String())
// return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode:respCachePb.CommonResp.ErrCode, ErrMsg: respCachePb.CommonResp.ErrMsg}}, nil
//}
reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{
UserIDList: []string{req.OpUserID},
GroupID: req.GroupID,
OperationID: req.OperationID,
}
etcdConnCache := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
cacheClient := pbCache.NewCacheClient(etcdConnCache)
cacheResp, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq)
if err != nil {
log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc call failed ", err.Error())
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc logic call failed ", cacheResp.String())
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
chat.MemberQuitNotification(req)
log.NewInfo(req.OperationID, "rpc QuitGroup return ", pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}})
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
@ -910,7 +996,8 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
for _, v := range groups {
groupMember, err := imdb.GetGroupMaster(v.GroupID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error(), v)
continue
}
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{
GroupInfo: &open_im_sdk.GroupInfo{
@ -926,7 +1013,7 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
GroupMasterName: groupMember.Nickname,
})
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", resp.String())
return resp, nil
}
@ -1006,6 +1093,7 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
CurrentPage: req.Pagination.PageNumber,
ShowNumber: req.Pagination.ShowNumber,
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp.String())
return resp, nil
}
@ -1047,9 +1135,26 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String(), v)
}
}
reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{
UserIDList: resp.Success,
GroupID: req.GroupId,
OperationID: req.OperationID,
}
etcdConnCache := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
cacheClient := pbCache.NewCacheClient(etcdConnCache)
cacheResp, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq)
if err != nil {
log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc call failed ", err.Error())
return resp, http.WrapError(constant.ErrDB)
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc logic call failed ", cacheResp.String())
return resp, http.WrapError(constant.ErrDB)
}
chat.MemberKickedNotification(reqKick, resp.Success)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "success: ", resp.Success)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "failed: ", resp.Failed)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
return resp, nil
}
@ -1086,6 +1191,24 @@ func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGrou
resp.Success = append(resp.Success, userId)
}
}
addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{
UserIDList: resp.Success,
GroupID: req.GroupId,
OperationID: req.OperationId,
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
cacheClient := pbCache.NewCacheClient(etcdConn)
cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq)
if err != nil {
log.NewError(req.OperationId, "AddGroupMemberToCache rpc call failed ", err.Error())
return resp, http.WrapError(constant.ErrDB)
}
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationId, "AddGroupMemberToCache rpc logic call failed ", cacheResp.String())
return resp, http.WrapError(constant.ErrDB)
}
chat.MemberInvitedNotification(req.OperationId, req.GroupId, req.OpUserId, "admin add you to group", resp.Success)
return resp, nil
}

View File

@ -6,6 +6,7 @@ import (
"Open_IM/pkg/common/db"
errors "Open_IM/pkg/common/http"
"context"
"strconv"
"Open_IM/pkg/common/log"
@ -17,7 +18,6 @@ import (
"Open_IM/pkg/utils"
"net"
"strconv"
"strings"
"google.golang.org/grpc"
@ -42,22 +42,35 @@ func NewMessageCMSServer(port int) *messageCMSServer {
func (s *messageCMSServer) Run() {
log.NewInfo("0", "messageCMS rpc start ")
ip := utils.ServerIP
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", registerAddress)
if err != nil {
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
return
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
log.NewInfo("0", "listen network success, ", registerAddress, listener)
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", address)
if err != nil {
panic("listening err:" + err.Error() + s.rpcRegisterName)
}
log.NewInfo("0", "listen network success, ", address, listener)
defer listener.Close()
//grpc server
srv := grpc.NewServer()
defer srv.GracefulStop()
//Service registers with etcd
pbMessageCMS.RegisterMessageCMSServer(srv, s)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
if err != nil {
log.NewError("0", "RegisterEtcd failed ", err.Error())
return
@ -96,6 +109,7 @@ func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetC
chatLog.RecvID = req.GroupId
chatLog.SendID = req.UserId
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "chat_log: ", chatLog)
nums, err := imdb.GetChatLogCount(chatLog)
resp.ChatLogsNum = int32(nums)
if err != nil {

View File

@ -31,6 +31,7 @@ func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) (canSend bool, err erro
if !config.Config.Callback.CallbackBeforeSendSingleMsg.Enable {
return true, nil
}
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
commonCallbackReq := copyCallbackCommonReqStruct(msg)
commonCallbackReq.CallbackCommand = constant.CallbackBeforeSendSingleMsgCommand

View File

@ -12,12 +12,13 @@ import (
func (rpc *rpcChat) DelMsgList(_ context.Context, req *commonPb.DelMsgListReq) (*commonPb.DelMsgListResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &commonPb.DelMsgListResp{}
if err := db.DB.DelMsgLogic(req.UserID, req.SeqList, req.OperationID); err != nil {
if err := db.DB.DelMsgBySeqList(req.UserID, req.SeqList, req.OperationID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsg failed", err.Error())
resp.ErrMsg = constant.ErrDB.ErrMsg
resp.ErrCode = constant.ErrDB.ErrCode
return resp, nil
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}

View File

@ -11,7 +11,7 @@ import (
)
func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *pbMsg.GetMaxAndMinSeqReq) (*pbMsg.GetMaxAndMinSeqResp, error) {
log.InfoByKv("rpc getMaxAndMinSeq is arriving", in.OperationID, in.String())
log.NewInfo(in.OperationID, "rpc getMaxAndMinSeq is arriving", in.String())
//seq, err := model.GetBiggestSeqFromReceive(in.UserID)
maxSeq, err1 := commonDB.DB.GetUserMaxSeq(in.UserID)
minSeq, err2 := commonDB.DB.GetUserMinSeq(in.UserID)
@ -42,7 +42,7 @@ func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.Pull
//msgList, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList, in.OperationID)
msgList, err := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, in.SeqList, in.OperationID)
if err != nil {
log.ErrorByKv("PullMessageBySeqList data error", in.OperationID, in.String())
log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err.Error())
resp.ErrCode = 201
resp.ErrMsg = err.Error()
return resp, nil

View File

@ -19,7 +19,8 @@ type rpcChat struct {
rpcRegisterName string
etcdSchema string
etcdAddr []string
producer *kafka.Producer
onlineProducer *kafka.Producer
offlineProducer *kafka.Producer
}
func NewRpcChatServer(port int) *rpcChat {
@ -30,38 +31,47 @@ func NewRpcChatServer(port int) *rpcChat {
etcdSchema: config.Config.Etcd.EtcdSchema,
etcdAddr: config.Config.Etcd.EtcdAddr,
}
rc.producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
rc.onlineProducer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
rc.offlineProducer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschatOffline.Addr, config.Config.Kafka.Ws2mschatOffline.Topic)
return &rc
}
func (rpc *rpcChat) Run() {
log.Info("", "", "rpc get_token init...")
address := utils.ServerIP + ":" + strconv.Itoa(rpc.rpcPort)
log.Info("", "rpcChat init...")
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
address := listenIP + ":" + strconv.Itoa(rpc.rpcPort)
listener, err := net.Listen("tcp", address)
if err != nil {
log.Error("", "", "listen network failed, err = %s, address = %s", err.Error(), address)
return
panic("listening err:" + err.Error() + rpc.rpcRegisterName)
}
log.Info("", "", "listen network success, address = ", address)
log.Info("", "listen network success, address ", address)
//grpc server
srv := grpc.NewServer()
defer srv.GracefulStop()
//service registers with etcd
rpcRegisterIP := ""
pbChat.RegisterChatServer(srv, rpc)
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), utils.ServerIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
if err != nil {
log.Error("", "", "register rpc get_token to etcd failed, err = %s", err.Error())
log.Error("", "register rpcChat to etcd failed ", err.Error())
return
}
err = srv.Serve(listener)
if err != nil {
log.Info("", "", "rpc get_token fail, err = %s", err.Error())
log.Error("", "rpc rpcChat failed ", err.Error())
return
}
log.Info("", "", "rpc get_token init success")
log.Info("", "rpc rpcChat init success")
}

View File

@ -7,12 +7,14 @@ import (
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
cacheRpc "Open_IM/pkg/proto/cache"
pbCache "Open_IM/pkg/proto/cache"
pbChat "Open_IM/pkg/proto/chat"
pbConversation "Open_IM/pkg/proto/conversation"
pbGroup "Open_IM/pkg/proto/group"
pbRelay "Open_IM/pkg/proto/relay"
sdk_ws "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"errors"
"github.com/garyburd/redigo/redis"
"github.com/golang/protobuf/proto"
"math/rand"
@ -22,6 +24,9 @@ import (
"time"
)
//When the number of group members is greater than this valueOnline users will be sent firstGuaranteed service availability
const GroupMemberNum = 500
type MsgCallBackReq struct {
SendID string `json:"sendID"`
RecvID string `json:"recvID"`
@ -146,7 +151,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
// return returnMsg(&replay, pb, http.StatusUnauthorized, "token validate err,not authorized", "", 0)
rpc.encapsulateMsgData(pb.MsgData)
log.Info("", "this is a test MsgData ", pb.MsgData)
msgToMQ := pbChat.MsgDataToMQ{Token: pb.Token, OperationID: pb.OperationID, MsgData: pb.MsgData}
msgToMQSingle := pbChat.MsgDataToMQ{Token: pb.Token, OperationID: pb.OperationID, MsgData: pb.MsgData}
//options := utils.JsonStringToMap(pbData.Options)
isHistory := utils.GetSwitchFromOptions(pb.MsgData.Options, constant.IsHistory)
mReq := MsgCallBackReq{
@ -186,18 +191,18 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
}
isSend := modifyMessageByUserMessageReceiveOpt(pb.MsgData.RecvID, pb.MsgData.SendID, constant.SingleChatType, pb)
if isSend {
msgToMQ.MsgData = pb.MsgData
log.NewInfo(msgToMQ.OperationID, msgToMQ)
err1 := rpc.sendMsgToKafka(&msgToMQ, msgToMQ.MsgData.RecvID)
msgToMQSingle.MsgData = pb.MsgData
log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle)
err1 := rpc.sendMsgToKafka(&msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus)
if err1 != nil {
log.NewError(msgToMQ.OperationID, "kafka send msg err:RecvID", msgToMQ.MsgData.RecvID, msgToMQ.String())
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String())
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
}
}
if msgToMQ.MsgData.SendID != msgToMQ.MsgData.RecvID { //Filter messages sent to yourself
err2 := rpc.sendMsgToKafka(&msgToMQ, msgToMQ.MsgData.SendID)
if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself
err2 := rpc.sendMsgToKafka(&msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus)
if err2 != nil {
log.NewError(msgToMQ.OperationID, "kafka send msg err:SendID", msgToMQ.MsgData.SendID, msgToMQ.String())
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String())
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
}
}
@ -205,7 +210,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
if err := callbackAfterSendSingleMsg(pb); err != nil {
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSingleMsg failed", err.Error())
}
return returnMsg(&replay, pb, 0, "", msgToMQ.MsgData.ServerMsgID, msgToMQ.MsgData.SendTime)
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime)
case constant.GroupChatType:
// callback
canSend, err := callbackBeforeSendGroupMsg(pb)
@ -216,27 +221,20 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendGroupMsg result", canSend, "end rpc and return")
return returnMsg(&replay, pb, 201, "callbackBeforeSendGroupMsg result stop rpc and return", "", 0)
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := pbGroup.NewGroupClient(etcdConn)
req := &pbGroup.GetGroupAllMemberReq{
GroupID: pb.MsgData.GroupID,
OperationID: pb.OperationID,
}
reply, err := client.GetGroupAllMember(context.Background(), req)
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pb.OperationID, GroupID: pb.MsgData.GroupID}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
client := pbCache.NewCacheClient(etcdConn)
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
if err != nil {
log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", err.Error())
return returnMsg(&replay, pb, 201, err.Error(), "", 0)
log.NewError(pb.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache failed", "", 0)
}
if reply.ErrCode != 0 {
log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", reply.ErrMsg)
return returnMsg(&replay, pb, reply.ErrCode, reply.ErrMsg, "", 0)
if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(pb.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache logic failed", "", 0)
}
memberUserIDList := func(all []*sdk_ws.GroupMemberFullInfo) (result []string) {
for _, v := range all {
result = append(result, v.UserID)
}
return result
}(reply.MemberList)
memberUserIDList := cacheResp.UserIDList
log.Debug(pb.OperationID, "GetGroupAllMember userID list", cacheResp.UserIDList)
var addUidList []string
switch pb.MsgData.ContentType {
case constant.MemberKickedNotification:
@ -259,67 +257,32 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
default:
}
groupID := pb.MsgData.GroupID
m := make(map[string][]string, 2)
if len(memberUserIDList) > GroupMemberNum {
getOnlineAndOfflineUserIDList(memberUserIDList, m, pb.OperationID)
log.Debug(pb.OperationID, m[constant.OnlineStatus], m[constant.OfflineStatus])
} else {
m[constant.OnlineStatus] = memberUserIDList
}
//split parallel send
var wg sync.WaitGroup
var sendTag bool
var split = 50
remain := len(memberUserIDList) % split
for i := 0; i < len(memberUserIDList)/split; i++ {
wg.Add(1)
go func(list []string) {
for _, v := range list {
pb.MsgData.RecvID = v
isSend := modifyMessageByUserMessageReceiveOpt(v, groupID, constant.GroupChatType, pb)
if isSend {
msgToMQ.MsgData = pb.MsgData
err := rpc.sendMsgToKafka(&msgToMQ, v)
if err != nil {
log.NewError(msgToMQ.OperationID, "kafka send msg err:UserId", v, msgToMQ.String())
} else {
sendTag = true
}
}
}
wg.Done()
}(memberUserIDList[i*split : (i+1)*split])
}
if remain > 0 {
wg.Add(1)
go func(list []string) {
for _, v := range list {
pb.MsgData.RecvID = v
isSend := modifyMessageByUserMessageReceiveOpt(v, groupID, constant.GroupChatType, pb)
if isSend {
msgToMQ.MsgData = pb.MsgData
err := rpc.sendMsgToKafka(&msgToMQ, v)
if err != nil {
log.NewError(msgToMQ.OperationID, "kafka send msg err:UserId", v, msgToMQ.String())
} else {
sendTag = true
}
}
}
wg.Done()
}(memberUserIDList[split*(len(memberUserIDList)/split):])
}
wg.Wait()
log.Info(msgToMQ.OperationID, "addUidList", addUidList)
for _, v := range addUidList {
pb.MsgData.RecvID = v
isSend := modifyMessageByUserMessageReceiveOpt(v, groupID, constant.GroupChatType, pb)
log.Info(msgToMQ.OperationID, "isSend", isSend)
if isSend {
msgToMQ.MsgData = pb.MsgData
err := rpc.sendMsgToKafka(&msgToMQ, v)
if err != nil {
log.NewError(msgToMQ.OperationID, "kafka send msg err:UserId", v, msgToMQ.String())
} else {
sendTag = true
}
for k, v := range m {
remain := len(v) % split
for i := 0; i < len(v)/split; i++ {
wg.Add(1)
go rpc.sendMsgToGroup(v[i*split:(i+1)*split], *pb, k, &sendTag, &wg)
}
if remain > 0 {
wg.Add(1)
go rpc.sendMsgToGroup(v[split*(len(v)/split):], *pb, k, &sendTag, &wg)
}
}
wg.Add(1)
go rpc.sendMsgToGroup(addUidList, *pb, constant.OnlineStatus, &sendTag, &wg)
wg.Wait()
// callback
if err := callbackAfterSendGroupMsg(pb); err != nil {
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendGroupMsg failed", err.Error())
@ -378,37 +341,47 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
}
}()
}
return returnMsg(&replay, pb, 0, "", msgToMQ.MsgData.ServerMsgID, msgToMQ.MsgData.SendTime)
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime)
}
case constant.NotificationChatType:
msgToMQ.MsgData = pb.MsgData
log.NewInfo(msgToMQ.OperationID, msgToMQ)
err1 := rpc.sendMsgToKafka(&msgToMQ, msgToMQ.MsgData.RecvID)
msgToMQSingle.MsgData = pb.MsgData
log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle)
err1 := rpc.sendMsgToKafka(&msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus)
if err1 != nil {
log.NewError(msgToMQ.OperationID, "kafka send msg err:RecvID", msgToMQ.MsgData.RecvID, msgToMQ.String())
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String())
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
}
if msgToMQ.MsgData.SendID != msgToMQ.MsgData.RecvID { //Filter messages sent to yourself
err2 := rpc.sendMsgToKafka(&msgToMQ, msgToMQ.MsgData.SendID)
if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself
err2 := rpc.sendMsgToKafka(&msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus)
if err2 != nil {
log.NewError(msgToMQ.OperationID, "kafka send msg err:SendID", msgToMQ.MsgData.SendID, msgToMQ.String())
log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String())
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
}
}
return returnMsg(&replay, pb, 0, "", msgToMQ.MsgData.ServerMsgID, msgToMQ.MsgData.SendTime)
return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime)
default:
return returnMsg(&replay, pb, 203, "unkonwn sessionType", "", 0)
}
}
func (rpc *rpcChat) sendMsgToKafka(m *pbChat.MsgDataToMQ, key string) error {
pid, offset, err := rpc.producer.SendMessage(m, key)
if err != nil {
log.ErrorByKv("kafka send failed", m.OperationID, "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), "key", key)
func (rpc *rpcChat) sendMsgToKafka(m *pbChat.MsgDataToMQ, key string, status string) error {
switch status {
case constant.OnlineStatus:
pid, offset, err := rpc.onlineProducer.SendMessage(m, key)
if err != nil {
log.Error(m.OperationID, "kafka send failed", "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), "key", key, status)
}
return err
case constant.OfflineStatus:
pid, offset, err := rpc.offlineProducer.SendMessage(m, key)
if err != nil {
log.Error(m.OperationID, "kafka send failed", "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), "key", key, status)
}
return err
}
return err
return errors.New("status error")
}
func GetMsgID(sendID string) string {
t := time.Now().Format("2006-01-02 15:04:05")
@ -723,3 +696,79 @@ func Notification(n *NotificationMsg) {
log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), reply.ErrCode, reply.ErrMsg)
}
}
func getOnlineAndOfflineUserIDList(memberList []string, m map[string][]string, operationID string) {
var onllUserIDList, offlUserIDList []string
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
req := &pbRelay.GetUsersOnlineStatusReq{}
req.UserIDList = memberList
req.OperationID = operationID
req.OpUserID = config.Config.Manager.AppManagerUid[0]
flag := false
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
for _, v := range grpcCons {
client := pbRelay.NewOnlineMessageRelayServiceClient(v)
reply, err := client.GetUsersOnlineStatus(context.Background(), req)
if err != nil {
log.NewError(operationID, "GetUsersOnlineStatus rpc err", req.String(), err.Error())
continue
} else {
if reply.ErrCode == 0 {
wsResult = append(wsResult, reply.SuccessResult...)
}
}
}
log.NewInfo(operationID, "call GetUsersOnlineStatus rpc server is success", wsResult)
//Online data merge of each node
for _, v1 := range memberList {
flag = false
for _, v2 := range wsResult {
if v2.UserID == v1 {
flag = true
onllUserIDList = append(onllUserIDList, v1)
}
}
if !flag {
offlUserIDList = append(offlUserIDList, v1)
}
}
m[constant.OnlineStatus] = onllUserIDList
m[constant.OfflineStatus] = offlUserIDList
}
func (rpc *rpcChat) sendMsgToGroup(list []string, pb pbChat.SendMsgReq, status string, sendTag *bool, wg *sync.WaitGroup) {
// log.Debug(pb.OperationID, "split userID ", list)
offlinePushInfo := sdk_ws.OfflinePushInfo{}
if pb.MsgData.OfflinePushInfo != nil {
offlinePushInfo = *pb.MsgData.OfflinePushInfo
}
msgData := sdk_ws.MsgData{}
msgData = *pb.MsgData
msgData.OfflinePushInfo = &offlinePushInfo
groupPB := pbChat.SendMsgReq{Token: pb.Token, OperationID: pb.OperationID, MsgData: &msgData}
msgToMQGroup := pbChat.MsgDataToMQ{Token: pb.Token, OperationID: pb.OperationID, MsgData: &msgData}
for _, v := range list {
options := make(map[string]bool, 10)
for key, value := range pb.MsgData.Options {
options[key] = value
}
groupPB.MsgData.RecvID = v
groupPB.MsgData.Options = options
isSend := modifyMessageByUserMessageReceiveOpt(v, msgData.GroupID, constant.GroupChatType, &groupPB)
if isSend {
msgToMQGroup.MsgData = groupPB.MsgData
// log.Debug(groupPB.OperationID, "sendMsgToKafka, ", v, groupID, msgToMQGroup.String())
err := rpc.sendMsgToKafka(&msgToMQGroup, v, status)
if err != nil {
log.NewError(msgToMQGroup.OperationID, "kafka send msg err:UserId", v, msgToMQGroup.String())
} else {
*sendTag = true
}
} else {
log.Debug(groupPB.OperationID, "not sendMsgToKafka, ", v)
}
}
wg.Done()
}

View File

@ -9,6 +9,7 @@ import (
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbCache "Open_IM/pkg/proto/cache"
pbOffice "Open_IM/pkg/proto/office"
pbCommon "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
@ -17,6 +18,7 @@ import (
"net"
"strconv"
"strings"
"sync"
"time"
)
@ -39,22 +41,34 @@ func NewOfficeServer(port int) *officeServer {
func (s *officeServer) Run() {
log.NewInfo("0", "officeServer rpc start ")
ip := utils.ServerIP
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", registerAddress)
if err != nil {
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
return
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
log.NewInfo("0", "listen network success, ", registerAddress, listener)
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", address)
if err != nil {
panic("listening err:" + err.Error() + s.rpcRegisterName)
}
log.NewInfo("0", "listen network success, ", address, listener)
defer listener.Close()
//grpc server
srv := grpc.NewServer()
defer srv.GracefulStop()
//Service registers with etcd
pbOffice.RegisterOfficeServiceServer(srv, s)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
if err != nil {
log.NewError("0", "RegisterEtcd failed ", err.Error())
return
@ -134,10 +148,10 @@ func (s *officeServer) DeleteTag(_ context.Context, req *pbOffice.DeleteTagReq)
func (s *officeServer) SetTag(_ context.Context, req *pbOffice.SetTagReq) (resp *pbOffice.SetTagResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp = &pbOffice.SetTagResp{CommonResp: &pbOffice.CommonResp{}}
IncreaseUserIDList := utils.RemoveRepeatedStringInList(req.IncreaseUserIDList)
increaseUserIDList := utils.RemoveRepeatedStringInList(req.IncreaseUserIDList)
reduceUserIDList := utils.RemoveRepeatedStringInList(req.ReduceUserIDList)
if err := db.DB.SetTag(req.UserID, req.TagID, req.NewName, IncreaseUserIDList, reduceUserIDList); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetTag failed", err.Error())
if err := db.DB.SetTag(req.UserID, req.TagID, req.NewName, increaseUserIDList, reduceUserIDList); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetTag failed", increaseUserIDList, reduceUserIDList, err.Error())
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
return resp, nil
@ -160,15 +174,29 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
}
var groupUserIDList []string
for _, groupID := range req.GroupList {
userIDList, err := im_mysql_model.GetGroupMemberIDListByGroupID(groupID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID failed", err.Error())
continue
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
cacheClient := pbCache.NewCacheClient(etcdConn)
req := pbCache.GetGroupMemberIDListFromCacheReq{
OperationID: req.OperationID,
GroupID: groupID,
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), userIDList)
groupUserIDList = append(groupUserIDList, userIDList...)
getGroupMemberIDListFromCacheResp, err := cacheClient.GetGroupMemberIDListFromCache(context.Background(), &req)
if err != nil {
log.NewError(req.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error(), req.String())
resp.CommonResp.ErrCode = constant.ErrServer.ErrCode
resp.CommonResp.ErrMsg = err.Error()
return resp, nil
}
if getGroupMemberIDListFromCacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", getGroupMemberIDListFromCacheResp.CommonResp.ErrCode)
resp.CommonResp.ErrCode = getGroupMemberIDListFromCacheResp.CommonResp.ErrCode
resp.CommonResp.ErrMsg = getGroupMemberIDListFromCacheResp.CommonResp.ErrMsg
return resp, nil
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), getGroupMemberIDListFromCacheResp.UserIDList)
groupUserIDList = append(groupUserIDList, getGroupMemberIDListFromCacheResp.UserIDList...)
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), groupUserIDList, req.GroupList)
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), groupUserIDList, req.GroupList)
var userIDList []string
userIDList = append(userIDList, tagUserIDList...)
userIDList = append(userIDList, groupUserIDList...)
@ -179,32 +207,47 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
userIDList = append(userIDList[:i], userIDList[i+1:]...)
}
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "total userIDList result: ", userIDList)
us, err := imdb.GetUserByUserID(req.SendID)
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "total userIDList result: ", userIDList)
user, err := imdb.GetUserByUserID(req.SendID)
if err != nil {
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.SendID)
resp.CommonResp.ErrMsg = err.Error()
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
return resp, nil
}
var wg sync.WaitGroup
wg.Add(len(userIDList))
for _, userID := range userIDList {
msg.TagSendMessage(req.OperationID, us, userID, req.Content, req.SenderPlatformID)
go func(userID string) {
defer wg.Done()
msg.TagSendMessage(req.OperationID, user, userID, req.Content, req.SenderPlatformID)
}(userID)
}
wg.Wait()
var tagSendLogs db.TagSendLog
wg.Add(len(userIDList))
for _, userID := range userIDList {
userName, err := im_mysql_model.GetUserNameByUserID(userID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", err.Error())
continue
}
tagSendLogs.UserList = append(tagSendLogs.UserList, db.TagUser{
UserID: userID,
UserName: userName,
})
go func(userID string) {
defer wg.Done()
userName, err := im_mysql_model.GetUserNameByUserID(userID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", err.Error())
return
}
tagSendLogs.UserList = append(tagSendLogs.UserList, db.TagUser{
UserID: userID,
UserName: userName,
})
}(userID)
}
wg.Wait()
tagSendLogs.SendID = req.SendID
tagSendLogs.Content = req.Content
tagSendLogs.SenderPlatformID = req.SenderPlatformID
tagSendLogs.SendTime = time.Now().Unix()
if err := db.DB.SaveTagSendLog(&tagSendLogs); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SaveTagSendLog failed", err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SaveTagSendLog failed", tagSendLogs, err.Error())
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
return resp, nil
@ -271,8 +314,9 @@ func (s *officeServer) CreateOneWorkMoment(_ context.Context, req *pbOffice.Crea
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp = &pbOffice.CreateOneWorkMomentResp{CommonResp: &pbOffice.CommonResp{}}
workMoment := db.WorkMoment{
Comments: []*db.Comment{},
LikeUserList: []*db.LikeUser{},
Comments: []*db.Comment{},
LikeUserList: []*db.WorkMomentUser{},
PermissionUserList: []*db.WorkMomentUser{},
}
createUser, err := imdb.GetUserByUserID(req.WorkMoment.UserID)
if err != nil {
@ -286,6 +330,18 @@ func (s *officeServer) CreateOneWorkMoment(_ context.Context, req *pbOffice.Crea
workMoment.UserName = createUser.Nickname
workMoment.FaceURL = createUser.FaceURL
workMoment.PermissionUserIDList = s.getPermissionUserIDList(req.OperationID, req.WorkMoment.PermissionGroupList, req.WorkMoment.PermissionUserList)
workMoment.PermissionUserList = []*db.WorkMomentUser{}
for _, userID := range workMoment.PermissionUserIDList {
userName, err := imdb.GetUserNameByUserID(userID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", err.Error())
continue
}
workMoment.PermissionUserList = append(workMoment.PermissionUserList, &db.WorkMomentUser{
UserID: userID,
UserName: userName,
})
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "workMoment to create", workMoment)
err = db.DB.CreateOneWorkMoment(&workMoment)
if err != nil {
@ -311,6 +367,20 @@ func (s *officeServer) CreateOneWorkMoment(_ context.Context, req *pbOffice.Crea
return resp, nil
}
func (s *officeServer) DeleteComment(_ context.Context, req *pbOffice.DeleteCommentReq) (resp *pbOffice.DeleteCommentResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp = &pbOffice.DeleteCommentResp{CommonResp: &pbOffice.CommonResp{}}
err = db.DB.DeleteComment(req.WorkMomentID, req.ContentID, req.OpUserID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetWorkMomentByID failed", err.Error())
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
return resp, nil
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}
// count and distinct permission users
func (s *officeServer) getPermissionUserIDList(operationID string, groupList []*pbOffice.PermissionGroup, userList []*pbOffice.WorkMomentUser) []string {
var permissionUserIDList []string
@ -471,7 +541,6 @@ func (s *officeServer) GetWorkMomentByID(_ context.Context, req *pbOffice.GetWor
workMoment, err := db.DB.GetWorkMomentByID(req.WorkMomentID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetWorkMomentByID failed", err.Error())
resp.CommonResp = &pbOffice.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
return resp, nil
}
canSee := isUserCanSeeWorkMoment(req.OpUserID, *workMoment)

View File

@ -10,6 +10,7 @@ import (
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
"Open_IM/pkg/proto/auth"
groupRpc "Open_IM/pkg/proto/group"
rpc "Open_IM/pkg/proto/organization"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
@ -40,27 +41,38 @@ func NewServer(port int) *organizationServer {
func (s *organizationServer) Run() {
log.NewInfo("", "organization rpc start ")
ip := utils.ServerIP
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", registerAddress)
if err != nil {
log.NewError("", "Listen failed ", err.Error(), registerAddress)
return
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
log.NewInfo("", "listen network success, ", registerAddress, listener)
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", address)
if err != nil {
panic("listening err:" + err.Error() + s.rpcRegisterName)
}
log.NewInfo("", "listen network success, ", address, listener)
defer listener.Close()
//grpc server
srv := grpc.NewServer()
defer srv.GracefulStop()
//Service registers with etcd
rpc.RegisterOrganizationServer(srv, s)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
if err != nil {
log.NewError("", "RegisterEtcd failed ", err.Error())
return
}
log.NewInfo("", "organization rpc RegisterEtcd success", ip, s.rpcPort, s.rpcRegisterName, 10)
log.NewInfo("", "organization rpc RegisterEtcd success", rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
err = srv.Serve(listener)
if err != nil {
log.NewError("", "Serve failed ", err.Error())
@ -99,6 +111,34 @@ func (s *organizationServer) CreateDepartment(ctx context.Context, req *rpc.Crea
utils.CopyStructFields(resp.DepartmentInfo, createdDepartment)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
client := groupRpc.NewGroupClient(etcdConn)
createGroupReq := &groupRpc.CreateGroupReq{
InitMemberList: nil,
GroupInfo: &open_im_sdk.GroupInfo{
GroupName: req.DepartmentInfo.Name,
FaceURL: req.DepartmentInfo.FaceURL,
CreateTime: uint32(time.Now().Unix()),
CreatorUserID: req.OpUserID,
GroupType: constant.DepartmentGroup,
},
OperationID: req.OperationID,
OpUserID: req.OpUserID,
}
createGroupResp, err := client.CreateGroup(context.Background(), createGroupReq)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CreateGroup rpc failed", createGroupReq, err.Error())
resp.ErrCode = constant.ErrDB.ErrCode
resp.ErrMsg = constant.ErrDB.ErrMsg + " createGroup failed " + err.Error()
return resp, nil
}
if createGroupResp.ErrCode != 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), resp)
resp.ErrCode = constant.ErrDB.ErrCode
resp.ErrMsg = constant.ErrDB.ErrMsg + " createGroup failed " + createGroupResp.ErrMsg
return resp, nil
}
return resp, nil
}
@ -296,6 +336,19 @@ func (s *organizationServer) CreateDepartmentMember(ctx context.Context, req *rp
return resp, nil
}
func (s *organizationServer) GetDepartmentParentIDList(_ context.Context, req *rpc.GetDepartmentParentIDListReq) (resp *rpc.GetDepartmentParentIDListResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req.String())
resp = &rpc.GetDepartmentParentIDListResp{}
resp.ParentIDList, err = imdb.GetDepartmentParentIDList(req.DepartmentID)
if err != nil {
resp.ErrMsg = constant.ErrDB.ErrMsg + ": " + err.Error()
resp.ErrCode = constant.ErrDB.ErrCode
return resp, nil
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp.String())
return resp, nil
}
func (s *organizationServer) GetUserInDepartmentByUserID(userID string, operationID string) (*open_im_sdk.UserInDepartment, error) {
err, organizationUser := imdb.GetOrganizationUser(userID)
if err != nil {
@ -427,3 +480,18 @@ func (s *organizationServer) GetDepartmentMember(ctx context.Context, req *rpc.G
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", resp)
return &resp, nil
}
func (s *organizationServer) GetDepartmentRelatedGroupIDList(ctx context.Context, req *rpc.GetDepartmentRelatedGroupIDListReq) (resp *rpc.GetDepartmentRelatedGroupIDListResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp = &rpc.GetDepartmentRelatedGroupIDListResp{}
groupIDList, err := imdb.GetDepartmentRelatedGroupIDList(req.DepartmentIDList)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
resp.ErrMsg = constant.ErrDB.ErrMsg + " GetDepartMentRelatedGroupIDList failed " + err.Error()
resp.ErrCode = constant.ErrDB.ErrCode
return resp, nil
}
resp.GroupIDList = groupIDList
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}

View File

@ -4,6 +4,7 @@ import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"context"
"strconv"
"sync"
"time"
@ -21,7 +22,6 @@ import (
//"context"
errors "Open_IM/pkg/common/http"
"net"
"strconv"
"strings"
"google.golang.org/grpc"
@ -46,22 +46,35 @@ func NewStatisticsServer(port int) *statisticsServer {
func (s *statisticsServer) Run() {
log.NewInfo("0", "Statistics rpc start ")
ip := utils.ServerIP
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", registerAddress)
if err != nil {
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
return
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
log.NewInfo("0", "listen network success, ", registerAddress, listener)
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", address)
if err != nil {
panic("listening err:" + err.Error() + s.rpcRegisterName)
}
log.NewInfo("0", "listen network success, ", address, listener)
defer listener.Close()
//grpc server
srv := grpc.NewServer()
defer srv.GracefulStop()
//Service registers with etcd
pbStatistics.RegisterUserServer(srv, s)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
if err != nil {
log.NewError("0", "RegisterEtcd failed ", err.Error())
return
@ -75,13 +88,14 @@ func (s *statisticsServer) Run() {
}
func (s *statisticsServer) GetActiveGroup(_ context.Context, req *pbStatistics.GetActiveGroupReq) (*pbStatistics.GetActiveGroupResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req", req.String())
resp := &pbStatistics.GetActiveGroupResp{}
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
return resp, errors.WrapError(constant.ErrArgs)
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveGroups failed", err.Error())
@ -95,6 +109,7 @@ func (s *statisticsServer) GetActiveGroup(_ context.Context, req *pbStatistics.G
MessageNum: int32(activeGroup.MessageNum),
})
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
return resp, nil
}
@ -106,6 +121,7 @@ func (s *statisticsServer) GetActiveUser(_ context.Context, req *pbStatistics.Ge
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
return resp, errors.WrapError(constant.ErrDB)
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUsers failed", err.Error())
@ -120,6 +136,7 @@ func (s *statisticsServer) GetActiveUser(_ context.Context, req *pbStatistics.Ge
},
)
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
return resp, nil
}
@ -219,7 +236,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
}
increaseGroupNum, err := imdb.GetIncreaseGroupNum(fromTime, toTime.Add(time.Hour*24))
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error(), fromTime, toTime)
return resp, errors.WrapError(constant.ErrDB)
}
totalGroupNum, err := imdb.GetTotalGroupNum()
@ -230,7 +247,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
resp.IncreaseGroupNum = increaseGroupNum
resp.TotalGroupNum = totalGroupNum
times := GetRangeDate(fromTime, toTime)
log.NewInfo(req.OperationID, "times:", times)
log.NewDebug(req.OperationID, "times:", times)
wg := &sync.WaitGroup{}
resp.IncreaseGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
resp.TotalGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
@ -257,6 +274,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
}(wg, i, v)
}
wg.Wait()
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
return resp, nil
}
@ -264,6 +282,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
resp := &pbStatistics.GetMessageStatisticsResp{}
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "times: ", fromTime, toTime)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
return resp, errors.WrapError(constant.ErrArgs)
@ -278,6 +297,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMessageNum failed", err.Error())
return resp, errors.WrapError(constant.ErrDB)
}
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), privateMessageNum, groupMessageNum)
resp.PrivateMessageNum = privateMessageNum
resp.GroupMessageNum = groupMessageNum
times := GetRangeDate(fromTime, toTime)
@ -312,7 +332,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
}
func (s *statisticsServer) GetUserStatistics(_ context.Context, req *pbStatistics.GetUserStatisticsReq) (*pbStatistics.GetUserStatisticsResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbStatistics.GetUserStatisticsResp{}
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
if err != nil {
@ -374,5 +394,6 @@ func (s *statisticsServer) GetUserStatistics(_ context.Context, req *pbStatistic
}(wg, i, v)
}
wg.Wait()
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
return resp, nil
}

View File

@ -16,7 +16,6 @@ import (
pbUser "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils"
"context"
"fmt"
"net"
"strconv"
"strings"
@ -42,26 +41,38 @@ func NewUserServer(port int) *userServer {
}
func (s *userServer) Run() {
log.NewInfo("0", "", "rpc user start...")
log.NewInfo("0", "rpc user start...")
ip := utils.ServerIP
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", registerAddress)
if err != nil {
log.NewError("0", "listen network failed ", err.Error(), registerAddress)
return
listenIP := ""
if config.Config.ListenIP == "" {
listenIP = "0.0.0.0"
} else {
listenIP = config.Config.ListenIP
}
log.NewInfo("0", "listen network success, address ", registerAddress, listener)
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
//listener network
listener, err := net.Listen("tcp", address)
if err != nil {
panic("listening err:" + err.Error() + s.rpcRegisterName)
}
log.NewInfo("0", "listen network success, address ", address, listener)
defer listener.Close()
//grpc server
srv := grpc.NewServer()
defer srv.GracefulStop()
//Service registers with etcd
pbUser.RegisterUserServer(srv, s)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
rpcRegisterIP := ""
if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP()
if err != nil {
log.Error("", "GetLocalIP failed ", err.Error())
}
}
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
if err != nil {
log.NewError("0", "RegisterEtcd failed ", err.Error(), s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName)
log.NewError("0", "RegisterEtcd failed ", err.Error(), s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName)
return
}
err = srv.Serve(listener)
@ -158,6 +169,7 @@ func (s *userServer) GetAllConversations(ctx context.Context, req *pbUser.GetAll
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.GetAllConversationsResp{Conversations: []*pbUser.Conversation{}}
conversations, err := imdb.GetUserAllConversations(req.OwnerUserID)
log.NewDebug(req.OperationID, "conversations: ", conversations)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
@ -175,6 +187,7 @@ func (s *userServer) GetConversation(ctx context.Context, req *pbUser.GetConvers
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.GetConversationResp{Conversation: &pbUser.Conversation{}}
conversation, err := imdb.GetConversation(req.OwnerUserID, req.ConversationID)
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation error", err.Error())
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
@ -192,6 +205,7 @@ func (s *userServer) GetConversations(ctx context.Context, req *pbUser.GetConver
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.GetConversationsResp{Conversations: []*pbUser.Conversation{}}
conversations, err := imdb.GetConversations(req.OwnerUserID, req.ConversationIDs)
log.NewDebug("", utils.GetSelfFuncName(), "conversations", conversations)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
@ -219,6 +233,7 @@ func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConvers
return resp, nil
}
if groupInfo.Status == constant.GroupStatusDismissed && !req.Conversation.IsNotInGroup {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "group status is dismissed", groupInfo)
errMsg := "group status is dismissed"
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}
return resp, nil
@ -390,14 +405,28 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
chat.UserInfoUpdatedNotification(req.OperationID, req.UserInfo.UserID, v.FriendUser.UserID)
}
//etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
//client := pbFriend.NewFriendClient(etcdConn)
chat.UserInfoUpdatedNotification(req.OperationID, req.UserInfo.UserID, req.OpUserID)
log.Info(req.OperationID, "UserInfoUpdatedNotification ", req.UserInfo.UserID, req.OpUserID)
if req.UserInfo.FaceURL != "" {
go s.SyncJoinedGroupMemberFaceURL(req.UserInfo.UserID, req.UserInfo.FaceURL, req.OperationID, req.OpUserID)
}
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{}}, nil
}
func (s *userServer) SyncJoinedGroupMemberFaceURL(userID string, faceURL string, operationID string, opUserID string) {
joinedGroupIDList, err := imdb.GetJoinedGroupIDListByUserID(userID)
if err != nil {
log.NewWarn(operationID, "GetJoinedGroupIDListByUserID failed ", userID, err.Error())
return
}
for _, v := range joinedGroupIDList {
groupMemberInfo := db.GroupMember{UserID: userID, GroupID: v, FaceURL: faceURL}
imdb.UpdateGroupMemberInfo(groupMemberInfo)
chat.GroupMemberInfoSetNotification(operationID, opUserID, v, userID)
}
}
func (s *userServer) GetUsersByName(ctx context.Context, req *pbUser.GetUsersByNameReq) (*pbUser.GetUsersByNameResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req.String())
resp := &pbUser.GetUsersByNameResp{}
@ -431,6 +460,7 @@ func (s *userServer) GetUsersByName(ctx context.Context, req *pbUser.GetUsersByN
CurrentPage: req.Pagination.PageNumber,
ShowNumber: req.Pagination.ShowNumber,
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
return resp, nil
}
@ -454,6 +484,7 @@ func (s *userServer) GetUserById(ctx context.Context, req *pbUser.GetUserByIdReq
CreateTime: user.CreateTime.String(),
IsBlock: isBlock,
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}
@ -462,6 +493,7 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
resp := &pbUser.GetUsersResp{User: []*pbUser.User{}}
users, err := imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsers failed", err.Error())
return resp, errors.WrapError(constant.ErrDB)
}
for _, v := range users {
@ -475,16 +507,19 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
IsBlock: isBlock,
}
resp.User = append(resp.User, user)
} else {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UserIsBlock failed", err.Error())
}
}
user := db.User{}
nums, err := imdb.GetUsersCount(user)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error(), user)
return resp, errors.WrapError(constant.ErrDB)
}
resp.UserNums = nums
resp.Pagination = &sdkws.ResponsePagination{ShowNumber: req.Pagination.ShowNumber, CurrentPage: req.Pagination.PageNumber}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}
@ -494,7 +529,7 @@ func (s *userServer) ResignUser(ctx context.Context, req *pbUser.ResignUserReq)
}
func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*pbUser.AlterUserResp, error) {
log.NewInfo(req.OperationID, "AlterUser args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.AlterUserResp{}
user := db.User{
PhoneNumber: strconv.FormatInt(req.PhoneNumber, 10),
@ -507,11 +542,12 @@ func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*
return resp, errors.WrapError(constant.ErrDB)
}
chat.UserInfoUpdatedNotification(req.OperationID, req.UserId, req.OpUserId)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}
func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUser.AddUserResp, error) {
log.NewInfo(req.OperationID, "AddUser args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.AddUserResp{}
err := imdb.AddUser(req.UserId, req.PhoneNumber, req.Name)
if err != nil {
@ -522,8 +558,7 @@ func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUs
}
func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*pbUser.BlockUserResp, error) {
log.NewInfo(req.OperationID, "BlockUser args ", req.String())
fmt.Println("BlockUser args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.BlockUserResp{}
err := imdb.BlockUser(req.UserId, req.EndDisableTime)
if err != nil {
@ -534,7 +569,7 @@ func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*
}
func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq) (*pbUser.UnBlockUserResp, error) {
log.NewInfo(req.OperationID, "UnBlockUser args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.UnBlockUserResp{}
err := imdb.UnBlockUser(req.UserId)
if err != nil {
@ -545,7 +580,7 @@ func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq
}
func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUsersReq) (*pbUser.GetBlockUsersResp, error) {
log.NewInfo(req.OperationID, "GetBlockUsers args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.GetBlockUsersResp{}
blockUsers, err := imdb.GetBlockUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
if err != nil {
@ -573,11 +608,12 @@ func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUser
return resp, errors.WrapError(constant.ErrDB)
}
resp.UserNums = nums
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
return resp, nil
}
func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUserByIdReq) (*pbUser.GetBlockUserByIdResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetBlockUserById args ", req.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbUser.GetBlockUserByIdResp{}
user, err := imdb.GetBlockUserById(req.UserId)
if err != nil {
@ -594,6 +630,7 @@ func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUse
BeginDisableTime: (user.BeginDisableTime).String(),
EndDisableTime: (user.EndDisableTime).String(),
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
return resp, nil
}

View File

@ -1,13 +1 @@
package utils
import (
"Open_IM/pkg/utils"
"net"
"testing"
)
func TestServerIP(t *testing.T) {
if net.ParseIP(utils.ServerIP) == nil {
t.Fail()
}
}

View File

@ -37,3 +37,22 @@ type UserTokenResp struct {
CommResp
UserToken UserTokenInfo `json:"data"`
}
type ParseTokenReq struct {
OperationID string `json:"operationID" binding:"required"`
}
//type ParseTokenResp struct {
// CommResp
// ExpireTime int64 `json:"expireTime" binding:"required"`
//}
type ExpireTime struct {
ExpireTimeSeconds uint32 `json:"expireTimeSeconds" `
}
type ParseTokenResp struct {
CommResp
Data map[string]interface{} `json:"data"`
ExpireTime ExpireTime `json:"-"`
}

View File

@ -81,8 +81,8 @@ type GetGroupAllMemberResp struct {
}
type CreateGroupReq struct {
MemberList []*GroupAddMemberInfo `json:"memberList" binding:"required"`
OwnerUserID string `json:"ownerUserID" binding:"required"`
MemberList []*GroupAddMemberInfo `json:"memberList"`
OwnerUserID string `json:"ownerUserID"`
GroupType int32 `json:"groupType"`
GroupName string `json:"groupName"`
Notification string `json:"notification"`
@ -90,6 +90,7 @@ type CreateGroupReq struct {
FaceURL string `json:"faceURL"`
Ex string `json:"ex"`
OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID"`
}
type CreateGroupResp struct {
CommResp

View File

@ -1,5 +1,7 @@
package base_info
import "mime/multipart"
type MinioStorageCredentialReq struct {
OperationID string `json:"operationID"`
}
@ -23,3 +25,35 @@ type MinioUploadFileResp struct {
SnapshotURL string `json:"snapshotURL,omitempty"`
SnapshotNewName string `json:"snapshotName,omitempty"`
}
type UploadUpdateAppReq struct {
OperationID string `form:"operationID" binding:"required"`
Type int `form:"type" binding:"required"`
Version string `form:"version" binding:"required"`
File *multipart.FileHeader `form:"file" binding:"required"`
Yaml *multipart.FileHeader `form:"yaml"`
ForceUpdate bool `form:"forceUpdate"`
UpdateLog string `form:"updateLog" binding:"required"`
}
type UploadUpdateAppResp struct {
CommResp
}
type GetDownloadURLReq struct {
OperationID string `json:"operationID" binding:"required"`
Type int `json:"type" binding:"required"`
Version string `json:"version" binding:"required"`
}
type GetDownloadURLResp struct {
CommResp
Data struct {
HasNewVersion bool `json:"hasNewVersion"`
ForceUpdate bool `json:"forceUpdate"`
FileURL string `json:"fileURL"`
YamlURL string `json:"yamlURL"`
Version string `json:"version"`
UpdateLog string `json:"update_log"`
} `json:"data"`
}

View File

@ -8,6 +8,7 @@ type CreateOneWorkMomentReq struct {
type CreateOneWorkMomentResp struct {
CommResp
Data struct{} `json:"data"`
}
type DeleteOneWorkMomentReq struct {
@ -16,6 +17,7 @@ type DeleteOneWorkMomentReq struct {
type DeleteOneWorkMomentResp struct {
CommResp
Data struct{} `json:"data"`
}
type LikeOneWorkMomentReq struct {
@ -24,6 +26,7 @@ type LikeOneWorkMomentReq struct {
type LikeOneWorkMomentResp struct {
CommResp
Data struct{} `json:"data"`
}
type CommentOneWorkMomentReq struct {
@ -32,6 +35,16 @@ type CommentOneWorkMomentReq struct {
type CommentOneWorkMomentResp struct {
CommResp
Data struct{} `json:"data"`
}
type DeleteCommentReq struct {
office.DeleteCommentReq
}
type DeleteCommentResp struct {
CommResp
Data struct{} `json:"data"`
}
type WorkMomentsUserCommonReq struct {
@ -45,15 +58,17 @@ type GetWorkMomentByIDReq struct {
}
type WorkMoment struct {
WorkMomentID string `json:"workMomentID"`
UserID string `json:"userID"`
Content string `json:"content"`
LikeUserList []*WorkMomentUser `json:"likeUsers"`
Comments []*Comment `json:"comments"`
FaceURL string `json:"faceURL"`
UserName string `json:"userName"`
AtUserList []*WorkMomentUser `json:"atUsers"`
CreateTime int32 `json:"createTime"`
WorkMomentID string `json:"workMomentID"`
UserID string `json:"userID"`
Content string `json:"content"`
LikeUserList []*WorkMomentUser `json:"likeUsers"`
Comments []*Comment `json:"comments"`
FaceURL string `json:"faceURL"`
UserName string `json:"userName"`
AtUserList []*WorkMomentUser `json:"atUsers"`
PermissionUserList []*WorkMomentUser `json:"permissionUsers"`
CreateTime int32 `json:"createTime"`
Permission int32 `json:"permission"`
}
type WorkMomentUser struct {
@ -111,4 +126,5 @@ type SetUserWorkMomentsLevelReq struct {
type SetUserWorkMomentsLevelResp struct {
CommResp
Data struct{} `json:"data"`
}

View File

@ -1,10 +1,43 @@
package cms_api_struct
import (
apiStruct "Open_IM/pkg/base_info"
)
type AdminLoginRequest struct {
AdminName string `json:"admin_name" binding:"required"`
Secret string `json:"secret" binding:"required"`
Secret string `json:"secret" binding:"required"`
}
type AdminLoginResponse struct {
Token string `json:"token"`
}
}
type UploadUpdateAppReq struct {
OperationID string `form:"operationID" binding:"required"`
Type int `form:"type" binding:"required"`
Version string `form:"version" binding:"required"`
//File *multipart.FileHeader `form:"file" binding:"required"`
//Yaml *multipart.FileHeader `form:"yaml" binding:"required"`
ForceUpdate bool `form:"forceUpdate" binding:"required"`
}
type UploadUpdateAppResp struct {
apiStruct.CommResp
}
type GetDownloadURLReq struct {
OperationID string `json:"operationID" binding:"required"`
Type int `json:"type" binding:"required"`
Version string `json:"version" binding:"required"`
}
type GetDownloadURLResp struct {
apiStruct.CommResp
Data struct {
HasNewVersion bool `json:"hasNewVersion"`
ForceUpdate bool `json:"forceUpdate"`
FileURL string `json:"fileURL"`
YamlURL string `json:"yamlURL"`
} `json:"data"`
}

View File

@ -6,7 +6,6 @@ import (
"path/filepath"
"runtime"
"github.com/spf13/viper"
"gopkg.in/yaml.v3"
)
@ -25,16 +24,23 @@ type callBackConfig struct {
}
type config struct {
ServerIP string `yaml:"serverip"`
ServerIP string `yaml:"serverip"`
RpcRegisterIP string `yaml:"rpcRegisterIP"`
ListenIP string `yaml:"listenIP"`
ServerVersion string `yaml:"serverversion"`
Api struct {
GinPort []int `yaml:"openImApiPort"`
GinPort []int `yaml:"openImApiPort"`
ListenIP string `yaml:"listenIP"`
}
CmsApi struct {
GinPort []int `yaml:"openImCmsApiPort"`
GinPort []int `yaml:"openImCmsApiPort"`
ListenIP string `yaml:"listenIP"`
}
Sdk struct {
WsPort []int `yaml:"openImSdkWsPort"`
WsPort []int `yaml:"openImSdkWsPort"`
DataDir []string `yaml:"dataDir"`
}
Credential struct {
Tencent struct {
@ -57,6 +63,7 @@ type config struct {
}
Minio struct {
Bucket string `yaml:"bucket"`
AppBucket string `yaml:"appBucket"`
Location string `yaml:"location"`
Endpoint string `yaml:"endpoint"`
AccessKeyID string `yaml:"accessKeyID"`
@ -78,7 +85,7 @@ type config struct {
DBMaxLifeTime int `yaml:"dbMaxLifeTime"`
}
Mongo struct {
DBUri string `yaml:"dbUri"` // 当dbUri值不为空则直接使用该值
DBUri string `yaml:"dbUri"`
DBAddress []string `yaml:"dbAddress"`
DBDirect bool `yaml:"dbDirect"`
DBTimeout int `yaml:"dbTimeout"`
@ -106,7 +113,7 @@ type config struct {
RpcGetTokenPort []int `yaml:"rpcGetTokenPort"`
}
RpcRegisterName struct {
OpenImStatisticsName string `yaml:"OpenImStatisticsName"`
OpenImStatisticsName string `yaml:"openImStatisticsName"`
OpenImUserName string `yaml:"openImUserName"`
OpenImFriendName string `yaml:"openImFriendName"`
OpenImOfflineMessageName string `yaml:"openImOfflineMessageName"`
@ -120,6 +127,7 @@ type config struct {
OpenImOrganizationName string `yaml:"openImOrganizationName"`
OpenImConversationName string `yaml:"openImConversationName"`
OpenImCacheName string `yaml:"openImCacheName"`
OpenImRealTimeCommName string `yaml:"openImRealTimeCommName"`
}
Etcd struct {
EtcdSchema string `yaml:"etcdSchema"`
@ -184,14 +192,19 @@ type config struct {
Addr []string `yaml:"addr"`
Topic string `yaml:"topic"`
}
Ws2mschatOffline struct {
Addr []string `yaml:"addr"`
Topic string `yaml:"topic"`
}
Ms2pschat struct {
Addr []string `yaml:"addr"`
Topic string `yaml:"topic"`
}
ConsumerGroupID struct {
MsgToMongo string `yaml:"msgToMongo"`
MsgToMySql string `yaml:"msgToMySql"`
MsgToPush string `yaml:"msgToPush"`
MsgToMongo string `yaml:"msgToMongo"`
MsgToMongoOffline string `yaml:"msgToMongoOffline"`
MsgToMySql string `yaml:"msgToMySql"`
MsgToPush string `yaml:"msgToPush"`
}
}
Secret string `yaml:"secret"`
@ -389,9 +402,15 @@ type config struct {
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"workMomentsNotification"`
JoinDepartmentNotification struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"joinDepartmentNotification"`
}
Demo struct {
Port []int `yaml:"openImDemoPort"`
Port []int `yaml:"openImDemoPort"`
ListenIP string `yaml:"listenIP"`
AliSMSVerify struct {
AccessKeyID string `yaml:"accessKeyId"`
AccessKeySecret string `yaml:"accessKeySecret"`
@ -407,6 +426,7 @@ type config struct {
SmtpAddr string `yaml:"smtpAddr"`
SmtpPort int `yaml:"smtpPort"`
}
TestDepartMentID string `yaml:"testDepartMentID"`
}
Rtc struct {
Port int `yaml:"port"`
@ -429,21 +449,11 @@ type PDefaultTips struct {
}
func init() {
//path, _ := os.Getwd()
//bytes, err := ioutil.ReadFile(path + "/config/config.yaml")
// if we cd Open-IM-Server/src/utils and run go test
// it will panic cannot find config/config.yaml
cfgName := os.Getenv("CONFIG_NAME")
if len(cfgName) == 0 {
cfgName = Root + "/config/config.yaml"
}
viper.SetConfigFile(cfgName)
err := viper.ReadInConfig()
if err != nil {
panic(err.Error())
}
bytes, err := ioutil.ReadFile(cfgName)
if err != nil {
panic(err.Error())

View File

@ -151,6 +151,10 @@ const (
GroupStatusDismissed = 2
GroupStatusMuted = 3
//GroupType
NormalGroup = 0
DepartmentGroup = 1
GroupBaned = 3
GroupBanPrivateChat = 4
@ -267,3 +271,5 @@ func GroupIsBanPrivateChat(status int32) bool {
const BigVersion = "v3"
const LogFileName = "OpenIM.log"
const StatisticsTimeInterval = 300

View File

@ -2,7 +2,8 @@ package db
import (
"Open_IM/pkg/common/config"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/x/bsonx"
"strings"
//"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
@ -68,54 +69,30 @@ func init() {
}
fmt.Println("0", utils.GetSelfFuncName(), "mongo driver client init success: ", uri)
// mongodb create index
opts := options.CreateIndexes().SetMaxTime(10 * time.Second)
dataBase := mongoClient.Database(config.Config.Mongo.DBDatabase)
cSendLogModels := []mongo.IndexModel{
{
Keys: bson.M{"user_id": -1},
},
if err := createMongoIndex(mongoClient, cSendLog, false, "send_id", "-send_time"); err != nil {
fmt.Println("send_id", "-send_time", "index create failed", err.Error())
}
result, err := dataBase.Collection(cSendLog).Indexes().CreateMany(context.Background(), cSendLogModels, opts)
if err != nil {
//fmt.Println("mongodb create cSendLogModels failed", result, err.Error())
if err := createMongoIndex(mongoClient, cChat, true, "uid"); err != nil {
fmt.Println("uid", " index create failed", err.Error())
}
if err := createMongoIndex(mongoClient, cWorkMoment, true, "-create_time", "work_moment_id"); err != nil {
fmt.Println("-create_time", "work_moment_id", "index create failed", err.Error())
}
if err := createMongoIndex(mongoClient, cWorkMoment, true, "work_moment_id"); err != nil {
fmt.Println("work_moment_id", "index create failed", err.Error())
}
cChatModels := []mongo.IndexModel{
{
Keys: bson.M{"uid": -1},
},
}
result, err = dataBase.Collection(cChat).Indexes().CreateMany(context.Background(), cChatModels, opts)
if err != nil {
fmt.Println("mongodb create cChatModels failed", result, err.Error())
if err := createMongoIndex(mongoClient, cWorkMoment, false, "user_id", "-create_time"); err != nil {
fmt.Println("user_id", "-create_time", "index create failed", err.Error())
}
cWorkMomentModels := []mongo.IndexModel{
{
Keys: bson.M{"work_moment_id": -1},
},
{
Keys: bson.M{"user_id": -1},
},
if err := createMongoIndex(mongoClient, cTag, false, "user_id", "-create_time"); err != nil {
fmt.Println("user_id", "-create_time", "index create failed", err.Error())
}
result, err = dataBase.Collection(cWorkMoment).Indexes().CreateMany(context.Background(), cWorkMomentModels, opts)
if err != nil {
//fmt.Println("mongodb create cWorkMomentModels failed", result, err.Error())
}
cTagModels := []mongo.IndexModel{
{
Keys: bson.M{"tag_id": -1},
},
{
Keys: bson.M{"user_id": -1},
},
}
result, err = dataBase.Collection(cTag).Indexes().CreateMany(context.Background(), cTagModels, opts)
if err != nil {
//fmt.Println("mongodb create cTagModels failed", result, err.Error())
if err := createMongoIndex(mongoClient, cTag, true, "tag_id"); err != nil {
fmt.Println("user_id", "-create_time", "index create failed", err.Error())
}
fmt.Println("create index success")
DB.mongoClient = mongoClient
// redis pool init
@ -136,3 +113,37 @@ func init() {
},
}
}
func createMongoIndex(client *mongo.Client, collection string, isUnique bool, keys ...string) error {
db := client.Database(config.Config.Mongo.DBDatabase).Collection(collection)
opts := options.CreateIndexes().SetMaxTime(10 * time.Second)
indexView := db.Indexes()
keysDoc := bsonx.Doc{}
// 复合索引
for _, key := range keys {
if strings.HasPrefix(key, "-") {
keysDoc = keysDoc.Append(strings.TrimLeft(key, "-"), bsonx.Int32(-1))
} else {
keysDoc = keysDoc.Append(key, bsonx.Int32(1))
}
}
// 创建索引
index := mongo.IndexModel{
Keys: keysDoc,
}
if isUnique == true {
index.Options = options.Index().SetUnique(true)
}
result, err := indexView.CreateOne(
context.Background(),
index,
opts,
)
if err != nil {
return utils.Wrap(err, result)
}
return nil
}

View File

@ -232,6 +232,7 @@ type Department struct {
ParentID string `gorm:"column:parent_id;size:64" json:"parentID" binding:"required"` // "0" or Real parent id
Order int32 `gorm:"column:order" json:"order" ` // 1, 2, ...
DepartmentType int32 `gorm:"column:department_type" json:"departmentType"` //1, 2...
RelatedGroupID string `gorm:"column:related_group_id;size:64" json:"relatedGroupID"`
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
}
@ -272,3 +273,17 @@ type DepartmentMember struct {
func (DepartmentMember) TableName() string {
return "department_members"
}
type AppVersion struct {
Version string `gorm:"column:version;size:64" json:"version"`
Type int `gorm:"column:type;primary_key" json:"type"`
UpdateTime int `gorm:"column:update_time" json:"update_time"`
ForceUpdate bool `gorm:"column:force_update" json:"force_update"`
FileName string `gorm:"column:file_name" json:"file_name"`
YamlName string `gorm:"column:yaml_name" json:"yaml_name"`
UpdateLog string `gorm:"column:update_log" json:"update_log"`
}
func (AppVersion) TableName() string {
return "app_version"
}

View File

@ -13,6 +13,7 @@ import (
"github.com/gogo/protobuf/sortkeys"
"go.mongodb.org/mongo-driver/mongo/options"
"math/rand"
"sync"
//"github.com/garyburd/redigo/redis"
"github.com/golang/protobuf/proto"
@ -79,6 +80,53 @@ func (d *DataBases) GetMinSeqFromMongo2(uid string) (MinSeq uint32, err error) {
return 1, nil
}
// deleteMsgByLogic
func (d *DataBases) DelMsgBySeqList(userID string, seqList []uint32, operationID string) (err error) {
log.Debug(operationID, utils.GetSelfFuncName(), "args ", userID, seqList)
sortkeys.Uint32s(seqList)
suffixUserID2SubSeqList := func(uid string, seqList []uint32) map[string][]uint32 {
t := make(map[string][]uint32)
for i := 0; i < len(seqList); i++ {
seqUid := getSeqUid(uid, seqList[i])
if value, ok := t[seqUid]; !ok {
var temp []uint32
t[seqUid] = append(temp, seqList[i])
} else {
t[seqUid] = append(value, seqList[i])
}
}
return t
}(userID, seqList)
var wg sync.WaitGroup
wg.Add(len(suffixUserID2SubSeqList))
for k, v := range suffixUserID2SubSeqList {
go func(suffixUserID string, subSeqList []uint32, operationID string) {
if e := d.DelMsgBySeqListInOneDoc(suffixUserID, subSeqList, operationID); e != nil {
log.Error(operationID, "DelMsgBySeqListInOneDoc failed ", e.Error(), suffixUserID, subSeqList)
err = e
}
wg.Done()
}(k, v, operationID)
}
wg.Wait()
return err
}
func (d *DataBases) DelMsgBySeqListInOneDoc(suffixUserID string, seqList []uint32, operationID string) error {
log.Debug(operationID, utils.GetSelfFuncName(), "args ", suffixUserID, seqList)
seqMsgList, indexList, err := d.GetMsgAndIndexBySeqListInOneMongo2(suffixUserID, seqList, operationID)
if err != nil {
return utils.Wrap(err, "")
}
for i, v := range seqMsgList {
if err := d.ReplaceMsgByIndex(suffixUserID, v, operationID, indexList[i]); err != nil {
return utils.Wrap(err, "")
}
}
return nil
}
// deleteMsgByLogic
func (d *DataBases) DelMsgLogic(uid string, seqList []uint32, operationID string) error {
sortkeys.Uint32s(seqList)
@ -96,6 +144,27 @@ func (d *DataBases) DelMsgLogic(uid string, seqList []uint32, operationID string
return nil
}
func (d *DataBases) ReplaceMsgByIndex(suffixUserID string, msg *open_im_sdk.MsgData, operationID string, seqIndex int) error {
log.NewInfo(operationID, utils.GetSelfFuncName(), suffixUserID, *msg)
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
s := fmt.Sprintf("msg.%d.msg", seqIndex)
log.NewDebug(operationID, utils.GetSelfFuncName(), seqIndex, s)
msg.Status = constant.MsgDeleted
bytes, err := proto.Marshal(msg)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "proto marshal failed ", err.Error(), msg.String())
return utils.Wrap(err, "")
}
updateResult, err := c.UpdateOne(ctx, bson.M{"uid": suffixUserID}, bson.M{"$set": bson.M{s: bytes}})
log.NewInfo(operationID, utils.GetSelfFuncName(), updateResult)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "UpdateOne", err.Error())
return utils.Wrap(err, "")
}
return nil
}
func (d *DataBases) ReplaceMsgBySeq(uid string, msg *open_im_sdk.MsgData, operationID string) error {
log.NewInfo(operationID, utils.GetSelfFuncName(), uid, *msg)
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
@ -109,6 +178,7 @@ func (d *DataBases) ReplaceMsgBySeq(uid string, msg *open_im_sdk.MsgData, operat
log.NewError(operationID, utils.GetSelfFuncName(), "proto marshal", err.Error())
return utils.Wrap(err, "")
}
updateResult, err := c.UpdateOne(
ctx, bson.M{"uid": uid},
bson.M{"$set": bson.M{s: bytes}})
@ -228,6 +298,36 @@ func (d *DataBases) GetMsgBySeqListMongo2(uid string, seqList []uint32, operatio
return seqMsg, nil
}
func (d *DataBases) GetMsgAndIndexBySeqListInOneMongo2(suffixUserID string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, indexList []int, err error) {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
sChat := UserChat{}
if err = c.FindOne(ctx, bson.M{"uid": suffixUserID}).Decode(&sChat); err != nil {
log.NewError(operationID, "not find seqUid", suffixUserID, err.Error())
return nil, nil, utils.Wrap(err, "")
}
singleCount := 0
var hasSeqList []uint32
for i := 0; i < len(sChat.Msg); i++ {
msg := new(open_im_sdk.MsgData)
if err = proto.Unmarshal(sChat.Msg[i].Msg, msg); err != nil {
log.NewError(operationID, "Unmarshal err", msg.String(), err.Error())
return nil, nil, err
}
if isContainInt32(msg.Seq, seqList) {
indexList = append(indexList, i)
seqMsg = append(seqMsg, msg)
hasSeqList = append(hasSeqList, msg.Seq)
singleCount++
if singleCount == len(seqList) {
break
}
}
}
return seqMsg, indexList, nil
}
func genExceptionMessageBySeqList(seqList []uint32) (exceptionMsg []*open_im_sdk.MsgData) {
for _, v := range seqList {
msg := new(open_im_sdk.MsgData)
@ -566,25 +666,21 @@ func (d *DataBases) GetTagSendLogs(userID string, showNumber, pageNumber int32)
}
type WorkMoment struct {
WorkMomentID string `bson:"work_moment_id"`
UserID string `bson:"user_id"`
UserName string `bson:"user_name"`
FaceURL string `bson:"face_url"`
Content string `bson:"content"`
LikeUserList []*LikeUser `bson:"like_user_list"`
AtUserList []*AtUser `bson:"at_user_list"`
Comments []*Comment `bson:"comments"`
PermissionUserIDList []string `bson:"permission_user_id_list"`
Permission int32 `bson:"permission"`
CreateTime int32 `bson:"create_time"`
WorkMomentID string `bson:"work_moment_id"`
UserID string `bson:"user_id"`
UserName string `bson:"user_name"`
FaceURL string `bson:"face_url"`
Content string `bson:"content"`
LikeUserList []*WorkMomentUser `bson:"like_user_list"`
AtUserList []*WorkMomentUser `bson:"at_user_list"`
PermissionUserList []*WorkMomentUser `bson:"permission_user_list"`
Comments []*Comment `bson:"comments"`
PermissionUserIDList []string `bson:"permission_user_id_list"`
Permission int32 `bson:"permission"`
CreateTime int32 `bson:"create_time"`
}
type AtUser struct {
UserID string `bson:"user_id"`
UserName string `bson:"user_name"`
}
type LikeUser struct {
type WorkMomentUser struct {
UserID string `bson:"user_id"`
UserName string `bson:"user_name"`
}
@ -616,6 +712,18 @@ func (d *DataBases) DeleteOneWorkMoment(workMomentID string) error {
return err
}
func (d *DataBases) DeleteComment(workMomentID, contentID, opUserID string) error {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
_, err := c.UpdateOne(ctx, bson.D{{"work_moment_id", workMomentID},
{"$or", bson.A{
bson.D{{"user_id", opUserID}},
bson.D{{"comments", bson.M{"$elemMatch": bson.M{"user_id": opUserID}}}},
},
}}, bson.M{"$pull": bson.M{"comments": bson.M{"content_id": contentID}}})
return err
}
func (d *DataBases) GetWorkMomentByID(workMomentID string) (*WorkMoment, error) {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
@ -637,7 +745,7 @@ func (d *DataBases) LikeOneWorkMoment(likeUserID, userName, workMomentID string)
}
}
if !isAlreadyLike {
workMoment.LikeUserList = append(workMoment.LikeUserList, &LikeUser{UserID: likeUserID, UserName: userName})
workMoment.LikeUserList = append(workMoment.LikeUserList, &WorkMomentUser{UserID: likeUserID, UserName: userName})
}
log.NewDebug("", utils.GetSelfFuncName(), workMoment)
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
@ -741,7 +849,7 @@ func getMsgIndex(seq uint32) int {
seqSuffix := seq / singleGocMsgNum
var index uint32
if seqSuffix == 0 {
index = (seq - seqSuffix*5000) - 1
index = (seq - seqSuffix*singleGocMsgNum) - 1
} else {
index = seq - seqSuffix*singleGocMsgNum
}

View File

@ -59,7 +59,7 @@ func initMysqlDB() {
&GroupMember{},
&GroupRequest{},
&User{},
&Black{}, &ChatLog{}, &Register{}, &Conversation{})
&Black{}, &ChatLog{}, &Register{}, &Conversation{}, &AppVersion{}, &Department{})
db.Set("gorm:table_options", "CHARSET=utf8")
db.Set("gorm:table_options", "collation=utf8_unicode_ci")
@ -119,7 +119,10 @@ func initMysqlDB() {
fmt.Println("CreateTable DepartmentMember")
db.CreateTable(&DepartmentMember{})
}
if !db.HasTable(&AppVersion{}) {
fmt.Println("CreateTable DepartmentMember")
db.CreateTable(&AppVersion{})
}
return
}

View File

@ -0,0 +1,43 @@
package im_mysql_model
import (
"Open_IM/pkg/common/db"
"time"
)
func UpdateAppVersion(appType int, version string, forceUpdate bool, fileName, yamlName, updateLog string) error {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return err
}
updateTime := int(time.Now().Unix())
app := db.AppVersion{
Version: version,
Type: appType,
UpdateTime: updateTime,
FileName: fileName,
YamlName: yamlName,
ForceUpdate: forceUpdate,
UpdateLog: updateLog,
}
result := dbConn.Model(db.AppVersion{}).Where("type = ?", appType).Update(map[string]interface{}{"force_update": forceUpdate,
"version": version, "update_time": int(time.Now().Unix()), "file_name": fileName, "yaml_name": yamlName, "type": appType, "update_log": updateLog})
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
err := dbConn.Create(&app).Error
return err
}
return nil
}
func GetNewestVersion(appType int) (*db.AppVersion, error) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
app := db.AppVersion{}
if err != nil {
return &app, err
}
dbConn.LogMode(true)
return &app, dbConn.Model(db.AppVersion{}).First(&app, appType).Error
}

View File

@ -3,6 +3,7 @@ package im_mysql_model
import (
"Open_IM/pkg/common/db"
"Open_IM/pkg/utils"
"github.com/jinzhu/gorm"
"time"
)
@ -234,5 +235,48 @@ func GetSubDepartmentNum(departmentID string) (error, uint32) {
return utils.Wrap(err, ""), 0
}
return nil, number
}
func GetDepartmentRelatedGroupIDList(departmentIDList []string) ([]string, error) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return nil, utils.Wrap(err, "DefaultGormDB failed")
}
var groupIDList []string
err = dbConn.Table("departments").Where("department_id IN (?) ", departmentIDList).Pluck("related_group_id", &groupIDList).Error
return groupIDList, err
}
func getDepartmentParent(departmentID string, dbConn *gorm.DB) (*db.Department, error) {
var department db.Department
var parentID string
dbConn.LogMode(true)
// select * from departments where department_id = (select parent_id from departments where department_id= zx234fd);
err := dbConn.Table("departments").Where("department_id=?", dbConn.Table("departments").Where("department_id=?", departmentID).Pluck("parent_id", parentID)).Find(&department).Error
return &department, err
}
func GetDepartmentParent(departmentID string, dbConn *gorm.DB, parentIDList []string) (*db.Department, error) {
department, err := getDepartmentParent(departmentID, dbConn)
if err != nil {
return nil, err
}
if department.ParentID != "" {
parentIDList = append(parentIDList, department.ParentID)
_, err = GetDepartmentParent(departmentID, dbConn, parentIDList)
if err != nil {
return nil, nil
}
}
return nil, nil
}
func GetDepartmentParentIDList(departmentID string) ([]string, error) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return nil, err
}
var parentIDList []string
_, err = GetDepartmentParent(departmentID, dbConn, parentIDList)
return parentIDList, err
}

View File

@ -233,7 +233,7 @@ func (d *DataBases) AddGroupMemberToCache(groupID string, userIDList ...string)
for _, id := range userIDList {
IDList = append(IDList, id)
}
_, err := d.Exec("SADD", blackListCache+groupID, IDList...)
_, err := d.Exec("SADD", groupCache+groupID, IDList...)
return err
}
@ -242,7 +242,7 @@ func (d *DataBases) ReduceGroupMemberFromCache(groupID string, userIDList ...str
for _, id := range userIDList {
IDList = append(IDList, id)
}
_, err := d.Exec("SREM", blackListCache+groupID, IDList...)
_, err := d.Exec("SREM", groupCache+groupID, IDList...)
return err
}

View File

@ -129,13 +129,23 @@ func CheckAccess(OpUserID string, OwnerUserID string) bool {
return false
}
func GetUserIDFromToken(token string, operationID string) (bool, string) {
func GetUserIDFromToken(token string, operationID string) (bool, string, string) {
claims, err := ParseToken(token, operationID)
if err != nil {
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
return false, ""
return false, "", err.Error()
}
return true, claims.UID
log.Debug(operationID, "token claims.ExpiresAt.Second() ", claims.ExpiresAt.Unix())
return true, claims.UID, ""
}
func GetUserIDFromTokenExpireTime(token string, operationID string) (bool, string, string, int64) {
claims, err := ParseToken(token, operationID)
if err != nil {
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
return false, "", err.Error(), 0
}
return true, claims.UID, "", claims.ExpiresAt.Unix()
}
func ParseTokenGetUserID(token string, operationID string) (error, string) {

View File

@ -4,7 +4,7 @@ import (
"Open_IM/pkg/common/log"
"context"
"fmt"
"go.etcd.io/etcd/clientv3"
clientv3 "go.etcd.io/etcd/client/v3"
"net"
"strconv"
"strings"

View File

@ -4,8 +4,10 @@ import (
"Open_IM/pkg/common/log"
"context"
"fmt"
"go.etcd.io/etcd/clientv3"
"go.etcd.io/etcd/mvcc/mvccpb"
"go.etcd.io/etcd/api/v3/mvccpb"
clientv3 "go.etcd.io/etcd/client/v3"
//"go.etcd.io/etcd/mvcc/mvccpb"
//"google.golang.org/genproto/googleapis/ads/googleads/v1/services"
"google.golang.org/grpc"
"google.golang.org/grpc/balancer/roundrobin"

View File

@ -36,7 +36,7 @@ func (m *CommonResp) Reset() { *m = CommonResp{} }
func (m *CommonResp) String() string { return proto.CompactTextString(m) }
func (*CommonResp) ProtoMessage() {}
func (*CommonResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{0}
return fileDescriptor_office_f560032e7c752d4f, []int{0}
}
func (m *CommonResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CommonResp.Unmarshal(m, b)
@ -82,7 +82,7 @@ func (m *TagUser) Reset() { *m = TagUser{} }
func (m *TagUser) String() string { return proto.CompactTextString(m) }
func (*TagUser) ProtoMessage() {}
func (*TagUser) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{1}
return fileDescriptor_office_f560032e7c752d4f, []int{1}
}
func (m *TagUser) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TagUser.Unmarshal(m, b)
@ -129,7 +129,7 @@ func (m *Tag) Reset() { *m = Tag{} }
func (m *Tag) String() string { return proto.CompactTextString(m) }
func (*Tag) ProtoMessage() {}
func (*Tag) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{2}
return fileDescriptor_office_f560032e7c752d4f, []int{2}
}
func (m *Tag) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Tag.Unmarshal(m, b)
@ -182,7 +182,7 @@ func (m *GetUserTagsReq) Reset() { *m = GetUserTagsReq{} }
func (m *GetUserTagsReq) String() string { return proto.CompactTextString(m) }
func (*GetUserTagsReq) ProtoMessage() {}
func (*GetUserTagsReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{3}
return fileDescriptor_office_f560032e7c752d4f, []int{3}
}
func (m *GetUserTagsReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserTagsReq.Unmarshal(m, b)
@ -228,7 +228,7 @@ func (m *GetUserTagsResp) Reset() { *m = GetUserTagsResp{} }
func (m *GetUserTagsResp) String() string { return proto.CompactTextString(m) }
func (*GetUserTagsResp) ProtoMessage() {}
func (*GetUserTagsResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{4}
return fileDescriptor_office_f560032e7c752d4f, []int{4}
}
func (m *GetUserTagsResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserTagsResp.Unmarshal(m, b)
@ -276,7 +276,7 @@ func (m *CreateTagReq) Reset() { *m = CreateTagReq{} }
func (m *CreateTagReq) String() string { return proto.CompactTextString(m) }
func (*CreateTagReq) ProtoMessage() {}
func (*CreateTagReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{5}
return fileDescriptor_office_f560032e7c752d4f, []int{5}
}
func (m *CreateTagReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateTagReq.Unmarshal(m, b)
@ -335,7 +335,7 @@ func (m *CreateTagResp) Reset() { *m = CreateTagResp{} }
func (m *CreateTagResp) String() string { return proto.CompactTextString(m) }
func (*CreateTagResp) ProtoMessage() {}
func (*CreateTagResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{6}
return fileDescriptor_office_f560032e7c752d4f, []int{6}
}
func (m *CreateTagResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateTagResp.Unmarshal(m, b)
@ -375,7 +375,7 @@ func (m *DeleteTagReq) Reset() { *m = DeleteTagReq{} }
func (m *DeleteTagReq) String() string { return proto.CompactTextString(m) }
func (*DeleteTagReq) ProtoMessage() {}
func (*DeleteTagReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{7}
return fileDescriptor_office_f560032e7c752d4f, []int{7}
}
func (m *DeleteTagReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteTagReq.Unmarshal(m, b)
@ -427,7 +427,7 @@ func (m *DeleteTagResp) Reset() { *m = DeleteTagResp{} }
func (m *DeleteTagResp) String() string { return proto.CompactTextString(m) }
func (*DeleteTagResp) ProtoMessage() {}
func (*DeleteTagResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{8}
return fileDescriptor_office_f560032e7c752d4f, []int{8}
}
func (m *DeleteTagResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteTagResp.Unmarshal(m, b)
@ -470,7 +470,7 @@ func (m *SetTagReq) Reset() { *m = SetTagReq{} }
func (m *SetTagReq) String() string { return proto.CompactTextString(m) }
func (*SetTagReq) ProtoMessage() {}
func (*SetTagReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{9}
return fileDescriptor_office_f560032e7c752d4f, []int{9}
}
func (m *SetTagReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetTagReq.Unmarshal(m, b)
@ -543,7 +543,7 @@ func (m *SetTagResp) Reset() { *m = SetTagResp{} }
func (m *SetTagResp) String() string { return proto.CompactTextString(m) }
func (*SetTagResp) ProtoMessage() {}
func (*SetTagResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{10}
return fileDescriptor_office_f560032e7c752d4f, []int{10}
}
func (m *SetTagResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetTagResp.Unmarshal(m, b)
@ -587,7 +587,7 @@ func (m *SendMsg2TagReq) Reset() { *m = SendMsg2TagReq{} }
func (m *SendMsg2TagReq) String() string { return proto.CompactTextString(m) }
func (*SendMsg2TagReq) ProtoMessage() {}
func (*SendMsg2TagReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{11}
return fileDescriptor_office_f560032e7c752d4f, []int{11}
}
func (m *SendMsg2TagReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SendMsg2TagReq.Unmarshal(m, b)
@ -667,7 +667,7 @@ func (m *SendMsg2TagResp) Reset() { *m = SendMsg2TagResp{} }
func (m *SendMsg2TagResp) String() string { return proto.CompactTextString(m) }
func (*SendMsg2TagResp) ProtoMessage() {}
func (*SendMsg2TagResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{12}
return fileDescriptor_office_f560032e7c752d4f, []int{12}
}
func (m *SendMsg2TagResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SendMsg2TagResp.Unmarshal(m, b)
@ -707,7 +707,7 @@ func (m *GetTagSendLogsReq) Reset() { *m = GetTagSendLogsReq{} }
func (m *GetTagSendLogsReq) String() string { return proto.CompactTextString(m) }
func (*GetTagSendLogsReq) ProtoMessage() {}
func (*GetTagSendLogsReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{13}
return fileDescriptor_office_f560032e7c752d4f, []int{13}
}
func (m *GetTagSendLogsReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetTagSendLogsReq.Unmarshal(m, b)
@ -761,7 +761,7 @@ func (m *TagSendLog) Reset() { *m = TagSendLog{} }
func (m *TagSendLog) String() string { return proto.CompactTextString(m) }
func (*TagSendLog) ProtoMessage() {}
func (*TagSendLog) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{14}
return fileDescriptor_office_f560032e7c752d4f, []int{14}
}
func (m *TagSendLog) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TagSendLog.Unmarshal(m, b)
@ -815,7 +815,7 @@ func (m *GetTagSendLogsResp) Reset() { *m = GetTagSendLogsResp{} }
func (m *GetTagSendLogsResp) String() string { return proto.CompactTextString(m) }
func (*GetTagSendLogsResp) ProtoMessage() {}
func (*GetTagSendLogsResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{15}
return fileDescriptor_office_f560032e7c752d4f, []int{15}
}
func (m *GetTagSendLogsResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetTagSendLogsResp.Unmarshal(m, b)
@ -869,7 +869,7 @@ func (m *GetUserTagByIDReq) Reset() { *m = GetUserTagByIDReq{} }
func (m *GetUserTagByIDReq) String() string { return proto.CompactTextString(m) }
func (*GetUserTagByIDReq) ProtoMessage() {}
func (*GetUserTagByIDReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{16}
return fileDescriptor_office_f560032e7c752d4f, []int{16}
}
func (m *GetUserTagByIDReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserTagByIDReq.Unmarshal(m, b)
@ -922,7 +922,7 @@ func (m *GetUserTagByIDResp) Reset() { *m = GetUserTagByIDResp{} }
func (m *GetUserTagByIDResp) String() string { return proto.CompactTextString(m) }
func (*GetUserTagByIDResp) ProtoMessage() {}
func (*GetUserTagByIDResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{17}
return fileDescriptor_office_f560032e7c752d4f, []int{17}
}
func (m *GetUserTagByIDResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserTagByIDResp.Unmarshal(m, b)
@ -968,7 +968,7 @@ func (m *LikeUser) Reset() { *m = LikeUser{} }
func (m *LikeUser) String() string { return proto.CompactTextString(m) }
func (*LikeUser) ProtoMessage() {}
func (*LikeUser) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{18}
return fileDescriptor_office_f560032e7c752d4f, []int{18}
}
func (m *LikeUser) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LikeUser.Unmarshal(m, b)
@ -1014,7 +1014,7 @@ func (m *NotificationUser) Reset() { *m = NotificationUser{} }
func (m *NotificationUser) String() string { return proto.CompactTextString(m) }
func (*NotificationUser) ProtoMessage() {}
func (*NotificationUser) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{19}
return fileDescriptor_office_f560032e7c752d4f, []int{19}
}
func (m *NotificationUser) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NotificationUser.Unmarshal(m, b)
@ -1066,7 +1066,7 @@ func (m *Comment) Reset() { *m = Comment{} }
func (m *Comment) String() string { return proto.CompactTextString(m) }
func (*Comment) ProtoMessage() {}
func (*Comment) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{20}
return fileDescriptor_office_f560032e7c752d4f, []int{20}
}
func (m *Comment) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Comment.Unmarshal(m, b)
@ -1154,7 +1154,7 @@ func (m *PermissionGroup) Reset() { *m = PermissionGroup{} }
func (m *PermissionGroup) String() string { return proto.CompactTextString(m) }
func (*PermissionGroup) ProtoMessage() {}
func (*PermissionGroup) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{21}
return fileDescriptor_office_f560032e7c752d4f, []int{21}
}
func (m *PermissionGroup) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PermissionGroup.Unmarshal(m, b)
@ -1200,7 +1200,7 @@ func (m *WorkMomentUser) Reset() { *m = WorkMomentUser{} }
func (m *WorkMomentUser) String() string { return proto.CompactTextString(m) }
func (*WorkMomentUser) ProtoMessage() {}
func (*WorkMomentUser) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{22}
return fileDescriptor_office_f560032e7c752d4f, []int{22}
}
func (m *WorkMomentUser) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_WorkMomentUser.Unmarshal(m, b)
@ -1256,7 +1256,7 @@ func (m *WorkMoment) Reset() { *m = WorkMoment{} }
func (m *WorkMoment) String() string { return proto.CompactTextString(m) }
func (*WorkMoment) ProtoMessage() {}
func (*WorkMoment) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{23}
return fileDescriptor_office_f560032e7c752d4f, []int{23}
}
func (m *WorkMoment) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_WorkMoment.Unmarshal(m, b)
@ -1372,7 +1372,7 @@ func (m *CreateOneWorkMomentReq) Reset() { *m = CreateOneWorkMomentReq{}
func (m *CreateOneWorkMomentReq) String() string { return proto.CompactTextString(m) }
func (*CreateOneWorkMomentReq) ProtoMessage() {}
func (*CreateOneWorkMomentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{24}
return fileDescriptor_office_f560032e7c752d4f, []int{24}
}
func (m *CreateOneWorkMomentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateOneWorkMomentReq.Unmarshal(m, b)
@ -1417,7 +1417,7 @@ func (m *CreateOneWorkMomentResp) Reset() { *m = CreateOneWorkMomentResp
func (m *CreateOneWorkMomentResp) String() string { return proto.CompactTextString(m) }
func (*CreateOneWorkMomentResp) ProtoMessage() {}
func (*CreateOneWorkMomentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{25}
return fileDescriptor_office_f560032e7c752d4f, []int{25}
}
func (m *CreateOneWorkMomentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateOneWorkMomentResp.Unmarshal(m, b)
@ -1457,7 +1457,7 @@ func (m *DeleteOneWorkMomentReq) Reset() { *m = DeleteOneWorkMomentReq{}
func (m *DeleteOneWorkMomentReq) String() string { return proto.CompactTextString(m) }
func (*DeleteOneWorkMomentReq) ProtoMessage() {}
func (*DeleteOneWorkMomentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{26}
return fileDescriptor_office_f560032e7c752d4f, []int{26}
}
func (m *DeleteOneWorkMomentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteOneWorkMomentReq.Unmarshal(m, b)
@ -1509,7 +1509,7 @@ func (m *DeleteOneWorkMomentResp) Reset() { *m = DeleteOneWorkMomentResp
func (m *DeleteOneWorkMomentResp) String() string { return proto.CompactTextString(m) }
func (*DeleteOneWorkMomentResp) ProtoMessage() {}
func (*DeleteOneWorkMomentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{27}
return fileDescriptor_office_f560032e7c752d4f, []int{27}
}
func (m *DeleteOneWorkMomentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteOneWorkMomentResp.Unmarshal(m, b)
@ -1549,7 +1549,7 @@ func (m *LikeOneWorkMomentReq) Reset() { *m = LikeOneWorkMomentReq{} }
func (m *LikeOneWorkMomentReq) String() string { return proto.CompactTextString(m) }
func (*LikeOneWorkMomentReq) ProtoMessage() {}
func (*LikeOneWorkMomentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{28}
return fileDescriptor_office_f560032e7c752d4f, []int{28}
}
func (m *LikeOneWorkMomentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LikeOneWorkMomentReq.Unmarshal(m, b)
@ -1601,7 +1601,7 @@ func (m *LikeOneWorkMomentResp) Reset() { *m = LikeOneWorkMomentResp{} }
func (m *LikeOneWorkMomentResp) String() string { return proto.CompactTextString(m) }
func (*LikeOneWorkMomentResp) ProtoMessage() {}
func (*LikeOneWorkMomentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{29}
return fileDescriptor_office_f560032e7c752d4f, []int{29}
}
func (m *LikeOneWorkMomentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LikeOneWorkMomentResp.Unmarshal(m, b)
@ -1643,7 +1643,7 @@ func (m *CommentOneWorkMomentReq) Reset() { *m = CommentOneWorkMomentReq
func (m *CommentOneWorkMomentReq) String() string { return proto.CompactTextString(m) }
func (*CommentOneWorkMomentReq) ProtoMessage() {}
func (*CommentOneWorkMomentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{30}
return fileDescriptor_office_f560032e7c752d4f, []int{30}
}
func (m *CommentOneWorkMomentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CommentOneWorkMomentReq.Unmarshal(m, b)
@ -1709,7 +1709,7 @@ func (m *CommentOneWorkMomentResp) Reset() { *m = CommentOneWorkMomentRe
func (m *CommentOneWorkMomentResp) String() string { return proto.CompactTextString(m) }
func (*CommentOneWorkMomentResp) ProtoMessage() {}
func (*CommentOneWorkMomentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{31}
return fileDescriptor_office_f560032e7c752d4f, []int{31}
}
func (m *CommentOneWorkMomentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CommentOneWorkMomentResp.Unmarshal(m, b)
@ -1736,6 +1736,106 @@ func (m *CommentOneWorkMomentResp) GetCommonResp() *CommonResp {
return nil
}
type DeleteCommentReq struct {
WorkMomentID string `protobuf:"bytes,1,opt,name=workMomentID" json:"workMomentID,omitempty"`
ContentID string `protobuf:"bytes,2,opt,name=contentID" json:"contentID,omitempty"`
OpUserID string `protobuf:"bytes,3,opt,name=opUserID" json:"opUserID,omitempty"`
OperationID string `protobuf:"bytes,4,opt,name=operationID" json:"operationID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DeleteCommentReq) Reset() { *m = DeleteCommentReq{} }
func (m *DeleteCommentReq) String() string { return proto.CompactTextString(m) }
func (*DeleteCommentReq) ProtoMessage() {}
func (*DeleteCommentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_f560032e7c752d4f, []int{32}
}
func (m *DeleteCommentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteCommentReq.Unmarshal(m, b)
}
func (m *DeleteCommentReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DeleteCommentReq.Marshal(b, m, deterministic)
}
func (dst *DeleteCommentReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_DeleteCommentReq.Merge(dst, src)
}
func (m *DeleteCommentReq) XXX_Size() int {
return xxx_messageInfo_DeleteCommentReq.Size(m)
}
func (m *DeleteCommentReq) XXX_DiscardUnknown() {
xxx_messageInfo_DeleteCommentReq.DiscardUnknown(m)
}
var xxx_messageInfo_DeleteCommentReq proto.InternalMessageInfo
func (m *DeleteCommentReq) GetWorkMomentID() string {
if m != nil {
return m.WorkMomentID
}
return ""
}
func (m *DeleteCommentReq) GetContentID() string {
if m != nil {
return m.ContentID
}
return ""
}
func (m *DeleteCommentReq) GetOpUserID() string {
if m != nil {
return m.OpUserID
}
return ""
}
func (m *DeleteCommentReq) GetOperationID() string {
if m != nil {
return m.OperationID
}
return ""
}
type DeleteCommentResp struct {
CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DeleteCommentResp) Reset() { *m = DeleteCommentResp{} }
func (m *DeleteCommentResp) String() string { return proto.CompactTextString(m) }
func (*DeleteCommentResp) ProtoMessage() {}
func (*DeleteCommentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_f560032e7c752d4f, []int{33}
}
func (m *DeleteCommentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteCommentResp.Unmarshal(m, b)
}
func (m *DeleteCommentResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DeleteCommentResp.Marshal(b, m, deterministic)
}
func (dst *DeleteCommentResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_DeleteCommentResp.Merge(dst, src)
}
func (m *DeleteCommentResp) XXX_Size() int {
return xxx_messageInfo_DeleteCommentResp.Size(m)
}
func (m *DeleteCommentResp) XXX_DiscardUnknown() {
xxx_messageInfo_DeleteCommentResp.DiscardUnknown(m)
}
var xxx_messageInfo_DeleteCommentResp proto.InternalMessageInfo
func (m *DeleteCommentResp) GetCommonResp() *CommonResp {
if m != nil {
return m.CommonResp
}
return nil
}
type GetWorkMomentByIDReq struct {
WorkMomentID string `protobuf:"bytes,1,opt,name=workMomentID" json:"workMomentID,omitempty"`
OpUserID string `protobuf:"bytes,2,opt,name=opUserID" json:"opUserID,omitempty"`
@ -1749,7 +1849,7 @@ func (m *GetWorkMomentByIDReq) Reset() { *m = GetWorkMomentByIDReq{} }
func (m *GetWorkMomentByIDReq) String() string { return proto.CompactTextString(m) }
func (*GetWorkMomentByIDReq) ProtoMessage() {}
func (*GetWorkMomentByIDReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{32}
return fileDescriptor_office_f560032e7c752d4f, []int{34}
}
func (m *GetWorkMomentByIDReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetWorkMomentByIDReq.Unmarshal(m, b)
@ -1802,7 +1902,7 @@ func (m *GetWorkMomentByIDResp) Reset() { *m = GetWorkMomentByIDResp{} }
func (m *GetWorkMomentByIDResp) String() string { return proto.CompactTextString(m) }
func (*GetWorkMomentByIDResp) ProtoMessage() {}
func (*GetWorkMomentByIDResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{33}
return fileDescriptor_office_f560032e7c752d4f, []int{35}
}
func (m *GetWorkMomentByIDResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetWorkMomentByIDResp.Unmarshal(m, b)
@ -1851,7 +1951,7 @@ func (m *ChangeWorkMomentPermissionReq) Reset() { *m = ChangeWorkMomentP
func (m *ChangeWorkMomentPermissionReq) String() string { return proto.CompactTextString(m) }
func (*ChangeWorkMomentPermissionReq) ProtoMessage() {}
func (*ChangeWorkMomentPermissionReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{34}
return fileDescriptor_office_f560032e7c752d4f, []int{36}
}
func (m *ChangeWorkMomentPermissionReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ChangeWorkMomentPermissionReq.Unmarshal(m, b)
@ -1917,7 +2017,7 @@ func (m *ChangeWorkMomentPermissionResp) Reset() { *m = ChangeWorkMoment
func (m *ChangeWorkMomentPermissionResp) String() string { return proto.CompactTextString(m) }
func (*ChangeWorkMomentPermissionResp) ProtoMessage() {}
func (*ChangeWorkMomentPermissionResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{35}
return fileDescriptor_office_f560032e7c752d4f, []int{37}
}
func (m *ChangeWorkMomentPermissionResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ChangeWorkMomentPermissionResp.Unmarshal(m, b)
@ -1958,7 +2058,7 @@ func (m *GetUserWorkMomentsReq) Reset() { *m = GetUserWorkMomentsReq{} }
func (m *GetUserWorkMomentsReq) String() string { return proto.CompactTextString(m) }
func (*GetUserWorkMomentsReq) ProtoMessage() {}
func (*GetUserWorkMomentsReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{36}
return fileDescriptor_office_f560032e7c752d4f, []int{38}
}
func (m *GetUserWorkMomentsReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserWorkMomentsReq.Unmarshal(m, b)
@ -2019,7 +2119,7 @@ func (m *GetUserWorkMomentsResp) Reset() { *m = GetUserWorkMomentsResp{}
func (m *GetUserWorkMomentsResp) String() string { return proto.CompactTextString(m) }
func (*GetUserWorkMomentsResp) ProtoMessage() {}
func (*GetUserWorkMomentsResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{37}
return fileDescriptor_office_f560032e7c752d4f, []int{39}
}
func (m *GetUserWorkMomentsResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserWorkMomentsResp.Unmarshal(m, b)
@ -2073,7 +2173,7 @@ func (m *GetUserFriendWorkMomentsReq) Reset() { *m = GetUserFriendWorkMo
func (m *GetUserFriendWorkMomentsReq) String() string { return proto.CompactTextString(m) }
func (*GetUserFriendWorkMomentsReq) ProtoMessage() {}
func (*GetUserFriendWorkMomentsReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{38}
return fileDescriptor_office_f560032e7c752d4f, []int{40}
}
func (m *GetUserFriendWorkMomentsReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserFriendWorkMomentsReq.Unmarshal(m, b)
@ -2127,7 +2227,7 @@ func (m *GetUserFriendWorkMomentsResp) Reset() { *m = GetUserFriendWorkM
func (m *GetUserFriendWorkMomentsResp) String() string { return proto.CompactTextString(m) }
func (*GetUserFriendWorkMomentsResp) ProtoMessage() {}
func (*GetUserFriendWorkMomentsResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{39}
return fileDescriptor_office_f560032e7c752d4f, []int{41}
}
func (m *GetUserFriendWorkMomentsResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserFriendWorkMomentsResp.Unmarshal(m, b)
@ -2189,7 +2289,7 @@ func (m *WorkMomentNotificationMsg) Reset() { *m = WorkMomentNotificatio
func (m *WorkMomentNotificationMsg) String() string { return proto.CompactTextString(m) }
func (*WorkMomentNotificationMsg) ProtoMessage() {}
func (*WorkMomentNotificationMsg) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{40}
return fileDescriptor_office_f560032e7c752d4f, []int{42}
}
func (m *WorkMomentNotificationMsg) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_WorkMomentNotificationMsg.Unmarshal(m, b)
@ -2299,7 +2399,7 @@ func (m *SetUserWorkMomentsLevelReq) Reset() { *m = SetUserWorkMomentsLe
func (m *SetUserWorkMomentsLevelReq) String() string { return proto.CompactTextString(m) }
func (*SetUserWorkMomentsLevelReq) ProtoMessage() {}
func (*SetUserWorkMomentsLevelReq) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{41}
return fileDescriptor_office_f560032e7c752d4f, []int{43}
}
func (m *SetUserWorkMomentsLevelReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetUserWorkMomentsLevelReq.Unmarshal(m, b)
@ -2351,7 +2451,7 @@ func (m *SetUserWorkMomentsLevelResp) Reset() { *m = SetUserWorkMomentsL
func (m *SetUserWorkMomentsLevelResp) String() string { return proto.CompactTextString(m) }
func (*SetUserWorkMomentsLevelResp) ProtoMessage() {}
func (*SetUserWorkMomentsLevelResp) Descriptor() ([]byte, []int) {
return fileDescriptor_office_45d86d1784e03bf7, []int{42}
return fileDescriptor_office_f560032e7c752d4f, []int{44}
}
func (m *SetUserWorkMomentsLevelResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetUserWorkMomentsLevelResp.Unmarshal(m, b)
@ -2411,6 +2511,8 @@ func init() {
proto.RegisterType((*LikeOneWorkMomentResp)(nil), "office.LikeOneWorkMomentResp")
proto.RegisterType((*CommentOneWorkMomentReq)(nil), "office.CommentOneWorkMomentReq")
proto.RegisterType((*CommentOneWorkMomentResp)(nil), "office.CommentOneWorkMomentResp")
proto.RegisterType((*DeleteCommentReq)(nil), "office.DeleteCommentReq")
proto.RegisterType((*DeleteCommentResp)(nil), "office.DeleteCommentResp")
proto.RegisterType((*GetWorkMomentByIDReq)(nil), "office.GetWorkMomentByIDReq")
proto.RegisterType((*GetWorkMomentByIDResp)(nil), "office.GetWorkMomentByIDResp")
proto.RegisterType((*ChangeWorkMomentPermissionReq)(nil), "office.ChangeWorkMomentPermissionReq")
@ -2446,6 +2548,7 @@ type OfficeServiceClient interface {
DeleteOneWorkMoment(ctx context.Context, in *DeleteOneWorkMomentReq, opts ...grpc.CallOption) (*DeleteOneWorkMomentResp, error)
LikeOneWorkMoment(ctx context.Context, in *LikeOneWorkMomentReq, opts ...grpc.CallOption) (*LikeOneWorkMomentResp, error)
CommentOneWorkMoment(ctx context.Context, in *CommentOneWorkMomentReq, opts ...grpc.CallOption) (*CommentOneWorkMomentResp, error)
DeleteComment(ctx context.Context, in *DeleteCommentReq, opts ...grpc.CallOption) (*DeleteCommentResp, error)
GetWorkMomentByID(ctx context.Context, in *GetWorkMomentByIDReq, opts ...grpc.CallOption) (*GetWorkMomentByIDResp, error)
ChangeWorkMomentPermission(ctx context.Context, in *ChangeWorkMomentPermissionReq, opts ...grpc.CallOption) (*ChangeWorkMomentPermissionResp, error)
// / user self
@ -2562,6 +2665,15 @@ func (c *officeServiceClient) CommentOneWorkMoment(ctx context.Context, in *Comm
return out, nil
}
func (c *officeServiceClient) DeleteComment(ctx context.Context, in *DeleteCommentReq, opts ...grpc.CallOption) (*DeleteCommentResp, error) {
out := new(DeleteCommentResp)
err := grpc.Invoke(ctx, "/office.OfficeService/DeleteComment", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *officeServiceClient) GetWorkMomentByID(ctx context.Context, in *GetWorkMomentByIDReq, opts ...grpc.CallOption) (*GetWorkMomentByIDResp, error) {
out := new(GetWorkMomentByIDResp)
err := grpc.Invoke(ctx, "/office.OfficeService/GetWorkMomentByID", in, out, c.cc, opts...)
@ -2621,6 +2733,7 @@ type OfficeServiceServer interface {
DeleteOneWorkMoment(context.Context, *DeleteOneWorkMomentReq) (*DeleteOneWorkMomentResp, error)
LikeOneWorkMoment(context.Context, *LikeOneWorkMomentReq) (*LikeOneWorkMomentResp, error)
CommentOneWorkMoment(context.Context, *CommentOneWorkMomentReq) (*CommentOneWorkMomentResp, error)
DeleteComment(context.Context, *DeleteCommentReq) (*DeleteCommentResp, error)
GetWorkMomentByID(context.Context, *GetWorkMomentByIDReq) (*GetWorkMomentByIDResp, error)
ChangeWorkMomentPermission(context.Context, *ChangeWorkMomentPermissionReq) (*ChangeWorkMomentPermissionResp, error)
// / user self
@ -2832,6 +2945,24 @@ func _OfficeService_CommentOneWorkMoment_Handler(srv interface{}, ctx context.Co
return interceptor(ctx, in, info, handler)
}
func _OfficeService_DeleteComment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteCommentReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OfficeServiceServer).DeleteComment(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/office.OfficeService/DeleteComment",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OfficeServiceServer).DeleteComment(ctx, req.(*DeleteCommentReq))
}
return interceptor(ctx, in, info, handler)
}
func _OfficeService_GetWorkMomentByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetWorkMomentByIDReq)
if err := dec(in); err != nil {
@ -2970,6 +3101,10 @@ var _OfficeService_serviceDesc = grpc.ServiceDesc{
MethodName: "CommentOneWorkMoment",
Handler: _OfficeService_CommentOneWorkMoment_Handler,
},
{
MethodName: "DeleteComment",
Handler: _OfficeService_DeleteComment_Handler,
},
{
MethodName: "GetWorkMomentByID",
Handler: _OfficeService_GetWorkMomentByID_Handler,
@ -2995,110 +3130,113 @@ var _OfficeService_serviceDesc = grpc.ServiceDesc{
Metadata: "office/office.proto",
}
func init() { proto.RegisterFile("office/office.proto", fileDescriptor_office_45d86d1784e03bf7) }
func init() { proto.RegisterFile("office/office.proto", fileDescriptor_office_f560032e7c752d4f) }
var fileDescriptor_office_45d86d1784e03bf7 = []byte{
// 1621 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x59, 0x4f, 0x6f, 0xdc, 0x44,
0x14, 0x97, 0x77, 0xb3, 0xd9, 0xec, 0xdb, 0xb4, 0x69, 0x26, 0xff, 0xb6, 0x6e, 0x93, 0x06, 0xb7,
0x45, 0x15, 0xa0, 0x04, 0x85, 0x0a, 0x21, 0x10, 0x15, 0x6a, 0xb6, 0x8d, 0x16, 0xb2, 0x6d, 0x70,
0x12, 0x2a, 0x38, 0x10, 0xb9, 0x9b, 0x89, 0xb1, 0xb2, 0xb1, 0x5d, 0x8f, 0x93, 0xd0, 0x13, 0x52,
0xcf, 0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cd, 0x45, 0x93, 0x7a, 0x79, 0x9b, 0x6b, 0xa3,
0x86, 0x49, 0x88, 0x30, 0x74, 0xca, 0xee, 0x56, 0x74, 0x3b, 0x37, 0x57, 0x57, 0x1d, 0x98, 0x77,
0xc6, 0x0b, 0x91, 0x10, 0x3d, 0x87, 0x95, 0x92, 0x9c, 0x87, 0x2c, 0xe9, 0x60, 0x97, 0xa4, 0x60,
0xf3, 0xf6, 0x58, 0x19, 0x12, 0x3e, 0x9c, 0xff, 0x6a, 0x6e, 0x23, 0xfd, 0x1f, 0xf0, 0xa3, 0xe4,
0xe7, 0xf9, 0x34, 0xfb, 0x93, 0xef, 0xbd, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x01, 0xfa, 0xac,
0xd6, 0x26, 0x1c, 0x00, 0x00,
var fileDescriptor_office_f560032e7c752d4f = []byte{
// 1673 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x59, 0xdf, 0x6f, 0xdc, 0xc4,
0x13, 0x97, 0xef, 0x72, 0xb9, 0xdc, 0x5c, 0xda, 0x34, 0x9b, 0x5f, 0x57, 0xb7, 0x49, 0xf3, 0x75,
0xdb, 0xaf, 0x2a, 0x40, 0x09, 0x0a, 0x15, 0x42, 0x20, 0x2a, 0xd4, 0x5c, 0x1b, 0x1d, 0xe4, 0xda,
0xe0, 0x24, 0x54, 0xf0, 0x40, 0xe4, 0x5e, 0x36, 0xc6, 0xca, 0xc5, 0x76, 0xbd, 0x4e, 0x42, 0x9f,
0x90, 0x78, 0x86, 0x17, 0x78, 0xe6, 0xaf, 0xe0, 0x6f, 0x40, 0x82, 0x27, 0xc4, 0x03, 0xff, 0x01,
0xff, 0x03, 0xaf, 0x68, 0xd7, 0xf6, 0xfe, 0xb0, 0xd7, 0x77, 0x87, 0x0b, 0x0f, 0x3c, 0x9d, 0x67,
0x77, 0x76, 0x76, 0xe6, 0xb3, 0x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xdb, 0x35, 0x2a, 0xa7, 0x34, 0xff,
0x3f, 0x09, 0x1b, 0x09, 0xd1, 0x3e, 0x6f, 0x28, 0x4a, 0xd1, 0x07, 0xad, 0xe6, 0x7c, 0x52, 0x4d,
0x01, 0xcc, 0xb5, 0x51, 0xd3, 0x24, 0x44, 0x18, 0x3a, 0x65, 0x2f, 0x34, 0xba, 0x9d, 0x5b, 0xab,
0xcb, 0x31, 0xcc, 0x3b, 0xe3, 0x99, 0x48, 0x88, 0x9e, 0xc3, 0x4a, 0x49, 0xe4, 0x44, 0x96, 0x14,
0x1e, 0x4a, 0x02, 0xb9, 0x79, 0x7b, 0x2c, 0x0f, 0x09, 0x1f, 0xce, 0x7f, 0x36, 0xb7, 0x91, 0xfe,
0x57, 0xfa, 0x5e, 0xf2, 0xf3, 0x7c, 0x9a, 0xfd, 0x11, 0xfa, 0xd6, 0x5f, 0x01, 0x00, 0x00, 0xff,
0xff, 0x86, 0x7f, 0x4e, 0xa8, 0x4a, 0x1d, 0x00, 0x00,
}

View File

@ -195,6 +195,17 @@ message CommentOneWorkMomentResp {
CommonResp commonResp = 1;
}
message DeleteCommentReq {
string workMomentID = 1;
string contentID = 2;
string opUserID = 3;
string operationID = 4;
}
message DeleteCommentResp {
CommonResp commonResp = 1;
}
message GetWorkMomentByIDReq {
string workMomentID = 1;
string opUserID = 2;
@ -280,6 +291,7 @@ service OfficeService {
rpc DeleteOneWorkMoment(DeleteOneWorkMomentReq) returns(DeleteOneWorkMomentResp);
rpc LikeOneWorkMoment(LikeOneWorkMomentReq) returns(LikeOneWorkMomentResp);
rpc CommentOneWorkMoment(CommentOneWorkMomentReq) returns(CommentOneWorkMomentResp);
rpc DeleteComment(DeleteCommentReq) returns(DeleteCommentResp);
rpc GetWorkMomentByID(GetWorkMomentByIDReq) returns(GetWorkMomentByIDResp);
rpc ChangeWorkMomentPermission(ChangeWorkMomentPermissionReq) returns(ChangeWorkMomentPermissionResp);
/// user self

View File

@ -37,7 +37,7 @@ func (m *CreateDepartmentReq) Reset() { *m = CreateDepartmentReq{} }
func (m *CreateDepartmentReq) String() string { return proto.CompactTextString(m) }
func (*CreateDepartmentReq) ProtoMessage() {}
func (*CreateDepartmentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{0}
return fileDescriptor_organization_6d9a9b5829486353, []int{0}
}
func (m *CreateDepartmentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateDepartmentReq.Unmarshal(m, b)
@ -91,7 +91,7 @@ func (m *CreateDepartmentResp) Reset() { *m = CreateDepartmentResp{} }
func (m *CreateDepartmentResp) String() string { return proto.CompactTextString(m) }
func (*CreateDepartmentResp) ProtoMessage() {}
func (*CreateDepartmentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{1}
return fileDescriptor_organization_6d9a9b5829486353, []int{1}
}
func (m *CreateDepartmentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateDepartmentResp.Unmarshal(m, b)
@ -145,7 +145,7 @@ func (m *UpdateDepartmentReq) Reset() { *m = UpdateDepartmentReq{} }
func (m *UpdateDepartmentReq) String() string { return proto.CompactTextString(m) }
func (*UpdateDepartmentReq) ProtoMessage() {}
func (*UpdateDepartmentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{2}
return fileDescriptor_organization_6d9a9b5829486353, []int{2}
}
func (m *UpdateDepartmentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UpdateDepartmentReq.Unmarshal(m, b)
@ -198,7 +198,7 @@ func (m *UpdateDepartmentResp) Reset() { *m = UpdateDepartmentResp{} }
func (m *UpdateDepartmentResp) String() string { return proto.CompactTextString(m) }
func (*UpdateDepartmentResp) ProtoMessage() {}
func (*UpdateDepartmentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{3}
return fileDescriptor_organization_6d9a9b5829486353, []int{3}
}
func (m *UpdateDepartmentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UpdateDepartmentResp.Unmarshal(m, b)
@ -245,7 +245,7 @@ func (m *GetSubDepartmentReq) Reset() { *m = GetSubDepartmentReq{} }
func (m *GetSubDepartmentReq) String() string { return proto.CompactTextString(m) }
func (*GetSubDepartmentReq) ProtoMessage() {}
func (*GetSubDepartmentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{4}
return fileDescriptor_organization_6d9a9b5829486353, []int{4}
}
func (m *GetSubDepartmentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetSubDepartmentReq.Unmarshal(m, b)
@ -299,7 +299,7 @@ func (m *GetSubDepartmentResp) Reset() { *m = GetSubDepartmentResp{} }
func (m *GetSubDepartmentResp) String() string { return proto.CompactTextString(m) }
func (*GetSubDepartmentResp) ProtoMessage() {}
func (*GetSubDepartmentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{5}
return fileDescriptor_organization_6d9a9b5829486353, []int{5}
}
func (m *GetSubDepartmentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetSubDepartmentResp.Unmarshal(m, b)
@ -353,7 +353,7 @@ func (m *DeleteDepartmentReq) Reset() { *m = DeleteDepartmentReq{} }
func (m *DeleteDepartmentReq) String() string { return proto.CompactTextString(m) }
func (*DeleteDepartmentReq) ProtoMessage() {}
func (*DeleteDepartmentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{6}
return fileDescriptor_organization_6d9a9b5829486353, []int{6}
}
func (m *DeleteDepartmentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteDepartmentReq.Unmarshal(m, b)
@ -406,7 +406,7 @@ func (m *DeleteDepartmentResp) Reset() { *m = DeleteDepartmentResp{} }
func (m *DeleteDepartmentResp) String() string { return proto.CompactTextString(m) }
func (*DeleteDepartmentResp) ProtoMessage() {}
func (*DeleteDepartmentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{7}
return fileDescriptor_organization_6d9a9b5829486353, []int{7}
}
func (m *DeleteDepartmentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteDepartmentResp.Unmarshal(m, b)
@ -440,6 +440,106 @@ func (m *DeleteDepartmentResp) GetErrMsg() string {
return ""
}
type GetDepartmentParentIDListReq struct {
DepartmentID string `protobuf:"bytes,1,opt,name=departmentID" json:"departmentID,omitempty"`
OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetDepartmentParentIDListReq) Reset() { *m = GetDepartmentParentIDListReq{} }
func (m *GetDepartmentParentIDListReq) String() string { return proto.CompactTextString(m) }
func (*GetDepartmentParentIDListReq) ProtoMessage() {}
func (*GetDepartmentParentIDListReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_6d9a9b5829486353, []int{8}
}
func (m *GetDepartmentParentIDListReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetDepartmentParentIDListReq.Unmarshal(m, b)
}
func (m *GetDepartmentParentIDListReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetDepartmentParentIDListReq.Marshal(b, m, deterministic)
}
func (dst *GetDepartmentParentIDListReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetDepartmentParentIDListReq.Merge(dst, src)
}
func (m *GetDepartmentParentIDListReq) XXX_Size() int {
return xxx_messageInfo_GetDepartmentParentIDListReq.Size(m)
}
func (m *GetDepartmentParentIDListReq) XXX_DiscardUnknown() {
xxx_messageInfo_GetDepartmentParentIDListReq.DiscardUnknown(m)
}
var xxx_messageInfo_GetDepartmentParentIDListReq proto.InternalMessageInfo
func (m *GetDepartmentParentIDListReq) GetDepartmentID() string {
if m != nil {
return m.DepartmentID
}
return ""
}
func (m *GetDepartmentParentIDListReq) GetOperationID() string {
if m != nil {
return m.OperationID
}
return ""
}
type GetDepartmentParentIDListResp struct {
ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"`
ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"`
ParentIDList []string `protobuf:"bytes,3,rep,name=parentIDList" json:"parentIDList,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetDepartmentParentIDListResp) Reset() { *m = GetDepartmentParentIDListResp{} }
func (m *GetDepartmentParentIDListResp) String() string { return proto.CompactTextString(m) }
func (*GetDepartmentParentIDListResp) ProtoMessage() {}
func (*GetDepartmentParentIDListResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_6d9a9b5829486353, []int{9}
}
func (m *GetDepartmentParentIDListResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetDepartmentParentIDListResp.Unmarshal(m, b)
}
func (m *GetDepartmentParentIDListResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetDepartmentParentIDListResp.Marshal(b, m, deterministic)
}
func (dst *GetDepartmentParentIDListResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetDepartmentParentIDListResp.Merge(dst, src)
}
func (m *GetDepartmentParentIDListResp) XXX_Size() int {
return xxx_messageInfo_GetDepartmentParentIDListResp.Size(m)
}
func (m *GetDepartmentParentIDListResp) XXX_DiscardUnknown() {
xxx_messageInfo_GetDepartmentParentIDListResp.DiscardUnknown(m)
}
var xxx_messageInfo_GetDepartmentParentIDListResp proto.InternalMessageInfo
func (m *GetDepartmentParentIDListResp) GetErrCode() int32 {
if m != nil {
return m.ErrCode
}
return 0
}
func (m *GetDepartmentParentIDListResp) GetErrMsg() string {
if m != nil {
return m.ErrMsg
}
return ""
}
func (m *GetDepartmentParentIDListResp) GetParentIDList() []string {
if m != nil {
return m.ParentIDList
}
return nil
}
type CreateOrganizationUserReq struct {
OrganizationUser *sdk_ws.OrganizationUser `protobuf:"bytes,1,opt,name=organizationUser" json:"organizationUser,omitempty"`
OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"`
@ -453,7 +553,7 @@ func (m *CreateOrganizationUserReq) Reset() { *m = CreateOrganizationUse
func (m *CreateOrganizationUserReq) String() string { return proto.CompactTextString(m) }
func (*CreateOrganizationUserReq) ProtoMessage() {}
func (*CreateOrganizationUserReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{8}
return fileDescriptor_organization_6d9a9b5829486353, []int{10}
}
func (m *CreateOrganizationUserReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateOrganizationUserReq.Unmarshal(m, b)
@ -506,7 +606,7 @@ func (m *CreateOrganizationUserResp) Reset() { *m = CreateOrganizationUs
func (m *CreateOrganizationUserResp) String() string { return proto.CompactTextString(m) }
func (*CreateOrganizationUserResp) ProtoMessage() {}
func (*CreateOrganizationUserResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{9}
return fileDescriptor_organization_6d9a9b5829486353, []int{11}
}
func (m *CreateOrganizationUserResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateOrganizationUserResp.Unmarshal(m, b)
@ -553,7 +653,7 @@ func (m *UpdateOrganizationUserReq) Reset() { *m = UpdateOrganizationUse
func (m *UpdateOrganizationUserReq) String() string { return proto.CompactTextString(m) }
func (*UpdateOrganizationUserReq) ProtoMessage() {}
func (*UpdateOrganizationUserReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{10}
return fileDescriptor_organization_6d9a9b5829486353, []int{12}
}
func (m *UpdateOrganizationUserReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UpdateOrganizationUserReq.Unmarshal(m, b)
@ -606,7 +706,7 @@ func (m *UpdateOrganizationUserResp) Reset() { *m = UpdateOrganizationUs
func (m *UpdateOrganizationUserResp) String() string { return proto.CompactTextString(m) }
func (*UpdateOrganizationUserResp) ProtoMessage() {}
func (*UpdateOrganizationUserResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{11}
return fileDescriptor_organization_6d9a9b5829486353, []int{13}
}
func (m *UpdateOrganizationUserResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UpdateOrganizationUserResp.Unmarshal(m, b)
@ -653,7 +753,7 @@ func (m *CreateDepartmentMemberReq) Reset() { *m = CreateDepartmentMembe
func (m *CreateDepartmentMemberReq) String() string { return proto.CompactTextString(m) }
func (*CreateDepartmentMemberReq) ProtoMessage() {}
func (*CreateDepartmentMemberReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{12}
return fileDescriptor_organization_6d9a9b5829486353, []int{14}
}
func (m *CreateDepartmentMemberReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateDepartmentMemberReq.Unmarshal(m, b)
@ -706,7 +806,7 @@ func (m *CreateDepartmentMemberResp) Reset() { *m = CreateDepartmentMemb
func (m *CreateDepartmentMemberResp) String() string { return proto.CompactTextString(m) }
func (*CreateDepartmentMemberResp) ProtoMessage() {}
func (*CreateDepartmentMemberResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{13}
return fileDescriptor_organization_6d9a9b5829486353, []int{15}
}
func (m *CreateDepartmentMemberResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateDepartmentMemberResp.Unmarshal(m, b)
@ -753,7 +853,7 @@ func (m *GetUserInDepartmentReq) Reset() { *m = GetUserInDepartmentReq{}
func (m *GetUserInDepartmentReq) String() string { return proto.CompactTextString(m) }
func (*GetUserInDepartmentReq) ProtoMessage() {}
func (*GetUserInDepartmentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{14}
return fileDescriptor_organization_6d9a9b5829486353, []int{16}
}
func (m *GetUserInDepartmentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserInDepartmentReq.Unmarshal(m, b)
@ -807,7 +907,7 @@ func (m *GetUserInDepartmentResp) Reset() { *m = GetUserInDepartmentResp
func (m *GetUserInDepartmentResp) String() string { return proto.CompactTextString(m) }
func (*GetUserInDepartmentResp) ProtoMessage() {}
func (*GetUserInDepartmentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{15}
return fileDescriptor_organization_6d9a9b5829486353, []int{17}
}
func (m *GetUserInDepartmentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserInDepartmentResp.Unmarshal(m, b)
@ -861,7 +961,7 @@ func (m *UpdateUserInDepartmentReq) Reset() { *m = UpdateUserInDepartmen
func (m *UpdateUserInDepartmentReq) String() string { return proto.CompactTextString(m) }
func (*UpdateUserInDepartmentReq) ProtoMessage() {}
func (*UpdateUserInDepartmentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{16}
return fileDescriptor_organization_6d9a9b5829486353, []int{18}
}
func (m *UpdateUserInDepartmentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UpdateUserInDepartmentReq.Unmarshal(m, b)
@ -914,7 +1014,7 @@ func (m *UpdateUserInDepartmentResp) Reset() { *m = UpdateUserInDepartme
func (m *UpdateUserInDepartmentResp) String() string { return proto.CompactTextString(m) }
func (*UpdateUserInDepartmentResp) ProtoMessage() {}
func (*UpdateUserInDepartmentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{17}
return fileDescriptor_organization_6d9a9b5829486353, []int{19}
}
func (m *UpdateUserInDepartmentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UpdateUserInDepartmentResp.Unmarshal(m, b)
@ -962,7 +1062,7 @@ func (m *DeleteUserInDepartmentReq) Reset() { *m = DeleteUserInDepartmen
func (m *DeleteUserInDepartmentReq) String() string { return proto.CompactTextString(m) }
func (*DeleteUserInDepartmentReq) ProtoMessage() {}
func (*DeleteUserInDepartmentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{18}
return fileDescriptor_organization_6d9a9b5829486353, []int{20}
}
func (m *DeleteUserInDepartmentReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteUserInDepartmentReq.Unmarshal(m, b)
@ -1022,7 +1122,7 @@ func (m *DeleteUserInDepartmentResp) Reset() { *m = DeleteUserInDepartme
func (m *DeleteUserInDepartmentResp) String() string { return proto.CompactTextString(m) }
func (*DeleteUserInDepartmentResp) ProtoMessage() {}
func (*DeleteUserInDepartmentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{19}
return fileDescriptor_organization_6d9a9b5829486353, []int{21}
}
func (m *DeleteUserInDepartmentResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteUserInDepartmentResp.Unmarshal(m, b)
@ -1069,7 +1169,7 @@ func (m *DeleteOrganizationUserReq) Reset() { *m = DeleteOrganizationUse
func (m *DeleteOrganizationUserReq) String() string { return proto.CompactTextString(m) }
func (*DeleteOrganizationUserReq) ProtoMessage() {}
func (*DeleteOrganizationUserReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{20}
return fileDescriptor_organization_6d9a9b5829486353, []int{22}
}
func (m *DeleteOrganizationUserReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteOrganizationUserReq.Unmarshal(m, b)
@ -1122,7 +1222,7 @@ func (m *DeleteOrganizationUserResp) Reset() { *m = DeleteOrganizationUs
func (m *DeleteOrganizationUserResp) String() string { return proto.CompactTextString(m) }
func (*DeleteOrganizationUserResp) ProtoMessage() {}
func (*DeleteOrganizationUserResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{21}
return fileDescriptor_organization_6d9a9b5829486353, []int{23}
}
func (m *DeleteOrganizationUserResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DeleteOrganizationUserResp.Unmarshal(m, b)
@ -1169,7 +1269,7 @@ func (m *GetDepartmentMemberReq) Reset() { *m = GetDepartmentMemberReq{}
func (m *GetDepartmentMemberReq) String() string { return proto.CompactTextString(m) }
func (*GetDepartmentMemberReq) ProtoMessage() {}
func (*GetDepartmentMemberReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{22}
return fileDescriptor_organization_6d9a9b5829486353, []int{24}
}
func (m *GetDepartmentMemberReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetDepartmentMemberReq.Unmarshal(m, b)
@ -1223,7 +1323,7 @@ func (m *GetDepartmentMemberResp) Reset() { *m = GetDepartmentMemberResp
func (m *GetDepartmentMemberResp) String() string { return proto.CompactTextString(m) }
func (*GetDepartmentMemberResp) ProtoMessage() {}
func (*GetDepartmentMemberResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_f9b83a1db54ed9cf, []int{23}
return fileDescriptor_organization_6d9a9b5829486353, []int{25}
}
func (m *GetDepartmentMemberResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetDepartmentMemberResp.Unmarshal(m, b)
@ -1264,6 +1364,106 @@ func (m *GetDepartmentMemberResp) GetUserDepartmentMemberList() []*sdk_ws.UserDe
return nil
}
type GetDepartmentRelatedGroupIDListReq struct {
OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"`
DepartmentIDList []string `protobuf:"bytes,2,rep,name=departmentIDList" json:"departmentIDList,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetDepartmentRelatedGroupIDListReq) Reset() { *m = GetDepartmentRelatedGroupIDListReq{} }
func (m *GetDepartmentRelatedGroupIDListReq) String() string { return proto.CompactTextString(m) }
func (*GetDepartmentRelatedGroupIDListReq) ProtoMessage() {}
func (*GetDepartmentRelatedGroupIDListReq) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_6d9a9b5829486353, []int{26}
}
func (m *GetDepartmentRelatedGroupIDListReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetDepartmentRelatedGroupIDListReq.Unmarshal(m, b)
}
func (m *GetDepartmentRelatedGroupIDListReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetDepartmentRelatedGroupIDListReq.Marshal(b, m, deterministic)
}
func (dst *GetDepartmentRelatedGroupIDListReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetDepartmentRelatedGroupIDListReq.Merge(dst, src)
}
func (m *GetDepartmentRelatedGroupIDListReq) XXX_Size() int {
return xxx_messageInfo_GetDepartmentRelatedGroupIDListReq.Size(m)
}
func (m *GetDepartmentRelatedGroupIDListReq) XXX_DiscardUnknown() {
xxx_messageInfo_GetDepartmentRelatedGroupIDListReq.DiscardUnknown(m)
}
var xxx_messageInfo_GetDepartmentRelatedGroupIDListReq proto.InternalMessageInfo
func (m *GetDepartmentRelatedGroupIDListReq) GetOperationID() string {
if m != nil {
return m.OperationID
}
return ""
}
func (m *GetDepartmentRelatedGroupIDListReq) GetDepartmentIDList() []string {
if m != nil {
return m.DepartmentIDList
}
return nil
}
type GetDepartmentRelatedGroupIDListResp struct {
ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"`
ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"`
GroupIDList []string `protobuf:"bytes,3,rep,name=groupIDList" json:"groupIDList,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetDepartmentRelatedGroupIDListResp) Reset() { *m = GetDepartmentRelatedGroupIDListResp{} }
func (m *GetDepartmentRelatedGroupIDListResp) String() string { return proto.CompactTextString(m) }
func (*GetDepartmentRelatedGroupIDListResp) ProtoMessage() {}
func (*GetDepartmentRelatedGroupIDListResp) Descriptor() ([]byte, []int) {
return fileDescriptor_organization_6d9a9b5829486353, []int{27}
}
func (m *GetDepartmentRelatedGroupIDListResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetDepartmentRelatedGroupIDListResp.Unmarshal(m, b)
}
func (m *GetDepartmentRelatedGroupIDListResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetDepartmentRelatedGroupIDListResp.Marshal(b, m, deterministic)
}
func (dst *GetDepartmentRelatedGroupIDListResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetDepartmentRelatedGroupIDListResp.Merge(dst, src)
}
func (m *GetDepartmentRelatedGroupIDListResp) XXX_Size() int {
return xxx_messageInfo_GetDepartmentRelatedGroupIDListResp.Size(m)
}
func (m *GetDepartmentRelatedGroupIDListResp) XXX_DiscardUnknown() {
xxx_messageInfo_GetDepartmentRelatedGroupIDListResp.DiscardUnknown(m)
}
var xxx_messageInfo_GetDepartmentRelatedGroupIDListResp proto.InternalMessageInfo
func (m *GetDepartmentRelatedGroupIDListResp) GetErrCode() int32 {
if m != nil {
return m.ErrCode
}
return 0
}
func (m *GetDepartmentRelatedGroupIDListResp) GetErrMsg() string {
if m != nil {
return m.ErrMsg
}
return ""
}
func (m *GetDepartmentRelatedGroupIDListResp) GetGroupIDList() []string {
if m != nil {
return m.GroupIDList
}
return nil
}
func init() {
proto.RegisterType((*CreateDepartmentReq)(nil), "organization.CreateDepartmentReq")
proto.RegisterType((*CreateDepartmentResp)(nil), "organization.CreateDepartmentResp")
@ -1273,6 +1473,8 @@ func init() {
proto.RegisterType((*GetSubDepartmentResp)(nil), "organization.GetSubDepartmentResp")
proto.RegisterType((*DeleteDepartmentReq)(nil), "organization.DeleteDepartmentReq")
proto.RegisterType((*DeleteDepartmentResp)(nil), "organization.DeleteDepartmentResp")
proto.RegisterType((*GetDepartmentParentIDListReq)(nil), "organization.GetDepartmentParentIDListReq")
proto.RegisterType((*GetDepartmentParentIDListResp)(nil), "organization.GetDepartmentParentIDListResp")
proto.RegisterType((*CreateOrganizationUserReq)(nil), "organization.CreateOrganizationUserReq")
proto.RegisterType((*CreateOrganizationUserResp)(nil), "organization.CreateOrganizationUserResp")
proto.RegisterType((*UpdateOrganizationUserReq)(nil), "organization.UpdateOrganizationUserReq")
@ -1289,6 +1491,8 @@ func init() {
proto.RegisterType((*DeleteOrganizationUserResp)(nil), "organization.DeleteOrganizationUserResp")
proto.RegisterType((*GetDepartmentMemberReq)(nil), "organization.GetDepartmentMemberReq")
proto.RegisterType((*GetDepartmentMemberResp)(nil), "organization.GetDepartmentMemberResp")
proto.RegisterType((*GetDepartmentRelatedGroupIDListReq)(nil), "organization.GetDepartmentRelatedGroupIDListReq")
proto.RegisterType((*GetDepartmentRelatedGroupIDListResp)(nil), "organization.GetDepartmentRelatedGroupIDListResp")
}
// Reference imports to suppress errors if they are not otherwise used.
@ -1306,6 +1510,7 @@ type OrganizationClient interface {
UpdateDepartment(ctx context.Context, in *UpdateDepartmentReq, opts ...grpc.CallOption) (*UpdateDepartmentResp, error)
GetSubDepartment(ctx context.Context, in *GetSubDepartmentReq, opts ...grpc.CallOption) (*GetSubDepartmentResp, error)
DeleteDepartment(ctx context.Context, in *DeleteDepartmentReq, opts ...grpc.CallOption) (*DeleteDepartmentResp, error)
GetDepartmentParentIDList(ctx context.Context, in *GetDepartmentParentIDListReq, opts ...grpc.CallOption) (*GetDepartmentParentIDListResp, error)
CreateOrganizationUser(ctx context.Context, in *CreateOrganizationUserReq, opts ...grpc.CallOption) (*CreateOrganizationUserResp, error)
UpdateOrganizationUser(ctx context.Context, in *UpdateOrganizationUserReq, opts ...grpc.CallOption) (*UpdateOrganizationUserResp, error)
DeleteOrganizationUser(ctx context.Context, in *DeleteOrganizationUserReq, opts ...grpc.CallOption) (*DeleteOrganizationUserResp, error)
@ -1314,6 +1519,7 @@ type OrganizationClient interface {
DeleteUserInDepartment(ctx context.Context, in *DeleteUserInDepartmentReq, opts ...grpc.CallOption) (*DeleteUserInDepartmentResp, error)
UpdateUserInDepartment(ctx context.Context, in *UpdateUserInDepartmentReq, opts ...grpc.CallOption) (*UpdateUserInDepartmentResp, error)
GetDepartmentMember(ctx context.Context, in *GetDepartmentMemberReq, opts ...grpc.CallOption) (*GetDepartmentMemberResp, error)
GetDepartmentRelatedGroupIDList(ctx context.Context, in *GetDepartmentRelatedGroupIDListReq, opts ...grpc.CallOption) (*GetDepartmentRelatedGroupIDListResp, error)
}
type organizationClient struct {
@ -1360,6 +1566,15 @@ func (c *organizationClient) DeleteDepartment(ctx context.Context, in *DeleteDep
return out, nil
}
func (c *organizationClient) GetDepartmentParentIDList(ctx context.Context, in *GetDepartmentParentIDListReq, opts ...grpc.CallOption) (*GetDepartmentParentIDListResp, error) {
out := new(GetDepartmentParentIDListResp)
err := grpc.Invoke(ctx, "/organization.organization/GetDepartmentParentIDList", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *organizationClient) CreateOrganizationUser(ctx context.Context, in *CreateOrganizationUserReq, opts ...grpc.CallOption) (*CreateOrganizationUserResp, error) {
out := new(CreateOrganizationUserResp)
err := grpc.Invoke(ctx, "/organization.organization/CreateOrganizationUser", in, out, c.cc, opts...)
@ -1432,6 +1647,15 @@ func (c *organizationClient) GetDepartmentMember(ctx context.Context, in *GetDep
return out, nil
}
func (c *organizationClient) GetDepartmentRelatedGroupIDList(ctx context.Context, in *GetDepartmentRelatedGroupIDListReq, opts ...grpc.CallOption) (*GetDepartmentRelatedGroupIDListResp, error) {
out := new(GetDepartmentRelatedGroupIDListResp)
err := grpc.Invoke(ctx, "/organization.organization/GetDepartmentRelatedGroupIDList", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Organization service
type OrganizationServer interface {
@ -1439,6 +1663,7 @@ type OrganizationServer interface {
UpdateDepartment(context.Context, *UpdateDepartmentReq) (*UpdateDepartmentResp, error)
GetSubDepartment(context.Context, *GetSubDepartmentReq) (*GetSubDepartmentResp, error)
DeleteDepartment(context.Context, *DeleteDepartmentReq) (*DeleteDepartmentResp, error)
GetDepartmentParentIDList(context.Context, *GetDepartmentParentIDListReq) (*GetDepartmentParentIDListResp, error)
CreateOrganizationUser(context.Context, *CreateOrganizationUserReq) (*CreateOrganizationUserResp, error)
UpdateOrganizationUser(context.Context, *UpdateOrganizationUserReq) (*UpdateOrganizationUserResp, error)
DeleteOrganizationUser(context.Context, *DeleteOrganizationUserReq) (*DeleteOrganizationUserResp, error)
@ -1447,6 +1672,7 @@ type OrganizationServer interface {
DeleteUserInDepartment(context.Context, *DeleteUserInDepartmentReq) (*DeleteUserInDepartmentResp, error)
UpdateUserInDepartment(context.Context, *UpdateUserInDepartmentReq) (*UpdateUserInDepartmentResp, error)
GetDepartmentMember(context.Context, *GetDepartmentMemberReq) (*GetDepartmentMemberResp, error)
GetDepartmentRelatedGroupIDList(context.Context, *GetDepartmentRelatedGroupIDListReq) (*GetDepartmentRelatedGroupIDListResp, error)
}
func RegisterOrganizationServer(s *grpc.Server, srv OrganizationServer) {
@ -1525,6 +1751,24 @@ func _Organization_DeleteDepartment_Handler(srv interface{}, ctx context.Context
return interceptor(ctx, in, info, handler)
}
func _Organization_GetDepartmentParentIDList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetDepartmentParentIDListReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrganizationServer).GetDepartmentParentIDList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/organization.organization/GetDepartmentParentIDList",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrganizationServer).GetDepartmentParentIDList(ctx, req.(*GetDepartmentParentIDListReq))
}
return interceptor(ctx, in, info, handler)
}
func _Organization_CreateOrganizationUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateOrganizationUserReq)
if err := dec(in); err != nil {
@ -1669,6 +1913,24 @@ func _Organization_GetDepartmentMember_Handler(srv interface{}, ctx context.Cont
return interceptor(ctx, in, info, handler)
}
func _Organization_GetDepartmentRelatedGroupIDList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetDepartmentRelatedGroupIDListReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrganizationServer).GetDepartmentRelatedGroupIDList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/organization.organization/GetDepartmentRelatedGroupIDList",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrganizationServer).GetDepartmentRelatedGroupIDList(ctx, req.(*GetDepartmentRelatedGroupIDListReq))
}
return interceptor(ctx, in, info, handler)
}
var _Organization_serviceDesc = grpc.ServiceDesc{
ServiceName: "organization.organization",
HandlerType: (*OrganizationServer)(nil),
@ -1689,6 +1951,10 @@ var _Organization_serviceDesc = grpc.ServiceDesc{
MethodName: "DeleteDepartment",
Handler: _Organization_DeleteDepartment_Handler,
},
{
MethodName: "GetDepartmentParentIDList",
Handler: _Organization_GetDepartmentParentIDList_Handler,
},
{
MethodName: "CreateOrganizationUser",
Handler: _Organization_CreateOrganizationUser_Handler,
@ -1721,60 +1987,72 @@ var _Organization_serviceDesc = grpc.ServiceDesc{
MethodName: "GetDepartmentMember",
Handler: _Organization_GetDepartmentMember_Handler,
},
{
MethodName: "GetDepartmentRelatedGroupIDList",
Handler: _Organization_GetDepartmentRelatedGroupIDList_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "organization/organization.proto",
}
func init() {
proto.RegisterFile("organization/organization.proto", fileDescriptor_organization_f9b83a1db54ed9cf)
proto.RegisterFile("organization/organization.proto", fileDescriptor_organization_6d9a9b5829486353)
}
var fileDescriptor_organization_f9b83a1db54ed9cf = []byte{
// 715 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xdf, 0x6e, 0x12, 0x4f,
0x14, 0xce, 0xfe, 0xf8, 0x59, 0xe5, 0xb4, 0x31, 0x64, 0x4a, 0x70, 0xbb, 0xa6, 0x91, 0xa2, 0x4d,
0xb9, 0x82, 0xa4, 0x5e, 0x7a, 0x67, 0x31, 0x2d, 0x89, 0x48, 0x82, 0xe9, 0x05, 0xde, 0x90, 0x45,
0x46, 0x42, 0x90, 0xdd, 0xe9, 0xcc, 0x22, 0x49, 0x5f, 0xc2, 0x2b, 0x6f, 0x8c, 0x4f, 0xe0, 0x95,
0x8f, 0xe2, 0x23, 0x99, 0xdd, 0xa5, 0x38, 0x7b, 0xe6, 0x2c, 0xc5, 0x05, 0x4c, 0xbd, 0x9c, 0x61,
0xe6, 0x7c, 0xe7, 0x7c, 0xe7, 0xcf, 0x7c, 0x2c, 0x3c, 0xf1, 0xe5, 0xd0, 0xf5, 0x46, 0xd7, 0x6e,
0x30, 0xf2, 0xbd, 0xba, 0xbe, 0xa8, 0x09, 0xe9, 0x07, 0x3e, 0xdb, 0xd3, 0xf7, 0x9c, 0xa3, 0xb6,
0xe0, 0x5e, 0xaf, 0xd9, 0xaa, 0x8b, 0xf1, 0xb0, 0x1e, 0x1d, 0xa8, 0xab, 0xc1, 0xb8, 0x37, 0x53,
0xf5, 0x99, 0x8a, 0x2f, 0x54, 0xbe, 0x5a, 0xb0, 0x7f, 0x26, 0xb9, 0x1b, 0xf0, 0x06, 0x17, 0xae,
0x0c, 0x26, 0xdc, 0x0b, 0x3a, 0xfc, 0x8a, 0xbd, 0x82, 0x87, 0x83, 0xc5, 0x46, 0xd3, 0xfb, 0xe0,
0xdb, 0x56, 0xd9, 0xaa, 0xee, 0x9e, 0x1e, 0xd6, 0x14, 0x97, 0x9f,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x72, 0xdb, 0x11, 0x25, 0x42, 0xd3, 0x58,
0x60, 0x62, 0xd3, 0x84, 0x38, 0xc6, 0xa6, 0x49, 0x8d, 0xda, 0x85, 0x02, 0xd6, 0x7d, 0xd8, 0x34,
0xa1, 0x48, 0xb1, 0x69, 0x52, 0x3a, 0x76, 0xa1, 0x80, 0x85, 0x14, 0x36, 0x4d, 0x28, 0x3c, 0x6c,
0x9a, 0xd4, 0x62, 0x63, 0x28, 0xd1, 0x62, 0x85, 0x9d, 0x50, 0x74, 0x12, 0x4d, 0xe9, 0x54, 0x57,
0x3b, 0x18, 0x83, 0xd1, 0xe2, 0x00, 0x83, 0xa5, 0xca, 0x1d, 0x0c, 0xb6, 0x44, 0x6b, 0x8c, 0xa1,
0x44, 0x77, 0x35, 0x06, 0x4b, 0x1d, 0x37, 0x18, 0x6c, 0xc9, 0x90, 0x58, 0xd0, 0x88, 0x2b, 0x9c,
0xa6, 0x91, 0x98, 0x0d, 0x34, 0x8d, 0x64, 0x1f, 0xf7, 0xa3, 0xff, 0x36, 0x78, 0xde, 0xb2, 0x67,
0x46, 0x25, 0x11, 0x2f, 0x85, 0x73, 0xbc, 0xc2, 0x29, 0x9d, 0x3d, 0x03, 0x86, 0x64, 0x8f, 0x42,
0xaa, 0xae, 0x76, 0x50, 0xaf, 0x8b, 0xdb, 0xc0, 0x52, 0x5f, 0x7f, 0xba, 0x2e, 0x48, 0xb0, 0x98,
0x3d, 0x23, 0x4f, 0x26, 0x7b, 0x54, 0x92, 0x8e, 0x57, 0x38, 0xa5, 0xc4, 0xcb, 0xc3, 0x77, 0x8f,
0x6b, 0x89, 0x8f, 0x1b, 0x2f, 0xf4, 0x45, 0x7f, 0x27, 0xfa, 0x72, 0xf1, 0xfc, 0x57, 0x00, 0x00,
0x00, 0xff, 0xff, 0x63, 0xc0, 0xb1, 0xa3, 0x0d, 0x11, 0x00, 0x00,
var fileDescriptor_organization_6d9a9b5829486353 = []byte{
// 846 bytes of a gzipped FileDescriptorProto
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, 0xc6, 0xc3, 0x88, 0x36, 0xcb, 0xae, 0xd8, 0x8e, 0xd5, 0xa1, 0x46, 0xb6, 0xb5, 0xbc,
0x23, 0xe3, 0xd8, 0xdc, 0x99, 0xe1, 0x94, 0x1c, 0x3d, 0x4d, 0x0d, 0x1a, 0x3d, 0x4c, 0x53, 0x65,
0xb6, 0x83, 0xf2, 0xbb, 0x98, 0xa6, 0x2c, 0x95, 0x62, 0xe1, 0xef, 0x02, 0x55, 0x16, 0x45, 0x4f,
0xcb, 0xd3, 0xf6, 0x84, 0xaa, 0x19, 0x27, 0x69, 0x67, 0x86, 0x53, 0x3e, 0x23, 0x5f, 0x0c, 0xd8,
0x98, 0xd2, 0xc4, 0xc9, 0xd3, 0x09, 0x50, 0xe8, 0x9c, 0x31, 0x9f, 0x5d, 0xf3, 0x86, 0xcf, 0x5e,
0xae, 0xbf, 0x7f, 0x54, 0x4d, 0xfc, 0x4f, 0xf7, 0x42, 0xfe, 0xe8, 0x2e, 0x8a, 0x3f, 0xe1, 0x9e,
0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x3f, 0xfc, 0xb9, 0x33, 0xd8, 0x13, 0x00, 0x00,
}

View File

@ -51,6 +51,17 @@ message DeleteDepartmentResp{
string errMsg = 2;
}
message GetDepartmentParentIDListReq {
string departmentID = 1;
string operationID = 2;
}
message GetDepartmentParentIDListResp {
int32 errCode = 1;
string errMsg = 2;
repeated string parentIDList = 3;
}
message CreateOrganizationUserReq{
server_api_params.OrganizationUser organizationUser = 1;
@ -148,12 +159,23 @@ message GetDepartmentMemberResp{
repeated server_api_params.UserDepartmentMember userDepartmentMemberList = 3;
}
message GetDepartmentRelatedGroupIDListReq {
string operationID = 1;
repeated string departmentIDList = 2;
}
message GetDepartmentRelatedGroupIDListResp {
int32 errCode = 1;
string errMsg = 2;
repeated string groupIDList = 3;
}
service organization{
rpc CreateDepartment(CreateDepartmentReq) returns(CreateDepartmentResp);
rpc UpdateDepartment(UpdateDepartmentReq) returns(UpdateDepartmentResp);
rpc GetSubDepartment(GetSubDepartmentReq) returns(GetSubDepartmentResp);
rpc DeleteDepartment(DeleteDepartmentReq) returns(DeleteDepartmentResp);
rpc GetDepartmentParentIDList(GetDepartmentParentIDListReq) returns(GetDepartmentParentIDListResp);
rpc CreateOrganizationUser(CreateOrganizationUserReq) returns(CreateOrganizationUserResp);
rpc UpdateOrganizationUser(UpdateOrganizationUserReq) returns(UpdateOrganizationUserResp);
@ -165,6 +187,7 @@ service organization{
rpc DeleteUserInDepartment(DeleteUserInDepartmentReq) returns(DeleteUserInDepartmentResp);
rpc UpdateUserInDepartment(UpdateUserInDepartmentReq) returns(UpdateUserInDepartmentResp);
rpc GetDepartmentMember(GetDepartmentMemberReq) returns(GetDepartmentMemberResp);
rpc GetDepartmentRelatedGroupIDList(GetDepartmentRelatedGroupIDListReq) returns(GetDepartmentRelatedGroupIDListResp);
}

View File

@ -6,27 +6,33 @@ import (
)
type Statistics struct {
Count *uint64
AllCount *uint64
ModuleName string
PrintArgs string
SleepTime int
}
func (s *Statistics) output() {
var intervalCount uint64
t := time.NewTicker(time.Duration(s.SleepTime) * time.Second)
defer t.Stop()
var sum uint64
for {
sum = *s.Count
sum = *s.AllCount
select {
case <-t.C:
}
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.Count-sum, "total:", *s.Count)
if *s.AllCount-sum <= 0 {
intervalCount = 0
} else {
intervalCount = *s.AllCount - sum
}
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, intervalCount, "total:", *s.AllCount)
}
}
func NewStatistics(count *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
p := &Statistics{Count: count, ModuleName: moduleName, SleepTime: sleepTime, PrintArgs: printArgs}
func NewStatistics(allCount *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
p := &Statistics{AllCount: allCount, ModuleName: moduleName, SleepTime: sleepTime, PrintArgs: printArgs}
go p.output()
return p
}

View File

@ -2,6 +2,7 @@ package utils
import (
"Open_IM/pkg/common/constant"
"errors"
"fmt"
"math/rand"
"os"
@ -37,3 +38,40 @@ func GetNewFileNameAndContentType(fileName string, fileType int) (string, string
}
return newName, contentType
}
func GetUploadAppNewName(appType int, version, fileName, yamlName string) (string, string, error) {
var newFileName, newYamlName = "_" + version + "_app", "_" + version + "_yaml"
switch appType {
case constant.IOSPlatformID:
newFileName = constant.IOSPlatformStr + newFileName
newYamlName = constant.IOSPlatformStr + newYamlName
case constant.AndroidPlatformID:
newFileName = constant.AndroidPlatformStr + newFileName
newYamlName = constant.AndroidPlatformStr + newYamlName
case constant.WindowsPlatformID:
newFileName = constant.WindowsPlatformStr + newFileName
newYamlName = constant.WindowsPlatformStr + newYamlName
case constant.OSXPlatformID:
newFileName = constant.OSXPlatformStr + newFileName
newYamlName = constant.OSXPlatformStr + newYamlName
case constant.WebPlatformID:
newFileName = constant.WebPlatformStr + newFileName
newYamlName = constant.WebPlatformStr + newYamlName
case constant.MiniWebPlatformID:
newFileName = constant.MiniWebPlatformStr + newFileName
newYamlName = constant.MiniWebPlatformStr + newYamlName
case constant.LinuxPlatformID:
newFileName = constant.LinuxPlatformStr + newFileName
newYamlName = constant.LinuxPlatformStr + newYamlName
default:
return "", "", errors.New("invalid app type")
}
suffixFile := path.Ext(fileName)
suffixYaml := path.Ext(yamlName)
newFileName = fmt.Sprintf("%s%s", newFileName, suffixFile)
newYamlName = fmt.Sprintf("%s%s", newYamlName, suffixYaml)
if yamlName == "" {
newYamlName = ""
}
return newFileName, newYamlName, nil
}

View File

@ -1,26 +1,28 @@
package utils
import (
"Open_IM/pkg/common/config"
"errors"
"fmt"
"net"
)
var ServerIP = ""
func init() {
//fixme In the configuration file, ip takes precedence, if not, get the valid network card ip of the machine
if config.Config.ServerIP != "" {
ServerIP = config.Config.ServerIP
return
}
// see https://gist.github.com/jniltinho/9787946#gistcomment-3019898
conn, err := net.Dial("udp", "8.8.8.8:80")
func GetLocalIP() (string, error) {
addrs, err := net.InterfaceAddrs()
if err != nil {
panic(err.Error())
return "", err
}
for _, address := range addrs {
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
fmt.Println(ipnet.IP.String())
return ipnet.IP.String(), nil
}
}
}
defer conn.Close()
localAddr := conn.LocalAddr().(*net.UDPAddr)
ServerIP = localAddr.IP.String()
return "", errors.New("no ip")
}

View File

@ -1,38 +0,0 @@
#!/usr/bin/env bash
source ./style_info.cfg
source ./path_info.cfg
source ./function.sh
#define database attributes
address=$(cat $config_path | grep -w dbMysqlAddress)
list_to_string ${address}
hostAndPort=($ports_array)
DATABASE_HOST=$(echo $hostAndPort | awk -F '[:]' '{print $1}')
DATABASE_PORT=$(echo $hostAndPort | awk -F '[:]' '{print $NF}')
DATABASE_USERNAME=$(cat $config_path | grep -w dbMysqlUserName | awk -F '[:]' '{print $NF}')
DATABASE_PWD=`eval echo $(cat $config_path | grep -w dbMysqlPassword | awk -F '[:]' '{print $NF}')`
DATABASE_NAME=$(cat $config_path | grep -w dbMysqlDatabaseName | awk -F '[:]' '{print $NF}')
SQL_FILE="../config/mysql_sql_file/openIM.sql"
create_data_sql="create database IF NOT EXISTS $DATABASE_NAME"
set_character_code_sql="alter database $DATABASE_NAME character set utf8mb4 collate utf8mb4_general_ci"
echo -e "${SKY_BLUE_PREFIX}start to create database.....$COLOR_SUFFIX"
mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$create_data_sql"
if [ $? -eq 0 ]; then
echo -e "${SKY_BLUE_PREFIX}create database ${DATABASE_NAME} successfully$COLOR_SUFFIX"
mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$set_character_code_sql"
else
echo -e "${RED_PREFIX}create database failed or exists the database$COLOR_SUFFIX\n"
fi
echo -e "${SKY_BLUE_PREFIX}start to source openIM.sql .....$COLOR_SUFFIX"
mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -D $DATABASE_NAME <$SQL_FILE
if [ $? -eq 0 ]; then
echo -e "${SKY_BLUE_PREFIX}source openIM.sql successfully$COLOR_SUFFIX"
else
echo -e "${RED_PREFIX}source openIM.sql failed$COLOR_SUFFIX\n"
fi

View File

@ -19,10 +19,6 @@ msg_transfer_source_root="../cmd/open_im_msg_transfer/"
msg_transfer_service_num=2
timer_task_name="open_im_timer_task"
timer_task_binary_root="../bin/"
timer_task_source_root="../cmd/open_im_timer_task/"
sdk_server_name="open_im_sdk_server"
sdk_server_binary_root="../bin/"
sdk_server_source_root="../cmd/Open-IM-SDK-Core/"

View File

@ -1,35 +0,0 @@
#!/usr/bin/env bash
#Include shell font styles and some basic information
source ./style_info.cfg
source ./path_info.cfg
#Check if the service exists
#If it is exists,kill this process
check=`ps aux | grep -w ./${timer_task_name} | grep -v grep| wc -l`
if [ $check -ge 1 ]
then
oldPid=`ps aux | grep -w ./${timer_task_name} | grep -v grep|awk '{print $2}'`
kill -9 $oldPid
fi
#Waiting port recycling
sleep 1
cd ${timer_task_binary_root}
nohup ./${timer_task_name} >>../logs/openIM.log 2>&1 &
#Check launched service process
check=`ps aux | grep -w ./${timer_task_name} | grep -v grep| wc -l`
if [ $check -ge 1 ]
then
newPid=`ps aux | grep -w ./${timer_task_name} | grep -v grep|awk '{print $2}'`
allPorts=""
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${timer_task_name}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX}
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
else
echo -e ${YELLOW_PREFIX}${timer_task_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
fi