Class: CommandTower::Messaging::Endpoint
Constant Summary
collapse
- SINGLE_ACTIVE_CHANNELS =
%w[pushover].freeze
- LIFECYCLE_STATES =
%w[active revoked invalid retired].freeze
- VERIFICATION_STATES =
%w[unverified pending verified failed].freeze
- TERMINAL_LIFECYCLES =
%w[revoked invalid retired].freeze
- TYPED_CREDENTIAL_CHANNELS =
%w[pushover].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
attribute_to_type_mapping
Class Method Details
.single_active_channel?(channel_key) ⇒ Boolean
39
40
41
|
# File 'app/models/command_tower/messaging/endpoint.rb', line 39
def self.single_active_channel?(channel_key)
SINGLE_ACTIVE_CHANNELS.include?(channel_key.to_s)
end
|
.typed_credentials_channel?(channel_key) ⇒ Boolean
43
44
45
|
# File 'app/models/command_tower/messaging/endpoint.rb', line 43
def self.typed_credentials_channel?(channel_key)
TYPED_CREDENTIAL_CHANNELS.include?(channel_key.to_s)
end
|
Instance Method Details
#active? ⇒ Boolean
51
52
53
|
# File 'app/models/command_tower/messaging/endpoint.rb', line 51
def active?
lifecycle_state == "active"
end
|
#derive_uniqueness_columns! ⇒ Object
Centralized uniqueness derivation — must run whenever lifecycle, owner,
channel, or fingerprint change. Terminal rows clear both slots.
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/models/command_tower/messaging/endpoint.rb', line 61
def derive_uniqueness_columns!
if active?
self.active_fingerprint = address_fingerprint
self.single_active_slot =
if self.class.single_active_channel?(channel_key)
"#{user_id}:#{channel_key}"
end
else
self.active_fingerprint = nil
self.single_active_slot = nil
end
end
|
#terminal? ⇒ Boolean
55
56
57
|
# File 'app/models/command_tower/messaging/endpoint.rb', line 55
def terminal?
TERMINAL_LIFECYCLES.include?(lifecycle_state)
end
|
#typed_credentials_channel? ⇒ Boolean
47
48
49
|
# File 'app/models/command_tower/messaging/endpoint.rb', line 47
def typed_credentials_channel?
self.class.typed_credentials_channel?(channel_key)
end
|