Avoid invalid lag figures upon self-delivery

parent bbf2a471
class PubRelay::SubscriptionManager::DeliverWorker
record Delivery,
message : String,
domain : String,
counter : Int32,
accept : Bool
......@@ -27,6 +28,10 @@ class PubRelay::SubscriptionManager::DeliverWorker
end
def call(delivery : Delivery)
if delivery.domain == @domain
@stats.send Stats::DeliveryPayload.new(@domain, "SELF DOMAIN", delivery.counter)
end
body_hash = OpenSSL::Digest.new("sha256")
body_hash.update(delivery.message)
body_hash = Base64.strict_encode(body_hash.digest)
......
......@@ -102,7 +102,9 @@ class PubRelay::SubscriptionManager
}
counter = new_counter
delivery = DeliverWorker::Delivery.new(accept_activity.to_json, counter, accept: true)
delivery = DeliverWorker::Delivery.new(
accept_activity.to_json, @relay_domain, counter, accept: true
)
deliver_worker.send delivery
end
......@@ -131,15 +133,9 @@ class PubRelay::SubscriptionManager
def deliver(message : String, source_domain : String)
counter = new_counter
delivery = DeliverWorker::Delivery.new(message, counter, accept: false)
delivery = DeliverWorker::Delivery.new(message, source_domain, counter, accept: false)
select_actions = @subscribed_workers.compact_map do |worker|
if worker.domain == source_domain
nil
else
worker.mailbox.send_select_action(delivery)
end
end
select_actions = @subscribed_workers.map(&.mailbox.send_select_action(delivery))
spawn do
until select_actions.empty?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment