Class: Domain

Inherits:
ApplicationRecord show all
Includes:
DnsimpleHelper
Defined in:
app/models/domain.rb

Defined Under Namespace

Classes: DestroyJob, InitializeJob, UpdateProvisionalCountJob

Instance Method Summary collapse

Methods included from DnsimpleHelper

#client

Instance Method Details

#provisional_notifyObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'app/models/domain.rb', line 53

def provisional_notify
  Admin::NotifyJob.perform_later("
  {
    \"blocks\": [
      {
        \"type\": \"section\",
        \"text\": {
          \"type\": \"mrkdwn\",
          \"text\": \"*Domain request: #{host}*\"
        }
      },
      {
        \"type\": \"divider\"
      },
      {
        \"type\": \"section\",
        \"text\": {
          \"type\": \"mrkdwn\",
          \"text\": \"*User*: #{user.name} (id: #{user.id})\n\n*Plan*: #{plan}\"
        },
        \"accessory\": {
          \"type\": \"button\",
          \"text\": {
            \"type\": \"plain_text\",
            \"text\": \"Review Domains\",
            \"emoji\": true
          },
          \"value\": \"click_me_123\",
          \"url\": \"https://admin.obl.ong/admin/domains/review\",
          \"action_id\": \"button-action\"
        }
      }
    ]
  }")
end

#recordsObject



45
46
47
# File 'app/models/domain.rb', line 45

def records
  Record.where_host(host)
end

#to_paramObject



26
27
28
# File 'app/models/domain.rb', line 26

def to_param
  host
end

#top_recordsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/domain.rb', line 30

def top_records
  records = []
  all_records = Record.where_host(host)

  if all_records.length > 3
    records[0] = all_records[0]
    records[1] = all_records[1]
    records[2] = all_records[2]
  else
    records = all_records
  end

  records
end

#userObject



49
50
51
# File 'app/models/domain.rb', line 49

def user
  User::User.find_by(id: user_users_id)
end