|
|
@ -2,13 +2,17 @@ package api
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var _ context.Context // 解决goland编辑器bug
|
|
|
|
var _ context.Context // 解决goland编辑器bug
|
|
|
@ -62,17 +66,28 @@ func (o *Third) GetURL(c *gin.Context) {
|
|
|
|
a2r.Call(third.ThirdClient.GetUrl, o.client, c)
|
|
|
|
a2r.Call(third.ThirdClient.GetUrl, o.client, c)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
operationID := c.Query("operationID")
|
|
|
|
|
|
|
|
if operationID == "" {
|
|
|
|
|
|
|
|
c.String(http.StatusBadRequest, "operationID is empty")
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
name := c.Query("name")
|
|
|
|
name := c.Query("name")
|
|
|
|
if name == "" {
|
|
|
|
if name == "" {
|
|
|
|
c.String(http.StatusBadRequest, "name is empty")
|
|
|
|
c.String(http.StatusBadRequest, "name is empty")
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expires, err := strconv.ParseInt(c.Query("expires"), 10, 64)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
c.String(http.StatusBadRequest, fmt.Sprintf("expires is invalid: %s", err.Error()))
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
client, err := o.client()
|
|
|
|
client, err := o.client()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
c.String(http.StatusInternalServerError, err.Error())
|
|
|
|
c.String(http.StatusInternalServerError, err.Error())
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resp, err := client.GetUrl(c, &third.GetUrlReq{Name: name})
|
|
|
|
c.Set(constant.OperationID, operationID)
|
|
|
|
|
|
|
|
resp, err := client.GetUrl(mcontext.SetOperationID(c, operationID), &third.GetUrlReq{Name: name, Expires: expires})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if errs.ErrArgs.Is(err) {
|
|
|
|
if errs.ErrArgs.Is(err) {
|
|
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
|
|
c.String(http.StatusBadRequest, err.Error())
|
|
|
|