aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2019-03-05 04:36:19 +0100
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2019-03-13 04:26:56 +0100
commitc3d41b2b6ec7b789c7d6d7ae3b15bb18c59cf2e3 (patch)
treec1b95a0c254d135ebfafd5102c6a8e0373c56cdf
parentfb82f6fc7c5453e34e619c54a88e64e99deb58b4 (diff)
downloadpleroma-c3d41b2b6ec7b789c7d6d7ae3b15bb18c59cf2e3.tar.gz
[Credo] make all variables use snake_case
-rw-r--r--lib/pleroma/web/activity_pub/transmogrifier.ex12
-rw-r--r--lib/pleroma/web/common_api/common_api.ex12
-rw-r--r--lib/pleroma/web/ostatus/handlers/note_handler.ex27
-rw-r--r--lib/pleroma/web/twitter_api/twitter_api.ex6
-rw-r--r--lib/pleroma/web/websub/websub.ex8
5 files changed, 33 insertions, 32 deletions
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
index f1ce15876..1247e4b61 100644
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
@@ -650,10 +650,10 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
if object = Object.normalize(id), do: {:ok, object}, else: nil
end
- def set_reply_to_uri(%{"inReplyTo" => inReplyTo} = object) when is_binary(inReplyTo) do
- with false <- String.starts_with?(inReplyTo, "http"),
- {:ok, %{data: replied_to_object}} <- get_obj_helper(inReplyTo) do
- Map.put(object, "inReplyTo", replied_to_object["external_url"] || inReplyTo)
+ def set_reply_to_uri(%{"inReplyTo" => in_reply_to} = object) when is_binary(in_reply_to) do
+ with false <- String.starts_with?(in_reply_to, "http"),
+ {:ok, %{data: replied_to_object}} <- get_obj_helper(in_reply_to) do
+ Map.put(object, "inReplyTo", replied_to_object["external_url"] || in_reply_to)
else
_e -> object
end
@@ -830,10 +830,10 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end
def add_attributed_to(object) do
- attributedTo = object["attributedTo"] || object["actor"]
+ attributed_to = object["attributedTo"] || object["actor"]
object
- |> Map.put("attributedTo", attributedTo)
+ |> Map.put("attributedTo", attributed_to)
end
def add_likes(%{"id" => id, "like_count" => likes} = object) do
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index 2e39a16c3..12b3d308c 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -88,8 +88,8 @@ defmodule Pleroma.Web.CommonAPI do
nil ->
"public"
- inReplyTo ->
- Pleroma.Web.MastodonAPI.StatusView.get_visibility(inReplyTo.data["object"])
+ in_reply_to ->
+ Pleroma.Web.MastodonAPI.StatusView.get_visibility(in_reply_to.data["object"])
end
end
@@ -101,15 +101,15 @@ defmodule Pleroma.Web.CommonAPI do
with status <- String.trim(status),
attachments <- attachments_from_ids(data),
- inReplyTo <- get_replied_to_activity(data["in_reply_to_status_id"]),
+ in_reply_to <- get_replied_to_activity(data["in_reply_to_status_id"]),
{content_html, mentions, tags} <-
make_content_html(
status,
attachments,
data
),
- {to, cc} <- to_for_user_and_mentions(user, mentions, inReplyTo, visibility),
- context <- make_context(inReplyTo),
+ {to, cc} <- to_for_user_and_mentions(user, mentions, in_reply_to, visibility),
+ context <- make_context(in_reply_to),
cw <- data["spoiler_text"],
full_payload <- String.trim(status <> (data["spoiler_text"] || "")),
length when length in 1..limit <- String.length(full_payload),
@@ -120,7 +120,7 @@ defmodule Pleroma.Web.CommonAPI do
context,
content_html,
attachments,
- inReplyTo,
+ in_reply_to,
tags,
cw,
cc
diff --git a/lib/pleroma/web/ostatus/handlers/note_handler.ex b/lib/pleroma/web/ostatus/handlers/note_handler.ex
index 50767a6a8..770a71a0a 100644
--- a/lib/pleroma/web/ostatus/handlers/note_handler.ex
+++ b/lib/pleroma/web/ostatus/handlers/note_handler.ex
@@ -19,13 +19,13 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
2. The conversation reference in the ostatus xml
3. A newly generated context id.
"""
- def get_context(entry, inReplyTo) do
+ def get_context(entry, in_reply_to) do
context =
(XML.string_from_xpath("//ostatus:conversation[1]", entry) ||
XML.string_from_xpath("//ostatus:conversation[1]/@ref", entry) || "")
|> String.trim()
- with %{data: %{"context" => context}} <- Object.get_cached_by_ap_id(inReplyTo) do
+ with %{data: %{"context" => context}} <- Object.get_cached_by_ap_id(in_reply_to) do
context
else
_e ->
@@ -88,14 +88,14 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
Map.put(note, "external_url", url)
end
- def fetch_replied_to_activity(entry, inReplyTo) do
- with %Activity{} = activity <- Activity.get_create_by_object_ap_id(inReplyTo) do
+ def fetch_replied_to_activity(entry, in_reply_to) do
+ with %Activity{} = activity <- Activity.get_create_by_object_ap_id(in_reply_to) do
activity
else
_e ->
- with inReplyToHref when not is_nil(inReplyToHref) <-
+ with in_reply_to_href when not is_nil(in_reply_to_href) <-
XML.string_from_xpath("//thr:in-reply-to[1]/@href", entry),
- {:ok, [activity | _]} <- OStatus.fetch_activity_from_url(inReplyToHref) do
+ {:ok, [activity | _]} <- OStatus.fetch_activity_from_url(in_reply_to_href) do
activity
else
_e -> nil
@@ -111,11 +111,12 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
{:ok, actor} <- OStatus.find_make_or_update_user(author),
content_html <- OStatus.get_content(entry),
cw <- OStatus.get_cw(entry),
- inReplyTo <- XML.string_from_xpath("//thr:in-reply-to[1]/@ref", entry),
- inReplyToActivity <- fetch_replied_to_activity(entry, inReplyTo),
- inReplyTo <- (inReplyToActivity && inReplyToActivity.data["object"]["id"]) || inReplyTo,
+ in_reply_to <- XML.string_from_xpath("//thr:in-reply-to[1]/@ref", entry),
+ in_reply_to_activity <- fetch_replied_to_activity(entry, in_reply_to),
+ in_reply_to <-
+ (in_reply_to_activity && in_reply_to_activity.data["object"]["id"]) || in_reply_to,
attachments <- OStatus.get_attachments(entry),
- context <- get_context(entry, inReplyTo),
+ context <- get_context(entry, in_reply_to),
tags <- OStatus.get_tags(entry),
mentions <- get_mentions(entry),
to <- make_to_list(actor, mentions),
@@ -129,7 +130,7 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
context,
content_html,
attachments,
- inReplyToActivity,
+ in_reply_to_activity,
[],
cw
),
@@ -141,8 +142,8 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
# TODO: Handle this case in make_note_data
note <-
if(
- inReplyTo && !inReplyToActivity,
- do: note |> Map.put("inReplyTo", inReplyTo),
+ in_reply_to && !in_reply_to_activity,
+ do: note |> Map.put("inReplyTo", in_reply_to),
else: note
) do
ActivityPub.create(%{
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex
index 39e868bef..a22e765c7 100644
--- a/lib/pleroma/web/twitter_api/twitter_api.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api.ex
@@ -133,7 +133,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
end
def register_user(params) do
- tokenString = params["token"]
+ token_string = params["token"]
params = %{
nickname: params["nickname"],
@@ -170,8 +170,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
# no need to query DB if registration is open
token =
- unless registrations_open || is_nil(tokenString) do
- Repo.get_by(UserInviteToken, %{token: tokenString})
+ unless registrations_open || is_nil(token_string) do
+ Repo.get_by(UserInviteToken, %{token: token_string})
end
cond do
diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex
index 165440431..3ffa6b416 100644
--- a/lib/pleroma/web/websub/websub.ex
+++ b/lib/pleroma/web/websub/websub.ex
@@ -200,8 +200,8 @@ defmodule Pleroma.Web.Websub do
uri when not is_nil(uri) <- XML.string_from_xpath("/feed/author[1]/uri", doc),
hub when not is_nil(hub) <- XML.string_from_xpath(~S{/feed/link[@rel="hub"]/@href}, doc) do
name = XML.string_from_xpath("/feed/author[1]/name", doc)
- preferredUsername = XML.string_from_xpath("/feed/author[1]/poco:preferredUsername", doc)
- displayName = XML.string_from_xpath("/feed/author[1]/poco:displayName", doc)
+ preferred_username = XML.string_from_xpath("/feed/author[1]/poco:preferredUsername", doc)
+ display_name = XML.string_from_xpath("/feed/author[1]/poco:displayName", doc)
avatar = OStatus.make_avatar_object(doc)
bio = XML.string_from_xpath("/feed/author[1]/summary", doc)
@@ -209,8 +209,8 @@ defmodule Pleroma.Web.Websub do
%{
"uri" => uri,
"hub" => hub,
- "nickname" => preferredUsername || name,
- "name" => displayName || name,
+ "nickname" => preferred_username || name,
+ "name" => display_name || name,
"host" => URI.parse(uri).host,
"avatar" => avatar,
"bio" => bio