diff options
author | pdp8 <pdp8@pdp8.info> | 2023-07-24 02:46:05 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-07-24 02:46:05 +0200 |
commit | a509c55faca368709044133199f71fb862b1e605 (patch) | |
tree | 9c53d06a4f26e6ccf8635278b8eb56c4a62403f3 /server.rb | |
parent | 3c38f81b8a145778d4329c6be4c91baa00ca0d48 (diff) |
html output removed
Diffstat (limited to 'server.rb')
-rw-r--r-- | server.rb | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -12,7 +12,7 @@ post '/inbox' do halt 400 end halt 501 if @activity['actor'] and @activity['type'] == 'Delete' # deleted actors return 403 => verification error - verify! # unless type == :accept # pixelfed sends unsigned accept activities??? + # verify! # pixelfed sends unsigned activities??? save_activity(@activity, INBOX) type = @activity['type'].downcase.to_sym send(type) if %i[create announce follow accept undo].include? type @@ -20,6 +20,14 @@ post '/inbox' do end # public +get '/' do + redirect 'https://pdp8.info' +end + +get '/pdp8', provides: 'html' do + redirect 'https://pdp8.info' +end + get '/.well-known/webfinger' do halt 404 unless request['resource'] == "acct:#{MENTION}" send_file(WEBFINGER, type: 'application/jrd+json') @@ -39,7 +47,7 @@ helpers do def create @object ||= @activity['object'] @object = save_object @object, INBOX - return unless @object['inReplyTo'] + return unless @object and @object['inReplyTo'] @object = @object['inReplyTo'] create @@ -133,12 +141,12 @@ helpers do inboxes.compact.uniq.each do |inbox| uri = URI(inbox) httpdate = Time.now.utc.httpdate - string = "(request-target): post #{uri.request_uri}\nhost: #{uri.host}\ndate: #{httpdate}\ndigest: #{digest}\ncontent-type: application/activity+json" + string = "(request-target): post #{uri.request_uri}\nhost: #{uri.host}\ndate: #{httpdate}\ndigest: #{digest}\ncontent-type: #{CONTENT_TYPE}" signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest.new('SHA256'), string)) signed_header = "keyId=\"#{ACTOR}#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) host date digest content-type\",signature=\"#{signature}\"" curl( - "-X POST -H 'Content-Type: application/activity+json' -H 'Host: #{uri.host}' -H 'Date: #{httpdate}' -H 'Digest: #{digest}' -H 'Signature: #{signed_header}' -d '#{body}'", inbox + "-X POST -H 'Host: #{uri.host}' -H 'Date: #{httpdate}' -H 'Digest: #{digest}' -H 'Signature: #{signed_header}' --data-binary '#{body}'", inbox ) end activity |