|> Multi.insert(:notification, %Notification{
user_id: user.id,
activity: activity,
+ seen: mark_as_read?(activity, user),
type: type_from_activity(activity)
})
|> Marker.multi_set_last_read_id(user, "notifications")
def skip?(_, _, _), do: false
+ def mark_as_read?(activity, target_user) do
+ user = Activity.user_actor(activity)
+ User.mutes_user?(target_user, user)
+ end
+
def for_user_and_activity(user, activity) do
from(n in __MODULE__,
where: n.user_id == ^user.id,
muter = Repo.get(User, muter.id)
{:ok, activity} = CommonAPI.post(muted, %{status: "Hi @#{muter.nickname}"})
- assert Notification.create_notification(activity, muter)
+ notification = Notification.create_notification(activity, muter)
+
+ assert notification.id
+ assert notification.seen
end
test "notification created if user is muted without notifications" do
[notification] = Notification.for_user(user)
assert notification.activity.object
+ assert notification.seen
end
test "it doesn't return notifications for muted user with notifications", %{user: user} do
expected = %{
id: to_string(notification.id),
- pleroma: %{is_seen: false, is_muted: true},
+ pleroma: %{is_seen: true, is_muted: true},
type: "favourite",
account: AccountView.render("show.json", %{user: another_user, for: user}),
status: StatusView.render("show.json", %{activity: create_activity, for: user}),