Skip to content

Commit 821570c

Browse files
a1012112796zeripathlafriks
authored
Fix to allow comment poster to edit or delete his own comments (#11671) (#11774)
* bug: fix comment update permision check No the ui only allow poster to update or delet comment, which is not reasonable and different with handle logic, this pr change it to allow poster of comment do it ref code: https://github.com/go-gitea/gitea/blob/e8955173a9be1acaa9a3755c37b6059422acda20/routers/repo/issue.go#L1636 https://github.com/go-gitea/gitea/blob/e8955173a9be1acaa9a3755c37b6059422acda20/routers/repo/issue.go#L1681 fix #11663 Signed-off-by: a1012112796 <[email protected]> * simplify code * fix sign in Co-authored-by: zeripath <[email protected]> Co-authored-by: Lauris BH <[email protected]> Co-authored-by: zeripath <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent 287e2c7 commit 821570c

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

templates/repo/diff/comments.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
{{end}}
3232
{{end}}
3333
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) }}
34-
{{template "repo/issue/view_content/context_menu" Dict "ctx" $.root "item" . "delete" true "diff" true }}
34+
{{template "repo/issue/view_content/context_menu" Dict "ctx" $.root "item" . "delete" true "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}}
3535
</div>
3636
</div>
3737
<div class="ui attached segment">

templates/repo/issue/view_content.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
{{if not $.Repository.IsArchived}}
4242
<div class="ui right actions">
4343
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}}
44-
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "diff" false }}
44+
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "diff" false "IsCommentPoster" $.IsIssuePoster}}
4545
</div>
4646
{{end}}
4747
</div>

templates/repo/issue/view_content/comments.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</div>
3939
{{end}}
4040
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
41-
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "diff" false }}
41+
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}}
4242
</div>
4343
{{end}}
4444
</div>

templates/repo/issue/view_content/context_menu.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="item context clipboard" data-clipboard-text="{{Printf "%s%s/issues/%d#%s" AppUrl .ctx.Repository.FullName .ctx.Issue.Index .item.HashTag}}">{{.ctx.i18n.Tr "repo.issues.context.copy_link"}}</div>
1111
{{end}}
1212
<div class="item context quote-reply {{if .diff}}quote-reply-diff{{end}}" data-target="{{.item.ID}}">{{.ctx.i18n.Tr "repo.issues.context.quote_reply"}}</div>
13-
{{if or .ctx.Permission.IsAdmin .ctx.IsIssuePoster .ctx.HasIssuesOrPullsWritePermission}}
13+
{{if or .ctx.Permission.IsAdmin .IsCommentPoster .ctx.HasIssuesOrPullsWritePermission}}
1414
<div class="divider"></div>
1515
<div class="item context edit-content">{{.ctx.i18n.Tr "repo.issues.context.edit"}}</div>
1616
{{if .delete}}

0 commit comments

Comments
 (0)