Chatwoot/app/jobs/trigger_scheduled_items_job.rb
Sojan Jose fdcaed75f6
chore: Move Whatsapp template sync to cron (#4858)
syncing WhatsApp templates job is moved to a cron job for a better user experience. The Templates are synced at 15-minute intervals now.
2022-06-14 23:46:36 +05:30

19 lines
667 B
Ruby

class TriggerScheduledItemsJob < ApplicationJob
queue_as :scheduled_jobs
def perform
# trigger the scheduled campaign jobs
Campaign.where(campaign_type: :one_off, campaign_status: :active).where(scheduled_at: 3.days.ago..Time.current).all.each do |campaign|
Campaigns::TriggerOneoffCampaignJob.perform_later(campaign)
end
# Job to reopen snoozed conversations
Conversations::ReopenSnoozedConversationsJob.perform_later
# Job to auto-resolve conversations
Account::ConversationsResolutionSchedulerJob.perform_later
# Job to sync whatsapp templates
Channels::Whatsapp::TemplatesSyncSchedulerJob.perform_later
end
end