forked from AkkomaGang/akkoma
Merge branch 'feature/push-subject-for-dm' into 'develop'
Direct messages should provide a distinct push notification subject See merge request pleroma/pleroma!1864
This commit is contained in:
commit
6281e4795a
2 changed files with 34 additions and 5 deletions
|
@ -125,6 +125,10 @@ def format_body(
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_title(%{activity: %{data: %{"directMessage" => true}}}) do
|
||||||
|
"New Direct Message"
|
||||||
|
end
|
||||||
|
|
||||||
def format_title(%{activity: %{data: %{"type" => type}}}) do
|
def format_title(%{activity: %{data: %{"type" => type}}}) do
|
||||||
case type do
|
case type do
|
||||||
"Create" -> "New Mention"
|
"Create" -> "New Mention"
|
||||||
|
|
|
@ -84,7 +84,7 @@ test "fail message sending" do
|
||||||
) == :error
|
) == :error
|
||||||
end
|
end
|
||||||
|
|
||||||
test "delete subsciption if restult send message between 400..500" do
|
test "delete subscription if result send message between 400..500" do
|
||||||
subscription = insert(:push_subscription)
|
subscription = insert(:push_subscription)
|
||||||
|
|
||||||
assert Impl.push_message(
|
assert Impl.push_message(
|
||||||
|
@ -97,7 +97,7 @@ test "delete subsciption if restult send message between 400..500" do
|
||||||
refute Pleroma.Repo.get(Subscription, subscription.id)
|
refute Pleroma.Repo.get(Subscription, subscription.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders body for create activity" do
|
test "renders title and body for create activity" do
|
||||||
user = insert(:user, nickname: "Bob")
|
user = insert(:user, nickname: "Bob")
|
||||||
|
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
|
@ -116,18 +116,24 @@ test "renders body for create activity" do
|
||||||
object
|
object
|
||||||
) ==
|
) ==
|
||||||
"@Bob: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
|
"@Bob: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
|
||||||
|
|
||||||
|
assert Impl.format_title(%{activity: activity}) ==
|
||||||
|
"New Mention"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders body for follow activity" do
|
test "renders title and body for follow activity" do
|
||||||
user = insert(:user, nickname: "Bob")
|
user = insert(:user, nickname: "Bob")
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
{:ok, _, _, activity} = CommonAPI.follow(user, other_user)
|
{:ok, _, _, activity} = CommonAPI.follow(user, other_user)
|
||||||
object = Object.normalize(activity)
|
object = Object.normalize(activity)
|
||||||
|
|
||||||
assert Impl.format_body(%{activity: activity}, user, object) == "@Bob has followed you"
|
assert Impl.format_body(%{activity: activity}, user, object) == "@Bob has followed you"
|
||||||
|
|
||||||
|
assert Impl.format_title(%{activity: activity}) ==
|
||||||
|
"New Follower"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders body for announce activity" do
|
test "renders title and body for announce activity" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
|
@ -141,9 +147,12 @@ test "renders body for announce activity" do
|
||||||
|
|
||||||
assert Impl.format_body(%{activity: announce_activity}, user, object) ==
|
assert Impl.format_body(%{activity: announce_activity}, user, object) ==
|
||||||
"@#{user.nickname} repeated: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
|
"@#{user.nickname} repeated: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
|
||||||
|
|
||||||
|
assert Impl.format_title(%{activity: announce_activity}) ==
|
||||||
|
"New Repeat"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders body for like activity" do
|
test "renders title and body for like activity" do
|
||||||
user = insert(:user, nickname: "Bob")
|
user = insert(:user, nickname: "Bob")
|
||||||
|
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
|
@ -156,5 +165,21 @@ test "renders body for like activity" do
|
||||||
object = Object.normalize(activity)
|
object = Object.normalize(activity)
|
||||||
|
|
||||||
assert Impl.format_body(%{activity: activity}, user, object) == "@Bob has favorited your post"
|
assert Impl.format_body(%{activity: activity}, user, object) == "@Bob has favorited your post"
|
||||||
|
|
||||||
|
assert Impl.format_title(%{activity: activity}) ==
|
||||||
|
"New Favorite"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "renders title for create activity with direct visibility" do
|
||||||
|
user = insert(:user, nickname: "Bob")
|
||||||
|
|
||||||
|
{:ok, activity} =
|
||||||
|
CommonAPI.post(user, %{
|
||||||
|
"visibility" => "direct",
|
||||||
|
"status" => "This is just between you and me, pal"
|
||||||
|
})
|
||||||
|
|
||||||
|
assert Impl.format_title(%{activity: activity}) ==
|
||||||
|
"New Direct Message"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue