diff options
Diffstat (limited to 'app/models/gpg_signature.rb')
-rw-r--r-- | app/models/gpg_signature.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/gpg_signature.rb b/app/models/gpg_signature.rb index e783c3b24e4..b718e8e1000 100644 --- a/app/models/gpg_signature.rb +++ b/app/models/gpg_signature.rb @@ -21,6 +21,19 @@ class GpgSignature < ActiveRecord::Base validates :project_id, presence: true validates :gpg_key_primary_keyid, presence: true + def self.with_key_and_subkeys(gpg_key) + return none unless gpg_key + + t = arel_table + subkey_ids = gpg_key&.subkeys&.pluck(:id) + + where( + t[:gpg_key_id].eq(gpg_key&.id).or( + t[:gpg_key_subkey_id].in(subkey_ids) + ) + ) + end + def gpg_key=(model) case model when GpgKey |