Opt: gen current movie type and resp movie list hide url

pull/31/head
zijiren233 3 years ago
parent 5c39296f96
commit a653974862

@ -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
}

@ -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)
}

Loading…
Cancel
Save