diff --git a/server/handlers/movie.go b/server/handlers/movie.go index ec28c22..8a2464b 100644 --- a/server/handlers/movie.go +++ b/server/handlers/movie.go @@ -81,7 +81,7 @@ func MovieList(ctx *gin.Context) { Creator: op.GetUserName(v.Movie.CreatorID), } // hide url and headers when proxy - if mresp[i].Base.Proxy { + if user.ID != v.Movie.CreatorID && v.Movie.Base.Proxy { mresp[i].Base.Url = "" mresp[i].Base.Headers = nil } @@ -112,6 +112,9 @@ func genCurrentResp(current *op.Current) *model.CurrentMovieResp { Creator: op.GetUserName(current.Movie.Movie.CreatorID), }, } + if c.Movie.Base.Type == "" && c.Movie.Base.Url != "" { + c.Movie.Base.Type = utils.GetUrlExtension(c.Movie.Base.Url) + } // hide url and headers when proxy if c.Movie.Base.Proxy { c.Movie.Base.Url = "" @@ -139,7 +142,7 @@ func CurrentMovie(ctx *gin.Context) { func Movies(ctx *gin.Context) { room := ctx.MustGet("room").(*op.Room) - // user := ctx.MustGet("user").(*op.User) + user := ctx.MustGet("user").(*op.User) page, max, err := GetPageAndPageSize(ctx) if err != nil { @@ -157,7 +160,7 @@ func Movies(ctx *gin.Context) { Creator: op.GetUserName(v.Movie.CreatorID), } // hide url and headers when proxy - if mresp[i].Base.Proxy { + if user.ID != v.Movie.CreatorID && v.Movie.Base.Proxy { mresp[i].Base.Url = "" mresp[i].Base.Headers = nil } diff --git a/utils/utils.go b/utils/utils.go index cbfd18d..9054e7d 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -298,3 +298,14 @@ func MapToHttpCookie(m map[string]string) []*http.Cookie { } return c } + +func GetUrlExtension(u string) string { + if u == "" { + return "" + } + p, err := url.Parse(u) + if err != nil { + return "" + } + return filepath.Ext(p.Path) +}