Module: Tempest::Jetstream::Subscription
- Defined in:
- lib/tempest/jetstream/subscription.rb
Class Method Summary collapse
Class Method Details
.build(self_did:, follows:, cap: 10_000) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tempest/jetstream/subscription.rb', line 17 def build(self_did:, follows:, cap: 10_000) ordered = [self_did] follows.each do |row| did = row[:did] || row["did"] next if did.nil? || did == self_did ordered << did end if ordered.length <= cap Plan.new(wanted_dids: ordered, filter: nil) else allowed = ordered.to_set Plan.new(wanted_dids: [], filter: ->(event) { allowed.include?(event.did) }) end end |