Page MenuHomePhorge

No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None
diff --git a/lib/pleroma/web/metadata/instance.ex b/lib/pleroma/web/metadata/instance.ex
index 78e166b74..5b75c3cbd 100644
--- a/lib/pleroma/web/metadata/instance.ex
+++ b/lib/pleroma/web/metadata/instance.ex
@@ -1,75 +1,73 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Metadata.Providers.Instance do
alias Pleroma.Web.Metadata.Providers.Provider
alias Pleroma.Web.MastodonAPI.InstanceView
alias Pleroma.Web.Nodeinfo.Nodeinfo
@behaviour Provider
@impl Provider
def build_tags(_params) do
[]
|> build_info_tag()
|> build_panel_tag()
|> build_nodeinfo_tag()
end
+ def build_info_tag(acc \\ []) do
+ "show.json"
+ |> InstanceView.render(%{})
+ |> Jason.encode!()
+ |> check_for_empty()
+ |> case do
+ "" ->
+ acc
+
+ safe_data ->
+ [make_tag("instance:info", safe_data) | acc]
+ end
+ end
+
def build_panel_tag(acc \\ []) do
- instance_path =
- Path.join(:code.priv_dir(:pleroma), "static/instance/panel.html")
- |> IO.inspect()
+ instance_path = Path.join(:code.priv_dir(:pleroma), "static/instance/panel.html")
if File.exists?(instance_path) do
instance_path
|> File.read!()
|> case do
"" ->
acc
safe_data ->
[make_tag("instance:panel", safe_data) | acc]
end
else
acc
end
end
- def build_info_tag(acc \\ []) do
- "show.json"
- |> InstanceView.render(%{})
- |> Jason.encode!()
- |> check_for_empty()
- |> case do
- "" ->
- acc
-
- safe_data ->
- [make_tag("instance:info", safe_data) | acc]
- end
- end
-
def build_nodeinfo_tag(acc \\ []) do
case Nodeinfo.get_nodeinfo("2.0") do
{:error, _} ->
acc
nodeinfo_data ->
[make_tag("instance:nodeinfo", Jason.encode!(nodeinfo_data)) | acc]
end
end
defp check_for_empty(data) do
if data != "" and data != "\u200B" do
data
else
""
end
end
defp make_tag(key, data) do
{:meta, [property: key, content: data], []}
end
end
diff --git a/lib/pleroma/web/metadata/user.ex b/lib/pleroma/web/metadata/user.ex
index 1c1398f33..0bfc405dc 100644
--- a/lib/pleroma/web/metadata/user.ex
+++ b/lib/pleroma/web/metadata/user.ex
@@ -1,64 +1,60 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Metadata.Providers.User do
alias Pleroma.User
alias Pleroma.Web.MastodonAPI.AccountView
alias Pleroma.Web.Metadata.Providers.Provider
@behaviour Provider
@impl Provider
def build_tags(params) do
- IO.inspect(params, label: "the build tag _params")
-
[]
|> build_accounts_tag(params)
|> build_relationships_tag(params)
end
def build_accounts_tag(acc \\ [], %{user: user}) do
- IO.inspect(user.id, label: "the user id")
-
"show.json"
|> AccountView.render(%{user: user, for: user})
|> Jason.encode!()
|> check_for_empty()
|> case do
"" ->
acc
safe_data ->
[make_tag("user:account", safe_data) | acc]
end
end
def build_relationships_tag(acc \\ [], %{user: %{id: user_id} = user}) do
targets = User.get_all_by_ids(List.wrap(user_id))
"relationships.json"
|> AccountView.render(%{user: user, targets: targets})
|> Jason.encode!()
|> check_for_empty()
|> case do
"" ->
acc
safe_data ->
[make_tag("user:relationships", safe_data) | acc]
end
end
defp check_for_empty(data) do
if data != "" and data != "\u200B" do
data
else
""
end
end
defp make_tag(key, data) do
{:meta, [property: key, content: data], []}
end
end

File Metadata

Mime Type
text/x-diff
Expires
Sun, Aug 30, 12:11 AM (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1737633
Default Alt Text
(3 KB)

Event Timeline