aboutsummaryrefslogtreecommitdiff
path: root/deliver.rb
diff options
context:
space:
mode:
authorAnthony Wang2022-07-11 15:12:46 -0500
committerAnthony Wang2022-07-11 15:12:46 -0500
commit41223c10be83f0feafc17e18955780d3e97b1cb1 (patch)
treeec6cc813bc54d4585ab856accd61d850d29bc135 /deliver.rb
parent964d4ff5a063ce1e84912faab2a70fdb1281df6c (diff)
Add Ruby script for delivering AS payload
Diffstat (limited to 'deliver.rb')
-rw-r--r--deliver.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/deliver.rb b/deliver.rb
new file mode 100644
index 0000000..3a46051
--- /dev/null
+++ b/deliver.rb
@@ -0,0 +1,14 @@
+# https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/
+
+require 'http'
+require 'openssl'
+
+document = File.read('message')
+date = Time.now.utc.httpdate
+keypair = OpenSSL::PKey::RSA.new(File.read('private.pem'))
+signed_string = "(request-target): post /inbox\nhost: git.exozy.me\ndate: #{date}"
+signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest::SHA256.new, signed_string))
+header = 'keyId="https://test.exozy.me/api/v1/activitypub/user/test#main-key",headers="(request-target) host date",signature="' + signature + '"'
+
+HTTP.headers({ 'Host': 'mastodon.social', 'Date': date, 'Signature': header })
+ .post('https://git.exozy.me/api/v1/activitypub/user/Ta180m/inbox', body: document)