Merge branch 'feature/mastodon_api_2.5.0' into 'develop'
Update mastodon API to 2.5.0 Closes: https://git.pleroma.social/pleroma/pleroma/issues/298 Closes: https://git.pleroma.social/pleroma/pleroma/issues/299 See: https://git.pleroma.social/pleroma/pleroma/merge_requests/351
This commit is contained in:
commit
7458adc256
|
@ -125,7 +125,7 @@ def user(conn, %{"id" => id}) do
|
||||||
end
|
end
|
||||||
|
|
||||||
@instance Application.get_env(:pleroma, :instance)
|
@instance Application.get_env(:pleroma, :instance)
|
||||||
@mastodon_api_level "2.4.3"
|
@mastodon_api_level "2.5.0"
|
||||||
|
|
||||||
def masto_instance(conn, _params) do
|
def masto_instance(conn, _params) do
|
||||||
response = %{
|
response = %{
|
||||||
|
@ -441,7 +441,7 @@ def update_media(%{assigns: %{user: _}} = conn, data) do
|
||||||
new_data = %{object.data | "name" => description}
|
new_data = %{object.data | "name" => description}
|
||||||
|
|
||||||
change = Object.change(object, %{data: new_data})
|
change = Object.change(object, %{data: new_data})
|
||||||
{:ok, media_obj} = Repo.update(change)
|
{:ok, _} = Repo.update(change)
|
||||||
|
|
||||||
data =
|
data =
|
||||||
new_data
|
new_data
|
||||||
|
@ -1077,7 +1077,7 @@ def render_notification(user, %{id: id, activity: activity, inserted_at: created
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_filters(%{assigns: %{user: user}} = conn, params) do
|
def get_filters(%{assigns: %{user: user}} = conn, _) do
|
||||||
filters = Pleroma.Filter.get_filters(user)
|
filters = Pleroma.Filter.get_filters(user)
|
||||||
res = FilterView.render("filters.json", filters: filters)
|
res = FilterView.render("filters.json", filters: filters)
|
||||||
json(conn, res)
|
json(conn, res)
|
||||||
|
@ -1101,7 +1101,7 @@ def create_filter(
|
||||||
json(conn, res)
|
json(conn, res)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_filter(%{assigns: %{user: user}} = conn, %{"id" => filter_id} = params) do
|
def get_filter(%{assigns: %{user: user}} = conn, %{"id" => filter_id}) do
|
||||||
filter = Pleroma.Filter.get(filter_id, user)
|
filter = Pleroma.Filter.get(filter_id, user)
|
||||||
res = FilterView.render("filter.json", filter: filter)
|
res = FilterView.render("filter.json", filter: filter)
|
||||||
json(conn, res)
|
json(conn, res)
|
||||||
|
@ -1126,13 +1126,13 @@ def update_filter(
|
||||||
json(conn, res)
|
json(conn, res)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_filter(%{assigns: %{user: user}} = conn, %{"id" => filter_id} = params) do
|
def delete_filter(%{assigns: %{user: user}} = conn, %{"id" => filter_id}) do
|
||||||
query = %Pleroma.Filter{
|
query = %Pleroma.Filter{
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
filter_id: filter_id
|
filter_id: filter_id
|
||||||
}
|
}
|
||||||
|
|
||||||
{:ok, response} = Pleroma.Filter.delete(query)
|
{:ok, _} = Pleroma.Filter.delete(query)
|
||||||
json(conn, %{})
|
json(conn, %{})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,8 @@ def render("relationship.json", %{user: user, target: target}) do
|
||||||
muting_notifications: false,
|
muting_notifications: false,
|
||||||
requested: false,
|
requested: false,
|
||||||
domain_blocking: false,
|
domain_blocking: false,
|
||||||
showing_reblogs: false
|
showing_reblogs: false,
|
||||||
|
endorsed: false
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ def render(
|
||||||
content: reblogged[:content],
|
content: reblogged[:content],
|
||||||
created_at: created_at,
|
created_at: created_at,
|
||||||
reblogs_count: 0,
|
reblogs_count: 0,
|
||||||
|
replies_count: 0,
|
||||||
favourites_count: 0,
|
favourites_count: 0,
|
||||||
reblogged: false,
|
reblogged: false,
|
||||||
favourited: false,
|
favourited: false,
|
||||||
|
@ -132,6 +133,7 @@ def render("status.json", %{activity: %{data: %{"object" => object}} = activity}
|
||||||
content: render_content(object),
|
content: render_content(object),
|
||||||
created_at: created_at,
|
created_at: created_at,
|
||||||
reblogs_count: announcement_count,
|
reblogs_count: announcement_count,
|
||||||
|
replies_count: 0,
|
||||||
favourites_count: like_count,
|
favourites_count: like_count,
|
||||||
reblogged: !!repeated,
|
reblogged: !!repeated,
|
||||||
favourited: !!favorited,
|
favourited: !!favorited,
|
||||||
|
|
|
@ -172,6 +172,8 @@ defmodule Pleroma.Web.Router do
|
||||||
delete("/filters/:id", MastodonAPIController, :delete_filter)
|
delete("/filters/:id", MastodonAPIController, :delete_filter)
|
||||||
|
|
||||||
get("/suggestions", MastodonAPIController, :suggestions)
|
get("/suggestions", MastodonAPIController, :suggestions)
|
||||||
|
|
||||||
|
get("/endorsements", MastodonAPIController, :empty_array)
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/api/web", Pleroma.Web.MastodonAPI do
|
scope "/api/web", Pleroma.Web.MastodonAPI do
|
||||||
|
|
|
@ -126,7 +126,8 @@ test "represent a relationship" do
|
||||||
muting_notifications: false,
|
muting_notifications: false,
|
||||||
requested: false,
|
requested: false,
|
||||||
domain_blocking: false,
|
domain_blocking: false,
|
||||||
showing_reblogs: false
|
showing_reblogs: false,
|
||||||
|
endorsed: false
|
||||||
}
|
}
|
||||||
|
|
||||||
assert expected == AccountView.render("relationship.json", %{user: user, target: other_user})
|
assert expected == AccountView.render("relationship.json", %{user: user, target: other_user})
|
||||||
|
|
|
@ -28,6 +28,7 @@ test "a note activity" do
|
||||||
content: HtmlSanitizeEx.basic_html(note.data["object"]["content"]),
|
content: HtmlSanitizeEx.basic_html(note.data["object"]["content"]),
|
||||||
created_at: created_at,
|
created_at: created_at,
|
||||||
reblogs_count: 0,
|
reblogs_count: 0,
|
||||||
|
replies_count: 0,
|
||||||
favourites_count: 0,
|
favourites_count: 0,
|
||||||
reblogged: false,
|
reblogged: false,
|
||||||
favourited: false,
|
favourited: false,
|
||||||
|
|
Loading…
Reference in New Issue