diff options
author | reverite <samantha@chalker.io> | 2019-03-15 05:54:30 -0700 |
---|---|---|
committer | reverite <samantha@chalker.io> | 2019-03-15 05:54:30 -0700 |
commit | 75eeb003b09c53d3b4e98046d1c20b0ad8a887bb (patch) | |
tree | d2ae669ee583c613a474f8698b7ea718da803819 /app/services/vote_service.rb | |
parent | 41d1369391d70a9cd25bdf96cfe567975793ef5a (diff) | |
parent | c2fa0f7c40bcc4064e8baaa221665eadd391c001 (diff) |
Merge remote-tracking branch 'glitch/master' into production
Diffstat (limited to 'app/services/vote_service.rb')
-rw-r--r-- | app/services/vote_service.rb | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/app/services/vote_service.rb b/app/services/vote_service.rb index 5b80da03a..0cace6c00 100644 --- a/app/services/vote_service.rb +++ b/app/services/vote_service.rb @@ -19,8 +19,27 @@ class VoteService < BaseService end end - return if @poll.account.local? + if @poll.account.local? + distribute_poll! + else + deliver_votes! + queue_final_poll_check! + end + end + + private + + def distribute_poll! + return if @poll.hide_totals? + ActivityPub::DistributePollUpdateWorker.perform_in(3.minutes, @poll.status.id) + end + + def queue_final_poll_check! + return unless @poll.expires? + PollExpirationNotifyWorker.perform_at(@poll.expires_at + 5.minutes, @poll.id) + end + def deliver_votes! @votes.each do |vote| ActivityPub::DeliveryWorker.perform_async( build_json(vote), @@ -30,8 +49,6 @@ class VoteService < BaseService end end - private - def build_json(vote) ActiveModelSerializers::SerializableResource.new( vote, |