aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--docs/Differences-in-MastodonAPI-Responses.md4
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex4
-rw-r--r--lib/pleroma/web/push/impl.ex10
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs13
5 files changed, 27 insertions, 6 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6deb0a1de..30589c9c5 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-image: elixir:1.7.2
+image: elixir:1.8.1
services:
- name: postgres:9.6.2
diff --git a/docs/Differences-in-MastodonAPI-Responses.md b/docs/Differences-in-MastodonAPI-Responses.md
index 667664f4e..7b11fe90f 100644
--- a/docs/Differences-in-MastodonAPI-Responses.md
+++ b/docs/Differences-in-MastodonAPI-Responses.md
@@ -19,3 +19,7 @@ Adding the parameter `with_muted=true` to the timeline queries will also return
Has these additional fields under the `pleroma` object:
- `local`: true if the post was made on the local instance.
+
+## Accounts
+
+- `/api/v1/accounts/:id`: The `id` parameter can also be the `nickname` of the user. This only works in this endpoint, not the deeper nested ones for following etc.
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index bfc8dcd0a..a97bc7569 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -132,8 +132,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
json(conn, account)
end
- def user(%{assigns: %{user: for_user}} = conn, %{"id" => id}) do
- with %User{} = user <- Repo.get(User, id),
+ def user(%{assigns: %{user: for_user}} = conn, %{"id" => nickname_or_id}) do
+ with %User{} = user <- User.get_cached_by_nickname_or_id(nickname_or_id),
true <- User.auth_active?(user) || user.id == for_user.id || User.superuser?(for_user) do
account = AccountView.render("account.json", %{user: user, for: for_user})
json(conn, account)
diff --git a/lib/pleroma/web/push/impl.ex b/lib/pleroma/web/push/impl.ex
index 33f912d34..0437ffd00 100644
--- a/lib/pleroma/web/push/impl.ex
+++ b/lib/pleroma/web/push/impl.ex
@@ -20,7 +20,10 @@ defmodule Pleroma.Web.Push.Impl do
@doc "Performs sending notifications for user subscriptions"
@spec perform_send(Notification.t()) :: list(any)
- def perform_send(%{activity: %{data: %{"type" => activity_type}}, user_id: user_id} = notif)
+ def perform_send(
+ %{activity: %{data: %{"type" => activity_type}, id: activity_id}, user_id: user_id} =
+ notif
+ )
when activity_type in @types do
actor = User.get_cached_by_ap_id(notif.activity.data["actor"])
@@ -37,7 +40,10 @@ defmodule Pleroma.Web.Push.Impl do
notification_id: notif.id,
notification_type: type,
icon: avatar_url,
- preferred_locale: "en"
+ preferred_locale: "en",
+ pleroma: %{
+ activity_id: activity_id
+ }
}
|> Jason.encode!()
|> push_message(build_sub(subscription), gcm_api_key, subscription)
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index d9e41d356..2caf514bb 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -1064,6 +1064,17 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert %{"error" => "Can't find user"} = json_response(conn, 404)
end
+ test "account fetching also works nickname", %{conn: conn} do
+ user = insert(:user)
+
+ conn =
+ conn
+ |> get("/api/v1/accounts/#{user.nickname}")
+
+ assert %{"id" => id} = json_response(conn, 200)
+ assert id == user.id
+ end
+
test "media upload", %{conn: conn} do
file = %Plug.Upload{
content_type: "image/jpg",
@@ -2032,7 +2043,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|> json_response(200)
end
- test "accound_id is required", %{
+ test "account_id is required", %{
conn: conn,
reporter: reporter,
activity: activity