diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-08-31 14:25:43 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-08-31 14:25:43 +0300 |
commit | e890ea7e821d61fca75084d46f70ed125acf1fc8 (patch) | |
tree | 7994c0be9f90b39a9ed46bbfd9f04fce70a14671 /test/support/factory.ex | |
parent | cd78e63a2528ab813088d5e44a026f6bb05b344b (diff) | |
parent | 6d33c89c4d27a1b52e69e1c14b408726410a6326 (diff) | |
download | pleroma-e890ea7e821d61fca75084d46f70ed125acf1fc8.tar.gz |
[#1149] Added Oban job for "activity_expiration". Merged remote-tracking branch 'remotes/upstream/develop' into 1149-oban-job-queue
# Conflicts:
# config/config.exs
Diffstat (limited to 'test/support/factory.ex')
-rw-r--r-- | test/support/factory.ex | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex index 1787c1088..719115003 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 @@ -143,6 +143,25 @@ defmodule Pleroma.Factory do |> Map.merge(attrs) end + defp expiration_offset_by_minutes(attrs, minutes) do + scheduled_at = + NaiveDateTime.utc_now() + |> NaiveDateTime.add(:timer.minutes(minutes), :millisecond) + |> NaiveDateTime.truncate(:second) + + %Pleroma.ActivityExpiration{} + |> Map.merge(attrs) + |> Map.put(:scheduled_at, scheduled_at) + 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, 61) + end + def article_activity_factory do article = insert(:article) @@ -188,13 +207,15 @@ defmodule Pleroma.Factory do object = Object.normalize(note_activity) user = insert(:user) - data = %{ - "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(), - "actor" => user.ap_id, - "type" => "Like", - "object" => object.data["id"], - "published_at" => DateTime.utc_now() |> DateTime.to_iso8601() - } + data = + %{ + "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(), + "actor" => user.ap_id, + "type" => "Like", + "object" => object.data["id"], + "published_at" => DateTime.utc_now() |> DateTime.to_iso8601() + } + |> Map.merge(attrs[:data_attrs] || %{}) %Pleroma.Activity{ data: data |