Sha256: f98795729640508828b455b2bd71ff68d9314018bff1d6a55c715e44152c4634

Contents?: true

Size: 941 Bytes

Versions: 71

Compression:

Stored size: 941 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    class UpcomingConferenceNotificationJob < ApplicationJob
      queue_as :events

      def perform(conference_id, checksum)
        conference = Decidim::Conference.find(conference_id)
        send_notification(conference) if verify_checksum(conference, checksum)
      end

      def self.generate_checksum(conference)
        Digest::MD5.hexdigest("#{conference.id}-#{conference.start_date}")
      end

      private

      def send_notification(conference)
        Decidim::EventsManager.publish(
          event: "decidim.events.conferences.upcoming_conference",
          event_class: Decidim::Conferences::UpcomingConferenceEvent,
          resource: conference,
          followers: conference.followers
        )
      end

      def verify_checksum(conference, checksum)
        self.class.generate_checksum(conference) == checksum
      end
    end
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
decidim-conferences-0.29.1 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.28.4 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.27.9 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.29.0 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.28.3 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.27.8 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.29.0.rc4 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.29.0.rc3 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.29.0.rc2 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.29.0.rc1 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.28.2 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.27.7 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.28.1 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.27.6 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.26.10 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.26.9 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.28.0 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.27.5 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.28.0.rc5 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb
decidim-conferences-0.28.0.rc4 app/jobs/decidim/conferences/upcoming_conference_notification_job.rb