Sha256: 0f13d48a8f52257500916d6d0ab9bb2901f7ff660ab17c71ff54e254e033a328

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Decidim
  # A wrapper for preparing push notifications messages from conversations
  # It respects the same contract as the Decidim::Messaging::ConversationMailer
  class PushNotificationMessageSender
    include HasConversations

    def deliver
      SendPushNotification.new.perform(@notification, title)
    end

    private

    # rubocop:disable Metrics/ParameterLists
    # rubocop:disable Lint/UnusedMethodArgument
    #
    # There are some parameters thar are not used in the method, but they are needed to
    # keep the same contract as the Decidim::Messaging::ConversationMailer
    def send_notification(from:, to:, conversation:, action:, message: nil, third_party: nil)
      @action = action
      @sender = to
      @third_party = third_party

      @notification = PushNotificationMessage.new(recipient: to, conversation: conversation, message: message)

      self
    end
    # rubocop:enable Lint/UnusedMethodArgument
    # rubocop:enable Metrics/ParameterLists

    def title
      get_subject(action: @action, sender: @sender, third_party: @third_party)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.27.10 app/services/decidim/push_notification_message_sender.rb
decidim-core-0.27.9 app/services/decidim/push_notification_message_sender.rb
decidim-core-0.27.8 app/services/decidim/push_notification_message_sender.rb
decidim-core-0.27.7 app/services/decidim/push_notification_message_sender.rb
decidim-core-0.27.6 app/services/decidim/push_notification_message_sender.rb