user: add moderator_user_query()
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 3 Sep 2018 12:03:23 +0000 (12:03 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 3 Sep 2018 12:03:23 +0000 (12:03 +0000)
lib/pleroma/user.ex

index 64c69b209cddc9ae339f4e1a13b2aad6d6361d87..1dad30e876f6265d5835e7604ded15aea50ca3a8 100644 (file)
@@ -609,6 +609,14 @@ defmodule Pleroma.User do
     )
   end
 
+  def moderator_user_query() do
+    from(
+      u in User,
+      where: u.local == true,
+      where: fragment("?->'is_moderator' @> 'true'", u.info)
+    )
+  end
+
   def deactivate(%User{} = user) do
     new_info = Map.put(user.info, "deactivated", true)
     cs = User.info_changeset(user, %{info: new_info})