diff options
author | Karen Konou <konoukaren@gmail.com> | 2019-02-05 13:35:24 +0100 |
---|---|---|
committer | Karen Konou <konoukaren@gmail.com> | 2019-02-07 17:36:14 +0100 |
commit | f4ff4ffba2761925dde59ff1989dfdb232732dd7 (patch) | |
tree | a5afbb2d5dfa27aef8335c09ef72d9abf3152844 /lib | |
parent | 03991e7bc5c6309739d8e936ce312a68d9e73b5a (diff) | |
download | pleroma-f4ff4ffba2761925dde59ff1989dfdb232732dd7.tar.gz |
Migration and some boilerplate stuff
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 16 | ||||
-rw-r--r-- | lib/pleroma/web/router.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/thread_mute.ex | 26 |
3 files changed, 44 insertions, 0 deletions
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 7f3fbff4a..00b39d76b 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -445,6 +445,22 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do end end + def mute_conversation(%{assigns: %{user: user}} = conn, %{"id" => id}) do + with {:ok, activity} <- Pleroma.Web.ThreadMute.add_mute(user, id) do + conn + |> put_view(StatusView) + |> try_render("status.json", %{activity: activity, for: user, as: :activity}) + end + end + + def unmute_conversation(%{assigns: %{user: user}} = conn, %{"id" => id}) do + with {:ok, activity} <- Pleroma.Web.ThreadMute.remove_mute(user, id) do + conn + |> put_view(StatusView) + |> try_render("status.json", %{activity: activity, for: user, as: :activity}) + end + end + def notifications(%{assigns: %{user: user}} = conn, params) do notifications = Notification.for_user(user, params) diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index c6b4d37ab..3f9759ca9 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -198,6 +198,8 @@ defmodule Pleroma.Web.Router do post("/statuses/:id/unpin", MastodonAPIController, :unpin_status) post("/statuses/:id/bookmark", MastodonAPIController, :bookmark_status) post("/statuses/:id/unbookmark", MastodonAPIController, :unbookmark_status) + post("/statuses/:id/mute", MastodonAPIController, :mute_conversation) + post("/statuses/:id/unmute", MastodonAPIController, :unmute_conversation) post("/notifications/clear", MastodonAPIController, :clear_notifications) post("/notifications/dismiss", MastodonAPIController, :dismiss_notification) diff --git a/lib/pleroma/web/thread_mute.ex b/lib/pleroma/web/thread_mute.ex new file mode 100644 index 000000000..8892155cd --- /dev/null +++ b/lib/pleroma/web/thread_mute.ex @@ -0,0 +1,26 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.ThreadMute do + use Ecto.Schema + + alias Pleroma.{Activity, Notification, User} + + schema "thread_mutes" do + field(:user_id, :string) + field(:context, :string) + end + + def add_mute(user, id) do + %{id: user_id} = user + %{data: %{"context" => context}} = Activity.get_by_id(id) + Pleroma.Repo.insert(%Pleroma.Web.ThreadMute{user_id: user_id, context: context}) + end + + def remove_mute(user, id) do + end + + def mute_thread() do + end +end |