diff options
author | pdp8 <pdp8@pdp8.info> | 2023-05-19 22:50:54 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-05-19 22:50:54 +0200 |
commit | d2c4d3b49e6b790d14f6dcb94c2ae0641559d2cf (patch) | |
tree | 09148e8d81e4686a9c969bb74b3f4f6fc9325f79 /social | |
parent | d523ce8d4fe4e852944331eb0c300d309641c057 (diff) |
follow and followers
Diffstat (limited to 'social')
-rwxr-xr-x | social | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +require 'net/http' +require 'uri' + +USER = "pdp8" +WWW_DOMAIN = "pdp8.info" +SOCIAL_DOMAIN = "social.#{WWW_DOMAIN}" +SOCIAL_URL = "https://#{SOCIAL_DOMAIN}" + +def post path, body + uri = URI.parse(File.join SOCIAL_URL, path) + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true + header = { 'Content-Type' => 'text/plain' } + 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 = body + response = http.request(request) + # TODO return error if response.code > 400 + puts(response.body, response.code) +end + +# cmd = ARGV.shift +case ARGV.shift +when "post" + post "outbox", File.read(ARGV[0]) +when "follow" + post "follow", ARGV.join(" ") +when "unfollow" + post "unfollow", ARGV.join(" ") +end |