Refactor the async user refreshing to use Oban

Previous implementation could cause duplicate simultaneous profile fetches which is not polite.
This commit is contained in:
Mark Felder 2024-06-17 10:08:54 -04:00
commit 9c67637255
5 changed files with 24 additions and 10 deletions

View file

@ -0,0 +1,14 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.UserRefreshWorker do
use Pleroma.Workers.WorkerHelper, queue: "background", max_attempts: 1, unique: [period: 300]
alias Pleroma.User
@impl Oban.Worker
def perform(%Job{args: %{"ap_id" => ap_id}}) do
User.fetch_by_ap_id(ap_id)
end
end