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.

changed indentation

+31 -29
+31 -29
lib/tapfall/stream.rb
··· 1 1 require 'skyfall/stream' 2 - require_relative 'version' 3 2 require_relative 'messages/tap_message' 3 + require_relative 'version' 4 4 5 - class Tapfall::Stream < Skyfall::Stream 6 - def initialize(server, options = {}) 7 - super(server) 5 + module Tapfall 6 + class Tapfall::Stream < Skyfall::Stream 7 + def initialize(server, options = {}) 8 + super(server) 8 9 9 - @options = options 10 - @root_url = ensure_empty_path(@root_url) 11 - @ack = true unless options[:ack] == false 12 - end 13 - 14 - def connect 15 - if @ack && @handlers[:message].nil? 16 - raise ConfigError, "The on(:message) handler must be set unless :ack => false option is passed" 10 + @options = options 11 + @root_url = ensure_empty_path(@root_url) 12 + @ack = true unless options[:ack] == false 17 13 end 18 14 19 - super 20 - end 15 + def connect 16 + if @ack && @handlers[:message].nil? 17 + raise ConfigError, "The on(:message) handler must be set unless :ack => false option is passed" 18 + end 21 19 22 - def handle_message(packet) 23 - data = packet.data 24 - @handlers[:raw_message]&.call(data) 20 + super 21 + end 25 22 26 - if @handlers[:message] 27 - tap_message = Tapfall::TapMessage.new(data) 28 - @handlers[:message].call(tap_message) 29 - send_ack(tap_message) if @ack 23 + def handle_message(packet) 24 + data = packet.data 25 + @handlers[:raw_message]&.call(data) 26 + 27 + if @handlers[:message] 28 + tap_message = TapMessage.new(data) 29 + @handlers[:message].call(tap_message) 30 + send_ack(tap_message) if @ack 31 + end 30 32 end 31 - end 32 33 33 - def send_ack(msg) 34 - json = %({"type":"ack","id":#{msg.id}}) 35 - send_data(json) 36 - end 34 + def send_ack(msg) 35 + json = %({"type":"ack","id":#{msg.id}}) 36 + send_data(json) 37 + end 37 38 38 - private 39 + private 39 40 40 - def build_websocket_url 41 - @root_url + "/channel" 41 + def build_websocket_url 42 + @root_url + "/channel" 43 + end 42 44 end 43 45 end