Merge branch 'feld-warnings' into 'develop'

Clean up warnings

See merge request pleroma/pleroma!144
This commit is contained in:
lambda 2018-05-06 18:42:31 +00:00
commit 6c2903d9a1
30 changed files with 97 additions and 107 deletions

View File

@ -1,6 +1,5 @@
defmodule Mix.Tasks.FixApUsers do defmodule Mix.Tasks.FixApUsers do
use Mix.Task use Mix.Task
import Mix.Ecto
import Ecto.Query import Ecto.Query
alias Pleroma.{Repo, User} alias Pleroma.{Repo, User}

View File

@ -1,7 +1,6 @@
defmodule Mix.Tasks.GeneratePasswordReset do defmodule Mix.Tasks.GeneratePasswordReset do
use Mix.Task use Mix.Task
import Mix.Ecto alias Pleroma.User
alias Pleroma.{Repo, User}
@shortdoc "Generate password reset link for user" @shortdoc "Generate password reset link for user"
def run([nickname]) do def run([nickname]) do

View File

@ -1,6 +1,5 @@
defmodule Mix.Tasks.RegisterUser do defmodule Mix.Tasks.RegisterUser do
use Mix.Task use Mix.Task
import Mix.Ecto
alias Pleroma.{Repo, User} alias Pleroma.{Repo, User}
@shortdoc "Register user" @shortdoc "Register user"

View File

@ -1,7 +1,6 @@
defmodule Mix.Tasks.RmUser do defmodule Mix.Tasks.RmUser do
use Mix.Task use Mix.Task
import Mix.Ecto alias Pleroma.User
alias Pleroma.{User, Repo}
@shortdoc "Permanently delete a user" @shortdoc "Permanently delete a user"
def run([nickname]) do def run([nickname]) do

View File

@ -65,12 +65,6 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do
"#{type}#{name}\t#{selector}\t#{address}\t#{port}\r\n" "#{type}#{name}\t#{selector}\t#{address}\t#{port}\r\n"
end end
def response("") do
info("Welcome to #{Keyword.get(@instance, :name, "Pleroma")}!") <>
link("Public Timeline", "/main/public") <>
link("Federated Timeline", "/main/all") <> ".\r\n"
end
def render_activities(activities) do def render_activities(activities) do
activities activities
|> Enum.reverse() |> Enum.reverse()
@ -93,6 +87,12 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do
|> Enum.join("\r\n") |> Enum.join("\r\n")
end end
def response("") do
info("Welcome to #{Keyword.get(@instance, :name, "Pleroma")}!") <>
link("Public Timeline", "/main/public") <>
link("Federated Timeline", "/main/all") <> ".\r\n"
end
def response("/main/public") do def response("/main/public") do
posts = posts =
ActivityPub.fetch_public_activities(%{"type" => ["Create"], "local_only" => true}) ActivityPub.fetch_public_activities(%{"type" => ["Create"], "local_only" => true})

View File

@ -7,11 +7,11 @@ defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do
options options
end end
def call(%{assigns: %{valid_signature: true}} = conn, opts) do def call(%{assigns: %{valid_signature: true}} = conn, _opts) do
conn conn
end end
def call(conn, opts) do def call(conn, _opts) do
user = conn.params["actor"] user = conn.params["actor"]
Logger.debug("Checking sig for #{user}") Logger.debug("Checking sig for #{user}")
[signature | _] = get_req_header(conn, "signature") [signature | _] = get_req_header(conn, "signature")

View File

@ -1,6 +1,6 @@
defmodule Pleroma.Stats do defmodule Pleroma.Stats do
import Ecto.Query import Ecto.Query
alias Pleroma.{User, Repo, Activity} alias Pleroma.{User, Repo}
def start_link do def start_link do
agent = Agent.start_link(fn -> {[], %{}} end, name: __MODULE__) agent = Agent.start_link(fn -> {[], %{}} end, name: __MODULE__)

View File

