@ -163,11 +166,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
end
end
defprocess_inline_images
defprocess_inline_images
proc=proc{|name|Rails.logger.debugname}
handler=TextHandler.new
handler=Handler.new(proc)
Ox.sax_parse(handler,@object['content'])
Ox.sax_parse(handler,@object['content'])
handler.srcs.eachdo|src|
handler.srcs.eachdo|src|
# Handle images where the src is formatted as "/foo/bar.png"
# Handle images where the src is formatted as "/foo/bar.biz"
# we assume that the `url` field is populated which lets us infer
# we assume that the `url` field is populated which lets us infer
# the protocol and domain of the _original_ article, as though
# the protocol and domain of the _original_ article, as though
# we were looking at it via a web browser
# we were looking at it via a web browser
@ -176,11 +178,15 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
src=site+src
src=site+src
end
end
# if media is set to reject from this domain, replace the src with an empty string
ifskip_download?
ifskip_download?
@object['content'].gsub!(src,'')
@object['content'].gsub!(src,'')
next
next
end
end
# Create a local proxy media file for each image in the post
# TODO: what about <video> or <audio> elements? should we handle them?
# TODO: is there a max number of images we should be handling? maybe if there's more than that or there is just too much rich media, we should not render the post at all and do a converted stub?