From 4586c63bd86fe3dad403086b15d5b74b6d67fc92 Mon Sep 17 00:00:00 2001 From: pdp8 Date: Thu, 1 Feb 2024 12:23:31 +0100 Subject: general outbox routes --- helpers.rb | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'helpers.rb') diff --git a/helpers.rb b/helpers.rb index 09b0d42..292c71d 100644 --- a/helpers.rb +++ b/helpers.rb @@ -162,7 +162,7 @@ helpers do a = fetch(actor) return nil unless a - mention = "#{a['preferredUsername']}@#{URI(actor).host}" + mention = "@#{a['preferredUsername']}@#{URI(actor).host}" cache mention, actor, a mention else @@ -171,11 +171,12 @@ helpers do end def actor(mention) - mention = mention.sub(/^@/, '').chomp + mention = mention.chomp actors = people.select { |p| p[0] == mention } if actors.empty? - _, server = mention.split('@') - a = fetch("https://#{server}/.well-known/webfinger?resource=acct:#{mention}", 'application/jrd+json') + server = mention.split('@').last + a = fetch("https://#{server}/.well-known/webfinger?resource=acct:#{mention.sub(/^@/, '')}", + 'application/jrd+json') return nil unless a actor = a['links'].select do |l| @@ -208,12 +209,6 @@ helpers do "#{type[0]}/#{ext}" end - # def find_file(id) - # Dir[File.join('*', 'object', '*', '*.json')].find do |f| - # JSON.load_file(f)['id'] == id - # end - # end - def find_object(id) Dir[File.join('*', '**', '*.json')].each do |file| object = JSON.load_file(file) -- cgit v1.2.3