@ -66,7 +66,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
), ),
{: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 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
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 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub 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 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub 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 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub 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

View File

@ -1,7 +1,7 @@
defmodule Pleroma.Web.ActivityPub.ActivityPubController do defmodule Pleroma.Web.ActivityPub.ActivityPubController do
use Pleroma.Web, :controller use Pleroma.Web, :controller
alias Pleroma.{User, Repo, Object, Activity} alias Pleroma.{User, Object}
alias Pleroma.Web.ActivityPub.{ObjectView, UserView, Transmogrifier} alias Pleroma.Web.ActivityPub.{ObjectView, UserView}
alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.Federator alias Pleroma.Web.Federator

View File

@ -78,7 +78,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
{:ok, object} <- check_ftl_removal(actor_info, object) do {:ok, object} <- check_ftl_removal(actor_info, object) do
{:ok, object} {:ok, object}
else else
e -> {:reject, nil} _e -> {:reject, nil}
end end
end end
end end

View File

@ -146,12 +146,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end end
def handle_incoming( def handle_incoming(
%{"type" => "Like", "object" => object_id, "actor" => actor, "id" => id} = data %{"type" => "Like", "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.like(actor, object, id, false) do {:ok, activity, _object} <- ActivityPub.like(actor, object, id, false) do
{:ok, activity} {:ok, activity}
else else
_e -> :error _e -> :error
@ -159,12 +159,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
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
@ -205,7 +205,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
# 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
@ -213,13 +213,13 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
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
@ -257,10 +257,10 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|> set_reply_to_uri |> set_reply_to_uri
end end
@doc # @doc
""" # """
internal -> Mastodon # internal -> Mastodon
""" # """
def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = object} = data) do def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = object} = data) do
object = object =
@ -275,7 +275,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
{: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
@ -289,7 +289,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier 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

View File

@ -47,25 +47,6 @@ defmodule Pleroma.Web.ActivityPub.UserView 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
offset = (page - 1) * 10
items = Enum.slice(collection, offset, 10)
items = Enum.map(items, fn user -> user.ap_id end)
total = total || length(collection)
map = %{
"id" => "#{iri}?page=#{page}",
"type" => "OrderedCollectionPage",
"partOf" => iri,
"totalItems" => length(collection),
"orderedItems" => items
}
if offset < length(collection) do
Map.put(map, "next", "#{iri}?page=#{page + 1}")
end
end
def render("following.json", %{user: user, page: page}) do def render("following.json", %{user: user, page: page}) do
query = User.get_friends_query(user) query = User.get_friends_query(user)
query = from(user in query, select: [:ap_id]) query = from(user in query, select: [:ap_id])
@ -165,4 +146,23 @@ defmodule Pleroma.Web.ActivityPub.UserView do
page |> Map.merge(Utils.make_json_ld_header()) page |> Map.merge(Utils.make_json_ld_header())
end end
end end
def collection(collection, iri, page, _total \\ nil) do
offset = (page - 1) * 10
items = Enum.slice(collection, offset, 10)
items = Enum.map(items, fn user -> user.ap_id end)
total = _total || length(collection)
map = %{
"id" => "#{iri}?page=#{page}",
"type" => "OrderedCollectionPage",
"partOf" => iri,
"totalItems" => length(collection),
"orderedItems" => items
}
if offset < length(collection) do
Map.put(map, "next", "#{iri}?page=#{page + 1}")
end
end
end end

View File

@ -1,7 +1,6 @@
defmodule Pleroma.Web.UserSocket do defmodule Pleroma.Web.UserSocket do
use Phoenix.Socket use Phoenix.Socket
alias Pleroma.User alias Pleroma.User
alias Comeonin.Pbkdf2
## Channels ## Channels
# channel "room:*", Pleroma.Web.RoomChannel # channel "room:*", Pleroma.Web.RoomChannel

View File

@ -1,5 +1,5 @@
defmodule Pleroma.Web.CommonAPI do defmodule Pleroma.Web.CommonAPI do
alias Pleroma.{Repo, Activity, Object, User} alias Pleroma.{Repo, Activity, Object}
alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Formatter alias Pleroma.Formatter

View File

@ -1,5 +1,5 @@
defmodule Pleroma.Web.CommonAPI.Utils do defmodule Pleroma.Web.CommonAPI.Utils do
alias Pleroma.{Repo, Object, Formatter, User, Activity} alias Pleroma.{Repo, Object, Formatter, Activity}
alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Web.ActivityPub.Utils
alias Calendar.Strftime alias Calendar.Strftime
@ -49,7 +49,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
{[user.follower_address | to], cc} {[user.follower_address | to], cc}
end end
def to_for_user_and_mentions(user, mentions, inReplyTo, "direct") do def to_for_user_and_mentions(_user, mentions, inReplyTo, "direct") do
mentioned_users = Enum.map(mentions, fn {_, %{ap_id: ap_id}} -> ap_id end) mentioned_users = Enum.map(mentions, fn {_, %{ap_id: ap_id}} -> ap_id end)
if inReplyTo do if inReplyTo do
@ -69,7 +69,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
def make_context(%Activity{data: %{"context" => context}}), do: context def make_context(%Activity{data: %{"context" => context}}), do: context
def make_context(_), do: Utils.generate_context_id() def make_context(_), do: Utils.generate_context_id()
def maybe_add_attachments(text, attachments, _no_links = true), do: text def maybe_add_attachments(text, _attachments, _no_links = true), do: text
def maybe_add_attachments(text, attachments, _no_links) do def maybe_add_attachments(text, attachments, _no_links) do
add_attachments(text, attachments) add_attachments(text, attachments)

View File

@ -89,12 +89,12 @@ defmodule Pleroma.Web.Federator do
with {:ok, _user} <- ap_enabled_actor(params["actor"]), with {:ok, _user} <- ap_enabled_actor(params["actor"]),
nil <- Activity.get_by_ap_id(params["id"]), nil <- Activity.get_by_ap_id(params["id"]),
{:ok, activity} <- Transmogrifier.handle_incoming(params) do {:ok, _activity} <- Transmogrifier.handle_incoming(params) do
else else
%Activity{} -> %Activity{} ->
Logger.info("Already had #{params["id"]}") Logger.info("Already had #{params["id"]}")
e -> _e ->
# Just drop those for now # Just drop those for now
Logger.info("Unhandled activity") Logger.info("Unhandled activity")
Logger.info(Poison.encode!(params, pretty: 2)) Logger.info(Poison.encode!(params, pretty: 2))
@ -154,7 +154,7 @@ defmodule Pleroma.Web.Federator do
end end
end end
def handle_cast({:enqueue, type, payload, priority}, state) def handle_cast({:enqueue, type, payload, _priority}, state)
when type in [:incoming_doc, :incoming_ap_doc] do when type in [:incoming_doc, :incoming_ap_doc] do
%{in: {i_running_jobs, i_queue}, out: {o_running_jobs, o_queue}} = state %{in: {i_running_jobs, i_queue}, out: {o_running_jobs, o_queue}} = state
i_queue = enqueue_sorted(i_queue, {type, payload}, 1) i_queue = enqueue_sorted(i_queue, {type, payload}, 1)
@ -162,7 +162,7 @@ defmodule Pleroma.Web.Federator do
{:noreply, %{in: {i_running_jobs, i_queue}, out: {o_running_jobs, o_queue}}} {:noreply, %{in: {i_running_jobs, i_queue}, out: {o_running_jobs, o_queue}}}
end end
def handle_cast({:enqueue, type, payload, priority}, state) do def handle_cast({:enqueue, type, payload, _priority}, state) do
%{in: {i_running_jobs, i_queue}, out: {o_running_jobs, o_queue}} = state %{in: {i_running_jobs, i_queue}, out: {o_running_jobs, o_queue}} = state
o_queue = enqueue_sorted(o_queue, {type, payload}, 1) o_queue = enqueue_sorted(o_queue, {type, payload}, 1)
{o_running_jobs, o_queue} = maybe_start_job(o_running_jobs, o_queue) {o_running_jobs, o_queue} = maybe_start_job(o_running_jobs, o_queue)

View File

@ -45,7 +45,7 @@ defmodule Pleroma.Web.HTTPSignatures do
end end
end end
else else
e -> _e ->
Logger.debug("Could not public key!") Logger.debug("Could not public key!")
false false
end end

View File

@ -82,19 +82,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
} }
end end
def get_reply_to(activity, %{replied_to_activities: replied_to_activities}) do
id = activity.data["object"]["inReplyTo"]
replied_to_activities[activity.data["object"]["inReplyTo"]]
end
def get_reply_to(%{data: %{"object" => object}}, _) do
if object["inReplyTo"] && object["inReplyTo"] != "" do
Activity.get_create_activity_by_object_ap_id(object["inReplyTo"])
else
nil
end
end
def render("status.json", %{activity: %{data: %{"object" => object}} = activity} = opts) do def render("status.json", %{activity: %{data: %{"object" => object}} = activity} = opts) do
user = User.get_cached_by_ap_id(activity.data["actor"]) user = User.get_cached_by_ap_id(activity.data["actor"])
@ -164,19 +151,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
} }
end end
def get_visibility(object) do
public = "https://www.w3.org/ns/activitystreams#Public"
to = object["to"] || []
cc = object["cc"] || []
cond do
public in to -> "public"
public in cc -> "unlisted"
Enum.any?(to, &String.contains?(&1, "/followers")) -> "private"
true -> "direct"
end
end
def render("attachment.json", %{attachment: attachment}) do def render("attachment.json", %{attachment: attachment}) do
[%{"mediaType" => media_type, "href" => href} | _] = attachment["url"] [%{"mediaType" => media_type, "href" => href} | _] = attachment["url"]
@ -199,4 +173,30 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
type: type type: type
} }
end end
def get_reply_to(activity, %{replied_to_activities: replied_to_activities}) do
_id = activity.data["object"]["inReplyTo"]
replied_to_activities[activity.data["object"]["inReplyTo"]]
end
def get_reply_to(%{data: %{"object" => object}}, _) do
if object["inReplyTo"] && object["inReplyTo"] != "" do
Activity.get_create_activity_by_object_ap_id(object["inReplyTo"])
else
nil
end
end
def get_visibility(object) do
public = "https://www.w3.org/ns/activitystreams#Public"
to = object["to"] || []
cc = object["cc"] || []
cond do
public in to -> "public"
public in cc -> "unlisted"
Enum.any?(to, &String.contains?(&1, "/followers")) -> "private"
true -> "direct"
end
end
end end

View File

@ -1,7 +1,6 @@
defmodule Pleroma.Web.Nodeinfo.NodeinfoController do defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
use Pleroma.Web, :controller use Pleroma.Web, :controller
alias Pleroma.Web.Nodeinfo
alias Pleroma.Stats alias Pleroma.Stats
alias Pleroma.Web alias Pleroma.Web

View File

@ -1,7 +1,6 @@
defmodule Pleroma.Web.OStatus.ActivityRepresenter do defmodule Pleroma.Web.OStatus.ActivityRepresenter do
alias Pleroma.{Activity, User, Object} alias Pleroma.{Activity, User, Object}
alias Pleroma.Web.OStatus.UserRepresenter alias Pleroma.Web.OStatus.UserRepresenter
alias Pleroma.Formatter
require Logger require Logger
defp get_href(id) do defp get_href(id) do

View File

@ -1,7 +1,7 @@
defmodule Pleroma.Web.OStatus.NoteHandler do defmodule Pleroma.Web.OStatus.NoteHandler do
require Logger require Logger
alias Pleroma.Web.{XML, OStatus} alias Pleroma.Web.{XML, OStatus}
alias Pleroma.{Object, User, Activity} alias Pleroma.{Object, Activity}
alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI

View File

@ -8,7 +8,6 @@ defmodule Pleroma.Web.OStatus.OStatusController do
alias Pleroma.Web.XML alias Pleroma.Web.XML
alias Pleroma.Web.ActivityPub.ActivityPubController alias Pleroma.Web.ActivityPub.ActivityPubController
alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.ActivityPub
import Ecto.Query
def feed_redirect(conn, %{"nickname" => nickname} = params) do def feed_redirect(conn, %{"nickname" => nickname} = params) do
user = User.get_cached_by_nickname(nickname) user = User.get_cached_by_nickname(nickname)

