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.
This commit is contained in:
Mike Verdone 2019-07-22 16:46:20 +02:00
commit 704960b3c1
6 changed files with 82 additions and 13 deletions

View file

@ -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