Fix presenters instead of modifying the getters

This commit is contained in:
Dennis Schubert 2014-11-09 07:47:40 -08:00
parent 6808150920
commit 4c98445f1c
4 changed files with 4 additions and 28 deletions

View file

@ -83,14 +83,6 @@ class Comment < ActiveRecord::Base
@message ||= Diaspora::MessageRenderer.new text
end
def text
if AppConfig.privacy.camo.proxy_markdown_images?
Diaspora::Camo.from_markdown(self[:text])
else
self[:text]
end
end
def text= text
self[:text] = text.to_s.strip #to_s if for nil, for whatever reason
end

View file

@ -142,22 +142,6 @@ class Profile < ActiveRecord::Base
birthday.to_s(:long).gsub(', 1000', '') if birthday.present?
end
def bio
if AppConfig.privacy.camo.proxy_markdown_images?
Diaspora::Camo.from_markdown(self[:bio])
else
self[:bio]
end
end
def location
if AppConfig.privacy.camo.proxy_markdown_images?
Diaspora::Camo.from_markdown(self[:location])
else
self[:location]
end
end
def bio_message
@bio_message ||= Diaspora::MessageRenderer.new(bio)
end

View file

@ -7,9 +7,9 @@ class CommentPresenter < BasePresenter
{
:id => @comment.id,
:guid => @comment.guid,
:text => @comment.text,
:text => @comment.message.plain_text_for_json,
:author => @comment.author.as_api_response(:backbone),
:created_at => @comment.created_at
}
end
end
end

View file

@ -4,8 +4,8 @@ class ProfilePresenter < BasePresenter
def base_hash
{ id: id,
tags: tags.pluck(:name),
bio: bio,
location: location,
bio: bio_message.plain_text_for_json,
location: location_message.plain_text_for_json,
gender: gender,
birthday: formatted_birthday,
searchable: searchable