diff options
Diffstat (limited to 'activitypub.rb')
-rw-r--r-- | activitypub.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/activitypub.rb b/activitypub.rb index 05ed6e0..ab42c4f 100644 --- a/activitypub.rb +++ b/activitypub.rb @@ -20,6 +20,10 @@ ACCOUNT = "#{USER}@#{SOCIAL_DOMAIN}" SOCIAL_URL = "https://#{SOCIAL_DOMAIN}" ACTOR = File.join(SOCIAL_URL, USER) +#OpenSSL::SSL::SSLContext::DEFAULT_PARAMS = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS.merge( + #options: OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options] + OpenSSL::SSL::OP_IGNORE_UNEXPECTED_EOF +#).freeze + enable :sessions set :session_secret, File.read(".secret").chomp set :default_content_type, 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' @@ -34,7 +38,7 @@ end post "/inbox" do # server-server request.body.rewind # in case someone already read it body = request.body.read - p body + #p body action = JSON.parse body case action["type"] @@ -55,7 +59,7 @@ post "/inbox" do # server-server "id" => File.join(SOCIAL_URL + "#accepts", SecureRandom.uuid), "type" => "Accept", "actor" => ACTOR, - "object" => action["object"] } + "object" => action } send_signed accept, action["actor"] when "Undo" @@ -67,8 +71,8 @@ post "/inbox" do # server-server end end - else - p body + #else + #p body end end @@ -77,7 +81,7 @@ post "/outbox" do # client-server request.body.rewind # in case someone already read it body = request.body.read date = Time.now.strftime("%Y-%m-%dT%H:%M:%S") - # TODO media attachments, hashtags + # TODO hashtags, replys outbox_path = File.join("public/outbox", date + ".json") object_path = File.join("public/objects", date + ".json") create = { @@ -126,7 +130,6 @@ post "/follow/*" do protected! mention = params['splat'][0] actor = actor(mention) - p actor following_path = File.join("public", "following", mention + ".json") follow = { "@context" => "https://www.w3.org/ns/activitystreams", "id" => File.join(SOCIAL_URL, following_path), @@ -171,7 +174,6 @@ end get "/inbox", :provides => 'html' do protected! @inbox = Dir['./inbox/*'].sort - p @inbox erb :inbox end @@ -250,13 +252,11 @@ def send_signed object, url request = Net::HTTP::Post.new(uri.request_uri, header) request.body = body + p uri, body http.request(request) end def inbox uri - p "INBOX" - p uri - p get(uri) URI(get(uri)["inbox"]).request_uri end |