diff --git a/internal/api/third.go b/internal/api/third.go index 2bd07fbb1..6e95b72e5 100644 --- a/internal/api/third.go +++ b/internal/api/third.go @@ -2,7 +2,6 @@ package api import ( "context" - "fmt" "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/constant" @@ -11,6 +10,7 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/errs" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third" "github.com/gin-gonic/gin" + "math/rand" "net/http" "strconv" ) @@ -70,20 +70,18 @@ func (o *Third) GetURL(c *gin.Context) { a2r.Call(third.ThirdClient.GetUrl, o.client, c) return } - operationID := c.Query("operationID") - if operationID == "" { - c.String(http.StatusBadRequest, "operationID is empty") - return - } name := c.Query("name") if name == "" { c.String(http.StatusBadRequest, "name is empty") 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 + operationID := c.Query("operationID") + if operationID == "" { + operationID = "auto_" + strconv.Itoa(rand.Int()) + } + expires, _ := strconv.ParseInt(c.Query("expires"), 10, 64) + if expires <= 0 { + expires = 3600 * 1000 } attachment, _ := strconv.ParseBool(c.Query("attachment")) client, err := o.client()