Add webpush front-end support

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-05-06 18:39:59 +02:00
parent 8c6b0003bc
commit 938f698b7a
99 changed files with 2594 additions and 1536 deletions

View File

@@ -0,0 +1,58 @@
defmodule Mobilizon.Service.Activity.Renderer.Group do
@moduledoc """
Insert a comment activity
"""
alias Mobilizon.Activities.Activity
alias Mobilizon.Actors.Actor
alias Mobilizon.Service.Activity.Renderer
alias Mobilizon.Web.{Endpoint, Gettext}
alias Mobilizon.Web.Router.Helpers, as: Routes
import Mobilizon.Web.Gettext, only: [dgettext: 3]
@behaviour Renderer
@impl Renderer
def render(%Activity{} = activity, options) do
locale = Keyword.get(options, :locale, "en")
Gettext.put_locale(locale)
case activity.subject do
:post_created ->
%{
body:
dgettext("activity", "The post %{post} was created by %{profile}.", %{
profile: profile(activity),
post: title(activity)
}),
url: post_url(activity)
}
:post_updated ->
%{
body:
dgettext("activity", "The post %{post} was updated by %{profile}.", %{
profile: profile(activity),
post: title(activity)
}),
url: post_url(activity)
}
:post_deleted ->
%{
body:
dgettext("activity", "The post %{post} was deleted by %{profile}.", %{
profile: profile(activity),
post: title(activity)
}),
url: post_url(activity)
}
end
end
defp post_url(activity) do
Routes.page_url(Endpoint, :post, activity.subject_params["post_slug"])
end
defp profile(activity), do: Actor.display_name_and_username(activity.author)
defp title(activity), do: activity.subject_params["post_title"]
end