06a878c6b5
Conflicts: - `app/controllers/admin/base_controller.rb`: Minor conflict caused by glitch-soc's theming system. - `app/javascript/mastodon/initial_state.js`: Minor conflict caused by glitch-soc making use of max_toot_chars. - `app/models/form/admin_settings.rb`: Minor conflict caused by glitch-soc's theming system. - `app/models/trends.rb`: Minor conflict caused by glitch-soc having more granular notification settings for trends. - `app/views/admin/accounts/index.html.haml`: Minor conflict caused by glitch-soc's theming system. - `app/views/admin/instances/show.html.haml`: Minor conflict caused by glitch-soc's theming system. - `app/views/layouts/application.html.haml`: Minor conflict caused by glitch-soc's theming system. - `app/views/settings/preferences/notifications/show.html.haml`: Minor conflict caused by glitch-soc having more granular notification settings for trends. - `config/navigation.rb`: Minor conflict caused by glitch-soc having additional navigation items for the theming system while upstream slightly changed every line.
52 lines
1.3 KiB
Ruby
52 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Trends
|
|
def self.table_name_prefix
|
|
'trends_'
|
|
end
|
|
|
|
def self.links
|
|
@links ||= Trends::Links.new
|
|
end
|
|
|
|
def self.tags
|
|
@tags ||= Trends::Tags.new
|
|
end
|
|
|
|
def self.statuses
|
|
@statuses ||= Trends::Statuses.new
|
|
end
|
|
|
|
def self.register!(status)
|
|
[links, tags, statuses].each { |trend_type| trend_type.register(status) }
|
|
end
|
|
|
|
def self.refresh!
|
|
[links, tags, statuses].each(&:refresh)
|
|
end
|
|
|
|
def self.request_review!
|
|
return unless enabled?
|
|
|
|
links_requiring_review = links.request_review
|
|
tags_requiring_review = tags.request_review
|
|
statuses_requiring_review = statuses.request_review
|
|
|
|
User.those_who_can(:manage_taxonomies).includes(:account).find_each do |user|
|
|
links = user.allows_trending_links_review_emails? ? links_requiring_review : []
|
|
tags = user.allows_trending_tags_review_emails? ? tags_requiring_review : []
|
|
statuses = user.allows_trending_statuses_review_emails? ? statuses_requiring_review : []
|
|
next if links.empty? && tags.empty? && statuses.empty?
|
|
|
|
AdminMailer.new_trends(user.account, links, tags, statuses).deliver_later!
|
|
end
|
|
end
|
|
|
|
def self.enabled?
|
|
Setting.trends
|
|
end
|
|
|
|
def self.available_locales
|
|
@available_locales ||= I18n.available_locales.map { |locale| locale.to_s.split(/[_-]/).first }.uniq
|
|
end
|
|
end
|