Allow plugins to customize the columns returned by user_actions

This is useful if they have a different mechanism for rendering an
avatar and want to include custom columns via the `custom_avatar_column`
plugin function.
This commit is contained in:
Robin Ward 2017-12-14 16:52:54 -05:00
parent 3cbaea81bd
commit 4fcf9ece3a

View File

@ -167,6 +167,18 @@ SQL
offset = opts[:offset] || 0
limit = opts[:limit] || 60
# Acting user columns. Can be extended by plugins to include custom avatar
# columns
acting_cols = [
'u.id AS acting_user_id',
'u.name AS acting_name'
]
AvatarLookup.lookup_columns.each do |c|
next if c == :id || c['.']
acting_cols << "u.#{c} AS acting_#{c}"
end
# The weird thing is that target_post_id can be null, so it makes everything
# ever so more complex. Should we allow this, not sure.
builder = SqlBuilder.new <<-SQL
@ -179,8 +191,7 @@ SQL
p.reply_to_post_number,
pu.username, pu.name, pu.id user_id,
pu.uploaded_avatar_id,
u.username acting_username, u.name acting_name, u.id acting_user_id,
u.uploaded_avatar_id acting_uploaded_avatar_id,
#{acting_cols.join(', ')},
coalesce(p.cooked, p2.cooked) cooked,
CASE WHEN coalesce(p.deleted_at, p2.deleted_at, t.deleted_at) IS NULL THEN false ELSE true END deleted,
p.hidden,