Welcome to mirror list, hosted at ThFree Co, Russian Federation.

account_deletion.rb « models « app - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 31b4683d8dee3e711283c3b95ea1802dfb8aeea3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.

class AccountDeletion < ApplicationRecord
  include Diaspora::Federated::Base

  scope :uncompleted, -> { where("completed_at is null") }

  belongs_to :person
  after_commit :queue_delete_account, on: :create

  delegate :diaspora_handle, to: :person

  def queue_delete_account
    Workers::DeleteAccount.perform_async(id)
  end

  def perform!
    Diaspora::Federation::Dispatcher.build(person.owner, self).dispatch if person.local?
    AccountDeleter.new(person).perform!
  end

  def subscribers
    person.owner.contact_people.remote | Person.who_have_reshared_a_users_posts(person.owner).remote
  end

  def public?
    true
  end
end