TODO: Fix spec/pigeon/parser_spec.rb:12 before proceeding
This commit is contained in:
parent
3a03d1b589
commit
56781696b2
|
@ -14,11 +14,13 @@ module Pigeon
|
|||
.current
|
||||
.get_message_count_for(author.public_key)
|
||||
count = store.get_message_count_for(author.public_key)
|
||||
raise "TODO: Render a signature here"
|
||||
msg = self.new(author: author,
|
||||
kind: draft.kind,
|
||||
body: draft.body,
|
||||
depth: depth,
|
||||
prev: store.get_message_by_depth(author.public_key, count - 1))
|
||||
prev: store.get_message_by_depth(author.public_key, count - 1),
|
||||
signature: signature)
|
||||
# We might need to add conditional logic here
|
||||
# Currently YAGNI since all Drafts we handle today
|
||||
# are authored by LocalIdentity.current
|
||||
|
@ -74,13 +76,13 @@ module Pigeon
|
|||
Helpers.verify_string(author, signature, tpl)
|
||||
end
|
||||
|
||||
def initialize(author:, kind:, body:, signature: nil, depth:, prev:)
|
||||
def initialize(author:, kind:, body:, signature:, depth:, prev:)
|
||||
raise MISSING_BODY if body.empty?
|
||||
@author = author
|
||||
@kind = kind
|
||||
@body = body
|
||||
@depth = depth
|
||||
@signature = author.is_a?(LocalIdentity) ? calculate_signature : signature
|
||||
@signature = signature
|
||||
@prev = prev || Pigeon::EMPTY_MESSAGE
|
||||
verify!
|
||||
store.save_message(self)
|
||||
|
@ -90,7 +92,7 @@ module Pigeon
|
|||
MessageSerializer.new(self)
|
||||
end
|
||||
|
||||
def calculate_signature
|
||||
def self.calculate_signature(author)
|
||||
@author.sign(template.render_without_signature)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue