aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/upload.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex37
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex3
-rw-r--r--lib/pleroma/web/nodeinfo/nodeinfo_controller.ex4
-rw-r--r--lib/pleroma/web/router.ex1
-rw-r--r--lib/pleroma/web/twitter_api/controllers/util_controller.ex19
6 files changed, 57 insertions, 9 deletions
diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex
index 43df0d418..92a89e296 100644
--- a/lib/pleroma/upload.ex
+++ b/lib/pleroma/upload.ex
@@ -19,7 +19,7 @@ defmodule Pleroma.Upload do
end
%{
- "type" => "Image",
+ "type" => "Document",
"url" => [
%{
"type" => "Link",
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index 09e6b0b59..956787d5a 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -1,6 +1,6 @@
defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
use Pleroma.Web, :controller
- alias Pleroma.{Repo, Activity, User, Notification, Stats}
+ alias Pleroma.{Repo, Object, Activity, User, Notification, Stats}
alias Pleroma.Web
alias Pleroma.Web.MastodonAPI.{StatusView, AccountView, MastodonView, ListView}
alias Pleroma.Web.ActivityPub.ActivityPub
@@ -125,7 +125,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
response = %{
uri: Web.base_url(),
title: Keyword.get(@instance, :name),
- description: "A Pleroma instance, an alternative fediverse server",
+ description: Keyword.get(@instance, :description),
version: "#{@mastodon_api_level} (compatible; #{Keyword.get(@instance, :version)})",
email: Keyword.get(@instance, :email),
urls: %{
@@ -428,16 +428,43 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
render(conn, AccountView, "relationships.json", %{user: user, targets: targets})
end
- def upload(%{assigns: %{user: _}} = conn, %{"file" => file}) do
- with {:ok, object} <- ActivityPub.upload(file) do
+ def update_media(%{assigns: %{user: _}} = conn, data) do
+ with %Object{} = object <- Repo.get(Object, data["id"]),
+ true <- is_binary(data["description"]),
+ description <- data["description"] do
+ new_data = %{object.data | "name" => description}
+
+ change = Object.change(object, %{data: new_data})
+ {:ok, media_obj} = Repo.update(change)
+
data =
- object.data
+ new_data
|> Map.put("id", object.id)
render(conn, StatusView, "attachment.json", %{attachment: data})
end
end
+ def upload(%{assigns: %{user: _}} = conn, %{"file" => file} = data) do
+ with {:ok, object} <- ActivityPub.upload(file) do
+ objdata =
+ if Map.has_key?(data, "description") do
+ Map.put(object.data, "name", data["description"])
+ else
+ object.data
+ end
+
+ change = Object.change(object, %{data: objdata})
+ {:ok, object} = Repo.update(change)
+
+ objdata =
+ objdata
+ |> Map.put("id", object.id)
+
+ render(conn, StatusView, "attachment.json", %{attachment: objdata})
+ end
+ end
+
def favourited_by(conn, %{"id" => id}) do
with %Activity{data: %{"object" => %{"likes" => likes}}} <- Repo.get(Activity, id) do
q = from(u in User, where: u.ap_id in ^likes)
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index 4c20581d6..5dbd59dd9 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -169,7 +169,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
remote_url: href,
preview_url: MediaProxy.url(href),
text_url: href,
- type: type
+ type: type,
+ description: attachment["name"]
}
end
diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
index 12aca4a10..7c67bbf1c 100644
--- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
+++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
@@ -43,7 +43,9 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
},
metadata: %{
nodeName: Keyword.get(instance, :name),
- mediaProxy: Keyword.get(media_proxy, :enabled)
+ nodeDescription: Keyword.get(instance, :description),
+ mediaProxy: Keyword.get(media_proxy, :enabled),
+ private: !Keyword.get(instance, :public, true)
}
}
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 34652cdde..fc7a947aa 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -127,6 +127,7 @@ defmodule Pleroma.Web.Router do
get("/notifications/:id", MastodonAPIController, :get_notification)
post("/media", MastodonAPIController, :upload)
+ put("/media/:id", MastodonAPIController, :update_media)
get("/lists", MastodonAPIController, :get_lists)
get("/lists/:id", MastodonAPIController, :get_list)
diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
index 7a0c37ce9..47fc79350 100644
--- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex
+++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
@@ -126,6 +126,8 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
@instance Application.get_env(:pleroma, :instance)
+ @instance_fe Application.get_env(:pleroma, :fe)
+ @instance_chat Application.get_env(:pleroma, :chat)
def config(conn, _params) do
case get_format(conn) do
"xml" ->
@@ -148,9 +150,24 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
json(conn, %{
site: %{
name: Keyword.get(@instance, :name),
+ description: Keyword.get(@instance, :description),
server: Web.base_url(),
textlimit: to_string(Keyword.get(@instance, :limit)),
- closed: if(Keyword.get(@instance, :registrations_open), do: "0", else: "1")
+ closed: if(Keyword.get(@instance, :registrations_open), do: "0", else: "1"),
+ private: if(Keyword.get(@instance, :public, true), do: "0", else: "1"),
+ pleromafe: %{
+ theme: Keyword.get(@instance_fe, :theme),
+ background: Keyword.get(@instance_fe, :background),
+ logo: Keyword.get(@instance_fe, :logo),
+ redirectRootNoLogin: Keyword.get(@instance_fe, :redirect_root_no_login),
+ redirectRootLogin: Keyword.get(@instance_fe, :redirect_root_login),
+ chatDisabled: !Keyword.get(@instance_chat, :enabled),
+ showInstanceSpecificPanel: Keyword.get(@instance_fe, :show_instance_panel),
+ showWhoToFollowPanel: Keyword.get(@instance_fe, :show_who_to_follow_panel),
+ scopeOptionsEnabled: Keyword.get(@instance_fe, :scope_options_enabled),
+ whoToFollowProvider: Keyword.get(@instance_fe, :who_to_follow_provider),
+ whoToFollowLink: Keyword.get(@instance_fe, :who_to_follow_link)
+ }
}
})
end