1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 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
9 alias Pleroma.Web.OAuth.Token.CleanWorker
11 use Pleroma.Workers.WorkerHelper, queue: "background"
14 def perform(%{"op" => "fetch_initial_posts", "user_id" => user_id}, _job) do
15 user = User.get_cached_by_id(user_id)
16 User.perform(:fetch_initial_posts, user)
19 def perform(%{"op" => "deactivate_user", "user_id" => user_id, "status" => status}, _job) do
20 user = User.get_cached_by_id(user_id)
21 User.perform(:deactivate_async, user, status)
24 def perform(%{"op" => "delete_user", "user_id" => user_id}, _job) do
25 user = User.get_cached_by_id(user_id)
26 User.perform(:delete, 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" => "clean_expired_tokens"}, _job) do
54 CleanWorker.perform(:clean)
57 def perform(%{"op" => "media_proxy_preload", "message" => message}, _job) do
58 MediaProxyWarmingPolicy.perform(:preload, message)
61 def perform(%{"op" => "media_proxy_prefetch", "url" => url}, _job) do
62 MediaProxyWarmingPolicy.perform(:prefetch, url)
65 def perform(%{"op" => "fetch_data_for_activity", "activity_id" => activity_id}, _job) do
66 activity = Activity.get_by_id(activity_id)
67 Pleroma.Web.RichMedia.Helpers.perform(:fetch, activity)