diff --git a/.sobelow-skips b/.sobelow-skips index 3ce31fbbd..b0d6ee102 100644 --- a/.sobelow-skips +++ b/.sobelow-skips @@ -1,15 +1,15 @@ 155A1FB53DE39EC8EFCFD7FB94EA823D 1C29EE70E90ECED01AF28EC58D2575B5 +26ED12A8E03D044BEDC08749BAA5E357 +2BB1D36656B423758A470021718FCB09 31CE26BC979C57B9E3CC97B40C290CE5 3529E7A4CECC24D02678820E6F521162 -37E854EA3BDF7275C6A7631F80804EC4 +3644C4E850300482AA409471EFE1EFB3 4E7C044C59E0BCB76AA826789998F624 53CBBEB6243FAF5C37249CBA17DE6F4C 5BCE3651A03711295046DE48BDFE007E -5C16A2AE6A24E4795F95DDE20EEC458E 5C4CED447689F00D9D1ACEB9B895ED29 -630C0972985257251EDF89A7117DE423 94ACF7B17C3FF42F64E57DD1DA936BD8 A32E125003F1EDFAD95C487C6A969725 ACF6272A1DBB3A2ABD96C0C120B5CA69 diff --git a/CHANGELOG.md b/CHANGELOG.md index 54365b376..c80a0c03a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 4.0.0-beta.2 (2023-12-01) + +* test: fix tests using verified routes ([5fcf3d5](https://framagit.org/framasoft/mobilizon/commits/5fcf3d5)) +* feat: add links to cancel anonymous participations in emails ([9e6b232](https://framagit.org/framasoft/mobilizon/commits/9e6b232)) +* feat(background): add a job to refresh participant stats ([11e42d6](https://framagit.org/framasoft/mobilizon/commits/11e42d6)) +* feat(front): add dedicated page and route for event announcements ([d831dff](https://framagit.org/framasoft/mobilizon/commits/d831dff)) +* chore(i18n): update backend translations ([6df16ef](https://framagit.org/framasoft/mobilizon/commits/6df16ef)) +* fix: fix creating participant stats ([3f2a88f](https://framagit.org/framasoft/mobilizon/commits/3f2a88f)) +* refactor: use Phoenix verified routes ([b315e1d](https://framagit.org/framasoft/mobilizon/commits/b315e1d)) + ## 4.0.0-beta.1 (2023-11-30) * fix: add a final fallback if we have default_language: nil in instance config ([cd53062](https://framagit.org/framasoft/mobilizon/commits/cd53062)) diff --git a/config/config.exs b/config/config.exs index c1abf462f..d46ebffd2 100644 --- a/config/config.exs +++ b/config/config.exs @@ -325,6 +325,7 @@ config :mobilizon, Oban, {"@hourly", Mobilizon.Service.Workers.ExportCleanerWorker, queue: :background}, {"@hourly", Mobilizon.Service.Workers.SendActivityRecapWorker, queue: :notifications}, {"@daily", Mobilizon.Service.Workers.CleanOldActivityWorker, queue: :background}, + {"@daily", Mobilizon.Service.Workers.RefreshParticipantStats, queue: :background}, {"@hourly", Mobilizon.Service.Workers.CleanApplicationData, queue: :background, args: %{type: :application_token}}, {"@hourly", Mobilizon.Service.Workers.CleanApplicationData, diff --git a/lib/federation/web_finger/web_finger.ex b/lib/federation/web_finger/web_finger.ex index 467e46b57..bc65bec4f 100644 --- a/lib/federation/web_finger/web_finger.ex +++ b/lib/federation/web_finger/web_finger.ex @@ -14,7 +14,7 @@ defmodule Mobilizon.Federation.WebFinger do alias Mobilizon.Federation.WebFinger.XmlBuilder alias Mobilizon.Service.HTTP.{HostMetaClient, WebfingerClient} alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes require Jason require Logger import SweetXml @@ -85,7 +85,7 @@ defmodule Mobilizon.Federation.WebFinger do %{"rel" => "self", "type" => "application/activity+json", "href" => actor.url}, %{ "rel" => "http://ostatus.org/schema/1.0/subscribe", - "template" => "#{Routes.page_url(Endpoint, :interact, uri: nil)}{uri}" + "template" => "#{url(~p"/interact?#{[uri: nil]}")}{uri}" } ] |> maybe_add_avatar(actor) diff --git a/lib/graphql/resolvers/participant.ex b/lib/graphql/resolvers/participant.ex index ad5058c1e..6b3efa5d0 100644 --- a/lib/graphql/resolvers/participant.ex +++ b/lib/graphql/resolvers/participant.ex @@ -176,7 +176,9 @@ defmodule Mobilizon.GraphQL.Resolvers.Participant do case Participations.leave(event, actor, %{local: false, cancellation_token: token}) do {:ok, _activity, %Participant{id: participant_id} = _participant} -> - {:ok, %{event: %{id: event_id}, actor: %{id: actor_id}, id: participant_id}} + {:ok, %Event{} = event} = Events.get_event_with_preload(event_id) + %Actor{} = actor = Actors.get_actor_with_preload!(actor_id) + {:ok, %{event: event, actor: actor, id: participant_id}} {:error, :is_only_organizer} -> {:error, @@ -202,8 +204,11 @@ defmodule Mobilizon.GraphQL.Resolvers.Participant do with {:is_owned, %Actor{} = actor} <- User.owns_actor(user, actor_id), {:has_event, {:ok, %Event{} = event}} <- {:has_event, Events.get_event_with_preload(event_id)}, - {:ok, _activity, _participant} <- Participations.leave(event, actor) do - {:ok, %{event: %{id: event_id}, actor: %{id: actor_id}}} + {:ok, _activity, %Participant{id: participant_id} = _participant} <- + Participations.leave(event, actor) do + {:ok, %Event{} = event} = Events.get_event_with_preload(event_id) + %Actor{} = actor = Actors.get_actor_with_preload!(actor_id) + {:ok, %{event: event, actor: actor, id: participant_id}} else {:has_event, _} -> {:error, "Event with this ID #{inspect(event_id)} doesn't exist"} diff --git a/lib/graphql/schema/events/participant.ex b/lib/graphql/schema/events/participant.ex index 0585173ae..07ba90e89 100644 --- a/lib/graphql/schema/events/participant.ex +++ b/lib/graphql/schema/events/participant.ex @@ -90,8 +90,8 @@ defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do object :deleted_participant do meta(:authorize, :all) field(:id, :id, description: "The participant ID") - field(:event, :deleted_object, description: "The participant's event") - field(:actor, :deleted_object, description: "The participant's actor") + field(:event, :event, description: "The participant's event") + field(:actor, :actor, description: "The participant's actor") end object :participant_mutations do diff --git a/lib/mix/tasks/mobilizon/maintenance/detect_spam.ex b/lib/mix/tasks/mobilizon/maintenance/detect_spam.ex index 1af1902aa..80ab1d6c6 100644 --- a/lib/mix/tasks/mobilizon/maintenance/detect_spam.ex +++ b/lib/mix/tasks/mobilizon/maintenance/detect_spam.ex @@ -9,8 +9,7 @@ defmodule Mix.Tasks.Mobilizon.Maintenance.DetectSpam do alias Mobilizon.Service.AntiSpam import Mix.Tasks.Mobilizon.Common alias Mobilizon.Federation.ActivityPub.Actions - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes @shortdoc "Scan all profiles and events against spam detector and report them" @@ -163,9 +162,7 @@ defmodule Mix.Tasks.Mobilizon.Maintenance.DetectSpam do end defp handle_spam_event(event_id, event_title, event_uuid, organizer_actor_id, options) do - shell_info( - "Detected event #{event_title} as spam: #{Routes.page_url(Endpoint, :event, event_uuid)}" - ) + shell_info("Detected event #{event_title} as spam: #{url(~p"/events/#{event_uuid}")}") unless dry_run?(options) do report_spam_event(event_id, event_title, organizer_actor_id, options) diff --git a/lib/mobilizon/actors/actor.ex b/lib/mobilizon/actors/actor.ex index 3d5cedc8a..14432ec1a 100644 --- a/lib/mobilizon/actors/actor.ex +++ b/lib/mobilizon/actors/actor.ex @@ -19,6 +19,7 @@ defmodule Mobilizon.Actors.Actor do alias Mobilizon.Web.Endpoint alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext, only: [dgettext: 2] import Mobilizon.Service.Guards, only: [is_valid_string: 1] @@ -445,7 +446,7 @@ defmodule Mobilizon.Actors.Actor do # Relay has a special URI def build_url("relay", :page, _args), - do: Endpoint |> Routes.activity_pub_url(:relay) |> URI.decode() + do: ~p"/relay" |> url() |> URI.decode() def build_url(preferred_username, endpoint, args) when endpoint in [:page, :resources, :posts, :discussions, :events, :todos] do diff --git a/lib/mobilizon/discussions/comment.ex b/lib/mobilizon/discussions/comment.ex index 151f45218..77c5817b5 100644 --- a/lib/mobilizon/discussions/comment.ex +++ b/lib/mobilizon/discussions/comment.ex @@ -15,8 +15,7 @@ defmodule Mobilizon.Discussions.Comment do alias Mobilizon.Medias.Media alias Mobilizon.Mention - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes @type t :: %__MODULE__{ text: String.t(), @@ -160,7 +159,7 @@ defmodule Mobilizon.Discussions.Comment do end @spec generate_url(String.t()) :: String.t() - defp generate_url(uuid), do: Routes.page_url(Endpoint, :comment, uuid) + defp generate_url(uuid), do: url(~p"/comments/#{uuid}") @spec put_tags(Ecto.Changeset.t(), map) :: Ecto.Changeset.t() defp put_tags(changeset, %{"tags" => tags}), diff --git a/lib/mobilizon/discussions/discussion.ex b/lib/mobilizon/discussions/discussion.ex index 5d5f513e8..b2ba6a597 100644 --- a/lib/mobilizon/discussions/discussion.ex +++ b/lib/mobilizon/discussions/discussion.ex @@ -27,8 +27,7 @@ defmodule Mobilizon.Discussions.Discussion do alias Mobilizon.Actors.Actor alias Mobilizon.Discussions.Comment alias Mobilizon.Discussions.Discussion.TitleSlug - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext, only: [dgettext: 2] @type t :: %__MODULE__{ @@ -101,5 +100,5 @@ defmodule Mobilizon.Discussions.Discussion do @spec generate_url(String.t(), String.t()) :: String.t() defp generate_url(preferred_username, slug), - do: Routes.page_url(Endpoint, :discussion, preferred_username, slug) + do: url(~p"/@:#{preferred_username}/c/#{slug}") end diff --git a/lib/mobilizon/events/event.ex b/lib/mobilizon/events/event.ex index 9a1692e35..ff76568ae 100644 --- a/lib/mobilizon/events/event.ex +++ b/lib/mobilizon/events/event.ex @@ -32,8 +32,7 @@ defmodule Mobilizon.Events.Event do alias Mobilizon.Medias.Media alias Mobilizon.Storage.Repo - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes @type t :: %__MODULE__{ id: integer(), @@ -140,7 +139,7 @@ defmodule Mobilizon.Events.Event do @spec changeset(t | Ecto.Schema.t(), map) :: Changeset.t() def changeset(%__MODULE__{} = event, attrs) do attrs = Map.update(attrs, :uuid, Ecto.UUID.generate(), &(&1 || Ecto.UUID.generate())) - attrs = Map.update(attrs, :url, Routes.page_url(Endpoint, :event, attrs.uuid), & &1) + attrs = Map.update(attrs, :url, url(~p"/events/#{attrs.uuid}"), & &1) event |> cast(attrs, @attrs) diff --git a/lib/mobilizon/events/events.ex b/lib/mobilizon/events/events.ex index 77f69fbed..8796ae442 100644 --- a/lib/mobilizon/events/events.ex +++ b/lib/mobilizon/events/events.ex @@ -1105,7 +1105,7 @@ defmodule Mobilizon.Events do defp increase_participant_stats(participant_stats, nil), do: participant_stats defp increase_participant_stats(participant_stats, role), - do: Map.update(participant_stats, role, 0, &(&1 + 1)) + do: Map.update(participant_stats, role, 1, &(&1 + 1)) defp decrease_participant_stats(participant_stats, nil), do: participant_stats diff --git a/lib/mobilizon/posts/post.ex b/lib/mobilizon/posts/post.ex index 870b438d5..a6d9d9bf7 100644 --- a/lib/mobilizon/posts/post.ex +++ b/lib/mobilizon/posts/post.ex @@ -27,8 +27,7 @@ defmodule Mobilizon.Posts.Post do alias Mobilizon.Medias.Media alias Mobilizon.Posts.Post.TitleSlug alias Mobilizon.Posts.PostVisibility - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext @type t :: %__MODULE__{ @@ -128,7 +127,7 @@ defmodule Mobilizon.Posts.Post do @spec generate_url(String.t()) :: String.t() defp generate_url(id_and_slug) when is_binary(id_and_slug), - do: Routes.page_url(Endpoint, :post, id_and_slug) + do: url(~p"/p/#{id_and_slug}") defp generate_url(_), do: nil diff --git a/lib/service/activity/renderer/comment.ex b/lib/service/activity/renderer/comment.ex index c7551c6d2..fe77ebcad 100644 --- a/lib/service/activity/renderer/comment.ex +++ b/lib/service/activity/renderer/comment.ex @@ -5,8 +5,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Comment do alias Mobilizon.Activities.Activity alias Mobilizon.Actors.Actor alias Mobilizon.Service.Activity.Renderer - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext, only: [dgettext: 3] @behaviour Renderer @@ -78,11 +77,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Comment do end defp event_url(activity) do - Routes.page_url( - Endpoint, - :event, - activity.subject_params["event_uuid"] - ) + url(~p"/events/#{activity.subject_params["event_uuid"]}") end defp event_comment_url(activity) do diff --git a/lib/service/activity/renderer/conversation.ex b/lib/service/activity/renderer/conversation.ex index e2a081188..d0bf1fa1e 100644 --- a/lib/service/activity/renderer/conversation.ex +++ b/lib/service/activity/renderer/conversation.ex @@ -5,8 +5,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Conversation do alias Mobilizon.Activities.Activity alias Mobilizon.Actors.Actor alias Mobilizon.Service.Activity.Renderer - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext, only: [dgettext: 3] @behaviour Renderer @@ -61,11 +60,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Conversation do end defp conversation_url(activity) do - Routes.page_url( - Endpoint, - :conversation, - activity.subject_params["conversation_id"] - ) + url(~p"/conversations/#{activity.subject_params["conversation_id"]}") end defp profile(activity), do: Actor.display_name_and_username(activity.author) diff --git a/lib/service/activity/renderer/discussion.ex b/lib/service/activity/renderer/discussion.ex index 224a93763..7dc3aca13 100644 --- a/lib/service/activity/renderer/discussion.ex +++ b/lib/service/activity/renderer/discussion.ex @@ -5,8 +5,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Discussion do alias Mobilizon.Activities.Activity alias Mobilizon.Actors.Actor alias Mobilizon.Service.Activity.Renderer - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext, only: [dgettext: 3] @behaviour Renderer @@ -113,12 +112,8 @@ defmodule Mobilizon.Service.Activity.Renderer.Discussion do end defp discussion_url(activity) do - Endpoint - |> Routes.page_url( - :discussion, - Actor.preferred_username_and_domain(activity.group), - activity.subject_params["discussion_slug"] - ) + ~p"/@#{Actor.preferred_username_and_domain(activity.group)}/c/#{activity.subject_params["discussion_slug"]}" + |> url() |> URI.decode() end diff --git a/lib/service/activity/renderer/event.ex b/lib/service/activity/renderer/event.ex index 3bf07232f..f06770146 100644 --- a/lib/service/activity/renderer/event.ex +++ b/lib/service/activity/renderer/event.ex @@ -5,8 +5,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Event do alias Mobilizon.Activities.Activity alias Mobilizon.Actors.Actor alias Mobilizon.Service.Activity.Renderer - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext, only: [dgettext: 3] @behaviour Renderer @@ -81,11 +80,8 @@ defmodule Mobilizon.Service.Activity.Renderer.Event do end defp event_url(activity) do - Endpoint - |> Routes.page_url( - :event, - activity.subject_params["event_uuid"] - ) + ~p"/events/#{activity.subject_params["event_uuid"]}" + |> url() |> URI.decode() end diff --git a/lib/service/activity/renderer/group.ex b/lib/service/activity/renderer/group.ex index a9df9d826..ca3216c67 100644 --- a/lib/service/activity/renderer/group.ex +++ b/lib/service/activity/renderer/group.ex @@ -5,8 +5,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Group do alias Mobilizon.Activities.Activity alias Mobilizon.Actors.Actor alias Mobilizon.Service.Activity.Renderer - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext, only: [dgettext: 3] @behaviour Renderer @@ -30,8 +29,8 @@ defmodule Mobilizon.Service.Activity.Renderer.Group do end defp group_url(activity) do - Endpoint - |> Routes.page_url(:actor, Actor.preferred_username_and_domain(activity.group)) + ~p"/@#{Actor.preferred_username_and_domain(activity.group)}" + |> url() |> URI.decode() end diff --git a/lib/service/activity/renderer/member.ex b/lib/service/activity/renderer/member.ex index 47509b532..f1da19aa1 100644 --- a/lib/service/activity/renderer/member.ex +++ b/lib/service/activity/renderer/member.ex @@ -5,8 +5,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Member do alias Mobilizon.Activities.Activity alias Mobilizon.Actors.Actor alias Mobilizon.Service.Activity.Renderer - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext, only: [dgettext: 3] @behaviour Renderer @@ -81,12 +80,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Member do defp member_url(activity) do group_url = - Endpoint - |> Routes.page_url( - :actor, - Actor.preferred_username_and_domain(activity.group) - ) - |> URI.decode() + ~p"/@#{Actor.preferred_username_and_domain(activity.group)}" |> url() |> URI.decode() "#{group_url}/settings/members" end diff --git a/lib/service/activity/renderer/post.ex b/lib/service/activity/renderer/post.ex index 1491e58e8..1706217de 100644 --- a/lib/service/activity/renderer/post.ex +++ b/lib/service/activity/renderer/post.ex @@ -5,8 +5,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Post do alias Mobilizon.Activities.Activity alias Mobilizon.Actors.Actor alias Mobilizon.Service.Activity.Renderer - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext, only: [dgettext: 3] @behaviour Renderer @@ -52,12 +51,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Post do end defp post_url(activity) do - Endpoint - |> Routes.page_url( - :post, - activity.subject_params["post_slug"] - ) - |> URI.decode() + URI.decode(~p"/p/#{activity.subject_params["post_slug"]}") end defp profile(activity), do: Actor.display_name_and_username(activity.author) diff --git a/lib/service/activity/renderer/resource.ex b/lib/service/activity/renderer/resource.ex index 4ad175048..7820872f4 100644 --- a/lib/service/activity/renderer/resource.ex +++ b/lib/service/activity/renderer/resource.ex @@ -5,8 +5,7 @@ defmodule Mobilizon.Service.Activity.Renderer.Resource do alias Mobilizon.Activities.Activity alias Mobilizon.Actors.Actor alias Mobilizon.Service.Activity.Renderer - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext, only: [dgettext: 3] @behaviour Renderer @@ -73,8 +72,8 @@ defmodule Mobilizon.Service.Activity.Renderer.Resource do end defp resource_url(activity) do - Endpoint - |> Routes.page_url(:resource, activity.subject_params["resource_uuid"]) + ~p"/resource/#{activity.subject_params["resource_uuid"]}" + |> url() |> URI.decode() end diff --git a/lib/service/auth/applications.ex b/lib/service/auth/applications.ex index 04b8d3cca..44770ff37 100644 --- a/lib/service/auth/applications.ex +++ b/lib/service/auth/applications.ex @@ -8,7 +8,7 @@ defmodule Mobilizon.Service.Auth.Applications do alias Mobilizon.Service.Auth.Authenticator alias Mobilizon.Users.User alias Mobilizon.Web.Auth.Guardian - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes require Logger @app_access_tokens_ttl {8, :hour} @@ -260,8 +260,7 @@ defmodule Mobilizon.Service.Auth.Applications do with {:app, %Application{scope: app_scope} = application} <- {:app, Applications.get_application_by_client_id(client_id)}, {device_code, user_code, verification_uri} <- - {string_of_length(40), string_of_length(8), - Routes.page_url(Mobilizon.Web.Endpoint, :auth_device)}, + {string_of_length(40), string_of_length(8), url(~p"/login/device")}, {:scope_included, true} <- {:scope_included, request_scope_valid?(app_scope, scope)}, {:ok, %ApplicationDeviceActivation{} = application_device_activation} <- Applications.create_application_device_activation(%{ diff --git a/lib/service/export/feed.ex b/lib/service/export/feed.ex index 96f5644af..80ec7dcb4 100644 --- a/lib/service/export/feed.ex +++ b/lib/service/export/feed.ex @@ -15,7 +15,7 @@ defmodule Mobilizon.Service.Export.Feed do alias Mobilizon.Users.User alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes require Logger @@ -104,10 +104,7 @@ defmodule Mobilizon.Service.Export.Feed do defp build_actor_feed(%Actor{} = actor, events, posts, public \\ true) do display_name = Actor.display_name(actor) - self_url = - Endpoint - |> Routes.feed_url(:actor, actor.preferred_username, "atom") - |> URI.decode() + self_url = ~p"/@#{actor.preferred_username}/feed/atom" |> url() |> URI.decode() title = if public, @@ -215,7 +212,7 @@ defmodule Mobilizon.Service.Export.Feed do # Build an atom feed from actor and its public events @spec build_user_feed(list(Event.t()), User.t(), String.t()) :: String.t() defp build_user_feed(events, %User{email: email}, token) do - self_url = Endpoint |> Routes.feed_url(:going, token, "atom") |> URI.decode() + self_url = ~p"/events/going/#{token}/format" |> url() |> URI.decode() # Title uses default instance language self_url diff --git a/lib/service/metadata/actor.ex b/lib/service/metadata/actor.ex index e4174c45b..e71cb6cc5 100644 --- a/lib/service/metadata/actor.ex +++ b/lib/service/metadata/actor.ex @@ -2,9 +2,8 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do alias Phoenix.HTML alias Phoenix.HTML.Tag alias Mobilizon.Actors.Actor - alias Mobilizon.Web.Endpoint alias Mobilizon.Web.JsonLD.ObjectView - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Service.Metadata.Utils, only: [process_description: 2, default_description: 1, escape_text: 1] @@ -25,13 +24,7 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do Tag.tag(:meta, property: "og:title", content: actor_display_name_escaped(group)), Tag.tag(:meta, property: "og:url", - content: - Endpoint - |> Routes.page_url( - :actor, - Actor.preferred_username_and_domain(group) - ) - |> URI.decode() + content: ~p"/@#{Actor.preferred_username_and_domain(group)}" |> url() |> URI.decode() ), Tag.tag(:meta, property: "og:description", content: group.summary), Tag.tag(:meta, property: "og:type", content: "profile"), @@ -92,19 +85,14 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do type: "application/atom+xml", title: gettext("%{name}'s feed", name: actor_display_name_escaped(group)) |> HTML.raw(), href: - Routes.feed_url(Endpoint, :actor, Actor.preferred_username_and_domain(group), :atom) + ~p"/@#{Actor.preferred_username_and_domain(group)}/feed/atom" |> url() |> URI.decode() ), Tag.tag(:link, rel: "alternate", type: "text/calendar", title: gettext("%{name}'s feed", name: actor_display_name_escaped(group)) |> HTML.raw(), href: - Routes.feed_url( - Endpoint, - :actor, - Actor.preferred_username_and_domain(group), - :ics - ) + ~p"/@#{Actor.preferred_username_and_domain(group)}/feed/ics" |> url() |> URI.decode() ), Tag.tag(:link, rel: "alternate", diff --git a/lib/service/metadata/event.ex b/lib/service/metadata/event.ex index 29b5a8059..e311c66b7 100644 --- a/lib/service/metadata/event.ex +++ b/lib/service/metadata/event.ex @@ -6,7 +6,7 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Events.Event do alias Mobilizon.Events.{Event, EventOptions} alias Mobilizon.Web.Endpoint alias Mobilizon.Web.JsonLD.ObjectView - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Service.Metadata.Utils, only: [ @@ -56,11 +56,8 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Events.Event do "position" => 1, "name" => event.attributed_to |> Actor.display_name() |> escape_text(), "item" => - Endpoint - |> Routes.page_url( - :actor, - Actor.preferred_username_and_domain(event.attributed_to) - ) + ~p"/@#{Actor.preferred_username_and_domain(event.attributed_to)}" + |> url() |> URI.decode() }, %{ diff --git a/lib/service/metadata/instance.ex b/lib/service/metadata/instance.ex index 953453ebe..8bbc5db93 100644 --- a/lib/service/metadata/instance.ex +++ b/lib/service/metadata/instance.ex @@ -9,7 +9,7 @@ defmodule Mobilizon.Service.Metadata.Instance do alias Mobilizon.Config alias Mobilizon.Service.Metadata.Utils alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes import Mobilizon.Web.Gettext @doc """ @@ -58,13 +58,13 @@ defmodule Mobilizon.Service.Metadata.Instance do rel: "alternate", type: "application/atom+xml", title: gettext("%{name}'s feed", name: Config.instance_name()) |> HTML.raw(), - href: Routes.feed_url(Endpoint, :instance, :atom) + href: url(~p"/feed/instance/atom") ), Tag.tag(:link, rel: "alternate", type: "text/calendar", title: gettext("%{name}'s feed", name: Config.instance_name()) |> HTML.raw(), - href: Routes.feed_url(Endpoint, :instance, :ics) + href: url(~p"/feed/instance/ics") ) ] end diff --git a/lib/service/metadata/post.ex b/lib/service/metadata/post.ex index 90daf3dc3..9ff64f9a4 100644 --- a/lib/service/metadata/post.ex +++ b/lib/service/metadata/post.ex @@ -4,9 +4,8 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Posts.Post do alias Mobilizon.Actors.Actor alias Mobilizon.Medias.{File, Media} alias Mobilizon.Posts.Post - alias Mobilizon.Web.Endpoint + use Mobilizon.Web, :verified_routes alias Mobilizon.Web.JsonLD.ObjectView - alias Mobilizon.Web.Router.Helpers, as: Routes import Mobilizon.Service.Metadata.Utils, only: [process_description: 2, strip_tags: 1, escape_text: 1] @@ -35,11 +34,8 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Posts.Post do "position" => 1, "name" => post.attributed_to |> Actor.display_name() |> escape_text, "item" => - Endpoint - |> Routes.page_url( - :actor, - Actor.preferred_username_and_domain(post.attributed_to) - ) + ~p"/@#{Actor.preferred_username_and_domain(post.attributed_to)}" + |> url() |> URI.decode() }, %{ diff --git a/lib/service/site_map.ex b/lib/service/site_map.ex index 9db246442..24609d7ba 100644 --- a/lib/service/site_map.ex +++ b/lib/service/site_map.ex @@ -6,14 +6,14 @@ defmodule Mobilizon.Service.SiteMap do alias Mobilizon.{Actors, Events, Posts} alias Mobilizon.Storage.Repo alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes @default_static_frequency :monthly @spec generate_sitemap :: {:ok, :ok} def generate_sitemap do static_routes = [ - {Routes.page_url(Endpoint, :index, []), :daily}, + {url(~p"/*path"), :daily}, "#{Endpoint.url()}/search", "#{Endpoint.url()}/about/instance", "#{Endpoint.url()}/terms", diff --git a/lib/service/workers/refresh_participant_stats.ex b/lib/service/workers/refresh_participant_stats.ex new file mode 100644 index 000000000..b41cea26e --- /dev/null +++ b/lib/service/workers/refresh_participant_stats.ex @@ -0,0 +1,61 @@ +defmodule Mobilizon.Service.Workers.RefreshParticipantStats do + @moduledoc """ + Worker to refresh the participant event stats based on participants data + """ + + use Oban.Worker, unique: [period: :infinity, keys: [:event_uuid, :action]] + + alias Mobilizon.Events + alias Mobilizon.Events.{Event, Participant} + alias Mobilizon.Storage.Page + alias Oban.Job + require Logger + + @impl Oban.Worker + @spec perform(Oban.Job.t()) :: :ok + def perform(%Job{}) do + refresh_participant_stats() + end + + def refresh_participant_stats do + Logger.info("Launching RefreshParticipantStats job") + %Page{elements: future_events} = Events.list_events(1, 100_000_000) + + updated_events_count = + Enum.reduce(future_events, 0, fn %Event{} = event, updated_events_count -> + participants = Events.list_all_participants_for_event(event.id) + + participant_stats = + Enum.reduce( + participants, + %{ + not_approved: 0, + not_confirmed: 0, + rejected: 0, + participant: 0, + moderator: 0, + administrator: 0, + creator: 0 + }, + fn %Participant{role: role}, acc -> + Map.update(acc, role, 1, &(&1 + 1)) + end + ) + + if participant_stats != Map.from_struct(event.participant_stats) do + Logger.debug("Uupdating event #{event.id} because of wrong participant_stats") + + Events.update_event(event, %{ + participant_stats: participant_stats + }) + + updated_events_count + 1 + else + Logger.debug("Skipped updating event #{event.id}") + updated_events_count + end + end) + + Logger.info("Updated #{updated_events_count} events on #{length(future_events)}") + end +end diff --git a/lib/web/cache/activity_pub.ex b/lib/web/cache/activity_pub.ex index 9b05cb650..7e2130682 100644 --- a/lib/web/cache/activity_pub.ex +++ b/lib/web/cache/activity_pub.ex @@ -13,8 +13,7 @@ defmodule Mobilizon.Web.Cache.ActivityPub do alias Mobilizon.Posts.Post alias Mobilizon.Resources.Resource alias Mobilizon.Todos.{Todo, TodoList} - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes + use Mobilizon.Web, :verified_routes @cache :activity_pub @@ -73,7 +72,7 @@ defmodule Mobilizon.Web.Cache.ActivityPub do {:commit, event} nil -> - with url <- Routes.page_url(Endpoint, :event, uuid), + with url <- url(~p"/events/#{uuid}"), %Tombstone{} = tomstone <- Tombstone.find_tombstone(url) do tomstone else diff --git a/lib/web/controllers/application_controller.ex b/lib/web/controllers/application_controller.ex index a08960f12..cdfc669ed 100644 --- a/lib/web/controllers/application_controller.ex +++ b/lib/web/controllers/application_controller.ex @@ -111,12 +111,7 @@ defmodule Mobilizon.Web.ApplicationController do is_binary(state) and is_binary(scope) do redirect(conn, to: - Routes.page_path(conn, :authorize, - client_id: client_id, - redirect_uri: redirect_uri, - scope: scope, - state: state - ) + ~p"/oauth/autorize_approve?#{[client_id: client_id, redirect_uri: redirect_uri, scope: scope, state: state]}" ) else if is_binary(redirect_uri) and valid_uri?(redirect_uri) do diff --git a/lib/web/controllers/node_info_controller.ex b/lib/web/controllers/node_info_controller.ex index e5165e336..f9a09b7f8 100644 --- a/lib/web/controllers/node_info_controller.ex +++ b/lib/web/controllers/node_info_controller.ex @@ -9,9 +9,6 @@ defmodule Mobilizon.Web.NodeInfoController do alias Mobilizon.Config alias Mobilizon.Service.Statistics - alias Mobilizon.Web.Endpoint - alias Mobilizon.Web.Router.Helpers, as: Routes - @node_info_supported_versions ["2.0", "2.1"] @node_info_schema_uri "http://nodeinfo.diaspora.software/ns/schema/" @@ -22,7 +19,7 @@ defmodule Mobilizon.Web.NodeInfoController do |> Enum.map(fn version -> %{ rel: @node_info_schema_uri <> version, - href: Routes.node_info_url(Endpoint, :nodeinfo, version) + href: url(~p"/.well-known/nodeinfo/#{version}") } end) diff --git a/lib/web/controllers/page_controller.ex b/lib/web/controllers/page_controller.ex index dcb80f391..104097c20 100644 --- a/lib/web/controllers/page_controller.ex +++ b/lib/web/controllers/page_controller.ex @@ -26,6 +26,8 @@ defmodule Mobilizon.Web.PageController do defdelegate moderation_report(conn, params), to: PageController, as: :index @spec participation_email_confirmation(Plug.Conn.t(), any) :: Plug.Conn.t() defdelegate participation_email_confirmation(conn, params), to: PageController, as: :index + @spec participation_email_cancellation(Plug.Conn.t(), any) :: Plug.Conn.t() + defdelegate participation_email_cancellation(conn, params), to: PageController, as: :index @spec user_email_validation(Plug.Conn.t(), any) :: Plug.Conn.t() defdelegate user_email_validation(conn, params), to: PageController, as: :index @spec my_groups(Plug.Conn.t(), any) :: Plug.Conn.t() diff --git a/lib/web/email/participation.ex b/lib/web/email/participation.ex index 9a101d102..6ac606bb8 100644 --- a/lib/web/email/participation.ex +++ b/lib/web/email/participation.ex @@ -99,6 +99,7 @@ defmodule Mobilizon.Web.Email.Participation do locale: locale, event: event, jsonLDMetadata: json_ld(participant), + participant: participant, subject: subject }) end @@ -123,6 +124,7 @@ defmodule Mobilizon.Web.Email.Participation do locale: locale, event: event, jsonLDMetadata: json_ld(participant), + participant: participant, subject: subject }) end diff --git a/lib/web/router.ex b/lib/web/router.ex index c290d2683..9a1534e88 100644 --- a/lib/web/router.ex +++ b/lib/web/router.ex @@ -195,6 +195,12 @@ defmodule Mobilizon.Web.Router do get("/participation/email/confirm/:token", PageController, :participation_email_confirmation) + get( + "/participation/email/cancel/:uuid/:token", + PageController, + :participation_email_cancellation + ) + get("/validate/email/:token", PageController, :user_email_validation) get("/groups/me", PageController, :my_groups) diff --git a/lib/web/templates/email/activity/_comment_activity_item.html.heex b/lib/web/templates/email/activity/_comment_activity_item.html.heex index 8daa72140..169608daf 100644 --- a/lib/web/templates/email/activity/_comment_activity_item.html.heex +++ b/lib/web/templates/email/activity/_comment_activity_item.html.heex @@ -3,9 +3,7 @@ <%= dgettext("activity", "%{profile} mentionned you in a comment under event %{event}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", event: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["event_title"])} " }) @@ -14,9 +12,7 @@ <%= dgettext("activity", "%{profile} has posted an announcement under event %{event}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", event: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["event_title"])} " }) @@ -26,9 +22,7 @@ <%= dgettext("activity", "%{profile} has posted a new reply under your event %{event}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", event: - " URI.decode()}#comment-#{@activity.subject_params["comment_reply_to_uuid"]}-#{@activity.subject_params["comment_uuid"]}\"> + " url() |> URI.decode()}#comment-#{@activity.subject_params["comment_reply_to_uuid"]}-#{@activity.subject_params["comment_uuid"]}\"> #{escape_html(@activity.subject_params["event_title"])} " }) @@ -40,9 +34,7 @@ %{ profile: "#{escaped_display_name_and_username(@activity.author)}", event: - " URI.decode()}#comment-#{@activity.subject_params["comment_uuid"]}\"> + " url() |> URI.decode()}#comment-#{@activity.subject_params["comment_uuid"]}\"> #{escape_html(@activity.subject_params["event_title"])} " } diff --git a/lib/web/templates/email/activity/_comment_activity_item.text.eex b/lib/web/templates/email/activity/_comment_activity_item.text.eex index f097b2732..002ffe2c0 100644 --- a/lib/web/templates/email/activity/_comment_activity_item.text.eex +++ b/lib/web/templates/email/activity/_comment_activity_item.text.eex @@ -4,22 +4,22 @@ event: @activity.subject_params["event_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :event, @activity.subject_params["event_uuid"]) |> URI.decode() %><% :participation_event_comment -> %><%= dgettext("activity", "%{profile} has posted an announcement under event %{event}.", +<%= url(~p"/events/#{@activity.subject_params["event_uuid"]}") |> URI.decode() %><% :participation_event_comment -> %><%= dgettext("activity", "%{profile} has posted an announcement under event %{event}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), event: @activity.subject_params["event_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :event, @activity.subject_params["event_uuid"]) |> URI.decode() %><% :event_new_comment -> %><%= if @activity.subject_params["comment_reply_to"] do %><%=dgettext("activity", "%{profile} has posted a new reply under your event %{event}.", +<%= url(~p"/events/#{@activity.subject_params["event_uuid"]}") |> URI.decode() %><% :event_new_comment -> %><%= if @activity.subject_params["comment_reply_to"] do %><%=dgettext("activity", "%{profile} has posted a new reply under your event %{event}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), event: @activity.subject_params["event_title"] } ) %> -<%= "#{Routes.page_url(Mobilizon.Web.Endpoint, :event, @activity.subject_params["event_uuid"]) |> URI.decode()}#comment-#{@activity.subject_params["comment_reply_to_uuid"]}-#{@activity.subject_params["comment_uuid"]}" %><% else %><%= dgettext("activity", "%{profile} has posted a new comment under your event %{event}.", +<%= "#{url(~p"/events/#{@activity.subject_params["event_uuid"]}") |> URI.decode()}#comment-#{@activity.subject_params["comment_reply_to_uuid"]}-#{@activity.subject_params["comment_uuid"]}" %><% else %><%= dgettext("activity", "%{profile} has posted a new comment under your event %{event}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), event: @activity.subject_params["event_title"] } ) %> -<%= "#{Routes.page_url(Mobilizon.Web.Endpoint, :event, @activity.subject_params["event_uuid"]) |> URI.decode()}#comment-#{@activity.subject_params["comment_uuid"]}"%><% end %><% end %> \ No newline at end of file +<%= "#{url(~p"/events/#{@activity.subject_params["event_uuid"]}") |> URI.decode()}#comment-#{@activity.subject_params["comment_uuid"]}"%><% end %><% end %> \ No newline at end of file diff --git a/lib/web/templates/email/activity/_conversation_activity_item.html.heex b/lib/web/templates/email/activity/_conversation_activity_item.html.heex index f59b2140c..8debdd3db 100644 --- a/lib/web/templates/email/activity/_conversation_activity_item.html.heex +++ b/lib/web/templates/email/activity/_conversation_activity_item.html.heex @@ -3,18 +3,14 @@ <%= dgettext("activity", "%{profile} mentionned you in a %{conversation}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", conversation: - " URI.decode()}\">conversation" + " url() |> URI.decode()}\">conversation" }) |> raw %> <% :conversation_replied -> %> <%= dgettext("activity", "%{profile} replied you in a %{conversation}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", conversation: - " URI.decode()}\">conversation" + " url() |> URI.decode()}\">conversation" }) |> raw %> <% end %> diff --git a/lib/web/templates/email/activity/_conversation_activity_item.text.eex b/lib/web/templates/email/activity/_conversation_activity_item.text.eex index 7fe1f8b4d..291c15c9f 100644 --- a/lib/web/templates/email/activity/_conversation_activity_item.text.eex +++ b/lib/web/templates/email/activity/_conversation_activity_item.text.eex @@ -3,9 +3,9 @@ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :conversation, @activity.subject_params["conversation_participant_id"]) |> URI.decode() %><% :conversation_replied -> %><%= dgettext("activity", "%{profile} replied you in a conversation.", +<%= url(~p"/conversations/#{@activity.subject_params["conversation_participant_id"]}") |> URI.decode() %><% :conversation_replied -> %><%= dgettext("activity", "%{profile} replied you in a conversation.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :conversation, @activity.subject_params["conversation_participant_id"]) |> URI.decode() %><% end %> \ No newline at end of file +<%= url(~p"/conversations/#{@activity.subject_params["conversation_participant_id"]}") |> URI.decode() %><% end %> \ No newline at end of file diff --git a/lib/web/templates/email/activity/_discussion_activity_item.html.heex b/lib/web/templates/email/activity/_discussion_activity_item.html.heex index e5ba67bc4..ce02312c5 100644 --- a/lib/web/templates/email/activity/_discussion_activity_item.html.heex +++ b/lib/web/templates/email/activity/_discussion_activity_item.html.heex @@ -3,7 +3,7 @@ <%= dgettext("activity", "%{profile} created the discussion %{discussion}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", discussion: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["discussion_title"])}" }) |> raw %> @@ -11,7 +11,7 @@ <%= dgettext("activity", "%{profile} replied to the discussion %{discussion}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", discussion: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["discussion_title"])}" }) |> raw %> @@ -19,7 +19,7 @@ <%= dgettext("activity", "%{profile} renamed the discussion %{discussion}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", discussion: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["discussion_title"])}" }) |> raw %> @@ -27,7 +27,7 @@ <%= dgettext("activity", "%{profile} archived the discussion %{discussion}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", discussion: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["discussion_title"])}" }) |> raw %> diff --git a/lib/web/templates/email/activity/_discussion_activity_item.text.eex b/lib/web/templates/email/activity/_discussion_activity_item.text.eex index 97e676649..a5d56ae22 100644 --- a/lib/web/templates/email/activity/_discussion_activity_item.text.eex +++ b/lib/web/templates/email/activity/_discussion_activity_item.text.eex @@ -4,25 +4,25 @@ discussion: @activity.subject_params["discussion_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :discussion, Mobilizon.Actors.Actor.preferred_username_and_domain(@activity.group), @activity.subject_params["discussion_slug"]) |> URI.decode() %><% :discussion_replied -> %><%= dgettext("activity", "%{profile} replied to the discussion %{discussion}.", +<%= ~p"/#{Mobilizon.Actors.Actor.preferred_username_and_domain(@activity.group)}/c/#{@activity.subject_params["discussion_slug"]}" |> url() |> URI.decode() %><% :discussion_replied -> %><%= dgettext("activity", "%{profile} replied to the discussion %{discussion}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), discussion: @activity.subject_params["discussion_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :discussion, Mobilizon.Actors.Actor.preferred_username_and_domain(@activity.group), @activity.subject_params["discussion_slug"]) |> URI.decode() %><% :discussion_renamed -> %><%= dgettext("activity", "%{profile} renamed the discussion %{discussion}.", +<%= ~p"/#{Mobilizon.Actors.Actor.preferred_username_and_domain(@activity.group)}/c/#{@activity.subject_params["discussion_slug"]}" |> url() |> URI.decode() %><% :discussion_renamed -> %><%= dgettext("activity", "%{profile} renamed the discussion %{discussion}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), discussion: @activity.subject_params["discussion_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :discussion, Mobilizon.Actors.Actor.preferred_username_and_domain(@activity.group), @activity.subject_params["discussion_slug"]) |> URI.decode() %><% :discussion_archived -> %><%= dgettext("activity", "%{profile} archived the discussion %{discussion}.", +<%= ~p"/#{Mobilizon.Actors.Actor.preferred_username_and_domain(@activity.group)}/c/#{@activity.subject_params["discussion_slug"]}" |> url() |> URI.decode() %><% :discussion_archived -> %><%= dgettext("activity", "%{profile} archived the discussion %{discussion}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), discussion: @activity.subject_params["discussion_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :discussion, Mobilizon.Actors.Actor.preferred_username_and_domain(@activity.group), @activity.subject_params["discussion_slug"]) |> URI.decode() %><% :discussion_deleted -> %><%= dgettext("activity", "%{profile} deleted the discussion %{discussion}.", +<%= ~p"/#{Mobilizon.Actors.Actor.preferred_username_and_domain(@activity.group)}/c/#{@activity.subject_params["discussion_slug"]}" |> url() |> URI.decode() %><% :discussion_deleted -> %><%= dgettext("activity", "%{profile} deleted the discussion %{discussion}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), discussion: @activity.subject_params["discussion_title"] diff --git a/lib/web/templates/email/activity/_event_activity_item.html.heex b/lib/web/templates/email/activity/_event_activity_item.html.heex index 0497d658d..8d8ba1ae8 100644 --- a/lib/web/templates/email/activity/_event_activity_item.html.heex +++ b/lib/web/templates/email/activity/_event_activity_item.html.heex @@ -3,9 +3,7 @@ <%= dgettext("activity", "The event %{event} was created by %{profile}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", event: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["event_title"])} " }) @@ -14,9 +12,7 @@ <%= dgettext("activity", "The event %{event} was updated by %{profile}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", event: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["event_title"])} " }) @@ -32,9 +28,7 @@ <%= dgettext("activity", "%{profile} replied to a comment on the event %{event}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", event: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["event_title"])} " }) @@ -43,9 +37,7 @@ <%= dgettext("activity", "%{profile} posted a comment on the event %{event}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", event: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["event_title"])} " }) @@ -55,9 +47,7 @@ <%= dgettext("activity", "%{profile} joined your event %{event}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", event: - " URI.decode()}\">#{escape_html(@activity.subject_params["event_title"])}" + " url() |> URI.decode()}\">#{escape_html(@activity.subject_params["event_title"])}" }) |> raw %> <% end %> diff --git a/lib/web/templates/email/activity/_event_activity_item.text.eex b/lib/web/templates/email/activity/_event_activity_item.text.eex index 30b05abc0..e5183f0ce 100644 --- a/lib/web/templates/email/activity/_event_activity_item.text.eex +++ b/lib/web/templates/email/activity/_event_activity_item.text.eex @@ -4,13 +4,13 @@ event: @activity.subject_params["event_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :event, @activity.subject_params["event_uuid"]) |> URI.decode() %><% :event_updated -> %><%= dgettext("activity", "The event %{event} was updated by %{profile}.", +<%= url(~p"/events/#{@activity.subject_params["event_uuid"]}") |> URI.decode() %><% :event_updated -> %><%= dgettext("activity", "The event %{event} was updated by %{profile}.", %{ profile: display_name_and_username(@activity.author), event: @activity.subject_params["event_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :event, @activity.subject_params["event_uuid"]) |> URI.decode() %><% :event_deleted -> %><%= dgettext("activity", "The event %{event} was deleted by %{profile}.", +<%= url(~p"/events/#{@activity.subject_params["event_uuid"]}") |> URI.decode() %><% :event_deleted -> %><%= dgettext("activity", "The event %{event} was deleted by %{profile}.", %{ profile: display_name_and_username(@activity.author), event: @activity.subject_params["event_title"] @@ -22,16 +22,16 @@ event: @activity.subject_params["event_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :event, @activity.subject_params["event_uuid"]) |> URI.decode() %><% else %><%= dgettext("activity", "%{profile} posted a comment on the event %{event}.", +<%= url(~p"/events/#{@activity.subject_params["event_uuid"]}") |> URI.decode() %><% else %><%= dgettext("activity", "%{profile} posted a comment on the event %{event}.", %{ profile: display_name_and_username(@activity.author), event: @activity.subject_params["event_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :event, @activity.subject_params["event_uuid"]) |> URI.decode() %><% end %><% :event_new_participation -> %><%= dgettext("activity", "%{profile} joined your event %{event}.", +<%= url(~p"/events/#{@activity.subject_params["event_uuid"]}") |> URI.decode() %><% end %><% :event_new_participation -> %><%= dgettext("activity", "%{profile} joined your event %{event}.", %{ profile: display_name_and_username(@activity.author), event: @activity.subject_params["event_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :event, @activity.subject_params["event_uuid"]) |> URI.decode() %><% end %> \ No newline at end of file +<%= url(~p"/events/#{@activity.subject_params["event_uuid"]}") |> URI.decode() %><% end %> \ No newline at end of file diff --git a/lib/web/templates/email/activity/_group_activity_item.html.heex b/lib/web/templates/email/activity/_group_activity_item.html.heex index 36ad49b16..bfd8b2b6b 100644 --- a/lib/web/templates/email/activity/_group_activity_item.html.heex +++ b/lib/web/templates/email/activity/_group_activity_item.html.heex @@ -3,9 +3,7 @@ <%= dgettext("activity", "%{profile} created the group %{group}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", group: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["group_name"])} " }) @@ -14,9 +12,7 @@ <%= dgettext("activity", "%{profile} updated the group %{group}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", group: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["group_name"])} " }) diff --git a/lib/web/templates/email/activity/_group_activity_item.text.eex b/lib/web/templates/email/activity/_group_activity_item.text.eex index 48308f74b..b414c3bd8 100644 --- a/lib/web/templates/email/activity/_group_activity_item.text.eex +++ b/lib/web/templates/email/activity/_group_activity_item.text.eex @@ -4,10 +4,10 @@ group: @activity.subject_params["group_name"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :actor, @activity.subject_params["group_federated_username"]) |> URI.decode() %><% :group_updated -> %><%= dgettext("activity", "%{profile} updated the group %{group}.", +<%= ~p"/@#{@activity.subject_params["group_federated_username"]}" |> url() |> URI.decode() %><% :group_updated -> %><%= dgettext("activity", "%{profile} updated the group %{group}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), group: @activity.subject_params["group_name"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :actor, @activity.subject_params["group_federated_username"]) |> URI.decode() %><% end %> \ No newline at end of file +<%= ~p"/@#{@activity.subject_params["group_federated_username"]}" |> url() |> URI.decode() %><% end %> \ No newline at end of file diff --git a/lib/web/templates/email/activity/_post_activity_item.html.heex b/lib/web/templates/email/activity/_post_activity_item.html.heex index 52c03e781..83a80b1bb 100644 --- a/lib/web/templates/email/activity/_post_activity_item.html.heex +++ b/lib/web/templates/email/activity/_post_activity_item.html.heex @@ -3,9 +3,7 @@ <%= dgettext("activity", "The post %{post} was created by %{profile}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", post: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["post_title"])} " }) @@ -14,9 +12,7 @@ <%= dgettext("activity", "The post %{post} was updated by %{profile}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", post: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["post_title"])} " }) diff --git a/lib/web/templates/email/activity/_post_activity_item.text.eex b/lib/web/templates/email/activity/_post_activity_item.text.eex index ee9c37c9b..8bafea653 100644 --- a/lib/web/templates/email/activity/_post_activity_item.text.eex +++ b/lib/web/templates/email/activity/_post_activity_item.text.eex @@ -4,13 +4,13 @@ post: @activity.subject_params["post_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :post, @activity.subject_params["post_slug"]) |> URI.decode() %><% :post_updated -> %><%= dgettext("activity", "The post %{post} was updated by %{profile}.", +<%= url(~p"/p/#{@activity.subject_params["post_slug"]}") |> URI.decode() %><% :post_updated -> %><%= dgettext("activity", "The post %{post} was updated by %{profile}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), post: @activity.subject_params["post_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :post, @activity.subject_params["post_slug"]) |> URI.decode() %><% :post_deleted -> %><%= dgettext("activity", "The post %{post} was deleted by %{profile}.", +<%= url(~p"/p/#{@activity.subject_params["post_slug"]}") |> URI.decode() %><% :post_deleted -> %><%= dgettext("activity", "The post %{post} was deleted by %{profile}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), post: @activity.subject_params["post_title"] diff --git a/lib/web/templates/email/activity/_resource_activity_item.html.heex b/lib/web/templates/email/activity/_resource_activity_item.html.heex index 67745aed6..b4300eabc 100644 --- a/lib/web/templates/email/activity/_resource_activity_item.html.heex +++ b/lib/web/templates/email/activity/_resource_activity_item.html.heex @@ -4,9 +4,7 @@ <%= dgettext("activity", "%{profile} created the folder %{resource}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", resource: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["resource_title"])} " }) @@ -15,9 +13,7 @@ <%= dgettext("activity", "%{profile} created the resource %{resource}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", resource: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["resource_title"])} " }) @@ -31,9 +27,7 @@ %{ profile: "#{escaped_display_name_and_username(@activity.author)}", resource: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["resource_title"])} ", old_resource_title: @@ -48,9 +42,7 @@ %{ profile: "#{escaped_display_name_and_username(@activity.author)}", resource: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["resource_title"])} ", old_resource_title: @@ -64,9 +56,7 @@ <%= dgettext("activity", "%{profile} moved the folder %{resource}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", resource: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["resource_title"])} " }) @@ -75,9 +65,7 @@ <%= dgettext("activity", "%{profile} moved the resource %{resource}.", %{ profile: "#{escaped_display_name_and_username(@activity.author)}", resource: - " URI.decode()}\"> + " url() |> URI.decode()}\"> #{escape_html(@activity.subject_params["resource_title"])} " }) diff --git a/lib/web/templates/email/activity/_resource_activity_item.text.eex b/lib/web/templates/email/activity/_resource_activity_item.text.eex index bd9ded7ab..1a8a59356 100644 --- a/lib/web/templates/email/activity/_resource_activity_item.text.eex +++ b/lib/web/templates/email/activity/_resource_activity_item.text.eex @@ -5,39 +5,39 @@ resource: @activity.subject_params["resource_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :resource, @activity.subject_params["resource_uuid"]) |> URI.decode() %><% else %><%= dgettext("activity", "%{profile} created the resource %{resource}.", +<%= url(~p"/resource/#{@activity.subject_params["resource_uuid"]}") |> URI.decode() %><% else %><%= dgettext("activity", "%{profile} created the resource %{resource}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), resource: @activity.subject_params["resource_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :resource, @activity.subject_params["resource_uuid"]) |> URI.decode() %><% end %><% :resource_renamed -> %><%= if @activity.subject_params["is_folder"] do %><%= dgettext("activity", "%{profile} renamed the folder from %{old_resource_title} to %{resource}.", +<%= url(~p"/resource/#{@activity.subject_params["resource_uuid"]}") |> URI.decode() %><% end %><% :resource_renamed -> %><%= if @activity.subject_params["is_folder"] do %><%= dgettext("activity", "%{profile} renamed the folder from %{old_resource_title} to %{resource}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), resource: @activity.subject_params["resource_title"], old_resource_title: @activity.subject_params["old_resource_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :resource, @activity.subject_params["resource_uuid"]) |> URI.decode() %><% else %><%= dgettext("activity", "%{profile} renamed the resource from %{old_resource_title} to %{resource}.", +<%= url(~p"/resource/#{@activity.subject_params["resource_uuid"]}") |> URI.decode() %><% else %><%= dgettext("activity", "%{profile} renamed the resource from %{old_resource_title} to %{resource}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), resource: @activity.subject_params["resource_title"], old_resource_title: @activity.subject_params["old_resource_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :resource, @activity.subject_params["resource_uuid"]) |> URI.decode() %><% end %><% :resource_moved -> %><%= if @activity.subject_params["is_folder"] do %><%= dgettext("activity", "%{profile} moved the folder %{resource}.", +<%= url(~p"/resource/#{@activity.subject_params["resource_uuid"]}") |> URI.decode() %><% end %><% :resource_moved -> %><%= if @activity.subject_params["is_folder"] do %><%= dgettext("activity", "%{profile} moved the folder %{resource}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), resource: @activity.subject_params["resource_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :resource, @activity.subject_params["resource_uuid"]) |> URI.decode() %><% else %><%= dgettext("activity", "%{profile} moved the resource %{resource}.", +<%= url(~p"/resource/#{@activity.subject_params["resource_uuid"]}") |> URI.decode() %><% else %><%= dgettext("activity", "%{profile} moved the resource %{resource}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), resource: @activity.subject_params["resource_title"] } ) %> -<%= Routes.page_url(Mobilizon.Web.Endpoint, :resource, @activity.subject_params["resource_uuid"]) |> URI.decode() %><% end %><% :resource_deleted -> %><%= if @activity.subject_params["is_folder"] do %><%= dgettext("activity", "%{profile} deleted the folder %{resource}.", +<%= url(~p"/resource/#{@activity.subject_params["resource_uuid"]}") |> URI.decode() %><% end %><% :resource_deleted -> %><%= if @activity.subject_params["is_folder"] do %><%= dgettext("activity", "%{profile} deleted the folder %{resource}.", %{ profile: Mobilizon.Actors.Actor.display_name_and_username(@activity.author), resource: @activity.subject_params["resource_title"] diff --git a/lib/web/templates/email/anonymous_participation_confirmation.html.heex b/lib/web/templates/email/anonymous_participation_confirmation.html.heex index 56c20f57b..50f4f9e8e 100644 --- a/lib/web/templates/email/anonymous_participation_confirmation.html.heex +++ b/lib/web/templates/email/anonymous_participation_confirmation.html.heex @@ -63,7 +63,9 @@
- <%= ngettext( - "Would you wish to cancel your attendance, visit the event page through the link above and click the « Attending » button.", - "Would you wish to cancel your attendance to one or several events, visit the event pages through the links above and click the « Attending » button.", - 1 + <%= gettext( + "If you wish to cancel your participation, simply click on the link below." ) %>
- <%= gettext( - "Would you wish to update or cancel your attendance, simply access the event page through the link above and click on the Attending button." - ) %> -
-+ <%= gettext( + "If you wish to cancel your participation, simply click on the link below." + ) %> +
+
+
|
+
+ <%= gettext( + "Would you wish to update or cancel your attendance, simply access the event page through the link above and click on the Attending button." + ) %> +
+