summaryrefslogtreecommitdiff
path: root/helpers.rb
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2024-02-01 12:23:31 +0100
committerpdp8 <pdp8@pdp8.info>2024-02-01 12:23:31 +0100
commit4586c63bd86fe3dad403086b15d5b74b6d67fc92 (patch)
tree41387860e635820738f27071a2d668212d1774d7 /helpers.rb
parent17fe7f0d25bc99285ddc3dbc153f1f3af9dca335 (diff)
general outbox routes
Diffstat (limited to 'helpers.rb')
-rw-r--r--helpers.rb15
1 files changed, 5 insertions, 10 deletions
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)