This repository has been archived on 2024-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
2019-09-09 06:50:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-02-24 18:34:14 -05:00
|
|
|
class Trends::TagBatch
|
2019-09-09 06:50:09 -04:00
|
|
|
include ActiveModel::Model
|
|
|
|
include Authorization
|
|
|
|
|
|
|
|
attr_accessor :tag_ids, :action, :current_account
|
|
|
|
|
|
|
|
def save
|
|
|
|
case action
|
|
|
|
when 'approve'
|
|
|
|
approve!
|
|
|
|
when 'reject'
|
|
|
|
reject!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def tags
|
|
|
|
Tag.where(id: tag_ids)
|
|
|
|
end
|
|
|
|
|
|
|
|
def approve!
|
2022-02-24 18:34:14 -05:00
|
|
|
tags.each { |tag| authorize(tag, :review?) }
|
2021-11-25 07:07:38 -05:00
|
|
|
tags.update_all(trendable: true, reviewed_at: action_time)
|
2019-09-09 06:50:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def reject!
|
2022-02-24 18:34:14 -05:00
|
|
|
tags.each { |tag| authorize(tag, :review?) }
|
2021-11-25 07:07:38 -05:00
|
|
|
tags.update_all(trendable: false, reviewed_at: action_time)
|
|
|
|
end
|
|
|
|
|
|
|
|
def action_time
|
|
|
|
@action_time ||= Time.now.utc
|
2019-09-09 06:50:09 -04:00
|
|
|
end
|
|
|
|
end
|