mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-24 02:16:16 +08:00
Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode
Conflicts: internal/api/auth.go internal/api/route.go internal/api/user.go internal/rpc/third/third.go
This commit is contained in:
commit
f177715ada
1
cmd/rpc/third/main.go
Normal file
1
cmd/rpc/third/main.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package third
|
56
internal/api/conversation.go
Normal file
56
internal/api/conversation.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"OpenIM/internal/api/a2r"
|
||||||
|
"OpenIM/pkg/common/config"
|
||||||
|
"OpenIM/pkg/proto/conversation"
|
||||||
|
"context"
|
||||||
|
"github.com/OpenIMSDK/openKeeper"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ context.Context // 解决goland编辑器bug
|
||||||
|
|
||||||
|
func NewConversation(zk *openKeeper.ZkClient) *Conversation {
|
||||||
|
return &Conversation{zk: zk}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Conversation struct {
|
||||||
|
zk *openKeeper.ZkClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Conversation) client() (conversation.ConversationClient, error) {
|
||||||
|
conn, err := o.zk.GetConn(config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return conversation.NewConversationClient(conn), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Conversation) GetAllConversations(c *gin.Context) {
|
||||||
|
a2r.Call(conversation.ConversationClient.GetAllConversations, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Conversation) GetConversation(c *gin.Context) {
|
||||||
|
a2r.Call(conversation.ConversationClient.GetConversation, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Conversation) GetConversations(c *gin.Context) {
|
||||||
|
a2r.Call(conversation.ConversationClient.GetConversations, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Conversation) SetConversation(c *gin.Context) {
|
||||||
|
a2r.Call(conversation.ConversationClient.SetConversation, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Conversation) BatchSetConversations(c *gin.Context) {
|
||||||
|
a2r.Call(conversation.ConversationClient.BatchSetConversations, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Conversation) SetRecvMsgOpt(c *gin.Context) {
|
||||||
|
a2r.Call(conversation.ConversationClient.SetRecvMsgOpt, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Conversation) ModifyConversationField(c *gin.Context) {
|
||||||
|
a2r.Call(conversation.ConversationClient.ModifyConversationField, o.client, c)
|
||||||
|
}
|
@ -1,327 +0,0 @@
|
|||||||
package conversation
|
|
||||||
|
|
||||||
import (
|
|
||||||
api "OpenIM/pkg/apistruct"
|
|
||||||
"OpenIM/pkg/common/config"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
pbConversation "OpenIM/pkg/proto/conversation"
|
|
||||||
pbUser "OpenIM/pkg/proto/user"
|
|
||||||
"OpenIM/pkg/utils"
|
|
||||||
"context"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func SetConversation(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.SetConversationReq
|
|
||||||
resp api.SetConversationResp
|
|
||||||
reqPb pbUser.SetConversationReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.Conversation = &pbConversation.Conversation{}
|
|
||||||
err := utils.CopyStructFields(&reqPb, req)
|
|
||||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
|
||||||
if err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
|
||||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
func ModifyConversationField(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.ModifyConversationFieldReq
|
|
||||||
resp api.ModifyConversationFieldResp
|
|
||||||
reqPb pbConversation.ModifyConversationFieldReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.Conversation = &pbConversation.Conversation{}
|
|
||||||
err := utils.CopyStructFields(&reqPb, req)
|
|
||||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
|
||||||
if err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbConversation.NewConversationClient(etcdConn)
|
|
||||||
respPb, err := client.ModifyConversationField(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
|
||||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func BatchSetConversations(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.BatchSetConversationsReq
|
|
||||||
resp api.BatchSetConversationsResp
|
|
||||||
reqPb pbUser.BatchSetConversationsReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := utils.CopyStructFields(&resp.Data, respPb); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
|
||||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Summary 获取用户所有会话
|
|
||||||
// @Description 获取用户所有会话
|
|
||||||
// @Tags 会话相关
|
|
||||||
// @ID GetAllConversations
|
|
||||||
// @Accept json
|
|
||||||
// @Param token header string true "im token"
|
|
||||||
// @Param req body api.GetAllConversationsReq true "ownerUserID为要获取的用户ID"
|
|
||||||
// @Produce json
|
|
||||||
// @Success 0 {object} api.GetAllConversationsResp
|
|
||||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
|
||||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
|
||||||
// @Router /msg/get_all_conversations [post]
|
|
||||||
func GetAllConversations(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.GetAllConversationsReq
|
|
||||||
resp api.GetAllConversationsResp
|
|
||||||
reqPb pbUser.GetAllConversationsReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
|
||||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
|
||||||
if err := utils.CopyStructFields(&resp.Conversations, respPb.Conversations); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed, ", err.Error())
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Summary 根据会话ID获取会话
|
|
||||||
// @Description 根据会话ID获取会话
|
|
||||||
// @Tags 会话相关
|
|
||||||
// @ID GetConversation
|
|
||||||
// @Accept json
|
|
||||||
// @Param token header string true "im token"
|
|
||||||
// @Param req body api.GetConversationReq true "ownerUserID为要获取的用户ID<br>conversationID为要获取的会话ID"
|
|
||||||
// @Produce json
|
|
||||||
// @Success 0 {object} api.GetConversationResp
|
|
||||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
|
||||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
|
||||||
// @Router /msg/get_conversation [post]
|
|
||||||
func GetConversation(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.GetConversationReq
|
|
||||||
resp api.GetConversationResp
|
|
||||||
reqPb pbUser.GetConversationReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetConversation(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
|
||||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
|
||||||
if err := utils.CopyStructFields(&resp.Conversation, respPb.Conversation); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Summary 根据会话ID列表获取会话
|
|
||||||
// @Description 根据会话ID列表获取会话
|
|
||||||
// @Tags 会话相关
|
|
||||||
// @ID GetConversations
|
|
||||||
// @Accept json
|
|
||||||
// @Param token header string true "im token"
|
|
||||||
// @Param req body api.GetConversationsReq true "ownerUserID为要获取的用户ID<br>conversationIDs为要获取的会话ID列表"
|
|
||||||
// @Produce json
|
|
||||||
// @Success 0 {object} api.GetConversationsResp
|
|
||||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
|
||||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
|
||||||
// @Router /msg/get_conversations [post]
|
|
||||||
func GetConversations(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.GetConversationsReq
|
|
||||||
resp api.GetConversationsResp
|
|
||||||
reqPb pbUser.GetConversationsReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetConversations(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
|
||||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
|
||||||
if err := utils.CopyStructFields(&resp.Conversations, respPb.Conversations); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetRecvMsgOpt(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.SetRecvMsgOptReq
|
|
||||||
resp api.SetRecvMsgOptResp
|
|
||||||
reqPb pbUser.SetRecvMsgOptReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
|
||||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
func SetReceiveMessageOpt(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
func GetReceiveMessageOpt(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
func GetAllConversationMessageOpt(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
@ -19,58 +19,58 @@ type Friend struct {
|
|||||||
zk *openKeeper.ZkClient
|
zk *openKeeper.ZkClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) getGroupClient() (friend.FriendClient, error) {
|
func (o *Friend) client() (friend.FriendClient, error) {
|
||||||
conn, err := f.zk.GetConn(config.Config.RpcRegisterName.OpenImGroupName)
|
conn, err := o.zk.GetConn(config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return friend.NewFriendClient(conn), nil
|
return friend.NewFriendClient(conn), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) AddFriend(c *gin.Context) {
|
func (o *Friend) ApplyToAddFriend(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.AddFriend, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.ApplyToAddFriend, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) DeleteFriend(c *gin.Context) {
|
func (o *Friend) DeleteFriend(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.DeleteFriend, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.DeleteFriend, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) GetFriendApplyList(c *gin.Context) {
|
func (o *Friend) GetFriendApplyList(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.GetFriendApplyList, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyFrom, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) GetSelfApplyList(c *gin.Context) {
|
func (o *Friend) GetSelfApplyList(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.GetSelfApplyList, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyFrom, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) GetFriendList(c *gin.Context) {
|
func (o *Friend) GetFriendList(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.GetFriendList, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.GetDesignatedFriends, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) AddFriendResponse(c *gin.Context) {
|
func (o *Friend) RespondFriendApply(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.AddFriendResponse, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.RespondFriendApply, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) SetFriendRemark(c *gin.Context) {
|
func (o *Friend) SetFriendRemark(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.SetFriendRemark, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.SetFriendRemark, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) AddBlack(c *gin.Context) {
|
func (o *Friend) AddBlack(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.AddBlack, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.AddBlack, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) GetBlacklist(c *gin.Context) {
|
func (o *Friend) GetPaginationBlacks(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.GetBlacklist, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.GetPaginationBlacks, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) RemoveBlacklist(c *gin.Context) {
|
func (o *Friend) RemoveBlack(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.RemoveBlacklist, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.RemoveBlack, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) ImportFriend(c *gin.Context) {
|
func (o *Friend) ImportFriends(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.ImportFriend, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.ImportFriends, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Friend) IsFriend(c *gin.Context) {
|
func (o *Friend) IsFriend(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.IsFriend, f.getGroupClient, c)
|
a2r.Call(friend.FriendClient.IsFriend, o.client, c)
|
||||||
}
|
}
|
||||||
|
@ -19,106 +19,106 @@ type Group struct {
|
|||||||
zk *openKeeper.ZkClient
|
zk *openKeeper.ZkClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) getGroupClient() (group.GroupClient, error) {
|
func (o *Group) client() (group.GroupClient, error) {
|
||||||
conn, err := g.zk.GetConn(config.Config.RpcRegisterName.OpenImGroupName)
|
conn, err := o.zk.GetConn(config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return group.NewGroupClient(conn), nil
|
return group.NewGroupClient(conn), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) NewCreateGroup(c *gin.Context) {
|
func (o *Group) NewCreateGroup(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.CreateGroup, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.CreateGroup, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) NewSetGroupInfo(c *gin.Context) {
|
func (o *Group) NewSetGroupInfo(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.SetGroupInfo, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.SetGroupInfo, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) JoinGroup(c *gin.Context) {
|
func (o *Group) JoinGroup(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.JoinGroup, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.JoinGroup, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) QuitGroup(c *gin.Context) {
|
func (o *Group) QuitGroup(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.QuitGroup, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.QuitGroup, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) ApplicationGroupResponse(c *gin.Context) {
|
func (o *Group) ApplicationGroupResponse(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.GroupApplicationResponse, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.GroupApplicationResponse, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) TransferGroupOwner(c *gin.Context) {
|
func (o *Group) TransferGroupOwner(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.TransferGroupOwner, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.TransferGroupOwner, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) GetRecvGroupApplicationList(c *gin.Context) {
|
func (o *Group) GetRecvGroupApplicationList(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.GetGroupApplicationList, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.GetGroupApplicationList, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) GetUserReqGroupApplicationList(c *gin.Context) {
|
func (o *Group) GetUserReqGroupApplicationList(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.GetUserReqApplicationList, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.GetUserReqApplicationList, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) GetGroupsInfo(c *gin.Context) {
|
func (o *Group) GetGroupsInfo(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.GetGroupsInfo, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.GetGroupsInfo, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) KickGroupMember(c *gin.Context) {
|
func (o *Group) KickGroupMember(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.KickGroupMember, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.KickGroupMember, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) GetGroupMembersInfo(c *gin.Context) {
|
func (o *Group) GetGroupMembersInfo(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.GetGroupMembersInfo, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.GetGroupMembersInfo, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) InviteUserToGroup(c *gin.Context) {
|
func (o *Group) InviteUserToGroup(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.InviteUserToGroup, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.InviteUserToGroup, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) GetJoinedGroupList(c *gin.Context) {
|
func (o *Group) GetJoinedGroupList(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.GetJoinedGroupList, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.GetJoinedGroupList, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) DismissGroup(c *gin.Context) {
|
func (o *Group) DismissGroup(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.DismissGroup, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.DismissGroup, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) MuteGroupMember(c *gin.Context) {
|
func (o *Group) MuteGroupMember(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.MuteGroupMember, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.MuteGroupMember, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) CancelMuteGroupMember(c *gin.Context) {
|
func (o *Group) CancelMuteGroupMember(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.CancelMuteGroupMember, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.CancelMuteGroupMember, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) MuteGroup(c *gin.Context) {
|
func (o *Group) MuteGroup(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.MuteGroup, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.MuteGroup, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) CancelMuteGroup(c *gin.Context) {
|
func (o *Group) CancelMuteGroup(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.CancelMuteGroup, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.CancelMuteGroup, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) SetGroupMemberInfo(c *gin.Context) {
|
func (o *Group) SetGroupMemberInfo(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.SetGroupMemberInfo, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.SetGroupMemberInfo, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) GetGroupAbstractInfo(c *gin.Context) {
|
func (o *Group) GetGroupAbstractInfo(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.GetGroupAbstractInfo, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.GetGroupAbstractInfo, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (g *Group) SetGroupMemberNickname(c *gin.Context) {
|
//func (g *Group) SetGroupMemberNickname(c *gin.Context) {
|
||||||
// a2r.Call(group.GroupClient.SetGroupMemberNickname, g.getGroupClient, c)
|
// a2r.Call(group.GroupClient.SetGroupMemberNickname, g.client, c)
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func (g *Group) GetGroupAllMemberList(c *gin.Context) {
|
//func (g *Group) GetGroupAllMemberList(c *gin.Context) {
|
||||||
// a2r.Call(group.GroupClient.GetGroupAllMember, g.getGroupClient, c)
|
// a2r.Call(group.GroupClient.GetGroupAllMember, g.client, c)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func (g *Group) GetJoinedSuperGroupList(c *gin.Context) {
|
func (o *Group) GetJoinedSuperGroupList(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.GetJoinedSuperGroupList, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.GetJoinedSuperGroupList, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) GetSuperGroupsInfo(c *gin.Context) {
|
func (o *Group) GetSuperGroupsInfo(c *gin.Context) {
|
||||||
a2r.Call(group.GroupClient.GetSuperGroupsInfo, g.getGroupClient, c)
|
a2r.Call(group.GroupClient.GetSuperGroupsInfo, o.client, c)
|
||||||
}
|
}
|
||||||
|
84
internal/api/msg.go
Normal file
84
internal/api/msg.go
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"OpenIM/internal/api/a2r"
|
||||||
|
"OpenIM/pkg/common/config"
|
||||||
|
"OpenIM/pkg/proto/msg"
|
||||||
|
"context"
|
||||||
|
"github.com/OpenIMSDK/openKeeper"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ context.Context // 解决goland编辑器bug
|
||||||
|
|
||||||
|
func NewMsg(zk *openKeeper.ZkClient) *Conversation {
|
||||||
|
return &Conversation{zk: zk}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Msg struct {
|
||||||
|
zk *openKeeper.ZkClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) client() (msg.MsgClient, error) {
|
||||||
|
conn, err := o.zk.GetConn(config.Config.RpcRegisterName.OpenImMsgName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return msg.NewMsgClient(conn), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) GetSeq(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.GetSeq, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) SendMsg(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.SendMsg, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) PullMsgBySeqList(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.PullMsgBySeqList, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) DelMsg(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.DelMsg, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) DelSuperGroupMsg(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.DelSuperGroupMsg, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) ClearMsg(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.ClearMsg, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) SetMsgMinSeq(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.SetMsgMinSeq, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) SetMessageReactionExtensions(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.SetMessageReactionExtensions, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) GetMessageListReactionExtensions(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.GetMessageListReactionExtensions, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) AddMessageReactionExtensions(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.AddMessageReactionExtensions, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) DeleteMessageReactionExtensions(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.DeleteMessageReactionExtensions, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) ManagementSendMsg(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.ManagementSendMsg, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) ManagementBatchSendMsg(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.ManagementBatchSendMsg, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Msg) CheckMsgIsSendSuccess(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.CheckMsgIsSendSuccess, o.client, c)
|
||||||
|
}
|
@ -1,273 +0,0 @@
|
|||||||
package msg
|
|
||||||
|
|
||||||
import (
|
|
||||||
api "OpenIM/pkg/apistruct"
|
|
||||||
"OpenIM/pkg/common/config"
|
|
||||||
"OpenIM/pkg/common/constant"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/common/tokenverify"
|
|
||||||
rpc "OpenIM/pkg/proto/msg"
|
|
||||||
pbCommon "OpenIM/pkg/proto/sdkws"
|
|
||||||
"OpenIM/pkg/utils"
|
|
||||||
"context"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// @Summary 根据seq列表删除消息
|
|
||||||
// @Description 根据seq列表删除消息
|
|
||||||
// @Tags 消息相关
|
|
||||||
// @ID DelMsg
|
|
||||||
// @Accept json
|
|
||||||
// @Param token header string true "im token"
|
|
||||||
// @Param req body api.DelMsgReq true "userID为要删除的用户ID <br> seqList为seq列表"
|
|
||||||
// @Produce json
|
|
||||||
// @Success 0 {object} api.DelMsgResp
|
|
||||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
|
||||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
|
||||||
// @Router /msg/del_msg [post]
|
|
||||||
func DelMsg(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.DelMsgReq
|
|
||||||
resp api.DelMsgResp
|
|
||||||
reqPb pbCommon.DelMsgListReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, reqPb.OpUserID, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
|
||||||
if grpcConn == nil {
|
|
||||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
msgClient := rpc.NewMsgClient(grpcConn)
|
|
||||||
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.ErrCode = respPb.ErrCode
|
|
||||||
resp.ErrMsg = respPb.ErrMsg
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
func DelSuperGroupMsg(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.DelSuperGroupMsgReq
|
|
||||||
resp api.DelSuperGroupMsgResp
|
|
||||||
)
|
|
||||||
rpcReq := &rpc.DelSuperGroupMsgReq{}
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("", "args err:", err.Error())
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
utils.CopyStructFields(rpcReq, &req)
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, rpcReq.OpUserID, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + rpcReq.OpUserID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
options := make(map[string]bool, 5)
|
|
||||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
|
||||||
utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false)
|
|
||||||
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
|
||||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
|
||||||
pbData := rpc.SendMsgReq{
|
|
||||||
OperationID: req.OperationID,
|
|
||||||
MsgData: &pbCommon.MsgData{
|
|
||||||
SendID: req.UserID,
|
|
||||||
RecvID: req.UserID,
|
|
||||||
ClientMsgID: utils.GetMsgID(req.UserID),
|
|
||||||
SessionType: constant.SingleChatType,
|
|
||||||
MsgFrom: constant.SysMsgType,
|
|
||||||
ContentType: constant.MsgDeleteNotification,
|
|
||||||
// ForceList: params.ForceList,
|
|
||||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
|
||||||
Options: options,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
var tips pbCommon.TipsComm
|
|
||||||
deleteMsg := api.MsgDeleteNotificationElem{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
IsAllDelete: req.IsAllDelete,
|
|
||||||
SeqList: req.SeqList,
|
|
||||||
}
|
|
||||||
tips.JsonDetail = utils.StructToJsonString(deleteMsg)
|
|
||||||
var err error
|
|
||||||
pbData.MsgData.Content, err = proto.Marshal(&tips)
|
|
||||||
if err != nil {
|
|
||||||
log.Error(req.OperationID, "Marshal failed ", err.Error(), tips.String())
|
|
||||||
resp.ErrCode = 400
|
|
||||||
resp.ErrMsg = err.Error()
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call start..., [data: %s]", pbData.String())
|
|
||||||
etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewMsgClient(etcdConn)
|
|
||||||
|
|
||||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call, api call rpc...")
|
|
||||||
if req.IsAllDelete {
|
|
||||||
RpcResp, err := client.DelSuperGroupMsg(context.Background(), rpcReq)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "call delete DelSuperGroupMsg rpc server failed", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call DelSuperGroupMsg rpc server failed"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
|
||||||
resp.ErrCode = RpcResp.ErrCode
|
|
||||||
resp.ErrMsg = RpcResp.ErrMsg
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
} else {
|
|
||||||
RpcResp, err := client.SendMsg(context.Background(), &pbData)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
|
||||||
resp.ErrCode = RpcResp.ErrCode
|
|
||||||
resp.ErrMsg = RpcResp.ErrMsg
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Summary 清空用户消息
|
|
||||||
// @Description 清空用户消息
|
|
||||||
// @Tags 消息相关
|
|
||||||
// @ID ClearMsg
|
|
||||||
// @Accept json
|
|
||||||
// @Param token header string true "im token"
|
|
||||||
// @Param req body api.CleanUpMsgReq true "userID为要清空的用户ID"
|
|
||||||
// @Produce json
|
|
||||||
// @Success 0 {object} api.CleanUpMsgResp
|
|
||||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
|
||||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
|
||||||
// @Router /msg/clear_msg [post]
|
|
||||||
func ClearMsg(c *gin.Context) {
|
|
||||||
params := api.CleanUpMsgReq{}
|
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//
|
|
||||||
req := &rpc.ClearMsgReq{}
|
|
||||||
utils.CopyStructFields(req, ¶ms)
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, req.OpUserID, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
|
||||||
|
|
||||||
etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewMsgClient(etcdConn)
|
|
||||||
RpcResp, err := client.ClearMsg(context.Background(), req)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, " CleanUpMsg failed ", err.Error(), req.String(), RpcResp.ErrMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": RpcResp.ErrMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
resp := api.CleanUpMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Summary 设置用户最小seq
|
|
||||||
// @Description 设置用户最小seq,以及用户相关读扩散群组最小seq
|
|
||||||
// @Tags 消息相关
|
|
||||||
// @ID SetMsgMinSeq
|
|
||||||
// @Accept json
|
|
||||||
// @Param token header string true "im token"
|
|
||||||
func SetMsgMinSeq(c *gin.Context) {
|
|
||||||
params := api.SetMsgMinSeqReq{}
|
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//
|
|
||||||
req := &rpc.SetMsgMinSeqReq{}
|
|
||||||
utils.CopyStructFields(req, ¶ms)
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, req.OpUserID, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
|
||||||
etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewMsgClient(etcdConn)
|
|
||||||
RpcResp, err := client.SetMsgMinSeq(context.Background(), req)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, " SetMsgMinSeq failed ", err.Error(), req.String(), RpcResp.ErrMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": RpcResp.ErrMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
resp := api.SetMsgMinSeqResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
@ -1,202 +0,0 @@
|
|||||||
package msg
|
|
||||||
|
|
||||||
import (
|
|
||||||
api "OpenIM/pkg/apistruct"
|
|
||||||
"OpenIM/pkg/common/config"
|
|
||||||
"OpenIM/pkg/common/constant"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/common/tokenverify"
|
|
||||||
rpc "OpenIM/pkg/proto/msg"
|
|
||||||
"OpenIM/pkg/utils"
|
|
||||||
"context"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func SetMessageReactionExtensions(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.SetMessageReactionExtensionsCallbackReq
|
|
||||||
resp api.SetMessageReactionExtensionsCallbackResp
|
|
||||||
reqPb rpc.SetMessageReactionExtensionsReq
|
|
||||||
)
|
|
||||||
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
|
||||||
|
|
||||||
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
|
||||||
}
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, reqPb.OpUserID, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
|
||||||
if grpcConn == nil {
|
|
||||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
msgClient := rpc.NewMsgClient(grpcConn)
|
|
||||||
respPb, err := msgClient.SetMessageReactionExtensions(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.ErrCode = respPb.ErrCode
|
|
||||||
resp.ErrMsg = respPb.ErrMsg
|
|
||||||
resp.Data.ResultKeyValue = respPb.Result
|
|
||||||
resp.Data.MsgFirstModifyTime = reqPb.MsgFirstModifyTime
|
|
||||||
resp.Data.IsReact = reqPb.IsReact
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetMessageListReactionExtensions(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.GetMessageListReactionExtensionsReq
|
|
||||||
resp api.GetMessageListReactionExtensionsResp
|
|
||||||
reqPb rpc.GetMessageListReactionExtensionsReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
|
||||||
|
|
||||||
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
|
||||||
}
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, reqPb.OpUserID, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
|
||||||
if grpcConn == nil {
|
|
||||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
msgClient := rpc.NewMsgClient(grpcConn)
|
|
||||||
respPb, err := msgClient.GetMessageListReactionExtensions(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.ErrCode = respPb.ErrCode
|
|
||||||
resp.ErrMsg = respPb.ErrMsg
|
|
||||||
resp.Data = respPb.SingleMessageResult
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddMessageReactionExtensions(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.AddMessageReactionExtensionsReq
|
|
||||||
resp api.AddMessageReactionExtensionsResp
|
|
||||||
reqPb rpc.ModifyMessageReactionExtensionsReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
|
||||||
|
|
||||||
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
|
||||||
}
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, reqPb.OpUserID, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
|
||||||
if grpcConn == nil {
|
|
||||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
msgClient := rpc.NewMsgClient(grpcConn)
|
|
||||||
respPb, err := msgClient.AddMessageReactionExtensions(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.ErrCode = respPb.ErrCode
|
|
||||||
resp.ErrMsg = respPb.ErrMsg
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeleteMessageReactionExtensions(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.DeleteMessageReactionExtensionsReq
|
|
||||||
resp api.DeleteMessageReactionExtensionsResp
|
|
||||||
reqPb rpc.DeleteMessageListReactionExtensionsReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
|
||||||
|
|
||||||
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
|
||||||
}
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, reqPb.OpUserID, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
|
||||||
if grpcConn == nil {
|
|
||||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
msgClient := rpc.NewMsgClient(grpcConn)
|
|
||||||
respPb, err := msgClient.DeleteMessageReactionExtensions(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.ErrCode = respPb.ErrCode
|
|
||||||
resp.ErrMsg = respPb.ErrMsg
|
|
||||||
resp.Data = respPb.Result
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
package msg
|
|
||||||
|
|
||||||
import (
|
|
||||||
"OpenIM/pkg/common/config"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/common/tokenverify"
|
|
||||||
pbChat "OpenIM/pkg/proto/msg"
|
|
||||||
sdkws "OpenIM/pkg/proto/sdkws"
|
|
||||||
"context"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type paramsUserNewestSeq struct {
|
|
||||||
ReqIdentifier int `json:"reqIdentifier" binding:"required"`
|
|
||||||
SendID string `json:"sendID" binding:"required"`
|
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
|
||||||
MsgIncr int `json:"msgIncr" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetSeq(c *gin.Context) {
|
|
||||||
params := paramsUserNewestSeq{}
|
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
|
||||||
if ok, err := tokenverify.VerifyToken(token, params.SendID); !ok {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pbData := sdkws.GetMaxAndMinSeqReq{}
|
|
||||||
pbData.UserID = params.SendID
|
|
||||||
pbData.OperationID = params.OperationID
|
|
||||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
|
||||||
if grpcConn == nil {
|
|
||||||
errMsg := pbData.OperationID + " getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(pbData.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
msgClient := pbChat.NewMsgClient(grpcConn)
|
|
||||||
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(params.OperationID, "UserGetSeq rpc failed, ", params, err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "UserGetSeq rpc failed, " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"errCode": reply.ErrCode,
|
|
||||||
"errMsg": reply.ErrMsg,
|
|
||||||
"msgIncr": params.MsgIncr,
|
|
||||||
"reqIdentifier": params.ReqIdentifier,
|
|
||||||
"data": gin.H{
|
|
||||||
"maxSeq": reply.MaxSeq,
|
|
||||||
"minSeq": reply.MinSeq,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
package msg
|
|
||||||
|
|
||||||
import (
|
|
||||||
"OpenIM/pkg/common/config"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/common/tokenverify"
|
|
||||||
"OpenIM/pkg/proto/msg"
|
|
||||||
sdkws "OpenIM/pkg/proto/sdkws"
|
|
||||||
"OpenIM/pkg/utils"
|
|
||||||
"context"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type paramsUserPullMsg struct {
|
|
||||||
ReqIdentifier *int `json:"reqIdentifier" binding:"required"`
|
|
||||||
SendID string `json:"sendID" binding:"required"`
|
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
|
||||||
Data struct {
|
|
||||||
SeqBegin *int64 `json:"seqBegin" binding:"required"`
|
|
||||||
SeqEnd *int64 `json:"seqEnd" binding:"required"`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type paramsUserPullMsgBySeqList struct {
|
|
||||||
ReqIdentifier int `json:"reqIdentifier" binding:"required"`
|
|
||||||
SendID string `json:"sendID" binding:"required"`
|
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
|
||||||
SeqList []uint32 `json:"seqList"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func PullMsgBySeqList(c *gin.Context) {
|
|
||||||
params := paramsUserPullMsgBySeqList{}
|
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
|
||||||
if ok, err := tokenverify.VerifyToken(token, params.SendID); !ok {
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error(), token, params.SendID)
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pbData := sdkws.PullMessageBySeqListReq{}
|
|
||||||
pbData.UserID = params.SendID
|
|
||||||
pbData.OperationID = params.OperationID
|
|
||||||
pbData.SeqList = params.SeqList
|
|
||||||
|
|
||||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
|
||||||
if grpcConn == nil {
|
|
||||||
errMsg := pbData.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(pbData.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
msgClient := msg.NewMsgClient(grpcConn)
|
|
||||||
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
|
|
||||||
if err != nil {
|
|
||||||
log.Error(pbData.OperationID, "PullMessageBySeqList error", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(pbData.OperationID, "rpc call success to PullMessageBySeqList", reply.String(), len(reply.List))
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"errCode": reply.ErrCode,
|
|
||||||
"errMsg": reply.ErrMsg,
|
|
||||||
"reqIdentifier": params.ReqIdentifier,
|
|
||||||
"data": reply.List,
|
|
||||||
})
|
|
||||||
}
|
|
@ -1,102 +0,0 @@
|
|||||||
package msg
|
|
||||||
|
|
||||||
import (
|
|
||||||
"OpenIM/pkg/common/config"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
pbChat "OpenIM/pkg/proto/msg"
|
|
||||||
sdkws "OpenIM/pkg/proto/sdkws"
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type paramsUserSendMsg struct {
|
|
||||||
SenderPlatformID int32 `json:"senderPlatformID" binding:"required"`
|
|
||||||
SendID string `json:"sendID" binding:"required"`
|
|
||||||
SenderNickName string `json:"senderNickName"`
|
|
||||||
SenderFaceURL string `json:"senderFaceUrl"`
|
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
|
||||||
Data struct {
|
|
||||||
SessionType int32 `json:"sessionType" binding:"required"`
|
|
||||||
MsgFrom int32 `json:"msgFrom" binding:"required"`
|
|
||||||
ContentType int32 `json:"contentType" binding:"required"`
|
|
||||||
RecvID string `json:"recvID" `
|
|
||||||
GroupID string `json:"groupID" `
|
|
||||||
ForceList []string `json:"forceList"`
|
|
||||||
Content []byte `json:"content" binding:"required"`
|
|
||||||
Options map[string]bool `json:"options" `
|
|
||||||
ClientMsgID string `json:"clientMsgID" binding:"required"`
|
|
||||||
CreateTime int64 `json:"createTime" binding:"required"`
|
|
||||||
OffLineInfo *sdkws.OfflinePushInfo `json:"offlineInfo" `
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func newUserSendMsgReq(token string, params *paramsUserSendMsg) *pbChat.SendMsgReq {
|
|
||||||
pbData := pbChat.SendMsgReq{
|
|
||||||
Token: token,
|
|
||||||
OperationID: params.OperationID,
|
|
||||||
MsgData: &sdkws.MsgData{
|
|
||||||
SendID: params.SendID,
|
|
||||||
RecvID: params.Data.RecvID,
|
|
||||||
GroupID: params.Data.GroupID,
|
|
||||||
ClientMsgID: params.Data.ClientMsgID,
|
|
||||||
SenderPlatformID: params.SenderPlatformID,
|
|
||||||
SenderNickname: params.SenderNickName,
|
|
||||||
SenderFaceURL: params.SenderFaceURL,
|
|
||||||
SessionType: params.Data.SessionType,
|
|
||||||
MsgFrom: params.Data.MsgFrom,
|
|
||||||
ContentType: params.Data.ContentType,
|
|
||||||
Content: params.Data.Content,
|
|
||||||
CreateTime: params.Data.CreateTime,
|
|
||||||
Options: params.Data.Options,
|
|
||||||
OfflinePushInfo: params.Data.OffLineInfo,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return &pbData
|
|
||||||
}
|
|
||||||
|
|
||||||
func SendMsg(c *gin.Context) {
|
|
||||||
params := paramsUserSendMsg{}
|
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
log.Error("0", "BindJSON failed ", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
|
||||||
log.NewInfo(params.OperationID, "api call success to sendMsgReq", params)
|
|
||||||
pbData := newUserSendMsgReq(token, ¶ms)
|
|
||||||
log.Info(params.OperationID, "", "api SendMsg call start..., [data: %s]", pbData.String())
|
|
||||||
|
|
||||||
etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(params.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbChat.NewMsgClient(etcdConn)
|
|
||||||
|
|
||||||
log.Info(params.OperationID, "", "api SendMsg call, api call rpc...")
|
|
||||||
|
|
||||||
reply, err := client.SendMsg(context.Background(), pbData)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(params.OperationID, "SendMsg rpc failed, ", params, err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "SendMsg rpc failed, " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Info(params.OperationID, "", "api SendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"errCode": reply.ErrCode,
|
|
||||||
"errMsg": reply.ErrMsg,
|
|
||||||
"data": gin.H{
|
|
||||||
"clientMsgID": reply.ClientMsgID,
|
|
||||||
"serverMsgID": reply.ServerMsgID,
|
|
||||||
"sendTime": reply.SendTime,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +1,13 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"OpenIM/internal/api/conversation"
|
|
||||||
"OpenIM/internal/api/manage"
|
"OpenIM/internal/api/manage"
|
||||||
"OpenIM/internal/api/msg"
|
"OpenIM/internal/api/msg"
|
||||||
"OpenIM/internal/api/third"
|
|
||||||
"OpenIM/pkg/common/config"
|
"OpenIM/pkg/common/config"
|
||||||
"OpenIM/pkg/common/log"
|
"OpenIM/pkg/common/log"
|
||||||
"OpenIM/pkg/common/middleware"
|
"OpenIM/pkg/common/middleware"
|
||||||
"OpenIM/pkg/common/prome"
|
"OpenIM/pkg/common/prome"
|
||||||
|
"github.com/OpenIMSDK/openKeeper"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@ -31,9 +30,11 @@ func NewGinRouter() *gin.Engine {
|
|||||||
r.GET("/metrics", prome.PrometheusHandler())
|
r.GET("/metrics", prome.PrometheusHandler())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var zk *openKeeper.ZkClient
|
||||||
|
|
||||||
userRouterGroup := r.Group("/user")
|
userRouterGroup := r.Group("/user")
|
||||||
{
|
{
|
||||||
u := NewUser(nil)
|
u := NewUser(zk)
|
||||||
userRouterGroup.POST("/user_register", u.UserRegister)
|
userRouterGroup.POST("/user_register", u.UserRegister)
|
||||||
userRouterGroup.POST("/update_user_info", u.UpdateUserInfo) //1
|
userRouterGroup.POST("/update_user_info", u.UpdateUserInfo) //1
|
||||||
userRouterGroup.POST("/set_global_msg_recv_opt", u.SetGlobalRecvMessageOpt)
|
userRouterGroup.POST("/set_global_msg_recv_opt", u.SetGlobalRecvMessageOpt)
|
||||||
@ -50,23 +51,23 @@ func NewGinRouter() *gin.Engine {
|
|||||||
////friend routing group
|
////friend routing group
|
||||||
friendRouterGroup := r.Group("/friend")
|
friendRouterGroup := r.Group("/friend")
|
||||||
{
|
{
|
||||||
f := NewFriend(nil)
|
f := NewFriend(zk)
|
||||||
friendRouterGroup.POST("/add_friend", f.AddFriend) //1
|
friendRouterGroup.POST("/add_friend", f.ApplyToAddFriend) //1
|
||||||
friendRouterGroup.POST("/delete_friend", f.DeleteFriend) //1
|
friendRouterGroup.POST("/delete_friend", f.DeleteFriend) //1
|
||||||
friendRouterGroup.POST("/get_friend_apply_list", f.GetFriendApplyList) //1
|
friendRouterGroup.POST("/get_friend_apply_list", f.GetFriendApplyList) //1
|
||||||
friendRouterGroup.POST("/get_self_friend_apply_list", f.GetSelfApplyList) //1
|
friendRouterGroup.POST("/get_self_friend_apply_list", f.GetSelfApplyList) //1
|
||||||
friendRouterGroup.POST("/get_friend_list", f.GetFriendList) //1
|
friendRouterGroup.POST("/get_friend_list", f.GetFriendList) //1
|
||||||
friendRouterGroup.POST("/add_friend_response", f.AddFriendResponse) //1
|
friendRouterGroup.POST("/add_friend_response", f.RespondFriendApply) //1
|
||||||
friendRouterGroup.POST("/set_friend_remark", f.SetFriendRemark) //1
|
friendRouterGroup.POST("/set_friend_remark", f.SetFriendRemark) //1
|
||||||
friendRouterGroup.POST("/add_black", f.AddBlack) //1
|
friendRouterGroup.POST("/add_black", f.AddBlack) //1
|
||||||
friendRouterGroup.POST("/get_black_list", f.GetBlacklist) //1
|
friendRouterGroup.POST("/get_black_list", f.GetPaginationBlacks) //1
|
||||||
friendRouterGroup.POST("/remove_black", f.RemoveBlacklist) //1
|
friendRouterGroup.POST("/remove_black", f.RemoveBlack) //1
|
||||||
friendRouterGroup.POST("/import_friend", f.ImportFriend) //1
|
friendRouterGroup.POST("/import_friend", f.ImportFriends) //1
|
||||||
friendRouterGroup.POST("/is_friend", f.IsFriend) //1
|
friendRouterGroup.POST("/is_friend", f.IsFriend) //1
|
||||||
|
|
||||||
}
|
}
|
||||||
groupRouterGroup := r.Group("/group")
|
groupRouterGroup := r.Group("/group")
|
||||||
g := NewGroup(nil)
|
g := NewGroup(zk)
|
||||||
{
|
{
|
||||||
groupRouterGroup.POST("/create_group", g.NewCreateGroup) //1
|
groupRouterGroup.POST("/create_group", g.NewCreateGroup) //1
|
||||||
groupRouterGroup.POST("/set_group_info", g.NewSetGroupInfo) //1
|
groupRouterGroup.POST("/set_group_info", g.NewSetGroupInfo) //1
|
||||||
@ -99,8 +100,8 @@ func NewGinRouter() *gin.Engine {
|
|||||||
////certificate
|
////certificate
|
||||||
authRouterGroup := r.Group("/auth")
|
authRouterGroup := r.Group("/auth")
|
||||||
{
|
{
|
||||||
a := NewAuth(nil)
|
a := NewAuth(zk)
|
||||||
u := NewUser(nil)
|
u := NewUser(zk)
|
||||||
authRouterGroup.POST("/user_register", u.UserRegister) //1
|
authRouterGroup.POST("/user_register", u.UserRegister) //1
|
||||||
authRouterGroup.POST("/user_token", a.UserToken) //1
|
authRouterGroup.POST("/user_token", a.UserToken) //1
|
||||||
authRouterGroup.POST("/parse_token", a.ParseToken) //1
|
authRouterGroup.POST("/parse_token", a.ParseToken) //1
|
||||||
@ -109,17 +110,16 @@ func NewGinRouter() *gin.Engine {
|
|||||||
////Third service
|
////Third service
|
||||||
thirdGroup := r.Group("/third")
|
thirdGroup := r.Group("/third")
|
||||||
{
|
{
|
||||||
thirdGroup.POST("/tencent_cloud_storage_credential", third.TencentCloudStorageCredential)
|
t := NewThird(zk)
|
||||||
thirdGroup.POST("/ali_oss_credential", third.AliOSSCredential)
|
|
||||||
thirdGroup.POST("/minio_storage_credential", third.MinioStorageCredential)
|
thirdGroup.POST("/get_rtc_invitation_info", t.GetSignalInvitationInfo)
|
||||||
thirdGroup.POST("/minio_upload", third.MinioUploadFile)
|
thirdGroup.POST("/get_rtc_invitation_start_app", t.GetSignalInvitationInfoStartApp)
|
||||||
thirdGroup.POST("/upload_update_app", third.UploadUpdateApp)
|
thirdGroup.POST("/fcm_update_token", t.FcmUpdateToken)
|
||||||
thirdGroup.POST("/get_download_url", third.GetDownloadURL)
|
thirdGroup.POST("/set_app_badge", t.SetAppBadge)
|
||||||
thirdGroup.POST("/get_rtc_invitation_info", third.GetRTCInvitationInfo)
|
|
||||||
thirdGroup.POST("/get_rtc_invitation_start_app", third.GetRTCInvitationInfoStartApp)
|
thirdGroup.POST("/apply_put", t.ApplyPut)
|
||||||
thirdGroup.POST("/fcm_update_token", third.FcmUpdateToken)
|
thirdGroup.POST("/get_put", t.GetPut)
|
||||||
thirdGroup.POST("/aws_storage_credential", third.AwsStorageCredential)
|
thirdGroup.POST("/confirm_put", t.ConfirmPut)
|
||||||
thirdGroup.POST("/set_app_badge", third.SetAppBadge)
|
|
||||||
}
|
}
|
||||||
////Message
|
////Message
|
||||||
chatGroup := r.Group("/msg")
|
chatGroup := r.Group("/msg")
|
||||||
@ -143,13 +143,36 @@ func NewGinRouter() *gin.Engine {
|
|||||||
////Conversation
|
////Conversation
|
||||||
conversationGroup := r.Group("/conversation")
|
conversationGroup := r.Group("/conversation")
|
||||||
{ //1
|
{ //1
|
||||||
conversationGroup.POST("/get_all_conversations", conversation.GetAllConversations)
|
c := NewConversation(zk)
|
||||||
conversationGroup.POST("/get_conversation", conversation.GetConversation)
|
conversationGroup.POST("/get_all_conversations", c.GetAllConversations)
|
||||||
conversationGroup.POST("/get_conversations", conversation.GetConversations)
|
conversationGroup.POST("/get_conversation", c.GetConversation)
|
||||||
conversationGroup.POST("/set_conversation", conversation.SetConversation)
|
conversationGroup.POST("/get_conversations", c.GetConversations)
|
||||||
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
conversationGroup.POST("/set_conversation", c.SetConversation)
|
||||||
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
conversationGroup.POST("/batch_set_conversation", c.BatchSetConversations)
|
||||||
conversationGroup.POST("/modify_conversation_field", conversation.ModifyConversationField)
|
conversationGroup.POST("/set_recv_msg_opt", c.SetRecvMsgOpt)
|
||||||
|
conversationGroup.POST("/modify_conversation_field", c.ModifyConversationField)
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
{
|
||||||
|
GetSeq
|
||||||
|
SendMsg
|
||||||
|
PullMsgBySeqList
|
||||||
|
DelMsg
|
||||||
|
DelSuperGroupMsg
|
||||||
|
ClearMsg
|
||||||
|
SetMsgMinSeq
|
||||||
|
SetMessageReactionExtensions
|
||||||
|
GetMessageListReactionExtensions
|
||||||
|
AddMessageReactionExtensions
|
||||||
|
DeleteMessageReactionExtensions
|
||||||
|
ManagementSendMsg
|
||||||
|
ManagementBatchSendMsg
|
||||||
|
CheckMsgIsSendSuccess
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
56
internal/api/third.go
Normal file
56
internal/api/third.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"OpenIM/internal/api/a2r"
|
||||||
|
"OpenIM/pkg/common/config"
|
||||||
|
"OpenIM/pkg/proto/third"
|
||||||
|
"context"
|
||||||
|
"github.com/OpenIMSDK/openKeeper"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ context.Context // 解决goland编辑器bug
|
||||||
|
|
||||||
|
func NewThird(zk *openKeeper.ZkClient) *Third {
|
||||||
|
return &Third{zk: zk}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Third struct {
|
||||||
|
zk *openKeeper.ZkClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Third) client() (third.ThirdClient, error) {
|
||||||
|
conn, err := o.zk.GetConn(config.Config.RpcRegisterName.OpenImThirdName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return third.NewThirdClient(conn), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Third) ApplyPut(c *gin.Context) {
|
||||||
|
a2r.Call(third.ThirdClient.ApplyPut, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Third) GetPut(c *gin.Context) {
|
||||||
|
a2r.Call(third.ThirdClient.GetPut, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Third) ConfirmPut(c *gin.Context) {
|
||||||
|
a2r.Call(third.ThirdClient.ConfirmPut, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Third) GetSignalInvitationInfo(c *gin.Context) {
|
||||||
|
a2r.Call(third.ThirdClient.GetSignalInvitationInfo, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Third) GetSignalInvitationInfoStartApp(c *gin.Context) {
|
||||||
|
a2r.Call(third.ThirdClient.GetSignalInvitationInfoStartApp, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Third) FcmUpdateToken(c *gin.Context) {
|
||||||
|
a2r.Call(third.ThirdClient.FcmUpdateToken, o.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Third) SetAppBadge(c *gin.Context) {
|
||||||
|
a2r.Call(third.ThirdClient.SetAppBadge, o.client, c)
|
||||||
|
}
|
@ -1,101 +0,0 @@
|
|||||||
package third
|
|
||||||
|
|
||||||
import (
|
|
||||||
api "OpenIM/pkg/apistruct"
|
|
||||||
"OpenIM/pkg/common/config"
|
|
||||||
"OpenIM/pkg/common/constant"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/common/tokenverify"
|
|
||||||
"fmt"
|
|
||||||
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
|
|
||||||
sts20150401 "github.com/alibabacloud-go/sts-20150401/client"
|
|
||||||
"github.com/alibabacloud-go/tea/tea"
|
|
||||||
"github.com/fatih/structs"
|
|
||||||
|
|
||||||
//"github.com/fatih/structs"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
var stsClient *sts20150401.Client
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用AK&SK初始化账号Client
|
|
||||||
* @param accessKeyId
|
|
||||||
* @param accessKeySecret
|
|
||||||
* @return Client
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
func getStsClient() *sts20150401.Client {
|
|
||||||
if stsClient != nil {
|
|
||||||
return stsClient
|
|
||||||
}
|
|
||||||
conf := &openapi.Config{
|
|
||||||
// 您的AccessKey ID
|
|
||||||
AccessKeyId: tea.String(config.Config.Credential.Ali.AccessKeyID),
|
|
||||||
// 您的AccessKey Secret
|
|
||||||
AccessKeySecret: tea.String(config.Config.Credential.Ali.AccessKeySecret),
|
|
||||||
// Endpoint
|
|
||||||
Endpoint: tea.String(config.Config.Credential.Ali.StsEndpoint),
|
|
||||||
}
|
|
||||||
result, err := sts20150401.NewClient(conf)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError("", "alists client初始化失败 ", err)
|
|
||||||
}
|
|
||||||
stsClient = result
|
|
||||||
return stsClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func AliOSSCredential(c *gin.Context) {
|
|
||||||
req := api.OSSCredentialReq{}
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
var userID string
|
|
||||||
var errInfo string
|
|
||||||
ok, userID, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "AliOSSCredential args ", userID)
|
|
||||||
|
|
||||||
stsResp, err := getStsClient().AssumeRole(&sts20150401.AssumeRoleRequest{
|
|
||||||
DurationSeconds: tea.Int64(config.Config.Credential.Ali.StsDurationSeconds),
|
|
||||||
Policy: nil,
|
|
||||||
RoleArn: tea.String(config.Config.Credential.Ali.OssRoleArn),
|
|
||||||
RoleSessionName: tea.String(fmt.Sprintf("%s-%d", userID, time.Now().Unix())),
|
|
||||||
})
|
|
||||||
|
|
||||||
resp := api.OSSCredentialResp{}
|
|
||||||
if err != nil {
|
|
||||||
resp.ErrCode = constant.ErrTencentCredential.ErrCode
|
|
||||||
resp.ErrMsg = err.Error()
|
|
||||||
} else {
|
|
||||||
resp = api.OSSCredentialResp{
|
|
||||||
CommResp: api.CommResp{},
|
|
||||||
OssData: api.OSSCredentialRespData{
|
|
||||||
Endpoint: config.Config.Credential.Ali.OssEndpoint,
|
|
||||||
AccessKeyId: *stsResp.Body.Credentials.AccessKeyId,
|
|
||||||
AccessKeySecret: *stsResp.Body.Credentials.AccessKeySecret,
|
|
||||||
Token: *stsResp.Body.Credentials.SecurityToken,
|
|
||||||
Bucket: config.Config.Credential.Ali.Bucket,
|
|
||||||
FinalHost: config.Config.Credential.Ali.FinalHost,
|
|
||||||
},
|
|
||||||
Data: nil,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resp.Data = structs.Map(&resp.OssData)
|
|
||||||
log.NewInfo(req.OperationID, "AliOSSCredential return ", resp)
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
package third
|
|
||||||
|
|
||||||
import (
|
|
||||||
api "OpenIM/pkg/apistruct"
|
|
||||||
"OpenIM/pkg/common/config"
|
|
||||||
"OpenIM/pkg/common/constant"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/common/tokenverify"
|
|
||||||
"OpenIM/pkg/utils"
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/aws"
|
|
||||||
awsConfig "github.com/aws/aws-sdk-go-v2/config"
|
|
||||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
|
||||||
"github.com/aws/aws-sdk-go-v2/service/sts"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
func AwsStorageCredential(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.AwsStorageCredentialReq
|
|
||||||
resp api.AwsStorageCredentialResp
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, _, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//原始帐号信息
|
|
||||||
awsSourceConfig, err := awsConfig.LoadDefaultConfig(context.TODO(), awsConfig.WithRegion(config.Config.Credential.Aws.Region),
|
|
||||||
awsConfig.WithCredentialsProvider(credentials.StaticCredentialsProvider{
|
|
||||||
Value: aws.Credentials{
|
|
||||||
AccessKeyID: config.Config.Credential.Aws.AccessKeyID,
|
|
||||||
SecretAccessKey: config.Config.Credential.Aws.AccessKeySecret,
|
|
||||||
Source: "Open IM OSS",
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
if err != nil {
|
|
||||||
errMsg := req.OperationID + " " + "Init AWS S3 Credential failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//帐号转化
|
|
||||||
awsStsClient := sts.NewFromConfig(awsSourceConfig)
|
|
||||||
StsRole, err := awsStsClient.AssumeRole(context.Background(), &sts.AssumeRoleInput{
|
|
||||||
RoleArn: aws.String(config.Config.Credential.Aws.RoleArn),
|
|
||||||
DurationSeconds: aws.Int32(constant.AwsDurationTimes),
|
|
||||||
RoleSessionName: aws.String(config.Config.Credential.Aws.RoleSessionName),
|
|
||||||
ExternalId: aws.String(config.Config.Credential.Aws.ExternalId),
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
errMsg := req.OperationID + " " + "AWS S3 AssumeRole failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.CosData.AccessKeyId = string(*StsRole.Credentials.AccessKeyId)
|
|
||||||
resp.CosData.SecretAccessKey = string(*StsRole.Credentials.SecretAccessKey)
|
|
||||||
resp.CosData.SessionToken = string(*StsRole.Credentials.SessionToken)
|
|
||||||
resp.CosData.Bucket = config.Config.Credential.Aws.Bucket
|
|
||||||
resp.CosData.RegionID = config.Config.Credential.Aws.Region
|
|
||||||
resp.CosData.FinalHost = config.Config.Credential.Aws.FinalHost
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package third
|
|
||||||
|
|
||||||
import (
|
|
||||||
api "OpenIM/pkg/apistruct"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/common/tokenverify"
|
|
||||||
"OpenIM/pkg/utils"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
func FcmUpdateToken(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.FcmUpdateTokenReq
|
|
||||||
resp api.FcmUpdateTokenResp
|
|
||||||
)
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
|
||||||
|
|
||||||
ok, UserId, errInfo := tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
resp.ErrCode = 500
|
|
||||||
resp.ErrMsg = errMsg
|
|
||||||
c.JSON(http.StatusInternalServerError, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req, UserId)
|
|
||||||
//逻辑处理开始
|
|
||||||
err := db.DB.SetFcmToken(UserId, req.Platform, req.FcmToken, 0)
|
|
||||||
if err != nil {
|
|
||||||
errMsg := req.OperationID + " " + "SetFcmToken failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
resp.ErrCode = 500
|
|
||||||
resp.ErrMsg = errMsg
|
|
||||||
c.JSON(http.StatusInternalServerError, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//逻辑处理完毕
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,101 +0,0 @@
|
|||||||
package third
|
|
||||||
|
|
||||||
import (
|
|
||||||
"OpenIM/pkg/common/config"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/utils"
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"github.com/minio/minio-go/v7"
|
|
||||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
|
||||||
url2 "net/url"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
MinioClient *minio.Client
|
|
||||||
)
|
|
||||||
|
|
||||||
func MinioInit() {
|
|
||||||
operationID := utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio config: ", config.Config.Credential.Minio)
|
|
||||||
var initUrl string
|
|
||||||
if config.Config.Credential.Minio.EndpointInnerEnable {
|
|
||||||
initUrl = config.Config.Credential.Minio.EndpointInner
|
|
||||||
} else {
|
|
||||||
initUrl = config.Config.Credential.Minio.Endpoint
|
|
||||||
}
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "use initUrl: ", initUrl)
|
|
||||||
minioUrl, err := url2.Parse(initUrl)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
opts := &minio.Options{
|
|
||||||
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
|
||||||
//Region: config.Config.Credential.Minio.Location,
|
|
||||||
}
|
|
||||||
if minioUrl.Scheme == "http" {
|
|
||||||
opts.Secure = false
|
|
||||||
} else if minioUrl.Scheme == "https" {
|
|
||||||
opts.Secure = true
|
|
||||||
}
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
|
|
||||||
MinioClient, err = minio.New(minioUrl.Host, opts)
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "new ok ", config.Config.Credential.Minio)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
opt := minio.MakeBucketOptions{
|
|
||||||
Region: config.Config.Credential.Minio.Location,
|
|
||||||
}
|
|
||||||
if config.Config.Credential.Minio.IsDistributedMod == true {
|
|
||||||
opt.ObjectLocking = true
|
|
||||||
}
|
|
||||||
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
|
|
||||||
if err != nil {
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
|
|
||||||
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
|
||||||
if err == nil && exists {
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
|
|
||||||
} else {
|
|
||||||
if err != nil {
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
}
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// make app bucket
|
|
||||||
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.AppBucket, opt)
|
|
||||||
if err != nil {
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
|
|
||||||
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
|
||||||
if err == nil && exists {
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
|
|
||||||
} else {
|
|
||||||
if err != nil {
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
}
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
policy, err := MinioClient.GetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket)
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), policy)
|
|
||||||
|
|
||||||
// 自动化桶public的代码
|
|
||||||
policyJsonString := fmt.Sprintf(`{"Version": "2012-10-17","Statement": [{"Action": ["s3:GetObject","s3:PutObject"],
|
|
||||||
"Effect": "Allow","Principal": {"AWS": ["*"]},"Resource": ["arn:aws:s3:::%s/*"],"Sid": ""}]}`, config.Config.Credential.Minio.Bucket)
|
|
||||||
err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policyJsonString)
|
|
||||||
if err != nil {
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
|
|
||||||
}
|
|
||||||
policyJsonString = fmt.Sprintf(`{"Version": "2012-10-17","Statement": [{"Action": ["s3:GetObject","s3:PutObject"],
|
|
||||||
"Effect": "Allow","Principal": {"AWS": ["*"]},"Resource": ["arn:aws:s3:::%s/*"],"Sid": ""}]}`, config.Config.Credential.Minio.AppBucket)
|
|
||||||
err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.AppBucket, policyJsonString)
|
|
||||||
if err != nil {
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
|
|
||||||
}
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio create and set policy success")
|
|
||||||
}
|
|
@ -1,276 +0,0 @@
|
|||||||
package third
|
|
||||||
|
|
||||||
import (
|
|
||||||
api "OpenIM/pkg/apistruct"
|
|
||||||
"OpenIM/pkg/common/config"
|
|
||||||
"OpenIM/pkg/common/constant"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/common/tokenverify"
|
|
||||||
_ "OpenIM/pkg/common/tokenverify"
|
|
||||||
"OpenIM/pkg/utils"
|
|
||||||
"context"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/minio/minio-go/v7"
|
|
||||||
_ "github.com/minio/minio-go/v7"
|
|
||||||
cr "github.com/minio/minio-go/v7/pkg/credentials"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// @Summary minio上传文件(web api)
|
|
||||||
// @Description minio上传文件(web api), 请注意本api请求为form并非json
|
|
||||||
// @Tags 第三方服务相关
|
|
||||||
// @ID MinioUploadFile
|
|
||||||
// @Accept json
|
|
||||||
// @Param token header string true "im token"
|
|
||||||
// @Param file formData file true "要上传的文件文件"
|
|
||||||
// @Param fileType formData int true "文件类型"
|
|
||||||
// @Param operationID formData string true "操作唯一ID"
|
|
||||||
// @Produce json
|
|
||||||
// @Success 0 {object} api.MinioUploadFileResp ""
|
|
||||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
|
||||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
|
||||||
// @Router /third/minio_upload [post]
|
|
||||||
func MinioUploadFile(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.MinioUploadFileReq
|
|
||||||
resp api.MinioUploadFile
|
|
||||||
)
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), r)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file or snapShot args"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, _, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
|
||||||
switch req.FileType {
|
|
||||||
// videoType upload snapShot
|
|
||||||
case constant.VideoType:
|
|
||||||
snapShotFile, err := c.FormFile("snapShot")
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing snapshot arg: " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
snapShotFileObj, err := snapShotFile.Open()
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
snapShotNewName, snapShotNewType := utils.GetNewFileNameAndContentType(snapShotFile.Filename, constant.ImageType)
|
|
||||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), snapShotNewName, snapShotNewType)
|
|
||||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject snapShotFile error", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.SnapshotURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.Bucket + "/" + snapShotNewName
|
|
||||||
resp.SnapshotNewName = snapShotNewName
|
|
||||||
}
|
|
||||||
file, err := c.FormFile("file")
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "FormFile failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fileObj, err := file.Open()
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file path" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType)
|
|
||||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, newType, MinioClient.EndpointURL())
|
|
||||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "upload file error", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "upload file error" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.NewName = newName
|
|
||||||
resp.URL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.Bucket + "/" + newName
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func MinioStorageCredential(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.MinioStorageCredentialReq
|
|
||||||
resp api.MiniostorageCredentialResp
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, _, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var stsOpts cr.STSAssumeRoleOptions
|
|
||||||
stsOpts.AccessKey = config.Config.Credential.Minio.AccessKeyID
|
|
||||||
stsOpts.SecretKey = config.Config.Credential.Minio.SecretAccessKey
|
|
||||||
stsOpts.DurationSeconds = constant.MinioDurationTimes
|
|
||||||
var endpoint string
|
|
||||||
if config.Config.Credential.Minio.EndpointInnerEnable {
|
|
||||||
endpoint = config.Config.Credential.Minio.EndpointInner
|
|
||||||
} else {
|
|
||||||
endpoint = config.Config.Credential.Minio.Endpoint
|
|
||||||
}
|
|
||||||
li, err := cr.NewSTSAssumeRole(endpoint, stsOpts)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "NewSTSAssumeRole failed", err.Error(), stsOpts, config.Config.Credential.Minio.Endpoint)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v, err := li.Get()
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "li.Get error", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.SessionToken = v.SessionToken
|
|
||||||
resp.SecretAccessKey = v.SecretAccessKey
|
|
||||||
resp.AccessKeyID = v.AccessKeyID
|
|
||||||
resp.BucketName = config.Config.Credential.Minio.Bucket
|
|
||||||
resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint
|
|
||||||
resp.StorageTime = config.Config.Credential.Minio.StorageTime
|
|
||||||
resp.IsDistributedMod = config.Config.Credential.Minio.IsDistributedMod
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
|
||||||
}
|
|
||||||
|
|
||||||
func UploadUpdateApp(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.UploadUpdateAppReq
|
|
||||||
resp api.UploadUpdateAppResp
|
|
||||||
)
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
|
|
||||||
var yamlName string
|
|
||||||
if req.Yaml == nil {
|
|
||||||
yamlName = ""
|
|
||||||
} else {
|
|
||||||
yamlName = req.Yaml.Filename
|
|
||||||
}
|
|
||||||
fileObj, err := req.File.Open()
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Open file error" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, req.File.Filename, fileObj, req.File.Size, minio.PutObjectOptions{})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject file error")
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject file error" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if yamlName != "" {
|
|
||||||
yamlObj, err := req.Yaml.Open()
|
|
||||||
if err == nil {
|
|
||||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, yamlName, yamlObj, req.Yaml.Size, minio.PutObjectOptions{})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject yaml error")
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject yaml error" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := imdb.UpdateAppVersion(req.Type, req.Version, req.ForceUpdate, req.File.Filename, yamlName, req.UpdateLog); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateAppVersion error", err.Error())
|
|
||||||
resp.ErrCode = http.StatusInternalServerError
|
|
||||||
resp.ErrMsg = err.Error()
|
|
||||||
c.JSON(http.StatusInternalServerError, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName())
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func version2Int(version string) (int, error) {
|
|
||||||
versions := strings.Split(version, ".")
|
|
||||||
s := strings.Join(versions, "")
|
|
||||||
versionInt, err := strconv.Atoi(s)
|
|
||||||
return versionInt, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetDownloadURL(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.GetDownloadURLReq
|
|
||||||
resp api.GetDownloadURLResp
|
|
||||||
)
|
|
||||||
defer func() {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
}()
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
app, err := imdb.GetNewestVersion(req.Type)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "getNewestVersion failed", err.Error())
|
|
||||||
}
|
|
||||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), "app: ", app)
|
|
||||||
if app != nil {
|
|
||||||
appVersion, err := version2Int(app.Version)
|
|
||||||
reqVersion, err := version2Int(req.Version)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), "req version", req.Version, "app version", app.Version)
|
|
||||||
}
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "req version:", reqVersion, "app version:", appVersion)
|
|
||||||
if appVersion > reqVersion && app.Version != "" {
|
|
||||||
resp.Data.HasNewVersion = true
|
|
||||||
if app.ForceUpdate == true {
|
|
||||||
resp.Data.ForceUpdate = true
|
|
||||||
}
|
|
||||||
if app.YamlName != "" {
|
|
||||||
resp.Data.YamlURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.YamlName
|
|
||||||
}
|
|
||||||
resp.Data.FileURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.FileName
|
|
||||||
resp.Data.Version = app.Version
|
|
||||||
resp.Data.UpdateLog = app.UpdateLog
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
resp.Data.HasNewVersion = false
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 0, "errMsg": "not found app version"})
|
|
||||||
}
|
|
@ -1,95 +0,0 @@
|
|||||||
package third
|
|
||||||
|
|
||||||
import (
|
|
||||||
api "OpenIM/pkg/apistruct"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/common/tokenverify"
|
|
||||||
"OpenIM/pkg/utils"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetRTCInvitationInfo(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.GetRTCInvitationInfoReq
|
|
||||||
resp api.GetRTCInvitationInfoResp
|
|
||||||
)
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
ok, userID, errInfo := tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var err error
|
|
||||||
invitationInfo, err := db.DB.GetSignalInfoFromCacheByClientMsgID(req.ClientMsgID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSignalInfoFromCache", err.Error(), req)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := db.DB.DelUserSignalList(userID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelUserSignalList result:", err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
resp.Data.OpUserID = invitationInfo.OpUserID
|
|
||||||
resp.Data.Invitation.RoomID = invitationInfo.Invitation.RoomID
|
|
||||||
resp.Data.Invitation.SessionType = invitationInfo.Invitation.SessionType
|
|
||||||
resp.Data.Invitation.GroupID = invitationInfo.Invitation.GroupID
|
|
||||||
resp.Data.Invitation.InviterUserID = invitationInfo.Invitation.InviterUserID
|
|
||||||
resp.Data.Invitation.InviteeUserIDList = invitationInfo.Invitation.InviteeUserIDList
|
|
||||||
resp.Data.Invitation.MediaType = invitationInfo.Invitation.MediaType
|
|
||||||
resp.Data.Invitation.Timeout = invitationInfo.Invitation.Timeout
|
|
||||||
resp.Data.Invitation.InitiateTime = invitationInfo.Invitation.InitiateTime
|
|
||||||
resp.Data.Invitation.PlatformID = invitationInfo.Invitation.PlatformID
|
|
||||||
resp.Data.Invitation.CustomData = invitationInfo.Invitation.CustomData
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetRTCInvitationInfoStartApp(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.GetRTCInvitationInfoStartAppReq
|
|
||||||
resp api.GetRTCInvitationInfoStartAppResp
|
|
||||||
)
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, userID, errInfo := tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
invitationInfo, err := db.DB.GetAvailableSignalInvitationInfo(userID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSignalInfoFromCache", err.Error(), req)
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": err.Error(), "data": struct{}{}})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.Data.OpUserID = invitationInfo.OpUserID
|
|
||||||
resp.Data.Invitation.RoomID = invitationInfo.Invitation.RoomID
|
|
||||||
resp.Data.Invitation.SessionType = invitationInfo.Invitation.SessionType
|
|
||||||
resp.Data.Invitation.GroupID = invitationInfo.Invitation.GroupID
|
|
||||||
resp.Data.Invitation.InviterUserID = invitationInfo.Invitation.InviterUserID
|
|
||||||
resp.Data.Invitation.InviteeUserIDList = invitationInfo.Invitation.InviteeUserIDList
|
|
||||||
resp.Data.Invitation.MediaType = invitationInfo.Invitation.MediaType
|
|
||||||
resp.Data.Invitation.Timeout = invitationInfo.Invitation.Timeout
|
|
||||||
resp.Data.Invitation.InitiateTime = invitationInfo.Invitation.InitiateTime
|
|
||||||
resp.Data.Invitation.PlatformID = invitationInfo.Invitation.PlatformID
|
|
||||||
resp.Data.Invitation.CustomData = invitationInfo.Invitation.CustomData
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package third
|
|
||||||
|
|
||||||
import (
|
|
||||||
api "OpenIM/pkg/apistruct"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/common/tokenverify"
|
|
||||||
"OpenIM/pkg/utils"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func SetAppBadge(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.SetAppBadgeReq
|
|
||||||
resp api.SetAppBadgeResp
|
|
||||||
)
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
var errInfo, opUserID string
|
|
||||||
ok, opUserID, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !tokenverify.CheckAccess(c, opUserID, req.FromUserID) {
|
|
||||||
log.NewError(req.OperationID, "CheckAccess false ", opUserID, req.FromUserID)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "no permission"})
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req, opUserID)
|
|
||||||
err := db.DB.SetUserBadgeUnreadCountSum(req.FromUserID, int(req.AppUnreadCount))
|
|
||||||
if err != nil {
|
|
||||||
errMsg := req.OperationID + " " + "SetUserBadgeUnreadCountSum failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
resp.ErrCode = 500
|
|
||||||
resp.ErrMsg = errMsg
|
|
||||||
c.JSON(http.StatusInternalServerError, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
package third
|
|
||||||
|
|
||||||
import (
|
|
||||||
api "OpenIM/pkg/apistruct"
|
|
||||||
"OpenIM/pkg/common/config"
|
|
||||||
"OpenIM/pkg/common/constant"
|
|
||||||
"OpenIM/pkg/common/log"
|
|
||||||
"OpenIM/pkg/common/tokenverify"
|
|
||||||
"github.com/fatih/structs"
|
|
||||||
|
|
||||||
//"github.com/fatih/structs"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
sts "github.com/tencentyun/qcloud-cos-sts-sdk/go"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TencentCloudStorageCredential(c *gin.Context) {
|
|
||||||
req := api.TencentCloudStorageCredentialReq{}
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
var userID string
|
|
||||||
var errInfo string
|
|
||||||
ok, userID, errInfo = tokenverify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "TencentCloudStorageCredential args ", userID)
|
|
||||||
|
|
||||||
cli := sts.NewClient(
|
|
||||||
config.Config.Credential.Tencent.SecretID,
|
|
||||||
config.Config.Credential.Tencent.SecretKey,
|
|
||||||
nil,
|
|
||||||
)
|
|
||||||
|
|
||||||
opt := &sts.CredentialOptions{
|
|
||||||
DurationSeconds: int64(time.Hour.Seconds()),
|
|
||||||
Region: config.Config.Credential.Tencent.Region,
|
|
||||||
Policy: &sts.CredentialPolicy{
|
|
||||||
Statement: []sts.CredentialPolicyStatement{
|
|
||||||
{
|
|
||||||
Action: []string{
|
|
||||||
"name/cos:PostObject",
|
|
||||||
"name/cos:PutObject",
|
|
||||||
},
|
|
||||||
Effect: "allow",
|
|
||||||
Resource: []string{
|
|
||||||
"qcs::cos:" + config.Config.Credential.Tencent.Region + ":uid/" + config.Config.Credential.Tencent.AppID + ":" + config.Config.Credential.Tencent.Bucket + "/*",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
res, err := cli.GetCredential(opt)
|
|
||||||
resp := api.TencentCloudStorageCredentialResp{}
|
|
||||||
if err != nil {
|
|
||||||
resp.ErrCode = constant.ErrTencentCredential.ErrCode
|
|
||||||
resp.ErrMsg = err.Error()
|
|
||||||
} else {
|
|
||||||
resp.CosData.Bucket = config.Config.Credential.Tencent.Bucket
|
|
||||||
resp.CosData.Region = config.Config.Credential.Tencent.Region
|
|
||||||
resp.CosData.CredentialResult = res
|
|
||||||
}
|
|
||||||
|
|
||||||
resp.Data = structs.Map(&resp.CosData)
|
|
||||||
log.NewInfo(req.OperationID, "TencentCloudStorageCredential return ", resp)
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
@ -19,58 +19,54 @@ type User struct {
|
|||||||
zk *openKeeper.ZkClient
|
zk *openKeeper.ZkClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) getGroupClient() (user.UserClient, error) {
|
func (o *User) client() (user.UserClient, error) {
|
||||||
conn, err := u.zk.GetConn(config.Config.RpcRegisterName.OpenImGroupName)
|
conn, err := o.zk.GetConn(config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return user.NewUserClient(conn), nil
|
return user.NewUserClient(conn), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) UserRegister(c *gin.Context) {
|
func (o *User) UpdateUserInfo(c *gin.Context) {
|
||||||
a2r.Call(user.UserClient.UserRegister, u.getGroupClient, c)
|
a2r.Call(user.UserClient.UpdateUserInfo, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) UpdateUserInfo(c *gin.Context) {
|
func (o *User) SetGlobalRecvMessageOpt(c *gin.Context) {
|
||||||
a2r.Call(user.UserClient.UpdateUserInfo, u.getGroupClient, c)
|
a2r.Call(user.UserClient.SetGlobalRecvMessageOpt, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) SetGlobalRecvMessageOpt(c *gin.Context) {
|
func (o *User) GetUsersPublicInfo(c *gin.Context) {
|
||||||
a2r.Call(user.UserClient.SetGlobalRecvMessageOpt, u.getGroupClient, c)
|
a2r.Call(user.UserClient.GetDesignateUsers, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) GetUsersPublicInfo(c *gin.Context) {
|
func (o *User) GetSelfUserInfo(c *gin.Context) {
|
||||||
a2r.Call(user.UserClient.GetDesignateUsers, u.getGroupClient, c)
|
a2r.Call(user.UserClient.GetSelfUserInfo, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) GetSelfUserInfo(c *gin.Context) {
|
func (o *User) GetUsersOnlineStatus(c *gin.Context) {
|
||||||
a2r.Call(user.UserClient.GetSelfUserInfo, u.getGroupClient, c)
|
a2r.Call(user.UserClient.GetUsersOnlineStatus, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) GetUsersOnlineStatus(c *gin.Context) {
|
func (o *User) GetUsersInfoFromCache(c *gin.Context) {
|
||||||
a2r.Call(user.UserClient.GetUsersOnlineStatus, u.getGroupClient, c)
|
a2r.Call(user.UserClient.GetUsersInfoFromCache, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) GetUsersInfoFromCache(c *gin.Context) {
|
func (o *User) GetFriendIDListFromCache(c *gin.Context) {
|
||||||
a2r.Call(user.UserClient.GetUsersInfoFromCache, u.getGroupClient, c)
|
a2r.Call(user.UserClient.GetFriendIDListFromCache, o.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) GetFriendIDListFromCache(c *gin.Context) {
|
func (o *User) GetBlackIDListFromCache(c *gin.Context) {
|
||||||
a2r.Call(user.UserClient.GetFriendIDListFromCache, u.getGroupClient, c)
|
a2r.Call(user.UserClient.GetBlackIDListFromCache, o.client, c)
|
||||||
}
|
|
||||||
|
|
||||||
func (u *User) GetBlackIDListFromCache(c *gin.Context) {
|
|
||||||
a2r.Call(user.UserClient.GetBlackIDListFromCache, u.getGroupClient, c)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (u *User) GetAllUsersUid(c *gin.Context) {
|
//func (u *User) GetAllUsersUid(c *gin.Context) {
|
||||||
// a2r.Call(user.UserClient.GetAllUsersUid, u.getGroupClient, c)
|
// a2r.Call(user.UserClient.GetAllUsersUid, u.client, c)
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func (u *User) AccountCheck(c *gin.Context) {
|
//func (u *User) AccountCheck(c *gin.Context) {
|
||||||
// a2r.Call(user.UserClient.AccountCheck, u.getGroupClient, c)
|
// a2r.Call(user.UserClient.AccountCheck, u.client, c)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func (u *User) GetUsers(c *gin.Context) {
|
func (o *User) GetUsers(c *gin.Context) {
|
||||||
a2r.Call(user.UserClient.GetPaginationUsers, u.getGroupClient, c)
|
a2r.Call(user.UserClient.GetPaginationUsers, o.client, c)
|
||||||
}
|
}
|
||||||
|
@ -1 +1,18 @@
|
|||||||
package third
|
package third
|
||||||
|
|
||||||
|
import (
|
||||||
|
"OpenIM/pkg/proto/third"
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (t *thirdServer) ApplyPut(ctx context.Context, req *third.ApplyPutReq) (*third.ApplyPutResp, error) {
|
||||||
|
return t.s3dataBase.ApplyPut(ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *thirdServer) GetPut(ctx context.Context, req *third.GetPutReq) (*third.GetPutResp, error) {
|
||||||
|
return t.s3dataBase.GetPut(ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *thirdServer) ConfirmPut(ctx context.Context, req *third.ConfirmPutReq) (*third.ConfirmPutResp, error) {
|
||||||
|
return t.s3dataBase.ConfirmPut(ctx, req)
|
||||||
|
}
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"OpenIM/internal/common/check"
|
"OpenIM/internal/common/check"
|
||||||
"OpenIM/pkg/common/db/cache"
|
"OpenIM/pkg/common/db/cache"
|
||||||
"OpenIM/pkg/common/db/controller"
|
"OpenIM/pkg/common/db/controller"
|
||||||
|
"OpenIM/pkg/common/db/obj"
|
||||||
"OpenIM/pkg/common/db/relation"
|
"OpenIM/pkg/common/db/relation"
|
||||||
"OpenIM/pkg/common/db/tx"
|
relationTb "OpenIM/pkg/common/db/table/relation"
|
||||||
"OpenIM/pkg/common/db/unrelation"
|
|
||||||
"OpenIM/pkg/proto/third"
|
"OpenIM/pkg/proto/third"
|
||||||
"context"
|
"context"
|
||||||
"github.com/OpenIMSDK/openKeeper"
|
"github.com/OpenIMSDK/openKeeper"
|
||||||
@ -18,20 +18,51 @@ func Start(client *openKeeper.ZkClient, server *grpc.Server) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
o, err := obj.NewMinioInterface()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
db, err := relation.NewGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := db.AutoMigrate(&relationTb.ObjectHashModel{}, &relationTb.ObjectInfoModel{}, &relationTb.ObjectPutModel{}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
third.RegisterThirdServer(server, &thirdServer{
|
third.RegisterThirdServer(server, &thirdServer{
|
||||||
thirdDatabase: controller.NewThirdDatabase(cache.NewCacheModel(rdb)),
|
thirdDatabase: controller.NewThirdDatabase(cache.NewCache(rdb)),
|
||||||
userCheck: check.NewUserCheck(client),
|
userCheck: check.NewUserCheck(client),
|
||||||
|
s3dataBase: controller.NewS3Database(o, relation.NewObjectHash(db), relation.NewObjectInfo(db), relation.NewObjectPut(db)),
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type thirdServer struct {
|
type thirdServer struct {
|
||||||
thirdDatabase controller.ThirdDatabase
|
thirdDatabase controller.ThirdDatabase
|
||||||
|
s3dataBase controller.S3Database
|
||||||
userCheck *check.UserCheck
|
userCheck *check.UserCheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *thirdServer) ApplySpace(ctx context.Context, req *third.ApplySpaceReq) (resp *third.ApplySpaceResp, err error) {
|
func (t *thirdServer) GetSignalInvitationInfo(ctx context.Context, req *third.GetSignalInvitationInfoReq) (resp *third.GetSignalInvitationInfoResp, err error) {
|
||||||
return
|
signalReq, err := t.thirdDatabase.GetSignalInvitationInfoByClientMsgID(ctx, req.ClientMsgID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp = &third.GetSignalInvitationInfoResp{}
|
||||||
|
resp.InvitationInfo = signalReq.Invitation
|
||||||
|
resp.OfflinePushInfo = signalReq.OfflinePushInfo
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *thirdServer) GetSignalInvitationInfoStartApp(ctx context.Context, req *third.GetSignalInvitationInfoStartAppReq) (resp *third.GetSignalInvitationInfoStartAppResp, err error) {
|
||||||
|
signalReq, err := t.thirdDatabase.GetAvailableSignalInvitationInfo(ctx, req.UserID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp = &third.GetSignalInvitationInfoStartAppResp{}
|
||||||
|
resp.InvitationInfo = signalReq.Invitation
|
||||||
|
resp.OfflinePushInfo = signalReq.OfflinePushInfo
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *thirdServer) FcmUpdateToken(ctx context.Context, req *third.FcmUpdateTokenReq) (resp *third.FcmUpdateTokenResp, err error) {
|
func (t *thirdServer) FcmUpdateToken(ctx context.Context, req *third.FcmUpdateTokenReq) (resp *third.FcmUpdateTokenResp, err error) {
|
||||||
|
@ -164,6 +164,7 @@ type config struct {
|
|||||||
OpenImConversationName string `yaml:"openImConversationName"`
|
OpenImConversationName string `yaml:"openImConversationName"`
|
||||||
OpenImCacheName string `yaml:"openImCacheName"`
|
OpenImCacheName string `yaml:"openImCacheName"`
|
||||||
OpenImRtcName string `yaml:"openImRtcName"`
|
OpenImRtcName string `yaml:"openImRtcName"`
|
||||||
|
OpenImThirdName string `yaml:"openImThirdName"`
|
||||||
}
|
}
|
||||||
Zookeeper struct {
|
Zookeeper struct {
|
||||||
Schema string `yaml:"schema"`
|
Schema string `yaml:"schema"`
|
||||||
|
353
pkg/common/db/controller/s3.go
Normal file
353
pkg/common/db/controller/s3.go
Normal file
@ -0,0 +1,353 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
"OpenIM/pkg/common/db/obj"
|
||||||
|
"OpenIM/pkg/common/db/table/relation"
|
||||||
|
"OpenIM/pkg/proto/third"
|
||||||
|
"OpenIM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"log"
|
||||||
|
"path"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type S3Database interface {
|
||||||
|
ApplyPut(ctx context.Context, req *third.ApplyPutReq) (*third.ApplyPutResp, error)
|
||||||
|
GetPut(ctx context.Context, req *third.GetPutReq) (*third.GetPutResp, error)
|
||||||
|
ConfirmPut(ctx context.Context, req *third.ConfirmPutReq) (*third.ConfirmPutResp, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewS3Database(obj obj.Interface, hash relation.ObjectHashModelInterface, info relation.ObjectInfoModelInterface, put relation.ObjectPutModelInterface) S3Database {
|
||||||
|
return &s3Database{
|
||||||
|
obj: obj,
|
||||||
|
hash: hash,
|
||||||
|
info: info,
|
||||||
|
put: put,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type s3Database struct {
|
||||||
|
obj obj.Interface
|
||||||
|
hash relation.ObjectHashModelInterface
|
||||||
|
info relation.ObjectInfoModelInterface
|
||||||
|
put relation.ObjectPutModelInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
// today 今天的日期
|
||||||
|
func (c *s3Database) today() string {
|
||||||
|
return time.Now().Format("20060102")
|
||||||
|
}
|
||||||
|
|
||||||
|
// fragmentName 根据序号生成文件名
|
||||||
|
func (c *s3Database) fragmentName(index int) string {
|
||||||
|
return "fragment_" + strconv.Itoa(index+1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// getFragmentNum 获取分片大小和分片数量
|
||||||
|
func (c *s3Database) getFragmentNum(fragmentSize int64, objectSize int64) (int64, int) {
|
||||||
|
if size := c.obj.MinFragmentSize(); fragmentSize < size {
|
||||||
|
fragmentSize = size
|
||||||
|
}
|
||||||
|
if fragmentSize <= 0 || objectSize <= fragmentSize {
|
||||||
|
return objectSize, 1
|
||||||
|
} else {
|
||||||
|
num := int(objectSize / fragmentSize)
|
||||||
|
if objectSize%fragmentSize > 0 {
|
||||||
|
num++
|
||||||
|
}
|
||||||
|
if n := c.obj.MaxFragmentNum(); num > n {
|
||||||
|
num = n
|
||||||
|
}
|
||||||
|
return fragmentSize, num
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *s3Database) CheckHash(hash string) error {
|
||||||
|
val, err := hex.DecodeString(hash)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(val) != md5.Size {
|
||||||
|
return errors.New("hash value error")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *s3Database) urlName(name string) string {
|
||||||
|
if name[0] != '/' {
|
||||||
|
name = "/" + name
|
||||||
|
}
|
||||||
|
return "http://127.0.0.1:8080" + name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *s3Database) UUID() string {
|
||||||
|
return uuid.New().String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *s3Database) HashName(hash string) string {
|
||||||
|
return path.Join("hash", hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *s3Database) isNotFound(err error) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *s3Database) ApplyPut(ctx context.Context, req *third.ApplyPutReq) (*third.ApplyPutResp, error) {
|
||||||
|
if err := c.CheckHash(req.Hash); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := c.obj.CheckName(req.Name); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if req.CleanTime != 0 && req.CleanTime <= time.Now().UnixMilli() {
|
||||||
|
return nil, errors.New("invalid CleanTime")
|
||||||
|
}
|
||||||
|
var expirationTime *time.Time
|
||||||
|
if req.CleanTime != 0 {
|
||||||
|
expirationTime = utils.ToPtr(time.UnixMilli(req.CleanTime))
|
||||||
|
}
|
||||||
|
if hash, err := c.hash.Take(ctx, req.Hash, c.obj.Name()); err == nil {
|
||||||
|
o := relation.ObjectInfoModel{
|
||||||
|
Name: req.Name,
|
||||||
|
Hash: hash.Hash,
|
||||||
|
ExpirationTime: expirationTime,
|
||||||
|
CreateTime: time.Now(),
|
||||||
|
}
|
||||||
|
if err := c.info.SetObject(ctx, &o); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &third.ApplyPutResp{Url: c.urlName(o.Name)}, nil // 服务器已存在
|
||||||
|
} else if !c.isNotFound(err) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// 新上传
|
||||||
|
var pack int
|
||||||
|
const effective = time.Hour * 24 * 2
|
||||||
|
req.FragmentSize, pack = c.getFragmentNum(req.FragmentSize, req.Size)
|
||||||
|
put := relation.ObjectPutModel{
|
||||||
|
PutID: c.UUID(),
|
||||||
|
Hash: req.Hash,
|
||||||
|
Name: req.Name,
|
||||||
|
ObjectSize: req.Size,
|
||||||
|
FragmentSize: req.FragmentSize,
|
||||||
|
ExpirationTime: expirationTime,
|
||||||
|
EffectiveTime: time.Now().Add(effective),
|
||||||
|
}
|
||||||
|
put.Path = path.Join("upload", c.today(), req.Hash, put.PutID)
|
||||||
|
putURLs := make([]string, 0, pack)
|
||||||
|
for i := 0; i < pack; i++ {
|
||||||
|
url, err := c.obj.PresignedPutURL(ctx, &obj.ApplyPutArgs{
|
||||||
|
Bucket: c.obj.TempBucket(),
|
||||||
|
Name: path.Join(put.Path, c.fragmentName(i)),
|
||||||
|
Effective: effective,
|
||||||
|
MaxObjectSize: req.FragmentSize,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
putURLs = append(putURLs, url)
|
||||||
|
}
|
||||||
|
put.CreateTime = time.Now()
|
||||||
|
if err := c.put.Create(ctx, []*relation.ObjectPutModel{&put}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &third.ApplyPutResp{
|
||||||
|
PutID: put.PutID,
|
||||||
|
FragmentSize: put.FragmentSize,
|
||||||
|
PutURLs: putURLs,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *s3Database) GetPut(ctx context.Context, req *third.GetPutReq) (*third.GetPutResp, error) {
|
||||||
|
up, err := c.put.Take(ctx, req.PutID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if up.Complete {
|
||||||
|
return nil, errors.New("up completed")
|
||||||
|
}
|
||||||
|
_, pack := c.getFragmentNum(up.FragmentSize, up.ObjectSize)
|
||||||
|
fragments := make([]*third.GetPutFragment, pack)
|
||||||
|
for i := 0; i < pack; i++ {
|
||||||
|
name := path.Join(up.Path, c.fragmentName(i))
|
||||||
|
o, err := c.obj.GetObjectInfo(ctx, &obj.BucketObject{
|
||||||
|
Bucket: c.obj.TempBucket(),
|
||||||
|
Name: name,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
if c.obj.IsNotFound(err) {
|
||||||
|
fragments[i] = &third.GetPutFragment{}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
fragments[i] = &third.GetPutFragment{Size: o.Size, Hash: o.Hash}
|
||||||
|
}
|
||||||
|
var cleanTime int64
|
||||||
|
if up.ExpirationTime != nil {
|
||||||
|
cleanTime = up.ExpirationTime.UnixMilli()
|
||||||
|
}
|
||||||
|
return &third.GetPutResp{
|
||||||
|
FragmentSize: up.FragmentSize,
|
||||||
|
Size: up.ObjectSize,
|
||||||
|
Name: up.Name,
|
||||||
|
Hash: up.Hash,
|
||||||
|
Fragments: fragments,
|
||||||
|
CleanTime: cleanTime,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *s3Database) ConfirmPut(ctx context.Context, req *third.ConfirmPutReq) (_ *third.ConfirmPutResp, _err error) {
|
||||||
|
up, err := c.put.Take(ctx, req.PutID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_, pack := c.getFragmentNum(up.FragmentSize, up.ObjectSize)
|
||||||
|
defer func() {
|
||||||
|
if _err == nil {
|
||||||
|
// 清理上传的碎片
|
||||||
|
for i := 0; i < pack; i++ {
|
||||||
|
name := path.Join(up.Path, c.fragmentName(i))
|
||||||
|
err := c.obj.DeleteObjet(ctx, &obj.BucketObject{
|
||||||
|
Bucket: c.obj.TempBucket(),
|
||||||
|
Name: name,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("delete fragment %d %s %s failed %s\n", i, c.obj.TempBucket(), name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if up.Complete {
|
||||||
|
return nil, errors.New("put completed")
|
||||||
|
}
|
||||||
|
now := time.Now().UnixMilli()
|
||||||
|
if up.EffectiveTime.UnixMilli() < now {
|
||||||
|
return nil, errors.New("upload expired")
|
||||||
|
}
|
||||||
|
if up.ExpirationTime != nil && up.ExpirationTime.UnixMilli() < now {
|
||||||
|
return nil, errors.New("object expired")
|
||||||
|
}
|
||||||
|
if hash, err := c.hash.Take(ctx, up.Hash, c.obj.Name()); err == nil {
|
||||||
|
o := relation.ObjectInfoModel{
|
||||||
|
Name: up.Name,
|
||||||
|
Hash: hash.Hash,
|
||||||
|
ExpirationTime: up.ExpirationTime,
|
||||||
|
CreateTime: time.Now(),
|
||||||
|
}
|
||||||
|
if err := c.info.SetObject(ctx, &o); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// 服务端已存在
|
||||||
|
return &third.ConfirmPutResp{
|
||||||
|
Url: c.urlName(o.Name),
|
||||||
|
}, nil
|
||||||
|
} else if c.isNotFound(err) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
src := make([]obj.BucketObject, pack)
|
||||||
|
for i := 0; i < pack; i++ {
|
||||||
|
name := path.Join(up.Path, c.fragmentName(i))
|
||||||
|
o, err := c.obj.GetObjectInfo(ctx, &obj.BucketObject{
|
||||||
|
Bucket: c.obj.TempBucket(),
|
||||||
|
Name: name,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if i+1 == pack { // 最后一个
|
||||||
|
size := up.ObjectSize - up.FragmentSize*int64(i)
|
||||||
|
if size != o.Size {
|
||||||
|
return nil, fmt.Errorf("last fragment %d size %d not equal to %d hash %s", i, o.Size, size, o.Hash)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if o.Size != up.FragmentSize {
|
||||||
|
return nil, fmt.Errorf("fragment %d size %d not equal to %d hash %s", i, o.Size, up.FragmentSize, o.Hash)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
src[i] = obj.BucketObject{
|
||||||
|
Bucket: c.obj.TempBucket(),
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dst := &obj.BucketObject{
|
||||||
|
Bucket: c.obj.DataBucket(),
|
||||||
|
Name: c.HashName(up.Hash),
|
||||||
|
}
|
||||||
|
if len(src) == 1 { // 未分片直接触发copy
|
||||||
|
// 检查数据完整性,避免脏数据
|
||||||
|
o, err := c.obj.GetObjectInfo(ctx, &src[0])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if up.ObjectSize != o.Size {
|
||||||
|
return nil, fmt.Errorf("size mismatching should %d reality %d", up.ObjectSize, o.Size)
|
||||||
|
}
|
||||||
|
if up.Hash != o.Hash {
|
||||||
|
return nil, fmt.Errorf("hash mismatching should %s reality %s", up.Hash, o.Hash)
|
||||||
|
}
|
||||||
|
if err := c.obj.CopyObjet(ctx, &src[0], dst); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tempBucket := &obj.BucketObject{
|
||||||
|
Bucket: c.obj.TempBucket(),
|
||||||
|
Name: path.Join("merge", c.today(), req.PutID, c.UUID()),
|
||||||
|
}
|
||||||
|
defer func() { // 清理合成的文件
|
||||||
|
if err := c.obj.DeleteObjet(ctx, tempBucket); err != nil {
|
||||||
|
log.Printf("delete %s %s %s failed %s\n", c.obj.Name(), tempBucket.Bucket, tempBucket.Name, err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
err := c.obj.ComposeObject(ctx, src, tempBucket)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
info, err := c.obj.GetObjectInfo(ctx, tempBucket)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if up.ObjectSize != info.Size {
|
||||||
|
return nil, fmt.Errorf("size mismatch should %d reality %d", up.ObjectSize, info.Size)
|
||||||
|
}
|
||||||
|
if up.Hash != info.Hash {
|
||||||
|
return nil, fmt.Errorf("hash mismatch should %s reality %s", up.Hash, info.Hash)
|
||||||
|
}
|
||||||
|
if err := c.obj.CopyObjet(ctx, tempBucket, dst); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
o := &relation.ObjectInfoModel{
|
||||||
|
Name: up.Name,
|
||||||
|
Hash: up.Hash,
|
||||||
|
ExpirationTime: up.ExpirationTime,
|
||||||
|
CreateTime: time.Now(),
|
||||||
|
}
|
||||||
|
h := &relation.ObjectHashModel{
|
||||||
|
Hash: up.Hash,
|
||||||
|
Size: up.ObjectSize,
|
||||||
|
Engine: c.obj.Name(),
|
||||||
|
Bucket: c.obj.DataBucket(),
|
||||||
|
Name: c.HashName(up.Hash),
|
||||||
|
CreateTime: time.Now(),
|
||||||
|
}
|
||||||
|
if err := c.hash.Create(ctx, []*relation.ObjectHashModel{h}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := c.info.SetObject(ctx, o); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := c.put.SetCompleted(ctx, up.PutID); err != nil {
|
||||||
|
log.Printf("set uploaded %s failed %s\n", up.PutID, err)
|
||||||
|
}
|
||||||
|
return &third.ConfirmPutResp{
|
||||||
|
Url: c.urlName(o.Name),
|
||||||
|
}, nil
|
||||||
|
}
|
183
pkg/common/db/obj/minio.go
Normal file
183
pkg/common/db/obj/minio.go
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
package obj
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/minio/minio-go/v7"
|
||||||
|
"github.com/minio/minio-go/v7/pkg/s3utils"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewMinioClient() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMinioInterface() (Interface, error) {
|
||||||
|
//client, err := minio.New("127.0.0.1:9000", &minio.Options{
|
||||||
|
// Creds: credentials.NewStaticV4("minioadmin", "minioadmin", ""),
|
||||||
|
// Secure: false,
|
||||||
|
//})
|
||||||
|
|
||||||
|
return &minioImpl{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type minioImpl struct {
|
||||||
|
tempBucket string // 上传桶
|
||||||
|
permanentBucket string // 永久桶
|
||||||
|
clearBucket string // 自动清理桶
|
||||||
|
urlstr string // 访问地址
|
||||||
|
client *minio.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
//func (m *minioImpl) Init() error {
|
||||||
|
// client, err := minio.New("127.0.0.1:9000", &minio.Options{
|
||||||
|
// Creds: credentials.NewStaticV4("minioadmin", "minioadmin", ""),
|
||||||
|
// Secure: false,
|
||||||
|
// })
|
||||||
|
// if err != nil {
|
||||||
|
// return fmt.Errorf("minio client error: %w", err)
|
||||||
|
// }
|
||||||
|
// m.urlstr = "http://127.0.0.1:9000"
|
||||||
|
// m.client = client
|
||||||
|
// m.tempBucket = "temp"
|
||||||
|
// m.permanentBucket = "permanent"
|
||||||
|
// m.clearBucket = "clear"
|
||||||
|
// return nil
|
||||||
|
//}
|
||||||
|
|
||||||
|
func (m *minioImpl) Name() string {
|
||||||
|
return "minio"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) MinFragmentSize() int64 {
|
||||||
|
return 1024 * 1024 * 5 // 每个分片最小大小 minio.absMinPartSize
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) MaxFragmentNum() int {
|
||||||
|
return 1000 // 最大分片数量 minio.maxPartsCount
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) MinExpirationTime() time.Duration {
|
||||||
|
return time.Hour * 24
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) AppendHeader() http.Header {
|
||||||
|
return map[string][]string{
|
||||||
|
"x-amz-object-append": {"true"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) TempBucket() string {
|
||||||
|
return m.tempBucket
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) DataBucket() string {
|
||||||
|
return m.permanentBucket
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) ClearBucket() string {
|
||||||
|
return m.clearBucket
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) GetURL(bucket string, name string) string {
|
||||||
|
return fmt.Sprintf("%s/%s/%s", m.urlstr, bucket, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) PresignedPutURL(ctx context.Context, args *ApplyPutArgs) (string, error) {
|
||||||
|
if args.Effective <= 0 {
|
||||||
|
return "", errors.New("EffectiveTime <= 0")
|
||||||
|
}
|
||||||
|
_, err := m.GetObjectInfo(ctx, &BucketObject{
|
||||||
|
Bucket: m.tempBucket,
|
||||||
|
Name: args.Name,
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
return "", fmt.Errorf("minio bucket %s name %s already exists", args.Bucket, args.Name)
|
||||||
|
} else if !m.IsNotFound(err) {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
u, err := m.client.PresignedPutObject(ctx, m.tempBucket, args.Name, args.Effective)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("minio apply error: %w", err)
|
||||||
|
}
|
||||||
|
return u.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) GetObjectInfo(ctx context.Context, args *BucketObject) (*ObjectInfo, error) {
|
||||||
|
info, err := m.client.StatObject(ctx, args.Bucket, args.Name, minio.StatObjectOptions{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ObjectInfo{
|
||||||
|
URL: m.GetURL(args.Bucket, args.Name),
|
||||||
|
Size: info.Size,
|
||||||
|
Hash: info.ETag,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) CopyObjet(ctx context.Context, src *BucketObject, dst *BucketObject) error {
|
||||||
|
_, err := m.client.CopyObject(ctx, minio.CopyDestOptions{
|
||||||
|
Bucket: dst.Bucket,
|
||||||
|
Object: dst.Name,
|
||||||
|
}, minio.CopySrcOptions{
|
||||||
|
Bucket: src.Bucket,
|
||||||
|
Object: src.Name,
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) DeleteObjet(ctx context.Context, info *BucketObject) error {
|
||||||
|
return m.client.RemoveObject(ctx, info.Bucket, info.Name, minio.RemoveObjectOptions{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) MoveObjetInfo(ctx context.Context, src *BucketObject, dst *BucketObject) error {
|
||||||
|
if err := m.CopyObjet(ctx, src, dst); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return m.DeleteObjet(ctx, src)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) ComposeObject(ctx context.Context, src []BucketObject, dst *BucketObject) error {
|
||||||
|
destOptions := minio.CopyDestOptions{
|
||||||
|
Bucket: dst.Bucket,
|
||||||
|
Object: dst.Name + ".temp",
|
||||||
|
}
|
||||||
|
sources := make([]minio.CopySrcOptions, len(src))
|
||||||
|
for i, s := range src {
|
||||||
|
sources[i] = minio.CopySrcOptions{
|
||||||
|
Bucket: s.Bucket,
|
||||||
|
Object: s.Name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := m.client.ComposeObject(ctx, destOptions, sources...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return m.MoveObjetInfo(ctx, &BucketObject{
|
||||||
|
Bucket: destOptions.Bucket,
|
||||||
|
Name: destOptions.Object,
|
||||||
|
}, &BucketObject{
|
||||||
|
Bucket: dst.Bucket,
|
||||||
|
Name: dst.Name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) IsNotFound(err error) bool {
|
||||||
|
if err == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
switch e := err.(type) {
|
||||||
|
case minio.ErrorResponse:
|
||||||
|
return e.StatusCode == 404 && e.Code == "NoSuchKey"
|
||||||
|
case *minio.ErrorResponse:
|
||||||
|
return e.StatusCode == 404 && e.Code == "NoSuchKey"
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *minioImpl) CheckName(name string) error {
|
||||||
|
return s3utils.CheckValidObjectName(name)
|
||||||
|
}
|
58
pkg/common/db/obj/obj.go
Normal file
58
pkg/common/db/obj/obj.go
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package obj
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BucketObject struct {
|
||||||
|
Bucket string `json:"bucket"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ApplyPutArgs struct {
|
||||||
|
Bucket string
|
||||||
|
Name string
|
||||||
|
Effective time.Duration // 申请有效时间
|
||||||
|
Header http.Header // header
|
||||||
|
MaxObjectSize int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type ObjectInfo struct {
|
||||||
|
URL string
|
||||||
|
Size int64
|
||||||
|
Hash string
|
||||||
|
Expiration time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type Interface interface {
|
||||||
|
// Name 存储名字
|
||||||
|
Name() string
|
||||||
|
// MinFragmentSize 最小允许的分片大小
|
||||||
|
MinFragmentSize() int64
|
||||||
|
// MaxFragmentNum 最大允许的分片数量
|
||||||
|
MaxFragmentNum() int
|
||||||
|
// MinExpirationTime 最小过期时间
|
||||||
|
MinExpirationTime() time.Duration
|
||||||
|
// TempBucket 临时桶名,用于上传
|
||||||
|
TempBucket() string
|
||||||
|
// DataBucket 永久存储的桶名
|
||||||
|
DataBucket() string
|
||||||
|
// GetURL 通过桶名和对象名返回URL
|
||||||
|
GetURL(bucket string, name string) string
|
||||||
|
// PresignedPutURL 申请上传,返回PUT的上传地址
|
||||||
|
PresignedPutURL(ctx context.Context, args *ApplyPutArgs) (string, error)
|
||||||
|
// GetObjectInfo 获取对象信息
|
||||||
|
GetObjectInfo(ctx context.Context, args *BucketObject) (*ObjectInfo, error)
|
||||||
|
// CopyObjet 复制对象
|
||||||
|
CopyObjet(ctx context.Context, src *BucketObject, dst *BucketObject) error
|
||||||
|
// DeleteObjet 删除对象
|
||||||
|
DeleteObjet(ctx context.Context, info *BucketObject) error
|
||||||
|
// ComposeObject 合并对象
|
||||||
|
ComposeObject(ctx context.Context, src []BucketObject, dst *BucketObject) error
|
||||||
|
// IsNotFound 判断是不是不存在导致的错误
|
||||||
|
IsNotFound(err error) bool
|
||||||
|
// CheckName 检查名字是否可用
|
||||||
|
CheckName(name string) error
|
||||||
|
}
|
40
pkg/common/db/relation/object_hash_model.go
Normal file
40
pkg/common/db/relation/object_hash_model.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package relation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"OpenIM/pkg/common/db/table/relation"
|
||||||
|
"OpenIM/pkg/common/tracelog"
|
||||||
|
"OpenIM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewObjectHash(db *gorm.DB) relation.ObjectHashModelInterface {
|
||||||
|
return &ObjectHashGorm{
|
||||||
|
DB: db,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ObjectHashGorm struct {
|
||||||
|
DB *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ObjectHashGorm) NewTx(tx any) relation.ObjectHashModelInterface {
|
||||||
|
return &ObjectHashGorm{
|
||||||
|
DB: tx.(*gorm.DB),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ObjectHashGorm) Take(ctx context.Context, hash string, engine string) (oh *relation.ObjectHashModel, err error) {
|
||||||
|
defer func() {
|
||||||
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "hash", hash, "engine", engine, "objectHash", oh)
|
||||||
|
}()
|
||||||
|
oh = &relation.ObjectHashModel{}
|
||||||
|
return oh, utils.Wrap1(o.DB.Where("hash = ? and engine = ?", hash, engine).Take(oh).Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ObjectHashGorm) Create(ctx context.Context, h []*relation.ObjectHashModel) (err error) {
|
||||||
|
defer func() {
|
||||||
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "objectHash", h)
|
||||||
|
}()
|
||||||
|
return utils.Wrap1(o.DB.Create(h).Error)
|
||||||
|
}
|
45
pkg/common/db/relation/object_info_model.go
Normal file
45
pkg/common/db/relation/object_info_model.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package relation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"OpenIM/pkg/common/db/table/relation"
|
||||||
|
"OpenIM/pkg/common/tracelog"
|
||||||
|
"OpenIM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewObjectInfo(db *gorm.DB) relation.ObjectInfoModelInterface {
|
||||||
|
return &ObjectInfoGorm{
|
||||||
|
DB: db,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ObjectInfoGorm struct {
|
||||||
|
DB *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ObjectInfoGorm) NewTx(tx any) relation.ObjectInfoModelInterface {
|
||||||
|
return &ObjectInfoGorm{
|
||||||
|
DB: tx.(*gorm.DB),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ObjectInfoGorm) SetObject(ctx context.Context, obj *relation.ObjectInfoModel) (err error) {
|
||||||
|
defer func() {
|
||||||
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "objectInfo", obj)
|
||||||
|
}()
|
||||||
|
return utils.Wrap1(o.DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
if err := tx.Where("name = ?", obj.Name).Delete(&relation.ObjectInfoModel{}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tx.Create(obj).Error
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ObjectInfoGorm) Take(ctx context.Context, name string) (info *relation.ObjectInfoModel, err error) {
|
||||||
|
defer func() {
|
||||||
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "name", name, "info", info)
|
||||||
|
}()
|
||||||
|
info = &relation.ObjectInfoModel{}
|
||||||
|
return info, utils.Wrap1(o.DB.Where("name = ?", name).Take(info).Error)
|
||||||
|
}
|
47
pkg/common/db/relation/object_put_model.go
Normal file
47
pkg/common/db/relation/object_put_model.go
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package relation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"OpenIM/pkg/common/db/table/relation"
|
||||||
|
"OpenIM/pkg/common/tracelog"
|
||||||
|
"OpenIM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewObjectPut(db *gorm.DB) relation.ObjectPutModelInterface {
|
||||||
|
return &ObjectPutGorm{
|
||||||
|
DB: db,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ObjectPutGorm struct {
|
||||||
|
DB *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ObjectPutGorm) NewTx(tx any) relation.ObjectPutModelInterface {
|
||||||
|
return &ObjectPutGorm{
|
||||||
|
DB: tx.(*gorm.DB),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ObjectPutGorm) Create(ctx context.Context, m []*relation.ObjectPutModel) (err error) {
|
||||||
|
defer func() {
|
||||||
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "objectPut", m)
|
||||||
|
}()
|
||||||
|
return utils.Wrap1(o.DB.Create(m).Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ObjectPutGorm) Take(ctx context.Context, putID string) (put *relation.ObjectPutModel, err error) {
|
||||||
|
defer func() {
|
||||||
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "putID", putID, "put", put)
|
||||||
|
}()
|
||||||
|
put = &relation.ObjectPutModel{}
|
||||||
|
return put, utils.Wrap1(o.DB.Where("put_id = ?", putID).Take(put).Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ObjectPutGorm) SetCompleted(ctx context.Context, putID string) (err error) {
|
||||||
|
defer func() {
|
||||||
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "putID", putID)
|
||||||
|
}()
|
||||||
|
return utils.Wrap1(o.DB.Model(&relation.ObjectPutModel{}).Where("put_id = ?", putID).Update("complete", true).Error)
|
||||||
|
}
|
29
pkg/common/db/table/relation/object_hash.go
Normal file
29
pkg/common/db/table/relation/object_hash.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package relation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ObjectHashModelTableName = "object_hash"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ObjectHashModel struct {
|
||||||
|
Hash string `gorm:"column:hash;primary_key;size:32"`
|
||||||
|
Engine string `gorm:"column:engine;primary_key;size:16"`
|
||||||
|
Size int64 `gorm:"column:size"`
|
||||||
|
Bucket string `gorm:"column:bucket"`
|
||||||
|
Name string `gorm:"column:name"`
|
||||||
|
CreateTime time.Time `gorm:"column:create_time"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ObjectHashModel) TableName() string {
|
||||||
|
return ObjectHashModelTableName
|
||||||
|
}
|
||||||
|
|
||||||
|
type ObjectHashModelInterface interface {
|
||||||
|
NewTx(tx any) ObjectHashModelInterface
|
||||||
|
Take(ctx context.Context, hash string, engine string) (*ObjectHashModel, error)
|
||||||
|
Create(ctx context.Context, h []*ObjectHashModel) error
|
||||||
|
}
|
27
pkg/common/db/table/relation/object_info.go
Normal file
27
pkg/common/db/table/relation/object_info.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package relation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ObjectInfoModelTableName = "object_info"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ObjectInfoModel struct {
|
||||||
|
Name string `gorm:"column:name;primary_key"`
|
||||||
|
Hash string `gorm:"column:hash"`
|
||||||
|
ExpirationTime *time.Time `gorm:"column:expiration_time"`
|
||||||
|
CreateTime time.Time `gorm:"column:create_time"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ObjectInfoModel) TableName() string {
|
||||||
|
return ObjectInfoModelTableName
|
||||||
|
}
|
||||||
|
|
||||||
|
type ObjectInfoModelInterface interface {
|
||||||
|
NewTx(tx any) ObjectInfoModelInterface
|
||||||
|
SetObject(ctx context.Context, obj *ObjectInfoModel) error
|
||||||
|
Take(ctx context.Context, name string) (*ObjectInfoModel, error)
|
||||||
|
}
|
34
pkg/common/db/table/relation/object_put.go
Normal file
34
pkg/common/db/table/relation/object_put.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package relation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ObjectPutModelTableName = "object_put"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ObjectPutModel struct {
|
||||||
|
PutID string `gorm:"column:put_id;primary_key"`
|
||||||
|
Hash string `gorm:"column:hash"`
|
||||||
|
Path string `gorm:"column:path"`
|
||||||
|
Name string `gorm:"column:name"`
|
||||||
|
ObjectSize int64 `gorm:"column:object_size"`
|
||||||
|
FragmentSize int64 `gorm:"column:fragment_size"`
|
||||||
|
Complete bool `gorm:"column:complete"`
|
||||||
|
ExpirationTime *time.Time `gorm:"column:expiration_time"`
|
||||||
|
EffectiveTime time.Time `gorm:"column:effective_time"`
|
||||||
|
CreateTime time.Time `gorm:"column:create_time"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ObjectPutModel) TableName() string {
|
||||||
|
return ObjectPutModelTableName
|
||||||
|
}
|
||||||
|
|
||||||
|
type ObjectPutModelInterface interface {
|
||||||
|
NewTx(tx any) ObjectPutModelInterface
|
||||||
|
Create(ctx context.Context, m []*ObjectPutModel) error
|
||||||
|
Take(ctx context.Context, putID string) (*ObjectPutModel, error)
|
||||||
|
SetCompleted(ctx context.Context, putID string) error
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
import "Open-IM-Server/pkg/proto/sdkws/ws.proto";
|
import "sdkws/ws.proto";
|
||||||
import "Open-IM-Server/pkg/proto/sdkws/wrappers.proto";
|
import "sdkws/wrappers.proto";
|
||||||
option go_package = "OpenIM/pkg/proto/group;group";
|
option go_package = "OpenIM/pkg/proto/group;group";
|
||||||
package group;
|
package group;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
import "Open-IM-Server/pkg/proto/sdkws/wrappers.proto";
|
import "sdkws/wrappers.proto";
|
||||||
option go_package = "OpenIM/pkg/proto/sdkws;sdkws";
|
option go_package = "OpenIM/pkg/proto/sdkws;sdkws";
|
||||||
package sdkws;
|
package sdkws;
|
||||||
|
|
||||||
|
@ -24,214 +24,384 @@ var _ = math.Inf
|
|||||||
// proto package needs to be updated.
|
// proto package needs to be updated.
|
||||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type ApplySpaceReq struct {
|
type ApplyPutReq struct {
|
||||||
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
|
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
|
||||||
Size int64 `protobuf:"varint,2,opt,name=size" json:"size,omitempty"`
|
Size int64 `protobuf:"varint,2,opt,name=size" json:"size,omitempty"`
|
||||||
Hash string `protobuf:"bytes,3,opt,name=hash" json:"hash,omitempty"`
|
Hash string `protobuf:"bytes,3,opt,name=hash" json:"hash,omitempty"`
|
||||||
Purpose uint32 `protobuf:"varint,4,opt,name=purpose" json:"purpose,omitempty"`
|
FragmentSize int64 `protobuf:"varint,4,opt,name=fragmentSize" json:"fragmentSize,omitempty"`
|
||||||
ContentType string `protobuf:"bytes,5,opt,name=contentType" json:"contentType,omitempty"`
|
CleanTime int64 `protobuf:"varint,5,opt,name=cleanTime" json:"cleanTime,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
XXX_sizecache int32 `json:"-"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ApplySpaceReq) Reset() { *m = ApplySpaceReq{} }
|
func (m *ApplyPutReq) Reset() { *m = ApplyPutReq{} }
|
||||||
func (m *ApplySpaceReq) String() string { return proto.CompactTextString(m) }
|
func (m *ApplyPutReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*ApplySpaceReq) ProtoMessage() {}
|
func (*ApplyPutReq) ProtoMessage() {}
|
||||||
func (*ApplySpaceReq) Descriptor() ([]byte, []int) {
|
func (*ApplyPutReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{0}
|
return fileDescriptor_third_1a03a4b056d14713, []int{0}
|
||||||
}
|
}
|
||||||
func (m *ApplySpaceReq) XXX_Unmarshal(b []byte) error {
|
func (m *ApplyPutReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_ApplySpaceReq.Unmarshal(m, b)
|
return xxx_messageInfo_ApplyPutReq.Unmarshal(m, b)
|
||||||
}
|
}
|
||||||
func (m *ApplySpaceReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
func (m *ApplyPutReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
return xxx_messageInfo_ApplySpaceReq.Marshal(b, m, deterministic)
|
return xxx_messageInfo_ApplyPutReq.Marshal(b, m, deterministic)
|
||||||
}
|
}
|
||||||
func (dst *ApplySpaceReq) XXX_Merge(src proto.Message) {
|
func (dst *ApplyPutReq) XXX_Merge(src proto.Message) {
|
||||||
xxx_messageInfo_ApplySpaceReq.Merge(dst, src)
|
xxx_messageInfo_ApplyPutReq.Merge(dst, src)
|
||||||
}
|
}
|
||||||
func (m *ApplySpaceReq) XXX_Size() int {
|
func (m *ApplyPutReq) XXX_Size() int {
|
||||||
return xxx_messageInfo_ApplySpaceReq.Size(m)
|
return xxx_messageInfo_ApplyPutReq.Size(m)
|
||||||
}
|
}
|
||||||
func (m *ApplySpaceReq) XXX_DiscardUnknown() {
|
func (m *ApplyPutReq) XXX_DiscardUnknown() {
|
||||||
xxx_messageInfo_ApplySpaceReq.DiscardUnknown(m)
|
xxx_messageInfo_ApplyPutReq.DiscardUnknown(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
var xxx_messageInfo_ApplySpaceReq proto.InternalMessageInfo
|
var xxx_messageInfo_ApplyPutReq proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *ApplySpaceReq) GetName() string {
|
func (m *ApplyPutReq) GetName() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Name
|
return m.Name
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ApplySpaceReq) GetSize() int64 {
|
func (m *ApplyPutReq) GetSize() int64 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Size
|
return m.Size
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ApplySpaceReq) GetHash() string {
|
func (m *ApplyPutReq) GetHash() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Hash
|
return m.Hash
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ApplySpaceReq) GetPurpose() uint32 {
|
func (m *ApplyPutReq) GetFragmentSize() int64 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Purpose
|
return m.FragmentSize
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ApplySpaceReq) GetContentType() string {
|
func (m *ApplyPutReq) GetCleanTime() int64 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.ContentType
|
return m.CleanTime
|
||||||
}
|
}
|
||||||
return ""
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApplySpaceResp struct {
|
type ApplyPutResp struct {
|
||||||
Url string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"`
|
Url string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"`
|
||||||
Size int64 `protobuf:"varint,2,opt,name=size" json:"size,omitempty"`
|
PutID string `protobuf:"bytes,2,opt,name=putID" json:"putID,omitempty"`
|
||||||
Put []string `protobuf:"bytes,3,rep,name=put" json:"put,omitempty"`
|
FragmentSize int64 `protobuf:"varint,3,opt,name=fragmentSize" json:"fragmentSize,omitempty"`
|
||||||
ConfirmID string `protobuf:"bytes,4,opt,name=confirmID" json:"confirmID,omitempty"`
|
ExpirationTime int64 `protobuf:"varint,4,opt,name=expirationTime" json:"expirationTime,omitempty"`
|
||||||
|
PutURLs []string `protobuf:"bytes,5,rep,name=PutURLs" json:"PutURLs,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
XXX_sizecache int32 `json:"-"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ApplySpaceResp) Reset() { *m = ApplySpaceResp{} }
|
func (m *ApplyPutResp) Reset() { *m = ApplyPutResp{} }
|
||||||
func (m *ApplySpaceResp) String() string { return proto.CompactTextString(m) }
|
func (m *ApplyPutResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*ApplySpaceResp) ProtoMessage() {}
|
func (*ApplyPutResp) ProtoMessage() {}
|
||||||
func (*ApplySpaceResp) Descriptor() ([]byte, []int) {
|
func (*ApplyPutResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{1}
|
return fileDescriptor_third_1a03a4b056d14713, []int{1}
|
||||||
}
|
}
|
||||||
func (m *ApplySpaceResp) XXX_Unmarshal(b []byte) error {
|
func (m *ApplyPutResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_ApplySpaceResp.Unmarshal(m, b)
|
return xxx_messageInfo_ApplyPutResp.Unmarshal(m, b)
|
||||||
}
|
}
|
||||||
func (m *ApplySpaceResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
func (m *ApplyPutResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
return xxx_messageInfo_ApplySpaceResp.Marshal(b, m, deterministic)
|
return xxx_messageInfo_ApplyPutResp.Marshal(b, m, deterministic)
|
||||||
}
|
}
|
||||||
func (dst *ApplySpaceResp) XXX_Merge(src proto.Message) {
|
func (dst *ApplyPutResp) XXX_Merge(src proto.Message) {
|
||||||
xxx_messageInfo_ApplySpaceResp.Merge(dst, src)
|
xxx_messageInfo_ApplyPutResp.Merge(dst, src)
|
||||||
}
|
}
|
||||||
func (m *ApplySpaceResp) XXX_Size() int {
|
func (m *ApplyPutResp) XXX_Size() int {
|
||||||
return xxx_messageInfo_ApplySpaceResp.Size(m)
|
return xxx_messageInfo_ApplyPutResp.Size(m)
|
||||||
}
|
}
|
||||||
func (m *ApplySpaceResp) XXX_DiscardUnknown() {
|
func (m *ApplyPutResp) XXX_DiscardUnknown() {
|
||||||
xxx_messageInfo_ApplySpaceResp.DiscardUnknown(m)
|
xxx_messageInfo_ApplyPutResp.DiscardUnknown(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
var xxx_messageInfo_ApplySpaceResp proto.InternalMessageInfo
|
var xxx_messageInfo_ApplyPutResp proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *ApplySpaceResp) GetUrl() string {
|
func (m *ApplyPutResp) GetUrl() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Url
|
return m.Url
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ApplySpaceResp) GetSize() int64 {
|
func (m *ApplyPutResp) GetPutID() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.PutID
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ApplyPutResp) GetFragmentSize() int64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.FragmentSize
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ApplyPutResp) GetExpirationTime() int64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.ExpirationTime
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ApplyPutResp) GetPutURLs() []string {
|
||||||
|
if m != nil {
|
||||||
|
return m.PutURLs
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfirmPutReq struct {
|
||||||
|
PutID string `protobuf:"bytes,1,opt,name=putID" json:"putID,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ConfirmPutReq) Reset() { *m = ConfirmPutReq{} }
|
||||||
|
func (m *ConfirmPutReq) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*ConfirmPutReq) ProtoMessage() {}
|
||||||
|
func (*ConfirmPutReq) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_third_1a03a4b056d14713, []int{2}
|
||||||
|
}
|
||||||
|
func (m *ConfirmPutReq) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_ConfirmPutReq.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *ConfirmPutReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_ConfirmPutReq.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *ConfirmPutReq) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_ConfirmPutReq.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *ConfirmPutReq) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_ConfirmPutReq.Size(m)
|
||||||
|
}
|
||||||
|
func (m *ConfirmPutReq) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_ConfirmPutReq.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_ConfirmPutReq proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *ConfirmPutReq) GetPutID() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.PutID
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfirmPutResp struct {
|
||||||
|
Url string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ConfirmPutResp) Reset() { *m = ConfirmPutResp{} }
|
||||||
|
func (m *ConfirmPutResp) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*ConfirmPutResp) ProtoMessage() {}
|
||||||
|
func (*ConfirmPutResp) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_third_1a03a4b056d14713, []int{3}
|
||||||
|
}
|
||||||
|
func (m *ConfirmPutResp) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_ConfirmPutResp.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *ConfirmPutResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_ConfirmPutResp.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *ConfirmPutResp) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_ConfirmPutResp.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *ConfirmPutResp) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_ConfirmPutResp.Size(m)
|
||||||
|
}
|
||||||
|
func (m *ConfirmPutResp) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_ConfirmPutResp.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_ConfirmPutResp proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *ConfirmPutResp) GetUrl() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Url
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetPutReq struct {
|
||||||
|
PutID string `protobuf:"bytes,1,opt,name=putID" json:"putID,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *GetPutReq) Reset() { *m = GetPutReq{} }
|
||||||
|
func (m *GetPutReq) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*GetPutReq) ProtoMessage() {}
|
||||||
|
func (*GetPutReq) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_third_1a03a4b056d14713, []int{4}
|
||||||
|
}
|
||||||
|
func (m *GetPutReq) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_GetPutReq.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *GetPutReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_GetPutReq.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *GetPutReq) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_GetPutReq.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *GetPutReq) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_GetPutReq.Size(m)
|
||||||
|
}
|
||||||
|
func (m *GetPutReq) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_GetPutReq.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_GetPutReq proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *GetPutReq) GetPutID() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.PutID
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetPutFragment struct {
|
||||||
|
Size int64 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"`
|
||||||
|
Hash string `protobuf:"bytes,2,opt,name=hash" json:"hash,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *GetPutFragment) Reset() { *m = GetPutFragment{} }
|
||||||
|
func (m *GetPutFragment) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*GetPutFragment) ProtoMessage() {}
|
||||||
|
func (*GetPutFragment) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_third_1a03a4b056d14713, []int{5}
|
||||||
|
}
|
||||||
|
func (m *GetPutFragment) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_GetPutFragment.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *GetPutFragment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_GetPutFragment.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *GetPutFragment) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_GetPutFragment.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *GetPutFragment) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_GetPutFragment.Size(m)
|
||||||
|
}
|
||||||
|
func (m *GetPutFragment) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_GetPutFragment.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_GetPutFragment proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *GetPutFragment) GetSize() int64 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Size
|
return m.Size
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ApplySpaceResp) GetPut() []string {
|
func (m *GetPutFragment) GetHash() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Put
|
return m.Hash
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetPutResp struct {
|
||||||
|
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
|
||||||
|
Size int64 `protobuf:"varint,2,opt,name=size" json:"size,omitempty"`
|
||||||
|
Hash string `protobuf:"bytes,3,opt,name=hash" json:"hash,omitempty"`
|
||||||
|
FragmentSize int64 `protobuf:"varint,4,opt,name=fragmentSize" json:"fragmentSize,omitempty"`
|
||||||
|
CleanTime int64 `protobuf:"varint,5,opt,name=cleanTime" json:"cleanTime,omitempty"`
|
||||||
|
Fragments []*GetPutFragment `protobuf:"bytes,6,rep,name=fragments" json:"fragments,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *GetPutResp) Reset() { *m = GetPutResp{} }
|
||||||
|
func (m *GetPutResp) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*GetPutResp) ProtoMessage() {}
|
||||||
|
func (*GetPutResp) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_third_1a03a4b056d14713, []int{6}
|
||||||
|
}
|
||||||
|
func (m *GetPutResp) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_GetPutResp.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *GetPutResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_GetPutResp.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (dst *GetPutResp) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_GetPutResp.Merge(dst, src)
|
||||||
|
}
|
||||||
|
func (m *GetPutResp) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_GetPutResp.Size(m)
|
||||||
|
}
|
||||||
|
func (m *GetPutResp) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_GetPutResp.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_GetPutResp proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *GetPutResp) GetName() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Name
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *GetPutResp) GetSize() int64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.Size
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *GetPutResp) GetHash() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Hash
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *GetPutResp) GetFragmentSize() int64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.FragmentSize
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *GetPutResp) GetCleanTime() int64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.CleanTime
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *GetPutResp) GetFragments() []*GetPutFragment {
|
||||||
|
if m != nil {
|
||||||
|
return m.Fragments
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ApplySpaceResp) GetConfirmID() string {
|
|
||||||
if m != nil {
|
|
||||||
return m.ConfirmID
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConfirmSpaceReq struct {
|
|
||||||
ConfirmID string `protobuf:"bytes,1,opt,name=confirmID" json:"confirmID,omitempty"`
|
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
|
||||||
XXX_unrecognized []byte `json:"-"`
|
|
||||||
XXX_sizecache int32 `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *ConfirmSpaceReq) Reset() { *m = ConfirmSpaceReq{} }
|
|
||||||
func (m *ConfirmSpaceReq) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*ConfirmSpaceReq) ProtoMessage() {}
|
|
||||||
func (*ConfirmSpaceReq) Descriptor() ([]byte, []int) {
|
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{2}
|
|
||||||
}
|
|
||||||
func (m *ConfirmSpaceReq) XXX_Unmarshal(b []byte) error {
|
|
||||||
return xxx_messageInfo_ConfirmSpaceReq.Unmarshal(m, b)
|
|
||||||
}
|
|
||||||
func (m *ConfirmSpaceReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
|
||||||
return xxx_messageInfo_ConfirmSpaceReq.Marshal(b, m, deterministic)
|
|
||||||
}
|
|
||||||
func (dst *ConfirmSpaceReq) XXX_Merge(src proto.Message) {
|
|
||||||
xxx_messageInfo_ConfirmSpaceReq.Merge(dst, src)
|
|
||||||
}
|
|
||||||
func (m *ConfirmSpaceReq) XXX_Size() int {
|
|
||||||
return xxx_messageInfo_ConfirmSpaceReq.Size(m)
|
|
||||||
}
|
|
||||||
func (m *ConfirmSpaceReq) XXX_DiscardUnknown() {
|
|
||||||
xxx_messageInfo_ConfirmSpaceReq.DiscardUnknown(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
var xxx_messageInfo_ConfirmSpaceReq proto.InternalMessageInfo
|
|
||||||
|
|
||||||
func (m *ConfirmSpaceReq) GetConfirmID() string {
|
|
||||||
if m != nil {
|
|
||||||
return m.ConfirmID
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConfirmSpaceResp struct {
|
|
||||||
ConfirmID string `protobuf:"bytes,1,opt,name=confirmID" json:"confirmID,omitempty"`
|
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
|
||||||
XXX_unrecognized []byte `json:"-"`
|
|
||||||
XXX_sizecache int32 `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *ConfirmSpaceResp) Reset() { *m = ConfirmSpaceResp{} }
|
|
||||||
func (m *ConfirmSpaceResp) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*ConfirmSpaceResp) ProtoMessage() {}
|
|
||||||
func (*ConfirmSpaceResp) Descriptor() ([]byte, []int) {
|
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{3}
|
|
||||||
}
|
|
||||||
func (m *ConfirmSpaceResp) XXX_Unmarshal(b []byte) error {
|
|
||||||
return xxx_messageInfo_ConfirmSpaceResp.Unmarshal(m, b)
|
|
||||||
}
|
|
||||||
func (m *ConfirmSpaceResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
|
||||||
return xxx_messageInfo_ConfirmSpaceResp.Marshal(b, m, deterministic)
|
|
||||||
}
|
|
||||||
func (dst *ConfirmSpaceResp) XXX_Merge(src proto.Message) {
|
|
||||||
xxx_messageInfo_ConfirmSpaceResp.Merge(dst, src)
|
|
||||||
}
|
|
||||||
func (m *ConfirmSpaceResp) XXX_Size() int {
|
|
||||||
return xxx_messageInfo_ConfirmSpaceResp.Size(m)
|
|
||||||
}
|
|
||||||
func (m *ConfirmSpaceResp) XXX_DiscardUnknown() {
|
|
||||||
xxx_messageInfo_ConfirmSpaceResp.DiscardUnknown(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
var xxx_messageInfo_ConfirmSpaceResp proto.InternalMessageInfo
|
|
||||||
|
|
||||||
func (m *ConfirmSpaceResp) GetConfirmID() string {
|
|
||||||
if m != nil {
|
|
||||||
return m.ConfirmID
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetSignalInvitationInfoReq struct {
|
type GetSignalInvitationInfoReq struct {
|
||||||
ClientMsgID string `protobuf:"bytes,1,opt,name=ClientMsgID" json:"ClientMsgID,omitempty"`
|
ClientMsgID string `protobuf:"bytes,1,opt,name=ClientMsgID" json:"ClientMsgID,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
@ -243,7 +413,7 @@ func (m *GetSignalInvitationInfoReq) Reset() { *m = GetSignalInvitationI
|
|||||||
func (m *GetSignalInvitationInfoReq) String() string { return proto.CompactTextString(m) }
|
func (m *GetSignalInvitationInfoReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetSignalInvitationInfoReq) ProtoMessage() {}
|
func (*GetSignalInvitationInfoReq) ProtoMessage() {}
|
||||||
func (*GetSignalInvitationInfoReq) Descriptor() ([]byte, []int) {
|
func (*GetSignalInvitationInfoReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{4}
|
return fileDescriptor_third_1a03a4b056d14713, []int{7}
|
||||||
}
|
}
|
||||||
func (m *GetSignalInvitationInfoReq) XXX_Unmarshal(b []byte) error {
|
func (m *GetSignalInvitationInfoReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_GetSignalInvitationInfoReq.Unmarshal(m, b)
|
return xxx_messageInfo_GetSignalInvitationInfoReq.Unmarshal(m, b)
|
||||||
@ -282,7 +452,7 @@ func (m *GetSignalInvitationInfoResp) Reset() { *m = GetSignalInvitation
|
|||||||
func (m *GetSignalInvitationInfoResp) String() string { return proto.CompactTextString(m) }
|
func (m *GetSignalInvitationInfoResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetSignalInvitationInfoResp) ProtoMessage() {}
|
func (*GetSignalInvitationInfoResp) ProtoMessage() {}
|
||||||
func (*GetSignalInvitationInfoResp) Descriptor() ([]byte, []int) {
|
func (*GetSignalInvitationInfoResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{5}
|
return fileDescriptor_third_1a03a4b056d14713, []int{8}
|
||||||
}
|
}
|
||||||
func (m *GetSignalInvitationInfoResp) XXX_Unmarshal(b []byte) error {
|
func (m *GetSignalInvitationInfoResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_GetSignalInvitationInfoResp.Unmarshal(m, b)
|
return xxx_messageInfo_GetSignalInvitationInfoResp.Unmarshal(m, b)
|
||||||
@ -327,7 +497,7 @@ func (m *GetSignalInvitationInfoStartAppReq) Reset() { *m = GetSignalInv
|
|||||||
func (m *GetSignalInvitationInfoStartAppReq) String() string { return proto.CompactTextString(m) }
|
func (m *GetSignalInvitationInfoStartAppReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetSignalInvitationInfoStartAppReq) ProtoMessage() {}
|
func (*GetSignalInvitationInfoStartAppReq) ProtoMessage() {}
|
||||||
func (*GetSignalInvitationInfoStartAppReq) Descriptor() ([]byte, []int) {
|
func (*GetSignalInvitationInfoStartAppReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{6}
|
return fileDescriptor_third_1a03a4b056d14713, []int{9}
|
||||||
}
|
}
|
||||||
func (m *GetSignalInvitationInfoStartAppReq) XXX_Unmarshal(b []byte) error {
|
func (m *GetSignalInvitationInfoStartAppReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_GetSignalInvitationInfoStartAppReq.Unmarshal(m, b)
|
return xxx_messageInfo_GetSignalInvitationInfoStartAppReq.Unmarshal(m, b)
|
||||||
@ -366,7 +536,7 @@ func (m *GetSignalInvitationInfoStartAppResp) Reset() { *m = GetSignalIn
|
|||||||
func (m *GetSignalInvitationInfoStartAppResp) String() string { return proto.CompactTextString(m) }
|
func (m *GetSignalInvitationInfoStartAppResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetSignalInvitationInfoStartAppResp) ProtoMessage() {}
|
func (*GetSignalInvitationInfoStartAppResp) ProtoMessage() {}
|
||||||
func (*GetSignalInvitationInfoStartAppResp) Descriptor() ([]byte, []int) {
|
func (*GetSignalInvitationInfoStartAppResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{7}
|
return fileDescriptor_third_1a03a4b056d14713, []int{10}
|
||||||
}
|
}
|
||||||
func (m *GetSignalInvitationInfoStartAppResp) XXX_Unmarshal(b []byte) error {
|
func (m *GetSignalInvitationInfoStartAppResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_GetSignalInvitationInfoStartAppResp.Unmarshal(m, b)
|
return xxx_messageInfo_GetSignalInvitationInfoStartAppResp.Unmarshal(m, b)
|
||||||
@ -414,7 +584,7 @@ func (m *FcmUpdateTokenReq) Reset() { *m = FcmUpdateTokenReq{} }
|
|||||||
func (m *FcmUpdateTokenReq) String() string { return proto.CompactTextString(m) }
|
func (m *FcmUpdateTokenReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*FcmUpdateTokenReq) ProtoMessage() {}
|
func (*FcmUpdateTokenReq) ProtoMessage() {}
|
||||||
func (*FcmUpdateTokenReq) Descriptor() ([]byte, []int) {
|
func (*FcmUpdateTokenReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{8}
|
return fileDescriptor_third_1a03a4b056d14713, []int{11}
|
||||||
}
|
}
|
||||||
func (m *FcmUpdateTokenReq) XXX_Unmarshal(b []byte) error {
|
func (m *FcmUpdateTokenReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_FcmUpdateTokenReq.Unmarshal(m, b)
|
return xxx_messageInfo_FcmUpdateTokenReq.Unmarshal(m, b)
|
||||||
@ -472,7 +642,7 @@ func (m *FcmUpdateTokenResp) Reset() { *m = FcmUpdateTokenResp{} }
|
|||||||
func (m *FcmUpdateTokenResp) String() string { return proto.CompactTextString(m) }
|
func (m *FcmUpdateTokenResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*FcmUpdateTokenResp) ProtoMessage() {}
|
func (*FcmUpdateTokenResp) ProtoMessage() {}
|
||||||
func (*FcmUpdateTokenResp) Descriptor() ([]byte, []int) {
|
func (*FcmUpdateTokenResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{9}
|
return fileDescriptor_third_1a03a4b056d14713, []int{12}
|
||||||
}
|
}
|
||||||
func (m *FcmUpdateTokenResp) XXX_Unmarshal(b []byte) error {
|
func (m *FcmUpdateTokenResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_FcmUpdateTokenResp.Unmarshal(m, b)
|
return xxx_messageInfo_FcmUpdateTokenResp.Unmarshal(m, b)
|
||||||
@ -504,7 +674,7 @@ func (m *SetAppBadgeReq) Reset() { *m = SetAppBadgeReq{} }
|
|||||||
func (m *SetAppBadgeReq) String() string { return proto.CompactTextString(m) }
|
func (m *SetAppBadgeReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SetAppBadgeReq) ProtoMessage() {}
|
func (*SetAppBadgeReq) ProtoMessage() {}
|
||||||
func (*SetAppBadgeReq) Descriptor() ([]byte, []int) {
|
func (*SetAppBadgeReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{10}
|
return fileDescriptor_third_1a03a4b056d14713, []int{13}
|
||||||
}
|
}
|
||||||
func (m *SetAppBadgeReq) XXX_Unmarshal(b []byte) error {
|
func (m *SetAppBadgeReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_SetAppBadgeReq.Unmarshal(m, b)
|
return xxx_messageInfo_SetAppBadgeReq.Unmarshal(m, b)
|
||||||
@ -548,7 +718,7 @@ func (m *SetAppBadgeResp) Reset() { *m = SetAppBadgeResp{} }
|
|||||||
func (m *SetAppBadgeResp) String() string { return proto.CompactTextString(m) }
|
func (m *SetAppBadgeResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SetAppBadgeResp) ProtoMessage() {}
|
func (*SetAppBadgeResp) ProtoMessage() {}
|
||||||
func (*SetAppBadgeResp) Descriptor() ([]byte, []int) {
|
func (*SetAppBadgeResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_third_de04cb9a0062d654, []int{11}
|
return fileDescriptor_third_1a03a4b056d14713, []int{14}
|
||||||
}
|
}
|
||||||
func (m *SetAppBadgeResp) XXX_Unmarshal(b []byte) error {
|
func (m *SetAppBadgeResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_SetAppBadgeResp.Unmarshal(m, b)
|
return xxx_messageInfo_SetAppBadgeResp.Unmarshal(m, b)
|
||||||
@ -569,10 +739,13 @@ func (m *SetAppBadgeResp) XXX_DiscardUnknown() {
|
|||||||
var xxx_messageInfo_SetAppBadgeResp proto.InternalMessageInfo
|
var xxx_messageInfo_SetAppBadgeResp proto.InternalMessageInfo
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*ApplySpaceReq)(nil), "third.ApplySpaceReq")
|
proto.RegisterType((*ApplyPutReq)(nil), "third.ApplyPutReq")
|
||||||
proto.RegisterType((*ApplySpaceResp)(nil), "third.ApplySpaceResp")
|
proto.RegisterType((*ApplyPutResp)(nil), "third.ApplyPutResp")
|
||||||
proto.RegisterType((*ConfirmSpaceReq)(nil), "third.ConfirmSpaceReq")
|
proto.RegisterType((*ConfirmPutReq)(nil), "third.ConfirmPutReq")
|
||||||
proto.RegisterType((*ConfirmSpaceResp)(nil), "third.ConfirmSpaceResp")
|
proto.RegisterType((*ConfirmPutResp)(nil), "third.ConfirmPutResp")
|
||||||
|
proto.RegisterType((*GetPutReq)(nil), "third.GetPutReq")
|
||||||
|
proto.RegisterType((*GetPutFragment)(nil), "third.GetPutFragment")
|
||||||
|
proto.RegisterType((*GetPutResp)(nil), "third.GetPutResp")
|
||||||
proto.RegisterType((*GetSignalInvitationInfoReq)(nil), "third.GetSignalInvitationInfoReq")
|
proto.RegisterType((*GetSignalInvitationInfoReq)(nil), "third.GetSignalInvitationInfoReq")
|
||||||
proto.RegisterType((*GetSignalInvitationInfoResp)(nil), "third.GetSignalInvitationInfoResp")
|
proto.RegisterType((*GetSignalInvitationInfoResp)(nil), "third.GetSignalInvitationInfoResp")
|
||||||
proto.RegisterType((*GetSignalInvitationInfoStartAppReq)(nil), "third.GetSignalInvitationInfoStartAppReq")
|
proto.RegisterType((*GetSignalInvitationInfoStartAppReq)(nil), "third.GetSignalInvitationInfoStartAppReq")
|
||||||
@ -594,7 +767,9 @@ const _ = grpc.SupportPackageIsVersion4
|
|||||||
// Client API for Third service
|
// Client API for Third service
|
||||||
|
|
||||||
type ThirdClient interface {
|
type ThirdClient interface {
|
||||||
ApplySpace(ctx context.Context, in *ApplySpaceReq, opts ...grpc.CallOption) (*ApplySpaceResp, error)
|
ApplyPut(ctx context.Context, in *ApplyPutReq, opts ...grpc.CallOption) (*ApplyPutResp, error)
|
||||||
|
GetPut(ctx context.Context, in *GetPutReq, opts ...grpc.CallOption) (*GetPutResp, error)
|
||||||
|
ConfirmPut(ctx context.Context, in *ConfirmPutReq, opts ...grpc.CallOption) (*ConfirmPutResp, error)
|
||||||
GetSignalInvitationInfo(ctx context.Context, in *GetSignalInvitationInfoReq, opts ...grpc.CallOption) (*GetSignalInvitationInfoResp, error)
|
GetSignalInvitationInfo(ctx context.Context, in *GetSignalInvitationInfoReq, opts ...grpc.CallOption) (*GetSignalInvitationInfoResp, error)
|
||||||
GetSignalInvitationInfoStartApp(ctx context.Context, in *GetSignalInvitationInfoStartAppReq, opts ...grpc.CallOption) (*GetSignalInvitationInfoStartAppResp, error)
|
GetSignalInvitationInfoStartApp(ctx context.Context, in *GetSignalInvitationInfoStartAppReq, opts ...grpc.CallOption) (*GetSignalInvitationInfoStartAppResp, error)
|
||||||
FcmUpdateToken(ctx context.Context, in *FcmUpdateTokenReq, opts ...grpc.CallOption) (*FcmUpdateTokenResp, error)
|
FcmUpdateToken(ctx context.Context, in *FcmUpdateTokenReq, opts ...grpc.CallOption) (*FcmUpdateTokenResp, error)
|
||||||
@ -609,9 +784,27 @@ func NewThirdClient(cc *grpc.ClientConn) ThirdClient {
|
|||||||
return &thirdClient{cc}
|
return &thirdClient{cc}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *thirdClient) ApplySpace(ctx context.Context, in *ApplySpaceReq, opts ...grpc.CallOption) (*ApplySpaceResp, error) {
|
func (c *thirdClient) ApplyPut(ctx context.Context, in *ApplyPutReq, opts ...grpc.CallOption) (*ApplyPutResp, error) {
|
||||||
out := new(ApplySpaceResp)
|
out := new(ApplyPutResp)
|
||||||
err := grpc.Invoke(ctx, "/third.third/ApplySpace", in, out, c.cc, opts...)
|
err := grpc.Invoke(ctx, "/third.third/ApplyPut", in, out, c.cc, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *thirdClient) GetPut(ctx context.Context, in *GetPutReq, opts ...grpc.CallOption) (*GetPutResp, error) {
|
||||||
|
out := new(GetPutResp)
|
||||||
|
err := grpc.Invoke(ctx, "/third.third/GetPut", in, out, c.cc, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *thirdClient) ConfirmPut(ctx context.Context, in *ConfirmPutReq, opts ...grpc.CallOption) (*ConfirmPutResp, error) {
|
||||||
|
out := new(ConfirmPutResp)
|
||||||
|
err := grpc.Invoke(ctx, "/third.third/ConfirmPut", in, out, c.cc, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -657,7 +850,9 @@ func (c *thirdClient) SetAppBadge(ctx context.Context, in *SetAppBadgeReq, opts
|
|||||||
// Server API for Third service
|
// Server API for Third service
|
||||||
|
|
||||||
type ThirdServer interface {
|
type ThirdServer interface {
|
||||||
ApplySpace(context.Context, *ApplySpaceReq) (*ApplySpaceResp, error)
|
ApplyPut(context.Context, *ApplyPutReq) (*ApplyPutResp, error)
|
||||||
|
GetPut(context.Context, *GetPutReq) (*GetPutResp, error)
|
||||||
|
ConfirmPut(context.Context, *ConfirmPutReq) (*ConfirmPutResp, error)
|
||||||
GetSignalInvitationInfo(context.Context, *GetSignalInvitationInfoReq) (*GetSignalInvitationInfoResp, error)
|
GetSignalInvitationInfo(context.Context, *GetSignalInvitationInfoReq) (*GetSignalInvitationInfoResp, error)
|
||||||
GetSignalInvitationInfoStartApp(context.Context, *GetSignalInvitationInfoStartAppReq) (*GetSignalInvitationInfoStartAppResp, error)
|
GetSignalInvitationInfoStartApp(context.Context, *GetSignalInvitationInfoStartAppReq) (*GetSignalInvitationInfoStartAppResp, error)
|
||||||
FcmUpdateToken(context.Context, *FcmUpdateTokenReq) (*FcmUpdateTokenResp, error)
|
FcmUpdateToken(context.Context, *FcmUpdateTokenReq) (*FcmUpdateTokenResp, error)
|
||||||
@ -668,20 +863,56 @@ func RegisterThirdServer(s *grpc.Server, srv ThirdServer) {
|
|||||||
s.RegisterService(&_Third_serviceDesc, srv)
|
s.RegisterService(&_Third_serviceDesc, srv)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _Third_ApplySpace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _Third_ApplyPut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(ApplySpaceReq)
|
in := new(ApplyPutReq)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if interceptor == nil {
|
if interceptor == nil {
|
||||||
return srv.(ThirdServer).ApplySpace(ctx, in)
|
return srv.(ThirdServer).ApplyPut(ctx, in)
|
||||||
}
|
}
|
||||||
info := &grpc.UnaryServerInfo{
|
info := &grpc.UnaryServerInfo{
|
||||||
Server: srv,
|
Server: srv,
|
||||||
FullMethod: "/third.third/ApplySpace",
|
FullMethod: "/third.third/ApplyPut",
|
||||||
}
|
}
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
return srv.(ThirdServer).ApplySpace(ctx, req.(*ApplySpaceReq))
|
return srv.(ThirdServer).ApplyPut(ctx, req.(*ApplyPutReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Third_GetPut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetPutReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ThirdServer).GetPut(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/third.third/GetPut",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ThirdServer).GetPut(ctx, req.(*GetPutReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Third_ConfirmPut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(ConfirmPutReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ThirdServer).ConfirmPut(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/third.third/ConfirmPut",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ThirdServer).ConfirmPut(ctx, req.(*ConfirmPutReq))
|
||||||
}
|
}
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
@ -763,8 +994,16 @@ var _Third_serviceDesc = grpc.ServiceDesc{
|
|||||||
HandlerType: (*ThirdServer)(nil),
|
HandlerType: (*ThirdServer)(nil),
|
||||||
Methods: []grpc.MethodDesc{
|
Methods: []grpc.MethodDesc{
|
||||||
{
|
{
|
||||||
MethodName: "ApplySpace",
|
MethodName: "ApplyPut",
|
||||||
Handler: _Third_ApplySpace_Handler,
|
Handler: _Third_ApplyPut_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetPut",
|
||||||
|
Handler: _Third_GetPut_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "ConfirmPut",
|
||||||
|
Handler: _Third_ConfirmPut_Handler,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MethodName: "GetSignalInvitationInfo",
|
MethodName: "GetSignalInvitationInfo",
|
||||||
@ -787,46 +1026,53 @@ var _Third_serviceDesc = grpc.ServiceDesc{
|
|||||||
Metadata: "third/third.proto",
|
Metadata: "third/third.proto",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("third/third.proto", fileDescriptor_third_de04cb9a0062d654) }
|
func init() { proto.RegisterFile("third/third.proto", fileDescriptor_third_1a03a4b056d14713) }
|
||||||
|
|
||||||
var fileDescriptor_third_de04cb9a0062d654 = []byte{
|
var fileDescriptor_third_1a03a4b056d14713 = []byte{
|
||||||
// 608 bytes of a gzipped FileDescriptorProto
|
// 712 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0xcd, 0x6e, 0xd3, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xdd, 0x4e, 0x13, 0x4f,
|
||||||
0x10, 0x96, 0xeb, 0xb6, 0x90, 0x89, 0x9a, 0xb6, 0xab, 0xb6, 0x18, 0x53, 0x15, 0x63, 0x24, 0x28,
|
0x14, 0xcf, 0xb6, 0xb4, 0x7f, 0x7a, 0xca, 0xbf, 0xd0, 0x23, 0xe0, 0xba, 0x12, 0x2c, 0x63, 0xd4,
|
||||||
0x48, 0x8d, 0x51, 0x39, 0x21, 0x0a, 0xa2, 0x2d, 0x14, 0xe5, 0x50, 0x35, 0x72, 0xd2, 0x0b, 0x27,
|
0x6a, 0x02, 0x4d, 0xe0, 0x46, 0x23, 0x1a, 0x01, 0x85, 0x34, 0x91, 0xd0, 0x6c, 0xe1, 0xc6, 0x2b,
|
||||||
0x8c, 0xb3, 0x4e, 0xac, 0x38, 0xeb, 0xc1, 0xbb, 0xee, 0x0f, 0x2f, 0x80, 0x78, 0x09, 0x2e, 0x48,
|
0xd7, 0x76, 0xda, 0x6e, 0xd8, 0x8f, 0x71, 0x67, 0x16, 0xd0, 0x17, 0x30, 0xc6, 0x57, 0x30, 0x5e,
|
||||||
0x3c, 0x27, 0xda, 0xb5, 0x93, 0xda, 0x26, 0x69, 0x38, 0x72, 0xb1, 0x76, 0x3e, 0x7f, 0xdf, 0xec,
|
0xfa, 0x1a, 0xbe, 0x9a, 0x99, 0xd9, 0x6d, 0xbb, 0xbb, 0xb4, 0xd4, 0x3b, 0xbd, 0xd9, 0xcc, 0xf9,
|
||||||
0xfc, 0xec, 0x0c, 0xac, 0x8b, 0x41, 0x98, 0xf4, 0x1c, 0xf5, 0x6d, 0x62, 0x12, 0x8b, 0x98, 0x2c,
|
0xed, 0xef, 0x9c, 0x39, 0xdf, 0x03, 0x55, 0x31, 0xb0, 0x83, 0x6e, 0x43, 0x7d, 0xb7, 0x58, 0xe0,
|
||||||
0x29, 0xc3, 0x7c, 0x7a, 0x86, 0x94, 0xed, 0xb5, 0x4e, 0xf7, 0x3a, 0x34, 0xb9, 0xa0, 0x89, 0x83,
|
0x0b, 0x1f, 0x0b, 0x4a, 0x30, 0x1e, 0x9d, 0x30, 0xea, 0x6d, 0x36, 0x8f, 0x37, 0xdb, 0x34, 0xb8,
|
||||||
0xc3, 0xbe, 0xa3, 0x08, 0x0e, 0xef, 0x0d, 0x2f, 0xb9, 0x73, 0xc9, 0x33, 0xbe, 0xfd, 0x5d, 0x83,
|
0xa0, 0x41, 0x83, 0x9d, 0xf7, 0x1b, 0x8a, 0xd0, 0xe0, 0xdd, 0xf3, 0x4b, 0xde, 0xb8, 0xe4, 0x11,
|
||||||
0x95, 0x43, 0xc4, 0xe8, 0xba, 0x83, 0x9e, 0x4f, 0x5d, 0xfa, 0x95, 0x10, 0x58, 0x64, 0xde, 0x88,
|
0x9f, 0x7c, 0xd3, 0xa0, 0xbc, 0xc7, 0x98, 0xf3, 0xa9, 0x15, 0x0a, 0x93, 0x7e, 0x44, 0x84, 0x39,
|
||||||
0x1a, 0x9a, 0xa5, 0xed, 0xd6, 0x5c, 0x75, 0x96, 0x18, 0x0f, 0xbf, 0x51, 0x63, 0xc1, 0xd2, 0x76,
|
0xcf, 0x72, 0xa9, 0xae, 0xd5, 0xb4, 0x7a, 0xc9, 0x54, 0x67, 0x89, 0x71, 0xfb, 0x33, 0xd5, 0x73,
|
||||||
0x75, 0x57, 0x9d, 0x25, 0x36, 0xf0, 0xf8, 0xc0, 0xd0, 0x33, 0x9e, 0x3c, 0x13, 0x03, 0xee, 0x60,
|
0x35, 0xad, 0x9e, 0x37, 0xd5, 0x59, 0x62, 0x03, 0x8b, 0x0f, 0xf4, 0x7c, 0xc4, 0x93, 0x67, 0x24,
|
||||||
0x9a, 0x60, 0xcc, 0xa9, 0xb1, 0x68, 0x69, 0xbb, 0x2b, 0xee, 0xd8, 0x24, 0x16, 0xd4, 0xfd, 0x98,
|
0xb0, 0xd0, 0x0b, 0xac, 0xbe, 0x4b, 0x3d, 0xd1, 0x96, 0xfc, 0x39, 0xc5, 0x4f, 0x61, 0xb8, 0x06,
|
||||||
0x09, 0xca, 0x44, 0xf7, 0x1a, 0xa9, 0xb1, 0xa4, 0x44, 0x45, 0xc8, 0x0e, 0xa0, 0x51, 0x0c, 0x84,
|
0xa5, 0x8e, 0x43, 0x2d, 0xef, 0xd4, 0x76, 0xa9, 0x5e, 0x50, 0x84, 0x31, 0x40, 0xbe, 0x6b, 0xb0,
|
||||||
0x23, 0x59, 0x03, 0x3d, 0x4d, 0xa2, 0x3c, 0x10, 0x79, 0x9c, 0x1a, 0xc7, 0x1a, 0xe8, 0x98, 0x0a,
|
0x30, 0xf6, 0x86, 0x33, 0x5c, 0x82, 0x7c, 0x18, 0x38, 0xb1, 0x37, 0xf2, 0x88, 0xcb, 0x50, 0x60,
|
||||||
0x43, 0xb7, 0x74, 0xc9, 0xc2, 0x54, 0x90, 0x6d, 0xa8, 0xf9, 0x31, 0x0b, 0xc2, 0x64, 0xd4, 0x7a,
|
0xa1, 0x68, 0xbe, 0x56, 0xde, 0x94, 0xcc, 0x48, 0xb8, 0x76, 0x75, 0x7e, 0xc2, 0xd5, 0x0f, 0xa1,
|
||||||
0xaf, 0xe2, 0xa8, 0xb9, 0x37, 0x80, 0xed, 0xc0, 0xea, 0x71, 0x66, 0x4c, 0x52, 0x2e, 0x09, 0xb4,
|
0x42, 0xaf, 0x98, 0x1d, 0x58, 0xc2, 0xf6, 0xa3, 0xfb, 0x23, 0x07, 0x33, 0x28, 0xea, 0xf0, 0x5f,
|
||||||
0xaa, 0xe0, 0x05, 0xac, 0x95, 0x05, 0x1c, 0xe7, 0x28, 0xde, 0x82, 0xf9, 0x91, 0x8a, 0x4e, 0xd8,
|
0x2b, 0x14, 0x67, 0xe6, 0x5b, 0xae, 0x17, 0x6a, 0xf9, 0x7a, 0xc9, 0x1c, 0x8a, 0xe4, 0x01, 0xfc,
|
||||||
0x67, 0x5e, 0xd4, 0x62, 0x17, 0xa1, 0xf0, 0x44, 0x18, 0xb3, 0x16, 0x0b, 0x62, 0x79, 0x9b, 0x05,
|
0x7f, 0xe0, 0x7b, 0x3d, 0x3b, 0x70, 0xe3, 0x6c, 0x8d, 0x9c, 0xd1, 0x12, 0xce, 0x10, 0x02, 0x95,
|
||||||
0xf5, 0xe3, 0x28, 0xa4, 0x4c, 0x9c, 0xf2, 0xfe, 0x44, 0x5d, 0x84, 0xec, 0x9f, 0x1a, 0x3c, 0x98,
|
0x24, 0x6d, 0x52, 0x18, 0x64, 0x03, 0x4a, 0x47, 0x54, 0xdc, 0x68, 0xe6, 0x29, 0x54, 0x22, 0xca,
|
||||||
0xe9, 0x80, 0x23, 0x79, 0x03, 0x8d, 0xb0, 0x84, 0x2a, 0x27, 0xf5, 0xfd, 0xcd, 0xa6, 0xea, 0x6e,
|
0x61, 0x1c, 0xc5, 0xa8, 0x10, 0xda, 0x84, 0x42, 0xe4, 0xc6, 0x85, 0x20, 0xbf, 0x34, 0x80, 0xa1,
|
||||||
0xb3, 0x22, 0xa9, 0x90, 0xc9, 0x3b, 0x58, 0x8d, 0x83, 0x20, 0x0a, 0x19, 0x6d, 0xa7, 0x7c, 0xa0,
|
0x75, 0xce, 0xfe, 0x6e, 0x4d, 0x71, 0x07, 0x4a, 0x43, 0x36, 0xd7, 0x8b, 0xb5, 0x7c, 0xbd, 0xbc,
|
||||||
0xf4, 0x0b, 0x4a, 0xbf, 0x95, 0xeb, 0xcf, 0xca, 0x7f, 0xdd, 0x2a, 0xdd, 0x3e, 0x00, 0x7b, 0x46,
|
0xbd, 0xb2, 0x15, 0xb5, 0x6c, 0x3a, 0x3c, 0x73, 0xcc, 0x23, 0x2f, 0xc1, 0x38, 0xa2, 0xa2, 0x6d,
|
||||||
0x7c, 0x1d, 0xe1, 0x25, 0xe2, 0x10, 0x51, 0x26, 0xba, 0x05, 0xcb, 0x29, 0xa7, 0xc9, 0x24, 0xc7,
|
0xf7, 0x3d, 0xcb, 0x69, 0x7a, 0x17, 0xb6, 0x50, 0xe5, 0x69, 0x7a, 0x3d, 0x5f, 0xe6, 0xab, 0x06,
|
||||||
0xdc, 0xb2, 0x7f, 0x6b, 0xf0, 0x78, 0xae, 0xfc, 0x7f, 0x48, 0xf3, 0x87, 0x06, 0xeb, 0x27, 0xfe,
|
0xe5, 0x03, 0xc7, 0xa6, 0x9e, 0x38, 0xe6, 0xfd, 0x51, 0xd6, 0x92, 0x10, 0xf9, 0xa1, 0xc1, 0xdd,
|
||||||
0xe8, 0x1c, 0x7b, 0x9e, 0xa0, 0xdd, 0x78, 0x48, 0x99, 0x4c, 0x6b, 0x07, 0xa0, 0x1d, 0x79, 0x22,
|
0xa9, 0x06, 0x38, 0xc3, 0x17, 0x50, 0xb1, 0x53, 0xa8, 0x32, 0x22, 0x3d, 0x53, 0xf3, 0xb1, 0x95,
|
||||||
0x88, 0x27, 0xcd, 0x5f, 0x72, 0x0b, 0x08, 0x31, 0xe1, 0xee, 0x89, 0x3f, 0x52, 0x74, 0x75, 0x61,
|
0x51, 0xc9, 0x90, 0xf1, 0x15, 0x2c, 0xfa, 0xbd, 0x9e, 0x63, 0x7b, 0xb4, 0x15, 0xf2, 0x81, 0xd2,
|
||||||
0xcd, 0x9d, 0xd8, 0x72, 0x40, 0x3c, 0xdf, 0x8f, 0x53, 0x26, 0xf2, 0xb9, 0x19, 0x9b, 0xd2, 0x2b,
|
0xcf, 0x29, 0xfd, 0xd5, 0x58, 0xff, 0x24, 0xfd, 0xd7, 0xcc, 0xd2, 0xc9, 0x2e, 0x90, 0x29, 0xfe,
|
||||||
0xbd, 0xc2, 0x30, 0xa1, 0xdd, 0x70, 0x94, 0x4d, 0x8f, 0xee, 0x16, 0x10, 0x7b, 0x03, 0x48, 0x35,
|
0xb5, 0x85, 0x15, 0x88, 0x3d, 0xc6, 0x64, 0xa0, 0xab, 0x50, 0x0c, 0x39, 0x0d, 0x46, 0x31, 0xc6,
|
||||||
0x14, 0x8e, 0x76, 0x1b, 0x1a, 0x1d, 0x2a, 0x0b, 0x76, 0xe4, 0xf5, 0xfa, 0xf4, 0x96, 0xa2, 0x93,
|
0x12, 0xf9, 0xa9, 0xc1, 0xfd, 0x99, 0xea, 0xff, 0x42, 0x98, 0x5f, 0x35, 0xa8, 0x1e, 0x76, 0xdc,
|
||||||
0x27, 0x6a, 0xbc, 0xce, 0x59, 0x42, 0xbd, 0xde, 0xb1, 0x0a, 0x60, 0x41, 0x45, 0x5e, 0x41, 0xed,
|
0x33, 0xd6, 0xb5, 0x04, 0x3d, 0xf5, 0xcf, 0xa9, 0x27, 0xc3, 0x5a, 0x07, 0x68, 0x39, 0x96, 0xe8,
|
||||||
0x75, 0x58, 0x2d, 0x79, 0xe4, 0xb8, 0xff, 0x4b, 0x87, 0x6c, 0xad, 0x90, 0x57, 0x00, 0x37, 0x33,
|
0xf9, 0x81, 0x1b, 0x87, 0x56, 0x30, 0x13, 0x08, 0x1a, 0x30, 0x7f, 0xd8, 0x71, 0x15, 0x3d, 0xee,
|
||||||
0x4a, 0x36, 0x9a, 0xd9, 0xe6, 0x29, 0xed, 0x0f, 0x73, 0x73, 0x0a, 0xca, 0x91, 0x7c, 0x86, 0x7b,
|
0xeb, 0x91, 0x2c, 0xa7, 0xd3, 0xea, 0x74, 0xfc, 0xd0, 0x13, 0x71, 0x9f, 0x0e, 0x45, 0x69, 0x55,
|
||||||
0x33, 0x7a, 0x4e, 0x1e, 0xe5, 0x8a, 0xd9, 0x33, 0x63, 0xda, 0xf3, 0x28, 0x1c, 0xc9, 0x15, 0x3c,
|
0x4d, 0x32, 0x4d, 0xcc, 0x76, 0x02, 0x21, 0xcb, 0x80, 0x59, 0x57, 0x38, 0x23, 0x2d, 0xa8, 0xb4,
|
||||||
0x9c, 0xf3, 0xaa, 0xc8, 0xb3, 0xdb, 0xdd, 0x14, 0x1e, 0xaf, 0xf9, 0xfc, 0x5f, 0xa9, 0x1c, 0xc9,
|
0xa9, 0x4c, 0xd8, 0xbe, 0xd5, 0xed, 0xd3, 0x1b, 0x92, 0x2e, 0xf7, 0xc7, 0x1e, 0x63, 0x67, 0x5e,
|
||||||
0x07, 0x68, 0x94, 0x7b, 0x43, 0x8c, 0x5c, 0xfd, 0xd7, 0xeb, 0x31, 0xef, 0xcf, 0xf8, 0xc3, 0x91,
|
0x40, 0xad, 0xee, 0x81, 0x72, 0x20, 0xa7, 0x3c, 0xcf, 0xa0, 0xa4, 0x0a, 0x8b, 0x29, 0x8b, 0x9c,
|
||||||
0x1c, 0x40, 0xbd, 0x50, 0x7a, 0x32, 0x2e, 0x64, 0xb9, 0xc1, 0xe6, 0xd6, 0x34, 0x98, 0xe3, 0xd1,
|
0x6d, 0x7f, 0x99, 0x83, 0x68, 0x31, 0xe3, 0x0e, 0xcc, 0x0f, 0x17, 0x1c, 0x62, 0x3c, 0x06, 0x89,
|
||||||
0xce, 0xa7, 0x6d, 0xb9, 0xf4, 0x5b, 0xa7, 0x85, 0x65, 0xaf, 0x98, 0xaf, 0xd5, 0xf7, 0xcb, 0xb2,
|
0xfd, 0x6b, 0xdc, 0xba, 0x86, 0x71, 0x86, 0x9b, 0x50, 0x8c, 0x46, 0x05, 0x97, 0x52, 0x93, 0x23,
|
||||||
0x82, 0x5e, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x74, 0xd3, 0xa9, 0xeb, 0x35, 0x06, 0x00, 0x00,
|
0x15, 0xaa, 0x19, 0x84, 0x33, 0x7c, 0x06, 0x30, 0xde, 0x3f, 0xb8, 0x1c, 0x13, 0x52, 0x9b, 0xcb,
|
||||||
|
0x58, 0x99, 0x80, 0x72, 0x86, 0xef, 0xe1, 0xf6, 0x94, 0xbe, 0xc2, 0x8d, 0xf1, 0x45, 0x53, 0xe6,
|
||||||
|
0xd2, 0x20, 0xb3, 0x28, 0x9c, 0xe1, 0x15, 0xdc, 0x9b, 0xd1, 0xb9, 0xf8, 0xf8, 0x66, 0x33, 0x89,
|
||||||
|
0x01, 0x31, 0x9e, 0xfc, 0x29, 0x95, 0x33, 0x7c, 0x03, 0x95, 0x74, 0xfd, 0x51, 0x8f, 0xb5, 0xaf,
|
||||||
|
0x75, 0xa8, 0x71, 0x67, 0xca, 0x1f, 0xce, 0x70, 0x17, 0xca, 0x89, 0xf2, 0xe2, 0x30, 0x91, 0xe9,
|
||||||
|
0x26, 0x32, 0x56, 0x27, 0xc1, 0x9c, 0xed, 0xaf, 0xbf, 0x5b, 0x93, 0x4f, 0x73, 0xf3, 0x38, 0xf1,
|
||||||
|
0x24, 0x2b, 0xe6, 0x73, 0xf5, 0xfd, 0x50, 0x54, 0xd0, 0xce, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff,
|
||||||
|
0xda, 0x49, 0x1e, 0x93, 0xdb, 0x07, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -3,28 +3,46 @@ import "Open-IM-Server/pkg/proto/sdkws/ws.proto";
|
|||||||
option go_package = "OpenIM/pkg/proto/third;third";
|
option go_package = "OpenIM/pkg/proto/third;third";
|
||||||
package third;
|
package third;
|
||||||
|
|
||||||
|
message ApplyPutReq {
|
||||||
message ApplySpaceReq {
|
string name = 1;
|
||||||
string name = 1; // 文件名字
|
int64 size = 2;
|
||||||
int64 size = 2; // 大小
|
string hash = 3;
|
||||||
string hash = 3; // md5
|
int64 fragmentSize = 4;
|
||||||
uint32 purpose = 4; // 用途
|
int64 cleanTime = 5;
|
||||||
string contentType = 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message ApplySpaceResp {
|
message ApplyPutResp {
|
||||||
string url = 1; // 不为空表示已存在
|
string url = 1;
|
||||||
int64 size = 2; // 分片大小
|
string putID = 2;
|
||||||
repeated string put = 3;// put地址
|
int64 fragmentSize = 3;
|
||||||
string confirmID = 4; // 确认ID
|
// int64 expirationTime = 4;
|
||||||
|
repeated string PutURLs = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ConfirmSpaceReq {
|
message ConfirmPutReq {
|
||||||
string confirmID = 1; // 确认ID
|
string putID = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ConfirmSpaceResp {
|
message ConfirmPutResp {
|
||||||
string confirmID = 1;
|
string url = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetPutReq {
|
||||||
|
string putID = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetPutFragment{
|
||||||
|
int64 size = 1;
|
||||||
|
string hash = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetPutResp {
|
||||||
|
string name = 1;
|
||||||
|
int64 size = 2;
|
||||||
|
string hash = 3;
|
||||||
|
int64 fragmentSize = 4;
|
||||||
|
int64 cleanTime = 5;
|
||||||
|
repeated GetPutFragment fragments = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetSignalInvitationInfoReq {
|
message GetSignalInvitationInfoReq {
|
||||||
@ -32,8 +50,8 @@ message GetSignalInvitationInfoReq {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message GetSignalInvitationInfoResp {
|
message GetSignalInvitationInfoResp {
|
||||||
sdkws.InvitationInfo invitationInfo = 1;
|
sdkws.InvitationInfo invitationInfo = 1;
|
||||||
sdkws.OfflinePushInfo offlinePushInfo = 2;
|
sdkws.OfflinePushInfo offlinePushInfo = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetSignalInvitationInfoStartAppReq {
|
message GetSignalInvitationInfoStartAppReq {
|
||||||
@ -41,15 +59,15 @@ message GetSignalInvitationInfoStartAppReq {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message GetSignalInvitationInfoStartAppResp {
|
message GetSignalInvitationInfoStartAppResp {
|
||||||
sdkws.InvitationInfo invitationInfo = 1;
|
sdkws.InvitationInfo invitationInfo = 1;
|
||||||
sdkws.OfflinePushInfo offlinePushInfo = 2;
|
sdkws.OfflinePushInfo offlinePushInfo = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message FcmUpdateTokenReq {
|
message FcmUpdateTokenReq {
|
||||||
int32 PlatformID = 1;
|
int32 PlatformID = 1;
|
||||||
string FcmToken = 2;
|
string FcmToken = 2;
|
||||||
string account = 3;
|
string account = 3;
|
||||||
int64 expireTime = 4;
|
int64 expireTime = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message FcmUpdateTokenResp {
|
message FcmUpdateTokenResp {
|
||||||
@ -64,7 +82,10 @@ message SetAppBadgeResp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
service third {
|
service third {
|
||||||
rpc ApplySpace(ApplySpaceReq) returns(ApplySpaceResp);
|
rpc ApplyPut(ApplyPutReq) returns(ApplyPutResp);
|
||||||
|
rpc GetPut(GetPutReq) returns(GetPutResp);
|
||||||
|
rpc ConfirmPut(ConfirmPutReq) returns(ConfirmPutResp);
|
||||||
|
|
||||||
rpc GetSignalInvitationInfo(GetSignalInvitationInfoReq) returns(GetSignalInvitationInfoResp);
|
rpc GetSignalInvitationInfo(GetSignalInvitationInfoReq) returns(GetSignalInvitationInfoResp);
|
||||||
rpc GetSignalInvitationInfoStartApp(GetSignalInvitationInfoStartAppReq) returns(GetSignalInvitationInfoStartAppResp);
|
rpc GetSignalInvitationInfoStartApp(GetSignalInvitationInfoStartAppReq) returns(GetSignalInvitationInfoStartAppResp);
|
||||||
rpc FcmUpdateToken(FcmUpdateTokenReq) returns(FcmUpdateTokenResp);
|
rpc FcmUpdateToken(FcmUpdateTokenReq) returns(FcmUpdateTokenResp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user