Fix presenters instead of modifying the getters
This commit is contained in:
parent
6808150920
commit
4c98445f1c
4 changed files with 4 additions and 28 deletions
|
|
@ -83,14 +83,6 @@ class Comment < ActiveRecord::Base
|
||||||
@message ||= Diaspora::MessageRenderer.new text
|
@message ||= Diaspora::MessageRenderer.new text
|
||||||
end
|
end
|
||||||
|
|
||||||
def text
|
|
||||||
if AppConfig.privacy.camo.proxy_markdown_images?
|
|
||||||
Diaspora::Camo.from_markdown(self[:text])
|
|
||||||
else
|
|
||||||
self[:text]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def text= text
|
def text= text
|
||||||
self[:text] = text.to_s.strip #to_s if for nil, for whatever reason
|
self[:text] = text.to_s.strip #to_s if for nil, for whatever reason
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -142,22 +142,6 @@ class Profile < ActiveRecord::Base
|
||||||
birthday.to_s(:long).gsub(', 1000', '') if birthday.present?
|
birthday.to_s(:long).gsub(', 1000', '') if birthday.present?
|
||||||
end
|
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
|
def bio_message
|
||||||
@bio_message ||= Diaspora::MessageRenderer.new(bio)
|
@bio_message ||= Diaspora::MessageRenderer.new(bio)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ class CommentPresenter < BasePresenter
|
||||||
{
|
{
|
||||||
:id => @comment.id,
|
:id => @comment.id,
|
||||||
:guid => @comment.guid,
|
:guid => @comment.guid,
|
||||||
:text => @comment.text,
|
:text => @comment.message.plain_text_for_json,
|
||||||
:author => @comment.author.as_api_response(:backbone),
|
:author => @comment.author.as_api_response(:backbone),
|
||||||
:created_at => @comment.created_at
|
:created_at => @comment.created_at
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ class ProfilePresenter < BasePresenter
|
||||||
def base_hash
|
def base_hash
|
||||||
{ id: id,
|
{ id: id,
|
||||||
tags: tags.pluck(:name),
|
tags: tags.pluck(:name),
|
||||||
bio: bio,
|
bio: bio_message.plain_text_for_json,
|
||||||
location: location,
|
location: location_message.plain_text_for_json,
|
||||||
gender: gender,
|
gender: gender,
|
||||||
birthday: formatted_birthday,
|
birthday: formatted_birthday,
|
||||||
searchable: searchable
|
searchable: searchable
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue