Avoid invalid lag figures upon self-delivery

parent bbf2a471
class PubRelay::SubscriptionManager::DeliverWorker class PubRelay::SubscriptionManager::DeliverWorker
record Delivery, record Delivery,
message : String, message : String,
domain : String,
counter : Int32, counter : Int32,
accept : Bool accept : Bool
...@@ -27,6 +28,10 @@ class PubRelay::SubscriptionManager::DeliverWorker ...@@ -27,6 +28,10 @@ class PubRelay::SubscriptionManager::DeliverWorker
end end
def call(delivery : Delivery) 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 = OpenSSL::Digest.new("sha256")
body_hash.update(delivery.message) body_hash.update(delivery.message)
body_hash = Base64.strict_encode(body_hash.digest) body_hash = Base64.strict_encode(body_hash.digest)
......
...@@ -102,7 +102,9 @@ class PubRelay::SubscriptionManager ...@@ -102,7 +102,9 @@ class PubRelay::SubscriptionManager
} }
counter = new_counter 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 deliver_worker.send delivery
end end
...@@ -131,15 +133,9 @@ class PubRelay::SubscriptionManager ...@@ -131,15 +133,9 @@ class PubRelay::SubscriptionManager
def deliver(message : String, source_domain : String) def deliver(message : String, source_domain : String)
counter = new_counter 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| select_actions = @subscribed_workers.map(&.mailbox.send_select_action(delivery))
if worker.domain == source_domain
nil
else
worker.mailbox.send_select_action(delivery)
end
end
spawn do spawn do
until select_actions.empty? 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