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, []}