diff options
author | Mike Verdone <spiral@arcseconds.net> | 2019-07-22 14:16:20 +0200 |
---|---|---|
committer | Mike Verdone <spiral@arcseconds.net> | 2019-07-24 13:14:52 +0200 |
commit | 666514194a325e2463c05bae516b89d7c5f59316 (patch) | |
tree | d98cc471458be04518cc5c5130799ef2082fbe03 /test/support | |
parent | b72940277470c67802b979e4cab44f277e8fffb3 (diff) | |
download | pleroma-666514194a325e2463c05bae516b89d7c5f59316.tar.gz |
Add activity expirations table
Add a table to store activity expirations. An activity can have zero or
one expirations. The expiration has a scheduled_at field which stores
the time at which the activity should expire and be deleted.
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/factory.ex | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex index c751546ce..7b52b1328 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Factory do @@ -142,6 +142,23 @@ defmodule Pleroma.Factory do |> Map.merge(attrs) end + defp expiration_offset_by_minutes(attrs, minutes) do + %Pleroma.ActivityExpiration{} + |> Map.merge(attrs) + |> Map.put( + :scheduled_at, + NaiveDateTime.add(NaiveDateTime.utc_now(), :timer.minutes(minutes), :millisecond) + ) + end + + def expiration_in_the_past_factory(attrs \\ %{}) do + expiration_offset_by_minutes(attrs, -60) + end + + def expiration_in_the_future_factory(attrs \\ %{}) do + expiration_offset_by_minutes(attrs, 60) + end + def article_activity_factory do article = insert(:article) |