Sha256: 0e0f9905867eb4180b5cf87e376947fb3c48082a5f6a091b1580ff1eebbc8121

Contents?: true

Size: 875 Bytes

Versions: 4

Compression:

Stored size: 875 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # A messsage 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

4 entries across 4 versions & 1 rubygems

Version Path
decidim-core-0.28.4 app/models/decidim/push_notification_message.rb
decidim-core-0.28.3 app/models/decidim/push_notification_message.rb
decidim-core-0.28.2 app/models/decidim/push_notification_message.rb
decidim-core-0.28.1 app/models/decidim/push_notification_message.rb