Migrate to phoenix 1.7 #626

Merged
floatingghost merged 13 commits from phoenix1.7 into develop 2023-08-15 10:22:18 +00:00
76 changed files with 426 additions and 355 deletions

View File

@ -1,3 +1,14 @@
[
inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}", "priv/repo/migrations/*.exs", "priv/repo/optional_migrations/**/*.exs", "priv/scrubbers/*.ex"]
import_deps: [:ecto, :ecto_sql, :phoenix],
subdirectories: ["priv/*/migrations"],
plugins: [Phoenix.LiveView.HTMLFormatter],
inputs: [
"mix.exs",
"*.{heex,ex,exs}",
"{config,lib,test}/**/*.{heex,ex,exs}",
"priv/*/seeds.exs",
"priv/repo/migrations/*.exs",
"priv/repo/optional_migrations/**/*.exs",
"priv/scrubbers/*.ex"
]
]

55
.woodpecker/lint.yml Normal file
View File

@ -0,0 +1,55 @@
platform: linux/amd64
variables:
- &scw-secrets
- SCW_ACCESS_KEY
- SCW_SECRET_KEY
- SCW_DEFAULT_ORGANIZATION_ID
- &setup-hex "mix local.hex --force && mix local.rebar --force"
- &on-release
when:
event:
- push
- tag
branch:
- develop
- stable
- refs/tags/v*
- refs/tags/stable-*
- &on-stable
when:
event:
- push
- tag
branch:
- stable
- refs/tags/stable-*
- &on-point-release
when:
event:
- push
branch:
- develop
- stable
- &on-pr-open
when:
event:
- pull_request
- &tag-build "export BUILD_TAG=$${CI_COMMIT_TAG:-\"$CI_COMMIT_BRANCH\"} && export PLEROMA_BUILD_BRANCH=$BUILD_TAG"
- &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix)"
- &mix-clean "mix deps.clean --all && mix clean"
pipeline:
lint:
image: akkoma/ci-base:1.15-otp26
<<: *on-pr-open
environment:
MIX_ENV: test
commands:
- mix local.hex --force
- mix local.rebar --force
- mix deps.get
- mix compile
- mix format --check-formatted

View File

@ -1,5 +1,8 @@
platform: linux/amd64
depends_on:
- lint
matrix:
ELIXIR_VERSION:
- 1.14
@ -68,15 +71,7 @@ services:
POSTGRES_PASSWORD: postgres
pipeline:
lint:
<<: *on-pr-open
image: akkoma/ci-base:1.15
commands:
- mix local.hex --force
- mix local.rebar --force
- mix format --check-formatted
build:
test:
image: akkoma/ci-base:${ELIXIR_VERSION}-otp${OTP_VERSION}
<<: *on-pr-open
environment:
@ -90,24 +85,9 @@ pipeline:
- mix local.rebar --force
- mix deps.get
- mix compile
test:
image: akkoma/ci-base:${ELIXIR_VERSION}-otp${OTP_VERSION}
<<: *on-pr-open
environment:
MIX_ENV: test
POSTGRES_DB: pleroma_test_${ELIXIR_VERSION}_${OTP_VERSION}
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
DB_HOST: postgres
commands:
- mix local.hex --force
- mix local.rebar --force
- mix deps.get
- mix compile
- mix ecto.drop -f -q
- mix ecto.create
- mix ecto.migrate
- mkdir -p test/tmp
- mix test --preload-modules --exclude erratic --exclude federated --exclude mocked
- mix test --preload-modules --only mocked
- mix ecto.drop -f -q
- mix ecto.create
- mix ecto.migrate
- mkdir -p test/tmp
- mix test --preload-modules --exclude erratic --exclude federated --exclude mocked
- mix test --preload-modules --only mocked

View File

@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Changed
- OTP builds are now built on erlang OTP26
- The base Phoenix framework is now updated to 1.7
## Fixed
- Documentation issue in which a non-existing nginx file was referenced
## 2023.08

View File

@ -110,17 +110,6 @@ config :pleroma, :uri_schemes,
"xmpp"
]
websocket_config = [
path: "/websocket",
serializer: [
{Phoenix.Socket.V1.JSONSerializer, "~> 1.0.0"},
{Phoenix.Socket.V2.JSONSerializer, "~> 2.0.0"}
],
timeout: 60_000,
transport_log: false,
compress: false
]
# Configures the endpoint
config :pleroma, Pleroma.Web.Endpoint,
url: [host: "localhost"],
@ -130,10 +119,7 @@ config :pleroma, Pleroma.Web.Endpoint,
{:_,
[
{"/api/v1/streaming", Pleroma.Web.MastodonAPI.WebsocketHandler, []},
{"/websocket", Phoenix.Endpoint.CowboyWebSocket,
{Phoenix.Transports.WebSocket,
{Pleroma.Web.Endpoint, Pleroma.Web.UserSocket, websocket_config}}},
{:_, Phoenix.Endpoint.Cowboy2Handler, {Pleroma.Web.Endpoint, []}}
{:_, Plug.Cowboy.Handler, {Pleroma.Web.Endpoint, []}}
]}
]
],

View File

@ -236,6 +236,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
IO.puts("#{pack_file} has been created with the #{name} pack")
end
Pleroma.Emoji.reload()
end

View File

@ -11,6 +11,7 @@ defmodule Mix.Tasks.Pleroma.User do
alias Pleroma.UserInviteToken
alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.Pipeline
use Pleroma.Web, :verified_routes
@shortdoc "Manages Pleroma users"
@moduledoc File.read!("docs/docs/administration/CLI_tasks/user.md")
@ -113,11 +114,7 @@ defmodule Mix.Tasks.Pleroma.User do
{:ok, token} <- Pleroma.PasswordResetToken.create_token(user) do
shell_info("Generated password reset token for #{user.nickname}")
IO.puts(
"URL: #{Pleroma.Web.Router.Helpers.reset_password_url(Pleroma.Web.Endpoint,
:reset,
token.token)}"
)
IO.puts("URL: #{~p[/api/v1/pleroma/password_reset/#{token.token}]}")
else
_ ->
shell_error("No local user #{nickname}")
@ -303,13 +300,7 @@ defmodule Mix.Tasks.Pleroma.User do
{:ok, invite} <- UserInviteToken.create_invite(options) do
shell_info("Generated user invite token " <> String.replace(invite.invite_type, "_", " "))
url =
Pleroma.Web.Router.Helpers.redirect_url(
Pleroma.Web.Endpoint,
:registration_page,
invite.token
)
url = url(~p[/registration/#{invite.token}])
IO.puts(url)
else
error ->

View File

@ -26,7 +26,6 @@ defmodule Phoenix.Transports.WebSocket.Raw do
conn
|> fetch_query_params
|> Transport.transport_log(opts[:transport_log])
|> Transport.force_ssl(handler, endpoint, opts)
|> Transport.check_origin(handler, endpoint, opts)
case conn do

View File

@ -6,10 +6,13 @@ defmodule Pleroma.Emails.AdminEmail do
@moduledoc "Admin emails"
import Swoosh.Email
use Pleroma.Web, :mailer
alias Pleroma.Config
alias Pleroma.HTML
alias Pleroma.Web.Router.Helpers
use Phoenix.VerifiedRoutes,
endpoint: Pleroma.Web.Endpoint,
router: Pleroma.Web.Router
defp instance_config, do: Config.get(:instance)
defp instance_name, do: instance_config()[:name]
@ -45,7 +48,7 @@ defmodule Pleroma.Emails.AdminEmail do
statuses
|> Enum.map(fn
%{id: id} ->
status_url = Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, id)
status_url = url(~p[/notice/#{id}])
"<li><a href=\"#{status_url}\">#{status_url}</li>"
%{"id" => id} when is_binary(id) ->

View File

@ -6,12 +6,11 @@ defmodule Pleroma.Emails.UserEmail do
@moduledoc "User emails"
require Pleroma.Web.Gettext
use Pleroma.Web, :mailer
alias Pleroma.Config
alias Pleroma.User
alias Pleroma.Web.Endpoint
alias Pleroma.Web.Gettext
alias Pleroma.Web.Router
import Swoosh.Email
import Phoenix.Swoosh, except: [render_body: 3]
@ -75,7 +74,7 @@ defmodule Pleroma.Emails.UserEmail do
def password_reset_email(user, token) when is_binary(token) do
Gettext.with_locale_or_default user.language do
password_reset_url = Router.Helpers.reset_password_url(Endpoint, :reset, token)
password_reset_url = ~p[/api/v1/pleroma/password_reset/#{token}]
html_body =
Gettext.dpgettext(
@ -108,12 +107,7 @@ defmodule Pleroma.Emails.UserEmail do
to_name \\ nil
) do
Gettext.with_locale_or_default user.language do
registration_url =
Router.Helpers.redirect_url(
Endpoint,
:registration_page,
user_invite_token.token
)
registration_url = ~p[/registration/#{user_invite_token.token}]
html_body =
Gettext.dpgettext(
@ -146,13 +140,7 @@ defmodule Pleroma.Emails.UserEmail do
def account_confirmation_email(user) do
Gettext.with_locale_or_default user.language do
confirmation_url =
Router.Helpers.confirm_email_url(
Endpoint,
:confirm_email,
user.id,
to_string(user.confirmation_token)
)
confirmation_url = ~p[/api/account/confirm_email/#{user.id}/#{user.confirmation_token}]
html_body =
Gettext.dpgettext(
@ -342,7 +330,7 @@ defmodule Pleroma.Emails.UserEmail do
|> Pleroma.JWT.generate_and_sign!()
|> Base.encode64()
Router.Helpers.subscription_url(Endpoint, :unsubscribe, token)
~p[/mailer/unsubscribe/#{token}]
end
def backup_is_ready_email(backup, admin_user_id \\ nil) do

View File

@ -44,6 +44,8 @@ defmodule Pleroma.User do
alias Pleroma.Web.RelMe
alias Pleroma.Workers.BackgroundWorker
use Pleroma.Web, :verified_routes
require Logger
@type t :: %__MODULE__{}
@ -2447,12 +2449,7 @@ defmodule Pleroma.User do
end
if is_url(raw_value) do
frontend_url =
Pleroma.Web.Router.Helpers.redirect_url(
Pleroma.Web.Endpoint,
:redirector_with_meta,
nickname
)
frontend_url = url(~p[/#{nickname}])
possible_urls = [ap_id, frontend_url]

View File

@ -27,6 +27,7 @@ defmodule Pleroma.Web do
alias Pleroma.Web.Plugs.ExpectPublicOrAuthenticatedCheckPlug
alias Pleroma.Web.Plugs.OAuthScopesPlug
alias Pleroma.Web.Plugs.PlugHelper
require Pleroma.Constants
def controller do
quote do
@ -37,7 +38,7 @@ defmodule Pleroma.Web do
import Pleroma.Web.Gettext
import Pleroma.Web.TranslationHelpers
alias Pleroma.Web.Router.Helpers, as: Routes
unquote(verified_routes())
plug(:set_put_layout)
@ -184,7 +185,10 @@ defmodule Pleroma.Web do
# Import convenience functions from controllers
import Phoenix.Controller,
only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]
only: [view_module: 1, view_template: 1]
import Phoenix.Flash
alias Phoenix.Flash
# Include shared imports and aliases for views
unquote(view_helpers())
@ -218,7 +222,7 @@ defmodule Pleroma.Web do
def router do
quote do
use Phoenix.Router
use Phoenix.Router, helpers: false
import Plug.Conn
import Phoenix.Controller
@ -246,7 +250,24 @@ defmodule Pleroma.Web do
import Pleroma.Web.ErrorHelpers
import Pleroma.Web.Gettext
alias Pleroma.Web.Router.Helpers, as: Routes
unquote(verified_routes())
end
end
def static_paths, do: Pleroma.Constants.static_only_files()
def verified_routes do
quote do
use Phoenix.VerifiedRoutes,
endpoint: Pleroma.Web.Endpoint,
router: Pleroma.Web.Router,
statics: Pleroma.Web.static_paths()
end
end
def mailer do
quote do
unquote(verified_routes())
end
end

View File

@ -1792,6 +1792,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end)
end
def pin_data_from_featured_collection(obj) do
Logger.error("Could not parse featured collection #{inspect(obj)}")
%{}
end
def fetch_and_prepare_featured_from_ap_id(nil) do
{:ok, %{}}
end

View File

@ -18,6 +18,8 @@ defmodule Pleroma.Web.ActivityPub.Builder do
alias Pleroma.Web.CommonAPI.ActivityDraft
alias Pleroma.Web.Endpoint
use Pleroma.Web, :verified_routes
require Pleroma.Constants
def accept_or_reject(actor, activity, type) do
@ -402,6 +404,6 @@ defmodule Pleroma.Web.ActivityPub.Builder do
end
defp pinned_url(nickname) when is_binary(nickname) do
Pleroma.Web.Router.Helpers.activity_pub_url(Pleroma.Web.Endpoint, :pinned, nickname)
url(~p[/users/#{nickname}/collections/featured])
end
end

View File

@ -16,10 +16,11 @@ defmodule Pleroma.Web.ActivityPub.Utils do
alias Pleroma.Web.ActivityPub.Visibility
alias Pleroma.Web.AdminAPI.AccountView
alias Pleroma.Web.Endpoint
alias Pleroma.Web.Router.Helpers
import Ecto.Query
use Pleroma.Web, :verified_routes
require Logger
require Pleroma.Constants
@ -124,19 +125,15 @@ defmodule Pleroma.Web.ActivityPub.Utils do
end
def generate_activity_id do
generate_id("activities")
url(~p[/activities/#{UUID.generate()}])
end
def generate_context_id do
generate_id("contexts")
url(~p[/contexts/#{UUID.generate()}])
end
def generate_object_id do
Helpers.o_status_url(Endpoint, :object, UUID.generate())
end
def generate_id(type) do
"#{Endpoint.url()}/#{type}/#{UUID.generate()}"
url(~p[/objects/#{UUID.generate()}])
end
def get_notified_from_object(%{"type" => type} = object) when type in @supported_object_types do
@ -154,7 +151,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do
Notification.get_notified_from_activity(%Activity{data: object}, false)
end
def maybe_create_context(context), do: context || generate_id("contexts")
def maybe_create_context(context), do: context || generate_context_id()
@doc """
Enqueues an activity for federation if it's local

View File

@ -12,24 +12,22 @@ defmodule Pleroma.Web.ActivityPub.UserView do
alias Pleroma.Web.ActivityPub.ObjectView
alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.Endpoint
alias Pleroma.Web.Router.Helpers
require Pleroma.Web.ActivityPub.Transmogrifier
import Ecto.Query
def render("endpoints.json", %{user: %User{nickname: nil, local: true} = _user}) do
%{"sharedInbox" => Helpers.activity_pub_url(Endpoint, :inbox)}
%{"sharedInbox" => ~p"/inbox"}
end
def render("endpoints.json", %{user: %User{local: true} = _user}) do
%{
"oauthAuthorizationEndpoint" => Helpers.o_auth_url(Endpoint, :authorize),
"oauthRegistrationEndpoint" => Helpers.app_url(Endpoint, :create),
"oauthTokenEndpoint" => Helpers.o_auth_url(Endpoint, :token_exchange),
"sharedInbox" => Helpers.activity_pub_url(Endpoint, :inbox),
"uploadMedia" => Helpers.activity_pub_url(Endpoint, :upload_media)
"oauthAuthorizationEndpoint" => ~p"/oauth/authorize",
"oauthRegistrationEndpoint" => ~p"/api/v1/apps",
"oauthTokenEndpoint" => ~p"/oauth/token",
"sharedInbox" => ~p"/inbox",
"uploadMedia" => ~p"/api/ap/upload_media"
}
end

View File

@ -17,9 +17,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
alias Pleroma.Web.AdminAPI
alias Pleroma.Web.AdminAPI.AccountView
alias Pleroma.Web.AdminAPI.ModerationLogView
alias Pleroma.Web.Endpoint
alias Pleroma.Web.Plugs.OAuthScopesPlug
alias Pleroma.Web.Router
@users_page_size 50
@ -256,7 +254,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
conn
|> json(%{
token: token.token,
link: Router.Helpers.reset_password_url(Endpoint, :reset, token.token)
link: url(~p[/api/v1/pleroma/password_reset/#{token.token}])
})
end

View File

@ -97,7 +97,7 @@ defmodule Pleroma.Web.Endpoint do
Plug.Static,
at: "/",
from: :pleroma,
only: Pleroma.Constants.static_only_files(),
only: Pleroma.Web.static_paths(),
# credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
gzip: true,
cache_control_for_etags: @static_cache_control,

View File

@ -30,7 +30,7 @@ defmodule Pleroma.Web.Feed.UserController do
def feed_redirect(conn, %{"nickname" => nickname}) do
with {_, %User{} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do
redirect(conn, external: "#{Routes.user_feed_url(conn, :feed, user.nickname)}.atom")
redirect(conn, external: "#{url(~p"/users/#{user.nickname}/feed")}.atom")
end
end

View File

@ -34,9 +34,9 @@ defmodule Pleroma.Web.MastoFEController do
index =
if flavour == "fedibird-fe" do
"fedibird.index.html"
"fedibird.html"
else
"glitchsoc.index.html"
"glitchsoc.html"
end
conn

View File

@ -54,12 +54,7 @@ defmodule Pleroma.Web.MastodonAPI.AuthController do
defp redirect_to_oauth_form(conn, _params) do
with {:ok, app} <- local_mastofe_app() do
path =
Routes.o_auth_path(conn, :authorize,
response_type: "code",
client_id: app.client_id,
redirect_uri: ".",
scope: Enum.join(app.scopes, " ")
)
~p[/oauth/authorize?#{[response_type: "code", client_id: app.client_id, redirect_uri: ".", scope: Enum.join(app.scopes, " ")]}]
redirect(conn, to: path)
end
@ -91,7 +86,7 @@ defmodule Pleroma.Web.MastodonAPI.AuthController do
defp local_mastodon_post_login_path(conn) do
case get_session(conn, :return_to) do
nil ->
Routes.masto_fe_path(conn, :index, ["getting-started"])
~p"/web/getting-started"
return_to ->
delete_session(conn, :return_to)

View File

@ -322,7 +322,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
url =
if user.local do
Pleroma.Web.Router.Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity)
url(~p[/notice/#{activity}])
else
object.data["url"] || object.data["external_url"] || object.data["id"]
end

View File

@ -1,7 +1,6 @@
defmodule Pleroma.Web.MastodonAPI.TagView do
use Pleroma.Web, :view
alias Pleroma.User
alias Pleroma.Web.Router.Helpers
def render("index.json", %{tags: tags, for_user: user}) do
render_many(tags, __MODULE__, "show.json", %{for_user: user})
@ -17,7 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.TagView do
%{
name: tag.name,
url: Helpers.tag_feed_url(Pleroma.Web.Endpoint, :feed, tag.name),
url: url(~p[/tags/#{tag.name}]),
history: [],
following: following
}

View File

@ -3,9 +3,9 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Metadata.Providers.Feed do
alias Pleroma.Web.Endpoint
alias Pleroma.Web.Metadata.Providers.Provider
alias Pleroma.Web.Router.Helpers
use Pleroma.Web, :verified_routes
@behaviour Provider
@ -16,7 +16,7 @@ defmodule Pleroma.Web.Metadata.Providers.Feed do
[
rel: "alternate",
type: "application/atom+xml",
href: Helpers.user_feed_path(Endpoint, :feed, user.nickname) <> ".atom"
href: ~p[/users/#{user.nickname}/feed.atom]
], []}
]
end

View File

@ -10,6 +10,8 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
alias Pleroma.Web.Metadata.Providers.Provider
alias Pleroma.Web.Metadata.Utils
use Pleroma.Web, :verified_routes
@behaviour Provider
@media_types ["image", "audio", "video"]
@ -112,7 +114,7 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
defp build_attachments(_id, _object), do: []
defp player_url(id) do
Pleroma.Web.Router.Helpers.o_status_url(Pleroma.Web.Endpoint, :notice_player, id)
url(~p[/notice/#{id}/embed_player])
end
# Videos have problems without dimensions, but we used to not provide WxH for images.

View File

@ -449,7 +449,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do
|> Map.put("state", state)
# Handing the request to Ueberauth
redirect(conn, to: Routes.o_auth_path(conn, :request, provider, params))
redirect(conn, to: ~p"/oauth/#{provider}?#{params}")
end
def request(%Plug.Conn{} = conn, params) do
@ -623,7 +623,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do
end
# Special case: Local MastodonFE
defp redirect_uri(%Plug.Conn{} = conn, "."), do: Routes.auth_url(conn, :login)
defp redirect_uri(_, "."), do: url(~p"/web/login")
defp redirect_uri(%Plug.Conn{}, redirect_uri), do: redirect_uri

View File

@ -14,7 +14,6 @@ defmodule Pleroma.Web.OStatus.OStatusController do
alias Pleroma.Web.Fallback.RedirectController
alias Pleroma.Web.Metadata.PlayerView
alias Pleroma.Web.Plugs.RateLimiter
alias Pleroma.Web.Router
plug(
RateLimiter,
@ -87,7 +86,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
%{
activity_id: activity.id,
object: object,
url: Router.Helpers.o_status_url(Endpoint, :notice, activity.id),
url: url(~p[/notice/#{activity.id}]),
user: user
}
)

View File

@ -5,8 +5,9 @@
defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do
import Plug.Conn
import Phoenix.Controller, only: [get_format: 1]
use Pleroma.Web, :verified_routes
alias Pleroma.Activity
alias Pleroma.Web.Router
alias Pleroma.Signature
alias Pleroma.Instances
require Logger
@ -32,10 +33,10 @@ defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do
end
def route_aliases(%{path_info: ["objects", id], query_string: query_string}) do
ap_id = Router.Helpers.o_status_url(Pleroma.Web.Endpoint, :object, id)
ap_id = url(~p[/objects/#{id}])
with %Activity{} = activity <- Activity.get_by_object_ap_id_with_object(ap_id) do
["/notice/#{activity.id}", "/notice/#{activity.id}?#{query_string}"]
[~p"/notice/#{activity.id}", "/notice/#{activity.id}?#{query_string}"]
else
_ -> []
end

View File

@ -11,7 +11,6 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.ActivityPub.Visibility
alias Pleroma.Web.Metadata
alias Pleroma.Web.Router.Helpers
plug(:put_layout, :static_fe)
plug(:assign_id)
@ -111,11 +110,11 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
end
def show(%{assigns: %{object_id: _}} = conn, _params) do
url = Helpers.url(conn) <> conn.request_path
url = unverified_url(conn, conn.request_path)
case Activity.get_create_by_object_ap_id_with_object(url) do
%Activity{} = activity ->
to = Helpers.o_status_path(Pleroma.Web.Endpoint, :notice, activity)
to = ~p[/notice/#{activity}]
redirect(conn, to: to)
_ ->
@ -124,11 +123,11 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
end
def show(%{assigns: %{activity_id: _}} = conn, _params) do
url = Helpers.url(conn) <> conn.request_path
url = unverified_url(conn, conn.request_path)
case Activity.get_by_ap_id(url) do
%Activity{} = activity ->
to = Helpers.o_status_path(Pleroma.Web.Endpoint, :notice, activity)
to = ~p[/notice/#{activity}]
redirect(conn, to: to)
_ ->
@ -167,7 +166,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
link =
case user.local do
true -> Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity)
true -> ~p[/notice/#{activity}]
_ -> data["url"] || data["external_url"] || data["id"]
end

View File

@ -11,7 +11,6 @@ defmodule Pleroma.Web.StaticFE.StaticFEView do
alias Pleroma.Web.Gettext
alias Pleroma.Web.MediaProxy
alias Pleroma.Web.Metadata.Utils
alias Pleroma.Web.Router.Helpers
use Phoenix.HTML

View File

@ -2,7 +2,7 @@
<h3>After you submit, you will need to refresh manually to get your new frontend!</h3>
<%= form_for @conn, Routes.frontend_switcher_path(@conn, :do_switch), fn f -> %>
<%= form_for @conn, ~p"/akkoma/frontend", fn f -> %>
<%= select(f, :frontend, @choices) %>
<%= submit do: "submit" %>

View File

@ -9,13 +9,13 @@
xmlns:ostatus="http://ostatus.org/schema/1.0"
xmlns:statusnet="http://status.net/schema/api/1/">
<id><%= '#{Routes.tag_feed_url(@conn, :feed, @tag)}.rss' %></id>
<id><%= '#{url(~p"/tags/#{@tag}")}.rss' %></id>
<title>#<%= @tag %></title>
<subtitle><%= Gettext.dpgettext("static_pages", "tag feed description", "These are public toots tagged with #%{tag}. You can interact with them if you have an account anywhere in the fediverse.", tag: @tag) %></subtitle>
<logo><%= feed_logo() %></logo>
<updated><%= most_recent_update(@activities) %></updated>
<link rel="self" href="<%= '#{Routes.tag_feed_url(@conn, :feed, @tag)}.atom' %>" type="application/atom+xml"/>
<link rel="self" href="<%= '#{url(~p"/tags/#{@tag}")}.atom' %>" type="application/atom+xml"/>
<%= for activity <- @activities do %>
<%= render @view_module, "_tag_activity.atom", Map.merge(assigns, prepare_activity(activity, actor: true)) %>
<% end %>

View File

@ -5,7 +5,7 @@
<title>#<%= @tag %></title>
<description><%= Gettext.dpgettext("static_pages", "tag feed description", "These are public toots tagged with #%{tag}. You can interact with them if you have an account anywhere in the fediverse.", tag: @tag) %></description>
<link><%= '#{Routes.tag_feed_url(@conn, :feed, @tag)}.rss' %></link>
<link><%= '#{url(~p"/tags/#{@tag}")}.rss' %></link>
<webfeeds:logo><%= feed_logo() %></webfeeds:logo>
<webfeeds:accentColor>2b90d9</webfeeds:accentColor>
<%= for activity <- @activities do %>

View File

@ -6,16 +6,16 @@
xmlns:poco="http://portablecontacts.net/spec/1.0"
xmlns:ostatus="http://ostatus.org/schema/1.0">
<id><%= Routes.user_feed_url(@conn, :feed, @user.nickname) <> ".atom" %></id>
<id><%= url(~p"/users/#{@user.nickname}/feed") <> ".atom" %></id>
<title><%= @user.nickname <> "'s timeline" %></title>
<updated><%= most_recent_update(@activities, @user) %></updated>
<logo><%= logo(@user) %></logo>
<link rel="self" href="<%= '#{Routes.user_feed_url(@conn, :feed, @user.nickname)}.atom' %>" type="application/atom+xml"/>
<link rel="self" href="<%= '#{url(~p"/users/#{@user.nickname}/feed")}.atom' %>" type="application/atom+xml"/>
<%= render @view_module, "_author.atom", assigns %>
<%= if last_activity(@activities) do %>
<link rel="next" href="<%= '#{Routes.user_feed_url(@conn, :feed, @user.nickname)}.atom?max_id=#{last_activity(@activities).id}' %>" type="application/atom+xml"/>
<link rel="next" href="<%= '#{url(~p"/users/#{@user.nickname}/feed")}.atom?max_id=#{last_activity(@activities).id}' %>" type="application/atom+xml"/>
<% end %>
<%= for activity <- @activities do %>

View File

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<guid><%= Routes.user_feed_url(@conn, :feed, @user.nickname) <> ".rss" %></guid>
<guid><%= url(~p"/users/#{@user.nickname}/feed") <> ".rss" %></guid>
<title><%= @user.nickname <> "'s timeline" %></title>
<updated><%= most_recent_update(@activities, @user) %></updated>
<image><%= logo(@user) %></image>
<link><%= '#{Routes.user_feed_url(@conn, :feed, @user.nickname)}.rss' %></link>
<link><%= '#{url(~p"/users/#{@user.nickname}/feed")}.rss' %></link>
<%= render @view_module, "_author.rss", assigns %>
<%= if last_activity(@activities) do %>
<link rel="next"><%= '#{Routes.user_feed_url(@conn, :feed, @user.nickname)}.rss?max_id=#{last_activity(@activities).id}' %></link>
<link rel="next"><%= '#{url(~p"/users/#{@user.nickname}/feed")}.rss?max_id=#{last_activity(@activities).id}' %></link>
<% end %>
<%= for activity <- @activities do %>

View File

@ -0,0 +1,58 @@
<!DOCTYPE html>
<!-- FEDIBIRD -->
<html lang="en">
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<title>
<%= Config.get([:instance, :name]) %>
</title>
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="manifest" type="applicaton/manifest+json" {%{href: ~p"/web/manifest.json"}} />
<meta name="theme-color" {%{content: Config.get([:manifest, :theme_color])}} />
<script id="initial-state" type="application/json">
<%= initial_state(@token, @user, @custom_emojis) %>
</script>
<script crossorigin="anonymous" src="/packs/js/common.js">
</script>
<script crossorigin="anonymous" src="/packs/js/locale_en.js">
</script>
<link
rel="preload"
as="script"
crossorigin="anonymous"
href="/packs/js/features/getting_started.js"
/>
<link rel="preload" as="script" crossorigin="anonymous" href="/packs/js/features/compose.js" />
<link
rel="preload"
as="script"
crossorigin="anonymous"
href="/packs/js/features/home_timeline.js"
/>
<link
rel="preload"
as="script"
crossorigin="anonymous"
href="/packs/js/features/public_timeline.js"
/>
<link
rel="preload"
as="script"
crossorigin="anonymous"
href="/packs/js/features/notifications.js"
/>
<script crossorigin="anonymous" src="/packs/js/application.js">
</script>
<link rel="stylesheet" media="all" href="/packs/css/common.css" />
<link rel="stylesheet" media="all" href="/packs/css/default.css" />
</head>
<body class="app-body no-reduce-motion system-font">
<div class="app-holder" data-props="{&quot;locale&quot;:&quot;en&quot;}" id="mastodon"></div>
</body>
</html>

View File

@ -1,35 +0,0 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta content='width=device-width, initial-scale=1' name='viewport'>
<title>
<%= Config.get([:instance, :name]) %>
</title>
<link rel="icon" type="image/png" href="/favicon.png"/>
<link rel="manifest" type="applicaton/manifest+json" href="<%= Routes.masto_fe_path(Pleroma.Web.Endpoint, :manifest) %>" />
<meta name="theme-color" content="<%= Config.get([:manifest, :theme_color]) %>" />
<script id='initial-state' type='application/json'><%= initial_state(@token, @user, @custom_emojis) %></script>
<script crossorigin='anonymous' src="/packs/js/common.js"></script>
<script crossorigin='anonymous' src="/packs/js/locale_en.js"></script>
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/getting_started.js'>
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/compose.js'>
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/home_timeline.js'>
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/public_timeline.js'>
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/notifications.js'>
<script crossorigin='anonymous' src="/packs/js/application.js"></script>
<link rel="stylesheet" media="all" href="/packs/css/common.css" />
<link rel="stylesheet" media="all" href="/packs/css/default.css" />
</head>
<body class='app-body no-reduce-motion system-font'>
<div class='app-holder' data-props='{&quot;locale&quot;:&quot;en&quot;}' id='mastodon'>
</div>
</body>
</html>

View File

@ -0,0 +1,57 @@
<!DOCTYPE html>
<!-- GLITCHSOC -->
<html lang="en">
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<title>
<%= Config.get([:instance, :name]) %>
</title>
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="manifest" type="applicaton/manifest+json" {%{href: ~p"/web/manifest.json"}} />
<meta name="theme-color" {%{content: Config.get([:manifest, :theme_color])}} />
<script crossorigin="anonymous" src="/packs/js/locales.js">
</script>
<script crossorigin="anonymous" src="/packs/js/locales/glitch/en.js">
</script>
<link
rel="preload"
as="script"
crossorigin="anonymous"
href="/packs/js/features/getting_started.js"
/>
<link rel="preload" as="script" crossorigin="anonymous" href="/packs/js/features/compose.js" />
<link
rel="preload"
as="script"
crossorigin="anonymous"
href="/packs/js/features/home_timeline.js"
/>
<link
rel="preload"
as="script"
crossorigin="anonymous"
href="/packs/js/features/notifications.js"
/>
<script id="initial-state" type="application/json">
<%= initial_state(@token, @user, @custom_emojis) %>
</script>
<script src="/packs/js/core/common.js">
</script>
<link rel="stylesheet" media="all" href="/packs/css/core/common.css" />
<script src="/packs/js/flavours/glitch/common.js">
</script>
<link rel="stylesheet" media="all" href="/packs/css/flavours/glitch/common.css" />
<script src="/packs/js/flavours/glitch/home.js">
</script>
</head>
<body class="app-body no-reduce-motion system-font">
<div class="app-holder" data-props="{&quot;locale&quot;:&quot;en&quot;}" id="mastodon"></div>
</body>
</html>

View File

@ -1,35 +0,0 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta content='width=device-width, initial-scale=1' name='viewport'>
<title>
<%= Config.get([:instance, :name]) %>
</title>
<link rel="icon" type="image/png" href="/favicon.png"/>
<link rel="manifest" type="applicaton/manifest+json" href="<%= Routes.masto_fe_path(Pleroma.Web.Endpoint, :manifest) %>" />
<meta name="theme-color" content="<%= Config.get([:manifest, :theme_color]) %>" />
<script crossorigin='anonymous' src="/packs/js/locales.js"></script>
<script crossorigin='anonymous' src="/packs/js/locales/glitch/en.js"></script>
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/getting_started.js'>
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/compose.js'>
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/home_timeline.js'>
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/notifications.js'>
<script id='initial-state' type='application/json'><%= initial_state(@token, @user, @custom_emojis) %></script>
<script src="/packs/js/core/common.js"></script>
<link rel="stylesheet" media="all" href="/packs/css/core/common.css" />
<script src="/packs/js/flavours/glitch/common.js"></script>
<link rel="stylesheet" media="all" href="/packs/css/flavours/glitch/common.css" />
<script src="/packs/js/flavours/glitch/home.js"></script>
</head>
<body class='app-body no-reduce-motion system-font'>
<div class='app-holder' data-props='{&quot;locale&quot;:&quot;en&quot;}' id='mastodon'>
</div>
</body>
</html>

View File

@ -1,15 +1,15 @@
<div>
<%= if get_flash(@conn, :info) do %>
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<%= if Flash.get(@flash, :info) do %>
<p class="alert alert-info" role="alert"><%= Flash.get(@flash, :info) %></p>
<% end %>
<%= if get_flash(@conn, :error) do %>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<%= if Flash.get(@flash, :error) do %>
<p class="alert alert-danger" role="alert"><%= Flash.get(@flash, :error) %></p>
<% end %>
<div class="panel-heading">
<%= Gettext.dpgettext("static_pages", "mfa recover page title", "Two-factor recovery") %>
</div>
<div class="panel-content">
<%= form_for @conn, Routes.mfa_verify_path(@conn, :verify), [as: "mfa"], fn f -> %>
<%= form_for @conn, ~p"/oauth/mfa/verify", [as: "mfa"], fn f -> %>
<div class="input">
<%= label f, :code, Gettext.dpgettext("static_pages", "mfa recover recovery code prompt", "Recovery code") %>
<%= text_input f, :code, [autocomplete: false, autocorrect: "off", autocapitalize: "off", autofocus: true, spellcheck: false] %>
@ -21,7 +21,7 @@
<%= submit Gettext.dpgettext("static_pages", "mfa recover verify recovery code button", "Verify") %>
<% end %>
<a href="<%= Routes.mfa_path(@conn, :show, %{challenge_type: "totp", mfa_token: @mfa_token, state: @state, redirect_uri: @redirect_uri}) %>">
<a href="<%= ~p"/oauth/mfa?#{[challenge_type: "totp", mfa_token: @mfa_token, state: @state, redirect_uri: @redirect_uri]}" %>">
<%= Gettext.dpgettext("static_pages", "mfa recover use 2fa code link", "Enter a two-factor code") %>
</a>

View File

@ -1,15 +1,15 @@
<div>
<%= if get_flash(@conn, :info) do %>
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<%= if Flash.get(@flash, :info) do %>
<p class="alert alert-info" role="alert"><%= Flash.get(@flash, :info) %></p>
<% end %>
<%= if get_flash(@conn, :error) do %>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<%= if Flash.get(@flash, :error) do %>
<p class="alert alert-danger" role="alert"><%= Flash.get(@flash, :error) %></p>
<% end %>
<div class="panel-heading">
<%= Gettext.dpgettext("static_pages", "mfa auth page title", "Two-factor authentication") %>
</div>
<div class="panel-content">
<%= form_for @conn, Routes.mfa_verify_path(@conn, :verify), [as: "mfa"], fn f -> %>
<%= form_for @conn, ~p"/oauth/mfa/verify", [as: "mfa"], fn f -> %>
<div class="input">
<%= label f, :code, Gettext.dpgettext("static_pages", "mfa auth code prompt", "Authentication code") %>
<%= text_input f, :code, [autocomplete: "one-time-code", autocorrect: "off", autocapitalize: "off", autofocus: true, pattern: "[0-9]*", spellcheck: false] %>
@ -21,7 +21,7 @@
<%= submit Gettext.dpgettext("static_pages", "mfa auth verify code button", "Verify") %>
<% end %>
<a href="<%= Routes.mfa_path(@conn, :show, %{challenge_type: "recovery", mfa_token: @mfa_token, state: @state, redirect_uri: @redirect_uri}) %>">
<a href="<%= ~p"/oauth/mfa?#{[challenge_type: "recovery", mfa_token: @mfa_token, state: @state, redirect_uri: @redirect_uri]}" %>">
<%= Gettext.dpgettext("static_pages", "mfa auth page use recovery code link", "Enter a two-factor recovery code") %>
</a>
</div>

View File

@ -1,6 +1,6 @@
<h2><%= Gettext.dpgettext("static_pages", "oauth external provider page title", "Sign in with external provider") %></h2>