Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `app/models/account.rb`: Not a real conflict, just upstream getting rid of unused constants too close to glitch-soc-specific contents. Removed unused constants like upstream did. - `app/models/trends.rb`: Conflict because glitch-soc disabled email notifications for trending links. Upstream has refactored this quite a bit and added trending posts. Took upstream code, but disabling the extra trending stuff will come in another commit. - `app/views/admin/trends/links/index.html.haml`: Conflict due to glitch-soc's theming system. Ported upstream changes accordingly.
This commit is contained in:
30
app/models/form/email_domain_block_batch.rb
Normal file
30
app/models/form/email_domain_block_batch.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Form::EmailDomainBlockBatch
|
||||
include ActiveModel::Model
|
||||
include Authorization
|
||||
include AccountableConcern
|
||||
|
||||
attr_accessor :email_domain_block_ids, :action, :current_account
|
||||
|
||||
def save
|
||||
case action
|
||||
when 'delete'
|
||||
delete!
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def email_domain_blocks
|
||||
@email_domain_blocks ||= EmailDomainBlock.where(id: email_domain_block_ids)
|
||||
end
|
||||
|
||||
def delete!
|
||||
email_domain_blocks.each do |email_domain_block|
|
||||
authorize(email_domain_block, :destroy?)
|
||||
email_domain_block.destroy!
|
||||
log_action :destroy, email_domain_block
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,65 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Form::PreviewCardBatch
|
||||
include ActiveModel::Model
|
||||
include Authorization
|
||||
|
||||
attr_accessor :preview_card_ids, :action, :current_account, :precision
|
||||
|
||||
def save
|
||||
case action
|
||||
when 'approve'
|
||||
approve!
|
||||
when 'approve_all'
|
||||
approve_all!
|
||||
when 'reject'
|
||||
reject!
|
||||
when 'reject_all'
|
||||
reject_all!
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def preview_cards
|
||||
@preview_cards ||= PreviewCard.where(id: preview_card_ids)
|
||||
end
|
||||
|
||||
def preview_card_providers
|
||||
@preview_card_providers ||= preview_cards.map(&:domain).uniq.map { |domain| PreviewCardProvider.matching_domain(domain) || PreviewCardProvider.new(domain: domain) }
|
||||
end
|
||||
|
||||
def approve!
|
||||
preview_cards.each { |preview_card| authorize(preview_card, :update?) }
|
||||
preview_cards.update_all(trendable: true)
|
||||
end
|
||||
|
||||
def approve_all!
|
||||
preview_card_providers.each do |provider|
|
||||
authorize(provider, :update?)
|
||||
provider.update(trendable: true, reviewed_at: action_time)
|
||||
end
|
||||
|
||||
# Reset any individual overrides
|
||||
preview_cards.update_all(trendable: nil)
|
||||
end
|
||||
|
||||
def reject!
|
||||
preview_cards.each { |preview_card| authorize(preview_card, :update?) }
|
||||
preview_cards.update_all(trendable: false)
|
||||
end
|
||||
|
||||
def reject_all!
|
||||
preview_card_providers.each do |provider|
|
||||
authorize(provider, :update?)
|
||||
provider.update(trendable: false, reviewed_at: action_time)
|
||||
end
|
||||
|
||||
# Reset any individual overrides
|
||||
preview_cards.update_all(trendable: nil)
|
||||
end
|
||||
|
||||
def action_time
|
||||
@action_time ||= Time.now.utc
|
||||
end
|
||||
end
|
@@ -1,33 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Form::PreviewCardProviderBatch
|
||||
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!
|
||||
preview_card_providers.each { |provider| authorize(provider, :update?) }
|
||||
preview_card_providers.update_all(trendable: true, reviewed_at: Time.now.utc)
|
||||
end
|
||||
|
||||
def reject!
|
||||
preview_card_providers.each { |provider| authorize(provider, :update?) }
|
||||
preview_card_providers.update_all(trendable: false, reviewed_at: Time.now.utc)
|
||||
end
|
||||
end
|
@@ -1,37 +0,0 @@
|
||||
# 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
|
Reference in New Issue
Block a user