mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
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:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user