Merge remote-tracking branch 'origin/main'

This commit is contained in:
wenxu12345 2022-04-08 16:21:12 +08:00
commit 68ff4a52dc
70 changed files with 7103 additions and 5159 deletions

View File

@ -10,19 +10,29 @@ import (
"Open_IM/internal/api/office"
apiThird "Open_IM/internal/api/third"
"Open_IM/internal/api/user"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"flag"
"io"
"os"
"strconv"
"github.com/gin-gonic/gin"
//"syscall"
"Open_IM/pkg/common/constant"
)
func main() {
log.NewPrivateLog(constant.LogFileName)
gin.SetMode(gin.ReleaseMode)
f, _ := os.Create("../logs/api.log")
gin.DefaultWriter = io.MultiWriter(f)
r := gin.Default()
r.Use(utils.CorsHandler())
log.Info("load config: ", config.Config)
// user routing group, which handles user registration and login services
userRouterGroup := r.Group("/user")
{
@ -67,7 +77,11 @@ func main() {
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
groupRouterGroup.POST("/dismiss_group", group.DismissGroup)
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
groupRouterGroup.POST("/cancel_mute_group_member", group.CancelMuteGroupMember) //MuteGroup
groupRouterGroup.POST("/mute_group", group.MuteGroup)
groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup)
}
//certificate
authRouterGroup := r.Group("/auth")
@ -114,14 +128,14 @@ func main() {
officeGroup := r.Group("/office")
{
officeGroup.POST("/get_user_tags", office.GetUserTags)
officeGroup.POST("/get_user_tag_by_id", office.GetUserTagByID)
officeGroup.POST("/create_tag", office.CreateTag)
officeGroup.POST("/delete_tag", office.DeleteTag)
officeGroup.POST("/set_tag", office.SetTag)
officeGroup.POST("/send_msg_to_tag", office.SendMsg2Tag)
officeGroup.POST("/get_send_tag_log", office.GetTagSendLogs)
}
apiThird.MinioInit()
log.NewPrivateLog("api")
go apiThird.MinioInit()
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
flag.Parse()
r.Run(":" + strconv.Itoa(*ginPort))

View File

@ -2,15 +2,22 @@ package main
import (
"Open_IM/internal/demo/register"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"flag"
"io"
"os"
"strconv"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"github.com/gin-gonic/gin"
)
func main() {
log.NewPrivateLog(constant.LogFileName)
gin.SetMode(gin.ReleaseMode)
f, _ := os.Create("../logs/api.log")
gin.DefaultWriter = io.MultiWriter(f)
r := gin.Default()
r.Use(utils.CorsHandler())
@ -23,7 +30,7 @@ func main() {
authRouterGroup.POST("/login", register.Login)
authRouterGroup.POST("/reset_password", register.ResetPassword)
}
log.NewPrivateLog("demo")
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
flag.Parse()
r.Run(":" + strconv.Itoa(*ginPort))

View File

@ -2,11 +2,14 @@ package main
import (
"Open_IM/internal/msg_gateway/gate"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"flag"
"sync"
)
func main() {
log.NewPrivateLog(constant.LogFileName)
rpcPort := flag.Int("rpc_port", 10400, "rpc listening port")
wsPort := flag.Int("ws_port", 17778, "ws listening port")
flag.Parse()

View File

@ -2,12 +2,15 @@ package main
import (
"Open_IM/internal/msg_transfer/logic"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"sync"
)
func main() {
var wg sync.WaitGroup
wg.Add(1)
log.NewPrivateLog(constant.LogFileName)
logic.Init()
logic.Run()
wg.Wait()

View File

@ -2,6 +2,8 @@ package main
import (
"Open_IM/internal/push/logic"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"flag"
"sync"
)
@ -11,6 +13,7 @@ func main() {
flag.Parse()
var wg sync.WaitGroup
wg.Add(1)
log.NewPrivateLog(constant.LogFileName)
logic.Init(*rpcPort)
logic.Run()
wg.Wait()

View File

@ -1,14 +1,12 @@
package main
import (
commonDB "Open_IM/pkg/common/db"
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"time"
)
func main() {
log.NewPrivateLog("timer")
log.NewPrivateLog(constant.LogFileName)
//for {
// fmt.Println("start delete mongodb expired record")
// timeUnixBegin := time.Now().Unix()
@ -39,27 +37,27 @@ func main() {
// 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)
}
}
}
//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

@ -92,7 +92,7 @@ credential: #腾讯cos发送图片、视频、文件时需要请自行申
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK中 object_storage参数为minio
bucket: openim
location: us-east-1
endpoint: http://127.0.0.1:9000
endpoint: http://121.37.25.71:9000
accessKeyID: user12345
secretAccessKey: key12345
ali: # ali oss
@ -148,7 +148,7 @@ log:
rotationTime: 24
remainRotationCount: 3 #日志数量
#日志级别 6表示全都打印测试阶段建议设置为6
remainLogLevel: 4
remainLogLevel: 6
elasticSearchSwitch: false
elasticSearchAddr: [ 127.0.0.1:9201 ]
elasticSearchUser: ""
@ -366,6 +366,56 @@ notification:
ext: "groupDismissed ext"
defaultTips:
tips: "group dismissed"
groupMuted:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "groupMuted title"
desc: "groupMuted desc"
ext: "groupMuted ext"
defaultTips:
tips: "group Muted"
groupCancelMuted:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "groupCancelMuted title"
desc: "groupCancelMuted desc"
ext: "groupCancelMuted ext"
defaultTips:
tips: "group Cancel Muted"
groupMemberMuted:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "groupMemberMuted title"
desc: "groupMemberMuted desc"
ext: "groupMemberMuted ext"
defaultTips:
tips: "group Member Muted"
groupMemberCancelMuted:
conversation:
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "groupMemberCancelMuted title"
desc: "groupMemberCancelMuted desc"
ext: "groupMemberCancelMuted ext"
defaultTips:
tips: "group Member Cancel Muted"
#############################friend#################################
friendApplicationAdded:
@ -501,6 +551,19 @@ notification:
defaultTips:
tips: "conversation opt update"
conversationSetPrivate:
conversation:
reliabilityLevel: 2
unreadCount: true
offlinePush:
switch: true
title: "burn after reading"
desc: "burn after reading"
ext: "burn after reading"
defaultTips:
openTips: "burn after reading was opened"
closeTips: "burn after reading was closed"
#---------------demo configuration---------------------#
@ -525,5 +588,6 @@ demo:
smtpAddr: "smtp.qq.com"
smtpPort: 25 #需开放此端口 出口方向
rtc:
port: 11300
address: 127.0.0.1

2
go.mod
View File

@ -22,7 +22,7 @@ require (
github.com/gin-gonic/gin v1.7.0
github.com/go-playground/validator/v10 v10.4.1
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/gogo/protobuf v1.3.2
github.com/golang-jwt/jwt/v4 v4.1.0
github.com/golang/protobuf v1.5.2
github.com/golang/snappy v0.0.4 // indirect

6
go.sum
View File

@ -53,6 +53,7 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alibabacloud-go/darabonba-openapi v0.1.7/go.mod h1:6FV1Bt1AItYIlC2rVopPTumrRNtkfPBmrPVAZ8v2bLk=
github.com/alibabacloud-go/darabonba-openapi v0.1.11 h1:w59gtSA0s87p0U5NNG/N/PIHsRP3rtj7qCP9hx9+GL8=
github.com/alibabacloud-go/darabonba-openapi v0.1.11/go.mod h1:MPJMxv7HYrFm5m9uOZWkDYsAWyZztEgnBRfk9Fg0eIU=
github.com/alibabacloud-go/darabonba-string v1.0.0/go.mod h1:93cTfV3vuPhhEwGGpKKqhVW4jLe7tDpo3LUM0i0g6mA=
@ -62,8 +63,11 @@ github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8 h1:KXMiCg99Jx7B6V+DlRFbWw
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8/go.mod h1:8aL6tSyQIWJygF7W/Vqxdf/QDbN2S+u57k36bEA8hD8=
github.com/alibabacloud-go/endpoint-util v1.1.0 h1:r/4D3VSw888XGaeNpP994zDUaxdgTSHBbVfZlzf6b5Q=
github.com/alibabacloud-go/endpoint-util v1.1.0/go.mod h1:O5FuCALmCKs2Ff7JFJMudHs0I5EBgecXXxZRyswlEjE=
github.com/alibabacloud-go/openapi-util v0.0.8/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
github.com/alibabacloud-go/openapi-util v0.0.9 h1:Z0DP4LFzkM/rW2nxOMiiLoQVZSeE3jVc5jrZ9Fd/UX0=
github.com/alibabacloud-go/openapi-util v0.0.9/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
github.com/alibabacloud-go/sts-20150401 v1.1.0 h1:1yVyKz02ES6aKo3xVjmoPLBH1OAmmSqPkhKRdjEkmYs=
github.com/alibabacloud-go/sts-20150401 v1.1.0/go.mod h1:QW4O/c7Hp4krHYt+6xwnoG8EyZW3V9GYkl6EgIBmxJc=
github.com/alibabacloud-go/tea v1.1.0/go.mod h1:IkGyUSX4Ba1V+k4pCtJUc6jDpZLFph9QMy2VUPTwukg=
github.com/alibabacloud-go/tea v1.1.7/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4=
github.com/alibabacloud-go/tea v1.1.8/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4=
@ -1095,6 +1099,8 @@ gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c=
gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw=
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=

View File

@ -35,10 +35,16 @@ func UserRegister(c *gin.Context) {
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
client := rpc.NewAuthClient(etcdConn)
reply, err := client.UserRegister(context.Background(), req)
if err != nil || reply.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "UserRegister failed ", err, reply.CommonResp.ErrCode)
if err != nil {
log.NewError(req.OperationID, "call rpc err ", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "internal service err"})
return
}
if reply.CommonResp.ErrCode != 0 {
log.NewError(req.OperationID, "UserRegister failed ", err)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": reply.CommonResp.ErrMsg})
return
}
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}

View File

@ -128,7 +128,7 @@ func GetConversation(c *gin.Context) {
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.GetConversation(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation rpc failed, ", reqPb.String(), err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
return
}
@ -192,7 +192,7 @@ func SetRecvMsgOpt(c *gin.Context) {
client := pbUser.NewUserClient(etcdConn)
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetRecvMsgOpt rpc failed, ", reqPb.String(), err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
return
}

View File

@ -568,3 +568,131 @@ func DismissGroup(c *gin.Context) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
c.JSON(http.StatusOK, resp)
}
func MuteGroupMember(c *gin.Context) {
params := api.MuteGroupMemberReq{}
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.MuteGroupMemberReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = 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"})
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)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.MuteGroupMember(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.MuteGroupMemberResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
c.JSON(http.StatusOK, resp)
}
func CancelMuteGroupMember(c *gin.Context) {
params := api.CancelMuteGroupMemberReq{}
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.CancelMuteGroupMemberReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = 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"})
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)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.CancelMuteGroupMember(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.CancelMuteGroupMemberResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
c.JSON(http.StatusOK, resp)
}
func MuteGroup(c *gin.Context) {
params := api.MuteGroupReq{}
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.MuteGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = 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"})
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)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.MuteGroup(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.MuteGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
c.JSON(http.StatusOK, resp)
}
func CancelMuteGroup(c *gin.Context) {
params := api.CancelMuteGroupReq{}
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.CancelMuteGroupReq{}
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = 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"})
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)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.CancelMuteGroup(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.CancelMuteGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
c.JSON(http.StatusOK, resp)
}

View File

@ -140,7 +140,7 @@ func ManagementSendMsg(c *gin.Context) {
}
log.NewInfo("", data, params)
token := c.Request.Header.Get("token")
claims, err := token_verify.ParseToken(token)
claims, err := token_verify.ParseToken(token, params.OperationID)
if err != nil {
log.NewError(params.OperationID, "parse token failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "parse token failed", "sendTime": 0, "MsgID": ""})
@ -218,16 +218,16 @@ type ManagementSendMsgReq struct {
type PictureBaseInfo struct {
UUID string `mapstructure:"uuid"`
Type string `mapstructure:"type" validate:"required"`
Size int64 `mapstructure:"size" validate:"required"`
Width int32 `mapstructure:"width" validate:"required"`
Height int32 `mapstructure:"height" validate:"required"`
Url string `mapstructure:"url" validate:"required"`
Type string `mapstructure:"type" `
Size int64 `mapstructure:"size" `
Width int32 `mapstructure:"width" `
Height int32 `mapstructure:"height"`
Url string `mapstructure:"url" `
}
type PictureElem struct {
SourcePath string `mapstructure:"sourcePath"`
SourcePicture PictureBaseInfo `mapstructure:"sourcePicture" validate:"required"`
SourcePicture PictureBaseInfo `mapstructure:"sourcePicture"`
BigPicture PictureBaseInfo `mapstructure:"bigPicture" `
SnapshotPicture PictureBaseInfo `mapstructure:"snapshotPicture"`
}
@ -282,25 +282,15 @@ type RevokeElem struct {
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
}
type OANotificationElem struct {
NotificationName string `mapstructure:"notificationName" validate:"required"`
NotificationFaceURL string `mapstructure:"notificationFaceURL" validate:"required"`
NotificationType int32 `mapstructure:"notificationType" validate:"required"`
Text string `mapstructure:"text" validate:"required"`
Url string `mapstructure:"url"`
MixType int32 `mapstructure:"mixType"`
Image struct {
SourceUrl string `mapstructure:"sourceUrl"`
SnapshotUrl string `mapstructure:"snapshotUrl"`
} `mapstructure:"image"`
Video struct {
SourceUrl string `mapstructure:"sourceUrl"`
SnapshotUrl string `mapstructure:"snapshotUrl"`
Duration int64 `mapstructure:"duration"`
} `mapstructure:"video"`
File struct {
SourceUrl string `mapstructure:"sourceUrl"`
FileName string `mapstructure:"fileName"`
FileSize int64 `mapstructure:"fileSize"`
} `mapstructure:"file"`
Ex string `mapstructure:"ex"`
NotificationName string `mapstructure:"notificationName" validate:"required"`
NotificationFaceURL string `mapstructure:"notificationFaceURL" validate:"required"`
NotificationType int32 `mapstructure:"notificationType" validate:"required"`
Text string `mapstructure:"text" validate:"required"`
Url string `mapstructure:"url"`
MixType int32 `mapstructure:"mixType"`
PictureElem PictureElem `mapstructure:"pictureElem"`
SoundElem SoundElem `mapstructure:"soundElem"`
VideoElem VideoElem `mapstructure:"videoElem"`
FileElem FileElem `mapstructure:"fileElem"`
Ex string `mapstructure:"ex"`
}

View File

@ -46,7 +46,11 @@ func GetUserTags(c *gin.Context) {
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
resp.Data.Tags = respPb.Tags
if respPb.Tags != nil {
resp.Data.Tags = respPb.Tags
} else {
resp.Data.Tags = []*pbOffice.Tag{}
}
c.JSON(http.StatusOK, resp)
}
@ -229,8 +233,48 @@ func GetTagSendLogs(c *gin.Context) {
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
resp.Data.Logs = respPb.TagSendLogs
if respPb.TagSendLogs != nil {
resp.Data.Logs = respPb.TagSendLogs
} else {
resp.Data.Logs = []*pbOffice.TagSendLog{}
}
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
c.JSON(http.StatusOK, resp)
}
func GetUserTagByID(c *gin.Context) {
var (
req apistruct.GetUserTagByIDReq
resp apistruct.GetUserTagByIDResp
reqPb pbOffice.GetUserTagByIDReq
respPb *pbOffice.GetUserTagByIDResp
)
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
}
ok, userID := 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"})
return
}
reqPb.UserID = userID
reqPb.OperationID = req.OperationID
reqPb.TagID = req.TagID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.GetUserTagByID(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTagByID failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
return
}
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
resp.Data.Tag = respPb.Tag
c.JSON(http.StatusOK, resp)
}

View File

@ -15,18 +15,21 @@ var (
)
func MinioInit() {
log.NewInfo("", utils.GetSelfFuncName())
operationID := utils.OperationIDGenerator()
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio config: ", config.Config.Credential.Minio)
minioUrl, err := url2.Parse(config.Config.Credential.Minio.Endpoint)
if err != nil {
log.NewError("", utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
return
}
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,
})
log.NewInfo(operationID, utils.GetSelfFuncName(), "new ok ", config.Config.Credential.Minio)
if err != nil {
log.NewError("", utils.GetSelfFuncName(), "init minio client failed", err.Error())
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
return
}
opt := minio.MakeBucketOptions{
@ -35,15 +38,15 @@ func MinioInit() {
}
err = minioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
if err != nil {
log.NewInfo("", utils.GetSelfFuncName(), err.Error())
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.NewInfo("", utils.GetSelfFuncName(), "We already own %s\n", config.Config.Credential.Minio.Bucket)
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
} else {
if err != nil {
log.NewError("", utils.GetSelfFuncName(), err.Error())
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
}
log.NewError("", utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
log.NewError(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
return
}
}
@ -53,5 +56,5 @@ func MinioInit() {
// log.NewError("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
// return
//}
log.NewInfo("", utils.GetSelfFuncName(), "minio create and set policy success")
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio create and set policy success")
}

View File

@ -81,7 +81,7 @@ func MinioUploadFile(c *gin.Context) {
_, 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.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file path" + err.Error()})
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "invalid file path" + err.Error()})
return
}
resp.NewName = newName

View File

@ -2,7 +2,7 @@ package gate
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/statistics"
"fmt"
"github.com/go-playground/validator/v10"
@ -20,7 +20,7 @@ var (
func Init(rpcPort, wsPort int) {
//log initialization
log.NewPrivateLog(config.Config.ModuleName.LongConnSvrName)
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)

View File

@ -6,13 +6,17 @@ import (
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbChat "Open_IM/pkg/proto/chat"
pbRtc "Open_IM/pkg/proto/rtc"
sdk_ws "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"bytes"
"context"
"encoding/gob"
"github.com/golang/protobuf/proto"
"github.com/gorilla/websocket"
"google.golang.org/grpc"
"runtime"
"strconv"
"strings"
)
@ -200,38 +204,61 @@ func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
nReply := new(pbChat.SendMsgResp)
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendSignalMsg)
if isPass {
isPass2, errCode2, errMsg2, signalResp, msgData := ws.signalMessageAssemble(pData.(*sdk_ws.SignalReq), m.OperationID)
if isPass2 {
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)
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))
ws.sendSignalMsgResp(conn, 204, "grpc SignalMessageAssemble failed: "+err.Error(), m, &signalResp)
return
}
signalResp.Payload = respPb.SignalResp.Payload
msgData := sdk_ws.MsgData{}
utils.CopyStructFields(&msgData, respPb.MsgData)
log.NewInfo(m.OperationID, utils.GetSelfFuncName(), respPb.String())
if respPb.IsPass {
pbData := pbChat.SendMsgReq{
Token: m.Token,
OperationID: m.OperationID,
MsgData: msgData,
MsgData: &msgData,
}
log.NewInfo(m.OperationID, utils.GetSelfFuncName(), "pbData: ", pbData)
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, msgData)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
client := pbChat.NewChatClient(etcdConn)
reply, err := client.SendMsg(context.Background(), &pbData)
if err != nil {
log.NewError(pbData.OperationID, "rpc sendMsg err", err.Error())
log.NewError(pbData.OperationID, utils.GetSelfFuncName(), "rpc sendMsg err", err.Error())
nReply.ErrCode = 200
nReply.ErrMsg = err.Error()
ws.sendSignalMsgResp(conn, 200, err.Error(), m, signalResp)
ws.sendSignalMsgResp(conn, 200, err.Error(), m, &signalResp)
} else {
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
ws.sendSignalMsgResp(conn, 0, "", m, signalResp)
ws.sendSignalMsgResp(conn, 0, "", m, &signalResp)
}
} else {
log.NewError(m.OperationID, isPass2, errCode2, errMsg2)
ws.sendSignalMsgResp(conn, errCode2, errMsg2, m, signalResp)
log.NewError(m.OperationID, utils.GetSelfFuncName(), respPb.IsPass, respPb.CommonResp.ErrCode, respPb.CommonResp.ErrMsg)
ws.sendSignalMsgResp(conn, respPb.CommonResp.ErrCode, respPb.CommonResp.ErrMsg, m, &signalResp)
}
} else {
ws.sendSignalMsgResp(conn, errCode, errMsg, m, nil)
}
}
func (ws *WServer) sendSignalMsgResp(conn *UserConn, errCode int32, errMsg string, m *Req, pb *sdk_ws.SignalResp) {
func (ws *WServer) sendSignalMsgResp(conn *UserConn, errCode int32, errMsg string, m *Req, pb *pbRtc.SignalResp) {
// := make(map[string]interface{})
log.Debug(m.OperationID, "SignalMsgResp is", pb.String())
b, _ := proto.Marshal(pb)
mReply := Resp{
ReqIdentifier: m.ReqIdentifier,

View File

@ -1,14 +1,5 @@
package open_im_media
import (
pbRtc "Open_IM/pkg/proto/rtc"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"context"
"errors"
"github.com/jinzhu/copier"
"google.golang.org/grpc"
)
const (
// Address gRPC服务地址
Address = "127.0.0.1:11300"
@ -23,35 +14,35 @@ func NewMedia() *Media {
return &Media{}
}
func (m *Media) GetJoinToken(room, identity string, operationID string, data *open_im_sdk.ParticipantMetaData) (string, string, error) {
var newData pbRtc.ParticipantMetaData
copier.Copy(&newData, data)
conn, err := grpc.Dial(Address, grpc.WithInsecure())
if err != nil {
return "", "", err
}
defer conn.Close()
c := pbRtc.NewRtcServiceClient(conn)
req := &pbRtc.GetJoinTokenReq{Room: room, OperationID: operationID, Identity: identity, MetaData: &newData}
resp, err := c.GetJoinToken(context.Background(), req)
if err != nil {
return "", "", err
}
if resp.CommonResp.ErrCode != 0 {
return "", "", errors.New(resp.CommonResp.ErrMsg)
}
return resp.Jwt, resp.LiveURL, nil
//at := auth.NewAccessToken(m.ApiKey, m.ApiSecret)
//grant := &auth.VideoGrant{
// RoomJoin: true,
// Room: room,
//}
//at.AddGrant(grant).
// SetIdentity(identity).
// SetValidFor(time.Hour)
//
//return at.ToJWT()
}
//func (m *Media) GetJoinToken(room, identity string, operationID string, data *open_im_sdk.ParticipantMetaData) (string, string, error) {
// var newData pbRtc.ParticipantMetaData
// copier.Copy(&newData, data)
// conn, err := grpc.Dial(Address, grpc.WithInsecure())
// if err != nil {
// return "", "", err
// }
// defer conn.Close()
// c := pbRtc.NewRtcServiceClient(conn)
// req := &pbRtc.GetJoinTokenReq{Room: room, OperationID: operationID, Identity: identity, MetaData: &newData}
// resp, err := c.GetJoinToken(context.Background(), req)
// if err != nil {
// return "", "", err
// }
// if resp.CommonResp.ErrCode != 0 {
// return "", "", errors.New(resp.CommonResp.ErrMsg)
// }
// return resp.Jwt, resp.LiveURL, nil
// //at := auth.NewAccessToken(m.ApiKey, m.ApiSecret)
// //grant := &auth.VideoGrant{
// // RoomJoin: true,
// // Room: room,
// //}
// //at.AddGrant(grant).
// // SetIdentity(identity).
// // SetValidFor(time.Hour)
// //
// //return at.ToJWT()
//}
func init() {
//roomClient = lksdk.NewRoomServiceClient(MediaAddress, ApiKey, ApiSecret)

View File

@ -7,12 +7,10 @@
package gate
import (
"Open_IM/internal/msg_gateway/gate/open_im_media"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
pbRtc "Open_IM/pkg/proto/rtc"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"errors"
"github.com/golang/protobuf/proto"
)
@ -74,7 +72,7 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
}
return true, 0, "", data
case constant.WSSendSignalMsg:
data := open_im_sdk.SignalReq{}
data := pbRtc.SignalReq{}
if err := proto.Unmarshal(m.Data, &data); err != nil {
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
return false, 203, err.Error(), nil
@ -117,139 +115,139 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
}
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
}
//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

@ -80,6 +80,22 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string)
mc.groupMsgCount++
}
go sendMessageToPush(&msgFromMQ, msgFromMQ.MsgData.RecvID)
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
}
mc.singleMsgCount++
log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", utils.GetCurrentTimestampByNano()-time)
}
if !isSenderSync && msgKey == msgFromMQ.MsgData.SendID {
} else {
go sendMessageToPush(&msgFromMQ, msgKey)
}
log.NewDebug(operationID, "saveUserChat cost time ", utils.GetCurrentTimestampByNano()-time)
default:
log.NewError(msgFromMQ.OperationID, "SessionType error", msgFromMQ.String())
return