View File

@ -92,7 +92,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
with %User{} = user <- User.get_cached_by_nickname(username), with %User{} = user <- User.get_cached_by_nickname(username),
true <- Pbkdf2.checkpw(password, user.password_hash), true <- Pbkdf2.checkpw(password, user.password_hash),
%User{} = followed <- Repo.get(User, id), %User{} = _followed <- Repo.get(User, id),
{:ok, follower} <- User.follow(user, followee), {:ok, follower} <- User.follow(user, followee),
{:ok, _activity} <- ActivityPub.follow(follower, followee) do {:ok, _activity} <- ActivityPub.follow(follower, followee) do
conn conn

View File

@ -1,7 +1,6 @@
defmodule Pleroma.Web.TwitterAPI.TwitterAPI do defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
alias Pleroma.{User, Activity, Repo, Object} alias Pleroma.{User, Activity, Repo, Object}
alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
alias Pleroma.Web.TwitterAPI.UserView alias Pleroma.Web.TwitterAPI.UserView
alias Pleroma.Web.{OStatus, CommonAPI} alias Pleroma.Web.{OStatus, CommonAPI}
import Ecto.Query import Ecto.Query
@ -184,7 +183,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
defp parse_int(_, default), do: default defp parse_int(_, default), do: default
def search(user, %{"q" => query} = params) do def search(_user, %{"q" => query} = params) do
limit = parse_int(params["rpp"], 20) limit = parse_int(params["rpp"], 20)
page = parse_int(params["page"], 1) page = parse_int(params["page"], 1)
offset = (page - 1) * limit offset = (page - 1) * limit
@ -206,7 +205,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
order_by: [desc: :inserted_at] order_by: [desc: :inserted_at]
) )
activities = Repo.all(q) _activities = Repo.all(q)
end end
defp make_date do defp make_date do

