1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Workers.BackgroundWorker do
8 alias Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy
10 use Pleroma.Workers.WorkerHelper, queue: "background"
14 def perform(%{"op" => "deactivate_user", "user_id" => user_id, "status" => status}, _job) do
15 user = User.get_cached_by_id(user_id)
16 User.perform(:deactivate_async, user, status)
19 def perform(%{"op" => "delete_user", "user_id" => user_id}, _job) do
20 user = User.get_cached_by_id(user_id)
21 User.perform(:delete, user)
24 def perform(%{"op" => "force_password_reset", "user_id" => user_id}, _job) do
25 user = User.get_cached_by_id(user_id)
26 User.perform(:force_password_reset, user)
31 "op" => "blocks_import",
32 "blocker_id" => blocker_id,
33 "blocked_identifiers" => blocked_identifiers
37 blocker = User.get_cached_by_id(blocker_id)
38 User.perform(:blocks_import, blocker, blocked_identifiers)
43 "op" => "follow_import",
44 "follower_id" => follower_id,
45 "followed_identifiers" => followed_identifiers
49 follower = User.get_cached_by_id(follower_id)
50 User.perform(:follow_import, follower, followed_identifiers)
53 def perform(%{"op" => "media_proxy_preload", "message" => message}, _job) do
54 MediaProxyWarmingPolicy.perform(:preload, message)
57 def perform(%{"op" => "media_proxy_prefetch", "url" => url}, _job) do
58 MediaProxyWarmingPolicy.perform(:prefetch, url)
61 def perform(%{"op" => "fetch_data_for_activity", "activity_id" => activity_id}, _job) do
62 activity = Activity.get_by_id(activity_id)
63 Pleroma.Web.RichMedia.Helpers.perform(:fetch, activity)
66 def perform(%{"op" => "move_following", "origin_id" => origin_id, "target_id" => target_id}, _) do
67 origin = User.get_cached_by_id(origin_id)
68 target = User.get_cached_by_id(target_id)
70 Pleroma.FollowingRelationship.move_following(origin, target)