View File

@ -2,8 +2,8 @@ package logic
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/kafka"
"Open_IM/pkg/common/log"
)
var (
@ -13,7 +13,7 @@ var (
)
func Init() {
log.NewPrivateLog(config.Config.ModuleName.MsgTransferName)
persistentCH.Init()
historyCH.Init()
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic)

View File

@ -34,26 +34,31 @@ func (pc *PersistentConsumerHandler) Init() {
func (pc *PersistentConsumerHandler) handleChatWs2Mysql(msg []byte, msgKey string) {
log.NewInfo("msg come here mysql!!!", "", "msg", string(msg))
var tag bool
msgFromMQ := pbMsg.MsgDataToMQ{}
err := proto.Unmarshal(msg, &msgFromMQ)
if err != nil {
log.ErrorByKv("msg_transfer Unmarshal msg err", "", "msg", string(msg), "err", err.Error())
log.NewError(msgFromMQ.OperationID, "msg_transfer Unmarshal msg err", "msg", string(msg), "err", err.Error())
return
}
//Control whether to store history messages (mysql)
isPersist := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsPersistent)
//Only process receiver data
if isPersist {
if msgKey == msgFromMQ.MsgData.RecvID && msgFromMQ.MsgData.SessionType == constant.SingleChatType {
log.InfoByKv("msg_transfer msg persisting", msgFromMQ.OperationID)
if err = im_mysql_msg_model.InsertMessageToChatLog(msgFromMQ); err != nil {
log.ErrorByKv("Message insert failed", msgFromMQ.OperationID, "err", err.Error(), "msg", msgFromMQ.String())
return
switch msgFromMQ.MsgData.SessionType {
case constant.SingleChatType, constant.NotificationChatType:
if msgKey == msgFromMQ.MsgData.RecvID {
tag = true
}
} else if msgFromMQ.MsgData.SessionType == constant.GroupChatType && msgKey == msgFromMQ.MsgData.SendID {
log.InfoByKv("msg_transfer msg persisting", msgFromMQ.OperationID)
case constant.GroupChatType:
if msgKey == msgFromMQ.MsgData.SendID || utils.IsContain(msgFromMQ.MsgData.SendID, config.Config.Manager.AppManagerUid) {
tag = true
}
}
if tag {
log.NewInfo(msgFromMQ.OperationID, "msg_transfer msg persisting", string(msg))
if err = im_mysql_msg_model.InsertMessageToChatLog(msgFromMQ); err != nil {
log.ErrorByKv("Message insert failed", msgFromMQ.OperationID, "err", err.Error(), "msg", msgFromMQ.String())
log.NewError(msgFromMQ.OperationID, "Message insert failed", "err", err.Error(), "msg", msgFromMQ.String())
return
}
}

View File

@ -0,0 +1,12 @@
package getui
type Getui struct {
}
func (g *Getui) Push(userIDList []string, alert, detailContent, platform string) (resp string, err error) {
return "", nil
}
func (g *Getui) Auth(apiKey, secretKey string, timeStamp int64) (token string, err error) {
return "", nil
}

View File

@ -13,6 +13,9 @@ import (
type JPushResp struct {
}
type JPush struct {
}
func JGAccountListPush(accounts []string, alert, detailContent, platform string) ([]byte, error) {
var pf requestBody.Platform

View File

@ -10,7 +10,6 @@ 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"
)
@ -24,7 +23,7 @@ var (
)
func Init(rpcPort int) {
log.NewPrivateLog(config.Config.ModuleName.PushName)
rpcServer.Init(rpcPort)
pushCh.Init()
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}

View File

@ -0,0 +1,6 @@
package push
type offlinePusher interface {
auth(apiKey, secretKey string, timeStamp int64) (token string, err error)
push(userIDList []string, alert, detailContent, platform string) (resp string, err error)
}

View File

@ -24,7 +24,7 @@ type adminCMSServer struct {
}
func NewAdminCMSServer(port int) *adminCMSServer {
log.NewPrivateLog("AdminCMS")
log.NewPrivateLog(constant.LogFileName)
return &adminCMSServer{
rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImAdminCMSName,
@ -66,12 +66,12 @@ func (s *adminCMSServer) Run() {
func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLoginReq) (*pbAdminCMS.AdminLoginResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbAdminCMS.AdminLoginResp{}
for i, adminID := range config.Config.Manager.AppManagerUid{
for i, adminID := range config.Config.Manager.AppManagerUid {
if adminID == req.AdminID && config.Config.Manager.Secrets[i] == req.Secret {
token, expTime, err := token_verify.CreateToken(adminID, constant.SingleChatType)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "generate token success", "token: ", token, "expTime:", expTime)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "adminID: ", adminID, err.Error())
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "adminID: ", adminID, err.Error())
return resp, openIMHttp.WrapError(constant.ErrTokenUnknown)
}
resp.Token = token
@ -84,4 +84,4 @@ func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLogi
return resp, openIMHttp.WrapError(constant.ErrTokenMalformed)
}
return resp, nil
}
}

View File

@ -63,7 +63,7 @@ type rpcAuth struct {
}
func NewRpcAuthServer(port int) *rpcAuth {
log.NewPrivateLog("auth")
log.NewPrivateLog(constant.LogFileName)
return &rpcAuth{
rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImAuthName,

View File

@ -29,7 +29,7 @@ type friendServer struct {
}
func NewFriendServer(port int) *friendServer {
log.NewPrivateLog("friend")
log.NewPrivateLog(constant.LogFileName)
return &friendServer{
rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImFriendName,

View File

@ -31,7 +31,7 @@ type groupServer struct {
}
func NewGroupServer(port int) *groupServer {
log.NewPrivateLog("group")
log.NewPrivateLog(constant.LogFileName)
return &groupServer{
rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImGroupName,
@ -41,16 +41,16 @@ func NewGroupServer(port int) *groupServer {
}
func (s *groupServer) Run() {
log.NewInfo("0", "group rpc start ")
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("0", "Listen failed ", err.Error(), registerAddress)
log.NewError("", "Listen failed ", err.Error(), registerAddress)
return
}
log.NewInfo("0", "listen network success, ", registerAddress, listener)
log.NewInfo("", "listen network success, ", registerAddress, listener)
defer listener.Close()
//grpc server
srv := grpc.NewServer()
@ -59,15 +59,15 @@ func (s *groupServer) Run() {
pbGroup.RegisterGroupServer(srv, s)
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
if err != nil {
log.NewError("0", "RegisterEtcd failed ", err.Error())
log.NewError("", "RegisterEtcd failed ", err.Error())
return
}
err = srv.Serve(listener)
if err != nil {
log.NewError("0", "Serve failed ", err.Error())
log.NewError("", "Serve failed ", err.Error())
return
}
log.NewInfo("0", "group rpc success")
log.NewInfo("", "group rpc success")
}
func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupReq) (*pbGroup.CreateGroupResp, error) {
@ -273,8 +273,11 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
}
for _, v := range memberList {
log.Debug(req.OperationID, v)
var node open_im_sdk.GroupMemberFullInfo
cp.GroupMemberDBCopyOpenIM(&node, &v)
log.Debug(req.OperationID, "db value:", v.MuteEndTime, "seconds: ", v.MuteEndTime.Unix())
log.Debug(req.OperationID, "cp value: ", node)
resp.MemberList = append(resp.MemberList, &node)
}
log.NewInfo(req.OperationID, "GetGroupAllMember rpc return ", resp.String())
@ -355,7 +358,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
//remove
var resp pbGroup.KickGroupMemberResp
for _, v := range req.KickedUserIDList {
//owner cant kicked
//owner cant kicked
if v == groupOwnerUserID {
log.NewError(req.OperationID, "failed, can't kick owner ", v)
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: -1})
@ -969,24 +972,26 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGroupMemberReq) (*pbGroup.MuteGroupMemberResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
if !imdb.IsGroupOwnerAdmin(req.GroupID, req.UserID) && !token_verify.IsMangerUserID(req.OpUserID) {
log.Error(req.OperationID, "verify failed ", req.OpUserID, req.GroupID)
if !imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) && !token_verify.IsMangerUserID(req.OpUserID) {
log.Error(req.OperationID, "verify failed ", req.GroupID, req.UserID)
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
}
groupMemberInfo := db.GroupMember{GroupID: req.GroupID, UserID: req.UserID}
groupMemberInfo.MuteEndTime = time.Unix(int64(time.Now().Second())+int64(req.MutedSeconds), 0)
groupMemberInfo.MuteEndTime = time.Unix(int64(time.Now().Second())+int64(req.MutedSeconds), time.Now().UnixNano())
err := imdb.UpdateGroupMemberInfo(groupMemberInfo)
if err != nil {
log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo)
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
chat.GroupMemberMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, req.MutedSeconds)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
}
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.CancelMuteGroupMemberReq) (*pbGroup.CancelMuteGroupMemberResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
if !imdb.IsGroupOwnerAdmin(req.GroupID, req.UserID) && !token_verify.IsMangerUserID(req.OpUserID) {
if !imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) && !token_verify.IsMangerUserID(req.OpUserID) {
log.Error(req.OperationID, "verify failed ", req.OpUserID, req.GroupID)
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
}
@ -997,14 +1002,40 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo)
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
chat.GroupMemberCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
}
func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) (*pbGroup.MuteGroupResp, error) {
return nil, nil
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
if !imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) && !token_verify.IsMangerUserID(req.OpUserID) {
log.Error(req.OperationID, "verify failed ", req.GroupID, req.GroupID)
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
}
err := imdb.OperateGroupStatus(req.GroupID, constant.GroupStatusMuted)
if err != nil {
log.Error(req.OperationID, "OperateGroupStatus failed ", err.Error(), req.GroupID, constant.GroupStatusMuted)
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
chat.GroupMutedNotification(req.OperationID, req.OpUserID, req.GroupID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
}
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMuteGroupReq) (*pbGroup.CancelMuteGroupResp, error) {
return nil, nil
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
if !imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) && !token_verify.IsMangerUserID(req.OpUserID) {
log.Error(req.OperationID, "verify failed ", req.OpUserID, req.GroupID)
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
}
err := imdb.UpdateGroupInfoDefaultZero(req.GroupID, map[string]interface{}{"status": constant.GroupOk})
if err != nil {
log.Error(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), req.GroupID)
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
chat.GroupCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
}

View File

@ -31,7 +31,7 @@ type messageCMSServer struct {
}
func NewMessageCMSServer(port int) *messageCMSServer {
log.NewPrivateLog("MessageCMS")
log.NewPrivateLog(constant.LogFileName)
return &messageCMSServer{
rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImMessageCMSName,
@ -84,8 +84,8 @@ func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetC
log.NewError(req.OperationID, utils.GetSelfFuncName(), "time string parse error", err.Error())
}
chatLog := db.ChatLog{
Content: req.Content,
SendTime: time,
Content: req.Content,
SendTime: time,
ContentType: req.ContentType,
SessionType: req.SessionType,
}
@ -101,20 +101,20 @@ func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetC
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLogCount", err.Error())
}
chatLogs, err := imdb.GetChatLog(chatLog, req.Pagination.PageNumber, req.Pagination.ShowNumber)
chatLogs, err := imdb.GetChatLog(chatLog, req.Pagination.PageNumber, req.Pagination.ShowNumber)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLog", err.Error())
return resp, errors.WrapError(constant.ErrDB)
}
for _, chatLog := range chatLogs {
pbChatLog := &pbMessageCMS.ChatLogs{
SessionType: chatLog.SessionType,
ContentType: chatLog.ContentType,
SearchContent: req.Content,
WholeContent: chatLog.Content,
Date: chatLog.CreateTime.String(),
SessionType: chatLog.SessionType,
ContentType: chatLog.ContentType,
SearchContent: req.Content,
WholeContent: chatLog.Content,
Date: chatLog.CreateTime.String(),
SenderNickName: chatLog.SenderNickname,
SenderId: chatLog.SendID,
SenderId: chatLog.SendID,
}
if chatLog.SenderNickname == "" {
sendUser, err := imdb.GetUserByUserID(chatLog.SendID)

View File

@ -10,12 +10,12 @@ import (
"github.com/golang/protobuf/proto"
)
func conversationNotification(contentType int32, m proto.Message, operationID, userID string) {
func SetConversationNotification(operationID, sendID, recvID string, contentType int, m proto.Message, tips open_im_sdk.TipsComm) {
log.NewInfo(operationID, "args: ", sendID, recvID, contentType, m.String(), tips.String())
var err error
var tips open_im_sdk.TipsComm
tips.Detail, err = proto.Marshal(m)
if err != nil {
log.Error(operationID, utils.GetSelfFuncName(), "Marshal failed ", err.Error(), m.String())
log.NewError(operationID, "Marshal failed ", err.Error(), m.String())
return
}
marshaler := jsonpb.Marshaler{
@ -24,15 +24,10 @@ func conversationNotification(contentType int32, m proto.Message, operationID, u
EmitDefaults: false,
}
tips.JsonDetail, _ = marshaler.MarshalToString(m)
cn := config.Config.Notification
switch contentType {
case constant.ConversationOptChangeNotification:
tips.DefaultTips = cn.ConversationOptUpdate.DefaultTips.Tips
}
var n NotificationMsg
n.SendID = userID
n.RecvID = userID
n.ContentType = contentType
n.SendID = sendID
n.RecvID = recvID
n.ContentType = int32(contentType)
n.SessionType = constant.SingleChatType
n.MsgFrom = constant.SysMsgType
n.OperationID = operationID
@ -44,10 +39,38 @@ func conversationNotification(contentType int32, m proto.Message, operationID, u
Notification(&n)
}
func SetConversationNotification(operationID, userID string) {
log.NewInfo(operationID, utils.GetSelfFuncName(), "userID: ", userID)
conversationUpdateTips := open_im_sdk.ConversationUpdateTips{
// SetPrivate调用
func ConversationSetPrivateNotification(operationID, sendID, recvID string, isPrivateChat bool) {
log.NewInfo(operationID, utils.GetSelfFuncName())
conversationSetPrivateTips := &open_im_sdk.ConversationSetPrivateTips{
RecvID: recvID,
SendID: sendID,
IsPrivate: isPrivateChat,
}
var tips open_im_sdk.TipsComm
var tipsMsg string
//var senderName string
//senderName, err := im_mysql_model.GetUserNameByUserID(sendID)
//if err != nil {
// log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
// senderName = sendID
//}
if isPrivateChat == true {
tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.OpenTips
} else {
tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.CloseTips
}
tips.DefaultTips = tipsMsg
SetConversationNotification(operationID, sendID, recvID, constant.ConversationPrivateChatNotification, conversationSetPrivateTips, tips)
}
// 会话改变
func ConversationChangeNotification(operationID, userID string) {
log.NewInfo(operationID, utils.GetSelfFuncName())
ConversationChangedTips := &open_im_sdk.ConversationUpdateTips{
UserID: userID,
}
conversationNotification(constant.ConversationOptChangeNotification, &conversationUpdateTips, operationID, userID)
var tips open_im_sdk.TipsComm
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
SetConversationNotification(operationID, userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips)
}

View File

@ -16,7 +16,7 @@ func (rpc *rpcChat) DelMsgList(_ context.Context, req *commonPb.DelMsgListReq) (
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsg failed", err.Error())
resp.ErrMsg = constant.ErrDB.ErrMsg
resp.ErrCode = constant.ErrDB.ErrCode
return resp, err
return resp, nil
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil

View File

@ -160,6 +160,14 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv
tips.DefaultTips = toNickname + " " + cn.MemberEnter.DefaultTips.Tips
case constant.GroupDismissedNotification:
tips.DefaultTips = toNickname + "" + cn.GroupDismissed.DefaultTips.Tips
case constant.GroupMutedNotification:
tips.DefaultTips = toNickname + "" + cn.GroupMuted.DefaultTips.Tips
case constant.GroupCancelMutedNotification:
tips.DefaultTips = toNickname + "" + cn.GroupCancelMuted.DefaultTips.Tips
case constant.GroupMemberMutedNotification:
tips.DefaultTips = toNickname + "" + cn.GroupMemberMuted.DefaultTips.Tips
case constant.GroupMemberCancelMutedNotification:
tips.DefaultTips = toNickname + "" + cn.GroupMemberCancelMuted.DefaultTips.Tips
default:
log.Error(operationID, "contentType failed ", contentType)
return
@ -227,6 +235,71 @@ func GroupInfoSetNotification(operationID, opUserID, groupID string) {
groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID)
}
func GroupMutedNotification(operationID, opUserID, groupID string) {
tips := open_im_sdk.GroupMutedTips{Group: &open_im_sdk.GroupInfo{},
OpUser: &open_im_sdk.GroupMemberFullInfo{}}
if err := setGroupInfo(groupID, tips.Group); err != nil {
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
return
}
if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
return
}
groupNotification(constant.GroupMutedNotification, &tips, opUserID, groupID, "", operationID)
}
func GroupCancelMutedNotification(operationID, opUserID, groupID string) {
tips := open_im_sdk.GroupCancelMutedTips{Group: &open_im_sdk.GroupInfo{},
OpUser: &open_im_sdk.GroupMemberFullInfo{}}
if err := setGroupInfo(groupID, tips.Group); err != nil {
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
return
}
if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
return
}
groupNotification(constant.GroupCancelMutedNotification, &tips, opUserID, groupID, "", operationID)
}
func GroupMemberMutedNotification(operationID, opUserID, groupID, groupMemberUserID string, mutedSeconds uint32) {
tips := open_im_sdk.GroupMemberMutedTips{Group: &open_im_sdk.GroupInfo{},
OpUser: &open_im_sdk.GroupMemberFullInfo{}, MutedUser: &open_im_sdk.GroupMemberFullInfo{}}
tips.MutedSeconds = mutedSeconds
if err := setGroupInfo(groupID, tips.Group); err != nil {
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
return
}
if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
return
}
if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil {
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID)
return
}
groupNotification(constant.GroupMemberMutedNotification, &tips, opUserID, groupID, "", operationID)
}
func GroupMemberCancelMutedNotification(operationID, opUserID, groupID, groupMemberUserID string) {
tips := open_im_sdk.GroupMemberCancelMutedTips{Group: &open_im_sdk.GroupInfo{},
OpUser: &open_im_sdk.GroupMemberFullInfo{}, MutedUser: &open_im_sdk.GroupMemberFullInfo{}}
if err := setGroupInfo(groupID, tips.Group); err != nil {
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
return
}
if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
return
}
if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil {
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID)
return
}
groupNotification(constant.GroupMemberCancelMutedNotification, &tips, opUserID, groupID, "", operationID)
}
//message ReceiveJoinApplicationTips{
// GroupInfo Group = 1;
// PublicUserInfo Applicant = 2;

View File

@ -2,6 +2,7 @@ package msg
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/kafka"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
@ -22,7 +23,7 @@ type rpcChat struct {
}
func NewRpcChatServer(port int) *rpcChat {
log.NewPrivateLog("msg")
log.NewPrivateLog(constant.LogFileName)
rc := rpcChat{
rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImOfflineMessageName,
@ -42,7 +43,7 @@ func (rpc *rpcChat) Run() {
log.Error("", "", "listen network failed, err = %s, address = %s", err.Error(), address)
return
}
log.Info("", "", "listen network success, address = %s", address)
log.Info("", "", "listen network success, address = ", address)
//grpc server
srv := grpc.NewServer()

View File

@ -281,6 +281,23 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendGroupMsg failed", err.Error())
}
return returnMsg(&replay, pb, 0, "", msgToMQ.MsgData.ServerMsgID, msgToMQ.MsgData.SendTime)
case constant.NotificationChatType:
msgToMQ.MsgData = pb.MsgData
log.NewInfo(msgToMQ.OperationID, msgToMQ)
err1 := rpc.sendMsgToKafka(&msgToMQ, msgToMQ.MsgData.RecvID)
if err1 != nil {
log.NewError(msgToMQ.OperationID, "kafka send msg err:RecvID", msgToMQ.MsgData.RecvID, msgToMQ.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 err2 != nil {
log.NewError(msgToMQ.OperationID, "kafka send msg err:SendID", msgToMQ.MsgData.SendID, msgToMQ.String())
return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0)
}
}
return returnMsg(&replay, pb, 0, "", msgToMQ.MsgData.ServerMsgID, msgToMQ.MsgData.SendTime)
default:
return returnMsg(&replay, pb, 203, "unkonwn sessionType", "", 0)
}
@ -513,6 +530,38 @@ func Notification(n *NotificationMsg) {
ex = config.Config.Notification.GroupDismissed.OfflinePush.Ext
reliabilityLevel = config.Config.Notification.GroupDismissed.Conversation.ReliabilityLevel
unReadCount = config.Config.Notification.GroupDismissed.Conversation.UnreadCount
case constant.GroupMutedNotification:
pushSwitch = config.Config.Notification.GroupMuted.OfflinePush.PushSwitch
title = config.Config.Notification.GroupMuted.OfflinePush.Title
desc = config.Config.Notification.GroupMuted.OfflinePush.Desc
ex = config.Config.Notification.GroupMuted.OfflinePush.Ext
reliabilityLevel = config.Config.Notification.GroupMuted.Conversation.ReliabilityLevel
unReadCount = config.Config.Notification.GroupMuted.Conversation.UnreadCount
case constant.GroupCancelMutedNotification:
pushSwitch = config.Config.Notification.GroupCancelMuted.OfflinePush.PushSwitch
title = config.Config.Notification.GroupCancelMuted.OfflinePush.Title
desc = config.Config.Notification.GroupCancelMuted.OfflinePush.Desc
ex = config.Config.Notification.GroupCancelMuted.OfflinePush.Ext
reliabilityLevel = config.Config.Notification.GroupCancelMuted.Conversation.ReliabilityLevel
unReadCount = config.Config.Notification.GroupCancelMuted.Conversation.UnreadCount
case constant.GroupMemberMutedNotification:
pushSwitch = config.Config.Notification.GroupMemberMuted.OfflinePush.PushSwitch
title = config.Config.Notification.GroupMemberMuted.OfflinePush.Title
desc = config.Config.Notification.GroupMemberMuted.OfflinePush.Desc
ex = config.Config.Notification.GroupMemberMuted.OfflinePush.Ext
reliabilityLevel = config.Config.Notification.GroupMemberMuted.Conversation.ReliabilityLevel
unReadCount = config.Config.Notification.GroupMemberMuted.Conversation.UnreadCount
case constant.GroupMemberCancelMutedNotification:
pushSwitch = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.PushSwitch
title = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Title
desc = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Desc
ex = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Ext
reliabilityLevel = config.Config.Notification.GroupMemberCancelMuted.Conversation.ReliabilityLevel
unReadCount = config.Config.Notification.GroupMemberCancelMuted.Conversation.UnreadCount
}
switch reliabilityLevel {
case constant.UnreliableNotification:
@ -539,6 +588,6 @@ func Notification(n *NotificationMsg) {
if err != nil {
log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), err.Error())
} else if reply.ErrCode != 0 {
log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String())
log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), reply.ErrCode, reply.ErrMsg)
}
}

