Class: Decidim::PushNotificationMessage

Inherits:
Object
  • Object
show all
Includes:
SanitizeHelper
Defined in:
app/models/decidim/push_notification_message.rb

Overview

A message from a conversation that will be sent as a push notification

Defined Under Namespace

Classes: InvalidActionError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SanitizeHelper

#decidim_escape_translated, #decidim_html_escape, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_sanitize_translated, #decidim_url_escape, included

Constructor Details

#initialize(recipient:, conversation:, message:) ⇒ PushNotificationMessage

Returns a new instance of PushNotificationMessage.



10
11
12
13
14
# File 'app/models/decidim/push_notification_message.rb', line 10

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

Instance Attribute Details

#conversationObject (readonly)

Returns the value of attribute conversation.



16
17
18
# File 'app/models/decidim/push_notification_message.rb', line 16

def conversation
  @conversation
end

#messageObject (readonly)

Returns the value of attribute message.



16
17
18
# File 'app/models/decidim/push_notification_message.rb', line 16

def message
  @message
end

#recipientObject (readonly) Also known as: user

Returns the value of attribute recipient.



16
17
18
# File 'app/models/decidim/push_notification_message.rb', line 16

def recipient
  @recipient
end

Instance Method Details

#bodyObject



20
21
22
# File 'app/models/decidim/push_notification_message.rb', line 20

def body
  decidim_escape_translated(message)
end

#iconObject



24
25
26
# File 'app/models/decidim/push_notification_message.rb', line 24

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

#urlObject



28
29
30
# File 'app/models/decidim/push_notification_message.rb', line 28

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