Commit 5367d821 authored by Mayel's avatar Mayel

Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop

parents 55ce8ddc e416469a
...@@ -16,6 +16,8 @@ config :pleroma, Pleroma.Upload, ...@@ -16,6 +16,8 @@ config :pleroma, Pleroma.Upload,
config :pleroma, :emoji, shortcode_globs: ["/emoji/custom/**/*.png"] config :pleroma, :emoji, shortcode_globs: ["/emoji/custom/**/*.png"]
config :pleroma, :uri_schemes, additionnal_schemes: []
# Configures the endpoint # Configures the endpoint
config :pleroma, Pleroma.Web.Endpoint, config :pleroma, Pleroma.Web.Endpoint,
url: [host: "localhost"], url: [host: "localhost"],
...@@ -111,6 +113,13 @@ config :pleroma, :gopher, ...@@ -111,6 +113,13 @@ config :pleroma, :gopher,
ip: {0, 0, 0, 0}, ip: {0, 0, 0, 0},
port: 9999 port: 9999
config :pleroma, :suggestions,
enabled: false,
third_party_engine:
"http://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-suggestions-api.cgi?{{host}}+{{user}}",
timeout: 300_000,
web: "https://vinayaka.distsn.org/?{{host}}+{{user}}"
# Import environment specific config. This must remain at the bottom # Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above. # of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs" import_config "#{Mix.env()}.exs"
...@@ -165,8 +165,29 @@ defmodule Pleroma.Formatter do ...@@ -165,8 +165,29 @@ defmodule Pleroma.Formatter do
@emoji @emoji
end end
@link_regex ~r/https?:\/\/[\w\.\/?=\-#\+%&@~'\(\):]+[\w\/]/u @link_regex ~r/[0-9a-z+\-\.]+:[0-9a-z$-_.+!*'(),]+/ui
# IANA got a list https://www.iana.org/assignments/uri-schemes/ but
# Stuff like ipfs isn’t in it
# There is very niche stuff
@uri_schemes [
"https://",
"http://",
"dat://",
"dweb://",
"gopher://",
"ipfs://",
"ipns://",
"irc:",
"ircs:",
"magnet:",
"mailto:",
"mumble:",
"ssb://",
"xmpp:"
]
# TODO: make it use something other than @link_regex
def html_escape(text) do def html_escape(text) do
Regex.split(@link_regex, text, include_captures: true) Regex.split(@link_regex, text, include_captures: true)
|> Enum.map_every(2, fn chunk -> |> Enum.map_every(2, fn chunk ->
...@@ -176,11 +197,18 @@ defmodule Pleroma.Formatter do ...@@ -176,11 +197,18 @@ defmodule Pleroma.Formatter do
|> Enum.join("") |> Enum.join("")
end end
@doc "changes http:... links to html links" @doc "changes scheme:... urls to html links"
def add_links({subs, text}) do def add_links({subs, text}) do
additionnal_schemes =
Application.get_env(:pleroma, :uri_schemes, [])
|> Keyword.get(:additionnal_schemes, [])
links = links =
Regex.scan(@link_regex, text) text
|> Enum.map(fn [url] -> {Ecto.UUID.generate(), url} end) |> String.split([" ", "\t", "<br>"])
|> Enum.filter(fn word -> String.starts_with?(word, @uri_schemes ++ additionnal_schemes) end)
|> Enum.filter(fn word -> Regex.match?(@link_regex, word) end)
|> Enum.map(fn url -> {Ecto.UUID.generate(), url} end)
|> Enum.sort_by(fn {_, url} -> -String.length(url) end) |> Enum.sort_by(fn {_, url} -> -String.length(url) end)
uuid_text = uuid_text =
......
...@@ -124,20 +124,20 @@ defmodule Pleroma.Upload do ...@@ -124,20 +124,20 @@ defmodule Pleroma.Upload do
if should_dedupe do if should_dedupe do
create_name(uuid, List.last(String.split(file.filename, ".")), type) create_name(uuid, List.last(String.split(file.filename, ".")), type)
else else
unless String.contains?(file.filename, ".") do parts = String.split(file.filename, ".")
case type do
"image/png" -> file.filename <> ".png" new_filename =
"image/jpeg" -> file.filename <> ".jpg" if length(parts) > 1 do
"image/gif" -> file.filename <> ".gif" Enum.drop(parts, -1) |> Enum.join(".")
"video/webm" -> file.filename <> ".webm" else
"video/mp4" -> file.filename <> ".mp4" Enum.join(parts)
"audio/mpeg" -> file.filename <> ".mp3"
"audio/ogg" -> file.filename <> ".ogg"
"audio/wav" -> file.filename <> ".wav"
_ -> file.filename
end end
else
file.filename case type do
"application/octet-stream" -> file.filename
"audio/mpeg" -> new_filename <> ".mp3"
"image/jpeg" -> new_filename <> ".jpg"
_ -> Enum.join([new_filename, String.split(type, "/") |> List.last()], ".")
end end
end end
end end
......
...@@ -565,7 +565,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do ...@@ -565,7 +565,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
def fetch_and_prepare_user_from_ap_id(ap_id) do def fetch_and_prepare_user_from_ap_id(ap_id) do
with {:ok, %{status_code: 200, body: body}} <- with {:ok, %{status_code: 200, body: body}} <-
@httpoison.get(ap_id, Accept: "application/activity+json"), @httpoison.get(ap_id, [Accept: "application/activity+json"], follow_redirect: true),
{:ok, data} <- Jason.decode(body) do {:ok, data} <- Jason.decode(body) do
user_data_from_user_object(data) user_data_from_user_object(data)
else else
......
...@@ -18,12 +18,16 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do ...@@ -18,12 +18,16 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end end
def get_actor(%{"actor" => actor}) when is_list(actor) do def get_actor(%{"actor" => actor}) when is_list(actor) do
Enum.at(actor, 0) if is_binary(Enum.at(actor, 0)) do
Enum.at(actor, 0)
else
Enum.find(actor, fn %{"type" => type} -> type == "Person" end)
|> Map.get("id")
end
end end
def get_actor(%{"actor" => actor_list}) do def get_actor(%{"actor" => actor}) when is_map(actor) do
Enum.find(actor_list, fn %{"type" => type} -> type == "Person" end) actor["id"]
|> Map.get("id")
end end
@doc """ @doc """
...@@ -38,6 +42,25 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do ...@@ -38,6 +42,25 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|> fix_emoji |> fix_emoji
|> fix_tag |> fix_tag
|> fix_content_map |> fix_content_map
|> fix_likes
|> fix_addressing
end
def fix_addressing_list(map, field) do
if is_binary(map[field]) do
map
|> Map.put(field, [map[field]])
else
map
end
end
def fix_addressing(map) do
map
|> fix_addressing_list("to")
|> fix_addressing_list("cc")
|> fix_addressing_list("bto")
|> fix_addressing_list("bcc")
end end
def fix_actor(%{"attributedTo" => actor} = object) do def fix_actor(%{"attributedTo" => actor} = object) do
...@@ -45,6 +68,20 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do ...@@ -45,6 +68,20 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|> Map.put("actor", get_actor(%{"actor" => actor})) |> Map.put("actor", get_actor(%{"actor" => actor}))
end end
def fix_likes(%{"likes" => likes} = object)
when is_bitstring(likes) do
# Check for standardisation
# This is what Peertube does
# curl -H 'Accept: application/activity+json' $likes | jq .totalItems
object
|> Map.put("likes", [])
|> Map.put("like_count", 0)
end
def fix_likes(object) do
object
end
def fix_in_reply_to(%{"inReplyTo" => in_reply_to_id} = object) def fix_in_reply_to(%{"inReplyTo" => in_reply_to_id} = object)
when not is_nil(in_reply_to_id) do when not is_nil(in_reply_to_id) do
case ActivityPub.fetch_object_from_id(in_reply_to_id) do case ActivityPub.fetch_object_from_id(in_reply_to_id) do
...@@ -72,8 +109,11 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do ...@@ -72,8 +109,11 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
def fix_in_reply_to(object), do: object def fix_in_reply_to(object), do: object
def fix_context(object) do def fix_context(object) do
context = object["context"] || object["conversation"] || Utils.generate_context_id()
object object
|> Map.put("context", object["conversation"]) |> Map.put("context", context)
|> Map.put("conversation", context)
end end
def fix_attachments(object) do def fix_attachments(object) do
...@@ -137,13 +177,22 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do ...@@ -137,13 +177,22 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
def fix_content_map(object), do: object def fix_content_map(object), do: object
# disallow objects with bogus IDs
def handle_incoming(%{"id" => nil}), do: :error
def handle_incoming(%{"id" => ""}), do: :error
# length of https:// = 8, should validate better, but good enough for now.
def handle_incoming(%{"id" => id}) when not (is_binary(id) and length(id) > 8), do: :error
# TODO: validate those with a Ecto scheme # TODO: validate those with a Ecto scheme
# - tags # - tags
# - emoji # - emoji
def handle_incoming(%{"type" => "Create", "object" => %{"type" => objtype} = object} = data) def handle_incoming(%{"type" => "Create", "object" => %{"type" => objtype} = object} = data)
when objtype in ["Article", "Note"] do when objtype in ["Article", "Note", "Video"] do
actor = get_actor(data) actor = get_actor(data)
data = Map.put(data, "actor", actor)
data =
Map.put(data, "actor", actor)
|> fix_addressing
with nil <- Activity.get_create_activity_by_object_ap_id(object["id"]), with nil <- Activity.get_create_activity_by_object_ap_id(object["id"]),
%User{} = user <- User.get_or_fetch_by_ap_id(data["actor"]) do %User{} = user <- User.get_or_fetch_by_ap_id(data["actor"]) do
......
...@@ -128,7 +128,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do ...@@ -128,7 +128,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do
Inserts a full object if it is contained in an activity. Inserts a full object if it is contained in an activity.
""" """
def insert_full_object(%{"object" => %{"type" => type} = object_data}) def insert_full_object(%{"object" => %{"type" => type} = object_data})
when is_map(object_data) and type in ["Article", "Note"] do when is_map(object_data) and type in ["Article", "Note", "Video"] do
with {:ok, _} <- Object.create(object_data) do with {:ok, _} <- Object.create(object_data) do
:ok :ok
end end
...@@ -204,13 +204,17 @@ defmodule Pleroma.Web.ActivityPub.Utils do ...@@ -204,13 +204,17 @@ defmodule Pleroma.Web.ActivityPub.Utils do
end end
def add_like_to_object(%Activity{data: %{"actor" => actor}}, object) do def add_like_to_object(%Activity{data: %{"actor" => actor}}, object) do
with likes <- [actor | object.data["likes"] || []] |> Enum.uniq() do likes = if is_list(object.data["likes"]), do: object.data["likes"], else: []
with likes <- [actor | likes] |> Enum.uniq() do
update_likes_in_object(likes, object) update_likes_in_object(likes, object)
end end
end end
def remove_like_from_object(%Activity{data: %{"actor" => actor}}, object) do def remove_like_from_object(%Activity{data: %{"actor" => actor}}, object) do
with likes <- (object.data["likes"] || []) |> List.delete(actor) do likes = if is_list(object.data["likes"]), do: object.data["likes"], else: []
with likes <- likes |> List.delete(actor) do
update_likes_in_object(likes, object) update_likes_in_object(likes, object)
end end
end end
...@@ -357,13 +361,19 @@ defmodule Pleroma.Web.ActivityPub.Utils do ...@@ -357,13 +361,19 @@ defmodule Pleroma.Web.ActivityPub.Utils do
end end
def add_announce_to_object(%Activity{data: %{"actor" => actor}}, object) do def add_announce_to_object(%Activity{data: %{"actor" => actor}}, object) do
with announcements <- [actor | object.data["announcements"] || []] |> Enum.uniq() do announcements =
if is_list(object.data["announcements"]), do: object.data["announcements"], else: []
with announcements <- [actor | announcements] |> Enum.uniq() do
update_element_in_object("announcement", announcements, object) update_element_in_object("announcement", announcements, object)
end end
end end
def remove_announce_from_object(%Activity{data: %{"actor" => actor}}, object) do def remove_announce_from_object(%Activity{data: %{"actor" => actor}}, object) do
with announcements <- (object.data["announcements"] || []) |> List.delete(actor) do announcements =
if is_list(object.data["announcements"]), do: object.data["announcements"], else: []
with announcements <- announcements |> List.delete(actor) do
update_element_in_object("announcement", announcements, object) update_element_in_object("announcement", announcements, object)
end end
end end
......
...@@ -98,9 +98,6 @@ defmodule Pleroma.Web.ActivityPub.UserView do ...@@ -98,9 +98,6 @@ defmodule Pleroma.Web.ActivityPub.UserView do
info = User.user_info(user) info = User.user_info(user)
params = %{ params = %{
"type" => ["Create", "Announce"],
"actor_id" => user.ap_id,
"whole_db" => true,
"limit" => "10" "limit" => "10"
} }
...@@ -111,10 +108,8 @@ defmodule Pleroma.Web.ActivityPub.UserView do ...@@ -111,10 +108,8 @@ defmodule Pleroma.Web.ActivityPub.UserView do
params params
end end
activities = ActivityPub.fetch_public_activities(params) activities = ActivityPub.fetch_user_activities(user, nil, params)
min_id = Enum.at(activities, 0).id min_id = Enum.at(Enum.reverse(activities), 0).id
activities = Enum.reverse(activities)
max_id = Enum.at(activities, 0).id max_id = Enum.at(activities, 0).id
collection = collection =
......
...@@ -64,7 +64,6 @@ defmodule Pleroma.Web.CommonAPI.Utils do ...@@ -64,7 +64,6 @@ defmodule Pleroma.Web.CommonAPI.Utils do
def make_content_html(status, mentions, attachments, tags, no_attachment_links \\ false) do def make_content_html(status, mentions, attachments, tags, no_attachment_links \\ false) do
status status
|> String.replace("\r", "")
|> format_input(mentions, tags) |> format_input(mentions, tags)
|> maybe_add_attachments(attachments, no_attachment_links) |> maybe_add_attachments(attachments, no_attachment_links)
end end
...@@ -95,7 +94,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do ...@@ -95,7 +94,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
def format_input(text, mentions, tags) do def format_input(text, mentions, tags) do
text text
|> Formatter.html_escape() |> Formatter.html_escape()
|> String.replace("\n", "<br>") |> String.replace(~r/\r?\n/, "<br>")
|> (&{[], &1}).() |> (&{[], &1}).()
|> Formatter.add_links() |> Formatter.add_links()
|> Formatter.add_user_links(mentions) |> Formatter.add_user_links(mentions)
...@@ -109,7 +108,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do ...@@ -109,7 +108,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|> Enum.sort_by(fn {tag, _} -> -String.length(tag) end) |> Enum.sort_by(fn {tag, _} -> -String.length(tag) end)
Enum.reduce(tags, text, fn {full, tag}, text -> Enum.reduce(tags, text, fn {full, tag}, text ->
url = "#<a href='#{Pleroma.Web.base_url()}/tag/#{tag}' rel='tag'>#{tag}</a>" url = "<a href='#{Pleroma.Web.base_url()}/tag/#{tag}' rel='tag'>##{tag}</a>"
String.replace(text, full, url) String.replace(text, full, url)
end) end)
end end
......
...@@ -5,21 +5,26 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do ...@@ -5,21 +5,26 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
alias Pleroma.Web.MastodonAPI.{StatusView, AccountView, MastodonView, ListView} alias Pleroma.Web.MastodonAPI.{StatusView, AccountView, MastodonView, ListView}
alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.{CommonAPI, OStatus} alias Pleroma.Web.CommonAPI
alias Pleroma.Web.OAuth.{Authorization, Token, App} alias Pleroma.Web.OAuth.{Authorization, Token, App}
alias Comeonin.Pbkdf2 alias Comeonin.Pbkdf2
import Ecto.Query import Ecto.Query
require Logger require Logger
@httpoison Application.get_env(:pleroma, :httpoison)
action_fallback(:errors) action_fallback(:errors)
def create_app(conn, params) do def create_app(conn, params) do
with cs <- App.register_changeset(%App{}, params) |> IO.inspect(), with cs <- App.register_changeset(%App{}, params) |> IO.inspect(),
{:ok, app} <- Repo.insert(cs) |> IO.inspect() do {:ok, app} <- Repo.insert(cs) |> IO.inspect() do
res = %{ res = %{
id: app.id, id: app.id |> to_string,
name: app.client_name,
client_id: app.client_id, client_id: app.client_id,
client_secret: app.client_secret client_secret: app.client_secret,
redirect_uri: app.redirect_uris,
website: app.website
} }
json(conn, res) json(conn, res)
...@@ -653,12 +658,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do ...@@ -653,12 +658,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
fetched = fetched =
if Regex.match?(~r/https?:/, query) do if Regex.match?(~r/https?:/, query) do
with {:ok, activities} <- OStatus.fetch_activity_from_url(query) do with {:ok, object} <- ActivityPub.fetch_object_from_id(query) do
activities [Activity.get_create_activity_by_object_ap_id(object.data["id"])]
|> Enum.filter(fn
%{data: %{"type" => "Create"}} -> true
_ -> false
end)
else else
_e -> [] _e -> []
end end
...@@ -705,12 +706,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do ...@@ -705,12 +706,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
fetched = fetched =
if Regex.match?(~r/https?:/, query) do if Regex.match?(~r/https?:/, query) do
with {:ok, activities} <- OStatus.fetch_activity_from_url(query) do with {:ok, object} <- ActivityPub.fetch_object_from_id(query) do
activities [Activity.get_create_activity_by_object_ap_id(object.data["id"])]
|> Enum.filter(fn
%{data: %{"type" => "Create"}} -> true
_ -> false
end)
else else
_e -> [] _e -> []
end end
...@@ -1097,4 +1094,38 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do ...@@ -1097,4 +1094,38 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|> put_status(500) |> put_status(500)
|> json("Something went wrong") |> json("Something went wrong")
end end
@suggestions Application.get_env(:pleroma, :suggestions)
def suggestions(%{assigns: %{user: user}} = conn, _) do
if Keyword.get(@suggestions, :enabled, false) do
api = Keyword.get(@suggestions, :third_party_engine, "")
timeout = Keyword.get(@suggestions, :timeout, 5000)
host =
Application.get_env(:pleroma, Pleroma.Web.Endpoint)
|> Keyword.get(:url)
|> Keyword.get(:host)
user = user.nickname
url = String.replace(api, "{{host}}", host) |> String.replace("{{user}}", user)
with {:ok, %{status_code: 200, body: body}} <-
@httpoison.get(url, [], timeout: timeout, recv_timeout: timeout),
{:ok, data} <- Jason.decode(body) do
data2 =
Enum.slice(data, 0, 40)
|> Enum.map(fn x ->
Map.put(x, "id", User.get_or_fetch(x["acct"]).id)
end)
conn
|> json(data2)
else
e -> Logger.error("Could not retrieve suggestions at fetch #{url}, #{inspect(e)}")
end
else
json(conn, [])
end
end
end end
...@@ -36,7 +36,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do ...@@ -36,7 +36,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
followers_count: user_info.follower_count, followers_count: user_info.follower_count,
following_count: user_info.following_count, following_count: user_info.following_count,
statuses_count: user_info.note_count, statuses_count: user_info.note_count,
note: user.bio || "", note: HtmlSanitizeEx.basic_html(user.bio) || "",
url: user.ap_id, url: user.ap_id,
avatar: image, avatar: image,
avatar_static: image, avatar_static: image,
......
...@@ -99,8 +99,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do ...@@ -99,8 +99,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
repeated = opts[:for] && opts[:for].ap_id in (object["announcements"] || []) repeated = opts[:for] && opts[:for].ap_id in (object["announcements"] || [])
favorited = opts[:for] && opts[:for].ap_id in (object["likes"] || []) favorited = opts[:for] && opts[:for].ap_id in (object["likes"] || [])
attachments = attachment_data = object["attachment"] || []
render_many(object["attachment"] || [], StatusView, "attachment.json", as: :attachment) attachment_data = attachment_data ++ if object["type"] == "Video", do: [object], else: []
attachments = render_many(attachment_data, StatusView, "attachment.json", as: :attachment)
created_at = Utils.to_masto_date(object["published"]) created_at = Utils.to_masto_date(object["published"])
...@@ -151,7 +152,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do ...@@ -151,7 +152,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
end end
def render("attachment.json", %{attachment: attachment}) do def render("attachment.json", %{attachment: attachment}) do
[%{"mediaType" => media_type, "href" => href} | _] = attachment["url"] [attachment_url | _] = attachment["url"]
media_type = attachment_url["mediaType"] || attachment_url["mimeType"]
href = attachment_url["href"]
type = type =
cond do cond do
...@@ -208,6 +211,19 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do ...@@ -208,6 +211,19 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
end end
end end
def render_content(%{"type" => "Video"} = object) do
name = object["name"]
content =
if !!name and name != "" do
"<p><a href=\"#{object["id"]}\">#{name}</a></p>#{object["content"]}"
else
object["content"]
end
HtmlSanitizeEx.basic_html(content)
end
def render_content(%{"type" => "Article"} = object) do def render_content(%{"type" => "Article"} = object) do
summary = object["name"] summary = object["name"]
......
...@@ -21,6 +21,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do ...@@ -21,6 +21,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
def nodeinfo(conn, %{"version" => "2.0"}) do def nodeinfo(conn, %{"version" => "2.0"}) do
instance = Application.get_env(:pleroma, :instance) instance = Application.get_env(:pleroma, :instance)
media_proxy = Application.get_env(:pleroma, :media_proxy) media_proxy = Application.get_env(:pleroma, :media_proxy)
suggestions = Application.get_env(:pleroma, :suggestions)
stats = Stats.get_stats() stats = Stats.get_stats()
response = %{ response = %{
...@@ -45,7 +46,13 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do ...@@ -45,7 +46,13 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
nodeName: Keyword.get(instance, :name), nodeName: Keyword.get(instance, :name),
nodeDescription: Keyword.get(instance, :description), nodeDescription: Keyword.get(instance, :description),
mediaProxy: Keyword.get(media_proxy, :enabled), mediaProxy: Keyword.get(media_proxy, :enabled),
private: !Keyword.get(instance, :public, true) private: !Keyword.get(instance, :public, true),
suggestions: %{
enabled: Keyword.get(suggestions, :enabled, false),
thirdPartyEngine: Keyword.get(suggestions, :third_party_engine, ""),
timeout: Keyword.get(suggestions, :timeout, 5000),
web: Keyword.get(suggestions, :web, "")
}
} }
} }
......
...@@ -141,6 +141,8 @@ defmodule Pleroma.Web.Router do ...@@ -141,6 +141,8 @@ defmodule Pleroma.Web.Router do
get("/domain_blocks", MastodonAPIController, :domain_blocks) get("/domain_blocks", MastodonAPIController, :domain_blocks)
post("/domain_blocks", MastodonAPIController, :block_domain) post("/domain_blocks", MastodonAPIController, :block_domain)
delete("/domain_blocks", MastodonAPIController, :unblock_domain) delete("/domain_blocks", MastodonAPIController, :unblock_domain)
get("/suggestions", MastodonAPIController, :suggestions)
end end
scope "/api/web", Pleroma.Web.MastodonAPI do scope "/api/web", Pleroma.Web.MastodonAPI do
......