about summary refs log tree commit diff
path: root/app/models/account.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-02-28 00:51:05 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-02-28 00:51:05 +0100
commit5ae54f9e364880e1350ddcc8251a23cf79ae55fc (patch)
tree9dbf55bae26ad0dfb9ecd9f39d68aeb32188cc0e /app/models/account.rb
parent2c70f0ecaa507427d2592434cb4a516bcedd5039 (diff)
Adding avatars to profile page and statuses
Diffstat (limited to 'app/models/account.rb')
-rw-r--r--app/models/account.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 0940118dc..f1ac6fdd7 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -3,7 +3,8 @@ class Account < ActiveRecord::Base
   has_one :user, inverse_of: :account
 
   # Avatar upload
-  has_attached_file :avatar, styles: { large: '300x300#', medium: '96x96#', small: '48x48#' }
+  attr_reader :avatar_remote_url
+  has_attached_file :avatar, styles: { large: '300x300#', medium: '96x96#', small: '48x48#' }, default_url: 'avatars/missing.png'
   validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/
 
   # Timelines
@@ -64,6 +65,11 @@ class Account < ActiveRecord::Base
     @subscription ||= OStatus2::Subscription.new(self.remote_url, secret: self.secret, token: self.verify_token, webhook: webhook_url, hub: self.hub_url)
   end
 
+  def avatar_remote_url=(url)
+    self.avatar = URI.parse(url)
+    @avatar_remote_url = url
+  end
+
   before_create do
     if local?
       keypair = OpenSSL::PKey::RSA.new(Rails.env.test? ? 48 : 2048)