From d72727f4acf37b1dde7dfb6a62f738fd5ed76abd Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 17 Jul 2016 00:54:37 +0200 Subject: [PATCH] remove unused absence_of_content check this didn't do anything --- app/models/status_message.rb | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/app/models/status_message.rb b/app/models/status_message.rb index 67fcb23a4..56279d8f8 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -20,11 +20,6 @@ class StatusMessage < Post has_one :location has_one :poll, autosave: true - - # a StatusMessage is federated before its photos are so presence_of_content() fails erroneously if no text is present - # therefore, we put the validation in a before_destory callback instead of a validation - before_destroy :absence_of_content - attr_accessor :oembed_url attr_accessor :open_graph_url @@ -42,13 +37,15 @@ class StatusMessage < Post end def self.user_tag_stream(user, tag_ids) - owned_or_visible_by_user(user). - tag_stream(tag_ids) + owned_or_visible_by_user(user).tag_stream(tag_ids) end def self.public_tag_stream(tag_ids) - all_public. - tag_stream(tag_ids) + all_public.tag_stream(tag_ids) + end + + def self.tag_stream(tag_ids) + joins(:taggings).where("taggings.tag_id IN (?)", tag_ids) end def nsfw @@ -124,20 +121,10 @@ class StatusMessage < Post } end - protected + private + def presence_of_content errors[:base] << "Cannot create a StatusMessage without content" if text_and_photos_blank? end - - def absence_of_content - unless text_and_photos_blank? - errors[:base] << "Cannot destory a StatusMessage with text and/or photos present" - end - end - - private - def self.tag_stream(tag_ids) - joins(:taggings).where('taggings.tag_id IN (?)', tag_ids) - end end