Class: ServiceDesk::CustomEmailVerification

Inherits:
ApplicationRecord show all
Defined in:
app/models/service_desk/custom_email_verification.rb

Constant Summary collapse

TIMEFRAME =
30.minutes
STATES =
{ started: 0, finished: 1, failed: 2 }.freeze

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, nullable_column?, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Class Method Details

.generate_tokenObject



98
99
100
# File 'app/models/service_desk/custom_email_verification.rb', line 98

def generate_token
  SecureRandom.alphanumeric(12)
end

Instance Method Details

#accepted_untilObject



103
104
105
106
107
108
# File 'app/models/service_desk/custom_email_verification.rb', line 103

def accepted_until
  return unless started?
  return unless triggered_at.present?

  TIMEFRAME.since(triggered_at)
end

#in_timeframe?Boolean

Returns:

  • (Boolean)


110
111
112
113
114
# File 'app/models/service_desk/custom_email_verification.rb', line 110

def in_timeframe?
  return false unless started?

  !!accepted_until&.future?
end