mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-17 07:19:02 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
This commit is contained in:
@@ -111,6 +111,9 @@ func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry) *gin.Engine {
|
||||
thirdGroup.POST("/apply_put", t.ApplyPut)
|
||||
thirdGroup.POST("/get_put", t.GetPut)
|
||||
thirdGroup.POST("/confirm_put", t.ConfirmPut)
|
||||
thirdGroup.GET("/get_url", t.GetURL)
|
||||
thirdGroup.GET("/object", t.GetURL)
|
||||
|
||||
}
|
||||
////Message
|
||||
chatGroup := r.Group("/msg")
|
||||
|
||||
+33
-1
@@ -4,10 +4,11 @@ import (
|
||||
"OpenIM/internal/api/a2r"
|
||||
"OpenIM/pkg/common/config"
|
||||
"OpenIM/pkg/discoveryregistry"
|
||||
"OpenIM/pkg/errs"
|
||||
"OpenIM/pkg/proto/third"
|
||||
"context"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var _ context.Context // 解决goland编辑器bug
|
||||
@@ -55,3 +56,34 @@ func (o *Third) FcmUpdateToken(c *gin.Context) {
|
||||
func (o *Third) SetAppBadge(c *gin.Context) {
|
||||
a2r.Call(third.ThirdClient.SetAppBadge, o.client, c)
|
||||
}
|
||||
|
||||
func (o *Third) GetURL(c *gin.Context) {
|
||||
if c.Request.Method == http.MethodPost {
|
||||
a2r.Call(third.ThirdClient.GetUrl, o.client, c)
|
||||
return
|
||||
}
|
||||
name := c.Query("name")
|
||||
if name == "" {
|
||||
c.String(http.StatusBadRequest, "name is empty")
|
||||
return
|
||||
}
|
||||
client, err := o.client()
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := client.GetUrl(c, &third.GetUrlReq{Name: name})
|
||||
if err != nil {
|
||||
if errs.ErrArgs.Is(err) {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
if errs.ErrRecordNotFound.Is(err) {
|
||||
c.String(http.StatusNotFound, err.Error())
|
||||
return
|
||||
}
|
||||
c.String(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
c.Redirect(http.StatusTemporaryRedirect, resp.Url)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package third
|
||||
|
||||
import (
|
||||
"OpenIM/pkg/common/tokenverify"
|
||||
"OpenIM/pkg/proto/third"
|
||||
"context"
|
||||
"time"
|
||||
@@ -18,6 +19,15 @@ func (t *thirdServer) ConfirmPut(ctx context.Context, req *third.ConfirmPutReq)
|
||||
return t.s3dataBase.ConfirmPut(ctx, req)
|
||||
}
|
||||
|
||||
func (t *thirdServer) GetUrl(ctx context.Context, req *third.GetUrlReq) (*third.GetUrlResp, error) {
|
||||
if req.Expires <= 0 {
|
||||
if err := tokenverify.CheckAdmin(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return t.s3dataBase.GetUrl(ctx, req)
|
||||
}
|
||||
|
||||
func (t *thirdServer) CleanObject(ctx context.Context, now time.Time) {
|
||||
t.s3dataBase.CleanExpirationObject(ctx, now)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user