logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: 64a4c147b1836be8af0c87b23073ed82bb9cf67c
parent 5c573a8a282725a9f2595fa264d794870a832a8a
Author: marcin mikołajczak <git@mkljczk.pl>
Date:   Mon,  6 Dec 2021 18:00:58 +0100

MastoAPI: accept notify param in follow request

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>

Diffstat:

Mlib/pleroma/web/api_spec/operations/account_operation.ex6++++++
Mlib/pleroma/web/mastodon_api/mastodon_api.ex12+++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/lib/pleroma/web/api_spec/operations/account_operation.ex b/lib/pleroma/web/api_spec/operations/account_operation.ex @@ -226,6 +226,12 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do type: :boolean, description: "Receive this account's reblogs in home timeline? Defaults to true.", default: true + }, + notify: %Schema{ + type: :boolean, + description: + "Receive notifications for all statuses posted by the account? Defaults to false.", + default: false } } }, diff --git a/lib/pleroma/web/mastodon_api/mastodon_api.ex b/lib/pleroma/web/mastodon_api/mastodon_api.ex @@ -24,6 +24,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do with {:ok, follower, _followed, _} <- result do options = cast_params(params) set_reblogs_visibility(options[:reblogs], result) + set_subscription(options[:notify], result) {:ok, follower} end end @@ -36,6 +37,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do CommonAPI.show_reblogs(follower, followed) end + defp set_subscription(true, {:ok, follower, followed, _}) do + User.subscribe(follower, followed) + end + + defp set_subscription(_, {:ok, follower, followed, _}) do + User.unsubscribe(follower, followed) + end + @spec get_followers(User.t(), map()) :: list(User.t()) def get_followers(user, params \\ %{}) do user @@ -73,7 +82,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do exclude_visibilities: {:array, :string}, reblogs: :boolean, with_muted: :boolean, - account_ap_id: :string + account_ap_id: :string, + notify: :boolean } changeset = cast({%{}, param_types}, params, Map.keys(param_types))