encode data properly
This commit is contained in:
parent
29ae5bb771
commit
dbcc1b105e
5 changed files with 54 additions and 44 deletions
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
defmodule Fallback.RedirectController do
|
||||
use Pleroma.Web, :controller
|
||||
|
||||
require Logger
|
||||
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.Metadata
|
||||
alias Pleroma.Web.Preload
|
||||
|
|
@ -38,8 +40,7 @@ defmodule Fallback.RedirectController do
|
|||
|
||||
response =
|
||||
index_content
|
||||
|> String.replace("<!--server-generated-meta-->", tags)
|
||||
|> String.replace("<!--server-generated-initial-data-->", preloads)
|
||||
|> String.replace("<!--server-generated-meta-->", tags <> preloads)
|
||||
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|
|
@ -56,7 +57,7 @@ defmodule Fallback.RedirectController do
|
|||
|
||||
response =
|
||||
index_content
|
||||
|> String.replace("<!--server-generated-initial-data-->", preloads)
|
||||
|> String.replace("<!--server-generated-meta-->", preloads)
|
||||
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ defmodule Pleroma.Web.Preload do
|
|||
end
|
||||
|
||||
def build_script_tag(content) do
|
||||
content = Base.encode64(content)
|
||||
|
||||
HTML.Tag.content_tag(:script, HTML.raw(content),
|
||||
id: "initial-results",
|
||||
type: "application/json"
|
||||
|
|
|
|||
|
|
@ -11,32 +11,29 @@ defmodule Pleroma.Web.Preload.Providers.Timelines do
|
|||
@public_url :"/api/v1/timelines/public"
|
||||
|
||||
@impl Provider
|
||||
def generate_terms(_params) do
|
||||
build_public_tag(%{})
|
||||
def generate_terms(params) do
|
||||
build_public_tag(%{}, params)
|
||||
end
|
||||
|
||||
def build_public_tag(acc) do
|
||||
def build_public_tag(acc, params) do
|
||||
if Pleroma.Config.get([:restrict_unauthenticated, :timelines, :federated], true) do
|
||||
acc
|
||||
else
|
||||
Map.put(acc, @public_url, public_timeline(nil))
|
||||
Map.put(acc, @public_url, public_timeline(params))
|
||||
end
|
||||
end
|
||||
|
||||
defp public_timeline(user) do
|
||||
defp public_timeline(%{"path" => ["main", "all"]}), do: get_public_timeline(false)
|
||||
|
||||
defp public_timeline(_params), do: get_public_timeline(true)
|
||||
|
||||
defp get_public_timeline(local_only) do
|
||||
activities =
|
||||
create_timeline_params(user)
|
||||
|> Map.put("local_only", false)
|
||||
|> ActivityPub.fetch_public_activities()
|
||||
ActivityPub.fetch_public_activities(%{
|
||||
"type" => ["Create"],
|
||||
"local_only" => local_only
|
||||
})
|
||||
|
||||
StatusView.render("index.json", activities: activities, for: user, as: :activity)
|
||||
end
|
||||
|
||||
defp create_timeline_params(user) do
|
||||
%{}
|
||||
|> Map.put("type", ["Create", "Announce"])
|
||||
|> Map.put("blocking_user", user)
|
||||
|> Map.put("muting_user", user)
|
||||
|> Map.put("user", user)
|
||||
StatusView.render("index.json", activities: activities, for: nil, as: :activity)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue