mirror of
https://github.com/mastodon/mastodon.git
synced 2024-10-21 10:05:39 +09:00
6e50134a42
* Add trending links * Add overriding specific links trendability * Add link type to preview cards and only trend articles Change trends review notifications from being sent every 5 minutes to being sent every 2 hours Change threshold from 5 unique accounts to 15 unique accounts * Fix tests
38 lines
653 B
Ruby
38 lines
653 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Form::TagBatch
|
|
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!
|
|
tags.each { |tag| authorize(tag, :update?) }
|
|
tags.update_all(trendable: true, reviewed_at: action_time)
|
|
end
|
|
|
|
def reject!
|
|
tags.each { |tag| authorize(tag, :update?) }
|
|
tags.update_all(trendable: false, reviewed_at: action_time)
|
|
end
|
|
|
|
def action_time
|
|
@action_time ||= Time.now.utc
|
|
end
|
|
end
|