mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Allow changing ownwership of posts by admins
This commit is contained in:
@@ -9,7 +9,8 @@ class PostRevisionSerializer < ApplicationSerializer
|
||||
:edit_reason,
|
||||
:body_changes,
|
||||
:title_changes,
|
||||
:category_changes
|
||||
:category_changes,
|
||||
:user_changes
|
||||
|
||||
def include_title_changes?
|
||||
object.has_topic_data?
|
||||
@@ -43,6 +44,26 @@ class PostRevisionSerializer < ApplicationSerializer
|
||||
object.lookup("edit_reason", 1)
|
||||
end
|
||||
|
||||
def user_changes
|
||||
obj = object.user_changes
|
||||
return unless obj
|
||||
# same as below - if stuff is messed up, default to system
|
||||
prev = obj[:previous_user] || Discourse.system_user
|
||||
new = obj[:current_user] || Discourse.system_user
|
||||
{
|
||||
previous: {
|
||||
username: prev.username_lower,
|
||||
display_username: prev.username,
|
||||
avatar_template: prev.avatar_template
|
||||
},
|
||||
current: {
|
||||
username: new.username_lower,
|
||||
display_username: new.username,
|
||||
avatar_template: new.avatar_template
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def user
|
||||
# if stuff goes pear shape attribute to system
|
||||
object.user || Discourse.system_user
|
||||
|
||||
Reference in New Issue
Block a user