timestamps()
end
+ @spec unread_notifications_count(User.t()) :: integer()
+ def unread_notifications_count(%User{id: user_id}) do
+ from(q in __MODULE__,
+ where: q.user_id == ^user_id and q.seen == false
+ )
+ |> Repo.aggregate(:count, :id)
+ end
+
def changeset(%Notification{} = notification, attrs) do
notification
|> cast(attrs, [:seen])
end
def create_notifications(%Activity{data: %{"to" => _, "type" => "Create"}} = activity) do
- object = Object.normalize(activity)
+ object = Object.normalize(activity, false)
if object && object.data["type"] == "Answer" do
{:ok, []}
end
end
- def create_notifications(%Activity{data: %{"type" => "Follow"}} = activity) do
- if Pleroma.Config.get([:notifications, :enable_follow_request_notifications]) ||
- Activity.follow_accepted?(activity) do
- do_create_notifications(activity)
- else
- {:ok, []}
- end
- end
-
def create_notifications(%Activity{data: %{"type" => type}} = activity)
- when type in ["Like", "Announce", "Move", "EmojiReact"] do
+ when type in ["Follow", "Like", "Announce", "Move", "EmojiReact"] do
do_create_notifications(activity)
end