diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/twitter_api/representers/activity_representer.ex | 6 | ||||
-rw-r--r-- | lib/pleroma/web/twitter_api/twitter_api.ex | 13 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index 9e4ffaefe..6a5304049 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -25,6 +25,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do content = get_in(activity.data, ["object", "content"]) created_at = get_in(activity.data, ["object", "published"]) |> date_to_asctime + like_count = get_in(activity.data, ["object", "like_count"]) || 0 mentions = opts[:mentioned] || [] @@ -45,14 +46,15 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do "in_reply_to_status_id" => activity.data["object"]["inReplyToStatusId"], "statusnet_conversation_id" => activity.data["object"]["statusnetConversationId"], "attachments" => (activity.data["object"]["attachment"] || []) |> ObjectRepresenter.enum_to_list(opts), - "attentions" => attentions + "attentions" => attentions, + "fave_num" => like_count } end defp date_to_asctime(date) do with {:ok, date, _offset} <- date |> DateTime.from_iso8601 do Calendar.Strftime.strftime!(date, "%a %b %d %H:%M:%S %z %Y") - else e -> + else _e -> "" end end diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index a195301ee..2679397d9 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -124,6 +124,19 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do end end + def favorite(%User{} = user, %Activity{data: %{"object" => object}} = activity) do + object = Object.get_by_ap_id(object["id"]) + + {:ok, _like_activity, object} = ActivityPub.like(user, object) + new_data = activity.data + |> Map.put("object", object.data) + + status = %{activity | data: new_data} + |> activity_to_status(%{for: user}) + + {:ok, status} + end + def upload(%Plug.Upload{} = file) do {:ok, object} = ActivityPub.upload(file) |