Ruby gem for ingesting ATProto repo data from a Tap service (extension of Skyfall gem)
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

added support for basic auth

+25 -2
+6 -1
lib/tapfall/api.rb
··· 4 4 5 5 module Tapfall 6 6 class API 7 - def initialize(server) 7 + def initialize(server, options = {}) 8 8 @root_url = build_root_url(server) 9 + @options = options 9 10 end 10 11 11 12 def add_repo(did) ··· 54 55 request = Net::HTTP::Post.new(uri) 55 56 request.body = JSON.generate(json_data) 56 57 request.content_type = "application/json" 58 + 59 + if @options[:admin_password] 60 + request.basic_auth('admin', @options[:admin_password]) 61 + end 57 62 58 63 response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => (uri.scheme == 'https')) do |http| 59 64 http.request(request)
+19 -1
lib/tapfall/stream.rb
··· 18 18 @options = options 19 19 @root_url = ensure_empty_path(@root_url) 20 20 @ack = true unless options[:ack] == false 21 + @password = options[:admin_password] 21 22 22 - @api = API.new(build_api_url) 23 + @api = build_api 23 24 end 24 25 25 26 def connect ··· 48 49 49 50 private 50 51 52 + def basic_auth(account, password) 53 + 'Basic ' + ["#{account}:#{password}"].pack('m0') 54 + end 55 + 56 + def request_headers 57 + if @password 58 + { 'Authorization' => basic_auth('admin', @password) } 59 + else 60 + {} 61 + end 62 + end 63 + 51 64 def build_websocket_url 52 65 @root_url + "/channel" 53 66 end ··· 58 71 else 59 72 @root_url.gsub(/^wss:/, 'https:') 60 73 end 74 + end 75 + 76 + def build_api 77 + api_url = build_api_url 78 + API.new(api_url, { admin_password: @password }) 61 79 end 62 80 end 63 81 end