Make subscriptions the same direction as blocks
That being, user - subscribes to -> users, rather than user - has subscribers -> users
This commit is contained in:
parent
23c4f49494
commit
316fe20d86
|
@ -1006,7 +1006,12 @@ def blocked_users(user),
|
||||||
do: Repo.all(from(u in User, where: u.ap_id in ^user.info.blocks))
|
do: Repo.all(from(u in User, where: u.ap_id in ^user.info.blocks))
|
||||||
|
|
||||||
def subscribed_users(user),
|
def subscribed_users(user),
|
||||||
do: Repo.all(from(u in User, where: u.ap_id in ^user.info.subscriptions))
|
do:
|
||||||
|
Repo.all(
|
||||||
|
from(u in User,
|
||||||
|
where: fragment("?->'subscriptions' @> ?", u.info, ^user.ap_id)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def block_domain(user, domain) do
|
def block_domain(user, domain) do
|
||||||
info_cng =
|
info_cng =
|
||||||
|
|
|
@ -336,10 +336,11 @@ def maybe_notify_mentioned_recipients(
|
||||||
def maybe_notify_mentioned_recipients(recipients, _), do: recipients
|
def maybe_notify_mentioned_recipients(recipients, _), do: recipients
|
||||||
|
|
||||||
def maybe_notify_subscribers(
|
def maybe_notify_subscribers(
|
||||||
recipients,
|
recipients,
|
||||||
%Activity{data: %{"actor" => actor, "type" => type}}
|
%Activity{data: %{"actor" => actor, "type" => type}}
|
||||||
) when type == "Create" do
|
)
|
||||||
with %User{} = user <- User.get_by_ap_id(actor) do
|
when type == "Create" do
|
||||||
|
with %User{} = user <- User.get_by_ap_id(actor) do
|
||||||
subscriber_ids =
|
subscriber_ids =
|
||||||
user
|
user
|
||||||
|> User.subscribed_users()
|
|> User.subscribed_users()
|
||||||
|
|
|
@ -279,7 +279,7 @@ def subscribe(%{assigns: %{user: user}} = conn, params) do
|
||||||
{:error, msg} ->
|
{:error, msg} ->
|
||||||
forbidden_json_reply(conn, msg)
|
forbidden_json_reply(conn, msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unsubscribe(%{assigns: %{user: user}} = conn, params) do
|
def unsubscribe(%{assigns: %{user: user}} = conn, params) do
|
||||||
case TwitterAPI.unsubscribe(user, params) do
|
case TwitterAPI.unsubscribe(user, params) do
|
||||||
|
@ -287,7 +287,7 @@ def unsubscribe(%{assigns: %{user: user}} = conn, params) do
|
||||||
conn
|
conn
|
||||||
|> put_view(UserView)
|
|> put_view(UserView)
|
||||||
|> render("show.json", %{user: unsubscribed, for: user})
|
|> render("show.json", %{user: unsubscribed, for: user})
|
||||||
|
|
||||||
{:error, msg} ->
|
{:error, msg} ->
|
||||||
forbidden_json_reply(conn, msg)
|
forbidden_json_reply(conn, msg)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue