Class: Jobs::AnonymizeUser
- Inherits:
-
Base
- Object
- Base
- Jobs::AnonymizeUser
show all
- Defined in:
- app/jobs/regular/anonymize_user.rb
Instance Method Summary
collapse
Methods inherited from Base
acquire_cluster_concurrency_lock!, clear_cluster_concurrency_lock!, cluster_concurrency, cluster_concurrency_redis_key, delayed_perform, #error_context, get_cluster_concurrency, #last_db_duration, #log, #perform, #perform_immediately
Instance Method Details
#anonymize_ips(new_ip) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'app/jobs/regular/anonymize_user.rb', line 40
def anonymize_ips(new_ip)
IncomingLink.where(ip_where("current_user_id")).update_all(ip_address: new_ip)
ScreenedEmail.where(email: @prev_email).update_all(ip_address: new_ip)
SearchLog.where(ip_where).update_all(ip_address: new_ip)
TopicLinkClick.where(ip_where).update_all(ip_address: new_ip)
TopicViewItem.where(ip_where).update_all(ip_address: new_ip)
UserHistory.where(ip_where("acting_user_id")).update_all(ip_address: new_ip)
UserProfileView.where(ip_where).update_all(ip_address: new_ip)
UserHistory.where(
"action = :action AND details LIKE :details",
action: UserHistory.actions[:delete_user],
details: "id: #{@user_id}\n%",
).update_all(ip_address: new_ip)
end
|
#anonymize_user_fields ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'app/jobs/regular/anonymize_user.rb', line 58
def anonymize_user_fields
user_field_ids = UserField.pluck(:id)
user = User.find(@user_id)
return if user_field_ids.blank? || user.blank?
user_field_ids.each do |field_id|
user.custom_fields.delete("#{User::USER_FIELD_PREFIX}#{field_id}")
end
user.save!
end
|
#execute(args) ⇒ Object
10
11
12
13
14
15
16
|
# File 'app/jobs/regular/anonymize_user.rb', line 10
def execute(args)
@user_id = args[:user_id]
@prev_email = args[:prev_email]
@anonymize_ip = args[:anonymize_ip]
make_anonymous
end
|
#ip_where(column = "user_id") ⇒ Object
36
37
38
|
# File 'app/jobs/regular/anonymize_user.rb', line 36
def ip_where(column = "user_id")
["#{column} = :user_id AND ip_address IS NOT NULL", user_id: @user_id]
end
|
#make_anonymous ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/jobs/regular/anonymize_user.rb', line 18
def make_anonymous
anonymize_ips(@anonymize_ip) if @anonymize_ip
Invite.where(email: @prev_email).destroy_all
InvitedUser.where(user_id: @user_id).destroy_all
EmailToken.where(user_id: @user_id).destroy_all
EmailLog.where(user_id: @user_id).delete_all
IncomingEmail.where("user_id = ? OR from_address = ?", @user_id, @prev_email).delete_all
Post
.with_deleted
.where(user_id: @user_id)
.where.not(raw_email: nil)
.update_all(raw_email: nil)
anonymize_user_fields
end
|