X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fmarker.ex;h=4439273922d2916e11886c302e9f7603b237ea07;hb=764b4f95a8e9e751d5a6136fc2be44d61a082443;hp=d5ca27bf202beefac048a74e02ff2b08d22fdb8e;hpb=ddbfc995ac40db9bd1da137b03e5acf6d050ddc5;p=akkoma
diff --git a/lib/pleroma/marker.ex b/lib/pleroma/marker.ex
index d5ca27bf2..443927392 100644
--- a/lib/pleroma/marker.ex
+++ b/lib/pleroma/marker.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Marker do
@@ -11,7 +11,6 @@ defmodule Pleroma.Marker do
alias Ecto.Multi
alias Pleroma.Repo
alias Pleroma.User
- alias __MODULE__
@timelines ["notifications"]
@@ -19,7 +18,6 @@ defmodule Pleroma.Marker do
field(:last_read_id, :string, default: "")
field(:timeline, :string, default: "")
field(:lock_version, :integer, default: 0)
- field(:unread_count, :integer, default: 0)
belongs_to(:user, User, type: FlakeId.Ecto.CompatType)
timestamps()
@@ -40,34 +38,13 @@ defmodule Pleroma.Marker do
Multi.insert(multi, timeline, marker,
returning: true,
- on_conflict: {:replace, [:last_read_id, :unread_count]},
+ on_conflict: {:replace, [:last_read_id]},
conflict_target: [:user_id, :timeline]
)
end)
|> Repo.transaction()
end
- @spec multi_set_unread_count(Multi.t(), User.t(), String.t()) :: Multi.t()
- def multi_set_unread_count(multi, %User{} = user, "notifications") do
- multi
- |> Multi.run(:counters, fn _repo, _changes ->
- {:ok, Repo.one(Pleroma.Notification.notifications_info_query(user))}
- end)
- |> Multi.insert(
- :marker,
- fn %{counters: attrs} ->
- %Marker{timeline: "notifications", user_id: user.id}
- |> struct(attrs)
- |> Ecto.Changeset.change()
- end,
- returning: true,
- on_conflict: {:replace, [:last_read_id, :unread_count]},
- conflict_target: [:user_id, :timeline]
- )
- end
-
- def multi_set_unread_count(multi, _, _), do: multi
-
defp get_marker(user, timeline) do
case Repo.find_resource(get_query(user, timeline)) do
{:ok, marker} -> %__MODULE__{marker | user: user}
@@ -78,7 +55,7 @@ defmodule Pleroma.Marker do
@doc false
defp changeset(marker, attrs) do
marker
- |> cast(attrs, [:last_read_id, :unread_count])
+ |> cast(attrs, [:last_read_id])
|> validate_required([:user_id, :timeline, :last_read_id])
|> validate_inclusion(:timeline, @timelines)
end