Prevent deleted/removed posts from being stickied

When a stickied post gets deleted or removed, it automatically gets
removed as a sticky. However, it's currently still possible to add
deleted/removed posts as stickies, even though they can't possibly show
up for anyone. This commit fixes that.
This commit is contained in:
Chad Birch
2015-12-11 10:24:46 -07:00
parent 973f4b821e
commit 007c8146d0
3 changed files with 5 additions and 1 deletions

View File

@@ -1636,6 +1636,9 @@ class ApiController(RedditController):
if not isinstance(thing, Link):
return
if thing._deleted or thing._spam:
abort(400, "Can't sticky a removed or deleted post")
sr = thing.subreddit_slow
if state:

View File

@@ -5290,6 +5290,7 @@ class LinkCommentsSettings(Templated):
(c.user_is_admin or
self.sr.is_moderator_with_perms(c.user, "posts"))
)
self.can_sticky = self.can_edit and not (link._deleted or link._spam)
self.sort = sort
self.suggested_sort = suggested_sort

View File

@@ -112,7 +112,7 @@
%endif
%endif
%if thing.can_edit:
%if thing.can_sticky:
%if thing.stickied:
${ynbutton(_("unsticky this post"), _("unstickied"), "set_subreddit_sticky",
hidden_data=dict(id=thing.link._fullname, state=False),