Fixes and general progress
This commit is contained in:
parent
709c6685a9
commit
1dad72bf13
15 changed files with 133 additions and 34 deletions
|
@ -29,6 +29,18 @@ class Account < ActiveRecord::Base
|
|||
self.domain.nil?
|
||||
end
|
||||
|
||||
def acct
|
||||
local? ? self.username : "#{self.username}@#{self.domain}"
|
||||
end
|
||||
|
||||
def object_type
|
||||
:person
|
||||
end
|
||||
|
||||
def subscribed?
|
||||
!(self.secret.blank? || self.verify_token.blank?)
|
||||
end
|
||||
|
||||
def keypair
|
||||
self.private_key.nil? ? OpenSSL::PKey::RSA.new(self.public_key) : OpenSSL::PKey::RSA.new(self.private_key)
|
||||
end
|
||||
|
|
|
@ -2,6 +2,28 @@ class Follow < ActiveRecord::Base
|
|||
belongs_to :account
|
||||
belongs_to :target_account, class_name: 'Account'
|
||||
|
||||
validates :account, :target_account, presence: true
|
||||
|
||||
def verb
|
||||
:follow
|
||||
end
|
||||
|
||||
def object_type
|
||||
:person
|
||||
end
|
||||
|
||||
def target
|
||||
self.target_account
|
||||
end
|
||||
|
||||
def content
|
||||
"#{self.account.acct} started following #{self.target_account.acct}"
|
||||
end
|
||||
|
||||
def title
|
||||
content
|
||||
end
|
||||
|
||||
after_create do
|
||||
self.account.stream_entries.create!(activity: self)
|
||||
end
|
||||
|
|
|
@ -1,6 +1,24 @@
|
|||
class Status < ActiveRecord::Base
|
||||
belongs_to :account, inverse_of: :statuses
|
||||
|
||||
validates :account, presence: true
|
||||
|
||||
def verb
|
||||
:post
|
||||
end
|
||||
|
||||
def object_type
|
||||
:note
|
||||
end
|
||||
|
||||
def content
|
||||
self.text
|
||||
end
|
||||
|
||||
def title
|
||||
content.truncate(80, omission: "...")
|
||||
end
|
||||
|
||||
after_create do
|
||||
self.account.stream_entries.create!(activity: self)
|
||||
end
|
||||
|
|
|
@ -2,32 +2,29 @@ class StreamEntry < ActiveRecord::Base
|
|||
belongs_to :account, inverse_of: :stream_entries
|
||||
belongs_to :activity, polymorphic: true
|
||||
|
||||
validates :account, :activity, presence: true
|
||||
|
||||
def object_type
|
||||
case self.activity_type
|
||||
when 'Status'
|
||||
:note
|
||||
when 'Follow'
|
||||
:person
|
||||
end
|
||||
self.activity.object_type
|
||||
end
|
||||
|
||||
def verb
|
||||
case self.activity_type
|
||||
when 'Status'
|
||||
:post
|
||||
when 'Follow'
|
||||
:follow
|
||||
end
|
||||
self.activity.verb
|
||||
end
|
||||
|
||||
def targeted?
|
||||
[:follow].include? self.verb
|
||||
end
|
||||
|
||||
def target
|
||||
case self.activity_type
|
||||
when 'Follow'
|
||||
self.activity.target_account
|
||||
end
|
||||
self.activity.target
|
||||
end
|
||||
|
||||
def title
|
||||
self.activity.title
|
||||
end
|
||||
|
||||
def content
|
||||
self.activity.text if self.activity_type == 'Status'
|
||||
self.activity.content
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
class User < ActiveRecord::Base
|
||||
belongs_to :account, inverse_of: :user
|
||||
|
||||
validates :account, presence: true
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue