Add missing group name to activity notifications
Closes #799 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -17,65 +17,91 @@ defmodule Mobilizon.Service.Activity.Renderer.Discussion do
|
||||
Gettext.put_locale(locale)
|
||||
profile = profile(activity)
|
||||
title = title(activity)
|
||||
group = group(activity)
|
||||
|
||||
case activity.subject do
|
||||
:discussion_created ->
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} created the discussion %{discussion}.", %{
|
||||
profile: profile,
|
||||
discussion: title
|
||||
}),
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} created the discussion %{discussion} in group {group}.",
|
||||
%{
|
||||
profile: profile,
|
||||
discussion: title,
|
||||
group: group
|
||||
}
|
||||
),
|
||||
url: discussion_url(activity)
|
||||
}
|
||||
|
||||
:discussion_replied ->
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} replied to the discussion %{discussion}.", %{
|
||||
profile: profile,
|
||||
discussion: title
|
||||
}),
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} replied to the discussion %{discussion} in group {group}.",
|
||||
%{
|
||||
profile: profile,
|
||||
discussion: title
|
||||
}
|
||||
),
|
||||
url: discussion_url(activity)
|
||||
}
|
||||
|
||||
:discussion_mention ->
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} mentionned you in the discussion %{discussion}.", %{
|
||||
profile: profile,
|
||||
discussion: title
|
||||
}),
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} mentionned you in the discussion %{discussion} in group {group}.",
|
||||
%{
|
||||
profile: profile,
|
||||
discussion: title
|
||||
}
|
||||
),
|
||||
url: discussion_url(activity)
|
||||
}
|
||||
|
||||
:discussion_renamed ->
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} renamed the discussion %{discussion}.", %{
|
||||
profile: profile,
|
||||
discussion: title
|
||||
}),
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} renamed the discussion %{discussion} in group {group}.",
|
||||
%{
|
||||
profile: profile,
|
||||
discussion: title
|
||||
}
|
||||
),
|
||||
url: discussion_url(activity)
|
||||
}
|
||||
|
||||
:discussion_archived ->
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} archived the discussion %{discussion}.", %{
|
||||
profile: profile,
|
||||
discussion: title
|
||||
}),
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} archived the discussion %{discussion} in group {group}.",
|
||||
%{
|
||||
profile: profile,
|
||||
discussion: title
|
||||
}
|
||||
),
|
||||
url: discussion_url(activity)
|
||||
}
|
||||
|
||||
:discussion_deleted ->
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} deleted the discussion %{discussion}.", %{
|
||||
profile: profile,
|
||||
discussion: title
|
||||
}),
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} deleted the discussion %{discussion} in group {group}.",
|
||||
%{
|
||||
profile: profile,
|
||||
discussion: title
|
||||
}
|
||||
),
|
||||
url: nil
|
||||
}
|
||||
end
|
||||
@@ -91,8 +117,10 @@ defmodule Mobilizon.Service.Activity.Renderer.Discussion do
|
||||
|> URI.decode()
|
||||
end
|
||||
|
||||
defp profile(%Activity{author: author}), do: Actor.display_name_and_username(author)
|
||||
defp profile(%Activity{author: author}), do: Actor.display_name(author)
|
||||
|
||||
defp title(%Activity{subject_params: %{"discussion_title" => discussion_title}}),
|
||||
do: discussion_title
|
||||
|
||||
defp group(%Activity{group: group}), do: Actor.display_name(group)
|
||||
end
|
||||
|
||||
@@ -20,54 +20,63 @@ defmodule Mobilizon.Service.Activity.Renderer.Member do
|
||||
body:
|
||||
text(activity.subject, %{
|
||||
profile: profile(activity),
|
||||
member: member(activity)
|
||||
member: member(activity),
|
||||
group: group(activity)
|
||||
}),
|
||||
url: member_url(activity)
|
||||
}
|
||||
end
|
||||
|
||||
defp text(:member_request, args) do
|
||||
dgettext("activity", "%{member} requested to join the group.", args)
|
||||
dgettext("activity", "%{member} requested to join the group %{group}.", args)
|
||||
end
|
||||
|
||||
defp text(:member_invited, args) do
|
||||
dgettext("activity", "%{member} was invited by %{profile}.", args)
|
||||
dgettext("activity", "%{member} was invited by %{profile} to group %{group}.", args)
|
||||
end
|
||||
|
||||
defp text(:member_accepted_invitation, args) do
|
||||
dgettext("activity", "%{member} accepted the invitation to join the group.", args)
|
||||
dgettext("activity", "%{member} accepted the invitation to join the group %{group}.", args)
|
||||
end
|
||||
|
||||
defp text(:member_rejected_invitation, args) do
|
||||
dgettext("activity", "%{member} rejected the invitation to join the group.", args)
|
||||
dgettext("activity", "%{member} rejected the invitation to join the group %{group}.", args)
|
||||
end
|
||||
|
||||
defp text(:member_joined, args) do
|
||||
dgettext("activity", "%{member} joined the group.", args)
|
||||
dgettext("activity", "%{member} joined the group %{group}.", args)
|
||||
end
|
||||
|
||||
defp text(:member_added, args) do
|
||||
dgettext("activity", "%{profile} added the member %{member}.", args)
|
||||
dgettext("activity", "%{profile} added the member %{member} to group %{group}.", args)
|
||||
end
|
||||
|
||||
defp text(:member_approved, args) do
|
||||
dgettext("activity", "%{profile} approved the membership request from %{member}.", args)
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} approved the membership request from %{member} for group %{group}.",
|
||||
args
|
||||
)
|
||||
end
|
||||
|
||||
defp text(:member_rejected, args) do
|
||||
dgettext("activity", "%{profile} rejected the membership request from %{member}.", args)
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} rejected the membership request from %{member} for group %{group}.",
|
||||
args
|
||||
)
|
||||
end
|
||||
|
||||
defp text(:member_updated, args) do
|
||||
dgettext("activity", "%{profile} updated the member %{member}.", args)
|
||||
dgettext("activity", "%{profile} updated the member %{member} in group %{group}.", args)
|
||||
end
|
||||
|
||||
defp text(:member_removed, args) do
|
||||
dgettext("activity", "%{profile} excluded member %{member}.", args)
|
||||
dgettext("activity", "%{profile} excluded member %{member} from the group %{group}.", args)
|
||||
end
|
||||
|
||||
defp text(:member_quit, args) do
|
||||
dgettext("activity", "%{profile} quit the group.", args)
|
||||
dgettext("activity", "%{profile} quit the group %{group}.", args)
|
||||
end
|
||||
|
||||
defp member_url(activity) do
|
||||
@@ -88,4 +97,6 @@ defmodule Mobilizon.Service.Activity.Renderer.Member do
|
||||
do:
|
||||
activity.subject_params["member_actor_name"] ||
|
||||
activity.subject_params["member_actor_federated_username"]
|
||||
|
||||
defp group(%Activity{group: group}), do: Actor.display_name(group)
|
||||
end
|
||||
|
||||
@@ -16,100 +16,59 @@ defmodule Mobilizon.Service.Activity.Renderer.Resource do
|
||||
locale = Keyword.get(options, :locale, "en")
|
||||
Gettext.put_locale(locale)
|
||||
|
||||
case activity.subject do
|
||||
:resource_created ->
|
||||
if activity.subject_params["is_folder"] do
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} created the folder %{resource}.", %{
|
||||
profile: profile(activity),
|
||||
resource: title(activity)
|
||||
}),
|
||||
url: resource_url(activity)
|
||||
}
|
||||
else
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} created the resource %{resource}.", %{
|
||||
profile: profile(activity),
|
||||
resource: title(activity)
|
||||
}),
|
||||
url: resource_url(activity)
|
||||
}
|
||||
end
|
||||
%{
|
||||
body:
|
||||
text(activity.subject, %{
|
||||
profile: profile(activity),
|
||||
resource: title(activity),
|
||||
group: group(activity),
|
||||
subject_params: activity.subject_params
|
||||
}),
|
||||
resource_url: resource_url(activity)
|
||||
}
|
||||
end
|
||||
|
||||
:resource_renamed ->
|
||||
if activity.subject_params["is_folder"] do
|
||||
%{
|
||||
body:
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} renamed the folder from %{old_resource_title} to %{resource}.",
|
||||
%{
|
||||
profile: profile(activity),
|
||||
resource: title(activity),
|
||||
old_resource_title: activity.subject_params["old_resource_title"]
|
||||
}
|
||||
),
|
||||
url: resource_url(activity)
|
||||
}
|
||||
else
|
||||
%{
|
||||
body:
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} renamed the resource from %{old_resource_title} to %{resource}.",
|
||||
%{
|
||||
profile: profile(activity),
|
||||
resource: title(activity),
|
||||
old_resource_title: activity.subject_params["old_resource_title"]
|
||||
}
|
||||
),
|
||||
url: resource_url(activity)
|
||||
}
|
||||
end
|
||||
defp text(:resource_created, %{subject_params: subject_params} = args) do
|
||||
if subject_params["is_folder"] do
|
||||
dgettext("activity", "%{profile} created the folder %{resource} in group %{group}.", args)
|
||||
else
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} created the resource %{resource} in group %{group}.",
|
||||
args
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
:resource_moved ->
|
||||
if activity.subject_params["is_folder"] do
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} moved the folder %{resource}.", %{
|
||||
profile: profile(activity),
|
||||
resource: title(activity)
|
||||
}),
|
||||
url: resource_url(activity)
|
||||
}
|
||||
else
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} moved the resource %{resource}.", %{
|
||||
profile: profile(activity),
|
||||
resource: title(activity)
|
||||
}),
|
||||
url: resource_url(activity)
|
||||
}
|
||||
end
|
||||
defp text(:resource_renamed, %{subject_params: subject_params} = args) do
|
||||
if subject_params["is_folder"] do
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} renamed the folder from %{old_resource_title} to %{resource} in group %{group}.",
|
||||
Map.put(args, :old_resource_title, subject_params["old_resource_title"])
|
||||
)
|
||||
else
|
||||
dgettext(
|
||||
"activity",
|
||||
"%{profile} renamed the resource from %{old_resource_title} to %{resource} in group %{group}.",
|
||||
Map.put(args, :old_resource_title, subject_params["old_resource_title"])
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
:resource_deleted ->
|
||||
if activity.subject_params["is_folder"] do
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} deleted the folder %{resource}.", %{
|
||||
profile: profile(activity),
|
||||
resource: title(activity)
|
||||
}),
|
||||
url: resource_url(activity)
|
||||
}
|
||||
else
|
||||
%{
|
||||
body:
|
||||
dgettext("activity", "%{profile} deleted the resource %{resource}.", %{
|
||||
profile: profile(activity),
|
||||
resource: title(activity)
|
||||
}),
|
||||
url: resource_url(activity)
|
||||
}
|
||||
end
|
||||
defp text(:resource_moved, %{subject_params: subject_params} = args) do
|
||||
if subject_params["is_folder"] do
|
||||
dgettext("activity", "%{profile} moved the folder %{resource} in group %{group}.", args)
|
||||
else
|
||||
dgettext("activity", "%{profile} moved the resource %{resource} in group %{group}.", args)
|
||||
end
|
||||
end
|
||||
|
||||
defp text(:resource_deleted, %{subject_params: subject_params} = args) do
|
||||
if subject_params["is_folder"] do
|
||||
dgettext("activity", "%{profile} deleted the folder %{resource} in group %{group}.", args)
|
||||
else
|
||||
dgettext("activity", "%{profile} deleted the resource %{resource} in group %{group}.", args)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -121,4 +80,5 @@ defmodule Mobilizon.Service.Activity.Renderer.Resource do
|
||||
|
||||
defp profile(activity), do: Actor.display_name_and_username(activity.author)
|
||||
defp title(activity), do: activity.subject_params["resource_title"]
|
||||
defp group(%Activity{group: group}), do: Actor.display_name(group)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user