X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fmastodon_api%2Fmastodon_api_controller.ex;h=1825e156f50712c784c06587402ab59c7e7a9bd6;hb=b949577472d5e4db1aeacb9ff2162eb89440130c;hp=b00f1e15c1a58506e02f597fb4b821f7c9040410;hpb=9998b4519da0a732d2a91ca067f4f849a0d37be6;p=akkoma diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index b00f1e15c..1825e156f 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -212,9 +212,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do |> Map.put("actor_id", ap_id) |> Map.put("whole_db", true) - activities = - ActivityPub.fetch_public_activities(params) - |> Enum.reverse() + if params["pinned"] == "true" do + # Since Pleroma has no "pinned" posts feature, we'll just set an empty list here + activities = [] + else + activities = + ActivityPub.fetch_public_activities(params) + |> Enum.reverse() + end conn |> add_link_headers(:user_statuses, activities, params["id"]) @@ -291,6 +296,12 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do end end + def unreblog_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do + with {:ok, announce, _activity} = CommonAPI.unrepeat(ap_id_or_id, user) do + render(conn, StatusView, "status.json", %{activity: announce, for: user, as: :activity}) + end + end + def fav_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do with {:ok, _fav, %{data: %{"id" => id}}} = CommonAPI.favorite(ap_id_or_id, user), %Activity{} = activity <- Activity.get_create_activity_by_object_ap_id(id) do @@ -515,7 +526,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do a.data, ^query ), - limit: 20 + limit: 20, + order_by: [desc: :inserted_at] ) statuses = Repo.all(q) ++ fetched @@ -605,35 +617,37 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do "video\/mp4" ] }, - settings: Map.get(user.info, "settings") || %{ - onboarded: true, - home: %{ - shows: %{ - reblog: true, - reply: true - } - }, - notifications: %{ - alerts: %{ - follow: true, - favourite: true, - reblog: true, - mention: true - }, - shows: %{ - follow: true, - favourite: true, - reblog: true, - mention: true + settings: + Map.get(user.info, "settings") || + %{ + onboarded: true, + home: %{ + shows: %{ + reblog: true, + reply: true + } + }, + notifications: %{ + alerts: %{ + follow: true, + favourite: true, + reblog: true, + mention: true + }, + shows: %{ + follow: true, + favourite: true, + reblog: true, + mention: true + }, + sounds: %{ + follow: true, + favourite: true, + reblog: true, + mention: true + } + } }, - sounds: %{ - follow: true, - favourite: true, - reblog: true, - mention: true - } - } - }, push_subscription: nil, accounts: accounts, custom_emojis: mastodon_emoji, @@ -656,7 +670,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do {:ok, _user} <- User.update_and_set_cache(change) do conn |> json(%{}) - else e -> + else + e -> conn |> json(%{error: inspect(e)}) end