Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `README.md`: Discarded upstream changes: we have our own README - `app/controllers/follower_accounts_controller.rb`: Port upstream's minor refactoring
This commit is contained in:
@@ -339,9 +339,15 @@ class Account < ApplicationRecord
|
||||
|
||||
def save_with_optional_media!
|
||||
save!
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
self.avatar = nil
|
||||
self.header = nil
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
errors = e.record.errors.errors
|
||||
errors.each do |err|
|
||||
if err.attribute == :avatar
|
||||
self.avatar = nil
|
||||
elsif err.attribute == :header
|
||||
self.header = nil
|
||||
end
|
||||
end
|
||||
|
||||
save!
|
||||
end
|
||||
|
||||
@@ -81,7 +81,7 @@ class AccountFilter
|
||||
when 'suspended'
|
||||
Account.suspended
|
||||
when 'disabled'
|
||||
accounts_with_users.merge(User.disabled)
|
||||
accounts_with_users.merge(User.disabled).without_suspended
|
||||
when 'silenced'
|
||||
Account.silenced
|
||||
when 'sensitized'
|
||||
|
||||
@@ -44,6 +44,10 @@ module AccountInteractions
|
||||
end
|
||||
end
|
||||
|
||||
def requested_by_map(target_account_ids, account_id)
|
||||
follow_mapping(FollowRequest.where(account_id: target_account_ids, target_account_id: account_id), :account_id)
|
||||
end
|
||||
|
||||
def endorsed_map(target_account_ids, account_id)
|
||||
follow_mapping(AccountPin.where(account_id: account_id, target_account_id: target_account_ids), :target_account_id)
|
||||
end
|
||||
|
||||
@@ -210,6 +210,8 @@ class MediaAttachment < ApplicationRecord
|
||||
|
||||
default_scope { order(id: :asc) }
|
||||
|
||||
attr_accessor :skip_download
|
||||
|
||||
def local?
|
||||
remote_url.blank?
|
||||
end
|
||||
|
||||
@@ -386,6 +386,15 @@ class User < ApplicationRecord
|
||||
super
|
||||
end
|
||||
|
||||
def revoke_access!
|
||||
Doorkeeper::AccessGrant.by_resource_owner(self).update_all(revoked_at: Time.now.utc)
|
||||
|
||||
Doorkeeper::AccessToken.by_resource_owner(self).in_batches do |batch|
|
||||
batch.update_all(revoked_at: Time.now.utc)
|
||||
Web::PushSubscription.where(access_token_id: batch).delete_all
|
||||
end
|
||||
end
|
||||
|
||||
def reset_password!
|
||||
# First, change password to something random and deactivate all sessions
|
||||
transaction do
|
||||
@@ -394,12 +403,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
# Then, remove all authorized applications and connected push subscriptions
|
||||
Doorkeeper::AccessGrant.by_resource_owner(self).in_batches.update_all(revoked_at: Time.now.utc)
|
||||
|
||||
Doorkeeper::AccessToken.by_resource_owner(self).in_batches do |batch|
|
||||
batch.update_all(revoked_at: Time.now.utc)
|
||||
Web::PushSubscription.where(access_token_id: batch).delete_all
|
||||
end
|
||||
revoke_access!
|
||||
|
||||
# Finally, send a reset password prompt to the user
|
||||
send_reset_password_instructions
|
||||
|
||||
Reference in New Issue
Block a user