Sha256: 2ce1d06aaf1f6dba938c894a8edf05a85f4f21cf2d2072790a6d5a33ea49cfff

Contents?: true

Size: 967 Bytes

Versions: 33

Compression:

Stored size: 967 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    class UpcomingMeetingNotificationJob < ApplicationJob
      queue_as :events

      def perform(meeting_id, checksum)
        meeting = Decidim::Meetings::Meeting.find(meeting_id)
        return if meeting.hidden? || meeting.withdrawn?
        return unless verify_checksum(meeting, checksum)

        send_notification(meeting)
      end

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

      private

      def send_notification(meeting)
        Decidim::EventsManager.publish(
          event: "decidim.events.meetings.upcoming_meeting",
          event_class: Decidim::Meetings::UpcomingMeetingEvent,
          resource: meeting,
          followers: meeting.followers
        )
      end

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

Version data entries

33 entries across 33 versions & 1 rubygems

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