Sha256: 094138726c01ef1f465d7cf76007fcf1506be3021394008bbb1435cab53bc3e0

Contents?: true

Size: 874 Bytes

Versions: 6

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # A message from a conversation that will be sent as a push notification
  class PushNotificationMessage
    class InvalidActionError < StandardError; end

    include SanitizeHelper

    def initialize(recipient:, conversation:, message:)
      @recipient = recipient
      @conversation = conversation
      @message = message
    end

    attr_reader :recipient, :conversation, :message

    alias user recipient

    def body
      decidim_escape_translated(message)
    end

    def icon
      organization.attached_uploader(:favicon).variant_url(:big, host: organization.host)
    end

    def url
      EngineRouter.new("decidim", {}).public_send(:conversation_path, host: organization.host, id: @conversation)
    end

    private

    def organization
      @organization ||= recipient.organization
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/models/decidim/push_notification_message.rb
decidim-core-0.29.0 app/models/decidim/push_notification_message.rb
decidim-core-0.29.0.rc4 app/models/decidim/push_notification_message.rb
decidim-core-0.29.0.rc3 app/models/decidim/push_notification_message.rb
decidim-core-0.29.0.rc2 app/models/decidim/push_notification_message.rb
decidim-core-0.29.0.rc1 app/models/decidim/push_notification_message.rb