Config.NoEmbed should override user preferences.

This commit is contained in:
Azareal 2020-06-29 21:40:52 +10:00
parent c4f2f0df90
commit 5ac7739648
3 changed files with 10 additions and 10 deletions

View File

@ -634,7 +634,7 @@ func (ru *ReplyUser) Init2() (group *Group, err error) {
postGroup, err := Groups.Get(ru.Group) postGroup, err := Groups.Get(ru.Group)
if err != nil { if err != nil {
return nil, err return postGroup, err
} }
if postGroup.IsMod { if postGroup.IsMod {
ru.ClassName = Config.StaffCSS ru.ClassName = Config.StaffCSS
@ -679,7 +679,7 @@ func (ru *ReplyUser) Init3(u *User, tu *TopicUser) (group *Group, err error) {
postGroup, err := Groups.Get(ru.Group) postGroup, err := Groups.Get(ru.Group)
if err != nil { if err != nil {
return nil, err return postGroup, err
} }
if postGroup.IsMod { if postGroup.IsMod {
ru.ClassName = Config.StaffCSS ru.ClassName = Config.StaffCSS
@ -760,14 +760,14 @@ func (t *TopicUser) Replies(offset int /*pFrag int, */, user *User) (rlist []*Re
hTbl := GetHookTable() hTbl := GetHookTable()
rf := func(r *ReplyUser) (err error) { rf := func(r *ReplyUser) (err error) {
//log.Printf("before r: %+v\n", r) //log.Printf("before r: %+v\n", r)
group, err := r.Init3(user, t) postGroup, err := r.Init3(user, t)
if err != nil { if err != nil {
return err return err
} }
//log.Printf("after r: %+v\n", r) //log.Printf("after r: %+v\n", r)
var parseSettings *ParseSettings var parseSettings *ParseSettings
if !group.Perms.AutoEmbed && (user.ParseSettings == nil || !user.ParseSettings.NoEmbed) { if (Config.NoEmbed || !postGroup.Perms.AutoEmbed) && (user.ParseSettings == nil || !user.ParseSettings.NoEmbed) {
parseSettings = DefaultParseSettings.CopyPtr() parseSettings = DefaultParseSettings.CopyPtr()
parseSettings.NoEmbed = true parseSettings.NoEmbed = true
} else { } else {
@ -798,13 +798,13 @@ func (t *TopicUser) Replies(offset int /*pFrag int, */, user *User) (rlist []*Re
rf3 := func(r *ReplyUser) error { rf3 := func(r *ReplyUser) error {
//log.Printf("before r: %+v\n", r) //log.Printf("before r: %+v\n", r)
group, err := r.Init2() postGroup, err := r.Init2()
if err != nil { if err != nil {
return err return err
} }
var parseSettings *ParseSettings var parseSettings *ParseSettings
if !group.Perms.AutoEmbed && (user.ParseSettings == nil || !user.ParseSettings.NoEmbed) { if (Config.NoEmbed || !postGroup.Perms.AutoEmbed) && (user.ParseSettings == nil || !user.ParseSettings.NoEmbed) {
parseSettings = DefaultParseSettings.CopyPtr() parseSettings = DefaultParseSettings.CopyPtr()
parseSettings.NoEmbed = true parseSettings.NoEmbed = true
} else { } else {

View File

@ -124,7 +124,7 @@ RefNoTrack - This switch disables tracking the referrers of users who click from
RefNoRef - This switch makes it so that if a user clicks on a link, then the incoming site won't know which site they're coming from. RefNoRef - This switch makes it so that if a user clicks on a link, then the incoming site won't know which site they're coming from.
NoEmbed - Avoid expanding links into videos or images. Default: false NoEmbed - Don't expand links into videos or images. Default: false
NoAvatar - The default avatar to use for users when they don't have their own. The default for this may change in the near future to better utilise HTTP/2. Example: https://api.adorable.io/avatars/{width}/{id}.png NoAvatar - The default avatar to use for users when they don't have their own. The default for this may change in the near future to better utilise HTTP/2. Example: https://api.adorable.io/avatars/{width}/{id}.png

View File

@ -86,7 +86,7 @@ func ViewTopic(w http.ResponseWriter, r *http.Request, user *c.User, h *c.Header
} }
var parseSettings *c.ParseSettings var parseSettings *c.ParseSettings
if !postGroup.Perms.AutoEmbed && (user.ParseSettings == nil || !user.ParseSettings.NoEmbed) { if (c.Config.NoEmbed || !postGroup.Perms.AutoEmbed) && (user.ParseSettings == nil || !user.ParseSettings.NoEmbed) {
parseSettings = c.DefaultParseSettings.CopyPtr() parseSettings = c.DefaultParseSettings.CopyPtr()
parseSettings.NoEmbed = true parseSettings.NoEmbed = true
} else { } else {
@ -226,7 +226,7 @@ func AttachTopicActCommon(w http.ResponseWriter, r *http.Request, u *c.User, sti
// TODO: Enforce the max request limit on all of this topic's attachments // TODO: Enforce the max request limit on all of this topic's attachments
// TODO: Test this route // TODO: Test this route
func AddAttachToTopicSubmit(w http.ResponseWriter, r *http.Request, u *c.User, stid string) c.RouteError { func AddAttachToTopicSubmit(w http.ResponseWriter, r *http.Request, u *c.User, stid string) c.RouteError {
topic, ferr := AttachTopicActCommon(w,r,u,stid) topic, ferr := AttachTopicActCommon(w, r, u, stid)
if ferr != nil { if ferr != nil {
return ferr return ferr
} }
@ -257,7 +257,7 @@ func AddAttachToTopicSubmit(w http.ResponseWriter, r *http.Request, u *c.User, s
} }
func RemoveAttachFromTopicSubmit(w http.ResponseWriter, r *http.Request, u *c.User, stid string) c.RouteError { func RemoveAttachFromTopicSubmit(w http.ResponseWriter, r *http.Request, u *c.User, stid string) c.RouteError {
_, ferr := AttachTopicActCommon(w,r,u,stid) _, ferr := AttachTopicActCommon(w, r, u, stid)
if ferr != nil { if ferr != nil {
return ferr return ferr
} }