View File

@ -31,7 +31,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView 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} ->

View File

@ -2,7 +2,6 @@ defmodule Pleroma.Web.TwitterAPI.NotificationView do
use Pleroma.Web, :view use Pleroma.Web, :view
alias Pleroma.{Notification, User} alias Pleroma.{Notification, User}
alias Pleroma.Web.CommonAPI.Utils alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.MediaProxy
alias Pleroma.Web.TwitterAPI.UserView alias Pleroma.Web.TwitterAPI.UserView
alias Pleroma.Web.TwitterAPI.ActivityView alias Pleroma.Web.TwitterAPI.ActivityView

View File

@ -1,7 +1,7 @@
defmodule Pleroma.Web.WebFinger do defmodule Pleroma.Web.WebFinger do
@httpoison Application.get_env(:pleroma, :httpoison) @httpoison Application.get_env(:pleroma, :httpoison)
alias Pleroma.{Repo, User, XmlBuilder} alias Pleroma.{User, XmlBuilder}
alias Pleroma.Web alias Pleroma.Web
alias Pleroma.Web.{XML, Salmon, OStatus} alias Pleroma.Web.{XML, Salmon, OStatus}
require Jason require Jason

View File

@ -14,7 +14,7 @@ defmodule Pleroma.Web.XML do
if res == "", do: nil, else: res if res == "", do: nil, else: res
catch catch
e -> _e ->
Logger.debug("Couldn't find xpath #{xpath} in XML doc") Logger.debug("Couldn't find xpath #{xpath} in XML doc")
nil nil
end end

View File

@ -26,7 +26,7 @@ defmodule Pleroma.Builders.ActivityBuilder do
end end
def insert_list(times, data \\ %{}, opts \\ %{}) do def insert_list(times, data \\ %{}, opts \\ %{}) do
Enum.map(1..times, fn n -> Enum.map(1..times, fn _n ->
{:ok, activity} = insert(data, opts) {:ok, activity} = insert(data, opts)
activity activity
end) end)

View File

@ -367,7 +367,7 @@ defmodule HTTPoisonMock do
def post( def post(
"https://social.heldscal.la/main/push/hub", "https://social.heldscal.la/main/push/hub",
{:form, data}, {:form, _data},
"Content-type": "application/x-www-form-urlencoded" "Content-type": "application/x-www-form-urlencoded"
) do ) do
{:ok, {:ok,
@ -711,11 +711,11 @@ defmodule HTTPoisonMock do
}"} }"}
end end
def post(url, body, headers) do def post(url, _body, _headers) do
{:error, "Not implemented the mock response for post #{inspect(url)}"} {:error, "Not implemented the mock response for post #{inspect(url)}"}
end end
def post(url, body, headers, options) do def post(url, _body, _headers, _options) do
{:error, "Not implemented the mock response for post #{inspect(url)}"} {:error, "Not implemented the mock response for post #{inspect(url)}"}
end end
end end