about summary refs log tree commit diff
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-10-12 21:26:58 -0500
committermultiple creatures <dev@multiple-creature.party>2019-10-12 21:26:58 -0500
commitbc04de8eed0cf0451018f3182af0a24754444f86 (patch)
tree253d9fd44b0bfadd7e0c14e6cbd8bf587c495eb8
parent85494ce21a39f9d4dc58d06448822a13901db7bf (diff)
add `parent:refetch` and `thread:refetch` bangtags allowing folks to have monsterfork fetch missing post or thread media
-rw-r--r--app/lib/bangtags.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb
index a16d6ca6e..7a82ba177 100644
--- a/app/lib/bangtags.rb
+++ b/app/lib/bangtags.rb
@@ -351,6 +351,13 @@ class Bangtags
               roar.save
               Rails.cache.delete("statuses/#{roar.id}")
             end
+          when 'fetch', 'refetch'
+            next if status.conversation_id.nil?
+            Status.where(conversation_id: status.conversation_id).pluck(:id).uniq.each do |acct_id|
+              FetchAvatarWorker.perform_async(acct_id)
+            end
+            media_ids = Status.where(conversation_id: status.conversation_id).joins(:media_attachments).distinct(:id).pluck(:id)
+            BatchFetchMediaWorker.perform_async(media_ids) unless media_ids.empty?
           end
         when 'parent'
           chunk = nil
@@ -399,6 +406,11 @@ class Bangtags
             @parent_status.curated = true
             @parent_status.save
             FanOutOnWriteService.new.call(@parent_status)
+          when 'fetch', 'refetch'
+            chunk = nil
+            media_ids = @parent_status.media_attachments.pluck(:id)
+            BatchFetchMediaWorker.perform_async(media_ids) unless media_ids.empty?
+            FetchAvatarWorker.perform_async(@parent_status.account.id)
           end
         when 'media'
           chunk = nil