projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'robotstxt' into 'develop'
[akkoma]
/
lib
/
pleroma
/
notification.ex
diff --git
a/lib/pleroma/notification.ex
b/lib/pleroma/notification.ex
index 4659e14ef8bd667f50d4b06ea3757b6d4d1f73d3..fe8181d8b57498bd35fc2039159d118b21af1338 100644
(file)
--- a/
lib/pleroma/notification.ex
+++ b/
lib/pleroma/notification.ex
@@
-4,14
+4,20
@@
defmodule Pleroma.Notification do
use Ecto.Schema
defmodule Pleroma.Notification do
use Ecto.Schema
- alias Pleroma.{User, Activity, Notification, Repo}
+
+ alias Pleroma.Activity
+ alias Pleroma.Notification
+ alias Pleroma.Repo
+ alias Pleroma.User
+ alias Pleroma.Web.CommonAPI
alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.CommonAPI.Utils
+
import Ecto.Query
schema "notifications" do
field(:seen, :boolean, default: false)
import Ecto.Query
schema "notifications" do
field(:seen, :boolean, default: false)
- belongs_to(:user,
Pleroma.User
)
- belongs_to(:activity,
Pleroma.Activity
)
+ belongs_to(:user,
User, type: Pleroma.FlakeId
)
+ belongs_to(:activity,
Activity, type: Pleroma.FlakeId
)
timestamps()
end
timestamps()
end
@@
-35,7
+41,8
@@
defmodule Pleroma.Notification do
n in Notification,
where: n.user_id == ^user.id,
order_by: [desc: n.id],
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
)
limit: 20
)
@@
-66,7
+73,8
@@
defmodule Pleroma.Notification do
from(
n in Notification,
where: n.id == ^id,
from(
n in Notification,
where: n.id == ^id,
- preload: [:activity]
+ join: activity in assoc(n, :activity),
+ preload: [activity: activity]
)
notification = Repo.one(query)
)
notification = Repo.one(query)
@@
-97,7
+105,7
@@
defmodule Pleroma.Notification do
end
end
end
end
- def create_notifications(%Activity{
id: _,
data: %{"to" => _, "type" => type}} = activity)
+ def create_notifications(%Activity{data: %{"to" => _, "type" => type}} = activity)
when type in ["Create", "Like", "Announce", "Follow"] do
users = get_notified_from_activity(activity)
when type in ["Create", "Like", "Announce", "Follow"] do
users = get_notified_from_activity(activity)
@@
-110,7
+118,7
@@
defmodule Pleroma.Notification do
# TODO move to sql, too.
def create_notification(%Activity{} = activity, %User{} = user) do
unless User.blocks?(user, %{ap_id: activity.data["actor"]}) or
# TODO move to sql, too.
def create_notification(%Activity{} = activity, %User{} = user) do
unless User.blocks?(user, %{ap_id: activity.data["actor"]}) or
- user.ap_id == activity.data["actor"] or
+
CommonAPI.thread_muted?(user, activity) or
user.ap_id == activity.data["actor"] or
(activity.data["type"] == "Follow" and
Enum.any?(Notification.for_user(user), fn notif ->
notif.activity.data["type"] == "Follow" and
(activity.data["type"] == "Follow" and
Enum.any?(Notification.for_user(user), fn notif ->
notif.activity.data["type"] == "Follow" and