View File

@ -10,20 +10,24 @@ import (
"Open_IM/pkg/utils"
"context"
"strings"
"time"
)
func TagSendMessage(operationID, sendID, recvID, content string, contentType int32) {
log.NewInfo(operationID, utils.GetSelfFuncName(), "args: ", sendID, recvID, content, contentType)
func TagSendMessage(operationID, sendID, recvID, content string, senderPlatformID int32) {
log.NewInfo(operationID, utils.GetSelfFuncName(), "args: ", sendID, recvID, content)
var req pbChat.SendMsgReq
var msgData pbCommon.MsgData
msgData.SendID = sendID
msgData.RecvID = recvID
msgData.ContentType = contentType
msgData.ContentType = constant.Custom
msgData.SessionType = constant.SingleChatType
msgData.MsgFrom = constant.UserMsgType
msgData.Content = []byte(content)
msgData.Options = map[string]bool{}
msgData.Options[constant.IsSenderConversationUpdate] = false
msgData.SendTime = time.Now().Unix()
msgData.CreateTime = time.Now().Unix()
msgData.SenderPlatformID = senderPlatformID
req.MsgData = &msgData
req.OperationID = operationID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)

View File

@ -16,6 +16,7 @@ import (
"net"
"strconv"
"strings"
"time"
)
type officeServer struct {
@ -26,7 +27,7 @@ type officeServer struct {
}
func NewOfficeServer(port int) *officeServer {
log.NewPrivateLog("office")
log.NewPrivateLog(constant.LogFileName)
return &officeServer{
rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImOfficeName,
@ -103,7 +104,7 @@ func (s *officeServer) GetUserTags(_ context.Context, req *pbOffice.GetUserTagsR
func (s *officeServer) CreateTag(_ context.Context, req *pbOffice.CreateTagReq) (resp *pbOffice.CreateTagResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "CreateTag req", req.String())
userIDList := utils.RemoveUserIDRepByMap(req.UserIDList)
userIDList := utils.RemoveRepeatedStringInList(req.UserIDList)
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "userIDList: ", userIDList)
resp = &pbOffice.CreateTagResp{CommonResp: &pbOffice.CommonResp{}}
if err := db.DB.CreateTag(req.UserID, req.TagName, userIDList); err != nil {
@ -132,8 +133,8 @@ 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.RemoveUserIDRepByMap(req.IncreaseUserIDList)
reduceUserIDList := utils.RemoveUserIDRepByMap(req.ReduceUserIDList)
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())
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
@ -147,11 +148,57 @@ func (s *officeServer) SetTag(_ context.Context, req *pbOffice.SetTagReq) (resp
func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagReq) (resp *pbOffice.SendMsg2TagResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp = &pbOffice.SendMsg2TagResp{CommonResp: &pbOffice.CommonResp{}}
userIDList, err := db.DB.GetUserIDListByTagID(req.SendID, req.TagID)
for _, userID := range userIDList {
msg.TagSendMessage(req.OperationID, req.SendID, userID, req.Content, req.ContentType)
var tagUserIDList []string
for _, tagID := range req.TagList {
userIDList, err := db.DB.GetUserIDListByTagID(req.SendID, tagID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserIDListByTagID failed", err.Error())
continue
}
tagUserIDList = append(tagUserIDList, userIDList...)
}
if err := db.DB.SaveTagSendLog(req); err != nil {
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
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), userIDList)
groupUserIDList = append(groupUserIDList, userIDList...)
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), groupUserIDList, req.GroupList)
var userIDList []string
userIDList = append(userIDList, tagUserIDList...)
userIDList = append(userIDList, groupUserIDList...)
userIDList = append(userIDList, req.UserList...)
userIDList = utils.RemoveRepeatedStringInList(userIDList)
for i, userID := range userIDList {
if userID == req.SendID || userID == "" {
userIDList = append(userIDList[:i], userIDList[i+1:]...)
}
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "total userIDList result: ", userIDList)
for _, userID := range userIDList {
msg.TagSendMessage(req.OperationID, req.SendID, userID, req.Content, req.SenderPlatformID)
}
var tagSendLogs db.TagSendLog
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,
})
}
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())
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
@ -184,3 +231,33 @@ func (s *officeServer) GetTagSendLogs(_ context.Context, req *pbOffice.GetTagSen
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}
func (s *officeServer) GetUserTagByID(_ context.Context, req *pbOffice.GetUserTagByIDReq) (resp *pbOffice.GetUserTagByIDResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp = &pbOffice.GetUserTagByIDResp{
CommonResp: &pbOffice.CommonResp{},
Tag: &pbOffice.Tag{},
}
tag, err := db.DB.GetTagByID(req.UserID, req.TagID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTagByID failed", err.Error())
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
return resp, nil
}
for _, userID := range tag.UserList {
userName, err := im_mysql_model.GetUserNameByUserID(userID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", err.Error())
continue
}
resp.Tag.UserList = append(resp.Tag.UserList, &pbOffice.TagUser{
UserID: userID,
UserName: userName,
})
}
resp.Tag.TagID = tag.TagID
resp.Tag.TagName = tag.TagName
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
}

