Allow fetching comments

Now with likes on comments, diaspora also tries to fetch comments if it
receives a like for a comment it doesn't know yet. So this now also
allows to fetch comments with `/fetch/comment/<guid>`.
This commit is contained in:
Benjamin Neff
2024-01-21 23:19:04 +01:00
parent 389b1870d3
commit 9e61693e20
3 changed files with 35 additions and 2 deletions

View File

@@ -37,6 +37,12 @@ class Comment < ApplicationRecord
scope :including_author, -> { includes(:author => :profile) }
scope :for_a_stream, -> { including_author.merge(order('created_at ASC')) }
scope :all_public, -> {
where("commentable_type = 'Post' AND EXISTS(
SELECT 1 FROM posts WHERE posts.id = commentable_id AND posts.public = true
)")
}
before_save do
self.text.strip! unless self.text.nil?
end