This commit is contained in:
withchao 2023-03-29 18:48:07 +08:00
parent 12b19bdf64
commit 267cfe24ce

View File

@ -2,7 +2,6 @@ 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/constant"
@ -11,6 +10,7 @@ import (
"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"
"math/rand"
"net/http" "net/http"
"strconv" "strconv"
) )
@ -70,20 +70,18 @@ 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) operationID := c.Query("operationID")
if err != nil { if operationID == "" {
c.String(http.StatusBadRequest, fmt.Sprintf("expires is invalid: %s", err.Error())) operationID = "auto_" + strconv.Itoa(rand.Int())
return }
expires, _ := strconv.ParseInt(c.Query("expires"), 10, 64)
if expires <= 0 {
expires = 3600 * 1000
} }
attachment, _ := strconv.ParseBool(c.Query("attachment")) attachment, _ := strconv.ParseBool(c.Query("attachment"))
client, err := o.client() client, err := o.client()