Fix 'Setting a marker should mark notifications as read'
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
5174c29d4c
commit
8cd8cea3fb
3 changed files with 45 additions and 1 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.MastodonAPI.MarkerController do
|
||||
use Pleroma.Web, :controller
|
||||
|
||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||
|
||||
plug(Pleroma.Web.ApiSpec.CastAndValidate)
|
||||
|
|
@ -30,9 +31,16 @@ defmodule Pleroma.Web.MastodonAPI.MarkerController do
|
|||
def upsert(%{assigns: %{user: user}, body_params: params} = conn, _) do
|
||||
params = Map.new(params, fn {key, value} -> {to_string(key), value} end)
|
||||
|
||||
with {:ok, result} <- Pleroma.Marker.upsert(user, params),
|
||||
with {:ok, _} <- mark_notifications_read(user, params),
|
||||
{:ok, result} <- Pleroma.Marker.upsert(user, params),
|
||||
markers <- Map.values(result) do
|
||||
render(conn, "markers.json", %{markers: markers})
|
||||
end
|
||||
end
|
||||
|
||||
defp mark_notifications_read(user, %{"notifications" => %{last_read_id: last_read_id}}) do
|
||||
Pleroma.Notification.set_read_up_to(user, last_read_id)
|
||||
end
|
||||
|
||||
defp mark_notifications_read(_, _), do: {:ok, :noop}
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue