From 4c98445f1c070c677d23a9c6c07a0cab148589aa Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Sun, 9 Nov 2014 07:47:40 -0800 Subject: [PATCH] Fix presenters instead of modifying the getters --- app/models/comment.rb | 8 -------- app/models/profile.rb | 16 ---------------- app/presenters/comment_presenter.rb | 4 ++-- app/presenters/profile_presenter.rb | 4 ++-- 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 918b3f440..b71fcaa22 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -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 diff --git a/app/models/profile.rb b/app/models/profile.rb index 75cf450e8..bfbb535e5 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -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 diff --git a/app/presenters/comment_presenter.rb b/app/presenters/comment_presenter.rb index 725d206c3..95eef095c 100644 --- a/app/presenters/comment_presenter.rb +++ b/app/presenters/comment_presenter.rb @@ -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 \ No newline at end of file +end diff --git a/app/presenters/profile_presenter.rb b/app/presenters/profile_presenter.rb index 047955e71..3581ef9f9 100644 --- a/app/presenters/profile_presenter.rb +++ b/app/presenters/profile_presenter.rb @@ -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