Skip to content

Commit

Permalink
add settings.UI.ReactionsMap
Browse files Browse the repository at this point in the history
so if !setting.UI.ReactionsMap[opts.Type] works
  • Loading branch information
6543 committed Dec 7, 2019
1 parent 76c1758 commit 567af84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions models/issue_reaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"

"xorm.io/builder"
"xorm.io/xorm"
Expand Down Expand Up @@ -100,7 +99,7 @@ type ReactionOptions struct {

// CreateReaction creates reaction for issue or comment.
func CreateReaction(opts *ReactionOptions) (reaction *Reaction, err error) {
if !util.IsStringInSlice(opts.Type, setting.UI.Reactions) {
if !setting.UI.ReactionsMap[opts.Type] {
return nil, ErrForbiddenIssueReaction{opts.Type}
}

Expand Down
6 changes: 6 additions & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ var (
DefaultTheme string
Themes []string
Reactions []string
ReactionsMap map[string]bool
SearchRepoDescription bool
UseServiceWorker bool

Expand Down Expand Up @@ -985,6 +986,11 @@ func NewContext() {
U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimRight(AppURL, "/"))

zip.Verbose = false

UI.ReactionsMap = make(map[string]bool)
for _, reaction := range UI.Reactions {
UI.ReactionsMap[reaction] = true
}
}

func loadInternalToken(sec *ini.Section) string {
Expand Down

0 comments on commit 567af84

Please sign in to comment.