gab-social/app/services/vote_service.rb

24 lines
479 B
Ruby
Raw Normal View History

2019-07-02 08:10:25 +01:00
# frozen_string_literal: true
class VoteService < BaseService
include Authorization
def call(account, poll, choices)
authorize_with account, poll, :vote?
@account = account
@poll = poll
@choices = choices
@votes = []
ApplicationRecord.transaction do
@choices.each do |choice|
2020-05-01 17:46:31 +01:00
@votes << @poll.votes.create!(account: @account, choice: choice)
2019-07-02 08:10:25 +01:00
end
end
# ActivityTracker.increment('activity:interactions')
2019-07-02 08:10:25 +01:00
end
end