summaryrefslogtreecommitdiff
path: root/client.rb
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2023-05-19 22:50:54 +0200
committerpdp8 <pdp8@pdp8.info>2023-05-19 22:50:54 +0200
commitd2c4d3b49e6b790d14f6dcb94c2ae0641559d2cf (patch)
tree09148e8d81e4686a9c969bb74b3f4f6fc9325f79 /client.rb
parentd523ce8d4fe4e852944331eb0c300d309641c057 (diff)
follow and followers
Diffstat (limited to 'client.rb')
-rwxr-xr-xclient.rb72
1 files changed, 0 insertions, 72 deletions
diff --git a/client.rb b/client.rb
deleted file mode 100755
index 0ef2896..0000000
--- a/client.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env ruby
-# TODO
-# run as service
-# client post md
-# direct from client (key)
-# via server (auth)
-require 'json'
-require 'net/http'
-require 'uri'
-require 'base64'
-require 'securerandom'
-require 'fileutils'
-require 'digest/sha2'
-
-USER = "pdp8"
-WWW_DOMAIN = "pdp8.info"
-WWW_URL = "https://#{WWW_DOMAIN}"
-SOCIAL_DOMAIN = "social.#{WWW_DOMAIN}"
-
-ACCOUNT = "#{USER}@#{SOCIAL_DOMAIN}"
-SOCIAL_URL = "https://#{SOCIAL_DOMAIN}"
-ACTOR = File.join(SOCIAL_URL, USER)
-
-=begin
-MATRIX = "@#{USER}:matrix.#{WWW_DOMAIN}"
-
-post = {
- "@context" => "https://www.w3.org/ns/activitystreams",
- "type" => "Note",
- "content" => ""
-}
-
-def webfinger account
- account = account.sub(/^@/, '').chomp
- user, server = account.split("@")
- header = { 'Accept' => "application/jrd+json" }
- uri = URI("https://" + server + "/.well-known/webfinger?resource=acct:#{account}")
- http = Net::HTTP.new(uri.host, uri.port)
- http.use_ssl = true
- request = Net::HTTP::Get.new(uri.request_uri, header)
- response = http.request(request)
- JSON.parse(response.body)["links"].select { |l| l["rel"] == "self" }[0]["href"]
-end
-
-ARGF.each do |line|
- if /^(To|Cc|Bcc):/.match line
- dest, addresses = line.split(/: */)
- dest = dest.downcase
- post[dest] ||= []
- addresses.split(/, */).each do |add|
- post[dest] << webfinger(add.chomp)
- end
- else
- post["content"] << line
- end
-end
-=end
-
-uri = URI.parse(File.join SOCIAL_URL, "outbox")
-http = Net::HTTP.new(uri.host, uri.port)
-http.use_ssl = true
-header = { 'Content-Type' => 'text/plain' }
-# header = { 'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' }
-request = Net::HTTP::Post.new(uri.request_uri, header)
-usr = File.read(".usr").chomp
-pwd = File.read(".pwd").chomp
-request.basic_auth(usr, pwd)
-request.body = File.read ARGV[0]
-
-response = http.request(request)
-# TODO return error if response.code > 400
-puts(response.body, response.code)