commit: 4dfa50f256ce7966ff127a12f91c9fdeabfff114
parent 9a4cdde5c9e833a8cc61d660f5627717756778d2
Author: Mark Felder <feld@feld.me>
Date: Wed, 19 Jun 2024 21:25:24 -0400
Rename RichMediaExpirationWorker to RichMediaWorker
Diffstat:
5 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/lib/pleroma/web/rich_media/backfill.ex b/lib/pleroma/web/rich_media/backfill.ex
@@ -6,7 +6,7 @@ defmodule Pleroma.Web.RichMedia.Backfill do
alias Pleroma.Web.RichMedia.Card
alias Pleroma.Web.RichMedia.Parser
alias Pleroma.Web.RichMedia.Parser.TTL
- alias Pleroma.Workers.RichMediaExpirationWorker
+ alias Pleroma.Workers.RichMediaWorker
require Logger
@@ -72,7 +72,7 @@ defmodule Pleroma.Web.RichMedia.Backfill do
{:ok, ttl} when is_number(ttl) ->
timestamp = DateTime.from_unix!(ttl)
- RichMediaExpirationWorker.new(%{"url" => url}, scheduled_at: timestamp)
+ RichMediaWorker.new(%{"op" => "expire", "url" => url}, scheduled_at: timestamp)
|> Oban.insert()
_ ->
diff --git a/lib/pleroma/workers/rich_media_expiration_worker.ex b/lib/pleroma/workers/rich_media_expiration_worker.ex
@@ -1,15 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Workers.RichMediaExpirationWorker do
- alias Pleroma.Web.RichMedia.Card
-
- use Oban.Worker,
- queue: :background
-
- @impl Oban.Worker
- def perform(%Job{args: %{"url" => url} = _args}) do
- Card.delete(url)
- end
-end
diff --git a/lib/pleroma/workers/rich_media_worker.ex b/lib/pleroma/workers/rich_media_worker.ex
@@ -0,0 +1,15 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Workers.RichMediaWorker do
+ alias Pleroma.Web.RichMedia.Card
+
+ use Oban.Worker,
+ queue: :background
+
+ @impl Oban.Worker
+ def perform(%Job{args: %{"op" => "expire", "url" => url} = _args}) do
+ Card.delete(url)
+ end
+end
diff --git a/test/pleroma/web/rich_media/parser/ttl/aws_signed_url_test.exs b/test/pleroma/web/rich_media/parser/ttl/aws_signed_url_test.exs
@@ -74,7 +74,10 @@ defmodule Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrlTest do
Card.get_or_backfill_by_url(url)
- assert_enqueued(worker: Pleroma.Workers.RichMediaExpirationWorker, args: %{"url" => url})
+ assert_enqueued(
+ worker: Pleroma.Workers.RichMediaWorker,
+ args: %{"op" => "expire", "url" => url}
+ )
[%Oban.Job{scheduled_at: scheduled_at}] = all_enqueued()
diff --git a/test/pleroma/web/rich_media/parser/ttl/opengraph_test.exs b/test/pleroma/web/rich_media/parser/ttl/opengraph_test.exs
@@ -36,6 +36,9 @@ defmodule Pleroma.Web.RichMedia.Parser.TTL.OpengraphTest do
Card.get_or_backfill_by_url(url)
- assert_enqueued(worker: Pleroma.Workers.RichMediaExpirationWorker, args: %{"url" => url})
+ assert_enqueued(
+ worker: Pleroma.Workers.RichMediaWorker,
+ args: %{"op" => "expire", "url" => url}
+ )
end
end