mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
[Feature] Custom Reactions (#8886)
* add [ui] Reactions * move contend check from form to go functions * use else if * check if reaction is allowed only on react (so previous custom reaction can be still removed) * use $.AllowedReactions in templates * use ctx.Flash.Error * use it there too * add redirection * back to server error because a wrong reaction is a template issue ... * add emoji list link * add docs entry * small wording nit suggestions from @jolheiser - thx * same reactions as github * fix PR reactions * handle error so template JS could check * Add Integrations Test * add REACTIONS setting to cheat-sheet doc page
This commit is contained in:
@@ -673,6 +673,7 @@ func ViewIssue(ctx *context.Context) {
|
||||
}
|
||||
}
|
||||
ctx.Data["IssueWatch"] = iw
|
||||
ctx.Data["AllowedReactions"] = setting.UI.Reactions
|
||||
|
||||
issue.RenderedContent = string(markdown.Render([]byte(issue.Content), ctx.Repo.RepoLink,
|
||||
ctx.Repo.Repository.ComposeMetas()))
|
||||
@@ -1447,6 +1448,12 @@ func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
|
||||
|
||||
switch ctx.Params(":action") {
|
||||
case "react":
|
||||
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
|
||||
err := fmt.Errorf("ChangeIssueReaction: '%s' is not an allowed reaction", form.Content)
|
||||
ctx.ServerError(err.Error(), err)
|
||||
return
|
||||
}
|
||||
|
||||
reaction, err := models.CreateIssueReaction(ctx.User, issue, form.Content)
|
||||
if err != nil {
|
||||
log.Info("CreateIssueReaction: %s", err)
|
||||
@@ -1542,6 +1549,12 @@ func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
|
||||
|
||||
switch ctx.Params(":action") {
|
||||
case "react":
|
||||
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
|
||||
err := fmt.Errorf("ChangeIssueReaction: '%s' is not an allowed reaction", form.Content)
|
||||
ctx.ServerError(err.Error(), err)
|
||||
return
|
||||
}
|
||||
|
||||
reaction, err := models.CreateCommentReaction(ctx.User, comment.Issue, comment, form.Content)
|
||||
if err != nil {
|
||||
log.Info("CreateCommentReaction: %s", err)
|
||||
|
Reference in New Issue
Block a user