mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FEATURE: search your bookmarks using in:bookmarks
This commit is contained in:
parent
eb7a5c251d
commit
16465edd88
2 changed files with 17 additions and 2 deletions
|
@ -2228,6 +2228,7 @@ en:
|
|||
<tr><td><code>status:open</code></td><td><code>status:closed</code></td><td><code>status:archived</code></td><td><code>status:noreplies</code></td><td><code>status:singleuser</code></td></tr>
|
||||
<tr><td><code>category:foo</code></td><td><code>user:foo</code></td><td colspan=3></td></tr>
|
||||
<tr><td><code>in:likes</code></td><td><code>in:posted</code></td><td><code>in:watching</code></td><td><code>in:tracking</code></td><td><code>in:private</code></td></tr>
|
||||
<tr><td><code>in:bookmarks</code></td><td colspan=4></td></tr>
|
||||
</table>
|
||||
</p>
|
||||
<p>
|
||||
|
|
|
@ -192,6 +192,9 @@ class Search
|
|||
elsif word == 'in:private'
|
||||
@search_pms = true
|
||||
nil
|
||||
elsif word == 'in:bookmarks'
|
||||
@bookmarked_only = true
|
||||
nil
|
||||
else
|
||||
word
|
||||
end
|
||||
|
@ -329,11 +332,15 @@ class Search
|
|||
end
|
||||
|
||||
if @guardian.user
|
||||
if @liked_only
|
||||
if @liked_only || @bookmarked_only
|
||||
|
||||
post_action_type = PostActionType.types[:like] if @liked_only
|
||||
post_action_type = PostActionType.types[:bookmark] if @bookmarked_only
|
||||
|
||||
posts = posts.where("posts.id IN (
|
||||
SELECT pa.post_id FROM post_actions pa
|
||||
WHERE pa.user_id = #{@guardian.user.id} AND
|
||||
pa.post_action_type_id = #{PostActionType.types[:like]}
|
||||
pa.post_action_type_id = #{post_action_type}
|
||||
)")
|
||||
end
|
||||
|
||||
|
@ -341,6 +348,13 @@ class Search
|
|||
posts = posts.where("posts.user_id = #{@guardian.user.id}")
|
||||
end
|
||||
|
||||
if @search_bookmarks
|
||||
post_action_type = @search_likes ? PostActionType.types(:like) : PostActionType.types[:bookmark]
|
||||
posts = posts.where(["posts.id IN (SELECT post_id FROM post_actions
|
||||
WHERE user_id = ? AND post_action_type_id = ?)",
|
||||
@guardian.user.id, post_action_type])
|
||||
end
|
||||
|
||||
if @notification_level
|
||||
posts = posts.where("posts.topic_id IN (
|
||||
SELECT tu.topic_id FROM topic_users tu
|
||||
|
|
Loading…
Reference in a new issue