DEV: Upgrading Discourse to Zeitwerk (#8098)

Zeitwerk simplifies working with dependencies in dev and makes it easier reloading class chains. 

We no longer need to use Rails "require_dependency" anywhere and instead can just use standard 
Ruby patterns to require files.

This is a far reaching change and we expect some followups here.
This commit is contained in:
Krzysztof Kotlarek 2019-10-02 14:01:53 +10:00 committed by Sam
parent 68d35b14f4
commit 427d54b2b0
496 changed files with 293 additions and 1050 deletions

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'rate_limiter'
class AboutController < ApplicationController
requires_login only: [:live_post_counts]

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require "backup_restore/backup_restore"
require "backup_restore"
require "backup_restore/backup_store"
class Admin::BackupsController < Admin::AdminController

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'email/renderer'
class Admin::EmailController < Admin::AdminController
def index

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'embedding'
class Admin::EmbeddingController < Admin::AdminController
before_action :fetch_embedding

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'upload_creator'
class Admin::EmojisController < Admin::AdminController
def index

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'report'
class Admin::ReportsController < Admin::AdminController
def index
reports_methods = ['page_view_total_reqs'] +

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'ip_addr'
class Admin::ScreenedIpAddressesController < Admin::AdminController
before_action :fetch_screened_ip_address, only: [:update, :destroy]

View File

@ -1,8 +1,5 @@
# frozen_string_literal: true
require_dependency 'seed_data/categories'
require_dependency 'seed_data/topics'
class Admin::SiteTextsController < Admin::AdminController
def self.preferred_keys

View File

@ -26,8 +26,6 @@ class Admin::StaffActionLogsController < Admin::AdminController
end
def diff
require_dependency "discourse_diff"
@history = UserHistory.find(params[:id])
prev = @history.previous_value
cur = @history.new_value

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'upload_creator'
require_dependency 'theme_store/tgz_exporter'
require 'base64'
class Admin::ThemesController < Admin::AdminController

View File

@ -1,9 +1,5 @@
# frozen_string_literal: true
require_dependency 'user_destroyer'
require_dependency 'admin_user_index_query'
require_dependency 'admin_confirmation'
class Admin::UsersController < Admin::AdminController
before_action :fetch_user, only: [:suspend,

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'discourse_updates'
class Admin::VersionsController < Admin::AdminController
def show
render json: DiscourseUpdates.check_version

View File

@ -1,20 +1,6 @@
# frozen_string_literal: true
require 'current_user'
require_dependency 'canonical_url'
require_dependency 'discourse'
require_dependency 'custom_renderer'
require_dependency 'archetype'
require_dependency 'rate_limiter'
require_dependency 'crawler_detection'
require_dependency 'json_error'
require_dependency 'letter_avatar'
require_dependency 'distributed_cache'
require_dependency 'global_path'
require_dependency 'secure_session'
require_dependency 'topic_query'
require_dependency 'hijack'
require_dependency 'read_only_header'
class ApplicationController < ActionController::Base
include CurrentUser

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'category_serializer'
class CategoriesController < ApplicationController
requires_login except: [:index, :categories_and_latest, :categories_and_top, :show, :redirect, :find_by_slug]

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'html_to_markdown'
class ComposerController < ApplicationController
requires_login

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'composer_messages_finder'
class ComposerMessagesController < ApplicationController
requires_login

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'topic_query_params'
class EmbedController < ApplicationController
include TopicQueryParams

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'inline_oneboxer'
class InlineOneboxController < ApplicationController
requires_login

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'rate_limiter'
class InvitesController < ApplicationController
requires_login only: [

View File

@ -1,8 +1,5 @@
# frozen_string_literal: true
require_dependency 'topic_list_responder'
require_dependency 'topic_query_params'
class ListController < ApplicationController
include TopicListResponder
include TopicQueryParams

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'notification_serializer'
class NotificationsController < ApplicationController
requires_login

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'oneboxer'
class OneboxController < ApplicationController
requires_login

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'discourse'
class PostActionUsersController < ApplicationController
def index
params.require(:post_action_type_id)

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'discourse'
class PostActionsController < ApplicationController
requires_login

View File

@ -1,14 +1,5 @@
# frozen_string_literal: true
require_dependency 'new_post_manager'
require_dependency 'post_creator'
require_dependency 'post_action_destroyer'
require_dependency 'post_destroyer'
require_dependency 'post_merger'
require_dependency 'distributed_memoizer'
require_dependency 'new_post_result_serializer'
require_dependency 'post_locker'
class PostsController < ApplicationController
requires_login except: [

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true
require_dependency 'reviewable_explanation_serializer'
class ReviewablesController < ApplicationController
requires_login

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'search'
class SearchController < ApplicationController
skip_before_action :check_xhr, only: :show

View File

@ -1,11 +1,5 @@
# frozen_string_literal: true
require_dependency 'rate_limiter'
require_dependency 'single_sign_on'
require_dependency 'single_sign_on_provider'
require_dependency 'url_helper'
require_dependency 'webauthn/webauthn'
class SessionController < ApplicationController
class LocalLoginNotAllowed < StandardError; end
rescue_from LocalLoginNotAllowed do

View File

@ -1,8 +1,5 @@
# frozen_string_literal: true
require_dependency 'similar_topic_serializer'
require_dependency 'search/grouped_search_results'
class SimilarTopicsController < ApplicationController
class SimilarTopic

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'site_serializer'
class SiteController < ApplicationController
layout false
skip_before_action :preload_json, :check_xhr

View File

@ -1,8 +1,5 @@
# frozen_string_literal: true
require_dependency 'distributed_memoizer'
require_dependency 'file_helper'
class StaticController < ApplicationController
skip_before_action :check_xhr, :redirect_to_login_if_required

View File

@ -1,9 +1,5 @@
# frozen_string_literal: true
require_dependency 'wizard'
require_dependency 'wizard/builder'
require_dependency 'wizard/step_updater'
class StepsController < ApplicationController
requires_login

View File

@ -1,10 +1,5 @@
# frozen_string_literal: true
require_dependency 'topic_list_responder'
require_dependency 'topic_query_params'
require_dependency 'topics_bulk_action'
require_dependency 'topic_query'
class TagsController < ::ApplicationController
include TopicListResponder
include TopicQueryParams

View File

@ -1,14 +1,5 @@
# frozen_string_literal: true
require_dependency 'topic_view'
require_dependency 'promotion'
require_dependency 'url_helper'
require_dependency 'topics_bulk_action'
require_dependency 'discourse_event'
require_dependency 'rate_limiter'
require_dependency 'topic_publisher'
require_dependency 'post_action_destroyer'
class TopicsController < ApplicationController
requires_login only: [
:timings,

View File

@ -1,8 +1,6 @@
# frozen_string_literal: true
require "mini_mime"
require_dependency 'upload_creator'
require_dependency "file_store/local_store"
class UploadsController < ApplicationController
requires_login except: [:show, :show_short]

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require_dependency 'letter_avatar'
class UserAvatarsController < ApplicationController
skip_before_action :preload_json, :redirect_to_login_if_required, :check_xhr, :verify_authenticity_token, only: [:show, :show_letter, :show_proxy_letter]

View File

@ -1,10 +1,6 @@
# -*- encoding : utf-8 -*-
# frozen_string_literal: true
require_dependency 'email'
require_dependency 'enum'
require_dependency 'user_name_suggester'
class Users::OmniauthCallbacksController < ApplicationController
skip_before_action :redirect_to_login_if_required

View File

@ -1,13 +1,5 @@
# frozen_string_literal: true
require_dependency 'discourse_hub'
require_dependency 'user_name_suggester'
require_dependency 'rate_limiter'
require_dependency 'wizard'
require_dependency 'wizard/builder'
require_dependency 'admin_confirmation'
require_dependency 'webauthn/webauthn'
class UsersController < ApplicationController
skip_before_action :authorize_mini_profiler, only: [:avatar]

View File

@ -1,9 +1,5 @@
# frozen_string_literal: true
require_dependency 'rate_limiter'
require_dependency 'email_validator'
require_dependency 'email_updater'
class UsersEmailController < ApplicationController
requires_login only: [:index, :update]

View File

@ -1,8 +1,5 @@
# frozen_string_literal: true
require_dependency 'wizard'
require_dependency 'wizard/builder'
class WizardController < ApplicationController
requires_login except: [:qunit]

View File

@ -2,14 +2,6 @@
# frozen_string_literal: true
require 'current_user'
require 'canonical_url'
require_dependency 'guardian'
require_dependency 'unread'
require_dependency 'age_words'
require_dependency 'configurable_urls'
require_dependency 'mobile_detection'
require_dependency 'category_badge'
require_dependency 'global_path'
require_dependency 'emoji'
module ApplicationHelper
include CurrentUser

View File

@ -187,7 +187,7 @@ module Jobs
def perform(*args)
opts = args.extract_options!.with_indifferent_access
if Jobs.run_later?
if ::Jobs.run_later?
Sidekiq.redis do |r|
r.set('last_job_perform_at', Time.now.to_i)
end
@ -275,7 +275,7 @@ module Jobs
extend MiniScheduler::Schedule
def perform(*args)
if (Jobs::Heartbeat === self) || !Discourse.readonly_mode?
if (::Jobs::Heartbeat === self) || !Discourse.readonly_mode?
super
end
end
@ -290,7 +290,8 @@ module Jobs
end
# If we are able to queue a job, do it
if Jobs.run_later?
if ::Jobs.run_later?
hash = {
'class' => klass,
'args' => [opts]
@ -361,7 +362,3 @@ module Jobs
end
end
end
Dir["#{Rails.root}/app/jobs/onceoff/*.rb"].each { |file| require_dependency file }
Dir["#{Rails.root}/app/jobs/regular/*.rb"].each { |file| require_dependency file }
Dir["#{Rails.root}/app/jobs/scheduled/*.rb"].each { |file| require_dependency file }

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class CleanUpPostTimings < Jobs::Onceoff
class CleanUpPostTimings < ::Jobs::Onceoff
# Remove post timings that are remnants of previous post moves
# or other shenanigans and don't reference a valid user or post anymore.

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class CleanUpSidekiqStatistic < Jobs::Onceoff
class CleanUpSidekiqStatistic < ::Jobs::Onceoff
def execute_onceoff(args)
$redis.without_namespace.del('sidekiq:sidekiq:statistic')
end

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class CleanUpUserExportTopics < Jobs::Onceoff
class CleanUpUserExportTopics < ::Jobs::Onceoff
def execute_onceoff(args)
translated_keys = I18n.available_locales.map do |l|
I18n.with_locale(:"#{l}") { I18n.t("system_messages.csv_export_succeeded.subject_template") }

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class ClearWidthAndHeight < Jobs::Onceoff
class ClearWidthAndHeight < ::Jobs::Onceoff
def execute_onceoff(args)
# we have to clear all old uploads cause
# we could have old versions of height / width

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class CorrectMissingDualstackUrls < Jobs::Onceoff
class CorrectMissingDualstackUrls < ::Jobs::Onceoff
def execute_onceoff(args)
# s3 now uses dualstack urls, keep them around correctly
# in both uploads and optimized_image tables

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class CreateTagsSearchIndex < Jobs::Onceoff
class CreateTagsSearchIndex < ::Jobs::Onceoff
def execute_onceoff(args)
DB.query('select id, name from tags').each do |t|
SearchIndexer.update_tags_index(t.id, t.name)

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class FixFeaturedLinkForTopics < Jobs::Onceoff
class FixFeaturedLinkForTopics < ::Jobs::Onceoff
def execute_onceoff(args)
Topic.where("featured_link IS NOT NULL").find_each do |topic|
featured_link = topic.featured_link

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class FixInvalidGravatarUploads < Jobs::Onceoff
class FixInvalidGravatarUploads < ::Jobs::Onceoff
def execute_onceoff(args)
Upload.where(original_filename: "gravatar.png").find_each do |upload|
# note, this still feels pretty expensive for a once off

View File

@ -1,9 +1,7 @@
# frozen_string_literal: true
require_dependency "upload_fixer"
module Jobs
class FixInvalidUploadExtensions < Jobs::Onceoff
class FixInvalidUploadExtensions < ::Jobs::Onceoff
def execute_onceoff(args)
UploadFixer.fix_all_extensions
end

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class FixOutOfSyncUserUploadedAvatar < Jobs::Onceoff
class FixOutOfSyncUserUploadedAvatar < ::Jobs::Onceoff
def execute_onceoff(args)
DB.exec(<<~SQL)
WITH X AS (

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class FixPostsRead < Jobs::Onceoff
class FixPostsRead < ::Jobs::Onceoff
def execute_onceoff(args)
# Skipping to the last post in a topic used to count all posts in the topic
# as read in user stats. Cap the posts read count to 50 * topics_entered.

View File

@ -1,9 +1,7 @@
# frozen_string_literal: true
require_dependency 'user_destroyer'
module Jobs
class FixPrimaryEmailsForStagedUsers < Jobs::Onceoff
class FixPrimaryEmailsForStagedUsers < ::Jobs::Onceoff
def execute_onceoff(args)
users = User.where(active: false, staged: true).joins(:email_tokens)
acting_user = Discourse.system_user

View File

@ -1,10 +1,8 @@
# frozen_string_literal: true
require_dependency 'jobs/scheduled/grant_anniversary_badges'
module Jobs
class FixRetroAnniversary < Jobs::Onceoff
class FixRetroAnniversary < ::Jobs::Onceoff
def execute_onceoff(args)
return unless SiteSetting.enable_badges

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class FixS3Etags < Jobs::Onceoff
class FixS3Etags < ::Jobs::Onceoff
def execute_onceoff(args)
[Upload, OptimizedImage].each do |model|

View File

@ -2,7 +2,7 @@
module Jobs
class GrantEmoji < Jobs::Onceoff
class GrantEmoji < ::Jobs::Onceoff
def execute_onceoff(args)
return unless SiteSetting.enable_badges
to_award = {}

View File

@ -2,7 +2,7 @@
module Jobs
class GrantFirstReplyByEmail < Jobs::Onceoff
class GrantFirstReplyByEmail < ::Jobs::Onceoff
def execute_onceoff(args)
return unless SiteSetting.enable_badges

View File

@ -2,7 +2,7 @@
module Jobs
class GrantOnebox < Jobs::Onceoff
class GrantOnebox < ::Jobs::Onceoff
sidekiq_options queue: 'low'
def execute_onceoff(args)

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class InitCategoryTagStats < Jobs::Onceoff
class InitCategoryTagStats < ::Jobs::Onceoff
def execute_onceoff(args)
DB.exec "DELETE FROM category_tag_stats"

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class MigrateCensoredWords < Jobs::Onceoff
class MigrateCensoredWords < ::Jobs::Onceoff
def execute_onceoff(args)
row = DB.query_single("SELECT value FROM site_settings WHERE name = 'censored_words'")
if row.count > 0

View File

@ -1,9 +1,7 @@
# frozen_string_literal: true
require_dependency 'upload_creator'
module Jobs
class MigrateCustomEmojis < Jobs::Onceoff
class MigrateCustomEmojis < ::Jobs::Onceoff
def execute_onceoff(args)
return if Rails.env.test?

View File

@ -2,7 +2,7 @@
module Jobs
class MigrateFeaturedLinks < Jobs::Onceoff
class MigrateFeaturedLinks < ::Jobs::Onceoff
def execute_onceoff(args)
TopicCustomField.where(name: "featured_link").find_each do |tcf|

View File

@ -2,7 +2,7 @@
module Jobs
class MigrateTaggingPlugin < Jobs::Onceoff
class MigrateTaggingPlugin < ::Jobs::Onceoff
def execute_onceoff(args)
all_tags = TopicCustomField.where(name: "tags").select('DISTINCT value').all.map(&:value)

View File

@ -2,7 +2,7 @@
module Jobs
class MigrateUploadExtensions < Jobs::Onceoff
class MigrateUploadExtensions < ::Jobs::Onceoff
def execute_onceoff(args)
Upload.find_each do |upload|
upload.extension = File.extname(upload.original_filename)[1..10]

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class MigrateUrlSiteSettings < Jobs::Onceoff
class MigrateUrlSiteSettings < ::Jobs::Onceoff
SETTINGS = [
['logo_url', 'logo'],
['logo_small_url', 'logo_small'],

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true
class Jobs::Onceoff < Jobs::Base
require_relative '../base.rb'
class Jobs::Onceoff < ::Jobs::Base
sidekiq_options retry: false
def self.name_for(klass)

View File

@ -1,9 +1,7 @@
# frozen_string_literal: true
require_dependency "upload_recovery"
module Jobs
class PostUploadsRecovery < Jobs::Onceoff
class PostUploadsRecovery < ::Jobs::Onceoff
MIN_PERIOD = 30
MAX_PERIOD = 120

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class RemoveOldAutoCloseJobs < Jobs::Onceoff
class RemoveOldAutoCloseJobs < ::Jobs::Onceoff
def execute_onceoff(args)
Jobs.cancel_scheduled_job(:close_topic)

View File

@ -1,10 +1,8 @@
# frozen_string_literal: true
require_dependency 'jobs/scheduled/grant_anniversary_badges'
module Jobs
class RetroGrantAnniversary < Jobs::Onceoff
class RetroGrantAnniversary < ::Jobs::Onceoff
def execute_onceoff(args)
return unless SiteSetting.enable_badges

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class RetroRecentTimeRead < Jobs::Onceoff
class RetroRecentTimeRead < ::Jobs::Onceoff
def execute_onceoff(args)
# update past records by evenly distributing total time reading among each post read
sql = <<~SQL

View File

@ -1,9 +1,7 @@
# frozen_string_literal: true
require_dependency 'email/sender'
module Jobs
class AdminConfirmationEmail < Jobs::Base
class AdminConfirmationEmail < ::Jobs::Base
sidekiq_options queue: 'critical'
def execute(args)

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class AnonymizeUser < Jobs::Base
class AnonymizeUser < ::Jobs::Base
sidekiq_options queue: 'low'

View File

@ -2,7 +2,7 @@
module Jobs
class AutomaticGroupMembership < Jobs::Base
class AutomaticGroupMembership < ::Jobs::Base
def execute(args)
group_id = args[:group_id]

View File

@ -1,11 +1,8 @@
# frozen_string_literal: true
require_dependency "backup_restore/local_backup_store"
require_dependency "backup_restore/backup_store"
module Jobs
class BackupChunksMerger < Jobs::Base
class BackupChunksMerger < ::Jobs::Base
sidekiq_options queue: 'critical', retry: false
def execute(args)

View File

@ -2,7 +2,7 @@
module Jobs
class BulkGrantTrustLevel < Jobs::Base
class BulkGrantTrustLevel < ::Jobs::Base
def execute(args)
trust_level = args[:trust_level]

View File

@ -1,10 +1,7 @@
# frozen_string_literal: true
require_dependency 'system_message'
module Jobs
class BulkInvite < Jobs::Base
class BulkInvite < ::Jobs::Base
sidekiq_options retry: false
def initialize

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class BumpTopic < Jobs::Base
class BumpTopic < ::Jobs::Base
def execute(args)
topic_timer = TopicTimer.find_by(id: args[:topic_timer_id] || args[:topic_status_update_id])

View File

@ -2,7 +2,7 @@
module Jobs
class ConfirmSnsSubscription < Jobs::Base
class ConfirmSnsSubscription < ::Jobs::Base
sidekiq_options retry: false
def execute(args)

View File

@ -3,11 +3,9 @@
require 'open-uri'
require 'nokogiri'
require 'excon'
require_dependency 'retrieve_title'
require_dependency 'topic_link'
module Jobs
class CrawlTopicLink < Jobs::Base
class CrawlTopicLink < ::Jobs::Base
sidekiq_options queue: 'low'

View File

@ -2,7 +2,7 @@
module Jobs
class CreateAvatarThumbnails < Jobs::Base
class CreateAvatarThumbnails < ::Jobs::Base
sidekiq_options queue: 'low'
def execute(args)

View File

@ -1,9 +1,9 @@
# frozen_string_literal: true
require "backup_restore/backup_restore"
require "backup_restore"
module Jobs
class CreateBackup < Jobs::Base
class CreateBackup < ::Jobs::Base
sidekiq_options retry: false
def execute(args)

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
class Jobs::CreateUserReviewable < Jobs::Base
class Jobs::CreateUserReviewable < ::Jobs::Base
attr_reader :reviewable
def execute(args)

View File

@ -1,7 +1,6 @@
# frozen_string_literal: true
# base.rb uses this style of require, so maintain usage of it here
require_dependency "#{Rails.root}/app/jobs/regular/user_email.rb"
module Jobs
class CriticalUserEmail < UserEmail

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class DeleteInaccessibleNotifications < Jobs::Base
class DeleteInaccessibleNotifications < ::Jobs::Base
def execute(args)
raise Discourse::InvalidParameters.new(:topic_id) if args[:topic_id].blank?

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class DeleteTopic < Jobs::Base
class DeleteTopic < ::Jobs::Base
def execute(args)
topic_timer = TopicTimer.find_by(id: args[:topic_timer_id] || args[:topic_status_update_id])

View File

@ -2,7 +2,7 @@
module Jobs
class DownloadAvatarFromUrl < Jobs::Base
class DownloadAvatarFromUrl < ::Jobs::Base
sidekiq_options retry: false
def execute(args)

View File

@ -1,11 +1,8 @@
# frozen_string_literal: true
require_dependency 'email/sender'
require_dependency "email_backup_token"
module Jobs
class DownloadBackupEmail < Jobs::Base
class DownloadBackupEmail < ::Jobs::Base
sidekiq_options queue: 'critical'

View File

@ -2,7 +2,7 @@
module Jobs
class DownloadProfileBackgroundFromUrl < Jobs::Base
class DownloadProfileBackgroundFromUrl < ::Jobs::Base
sidekiq_options retry: false
def execute(args)

View File

@ -3,7 +3,7 @@
require 'excon'
module Jobs
class EmitWebHookEvent < Jobs::Base
class EmitWebHookEvent < ::Jobs::Base
PING_EVENT = 'ping'.freeze
MAX_RETRY_COUNT = 4.freeze
RETRY_BACKOFF = 5

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class EnableBootstrapMode < Jobs::Base
class EnableBootstrapMode < ::Jobs::Base
sidekiq_options queue: 'critical'
def execute(args)

View File

@ -2,13 +2,10 @@
require 'csv'
require 'zip'
require_dependency 'system_message'
require_dependency 'upload_creator'
require_dependency 'upload_markdown'
module Jobs
class ExportCsvFile < Jobs::Base
class ExportCsvFile < ::Jobs::Base
sidekiq_options retry: false
HEADER_ATTRS_FOR ||= HashWithIndifferentAccess.new(

View File

@ -2,7 +2,7 @@
module Jobs
class FeatureTopicUsers < Jobs::Base
class FeatureTopicUsers < ::Jobs::Base
def execute(args)
topic_id = args[:topic_id]

View File

@ -1,11 +1,9 @@
# frozen_string_literal: true
require_dependency 'email/sender'
module Jobs
# Asynchronously send an email
class InviteEmail < Jobs::Base
class InviteEmail < ::Jobs::Base
def execute(args)
raise Discourse::InvalidParameters.new(:invite_id) unless args[:invite_id].present?

View File

@ -1,11 +1,9 @@
# frozen_string_literal: true
require_dependency 'email/sender'
module Jobs
# Asynchronously send an email
class InvitePasswordInstructionsEmail < Jobs::Base
class InvitePasswordInstructionsEmail < ::Jobs::Base
def execute(args)
raise Discourse::InvalidParameters.new(:username) unless args[:username].present?

View File

@ -1,9 +1,7 @@
# frozen_string_literal: true
require_dependency "post_alerter"
module Jobs
class NotifyCategoryChange < Jobs::Base
class NotifyCategoryChange < ::Jobs::Base
def execute(args)
post = Post.find_by(id: args[:post_id])

View File

@ -1,10 +1,8 @@
# frozen_string_literal: true
require_dependency 'post'
module Jobs
class NotifyMailingListSubscribers < Jobs::Base
class NotifyMailingListSubscribers < ::Jobs::Base
include Skippable
RETRY_TIMES = [5.minute, 15.minute, 30.minute, 45.minute, 90.minute, 180.minute, 300.minute]

View File

@ -2,7 +2,7 @@
module Jobs
class NotifyMovedPosts < Jobs::Base
class NotifyMovedPosts < ::Jobs::Base
def execute(args)
raise Discourse::InvalidParameters.new(:post_ids) if args[:post_ids].blank?

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Jobs
class NotifyPostRevision < Jobs::Base
class NotifyPostRevision < ::Jobs::Base
def execute(args)
raise Discourse::InvalidParameters.new(:user_ids) unless args[:user_ids]

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
class Jobs::NotifyReviewable < Jobs::Base
class Jobs::NotifyReviewable < ::Jobs::Base
def execute(args)
reviewable = Reviewable.find_by(id: args[:reviewable_id])

Some files were not shown because too many files have changed in this diff Show More