Class: Email::V3

Inherits:
Integration
  • Object
show all
Defined in:
app/models/pager_tree/integrations/email/v3.rb

Constant Summary collapse

OPTIONS =
[
  {key: :allow_spam, type: :boolean, default: false},
  {key: :dedup_threads, type: :boolean, default: true}
]

Instance Method Summary collapse

Instance Method Details

#adapter_actionObject



49
50
51
# File 'app/models/pager_tree/integrations/email/v3.rb', line 49

def adapter_action
  :create
end

#adapter_process_createObject



53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/pager_tree/integrations/email/v3.rb', line 53

def adapter_process_create
  Alert.new(
    title: _title,
    description: _description,
    urgency: urgency,
    thirdparty_id: _thirdparty_id,
    dedup_keys: _dedup_keys,
    additional_data: _additional_datums,
    attachments: _attachments
  )
end

#adapter_should_block?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/pager_tree/integrations/email/v3.rb', line 29

def adapter_should_block?
  return false if option_allow_spam == true

  ses_spam_verdict = _get_header("X-SES-Spam-Verdict")&.value

  if ses_spam_verdict.present?
    return ses_spam_verdict != "PASS"
  end

  false
end

#adapter_supports_incoming?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/models/pager_tree/integrations/email/v3.rb', line 41

def adapter_supports_incoming?
  true
end

#adapter_thirdparty_idObject



45
46
47
# File 'app/models/pager_tree/integrations/email/v3.rb', line 45

def adapter_thirdparty_id
  _thirdparty_id
end

#endpointObject

SPECIAL: override integration endpoint



18
19
20
21
22
23
24
25
26
27
# File 'app/models/pager_tree/integrations/email/v3.rb', line 18

def endpoint
  domain = ::PagerTree::Integrations.integration_email_v3_domain
  inbox = ::PagerTree::Integrations.integration_email_v3_inbox
  postfix = ""
  postfix = "_stg" if Rails.env.staging?
  postfix = "_tst" if Rails.env.test?
  postfix = "_dev" if Rails.env.development?

  "#{inbox}#{postfix}+#{id}@#{domain}"
end