mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
Improvements to user drafts (#6226)
* drafts in user profile: only show to user herself (not to admins), use avatar replying to (instead of topic OP), add keyboard shortcut for drafts, simplify display labels * use JSON when testing Draft.stream
This commit is contained in:
@ -58,13 +58,15 @@ class Draft < ActiveRecord::Base
|
||||
pu.username, pu.name, pu.id user_id, pu.uploaded_avatar_id, pu.username_lower,
|
||||
du.username draft_username, NULL as raw, NULL as cooked, NULL as post_number
|
||||
FROM drafts d
|
||||
LEFT JOIN LATERAL json_extract_path_text (d.data::json, 'postId') postId ON TRUE
|
||||
LEFT JOIN posts p ON postId :: BIGINT = p.id
|
||||
LEFT JOIN topics t ON
|
||||
CASE
|
||||
WHEN d.draft_key LIKE '%' || '#{EXISTING_TOPIC}' || '%'
|
||||
THEN CAST(replace(d.draft_key, '#{EXISTING_TOPIC}', '') AS INT)
|
||||
ELSE 0
|
||||
END = t.id
|
||||
JOIN users pu on pu.id = COALESCE(t.user_id, d.user_id)
|
||||
JOIN users pu on pu.id = COALESCE(p.user_id, t.user_id, d.user_id)
|
||||
JOIN users du on du.id = #{user_id}
|
||||
/*where*/
|
||||
/*order_by*/
|
||||
|
Reference in New Issue
Block a user