View File

@ -19,10 +19,10 @@ import (
//open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
//"context"
errors "Open_IM/pkg/common/http"
"net"
"strconv"
"strings"
errors "Open_IM/pkg/common/http"
"google.golang.org/grpc"
)
@ -35,7 +35,7 @@ type statisticsServer struct {
}
func NewStatisticsServer(port int) *statisticsServer {
log.NewPrivateLog("Statistics")
log.NewPrivateLog(constant.LogFileName)
return &statisticsServer{
rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImStatisticsName,
@ -164,7 +164,7 @@ func GetRangeDate(from, to time.Time) [][2]time.Time {
}
// month
case !isInOneMonth(from, to):
if to.Sub(from) < time.Hour * 24 * 30 {
if to.Sub(from) < time.Hour*24*30 {
for i := 0; ; i++ {
fromTime := from.Add(time.Hour * 24 * time.Duration(i))
toTime := from.Add(time.Hour * 24 * time.Duration(i+1))
@ -251,7 +251,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
}
resp.TotalGroupNumList[index] = &pbStatistics.DateNumList{
Date: v[0].String(),
Date: v[0].String(),
Num: num,
}
}(wg, i, v)

View File

@ -32,7 +32,7 @@ type userServer struct {
}
func NewUserServer(port int) *userServer {
log.NewPrivateLog("user")
log.NewPrivateLog(constant.LogFileName)
return &userServer{
rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImUserName,
@ -72,6 +72,30 @@ func (s *userServer) Run() {
log.NewInfo("0", "rpc user success")
}
func syncPeerUserConversation(conversation *pbUser.Conversation, operationID string) error {
peerUserConversation := db.Conversation{
OwnerUserID: conversation.UserID,
ConversationID: "single_" + conversation.OwnerUserID,
ConversationType: constant.SingleChatType,
UserID: conversation.OwnerUserID,
GroupID: "",
RecvMsgOpt: 0,
UnreadCount: 0,
DraftTextTime: 0,
IsPinned: false,
IsPrivateChat: conversation.IsPrivateChat,
AttachedInfo: "",
Ex: "",
}
err := imdb.PeerUserSetConversation(peerUserConversation)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
return err
}
chat.ConversationSetPrivateNotification(operationID, conversation.OwnerUserID, conversation.UserID, conversation.IsPrivateChat)
return nil
}
func (s *userServer) GetUserInfo(ctx context.Context, req *pbUser.GetUserInfoReq) (*pbUser.GetUserInfoResp, error) {
log.NewInfo(req.OperationID, "GetUserInfo args ", req.String())
var userInfoList []*sdkws.UserInfo
@ -96,6 +120,9 @@ func (s *userServer) GetUserInfo(ctx context.Context, req *pbUser.GetUserInfoReq
func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.BatchSetConversationsReq) (*pbUser.BatchSetConversationsResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
if req.NotificationType == 0 {
req.NotificationType = constant.ConversationOptChangeNotification
}
resp := &pbUser.BatchSetConversationsResp{}
for _, v := range req.Conversations {
conversation := db.Conversation{}
@ -113,8 +140,14 @@ func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.Batc
continue
}
resp.Success = append(resp.Success, v.ConversationID)
// if is set private chat operationthen peer user need to sync and set tips\
if v.ConversationType == constant.SingleChatType && req.NotificationType == constant.ConversationPrivateChatNotification {
if err := syncPeerUserConversation(v, req.OperationID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "syncPeerUserConversation", err.Error())
}
}
}
chat.SetConversationNotification(req.OperationID, req.OwnerUserID)
chat.ConversationChangeNotification(req.OperationID, req.OwnerUserID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return", resp.String())
resp.CommonResp = &pbUser.CommonResp{}
return resp, nil
@ -173,6 +206,9 @@ func (s *userServer) GetConversations(ctx context.Context, req *pbUser.GetConver
func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConversationReq) (*pbUser.SetConversationResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
if req.NotificationType == 0 {
req.NotificationType = constant.ConversationOptChangeNotification
}
resp := &pbUser.SetConversationResp{}
var conversation db.Conversation
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
@ -189,7 +225,17 @@ func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConvers
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
return resp, nil
}
chat.SetConversationNotification(req.OperationID, req.Conversation.OwnerUserID)
// notification
if req.Conversation.ConversationType == constant.SingleChatType && req.NotificationType == constant.ConversationPrivateChatNotification {
//sync peer user conversation if conversation is singleChatType
if err := syncPeerUserConversation(req.Conversation, req.OperationID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "syncPeerUserConversation", err.Error())
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
return resp, nil
}
} else {
chat.ConversationChangeNotification(req.OperationID, req.Conversation.OwnerUserID)
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return", resp.String())
resp.CommonResp = &pbUser.CommonResp{}
return resp, nil
@ -207,13 +253,24 @@ func (s *userServer) SetRecvMsgOpt(ctx context.Context, req *pbUser.SetRecvMsgOp
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
return resp, nil
}
stringList := strings.Split(req.ConversationID, "_")
if len(stringList) > 1 {
switch stringList[0] {
case "single_":
conversation.UserID = stringList[1]
conversation.ConversationType = constant.SingleChatType
case "group":
conversation.GroupID = stringList[1]
conversation.ConversationType = constant.GroupChatType
}
}
err := imdb.SetRecvMsgOpt(conversation)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
return resp, nil
}
chat.SetConversationNotification(req.OperationID, req.OwnerUserID)
chat.ConversationChangeNotification(req.OperationID, req.OwnerUserID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
resp.CommonResp = &pbUser.CommonResp{}
return resp, nil

View File

@ -76,7 +76,7 @@ func Test_ParseToken(t *testing.T) {
uid := "1"
platform := int32(1)
tokenString, _, _ := token_verify.CreateToken(uid, platform)
claims, err := token_verify.ParseToken(tokenString)
claims, err := token_verify.ParseToken(tokenString, "")
if err == nil {
assert.Equal(t, claims.UID, uid)
}

View File

@ -34,8 +34,8 @@ type SetReceiveMessageOptResp struct {
type Conversation struct {
OwnerUserID string `json:"ownerUserID" binding:"required"`
ConversationID string `json:"conversationID"`
ConversationType int32 `json:"conversationType"`
ConversationID string `json:"conversationID" binding:"required"`
ConversationType int32 `json:"conversationType" binding:"required"`
UserID string `json:"userID"`
GroupID string `json:"groupID"`
RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
@ -49,7 +49,8 @@ type Conversation struct {
type SetConversationReq struct {
Conversation
OperationID string `json:"operationID" binding:"required"`
NotificationType int32 `json:"notificationType"`
OperationID string `json:"operationID" binding:"required"`
}
type SetConversationResp struct {
@ -57,9 +58,10 @@ type SetConversationResp struct {
}
type BatchSetConversationsReq struct {
Conversations []Conversation `json:"conversations" binding:"required"`
OwnerUserID string `json:"ownerUserID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
Conversations []Conversation `json:"conversations" binding:"required"`
NotificationType int32 `json:"notificationType"`
OwnerUserID string `json:"ownerUserID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type BatchSetConversationsResp struct {
@ -103,10 +105,11 @@ type GetConversationsResp struct {
}
type SetRecvMsgOptReq struct {
OwnerUserID string `json:"ownerUserID" binding:"required"`
ConversationID string `json:"conversationID"`
RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
OperationID string `json:"operationID" binding:"required"`
OwnerUserID string `json:"ownerUserID" binding:"required"`
ConversationID string `json:"conversationID"`
RecvMsgOpt int32 `json:"recvMsgOpt" binding:"omitempty,oneof=0 1 2"`
OperationID string `json:"operationID" binding:"required"`
NotificationType int32 `json:"notificationType"`
}
type SetRecvMsgOptResp struct {

View File

@ -185,3 +185,38 @@ type DismissGroupReq struct {
type DismissGroupResp struct {
CommResp
}
type MuteGroupMemberReq struct {
OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID" binding:"required"`
UserID string `json:"userID" binding:"required"`
MutedSeconds uint32 `json:"mutedSeconds" binding:"required"`
}
type MuteGroupMemberResp struct {
CommResp
}
type CancelMuteGroupMemberReq struct {
OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID" binding:"required"`
UserID string `json:"userID" binding:"required"`
}
type CancelMuteGroupMemberResp struct {
CommResp
}
type MuteGroupReq struct {
OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID" binding:"required"`
}
type MuteGroupResp struct {
CommResp
}
type CancelMuteGroupReq struct {
OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID" binding:"required"`
}
type CancelMuteGroupResp struct {
CommResp
}

View File

@ -5,7 +5,7 @@ import (
)
type GetUserTagsReq struct {
OperationID string `json:"operationID"`
OperationID string `json:"operationID" binding:"required"`
}
type GetUserTagsResp struct {
@ -47,10 +47,12 @@ type SetTagResp struct {
}
type SendMsg2TagReq struct {
TagID string `json:"tagID" binding:"required"`
TagList []string `json:"tagList"`
UserList []string `json:"userList"`
GroupList []string `json:"groupList"`
SenderPlatformID int32 `json:"senderPlatformID" binding:"required"`
Content string `json:"content" binding:"required"`
ContentType int32 `json:"contentType" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
@ -72,3 +74,15 @@ type GetTagSendLogsResp struct {
ShowNumber int32 `json:"showNumber"`
} `json:"data"`
}
type GetUserTagByIDReq struct {
TagID string `json:"tagID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type GetUserTagByIDResp struct {
CommResp
Data struct {
Tag *pbOffice.Tag `json:"tag"`
} `json:"data"`
}

View File

@ -1,7 +1,6 @@
package config
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
@ -270,6 +269,30 @@ type config struct {
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupDismissed"`
GroupMuted struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupMuted"`
GroupCancelMuted struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupCancelMuted"`
GroupMemberMuted struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupMemberMuted"`
GroupMemberCancelMuted struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupMemberCancelMuted"`
////////////////////////user///////////////////////
UserInfoUpdated struct {
Conversation PConversation `yaml:"conversation"`
@ -326,6 +349,14 @@ type config struct {
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"conversationOptUpdate"`
ConversationSetPrivate struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips struct {
OpenTips string `yaml:"openTips"`
CloseTips string `yaml:"closeTips"`
} `yaml:"defaultTips"`
} `yaml:"conversationSetPrivate"`
}
Demo struct {
Port []int `yaml:"openImDemoPort"`
@ -345,6 +376,10 @@ type config struct {
SmtpPort int `yaml:"smtpPort"`
}
}
Rtc struct {
Port int `yaml:"port"`
Address string `yaml:"address"`
} `yaml:"rtc"`
}
type PConversation struct {
ReliabilityLevel int `yaml:"reliabilityLevel"`
@ -384,5 +419,4 @@ func init() {
if err = yaml.Unmarshal(bytes, &Config); err != nil {
panic(err.Error())
}
fmt.Println("load config: ", Config)
}

View File

@ -56,13 +56,11 @@ const (
FriendRemarkSetNotification = 1206 //set_friend_remark?
BlackAddedNotification = 1207 //add_black
BlackDeletedNotification = 1208 //remove_black
ConversationOptChangeNotification = 1300 // change conversation opt
ConversationOptChangeNotification = 1300 // change conversation opt
UserNotificationBegin = 1301
UserInfoUpdatedNotification = 1303 //SetSelfInfoTip = 204
ConversationNotification = 1307
ConversationNotNotification = 1308
ConversationDefault = 0
UserNotificationEnd = 1399
OANotification = 1400
@ -79,11 +77,18 @@ const (
MemberInvitedNotification = 1509
MemberEnterNotification = 1510
GroupDismissedNotification = 1511
GroupMemberMutedNotification = 1512
GroupMemberCancelMutedNotification = 1513
GroupMutedNotification = 1514
GroupCancelMutedNotification = 1515
SignalingNotificationBegin = 1600
SignalingNotification = 1601
SignalingNotificationEnd = 1699
NotificationEnd = 2000
ConversationPrivateChatNotification = 1701
NotificationEnd = 2000
//status
MsgNormal = 1
@ -226,3 +231,5 @@ func GroupIsBanPrivateChat(status int32) bool {
}
const BigVersion = "v3"
const LogFileName = "OpenIM.log"

View File

@ -2,7 +2,7 @@ package db
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
//"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
"fmt"
"go.mongodb.org/mongo-driver/mongo/options"
@ -33,6 +33,7 @@ func key(dbAddress, dbName string) string {
}
func init() {
//log.NewPrivateLog(constant.LogFileName)
//var mgoSession *mgo.Session
var mongoClient *mongo.Client
var err1 error
@ -51,16 +52,17 @@ func init() {
}
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
if err != nil{
log.NewError(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri)
if err != nil {
fmt.Println(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri)
time.Sleep(time.Duration(30) * time.Second)
mongoClient, err1 = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
if err1 != nil {
log.NewError(" mongo.Connect retry failed, panic", err.Error(), uri)
fmt.Println(" mongo.Connect retry failed, panic", err.Error(), uri)
panic(err1.Error())
}
}
log.NewInfo("0", utils.GetSelfFuncName(), "mongo driver client init success")
fmt.Println("0", utils.GetSelfFuncName(), "mongo driver client init success")
DB.mongoClient = mongoClient
//mgoDailInfo := &mgo.DialInfo{

View File

@ -5,7 +5,6 @@ import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
pbMsg "Open_IM/pkg/proto/chat"
officePb "Open_IM/pkg/proto/office"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
@ -470,6 +469,14 @@ func (d *DataBases) CreateTag(userID, tagName string, userList []string) error {
return err
}
func (d *DataBases) GetTagByID(userID, tagID string) (Tag, error) {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
var tag Tag
err := c.FindOne(ctx, bson.M{"user_id": userID, "tag_id": tagID}).Decode(&tag)
return tag, err
}
func (d *DataBases) DeleteTag(userID, tagID string) error {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
@ -491,7 +498,7 @@ func (d *DataBases) SetTag(userID, tagID, newName string, increaseUserIDList []s
}
}
tag.UserList = append(tag.UserList, increaseUserIDList...)
tag.UserList = utils.RemoveUserIDRepByMap(tag.UserList)
tag.UserList = utils.RemoveRepeatedStringInList(tag.UserList)
for _, v := range reduceUserIDList {
for i2, v2 := range tag.UserList {
if v == v2 {
@ -526,30 +533,16 @@ type TagUser struct {
}
type TagSendLog struct {
TagID string `bson:"tag_id"`
TagName string `bson:"tag_name"`
SendID string `bson:"send_id"`
SenderPlatformID int32 `bson:"sender_platform_id"`
Content string `bson:"content"`
ContentType int32 `bson:"content_type"`
SendTime int64 `bson:"send_time"`
UserList []TagUser `bson:"tag_list"`
SendID string `bson:"send_id"`
SenderPlatformID int32 `bson:"sender_platform_id"`
Content string `bson:"content"`
SendTime int64 `bson:"send_time"`
}
func (d *DataBases) SaveTagSendLog(sendReq *officePb.SendMsg2TagReq) error {
func (d *DataBases) SaveTagSendLog(tagSendLog *TagSendLog) error {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
var tag Tag
_ = c.FindOne(ctx, bson.M{"user_id": sendReq.SendID, "tag_id": sendReq.TagID}).Decode(&tag)
c = d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSendLog)
tagSendLog := TagSendLog{
TagID: sendReq.TagID,
TagName: tag.TagName,
SendID: sendReq.SendID,
SenderPlatformID: sendReq.SenderPlatformID,
Content: sendReq.Content,
ContentType: sendReq.ContentType,
SendTime: time.Now().Unix(),
}
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSendLog)
_, err := c.InsertOne(ctx, tagSendLog)
return err
}
@ -571,7 +564,7 @@ func (d *DataBases) GetTagSendLogs(userID string, showNumber, pageNumber int32)
}
func generateTagID(tagName, userID string) string {
return utils.Md5(tagName + userID + strconv.Itoa(rand.Int()))
return utils.Md5(tagName + userID + strconv.Itoa(rand.Int()) + time.Now().String())
}
func getCurrentTimestampByMill() int64 {

View File

@ -30,9 +30,7 @@ func InsertIntoGroupMember(toInsertInfo db.GroupMember) error {
if toInsertInfo.RoleLevel == 0 {
toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers
}
if toInsertInfo.MuteEndTime.Unix() == 0 {
toInsertInfo.MuteEndTime = time.Unix(0, 0)
}
toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0)
err = dbConn.Table("group_members").Create(toInsertInfo).Error
if err != nil {
return err
@ -68,6 +66,24 @@ func GetGroupMemberListByGroupID(groupID string) ([]db.GroupMember, error) {
return groupMemberList, nil
}
func GetGroupMemberIDListByGroupID(groupID string) ([]string, error) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return nil, err
}
dbConn.LogMode(true)
var groupMembers []db.GroupMember
err = dbConn.Table("group_members").Select("user_id").Where("group_id=?", groupID).Find(&groupMembers).Error
if err != nil {
return nil, err
}
var groupMemberIDList []string
for _, v := range groupMembers {
groupMemberIDList = append(groupMemberIDList, v.UserID)
}
return groupMemberIDList, nil
}
func GetGroupMemberListByGroupIDAndRoleLevel(groupID string, roleLevel int32) ([]db.GroupMember, error) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {

View File

@ -216,10 +216,10 @@ func GetGroupMaster(groupId string) (db.GroupMember, error) {
return groupMember, nil
}
func UpdateGroupInfoDefaultZero(groupInfo db.Group, args map[string]interface{}) error {
func UpdateGroupInfoDefaultZero(groupID string, args map[string]interface{}) error {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return err
}
return dbConn.Model(groupInfo).Updates(args).Error
return dbConn.Table("groups").Where("group_id = ? ", groupID).Update(args).Error
}

View File

@ -325,6 +325,25 @@ func SetConversation(conversation db.Conversation) error {
}
}
func PeerUserSetConversation(conversation db.Conversation) error {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return err
}
dbConn.LogMode(true)
newConversation := conversation
if dbConn.Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 {
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create")
return dbConn.Model(&db.Conversation{}).Create(conversation).Error
// if exist, then update record
}
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update")
//force update
return dbConn.Model(conversation).Where("owner_user_id = ? and conversation_id = ?", conversation.OwnerUserID, conversation.ConversationID).
Update(map[string]interface{}{"is_private_chat": conversation.IsPrivateChat}).Error
}
func SetRecvMsgOpt(conversation db.Conversation) error {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {

View File

@ -63,10 +63,10 @@ func loggerInit(moduleName string) *Logger {
}
func NewLfsHook(rotationTime time.Duration, maxRemainNum uint, moduleName string) logrus.Hook {
lfsHook := lfshook.NewHook(lfshook.WriterMap{
logrus.DebugLevel: initRotateLogs(rotationTime, maxRemainNum, "debug", moduleName),
logrus.InfoLevel: initRotateLogs(rotationTime, maxRemainNum, "info", moduleName),
logrus.WarnLevel: initRotateLogs(rotationTime, maxRemainNum, "warn", moduleName),
logrus.ErrorLevel: initRotateLogs(rotationTime, maxRemainNum, "error", moduleName),
logrus.DebugLevel: initRotateLogs(rotationTime, maxRemainNum, "all", moduleName),
logrus.InfoLevel: initRotateLogs(rotationTime, maxRemainNum, "all", moduleName),
logrus.WarnLevel: initRotateLogs(rotationTime, maxRemainNum, "all", moduleName),
logrus.ErrorLevel: initRotateLogs(rotationTime, maxRemainNum, "all", moduleName),
}, &nested.Formatter{
TimestampFormat: "2006-01-02 15:04:05.000",
HideKeys: false,

View File

@ -101,7 +101,7 @@ func GetClaimFromToken(tokensString string) (*Claims, error) {
}
func IsAppManagerAccess(token string, OpUserID string) bool {
claims, err := ParseToken(token)
claims, err := ParseToken(token, "")
if err != nil {
return false
}
@ -130,7 +130,7 @@ func CheckAccess(OpUserID string, OwnerUserID string) bool {
}
func GetUserIDFromToken(token string, operationID string) (bool, string) {
claims, err := ParseToken(token)
claims, err := ParseToken(token, operationID)
if err != nil {
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
return false, ""
@ -138,31 +138,31 @@ func GetUserIDFromToken(token string, operationID string) (bool, string) {
return true, claims.UID
}
func ParseToken(tokensString string) (claims *Claims, err error) {
func ParseToken(tokensString, operationID string) (claims *Claims, err error) {
claims, err = GetClaimFromToken(tokensString)
if err != nil {
log.NewError("", "token validate err", err.Error())
log.NewError(operationID, "token validate err", err.Error(), tokensString)
return nil, err
}
m, err := commonDB.DB.GetTokenMapByUidPid(claims.UID, claims.Platform)
if err != nil {
log.NewError("", "get token from redis err", err.Error())
log.NewError(operationID, "get token from redis err", err.Error(), tokensString)
return nil, &constant.ErrTokenInvalid
}
if m == nil {
log.NewError("", "get token from redis err", "m is nil")
log.NewError(operationID, "get token from redis err", "m is nil", tokensString)
return nil, &constant.ErrTokenInvalid
}
if v, ok := m[tokensString]; ok {
switch v {
case constant.NormalToken:
log.NewDebug("", "this is normal return", claims)
log.NewDebug(operationID, "this is normal return", claims)
return claims, nil
case constant.InValidToken:
return nil, &constant.ErrTokenInvalid
case constant.KickedToken:
log.Error(operationID, "this token has been kicked by other same terminal ", constant.ErrTokenKicked)
return nil, &constant.ErrTokenKicked
case constant.ExpiredToken:
return nil, &constant.ErrTokenExpired
@ -170,6 +170,7 @@ func ParseToken(tokensString string) (claims *Claims, err error) {
return nil, &constant.ErrTokenUnknown
}
}
log.NewError(operationID, "redis token map not find", constant.ErrTokenUnknown)
return nil, &constant.ErrTokenUnknown
}
@ -195,7 +196,7 @@ func ParseRedisInterfaceToken(redisToken interface{}) (*Claims, error) {
//Validation token, false means failure, true means successful verification
func VerifyToken(token, uid string) (bool, error) {
claims, err := ParseToken(token)
claims, err := ParseToken(token, "")
if err != nil {
return false, err
}
@ -207,7 +208,7 @@ func VerifyToken(token, uid string) (bool, error) {
return true, nil
}
func WsVerifyToken(token, uid string, platformID string) (bool, error, string) {
claims, err := ParseToken(token)
claims, err := ParseToken(token, "")
if err != nil {
return false, err, "parse token err"
}

View File

@ -118,7 +118,14 @@ func GroupMemberDBCopyOpenIM(dst *open_im_sdk.GroupMemberFullInfo, src *db.Group
dst.AppMangerLevel = 1
}
dst.JoinTime = int32(src.JoinTime.Unix())
dst.MuteEndTime = uint32(src.JoinTime.Unix())
if src.MuteEndTime.Unix() < 0 {
dst.JoinTime = 0
return nil
}
dst.MuteEndTime = uint32(src.MuteEndTime.Unix())
if dst.MuteEndTime < uint32(time.Now().Unix()) {
dst.MuteEndTime = 0
}
return nil
}

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_8580c3f7b2871da9, []int{0}
return fileDescriptor_office_7f5adce6bc494f97, []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_8580c3f7b2871da9, []int{1}
return fileDescriptor_office_7f5adce6bc494f97, []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_8580c3f7b2871da9, []int{2}
return fileDescriptor_office_7f5adce6bc494f97, []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_8580c3f7b2871da9, []int{3}
return fileDescriptor_office_7f5adce6bc494f97, []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_8580c3f7b2871da9, []int{4}
return fileDescriptor_office_7f5adce6bc494f97, []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_8580c3f7b2871da9, []int{5}
return fileDescriptor_office_7f5adce6bc494f97, []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_8580c3f7b2871da9, []int{6}
return fileDescriptor_office_7f5adce6bc494f97, []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_8580c3f7b2871da9, []int{7}
return fileDescriptor_office_7f5adce6bc494f97, []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_8580c3f7b2871da9, []int{8}
return fileDescriptor_office_7f5adce6bc494f97, []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_8580c3f7b2871da9, []int{9}
return fileDescriptor_office_7f5adce6bc494f97, []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_8580c3f7b2871da9, []int{10}
return fileDescriptor_office_7f5adce6bc494f97, []int{10}
}
func (m *SetTagResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetTagResp.Unmarshal(m, b)
@ -571,12 +571,13 @@ func (m *SetTagResp) GetCommonResp() *CommonResp {
}
type SendMsg2TagReq struct {
TagID string `protobuf:"bytes,1,opt,name=tagID" json:"tagID,omitempty"`
SendID string `protobuf:"bytes,2,opt,name=sendID" json:"sendID,omitempty"`
SenderPlatformID int32 `protobuf:"varint,3,opt,name=senderPlatformID" json:"senderPlatformID,omitempty"`
Content string `protobuf:"bytes,4,opt,name=content" json:"content,omitempty"`
ContentType int32 `protobuf:"varint,5,opt,name=contentType" json:"contentType,omitempty"`
OperationID string `protobuf:"bytes,6,opt,name=operationID" json:"operationID,omitempty"`
TagList []string `protobuf:"bytes,1,rep,name=tagList" json:"tagList,omitempty"`
UserList []string `protobuf:"bytes,2,rep,name=UserList" json:"UserList,omitempty"`
GroupList []string `protobuf:"bytes,3,rep,name=GroupList" json:"GroupList,omitempty"`
SendID string `protobuf:"bytes,4,opt,name=sendID" json:"sendID,omitempty"`
SenderPlatformID int32 `protobuf:"varint,5,opt,name=senderPlatformID" json:"senderPlatformID,omitempty"`
Content string `protobuf:"bytes,6,opt,name=content" json:"content,omitempty"`
OperationID string `protobuf:"bytes,7,opt,name=operationID" json:"operationID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -586,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_8580c3f7b2871da9, []int{11}
return fileDescriptor_office_7f5adce6bc494f97, []int{11}
}
func (m *SendMsg2TagReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SendMsg2TagReq.Unmarshal(m, b)
@ -606,11 +607,25 @@ func (m *SendMsg2TagReq) XXX_DiscardUnknown() {
var xxx_messageInfo_SendMsg2TagReq proto.InternalMessageInfo
func (m *SendMsg2TagReq) GetTagID() string {
func (m *SendMsg2TagReq) GetTagList() []string {
if m != nil {
return m.TagID
return m.TagList
}
return ""
return nil
}
func (m *SendMsg2TagReq) GetUserList() []string {
if m != nil {
return m.UserList
}
return nil
}
func (m *SendMsg2TagReq) GetGroupList() []string {
if m != nil {
return m.GroupList
}
return nil
}
func (m *SendMsg2TagReq) GetSendID() string {
@ -634,13 +649,6 @@ func (m *SendMsg2TagReq) GetContent() string {
return ""
}
func (m *SendMsg2TagReq) GetContentType() int32 {
if m != nil {
return m.ContentType
}
return 0
}
func (m *SendMsg2TagReq) GetOperationID() string {
if m != nil {
return m.OperationID
@ -659,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_8580c3f7b2871da9, []int{12}
return fileDescriptor_office_7f5adce6bc494f97, []int{12}
}
func (m *SendMsg2TagResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SendMsg2TagResp.Unmarshal(m, b)
@ -699,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_8580c3f7b2871da9, []int{13}
return fileDescriptor_office_7f5adce6bc494f97, []int{13}
}
func (m *GetTagSendLogsReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetTagSendLogsReq.Unmarshal(m, b)
@ -741,21 +749,19 @@ func (m *GetTagSendLogsReq) GetOperationID() string {
}
type TagSendLog struct {
TagID string `protobuf:"bytes,1,opt,name=tagID" json:"tagID,omitempty"`
TagName string `protobuf:"bytes,2,opt,name=tagName" json:"tagName,omitempty"`
ContentType int32 `protobuf:"varint,3,opt,name=contentType" json:"contentType,omitempty"`
Content string `protobuf:"bytes,4,opt,name=content" json:"content,omitempty"`
SendTime int64 `protobuf:"varint,5,opt,name=sendTime" json:"sendTime,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
UserList []*TagUser `protobuf:"bytes,1,rep,name=userList" json:"userList,omitempty"`
Content string `protobuf:"bytes,2,opt,name=content" json:"content,omitempty"`
SendTime int64 `protobuf:"varint,3,opt,name=sendTime" json:"sendTime,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
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_8580c3f7b2871da9, []int{14}
return fileDescriptor_office_7f5adce6bc494f97, []int{14}
}
func (m *TagSendLog) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TagSendLog.Unmarshal(m, b)
@ -775,25 +781,11 @@ func (m *TagSendLog) XXX_DiscardUnknown() {
var xxx_messageInfo_TagSendLog proto.InternalMessageInfo
func (m *TagSendLog) GetTagID() string {
func (m *TagSendLog) GetUserList() []*TagUser {
if m != nil {
return m.TagID
return m.UserList
}
return ""
}
func (m *TagSendLog) GetTagName() string {
if m != nil {
return m.TagName
}
return ""
}
func (m *TagSendLog) GetContentType() int32 {
if m != nil {
return m.ContentType
}
return 0
return nil
}
func (m *TagSendLog) GetContent() string {
@ -823,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_8580c3f7b2871da9, []int{15}
return fileDescriptor_office_7f5adce6bc494f97, []int{15}
}
func (m *GetTagSendLogsResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetTagSendLogsResp.Unmarshal(m, b)
@ -864,6 +856,106 @@ func (m *GetTagSendLogsResp) GetTagSendLogs() []*TagSendLog {
return nil
}
type GetUserTagByIDReq struct {
UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"`
TagID string `protobuf:"bytes,2,opt,name=tagID" json:"tagID,omitempty"`
OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
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_7f5adce6bc494f97, []int{16}
}
func (m *GetUserTagByIDReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserTagByIDReq.Unmarshal(m, b)
}
func (m *GetUserTagByIDReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetUserTagByIDReq.Marshal(b, m, deterministic)
}
func (dst *GetUserTagByIDReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetUserTagByIDReq.Merge(dst, src)
}
func (m *GetUserTagByIDReq) XXX_Size() int {
return xxx_messageInfo_GetUserTagByIDReq.Size(m)
}
func (m *GetUserTagByIDReq) XXX_DiscardUnknown() {
xxx_messageInfo_GetUserTagByIDReq.DiscardUnknown(m)
}
var xxx_messageInfo_GetUserTagByIDReq proto.InternalMessageInfo
func (m *GetUserTagByIDReq) GetUserID() string {
if m != nil {
return m.UserID
}
return ""
}
func (m *GetUserTagByIDReq) GetTagID() string {
if m != nil {
return m.TagID
}
return ""
}
func (m *GetUserTagByIDReq) GetOperationID() string {
if m != nil {
return m.OperationID
}
return ""
}
type GetUserTagByIDResp struct {
CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"`
Tag *Tag `protobuf:"bytes,2,opt,name=tag" json:"tag,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
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_7f5adce6bc494f97, []int{17}
}
func (m *GetUserTagByIDResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserTagByIDResp.Unmarshal(m, b)
}
func (m *GetUserTagByIDResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetUserTagByIDResp.Marshal(b, m, deterministic)
}
func (dst *GetUserTagByIDResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetUserTagByIDResp.Merge(dst, src)
}
func (m *GetUserTagByIDResp) XXX_Size() int {
return xxx_messageInfo_GetUserTagByIDResp.Size(m)
}
func (m *GetUserTagByIDResp) XXX_DiscardUnknown() {
xxx_messageInfo_GetUserTagByIDResp.DiscardUnknown(m)
}
var xxx_messageInfo_GetUserTagByIDResp proto.InternalMessageInfo
func (m *GetUserTagByIDResp) GetCommonResp() *CommonResp {
if m != nil {
return m.CommonResp
}
return nil
}
func (m *GetUserTagByIDResp) GetTag() *Tag {
if m != nil {
return m.Tag
}
return nil
}
func init() {
proto.RegisterType((*CommonResp)(nil), "office.CommonResp")
proto.RegisterType((*TagUser)(nil), "office.TagUser")
@ -881,6 +973,8 @@ func init() {
proto.RegisterType((*GetTagSendLogsReq)(nil), "office.GetTagSendLogsReq")
proto.RegisterType((*TagSendLog)(nil), "office.TagSendLog")
proto.RegisterType((*GetTagSendLogsResp)(nil), "office.GetTagSendLogsResp")
proto.RegisterType((*GetUserTagByIDReq)(nil), "office.GetUserTagByIDReq")
proto.RegisterType((*GetUserTagByIDResp)(nil), "office.GetUserTagByIDResp")
}
// Reference imports to suppress errors if they are not otherwise used.
@ -900,6 +994,7 @@ type OfficeServiceClient interface {
SetTag(ctx context.Context, in *SetTagReq, opts ...grpc.CallOption) (*SetTagResp, error)
SendMsg2Tag(ctx context.Context, in *SendMsg2TagReq, opts ...grpc.CallOption) (*SendMsg2TagResp, error)
GetTagSendLogs(ctx context.Context, in *GetTagSendLogsReq, opts ...grpc.CallOption) (*GetTagSendLogsResp, error)
GetUserTagByID(ctx context.Context, in *GetUserTagByIDReq, opts ...grpc.CallOption) (*GetUserTagByIDResp, error)
}
type officeServiceClient struct {
@ -964,6 +1059,15 @@ func (c *officeServiceClient) GetTagSendLogs(ctx context.Context, in *GetTagSend
return out, nil
}
func (c *officeServiceClient) GetUserTagByID(ctx context.Context, in *GetUserTagByIDReq, opts ...grpc.CallOption) (*GetUserTagByIDResp, error) {
out := new(GetUserTagByIDResp)
err := grpc.Invoke(ctx, "/office.OfficeService/GetUserTagByID", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for OfficeService service
type OfficeServiceServer interface {
@ -973,6 +1077,7 @@ type OfficeServiceServer interface {
SetTag(context.Context, *SetTagReq) (*SetTagResp, error)
SendMsg2Tag(context.Context, *SendMsg2TagReq) (*SendMsg2TagResp, error)
GetTagSendLogs(context.Context, *GetTagSendLogsReq) (*GetTagSendLogsResp, error)
GetUserTagByID(context.Context, *GetUserTagByIDReq) (*GetUserTagByIDResp, error)
}
func RegisterOfficeServiceServer(s *grpc.Server, srv OfficeServiceServer) {
@ -1087,6 +1192,24 @@ func _OfficeService_GetTagSendLogs_Handler(srv interface{}, ctx context.Context,
return interceptor(ctx, in, info, handler)
}
func _OfficeService_GetUserTagByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserTagByIDReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OfficeServiceServer).GetUserTagByID(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/office.OfficeService/GetUserTagByID",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OfficeServiceServer).GetUserTagByID(ctx, req.(*GetUserTagByIDReq))
}
return interceptor(ctx, in, info, handler)
}
var _OfficeService_serviceDesc = grpc.ServiceDesc{
ServiceName: "office.OfficeService",
HandlerType: (*OfficeServiceServer)(nil),
@ -1115,60 +1238,68 @@ var _OfficeService_serviceDesc = grpc.ServiceDesc{
MethodName: "GetTagSendLogs",
Handler: _OfficeService_GetTagSendLogs_Handler,
},
{
MethodName: "GetUserTagByID",
Handler: _OfficeService_GetUserTagByID_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "office/office.proto",
}
func init() { proto.RegisterFile("office/office.proto", fileDescriptor_office_8580c3f7b2871da9) }
func init() { proto.RegisterFile("office/office.proto", fileDescriptor_office_7f5adce6bc494f97) }
var fileDescriptor_office_8580c3f7b2871da9 = []byte{
// 751 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xc1, 0x6e, 0xd3, 0x4c,
0x10, 0x96, 0x93, 0x26, 0x6d, 0x26, 0x6d, 0xf3, 0x77, 0xff, 0x52, 0x82, 0x0f, 0x10, 0x2c, 0x90,
0x2a, 0x90, 0x12, 0x29, 0x70, 0x40, 0x42, 0x54, 0x88, 0xa4, 0xaa, 0x8a, 0x5a, 0x5a, 0x6d, 0xd3,
0x0b, 0x07, 0xa2, 0x6d, 0x32, 0xb1, 0xac, 0x36, 0xb6, 0xbb, 0xbb, 0x6d, 0xc5, 0x95, 0x57, 0x80,
0x57, 0x42, 0xe2, 0xca, 0x03, 0x21, 0x21, 0xaf, 0xd7, 0xf6, 0xda, 0x49, 0x04, 0xe4, 0x94, 0x9d,
0xd9, 0x99, 0xc9, 0xf7, 0x7d, 0xb3, 0x3b, 0x6b, 0xf8, 0x3f, 0x98, 0x4c, 0xbc, 0x11, 0x76, 0xe2,
0x9f, 0x76, 0xc8, 0x03, 0x19, 0x90, 0x6a, 0x6c, 0xd9, 0x8f, 0x4f, 0x42, 0xf4, 0x87, 0x87, 0xc7,
0x9d, 0xf0, 0xd2, 0xed, 0xa8, 0xad, 0x8e, 0x18, 0x5f, 0x0e, 0xef, 0x44, 0xe7, 0x4e, 0xc4, 0xa1,
0xce, 0x1e, 0x40, 0x2f, 0x98, 0x4e, 0x03, 0x9f, 0xa2, 0x08, 0x49, 0x13, 0x56, 0x91, 0xf3, 0x5e,
0x30, 0xc6, 0xa6, 0xd5, 0xb2, 0x76, 0x2b, 0x34, 0x31, 0xc9, 0x0e, 0x54, 0x91, 0xf3, 0x63, 0xe1,
0x36, 0x4b, 0x2d, 0x6b, 0xb7, 0x46, 0xb5, 0xe5, 0xbc, 0x81, 0xd5, 0x01, 0x73, 0xcf, 0x05, 0xf2,
0x28, 0xe4, 0x46, 0x20, 0x3f, 0xec, 0xab, 0xdc, 0x1a, 0xd5, 0x16, 0xb1, 0x61, 0x2d, 0x5a, 0x7d,
0x60, 0x53, 0xd4, 0xc9, 0xa9, 0xed, 0x5c, 0x40, 0x79, 0xc0, 0x5c, 0xb2, 0x0d, 0x15, 0xc9, 0xdc,
0x34, 0x33, 0x36, 0x22, 0x34, 0x92, 0xb9, 0x46, 0x5e, 0x62, 0x92, 0xe7, 0x71, 0xc9, 0x23, 0x4f,
0xc8, 0x66, 0xb9, 0x55, 0xde, 0xad, 0x77, 0x1b, 0x6d, 0xad, 0x80, 0x46, 0x43, 0xd3, 0x00, 0xe7,
0x3d, 0x6c, 0x1e, 0xa0, 0x8c, 0x9c, 0x03, 0xe6, 0x0a, 0x8a, 0xd7, 0x0b, 0x91, 0xb6, 0xa0, 0x1e,
0x84, 0xc8, 0x99, 0xf4, 0x02, 0xff, 0xb0, 0xaf, 0xff, 0xd4, 0x74, 0x39, 0x13, 0x68, 0xe4, 0x6a,
0x89, 0x90, 0x74, 0x01, 0x46, 0xa9, 0x82, 0xaa, 0x60, 0xbd, 0x4b, 0x12, 0x34, 0x99, 0xb6, 0xd4,
0x88, 0x22, 0x8f, 0x60, 0x45, 0x32, 0x57, 0x34, 0x4b, 0x0a, 0x7b, 0xdd, 0xc0, 0x4e, 0xd5, 0x86,
0xf3, 0xc5, 0x82, 0xf5, 0x1e, 0x47, 0x26, 0x31, 0xf2, 0xe1, 0xb5, 0xa9, 0x85, 0x95, 0xd7, 0x22,
0x23, 0x53, 0xca, 0x91, 0x79, 0x08, 0x10, 0xaf, 0x52, 0x95, 0x6a, 0xd4, 0xf0, 0x14, 0xc9, 0xae,
0xcc, 0x92, 0xed, 0xc1, 0x86, 0x81, 0x61, 0x39, 0xaa, 0xce, 0x27, 0x58, 0xef, 0xe3, 0x15, 0xa6,
0x44, 0x16, 0x69, 0x9f, 0x1e, 0x81, 0x92, 0x79, 0x04, 0x0a, 0x20, 0xcb, 0x73, 0x41, 0x1a, 0xf5,
0x97, 0x04, 0xf9, 0xd3, 0x82, 0xda, 0x19, 0xca, 0xa5, 0x20, 0x36, 0x61, 0xd5, 0xc7, 0x3b, 0xd5,
0x99, 0x18, 0x5e, 0x62, 0x92, 0x36, 0x10, 0xcf, 0x1f, 0x71, 0x64, 0x02, 0xcf, 0xb3, 0x4e, 0xac,
0xa8, 0x4e, 0xcc, 0xd9, 0x21, 0xcf, 0xe0, 0x3f, 0x8e, 0xe3, 0x9b, 0x91, 0x19, 0x5d, 0x51, 0xd1,
0x33, 0xfe, 0xa2, 0x30, 0xd5, 0x59, 0x61, 0xde, 0x02, 0x24, 0x94, 0x96, 0x54, 0xe5, 0x87, 0x05,
0x9b, 0x67, 0xe8, 0x8f, 0x8f, 0x85, 0xdb, 0xd5, 0xd2, 0xcc, 0xbf, 0xa8, 0x3b, 0x50, 0x15, 0xe8,
0x8f, 0xb3, 0x23, 0x18, 0x5b, 0x11, 0xa1, 0x68, 0x85, 0xfc, 0xf4, 0x8a, 0xc9, 0x49, 0xc0, 0xa7,
0xba, 0x85, 0x15, 0x3a, 0xe3, 0x8f, 0x64, 0x1c, 0x05, 0xbe, 0x44, 0x5f, 0xea, 0xa3, 0x98, 0x98,
0x11, 0x55, 0xbd, 0x1c, 0x7c, 0x0e, 0xb1, 0x59, 0x51, 0x05, 0x4c, 0xd7, 0x5f, 0x88, 0xb1, 0x0f,
0x8d, 0x1c, 0x93, 0x25, 0x15, 0xf9, 0x6a, 0xc1, 0xd6, 0x81, 0x12, 0x35, 0xaa, 0x76, 0x14, 0xc4,
0xe3, 0xa4, 0x0f, 0x70, 0xca, 0x5c, 0xcf, 0x57, 0x7f, 0xa6, 0x2b, 0x3d, 0x69, 0x0b, 0xe4, 0xb7,
0xc8, 0x87, 0x2c, 0xf4, 0x86, 0x21, 0xe3, 0x6c, 0x2a, 0xda, 0x14, 0xaf, 0x6f, 0x50, 0xc8, 0x2c,
0x96, 0x1a, 0x79, 0x0b, 0xef, 0xf1, 0x9f, 0xaf, 0xc0, 0x37, 0x0b, 0x20, 0x83, 0xf4, 0xcf, 0xc3,
0xb4, 0xa0, 0x6f, 0x79, 0x56, 0xdf, 0xc5, 0xbd, 0xb1, 0x61, 0x2d, 0xea, 0xe4, 0xc0, 0x9b, 0xc6,
0x8d, 0x29, 0xd3, 0xd4, 0x76, 0xbe, 0x5b, 0x40, 0x8a, 0x62, 0x2d, 0x39, 0x2f, 0xf7, 0x73, 0x0a,
0x97, 0x54, 0xce, 0xd3, 0xb9, 0x0a, 0x8b, 0x30, 0xf0, 0x05, 0x2e, 0x90, 0xf8, 0x25, 0xd4, 0x65,
0x86, 0x46, 0xbf, 0x1c, 0xc4, 0x98, 0xbe, 0x7a, 0x8b, 0x9a, 0x61, 0xdd, 0x5f, 0x25, 0xd8, 0x38,
0x51, 0x21, 0x67, 0xc8, 0x6f, 0xbd, 0x11, 0x92, 0x3d, 0xa8, 0x1b, 0xaf, 0x00, 0xd9, 0x49, 0x2a,
0xe4, 0x9f, 0x19, 0xfb, 0xfe, 0x5c, 0xbf, 0x08, 0xc9, 0x2b, 0xa8, 0xa5, 0x83, 0x95, 0x6c, 0xa7,
0xdc, 0x8d, 0x79, 0x6f, 0xdf, 0x9b, 0xe3, 0x8d, 0x33, 0xd3, 0x69, 0x97, 0x65, 0x9a, 0x03, 0x36,
0xcb, 0xcc, 0x8f, 0xc5, 0x0e, 0x54, 0xe3, 0x71, 0x40, 0xb6, 0x92, 0x80, 0x74, 0xe2, 0xd9, 0xa4,
0xe8, 0x12, 0x61, 0x44, 0xd2, 0xb8, 0x32, 0x19, 0xc9, 0xfc, 0x44, 0xc8, 0x48, 0x16, 0xef, 0xd7,
0x81, 0x7a, 0x76, 0x8d, 0xee, 0x93, 0x07, 0x86, 0x1e, 0xf9, 0x2b, 0x64, 0xdb, 0x8b, 0xb6, 0x44,
0xf8, 0x6e, 0xeb, 0x63, 0xa3, 0xad, 0xbf, 0x6f, 0x5e, 0xc7, 0x3f, 0x17, 0x55, 0xf5, 0xf1, 0xf2,
0xe2, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x72, 0xfc, 0x2a, 0x94, 0xfe, 0x08, 0x00, 0x00,
var fileDescriptor_office_7f5adce6bc494f97 = []byte{
// 810 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xd1, 0x6a, 0xdb, 0x4a,
0x10, 0x45, 0x76, 0x6c, 0xc7, 0xe3, 0x24, 0xbe, 0xd9, 0x9b, 0x9b, 0xeb, 0x2b, 0x6e, 0x5b, 0x57,
0xb4, 0x10, 0x5a, 0xb0, 0xc1, 0xed, 0x43, 0xa1, 0x34, 0x94, 0xd8, 0xc1, 0xb8, 0x24, 0x4d, 0x50,
0x9c, 0x97, 0x3e, 0xd4, 0x6c, 0xec, 0xb1, 0x10, 0x89, 0x25, 0x65, 0x57, 0x4e, 0xe8, 0x6b, 0x7f,
0xa1, 0xdf, 0xd4, 0xbe, 0xf7, 0x1f, 0xfa, 0x21, 0x45, 0x2b, 0x69, 0xb5, 0x2b, 0xdb, 0x04, 0x0c,
0x7d, 0x92, 0x66, 0x76, 0x66, 0x74, 0xe6, 0xec, 0xec, 0x59, 0xc1, 0xdf, 0xfe, 0x74, 0xea, 0x8e,
0xb1, 0x1d, 0x3f, 0x5a, 0x01, 0xf3, 0x43, 0x9f, 0x94, 0x63, 0xcb, 0x7c, 0x7a, 0x16, 0xa0, 0x37,
0x1a, 0x9c, 0xb6, 0x83, 0x6b, 0xa7, 0x2d, 0x96, 0xda, 0x7c, 0x72, 0x3d, 0xba, 0xe7, 0xed, 0x7b,
0x1e, 0x87, 0x5a, 0x87, 0x00, 0x5d, 0x7f, 0x36, 0xf3, 0x3d, 0x1b, 0x79, 0x40, 0x1a, 0x50, 0x41,
0xc6, 0xba, 0xfe, 0x04, 0x1b, 0x46, 0xd3, 0x38, 0x28, 0xd9, 0xa9, 0x49, 0xf6, 0xa1, 0x8c, 0x8c,
0x9d, 0x72, 0xa7, 0x51, 0x68, 0x1a, 0x07, 0x55, 0x3b, 0xb1, 0xac, 0x77, 0x50, 0x19, 0x52, 0xe7,
0x92, 0x23, 0x8b, 0x42, 0xe6, 0x1c, 0xd9, 0xa0, 0x27, 0x72, 0xab, 0x76, 0x62, 0x11, 0x13, 0x36,
0xa3, 0xb7, 0x8f, 0x74, 0x86, 0x49, 0xb2, 0xb4, 0xad, 0x2b, 0x28, 0x0e, 0xa9, 0x43, 0xf6, 0xa0,
0x14, 0x52, 0x47, 0x66, 0xc6, 0x46, 0x84, 0x26, 0xa4, 0x8e, 0x92, 0x97, 0x9a, 0xe4, 0x65, 0x5c,
0xf2, 0xc4, 0xe5, 0x61, 0xa3, 0xd8, 0x2c, 0x1e, 0xd4, 0x3a, 0xf5, 0x56, 0xc2, 0x40, 0x82, 0xc6,
0x96, 0x01, 0xd6, 0x07, 0xd8, 0xe9, 0x63, 0x18, 0x39, 0x87, 0xd4, 0xe1, 0x36, 0xde, 0xae, 0x44,
0xda, 0x84, 0x9a, 0x1f, 0x20, 0xa3, 0xa1, 0xeb, 0x7b, 0x83, 0x5e, 0xf2, 0x51, 0xd5, 0x65, 0x4d,
0xa1, 0xae, 0xd5, 0xe2, 0x01, 0xe9, 0x00, 0x8c, 0x25, 0x83, 0xa2, 0x60, 0xad, 0x43, 0x52, 0x34,
0x19, 0xb7, 0xb6, 0x12, 0x45, 0x9e, 0xc0, 0x46, 0x48, 0x1d, 0xde, 0x28, 0x08, 0xec, 0x35, 0x05,
0xbb, 0x2d, 0x16, 0xac, 0xaf, 0x06, 0x6c, 0x75, 0x19, 0xd2, 0x10, 0x23, 0x1f, 0xde, 0xaa, 0x5c,
0x18, 0x3a, 0x17, 0x59, 0x33, 0x05, 0xad, 0x99, 0xc7, 0x00, 0xf1, 0x9b, 0x64, 0xa9, 0x6a, 0x2b,
0x9e, 0x7c, 0xb3, 0x1b, 0x8b, 0xcd, 0x76, 0x61, 0x5b, 0xc1, 0xb0, 0x5e, 0xab, 0xd6, 0x67, 0xd8,
0xea, 0xe1, 0x0d, 0xca, 0x46, 0x56, 0x71, 0x2f, 0x47, 0xa0, 0xa0, 0x8e, 0x40, 0x0e, 0x64, 0x71,
0x29, 0x48, 0xa5, 0xfe, 0x9a, 0x20, 0x7f, 0x1a, 0x50, 0xbd, 0xc0, 0x70, 0x2d, 0x88, 0x0d, 0xa8,
0x78, 0x78, 0x2f, 0x76, 0x26, 0x86, 0x97, 0x9a, 0xa4, 0x05, 0xc4, 0xf5, 0xc6, 0x0c, 0x29, 0xc7,
0xcb, 0x6c, 0x27, 0x36, 0xc4, 0x4e, 0x2c, 0x59, 0x21, 0x2f, 0xe0, 0x2f, 0x86, 0x93, 0xf9, 0x58,
0x8d, 0x2e, 0x89, 0xe8, 0x05, 0x7f, 0x9e, 0x98, 0xf2, 0x22, 0x31, 0xef, 0x01, 0xd2, 0x96, 0xd6,
0x64, 0xe5, 0x97, 0x01, 0x3b, 0x17, 0xe8, 0x4d, 0x4e, 0xb9, 0xd3, 0xd1, 0xc6, 0x50, 0x20, 0x33,
0x04, 0xb2, 0xd4, 0x8c, 0x4e, 0xf9, 0x65, 0x7a, 0x24, 0x0b, 0x62, 0x49, 0xda, 0xe4, 0x7f, 0xa8,
0xf6, 0x99, 0x3f, 0x0f, 0x94, 0x49, 0xcc, 0x1c, 0x11, 0xdd, 0x1c, 0xbd, 0x89, 0x9c, 0xc1, 0xc4,
0x8a, 0xe8, 0x88, 0xde, 0x90, 0x9d, 0xdf, 0xd0, 0x70, 0xea, 0xb3, 0xd9, 0xa0, 0xd7, 0x28, 0x09,
0x55, 0x5a, 0xf0, 0x47, 0xb8, 0xc6, 0xbe, 0x17, 0xa2, 0x17, 0x26, 0x54, 0xa4, 0x66, 0x9e, 0xa8,
0xca, 0x22, 0x51, 0xc7, 0x50, 0xd7, 0xba, 0x5c, 0x93, 0xad, 0x6f, 0x06, 0xec, 0xf6, 0x05, 0xe1,
0x51, 0xb5, 0x13, 0x3f, 0x96, 0x9a, 0x1e, 0xc0, 0x39, 0x75, 0x5c, 0x4f, 0x7c, 0x2c, 0xa9, 0xf4,
0xac, 0xc5, 0x91, 0xdd, 0x21, 0x1b, 0xd1, 0xc0, 0x1d, 0x05, 0x94, 0xd1, 0x19, 0x6f, 0xd9, 0x78,
0x3b, 0x47, 0x1e, 0x66, 0xb1, 0xb6, 0x92, 0xb7, 0xf2, 0x8c, 0x3f, 0x7c, 0x3c, 0x7c, 0x80, 0x0c,
0x91, 0xa6, 0x9b, 0xc6, 0x03, 0xba, 0xa9, 0x72, 0x5a, 0xd0, 0x39, 0x35, 0x61, 0x33, 0xda, 0x81,
0xa1, 0x9b, 0xcc, 0x7c, 0xd1, 0x96, 0xb6, 0xf5, 0xdd, 0x00, 0x92, 0xa7, 0x61, 0x4d, 0x95, 0x3c,
0xd6, 0xb8, 0x2b, 0x88, 0x9c, 0xe7, 0x4b, 0xb9, 0xe3, 0x81, 0xef, 0x71, 0x5c, 0x41, 0xde, 0x6b,
0xa8, 0x85, 0x19, 0x9a, 0xe4, 0xbe, 0x20, 0x4a, 0xdf, 0xc9, 0x92, 0xad, 0x86, 0x59, 0x63, 0xb1,
0x9b, 0x89, 0xd2, 0x1f, 0x7d, 0x19, 0xf4, 0xfe, 0x84, 0x78, 0x39, 0x82, 0x2b, 0xed, 0x23, 0x6b,
0x72, 0xf5, 0x08, 0x8a, 0x21, 0x75, 0x12, 0x92, 0xb4, 0x0b, 0x25, 0xf2, 0x77, 0x7e, 0x14, 0x61,
0xfb, 0x4c, 0xf8, 0x2e, 0x90, 0xdd, 0xb9, 0x63, 0x24, 0x87, 0x50, 0x53, 0x6e, 0x32, 0xb2, 0x9f,
0xa6, 0xe8, 0x57, 0xa5, 0xf9, 0xef, 0x52, 0x3f, 0x0f, 0xc8, 0x1b, 0xa8, 0xca, 0xcb, 0x81, 0xec,
0x49, 0x74, 0xca, 0x9d, 0x65, 0xfe, 0xb3, 0xc4, 0x1b, 0x67, 0x4a, 0xc5, 0xce, 0x32, 0xd5, 0x4b,
0x22, 0xcb, 0xd4, 0xa5, 0xbd, 0x0d, 0xe5, 0x58, 0xd2, 0xc8, 0x6e, 0x1a, 0x20, 0x55, 0xdb, 0x24,
0x79, 0x17, 0x0f, 0xa2, 0x26, 0x95, 0xa3, 0x9d, 0x35, 0xa9, 0xab, 0x5a, 0xd6, 0x64, 0x5e, 0x07,
0xfa, 0xe2, 0xd7, 0x41, 0x99, 0x65, 0xf2, 0x9f, 0xc2, 0x87, 0x7e, 0xd4, 0x4d, 0x73, 0xd5, 0x92,
0x2c, 0xa4, 0x6c, 0xb4, 0x56, 0x48, 0x9f, 0x32, 0xad, 0x50, 0x6e, 0x36, 0x8e, 0x76, 0x3f, 0xd5,
0x5b, 0xc9, 0xcf, 0xde, 0xdb, 0xf8, 0x71, 0x55, 0x16, 0x7f, 0x72, 0xaf, 0x7e, 0x07, 0x00, 0x00,
0xff, 0xff, 0xed, 0x02, 0x0a, 0x32, 0x0b, 0x0a, 0x00, 0x00,
}

View File

@ -64,12 +64,13 @@ message SetTagResp {
}
message SendMsg2TagReq {
string tagID = 1;
string sendID = 2;
int32 senderPlatformID = 3;
string content = 4;
int32 contentType = 5;
string operationID = 6;
repeated string tagList = 1;
repeated string UserList = 2;
repeated string GroupList = 3;
string sendID = 4;
int32 senderPlatformID = 5;
string content = 6;
string operationID = 7;
}
message SendMsg2TagResp {
@ -83,11 +84,9 @@ message GetTagSendLogsReq {
}
message TagSendLog {
string tagID = 1;
string tagName = 2;
int32 contentType = 3;
string content = 4;
int64 sendTime = 5;
repeated TagUser userList = 1;
string content = 2;
int64 sendTime = 3;
}
message GetTagSendLogsResp {
@ -96,6 +95,17 @@ message GetTagSendLogsResp {
repeated TagSendLog tagSendLogs = 3;
}
message GetUserTagByIDReq {
string userID = 1;
string tagID = 2;
string operationID = 3;
}
message GetUserTagByIDResp {
CommonResp commonResp = 1;
Tag tag = 2;
}
service OfficeService {
rpc GetUserTags(GetUserTagsReq) returns(GetUserTagsResp);
rpc CreateTag(CreateTagReq) returns(CreateTagResp);
@ -103,5 +113,6 @@ service OfficeService {
rpc SetTag(SetTagReq) returns(SetTagResp);
rpc SendMsg2Tag(SendMsg2TagReq) returns(SendMsg2TagResp);
rpc GetTagSendLogs(GetTagSendLogsReq) returns(GetTagSendLogsResp);
rpc GetUserTagByID(GetUserTagByIDReq) returns(GetUserTagByIDResp);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,34 @@
syntax = "proto3";
option go_package = "./rtc;rtc";
package rtc;
package proto;
message CommonResp{
int32 errCode = 1;
string errMsg = 2;
}
message MsgData {
string sendID = 1;
string recvID = 2;
string groupID = 3;
string clientMsgID = 4;
string serverMsgID = 5;
int32 senderPlatformID = 6;
string senderNickname = 7;
string senderFaceURL = 8;
int32 sessionType = 9;
int32 msgFrom = 10;
int32 contentType = 11;
bytes content = 12;
uint32 seq = 14;
int64 sendTime = 15;
int64 createTime = 16;
int32 status = 17;
map<string, bool> options = 18;
OfflinePushInfo offlinePushInfo = 19;
}
message GroupInfo{
string groupID = 1;
string groupName = 2;
@ -62,8 +84,136 @@ message GetJoinTokenResp{
string liveURL = 3;
}
service RtcService {
rpc GetJoinToken(GetJoinTokenReq) returns(GetJoinTokenResp);
message OfflinePushInfo{
string title = 1;
string desc = 2;
string ex = 3;
string iOSPushSound = 4;
bool iOSBadgeCount = 5;
}
message SignalReq {
oneof payload {
SignalInviteReq invite = 1;
SignalInviteInGroupReq inviteInGroup= 2;
SignalCancelReq cancel = 3;
SignalAcceptReq accept = 4;
SignalHungUpReq hungUp = 5;
SignalRejectReq reject = 6;
}
}
message SignalResp {
oneof payload {
SignalInviteReply invite = 1;
SignalInviteInGroupReply inviteInGroup= 2;
SignalCancelReply cancel = 3;
SignalAcceptReply accept = 4;
SignalHungUpReply hungUp = 5;
SignalRejectReply reject = 6;
}
}
message InvitationInfo {
string inviterUserID = 1;
repeated string inviteeUserIDList = 2;
string customData = 3;
string groupID = 4;
string roomID = 5;
int32 timeout = 6;
string mediaType = 7;
int32 platformID = 8;
int32 sessionType = 9;
}
message SignalInviteReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
ParticipantMetaData participant = 4;
}
message SignalInviteReply {
string token = 1;
string roomID = 2;
string liveURL = 3;
}
message SignalInviteInGroupReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
ParticipantMetaData participant = 4;
}
message SignalInviteInGroupReply {
string token = 1;
string roomID = 2;
string liveURL = 3;
}
message SignalCancelReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
ParticipantMetaData participant = 4;
}
message SignalCancelReply {
}
message SignalAcceptReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
ParticipantMetaData participant = 4;
int32 opUserPlatformID = 5;
}
message SignalAcceptReply {
string token = 1;
string roomID = 2;
string liveURL = 3;
}
message SignalHungUpReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
}
message SignalHungUpReply {
}
message SignalRejectReq {
string opUserID = 1;
InvitationInfo invitation = 2;
OfflinePushInfo offlinePushInfo = 3;
ParticipantMetaData participant = 4;
int32 opUserPlatformID = 5;
}
message SignalRejectReply {
}
message SignalMessageAssembleReq {
SignalReq signalReq = 1;
string operationID = 2;
}
message SignalMessageAssembleResp {
CommonResp commonResp = 1;
bool isPass = 2;
SignalResp signalResp = 3;
MsgData msgData = 4;
}
service RtcService {
rpc SignalMessageAssemble(SignalMessageAssembleReq) returns(SignalMessageAssembleResp);
}

File diff suppressed because it is too large Load Diff

View File

@ -261,6 +261,33 @@ message GroupDismissedTips{
int64 operationTime = 3;
}
message GroupMemberMutedTips{
GroupInfo group = 1;
GroupMemberFullInfo opUser = 2;
int64 operationTime = 3;
GroupMemberFullInfo mutedUser = 4;
uint32 mutedSeconds = 5;
}
message GroupMemberCancelMutedTips{
GroupInfo group = 1;
GroupMemberFullInfo opUser = 2;
int64 operationTime = 3;
GroupMemberFullInfo mutedUser = 4;
}
message GroupMutedTips{
GroupInfo group = 1;
GroupMemberFullInfo opUser = 2;
int64 operationTime = 3;
}
message GroupCancelMutedTips{
GroupInfo group = 1;
GroupMemberFullInfo opUser = 2;
int64 operationTime = 3;
}
//////////////////////friend/////////////////////
//message FriendInfo{
@ -333,7 +360,12 @@ message UserInfoUpdatedTips{
//////////////////////conversation/////////////////////
message ConversationUpdateTips{
string UserID = 1;
}
message ConversationSetPrivateTips{
string recvID = 1;
string sendID = 2;
bool isPrivate = 3;
}
@ -474,7 +506,7 @@ message DelMsgListReq{
}
message DelMsgListResp{
int32 errCode = 1;
int32 errCode = 1;
string errMsg = 2;
}

File diff suppressed because it is too large Load Diff

View File

@ -84,7 +84,8 @@ message Conversation{
message SetConversationReq{
Conversation Conversation = 1;
string OperationID = 2;
int32 notificationType = 2;
string OperationID = 3;
}
message SetConversationResp{
@ -95,7 +96,8 @@ message SetRecvMsgOptReq {
string OwnerUserID = 1;
string ConversationID = 2;
int32 RecvMsgOpt = 3;
string OperationID = 4;
int32 notificationType = 4;
string OperationID = 5;
}
message SetRecvMsgOptResp {
@ -137,7 +139,8 @@ message GetAllConversationsResp{
message BatchSetConversationsReq{
repeated Conversation Conversations = 1;
string OwnerUserID = 2;
string OperationID = 3;
int32 notificationType = 3;
string OperationID = 4;
}
message BatchSetConversationsResp{

View File

@ -77,7 +77,7 @@ func OperationIDGenerator() string {
return strconv.FormatInt(time.Now().UnixNano()+int64(rand.Uint32()), 10)
}
func RemoveUserIDRepByMap(slc []string) []string {
func RemoveRepeatedStringInList(slc []string) []string {
var result []string
tempMap := map[string]byte{}
for _, e := range slc {

View File

@ -24,7 +24,15 @@ begin_path=$PWD
for ((i = 0; i < ${#service_source_root[*]}; i++)); do
cd $begin_path
service_path=${service_source_root[$i]}
cd $service_path && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
make install && echo -e "${SKY_BLUE_PREFIX}build ${service_names[$i]} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
echo -e "${SKY_BLUE_PREFIX}Successful moved ${service_names[$i]} to the bin directory${COLOR_SUFFIX}\n"
cd $service_path
make install
if [ $? -ne 0 ]; then
echo -e "${RED_PREFIX}${service_names[$i]} build failed ${COLOR_SUFFIX}\n"
exit -1
else
echo -e "${GREEN_PREFIX}${service_names[$i]} successfully be built ${COLOR_SUFFIX}\n"
fi
done
echo -e ${YELLOW_PREFIX}"all services build success"${COLOR_SUFFIX}

View File

@ -9,14 +9,20 @@ need_to_start_server_shell=(
push_start.sh
msg_transfer_start.sh
sdk_svr_start.sh
timer_start.sh
demo_svr_start.sh
)
#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started
sleep 10
time=`date +"%Y-%m-%d %H:%M:%S"`
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========server start time:${time}===========">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
for i in ${need_to_start_server_shell[*]}; do
chmod +x $i
./$i

View File

@ -1,12 +1,36 @@
#!/usr/bin/env bash
source ./style_info.cfg
echo -e "check environment......................................."
echo -e "check login user........................................"
user=`whoami`
if [ $user == "root" ] ; then
echo -e ${GREEN_PREFIX} "ok: login user is root" ${COLOR_SUFFIX}
else
echo -e ${RED_PREFIX}"Warning: The current user is not root "${COLOR_SUFFIX}
fi
echo -e "check docker............................................"
docker_running=`systemctl status docker | grep running | grep active | wc -l`
docker_version=`docker-compose -v; docker -v`
if [ $docker_running -gt 0 ]; then
echo -e ${GREEN_PREFIX} "ok: docker is running" ${COLOR_SUFFIX}
echo -e ${GREEN_PREFIX} $docker_version ${COLOR_SUFFIX}
else
echo -e ${RED_PREFIX}"docker not running"${COLOR_SUFFIX}
fi
echo -e "check environment......................................."
SYSTEM=`uname -s`
if [ $SYSTEM != "Linux" ] ; then
echo -e ${RED_PREFIX}"Warning: Currently only Linux is supported"${COLOR_SUFFIX}
else
echo -e ${GREEN_PREFIX} "Linux system is ok"${COLOR_SUFFIX}
echo -e ${GREEN_PREFIX} "ok: system is linux"${COLOR_SUFFIX}
fi
echo -e "check memory............................................"
@ -15,5 +39,5 @@ if [ $available -lt 2000 ] ; then
echo -e ${RED_PREFIX}"Warning: Your memory not enough, available is: " "$available"m${COLOR_SUFFIX}"\c"
echo -e ${RED_PREFIX}", must be greater than 2000m"${COLOR_SUFFIX}
else
echo -e ${GREEN_PREFIX} "Memory is ok, available is: "$available"m${COLOR_SUFFIX}"
echo -e ${GREEN_PREFIX} "ok: available memory is: "$available"m${COLOR_SUFFIX}"
fi

View File

@ -14,7 +14,7 @@ ws_ports=($ports_array)
if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then
echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX}
exit 0
exit -1
fi
#Check if the service exists

View File

@ -11,8 +11,19 @@ need_to_start_server_shell=(
sdk_svr_start.sh
demo_svr_start.sh
)
time=`date +"%Y-%m-%d %H:%M:%S"`
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========server start time:${time}===========">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
echo "==========================================================">>../logs/openIM.log 2>&1 &
for i in ${need_to_start_server_shell[*]}; do
chmod +x $i
./$i
if [ $? -ne 0 ]; then
exit -1
fi
done

View File

@ -45,24 +45,23 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
if [ $(eval ${count}) -gt 0 ]; then
pid="${service_name}| awk '{print \$2}'"
echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename[$i]} pid:$(eval $pid)${COLOR_SUFFIX}"
echo "${service_filename[$i]} service has been started,pid:$(eval $pid)"
echo "killing the service ${service_filename[$i]} pid:$(eval $pid)"
#kill the service that existed
kill -9 $(eval $pid)
sleep 0.5
fi
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service is starting${COLOR_SUFFIX}"
cd ../bin
#Get the rpc port in the configuration file
portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}')
list_to_string ${portList}
#Start related rpc services based on the number of ports
for j in ${ports_array}; do
echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} Service is starting,port number:$j $COLOR_SUFFIX"
#Start the service in the background
# ./${service_filename[$i]} -port $j &
nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 &
sleep 1
pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1"
echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX"
echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:$j pid:$(eval $pid)$COLOR_SUFFIX"
done
done