do: Repo.all(from(u in User, where: u.ap_id in ^user.info.blocks))
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
info_cng =
def maybe_notify_mentioned_recipients(recipients, _), do: recipients
def maybe_notify_subscribers(
- recipients,
- %Activity{data: %{"actor" => actor, "type" => type}}
- ) when type == "Create" do
- with %User{} = user <- User.get_by_ap_id(actor) do
+ recipients,
+ %Activity{data: %{"actor" => actor, "type" => type}}
+ )
+ when type == "Create" do
+ with %User{} = user <- User.get_by_ap_id(actor) do
subscriber_ids =
user
|> User.subscribed_users()
{:error, msg} ->
forbidden_json_reply(conn, msg)
end
- end
+ end
def unsubscribe(%{assigns: %{user: user}} = conn, params) do
case TwitterAPI.unsubscribe(user, params) do
conn
|> put_view(UserView)
|> render("show.json", %{user: unsubscribed, for: user})
-
+
{:error, msg} ->
forbidden_json_reply(conn, msg)
end