mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Change the way nuked users' posts are handled. Allow null in the user_id column of posts. Show these posts in the posts stream.
This commit is contained in:
@@ -8,15 +8,15 @@ class BasicPostSerializer < ApplicationSerializer
|
||||
:cooked
|
||||
|
||||
def name
|
||||
object.user.name
|
||||
object.user.try(:name)
|
||||
end
|
||||
|
||||
def username
|
||||
object.user.username
|
||||
object.user.try(:username)
|
||||
end
|
||||
|
||||
def avatar_template
|
||||
object.user.avatar_template
|
||||
object.user.try(:avatar_template)
|
||||
end
|
||||
|
||||
def cooked
|
||||
|
||||
@@ -46,11 +46,11 @@ class PostSerializer < BasicPostSerializer
|
||||
|
||||
|
||||
def moderator?
|
||||
object.user.moderator?
|
||||
object.user.try(:moderator?) || false
|
||||
end
|
||||
|
||||
def staff?
|
||||
object.user.staff?
|
||||
object.user.try(:staff?) || false
|
||||
end
|
||||
|
||||
def yours
|
||||
@@ -70,7 +70,7 @@ class PostSerializer < BasicPostSerializer
|
||||
end
|
||||
|
||||
def display_username
|
||||
object.user.name
|
||||
object.user.try(:name)
|
||||
end
|
||||
|
||||
def link_counts
|
||||
@@ -101,11 +101,11 @@ class PostSerializer < BasicPostSerializer
|
||||
end
|
||||
|
||||
def user_title
|
||||
object.user.title
|
||||
object.user.try(:title)
|
||||
end
|
||||
|
||||
def trust_level
|
||||
object.user.trust_level
|
||||
object.user.try(:trust_level)
|
||||
end
|
||||
|
||||
def reply_to_user
|
||||
|
||||
@@ -15,15 +15,13 @@ module PostStreamSerializerMixin
|
||||
@highest_number_in_posts = 0
|
||||
if object.posts.present?
|
||||
object.posts.each_with_index do |p, idx|
|
||||
if p.user
|
||||
@highest_number_in_posts = p.post_number if p.post_number > @highest_number_in_posts
|
||||
ps = PostSerializer.new(p, scope: scope, root: false)
|
||||
ps.topic_slug = object.topic.slug
|
||||
ps.topic_view = object
|
||||
p.topic = object.topic
|
||||
@highest_number_in_posts = p.post_number if p.post_number > @highest_number_in_posts
|
||||
ps = PostSerializer.new(p, scope: scope, root: false)
|
||||
ps.topic_slug = object.topic.slug
|
||||
ps.topic_view = object
|
||||
p.topic = object.topic
|
||||
|
||||
@posts << ps.as_json
|
||||
end
|
||||
@posts << ps.as_json
|
||||
end
|
||||
end
|
||||
@posts
|
||||
|
||||
Reference in New Issue
Block a user