mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-24 14:27:58 -05:00
Links: allow re-queuing for scrape if unsuccessful
If the scrape of a link fails for some reason, this will add a "retry thumb" button to the link, which will re-add it to the queue to try again. This will appear to similar people as the "nsfw" button - either mods of the subreddit, the submitter, or the sponsor for a promoted link.
This commit is contained in:
@@ -73,7 +73,7 @@ class MessageQueue(object):
|
||||
|
||||
def declare_queues(g):
|
||||
queues = Queues({
|
||||
"scraper_q": MessageQueue(),
|
||||
"scraper_q": MessageQueue(bind_to_self=True),
|
||||
"newcomments_q": MessageQueue(),
|
||||
"commentstree_q": MessageQueue(bind_to_self=True),
|
||||
"commentstree_fastlane_q": MessageQueue(bind_to_self=True),
|
||||
|
||||
@@ -1171,6 +1171,17 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
# flag search indexer that something has changed
|
||||
changed(thing)
|
||||
|
||||
@noresponse(VUser(),
|
||||
VModhash(),
|
||||
VSrCanAlter('id'),
|
||||
thing=VByName('id'))
|
||||
def POST_rescrape(self, thing):
|
||||
"""Re-queues the link in the media scraper."""
|
||||
if not isinstance(thing, Link):
|
||||
return
|
||||
|
||||
amqp.add_item("scraper_q", thing._fullname)
|
||||
|
||||
@require_oauth2_scope("modposts")
|
||||
@validatedForm(VUser(),
|
||||
VModhash(),
|
||||
|
||||
@@ -36,7 +36,7 @@ class PrintableButtons(Styled):
|
||||
show_delete = False, show_report = True,
|
||||
show_distinguish = False, show_marknsfw = False,
|
||||
show_unmarknsfw = False, is_link=False,
|
||||
show_flair = False, **kw):
|
||||
show_flair = False, show_rescrape=False, **kw):
|
||||
show_ignore = thing.show_reports
|
||||
approval_checkmark = getattr(thing, "approval_checkmark", None)
|
||||
show_approve = (thing.show_spam or show_ignore or
|
||||
@@ -57,6 +57,7 @@ class PrintableButtons(Styled):
|
||||
show_marknsfw = show_marknsfw,
|
||||
show_unmarknsfw = show_unmarknsfw,
|
||||
show_flair = show_flair,
|
||||
show_rescrape=show_rescrape,
|
||||
**kw)
|
||||
|
||||
class BanButtons(PrintableButtons):
|
||||
@@ -76,12 +77,17 @@ class LinkButtons(PrintableButtons):
|
||||
show_report = False
|
||||
|
||||
show_marknsfw = show_unmarknsfw = False
|
||||
show_rescrape = False
|
||||
if thing.can_ban or is_author or (thing.promoted and c.user_is_sponsor):
|
||||
if not thing.nsfw:
|
||||
show_marknsfw = True
|
||||
elif thing.nsfw and not thing.nsfw_str:
|
||||
show_unmarknsfw = True
|
||||
|
||||
if (not thing.is_self and
|
||||
not (thing.has_thumbnail or thing.media_object)):
|
||||
show_rescrape = True
|
||||
|
||||
# do we show the delete button?
|
||||
show_delete = is_author and delete and not thing._deleted
|
||||
# disable the delete button for live sponsored links
|
||||
@@ -125,6 +131,7 @@ class LinkButtons(PrintableButtons):
|
||||
show_marknsfw = show_marknsfw,
|
||||
show_unmarknsfw = show_unmarknsfw,
|
||||
show_flair = thing.can_flair,
|
||||
show_rescrape=show_rescrape,
|
||||
show_comments = comments,
|
||||
# promotion
|
||||
promoted = thing.promoted,
|
||||
|
||||
@@ -71,6 +71,9 @@
|
||||
</form>
|
||||
</li>
|
||||
%endif
|
||||
%if thing.show_rescrape:
|
||||
<li>${ynbutton(_("retry thumb"), _("retrying"), "rescrape")}</li>
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="distinguish_setter(name, value=None)">
|
||||
|
||||
Reference in New Issue
Block a user