From 704960b3c135d2e050308c68f5ccf5d7b7df40f8 Mon Sep 17 00:00:00 2001
From: Mike Verdone
Date: Mon, 22 Jul 2019 16:46:20 +0200
Subject: Add support for activity expiration to common and Masto API
The "expires_at" parameter accepts an ISO8601-formatted date which
defines when the activity will expire.
At this point the API will not give you any feedback about if your post
will expire or not.
---
test/web/common_api/common_api_test.exs | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
(limited to 'test/web/common_api')
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index 16b3f121d..210314a4a 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -160,6 +160,23 @@ defmodule Pleroma.Web.CommonAPITest do
Pleroma.Config.put([:instance, :limit], limit)
end
+
+ test "it can handle activities that expire" do
+ user = insert(:user)
+
+ expires_at =
+ NaiveDateTime.utc_now()
+ |> NaiveDateTime.truncate(:second)
+ |> NaiveDateTime.add(1_000_000, :second)
+
+ expires_at_iso8601 = expires_at |> NaiveDateTime.to_iso8601()
+
+ assert {:ok, activity} =
+ CommonAPI.post(user, %{"status" => "chai", "expires_at" => expires_at_iso8601})
+
+ assert expiration = Pleroma.ActivityExpiration.get_by_activity_id(activity.id)
+ assert expiration.scheduled_at == expires_at
+ end
end
describe "reactions" do
--
cgit v1.2.3
From efb8818e9ee280b53eac17699e8114e8af82b03b Mon Sep 17 00:00:00 2001
From: lain
Date: Sat, 24 Aug 2019 17:22:48 +0200
Subject: Activity Expiration: Switch to 'expires_in' system.
---
test/web/common_api/common_api_test.exs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
(limited to 'test/web/common_api')
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index 5fda91438..f28a66090 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -213,10 +213,8 @@ defmodule Pleroma.Web.CommonAPITest do
|> NaiveDateTime.truncate(:second)
|> NaiveDateTime.add(1_000_000, :second)
- expires_at_iso8601 = expires_at |> NaiveDateTime.to_iso8601()
-
assert {:ok, activity} =
- CommonAPI.post(user, %{"status" => "chai", "expires_at" => expires_at_iso8601})
+ CommonAPI.post(user, %{"status" => "chai", "expires_in" => 1_000_000})
assert expiration = Pleroma.ActivityExpiration.get_by_activity_id(activity.id)
assert expiration.scheduled_at == expires_at
--
cgit v1.2.3
From 447514dfa2759e3415399412e82bf772ff119e04 Mon Sep 17 00:00:00 2001
From: "Haelwenn (lanodan) Monnier"
Date: Wed, 18 Sep 2019 23:20:54 +0200
Subject: Bump copyright years of files changed in 2019
Done via the following command:
git diff 1e6c102bfcfe0e4835a48f2483f2376f9bf86a20 --stat --name-only | cat - | xargs sed -i 's/2017-2018 Pleroma Authors/2017-2019 Pleroma Authors/'
---
test/web/common_api/common_api_utils_test.exs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'test/web/common_api')
diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs
index c281dd1f1..230146451 100644
--- a/test/web/common_api/common_api_utils_test.exs
+++ b/test/web/common_api/common_api_utils_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.CommonAPI.UtilsTest do
--
cgit v1.2.3
From cf3041220a7a14dc3fac24177fac1f4aecc77f5f Mon Sep 17 00:00:00 2001
From: Egor Kislitsyn
Date: Tue, 17 Sep 2019 15:22:46 +0700
Subject: Add support for `rel="ugc"`
---
test/web/common_api/common_api_utils_test.exs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'test/web/common_api')
diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs
index 230146451..78cfe3c5f 100644
--- a/test/web/common_api/common_api_utils_test.exs
+++ b/test/web/common_api/common_api_utils_test.exs
@@ -157,11 +157,11 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
text = "**hello world**\n\n*another @user__test and @user__test google.com paragraph*"
expected =
- "hello world
\nanother hello world
\nanother @user__test and @user__test and @user__test google.com paragraph
\n"
+ }" class="u-url mention" href="http://foo.com/user__test">@user__test google.com paragraph
\n)
{output, _, _} = Utils.format_input(text, "text/markdown")
--
cgit v1.2.3
From 95c948110ca130559fd6a5302011aa58900274ac Mon Sep 17 00:00:00 2001
From: Egor Kislitsyn
Date: Thu, 19 Sep 2019 14:39:52 +0700
Subject: Add `rel="ugc"` to hashtags and mentions
---
test/web/common_api/common_api_utils_test.exs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'test/web/common_api')
diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs
index 78cfe3c5f..2588898d0 100644
--- a/test/web/common_api/common_api_utils_test.exs
+++ b/test/web/common_api/common_api_utils_test.exs
@@ -159,9 +159,9 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
expected =
~s(hello world
\nanother @user__test and @user__test and @user__test google.com paragraph
\n)
+ }" class="u-url mention" href="http://foo.com/user__test" rel="ugc">@user__test google.com paragraph\n)
{output, _, _} = Utils.format_input(text, "text/markdown")
--
cgit v1.2.3
From 2c82d8603bb4c3f7281023752dc78aa31a814ab6 Mon Sep 17 00:00:00 2001
From: Ariadne Conill
Date: Sat, 28 Sep 2019 00:24:32 +0000
Subject: common api: implement scrobbling
---
test/web/common_api/common_api_test.exs | 39 +++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
(limited to 'test/web/common_api')
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index f28a66090..0f4a5eb25 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -510,4 +510,43 @@ defmodule Pleroma.Web.CommonAPITest do
assert {:error, "Already voted"} == CommonAPI.vote(other_user, object, [1])
end
end
+
+ describe "listen/2" do
+ test "returns a valid activity" do
+ user = insert(:user)
+
+ {:ok, activity} =
+ CommonAPI.listen(user, %{
+ "title" => "lain radio episode 1",
+ "album" => "lain radio",
+ "artist" => "lain",
+ "length" => 180_000
+ })
+
+ object = Object.normalize(activity)
+
+ assert object.data["title"] == "lain radio episode 1"
+
+ assert Visibility.get_visibility(activity) == "public"
+ end
+
+ test "respects visibility=private" do
+ user = insert(:user)
+
+ {:ok, activity} =
+ CommonAPI.listen(user, %{
+ "title" => "lain radio episode 1",
+ "album" => "lain radio",
+ "artist" => "lain",
+ "length" => 180_000,
+ "visibility" => "private"
+ })
+
+ object = Object.normalize(activity)
+
+ assert object.data["title"] == "lain radio episode 1"
+
+ assert Visibility.get_visibility(activity) == "private"
+ end
+ end
end
--
cgit v1.2.3