diff --git a/r2/r2/config/queues.py b/r2/r2/config/queues.py index cccd9012d..a00c5b333 100644 --- a/r2/r2/config/queues.py +++ b/r2/r2/config/queues.py @@ -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), diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index a6a49c2a5..508589e48 100755 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -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(), diff --git a/r2/r2/lib/pages/things.py b/r2/r2/lib/pages/things.py index 3fba9b211..a084c86e4 100644 --- a/r2/r2/lib/pages/things.py +++ b/r2/r2/lib/pages/things.py @@ -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, diff --git a/r2/r2/templates/printablebuttons.html b/r2/r2/templates/printablebuttons.html index 420130f6c..53d8daebb 100644 --- a/r2/r2/templates/printablebuttons.html +++ b/r2/r2/templates/printablebuttons.html @@ -71,6 +71,9 @@ %endif + %if thing.show_rescrape: +
  • ${ynbutton(_("retry thumb"), _("retrying"), "rescrape")}
  • + %endif <%def name="distinguish_setter(name, value=None)">