Skip to content

Commit

Permalink
AtpRemoteBlob.get_or_create: stop checking mime type
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Oct 2, 2024
1 parent 918a712 commit 7c71feb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions atproto.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,10 @@ def _convert(cls, obj, fetch_blobs=False, from_user=None):

blobs = {} # maps str URL to dict blob object
if fetch_blobs:
def fetch_blob(url, blob_field, name, check_size=True):
def fetch_blob(url, blob_field, name, check_size=True, check_type=True):
if url and url not in blobs:
max_size = blob_field[name].get('maxSize') if check_size else None
accept = blob_field[name].get('accept')
accept = blob_field[name].get('accept') if check_type else None
try:
blob = AtpRemoteBlob.get_or_create(
url=url, get_fn=util.requests_get, max_size=max_size,
Expand All @@ -753,19 +753,19 @@ def fetch_blob(url, blob_field, name, check_size=True):

for o in obj.as1, as1.get_object(obj.as1):
for url in util.get_urls(o, 'image'):
# TODO: maybe eventually check size? the current
# TODO: maybe eventually check size and type? the current
# 1MB limit feels too small though, and the AppView doesn't
# seem to validate, it's happily allowing bigger image blobs
# as of 9/29/2024:
# and different types as of 9/29/2024:
# https://github.com/snarfed/bridgy-fed/issues/1348#issuecomment-2381056468
fetch_blob(url, appview.defs['app.bsky.embed.images#image']['properties'],
name='image', check_size=False)
name='image', check_size=False, check_type=False)

for att in util.get_list(o, 'attachments'):
if isinstance(att, dict):
fetch_blob(att.get('stream', {}).get('url'),
appview.defs['app.bsky.embed.video']['properties'],
name='video')
name='video', check_size=True, check_type=True)

inner_obj = as1.get_object(obj.as1) or obj.as1
orig_url = as1.get_url(inner_obj) or inner_obj.get('id')
Expand Down

0 comments on commit 7c71feb

Please sign in to comment.