summaryrefslogtreecommitdiff
path: root/server.rb
diff options
context:
space:
mode:
Diffstat (limited to 'server.rb')
-rw-r--r--server.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/server.rb b/server.rb
index 4fdf1e8..f337820 100644
--- a/server.rb
+++ b/server.rb
@@ -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