diff options
author | kaniini <nenolod@gmail.com> | 2019-03-16 00:30:04 +0000 |
---|---|---|
committer | kaniini <nenolod@gmail.com> | 2019-03-16 00:30:04 +0000 |
commit | 532e8b0a43f496cb2cab75850c385a9f17aee84e (patch) | |
tree | 31b8bc6913a212c1739aa6b27feec0c8ac1b16bf /lib/pleroma/web/twitter_api/controllers/util_controller.ex | |
parent | 4b3c86c1a61a029202a262229c713cc3737b2a1b (diff) | |
parent | 43fb03be5a8968c1df23938ed4f5a93825ab476c (diff) | |
download | pleroma-532e8b0a43f496cb2cab75850c385a9f17aee84e.tar.gz |
Merge branch 'mark-notifications-as-read' into 'develop'
Allow to mark a single notification as read
See merge request pleroma/pleroma!941
Diffstat (limited to 'lib/pleroma/web/twitter_api/controllers/util_controller.ex')
-rw-r--r-- | lib/pleroma/web/twitter_api/controllers/util_controller.ex | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index 8ed02a93f..320ec778c 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -9,6 +9,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do alias Comeonin.Pbkdf2 alias Pleroma.Emoji + alias Pleroma.Notification alias Pleroma.PasswordResetToken alias Pleroma.Repo alias Pleroma.User @@ -142,6 +143,17 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do end end + def notifications_read(%{assigns: %{user: user}} = conn, %{"id" => notification_id}) do + with {:ok, _} <- Notification.read_one(user, notification_id) do + json(conn, %{status: "success"}) + else + {:error, message} -> + conn + |> put_resp_content_type("application/json") + |> send_resp(403, Jason.encode!(%{"error" => message})) + end + end + def config(conn, _params) do instance = Pleroma.Config.get(:instance) instance_fe = Pleroma.Config.get(:fe) |