diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/application_helper.rb | 4 | ||||
-rw-r--r-- | app/models/account.rb | 8 | ||||
-rw-r--r-- | app/models/status.rb | 7 | ||||
-rw-r--r-- | app/models/stream_entry.rb | 2 | ||||
-rw-r--r-- | app/services/setup_local_account_service.rb | 4 |
5 files changed, 14 insertions, 11 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7a74a4d96..4c65a78bb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -6,8 +6,8 @@ module ApplicationHelper end def unique_tag_to_local_id(tag, expected_type) - Regexp.new("objectId=([\d]+):objectType=#{expected_type}").match(tag) - return match[1] unless match.nil? + matches = Regexp.new("objectId=([\\d]+):objectType=#{expected_type}").match(tag) + return matches[1] unless matches.nil? end def local_id?(id) diff --git a/app/models/account.rb b/app/models/account.rb index 2cbec488b..1b4f4ebdf 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -59,4 +59,12 @@ class Account < ActiveRecord::Base def subscription(webhook_url) @subscription ||= OStatus2::Subscription.new(self.remote_url, secret: self.secret, token: self.verify_token, webhook: webhook_url, hub: self.hub_url) end + + before_create do + if local? + keypair = OpenSSL::PKey::RSA.new(Rails.env.test? ? 48 : 2048) + self.private_key = keypair.to_pem + self.public_key = keypair.public_key.to_pem + end + end end diff --git a/app/models/status.rb b/app/models/status.rb index d95870393..3ba58cc91 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -54,10 +54,9 @@ class Status < ActiveRecord::Base unless reblog? self.text.scan(Account::MENTION_RE).each do |match| - uri = match.first - username = uri.split('@').first - domain = uri.split('@').size == 2 ? uri.split('@').last : nil - account = Account.find_by(username: username, domain: domain) + uri = match.first + username, domain = uri.split('@') + account = Account.find_by(username: username, domain: domain) m << account unless account.nil? end diff --git a/app/models/stream_entry.rb b/app/models/stream_entry.rb index a3ae099a1..e19dcc6c6 100644 --- a/app/models/stream_entry.rb +++ b/app/models/stream_entry.rb @@ -29,7 +29,7 @@ class StreamEntry < ActiveRecord::Base end def threaded? - [:favorite, :comment].include? verb + verb == :favorite || object_type == :comment end def thread diff --git a/app/services/setup_local_account_service.rb b/app/services/setup_local_account_service.rb index a5ef68996..16de87e50 100644 --- a/app/services/setup_local_account_service.rb +++ b/app/services/setup_local_account_service.rb @@ -9,10 +9,6 @@ class SetupLocalAccountService < BaseService user.account.username = username user.account.domain = nil - keypair = OpenSSL::PKey::RSA.new(2048) - user.account.private_key = keypair.to_pem - user.account.public_key = keypair.public_key.to_pem - user.save! end end |