summaryrefslogtreecommitdiff
path: root/test/web/mastodon_api/mastodon_api_controller_test.exs
diff options
context:
space:
mode:
authorMike Verdone <spiral@arcseconds.net>2019-07-22 16:46:20 +0200
committerMike Verdone <spiral@arcseconds.net>2019-07-24 14:45:14 +0200
commit704960b3c135d2e050308c68f5ccf5d7b7df40f8 (patch)
tree85c5e602683014b42147dd582113fafff578c4eb /test/web/mastodon_api/mastodon_api_controller_test.exs
parent378f5f0fbe21c2533719fed9afe8313586fda5d5 (diff)
downloadpleroma-704960b3c135d2e050308c68f5ccf5d7b7df40f8.tar.gz
pleroma-704960b3c135d2e050308c68f5ccf5d7b7df40f8.zip
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.
Diffstat (limited to 'test/web/mastodon_api/mastodon_api_controller_test.exs')
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index b5279412f..24482a4a2 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -7,6 +7,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
alias Ecto.Changeset
alias Pleroma.Activity
+ alias Pleroma.ActivityExpiration
alias Pleroma.Notification
alias Pleroma.Object
alias Pleroma.Repo
@@ -151,6 +152,24 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert %{"id" => third_id} = json_response(conn_three, 200)
refute id == third_id
+
+ # An activity that will expire:
+ expires_at =
+ NaiveDateTime.utc_now()
+ |> NaiveDateTime.add(:timer.minutes(120), :millisecond)
+ |> NaiveDateTime.truncate(:second)
+
+ conn_four =
+ conn
+ |> post("api/v1/statuses", %{
+ "status" => "oolong",
+ "expires_at" => expires_at
+ })
+
+ assert %{"id" => fourth_id} = json_response(conn_four, 200)
+ assert activity = Activity.get_by_id(fourth_id)
+ assert expiration = ActivityExpiration.get_by_activity_id(fourth_id)
+ assert expiration.scheduled_at == expires_at
end
test "replying to a status", %{conn: conn} do