Minor cleanup

This commit is contained in:
Netscape Navigator 2020-02-25 18:18:47 -06:00
parent f68e004e53
commit aaea1d3f6d
1 changed files with 8 additions and 2 deletions

View File

@ -4,6 +4,8 @@ module Pigeon
class Message
attr_reader :author, :kind, :body, :signature
class NotSaved < StandardError; end
def self.create(kind:, body: {})
self.new(author: KeyPair.current.public_key,
kind: kind,
@ -103,8 +105,12 @@ module Pigeon
end
def calculate_depth
raise "Don't do this- read from the index. Also, crash if message is not saved."
@depth || Pigeon::Storage.current.message_count
if saved?
raise NotSaved, "Can't calculate depth of unsaved messages"
else
# raise "Hmm.... I need to create a message index."
@depth || Pigeon::Storage.current.message_count
end
end
def message_id # I need this to calculate `prev`.