1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Workers.BackgroundWorker do
6 alias Pleroma.Instances.Instance
9 use Pleroma.Workers.WorkerHelper, queue: "background"
13 def perform(%Job{args: %{"op" => "user_activation", "user_id" => user_id, "status" => status}}) do
14 user = User.get_cached_by_id(user_id)
15 User.perform(:set_activation_async, user, status)
18 def perform(%Job{args: %{"op" => "delete_user", "user_id" => user_id}}) do
19 user = User.get_cached_by_id(user_id)
20 User.perform(:delete, user)
23 def perform(%Job{args: %{"op" => "force_password_reset", "user_id" => user_id}}) do
24 user = User.get_cached_by_id(user_id)
25 User.perform(:force_password_reset, user)
28 def perform(%Job{args: %{"op" => op, "user_id" => user_id, "identifier" => identifier}})
29 when op in ["blocks_import", "follow_import", "mutes_import"] do
30 user = User.get_cached_by_id(user_id)
31 {:ok, User.Import.perform(String.to_atom(op), user, identifier)}
35 args: %{"op" => "move_following", "origin_id" => origin_id, "target_id" => target_id}
37 origin = User.get_cached_by_id(origin_id)
38 target = User.get_cached_by_id(target_id)
40 Pleroma.FollowingRelationship.move_following(origin, target)
43 def perform(%Job{args: %{"op" => "delete_instance", "host" => host}}) do
44 Instance.perform(:delete_instance, host)