summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2024-08-16 00:36:31 +0000
committerfeld <feld@feld.me>2024-08-16 00:36:31 +0000
commitc91fc03e6193cb82e5565abf7eee157210252152 (patch)
tree6789bde6aa322913708cafee0489fc699177b74d /lib
parent3119ed3648b29ff1ef70045ef9f7d10f92906a5d (diff)
parent8cd8cea3fb5ce87e5f92dfb45a667c47f78b6b02 (diff)
downloadpleroma-c91fc03e6193cb82e5565abf7eee157210252152.tar.gz
pleroma-c91fc03e6193cb82e5565abf7eee157210252152.zip
Merge branch 'norifications-marker' into 'develop'
Fix 'Setting a marker should mark notifications as read' Closes #2769 See merge request pleroma/pleroma!4223
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/marker_controller.ex10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/controllers/marker_controller.ex b/lib/pleroma/web/mastodon_api/controllers/marker_controller.ex
index 4ad30f330..42b2a201d 100644
--- a/lib/pleroma/web/mastodon_api/controllers/marker_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/marker_controller.ex
@@ -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