More unused variables
This commit is contained in:
parent
5855ffd322
commit
943820ae29
|
@ -66,7 +66,7 @@ def create(%{to: to, actor: actor, context: context, object: object} = params) d
|
||||||
),
|
),
|
||||||
{:ok, activity} <- insert(create_data, local),
|
{:ok, activity} <- insert(create_data, local),
|
||||||
:ok <- maybe_federate(activity),
|
:ok <- maybe_federate(activity),
|
||||||
{:ok, actor} <- User.increase_note_count(actor) do
|
{:ok, _actor} <- User.increase_note_count(actor) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -177,7 +177,7 @@ def delete(%Object{data: %{"id" => id, "actor" => actor}} = object, local \\ tru
|
||||||
Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id)),
|
Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id)),
|
||||||
{:ok, activity} <- insert(data, local),
|
{:ok, activity} <- insert(data, local),
|
||||||
:ok <- maybe_federate(activity),
|
:ok <- maybe_federate(activity),
|
||||||
{:ok, actor} <- User.decrease_note_count(user) do
|
{:ok, _actor} <- User.decrease_note_count(user) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -236,7 +236,7 @@ defp restrict_tag(query, %{"tag" => tag}) do
|
||||||
|
|
||||||
defp restrict_tag(query, _), do: query
|
defp restrict_tag(query, _), do: query
|
||||||
|
|
||||||
defp restrict_recipients(query, [], user), do: query
|
defp restrict_recipients(query, [], _user), do: query
|
||||||
|
|
||||||
defp restrict_recipients(query, recipients, nil) do
|
defp restrict_recipients(query, recipients, nil) do
|
||||||
from(activity in query, where: fragment("? && ?", ^recipients, activity.recipients))
|
from(activity in query, where: fragment("? && ?", ^recipients, activity.recipients))
|
||||||
|
@ -400,7 +400,7 @@ def fetch_and_prepare_user_from_ap_id(ap_id) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_user_from_ap_id(ap_id) do
|
def make_user_from_ap_id(ap_id) do
|
||||||
if user = User.get_by_ap_id(ap_id) do
|
if _user = User.get_by_ap_id(ap_id) do
|
||||||
Transmogrifier.upgrade_user_from_ap_id(ap_id)
|
Transmogrifier.upgrade_user_from_ap_id(ap_id)
|
||||||
else
|
else
|
||||||
with {:ok, data} <- fetch_and_prepare_user_from_ap_id(ap_id) do
|
with {:ok, data} <- fetch_and_prepare_user_from_ap_id(ap_id) do
|
||||||
|
@ -496,7 +496,7 @@ def fetch_object_from_id(id) do
|
||||||
object = %Object{} ->
|
object = %Object{} ->
|
||||||
{:ok, object}
|
{:ok, object}
|
||||||
|
|
||||||
e ->
|
_e ->
|
||||||
Logger.info("Couldn't get object via AP, trying out OStatus fetching...")
|
Logger.info("Couldn't get object via AP, trying out OStatus fetching...")
|
||||||
|
|
||||||
case OStatus.fetch_activity_from_url(id) do
|
case OStatus.fetch_activity_from_url(id) do
|
||||||
|
|
|
@ -156,12 +156,12 @@ def handle_incoming(
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_incoming(
|
def handle_incoming(
|
||||||
%{"type" => "Announce", "object" => object_id, "actor" => actor, "id" => id} = data
|
%{"type" => "Announce", "object" => object_id, "actor" => actor, "id" => id} = _data
|
||||||
) do
|
) do
|
||||||
with %User{} = actor <- User.get_or_fetch_by_ap_id(actor),
|
with %User{} = actor <- User.get_or_fetch_by_ap_id(actor),
|
||||||
{:ok, object} <-
|
{:ok, object} <-
|
||||||
get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id),
|
get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id),
|
||||||
{:ok, activity, object} <- ActivityPub.announce(actor, object, id, false) do
|
{:ok, activity, _object} <- ActivityPub.announce(actor, object, id, false) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
_e -> :error
|
_e -> :error
|
||||||
|
@ -202,7 +202,7 @@ def handle_incoming(
|
||||||
|
|
||||||
# TODO: Make secure.
|
# TODO: Make secure.
|
||||||
def handle_incoming(
|
def handle_incoming(
|
||||||
%{"type" => "Delete", "object" => object_id, "actor" => actor, "id" => id} = data
|
%{"type" => "Delete", "object" => object_id, "actor" => actor, "id" => _id} = _data
|
||||||
) do
|
) do
|
||||||
object_id =
|
object_id =
|
||||||
case object_id do
|
case object_id do
|
||||||
|
@ -210,13 +210,13 @@ def handle_incoming(
|
||||||
id -> id
|
id -> id
|
||||||
end
|
end
|
||||||
|
|
||||||
with %User{} = actor <- User.get_or_fetch_by_ap_id(actor),
|
with %User{} = _actor <- User.get_or_fetch_by_ap_id(actor),
|
||||||
{:ok, object} <-
|
{:ok, object} <-
|
||||||
get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id),
|
get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id),
|
||||||
{:ok, activity} <- ActivityPub.delete(object, false) do
|
{:ok, activity} <- ActivityPub.delete(object, false) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
e -> :error
|
_e -> :error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = obj
|
||||||
{:ok, data}
|
{:ok, data}
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_outgoing(%{"type" => type} = data) do
|
def prepare_outgoing(%{"type" => _type} = data) do
|
||||||
data =
|
data =
|
||||||
data
|
data
|
||||||
|> maybe_fix_object_url
|
|> maybe_fix_object_url
|
||||||
|
@ -286,7 +286,7 @@ def maybe_fix_object_url(data) do
|
||||||
case ActivityPub.fetch_object_from_id(data["object"]) do
|
case ActivityPub.fetch_object_from_id(data["object"]) do
|
||||||
{:ok, relative_object} ->
|
{:ok, relative_object} ->
|
||||||
if relative_object.data["external_url"] do
|
if relative_object.data["external_url"] do
|
||||||
data =
|
_data =
|
||||||
data
|
data
|
||||||
|> Map.put("object", relative_object.data["external_url"])
|
|> Map.put("object", relative_object.data["external_url"])
|
||||||
else
|
else
|
||||||
|
|
|
@ -47,11 +47,11 @@ def render("user.json", %{user: user}) do
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
end
|
end
|
||||||
|
|
||||||
def collection(collection, iri, page, total \\ nil) do
|
def collection(collection, iri, page, _total \\ nil) do
|
||||||
offset = (page - 1) * 10
|
offset = (page - 1) * 10
|
||||||
items = Enum.slice(collection, offset, 10)
|
items = Enum.slice(collection, offset, 10)
|
||||||
items = Enum.map(items, fn user -> user.ap_id end)
|
items = Enum.map(items, fn user -> user.ap_id end)
|
||||||
total = total || length(collection)
|
_total = _total || length(collection)
|
||||||
|
|
||||||
map = %{
|
map = %{
|
||||||
"id" => "#{iri}?page=#{page}",
|
"id" => "#{iri}?page=#{page}",
|
||||||
|
|
|
@ -31,7 +31,7 @@ defp query_users(user_ids) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp collect_context_ids(activities) do
|
defp collect_context_ids(activities) do
|
||||||
contexts =
|
_contexts =
|
||||||
activities
|
activities
|
||||||
|> Enum.reject(& &1.data["context_id"])
|
|> Enum.reject(& &1.data["context_id"])
|
||||||
|> Enum.map(fn %{data: data} ->
|
|> Enum.map(fn %{data: data} ->
|
||||||
|
|
Loading…
Reference in New Issue