Merge branch 'fix/credo-issues' into 'develop'
[akkoma] / lib / pleroma / notification.ex
index e47145601e8cbd3d57af9eccc1d0c6dad409914e..c7c925c890a16c4c93fbfdd55a02b3b57259950c 100644 (file)
@@ -4,8 +4,13 @@
 
 defmodule Pleroma.Notification do
   use Ecto.Schema
-  alias Pleroma.{User, Activity, Notification, Repo}
+
+  alias Pleroma.User
+  alias Pleroma.Activity
+  alias Pleroma.Notification
+  alias Pleroma.Repo
   alias Pleroma.Web.CommonAPI.Utils
+
   import Ecto.Query
 
   schema "notifications" do
@@ -35,7 +40,8 @@ defmodule Pleroma.Notification do
         n in Notification,
         where: n.user_id == ^user.id,
         order_by: [desc: n.id],
-        preload: [:activity],
+        join: activity in assoc(n, :activity),
+        preload: [activity: activity],
         limit: 20
       )
 
@@ -66,7 +72,8 @@ defmodule Pleroma.Notification do
       from(
         n in Notification,
         where: n.id == ^id,
-        preload: [:activity]
+        join: activity in assoc(n, :activity),
+        preload: [activity: activity]
       )
 
     notification = Repo.one(query)