aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexander Strizhakov <alex.strizhakov@gmail.com>2019-04-12 02:28:46 +0000
committerkaniini <nenolod@gmail.com>2019-04-12 02:28:46 +0000
commit711ade961e43daaf7dc89aa6fd6da1faffc152ff (patch)
tree0466472c90a80bb14dc07a5e6a1a14d6827a4a00 /lib
parent9825a943917321204d26ca1b486491138c8c82da (diff)
downloadpleroma-711ade961e43daaf7dc89aa6fd6da1faffc152ff.tar.gz
adding destroy multiple for mastofe
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/notification.ex11
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex5
-rw-r--r--lib/pleroma/web/router.ex1
3 files changed, 15 insertions, 2 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 15789907a..b357d5399 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -98,6 +98,14 @@ defmodule Pleroma.Notification do
|> Repo.delete_all()
end
+ def destroy_multiple(%{id: user_id} = _user, ids) do
+ from(n in Notification,
+ where: n.id in ^ids,
+ where: n.user_id == ^user_id
+ )
+ |> Repo.delete_all()
+ end
+
def dismiss(%{id: user_id} = _user, id) do
notification = Repo.get(Notification, id)
@@ -173,8 +181,7 @@ defmodule Pleroma.Notification do
def skip?(:muted, activity, user) do
actor = activity.data["actor"]
- User.mutes?(user, %{ap_id: actor}) or
- CommonAPI.thread_muted?(user, activity)
+ User.mutes?(user, %{ap_id: actor}) or CommonAPI.thread_muted?(user, activity)
end
def skip?(
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index ed082abdf..f3865b2f2 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -612,6 +612,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
end
end
+ def destroy_multiple(%{assigns: %{user: user}} = conn, %{"ids" => ids} = _params) do
+ Notification.destroy_multiple(user, ids)
+ json(conn, %{})
+ end
+
def relationships(%{assigns: %{user: user}} = conn, %{"id" => id}) do
id = List.wrap(id)
q = from(u in User, where: u.id in ^id)
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 172f337db..a809347be 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -261,6 +261,7 @@ defmodule Pleroma.Web.Router do
post("/notifications/dismiss", MastodonAPIController, :dismiss_notification)
get("/notifications", MastodonAPIController, :notifications)
get("/notifications/:id", MastodonAPIController, :get_notification)
+ delete("/notifications/destroy_multiple", MastodonAPIController, :destroy_multiple)
get("/scheduled_statuses", MastodonAPIController, :scheduled_statuses)
get("/scheduled_statuses/:id", MastodonAPIController, :show_scheduled_status)