mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-18 15:14:42 +00:00
More refactoring.
This commit is contained in:
parent
ef4190b3ab
commit
4771962a5d
1 changed files with 12 additions and 7 deletions
|
@ -26,21 +26,26 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_replied_to_activity(id) when not is_nil(id) do
|
||||||
|
Repo.get(Activity, id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_replied_to_activity(_), do: nil
|
||||||
|
|
||||||
def create_status(user = %User{}, data = %{"status" => status}) do
|
def create_status(user = %User{}, data = %{"status" => status}) do
|
||||||
attachments = attachments_from_ids(data["media_ids"])
|
attachments = attachments_from_ids(data["media_ids"])
|
||||||
context = ActivityPub.generate_context_id
|
context = ActivityPub.generate_context_id
|
||||||
mentions = parse_mentions(status)
|
mentions = parse_mentions(status)
|
||||||
content_html = format_input(status, mentions)
|
content_html = format_input(status, mentions)
|
||||||
to = to_for_user_and_mentions(user, mentions)
|
to = to_for_user_and_mentions(user, mentions)
|
||||||
|
|
||||||
date = make_date()
|
date = make_date()
|
||||||
|
|
||||||
|
inReplyTo = get_replied_to_activity(data["in_reply_to_status_id"])
|
||||||
|
|
||||||
# Wire up reply info.
|
# Wire up reply info.
|
||||||
[to, context, object, additional] =
|
[to, context, object, additional] =
|
||||||
with inReplyToId when not is_nil(inReplyToId) <- data["in_reply_to_status_id"],
|
if inReplyTo do
|
||||||
inReplyTo <- Repo.get(Activity, inReplyToId),
|
context = inReplyTo.data["context"]
|
||||||
context <- inReplyTo.data["context"]
|
|
||||||
do
|
|
||||||
to = to ++ [inReplyTo.data["actor"]]
|
to = to ++ [inReplyTo.data["actor"]]
|
||||||
|
|
||||||
object = %{
|
object = %{
|
||||||
|
@ -52,7 +57,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
||||||
"attachment" => attachments,
|
"attachment" => attachments,
|
||||||
"actor" => user.ap_id,
|
"actor" => user.ap_id,
|
||||||
"inReplyTo" => inReplyTo.data["object"]["id"],
|
"inReplyTo" => inReplyTo.data["object"]["id"],
|
||||||
"inReplyToStatusId" => inReplyToId,
|
"inReplyToStatusId" => inReplyTo.id,
|
||||||
"statusnetConversationId" => inReplyTo.data["statusnetConversationId"]
|
"statusnetConversationId" => inReplyTo.data["statusnetConversationId"]
|
||||||
}
|
}
|
||||||
additional = %{
|
additional = %{
|
||||||
|
@ -60,7 +65,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
||||||
}
|
}
|
||||||
|
|
||||||
[to, context, object, additional]
|
[to, context, object, additional]
|
||||||
else _e ->
|
else
|
||||||
object = %{
|
object = %{
|
||||||
"type" => "Note",
|
"type" => "Note",
|
||||||
"to" => to,
|
"to" => to,
|
||||||
|
|
Loading…
Reference in a new issue