aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-04-25 17:32:36 +0200
committerRoger Braun <roger@rogerbraun.net>2017-04-25 17:32:36 +0200
commit4771962a5d0749746b7bb921074b97e13348dedf (patch)
treec8faf3a5c56c3074368d833f8c6737959ff7d639
parentef4190b3abbc581e9405f2a32fe7579345a3d155 (diff)
downloadpleroma-4771962a5d0749746b7bb921074b97e13348dedf.tar.gz
More refactoring.
-rw-r--r--lib/pleroma/web/twitter_api/twitter_api.ex19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex
index ad73e82ce..ad4bf7153 100644
--- a/lib/pleroma/web/twitter_api/twitter_api.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api.ex
@@ -26,21 +26,26 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
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
attachments = attachments_from_ids(data["media_ids"])
context = ActivityPub.generate_context_id
mentions = parse_mentions(status)
content_html = format_input(status, mentions)
to = to_for_user_and_mentions(user, mentions)
-
date = make_date()
+ inReplyTo = get_replied_to_activity(data["in_reply_to_status_id"])
+
# Wire up reply info.
[to, context, object, additional] =
- with inReplyToId when not is_nil(inReplyToId) <- data["in_reply_to_status_id"],
- inReplyTo <- Repo.get(Activity, inReplyToId),
- context <- inReplyTo.data["context"]
- do
+ if inReplyTo do
+ context = inReplyTo.data["context"]
to = to ++ [inReplyTo.data["actor"]]
object = %{
@@ -52,7 +57,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
"attachment" => attachments,
"actor" => user.ap_id,
"inReplyTo" => inReplyTo.data["object"]["id"],
- "inReplyToStatusId" => inReplyToId,
+ "inReplyToStatusId" => inReplyTo.id,
"statusnetConversationId" => inReplyTo.data["statusnetConversationId"]
}
additional = %{
@@ -60,7 +65,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
}
[to, context, object, additional]
- else _e ->
+ else
object = %{
"type" => "Note",
"to" => to,