提交 37dcfb6e 编写于 作者: R Rubén Dávila

Delegate #key to parent when working with a GPG subkey

The content returned by #key is important when veryfying the signature,
so given we don't want to repeat it in the database for GPG subkeys we
need to delegate it to the parent.
上级 62d54034
......@@ -8,6 +8,7 @@ class GpgKey < ActiveRecord::Base
sha_attribute :fingerprint
belongs_to :user
belongs_to :parent, class_name: 'GpgKey'
has_many :gpg_signatures
has_many :subkeys, class_name: 'GpgKey', foreign_key: :parent_id, dependent: :destroy
......@@ -48,6 +49,10 @@ class GpgKey < ActiveRecord::Base
super&.upcase
end
def key
parent_id? ? parent.key : super
end
def key=(value)
super(value&.strip)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册