This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2021-11-25 04:07:38 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-02-24 15:34:14 -08:00
|
|
|
class Trends::PreviewCardProviderBatch
|
2021-11-25 04:07:38 -08:00
|
|
|
include ActiveModel::Model
|
|
|
|
include Authorization
|
|
|
|
|
|
|
|
attr_accessor :preview_card_provider_ids, :action, :current_account
|
|
|
|
|
|
|
|
def save
|
|
|
|
case action
|
|
|
|
when 'approve'
|
|
|
|
approve!
|
|
|
|
when 'reject'
|
|
|
|
reject!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def preview_card_providers
|
|
|
|
PreviewCardProvider.where(id: preview_card_provider_ids)
|
|
|
|
end
|
|
|
|
|
|
|
|
def approve!
|
2022-02-24 15:34:14 -08:00
|
|
|
preview_card_providers.each { |provider| authorize(provider, :review?) }
|
2021-11-25 04:07:38 -08:00
|
|
|
preview_card_providers.update_all(trendable: true, reviewed_at: Time.now.utc)
|
|
|
|
end
|
|
|
|
|
|
|
|
def reject!
|
2022-02-24 15:34:14 -08:00
|
|
|
preview_card_providers.each { |provider| authorize(provider, :review?) }
|
2021-11-25 04:07:38 -08:00
|
|
|
preview_card_providers.update_all(trendable: false, reviewed_at: Time.now.utc)
|
|
|
|
end
|
|
|
|
end
|