Commit 074fa790 authored by Maksim's avatar Maksim
Browse files

fix compile warnings

parent cf85a9ae
defmodule Pleroma.Web.MastodonAPI.MastodonView do
use Pleroma.Web, :view
import Phoenix.HTML
import Phoenix.HTML.Form
end
defmodule Pleroma.Web.MastodonAPI.PushSubscriptionView do
use Pleroma.Web, :view
alias Pleroma.Web.MastodonAPI.PushSubscriptionView
def render("push_subscription.json", %{subscription: subscription}) do
%{
......
......@@ -8,7 +8,7 @@ def remote(conn, params = %{"sig" => sig64, "url" => url64}) do
with config <- Pleroma.Config.get([:media_proxy], []),
true <- Keyword.get(config, :enabled, false),
{:ok, url} <- MediaProxy.decode_url(sig64, url64),
filename <- Path.basename(URI.parse(url).path),
_filename <- Path.basename(URI.parse(url).path),
:ok <- filename_matches(Map.has_key?(params, "filename"), conn.request_path, url) do
ReverseProxy.call(conn, url, Keyword.get(config, :proxy_opts, @default_proxy_opts))
else
......
......@@ -121,7 +121,7 @@ def token_exchange(
def token_exchange(
conn,
%{"grant_type" => "password", "name" => name, "password" => password} = params
%{"grant_type" => "password", "name" => name, "password" => _password} = params
) do
params =
params
......
......@@ -376,7 +376,7 @@ def fetch_activity_from_html_url(url) do
def fetch_activity_from_url(url) do
try do
with {:ok, activities} when length(activities) > 0 <- fetch_activity_from_atom_url(url) do
with {:ok, activities} when activities != [] <- fetch_activity_from_atom_url(url) do
{:ok, activities}
else
_e ->
......
......@@ -157,7 +157,7 @@ defp represent_activity(
conn,
"activity+json",
%Activity{data: %{"type" => "Create"}} = activity,
user
_user
) do
object = Object.normalize(activity.data["object"])
......@@ -166,7 +166,7 @@ defp represent_activity(
|> json(ObjectView.render("object.json", %{object: object}))
end
defp represent_activity(conn, "activity+json", _, _) do
defp represent_activity(_conn, "activity+json", _, _) do
{:error, :not_found}
end
......
defmodule Pleroma.Web.Router do
use Pleroma.Web, :router
alias Pleroma.{Repo, User, Web.Router}
pipeline :api do
plug(:accepts, ["json"])
plug(:fetch_session)
......
......@@ -61,8 +61,6 @@ def handle_cast(%{action: :stream, topic: "direct", item: item}, topics) do
end
def handle_cast(%{action: :stream, topic: "list", item: item}, topics) do
author = User.get_cached_by_ap_id(item.data["actor"])
# filter the recipient list if the activity is not public, see #270.
recipient_lists =
case ActivityPub.is_public?(item) do
......
......@@ -6,9 +6,8 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
alias Pleroma.Web.WebFinger
alias Pleroma.Web.CommonAPI
alias Comeonin.Pbkdf2
alias Pleroma.{Formatter, Emoji}
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.{Repo, PasswordResetToken, User}
alias Pleroma.{Repo, PasswordResetToken, User, Emoji}
def show_password_reset(conn, %{"token" => token}) do
with %{used: false} = token <- Repo.get_by(PasswordResetToken, %{token: token}),
......
......@@ -141,7 +141,7 @@ def to_map(
end
def to_map(
%Activity{data: %{"object" => %{"content" => content} = object}} = activity,
%Activity{data: %{"object" => %{"content" => _content} = object}} = activity,
%{user: user} = opts
) do
created_at = object["published"] |> Utils.date_to_asctime()
......@@ -165,7 +165,7 @@ def to_map(
tags = if possibly_sensitive, do: Enum.uniq(["nsfw" | tags]), else: tags
{summary, content} = ActivityView.render_content(object)
{_summary, content} = ActivityView.render_content(object)
html =
HTML.filter_tags(content, User.html_filter_policy(opts[:for]))
......@@ -173,7 +173,7 @@ def to_map(
video =
if object["type"] == "Video" do
vid = [object]
[object]
else
[]
end
......
......@@ -2,18 +2,15 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
alias Pleroma.{UserInviteToken, User, Activity, Repo, Object}
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.TwitterAPI.UserView
alias Pleroma.Web.{OStatus, CommonAPI}
alias Pleroma.Web.MediaProxy
alias Pleroma.Web.CommonAPI
import Ecto.Query
@httpoison Application.get_env(:pleroma, :httpoison)
def create_status(%User{} = user, %{"status" => _} = data) do
CommonAPI.post(user, data)
end
def delete(%User{} = user, id) do
with %Activity{data: %{"type" => type}} <- Repo.get(Activity, id),
with %Activity{data: %{"type" => _type}} <- Repo.get(Activity, id),
{:ok, activity} <- CommonAPI.delete(id, user) do
{:ok, activity}
end
......@@ -37,7 +34,7 @@ def follow(%User{} = follower, params) do
def unfollow(%User{} = follower, params) do
with {:ok, %User{} = unfollowed} <- get_user(params),
{:ok, follower, follow_activity} <- User.unfollow(follower, unfollowed),
{:ok, follower, _follow_activity} <- User.unfollow(follower, unfollowed),
{:ok, _activity} <- ActivityPub.unfollow(follower, unfollowed) do
{:ok, follower, unfollowed}
else
......@@ -244,10 +241,6 @@ def search(_user, %{"q" => query} = params) do
_activities = Repo.all(q)
end
defp make_date do
DateTime.utc_now() |> DateTime.to_iso8601()
end
# DEPRECATED mostly, context objects are now created at insertion time.
def context_to_conversation_id(context) do
with %Object{id: id} <- Object.get_cached_by_ap_id(context) do
......
defmodule Pleroma.Web.TwitterAPI.Controller do
use Pleroma.Web, :controller
alias Pleroma.Formatter
alias Pleroma.Web.TwitterAPI.{TwitterAPI, UserView, ActivityView, NotificationView}
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.CommonAPI.Utils, as: CommonUtils
alias Pleroma.{Repo, Activity, Object, User, Notification}
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.ActivityPub.Utils
......@@ -155,7 +153,7 @@ def notifications_read(%{assigns: %{user: user}} = conn, %{"latest_id" => latest
|> render(NotificationView, "notification.json", %{notifications: notifications, for: user})
end
def notifications_read(%{assigns: %{user: user}} = conn, _) do
def notifications_read(%{assigns: %{user: _user}} = conn, _) do
bad_request_reply(conn, "You need to specify latest_id")
end
......@@ -416,7 +414,7 @@ def friend_requests(conn, params) do
end
end
def approve_friend_request(conn, %{"user_id" => uid} = params) do
def approve_friend_request(conn, %{"user_id" => uid} = _params) do
with followed <- conn.assigns[:user],
uid when is_number(uid) <- String.to_integer(uid),
%User{} = follower <- Repo.get(User, uid),
......@@ -436,7 +434,7 @@ def approve_friend_request(conn, %{"user_id" => uid} = params) do
end
end
def deny_friend_request(conn, %{"user_id" => uid} = params) do
def deny_friend_request(conn, %{"user_id" => uid} = _params) do
with followed <- conn.assigns[:user],
uid when is_number(uid) <- String.to_integer(uid),
%User{} = follower <- Repo.get(User, uid),
......
......@@ -28,12 +28,12 @@ def parse_document(text) do
|> :xmerl_scan.string()
doc
catch
:exit, _error ->
rescue
_e ->
Logger.debug("Couldn't parse XML: #{inspect(text)}")
:error
rescue
e ->
catch
:exit, _error ->
Logger.debug("Couldn't parse XML: #{inspect(text)}")
:error
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment