summaryrefslogtreecommitdiff
path: root/app/models/gpg_key_subkey.rb
blob: 110bf45113652ebbe8b2ac4a7b3a1b90a1f8e6af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

class GpgKeySubkey < ApplicationRecord
  include ShaAttribute

  sha_attribute :keyid
  sha_attribute :fingerprint

  belongs_to :gpg_key

  validates :gpg_key_id, presence: true
  validates :fingerprint, :keyid, presence: true, uniqueness: true

  delegate :key, :user, :user_infos, :verified?, :verified_user_infos,
    :verified_and_belongs_to_email?, to: :gpg_key

  def keyid
    super&.upcase
  end

  def fingerprint
    super&.upcase
  end
end