Skip to content

Commit 567af84

Browse files
committed
add settings.UI.ReactionsMap
so if !setting.UI.ReactionsMap[opts.Type] works
1 parent 76c1758 commit 567af84

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

models/issue_reaction.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
"code.gitea.io/gitea/modules/setting"
1212
"code.gitea.io/gitea/modules/timeutil"
13-
"code.gitea.io/gitea/modules/util"
1413

1514
"xorm.io/builder"
1615
"xorm.io/xorm"
@@ -100,7 +99,7 @@ type ReactionOptions struct {
10099

101100
// CreateReaction creates reaction for issue or comment.
102101
func CreateReaction(opts *ReactionOptions) (reaction *Reaction, err error) {
103-
if !util.IsStringInSlice(opts.Type, setting.UI.Reactions) {
102+
if !setting.UI.ReactionsMap[opts.Type] {
104103
return nil, ErrForbiddenIssueReaction{opts.Type}
105104
}
106105

modules/setting/setting.go

+6
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ var (
171171
DefaultTheme string
172172
Themes []string
173173
Reactions []string
174+
ReactionsMap map[string]bool
174175
SearchRepoDescription bool
175176
UseServiceWorker bool
176177

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

987988
zip.Verbose = false
989+
990+
UI.ReactionsMap = make(map[string]bool)
991+
for _, reaction := range UI.Reactions {
992+
UI.ReactionsMap[reaction] = true
993+
}
988994
}
989995

990996
func loadInternalToken(sec *ini.Section) string {

0 commit comments

Comments
 (0)