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
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
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
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),
context,
content_html,
attachments,
- inReplyTo,
+ in_reply_to,
tags,
cw,
cc
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 ->
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
{: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),
context,
content_html,
attachments,
- inReplyToActivity,
+ in_reply_to_activity,
[],
cw
),
# 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(%{
end
def register_user(params) do
- tokenString = params["token"]
+ token_string = params["token"]
params = %{
nickname: params["nickname"],
# 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
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)
%{
"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