transparancy - log use of admin related method calls & activitypub auto-rejections to a logger account
parent
8f6e737f38
commit
cefcad1130
|
@ -61,8 +61,10 @@ module AutorejectHelper
|
||||||
if should_reject?(uri)
|
if should_reject?(uri)
|
||||||
if @json
|
if @json
|
||||||
Rails.logger.info("Auto-rejected #{@json['id']} (#{@json['type']})")
|
Rails.logger.info("Auto-rejected #{@json['id']} (#{@json['type']})")
|
||||||
|
LogWorker.perform_async("Auto-rejected an incoming '#{@json['type']}#{@object && " #{@object['type']}".rstrip}' from #{@json['id']}.")
|
||||||
elsif uri
|
elsif uri
|
||||||
Rails.logger.info("Auto-rejected #{uri}")
|
Rails.logger.info("Auto-rejected #{uri}")
|
||||||
|
LogWorker.perform_async("Auto-rejected a request to #{uri}.")
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -184,6 +184,7 @@ class ActivityPub::Activity
|
||||||
|
|
||||||
def reject_payload!
|
def reject_payload!
|
||||||
Rails.logger.info("Rejected #{@json['type']} activity #{@json['id']} from #{@account.uri}#{@options[:relayed_through_account] && "via #{@options[:relayed_through_account].uri}"}")
|
Rails.logger.info("Rejected #{@json['type']} activity #{@json['id']} from #{@account.uri}#{@options[:relayed_through_account] && "via #{@options[:relayed_through_account].uri}"}")
|
||||||
|
LogWorker.perform_async("Auto-rejected an incoming '#{@json['type']}#{@object && " #{@object['type']}".rstrip}' from #{@json['id']} by #{@account.uri}#{@options[:relayed_through_account] && " via #{@options[:relayed_through_account].uri}"}.")
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -212,6 +212,7 @@ class Account < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def force_unlisted!
|
def force_unlisted!
|
||||||
|
LogWorker.perform_async("\xf0\x9f\x93\xb5 Forced the media of account '#{@account.acct}' to be unlisted.")
|
||||||
transaction do
|
transaction do
|
||||||
update!(force_unlisted: true)
|
update!(force_unlisted: true)
|
||||||
Status.where(account_id: id, visibility: :public).in_batches.update_all(visibility: :unlisted)
|
Status.where(account_id: id, visibility: :public).in_batches.update_all(visibility: :unlisted)
|
||||||
|
@ -219,6 +220,7 @@ class Account < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def force_sensitive!
|
def force_sensitive!
|
||||||
|
LogWorker.perform_async("\xf0\x9f\x94\x9e Forced the media of account '#{@account.acct}' to be marked sensitive.")
|
||||||
transaction do
|
transaction do
|
||||||
update!(force_sensitive: true)
|
update!(force_sensitive: true)
|
||||||
Status.where(account_id: id, sensitive: false).in_batches.update_all(sensitive: true)
|
Status.where(account_id: id, sensitive: false).in_batches.update_all(sensitive: true)
|
||||||
|
@ -226,6 +228,7 @@ class Account < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def allow_public!
|
def allow_public!
|
||||||
|
LogWorker.perform_async("\xf0\x9f\x86\x97 No longer forcing the media of account '#{@account.acct}' to be marked sensitive.")
|
||||||
update!(force_unlisted: false)
|
update!(force_unlisted: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -240,10 +243,12 @@ class Account < ApplicationRecord
|
||||||
def silence!(date = nil)
|
def silence!(date = nil)
|
||||||
date ||= Time.now.utc
|
date ||= Time.now.utc
|
||||||
update!(silenced_at: date)
|
update!(silenced_at: date)
|
||||||
|
LogWorker.perform_async("\xf0\x9f\x94\x87 Silenced account '#{@account.acct}'.")
|
||||||
end
|
end
|
||||||
|
|
||||||
def unsilence!
|
def unsilence!
|
||||||
update!(silenced_at: nil)
|
update!(silenced_at: nil)
|
||||||
|
LogWorker.perform_async("\xf0\x9f\x94\x8a Unsilenced account '#{@account.acct}'.")
|
||||||
end
|
end
|
||||||
|
|
||||||
def suspended?
|
def suspended?
|
||||||
|
|
|
@ -5,6 +5,7 @@ class BlockDomainService < BaseService
|
||||||
|
|
||||||
def call(domain_block)
|
def call(domain_block)
|
||||||
@domain_block = domain_block
|
@domain_block = domain_block
|
||||||
|
LogWorker.perform_async("\xf0\x9f\x9a\xab Applying #{@domain_block.severity}#{@domain_block.force_sensitive? ? " and force sensitive media" : ''}#{@domain_block.reject_media? ? " and reject media" : ''} policy on domain '#{blocked_domain}'.")
|
||||||
process_domain_block!
|
process_domain_block!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@ class SuspendAccountService < BaseService
|
||||||
@account = account
|
@account = account
|
||||||
@options = options
|
@options = options
|
||||||
|
|
||||||
|
LogWorker.perform_async("\xf0\x9f\x97\x91\xef\xb8\x8f Suspending account '#{@account.acct}'.")
|
||||||
|
|
||||||
reject_follows!
|
reject_follows!
|
||||||
purge_user!
|
purge_user!
|
||||||
purge_profile!
|
purge_profile!
|
||||||
|
|
|
@ -5,6 +5,7 @@ class UnblockDomainService < BaseService
|
||||||
|
|
||||||
def call(domain_block)
|
def call(domain_block)
|
||||||
@domain_block = domain_block
|
@domain_block = domain_block
|
||||||
|
LogWorker.perform_async("\xf0\x9f\x86\x97 Reset policy on domain '#{@domain_block.domain}'.")
|
||||||
process_retroactive_updates
|
process_retroactive_updates
|
||||||
domain_block.destroy
|
domain_block.destroy
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class LogWorker
|
||||||
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options unique: :until_executed
|
||||||
|
|
||||||
|
def perform(log_text)
|
||||||
|
logger_id = ENV['LOG_USER'].to_i
|
||||||
|
return true if logger_id == 0
|
||||||
|
|
||||||
|
logger = Account.find_by(id: logger_id)
|
||||||
|
return true if logger.nil?
|
||||||
|
|
||||||
|
PostStatusService.new.call(
|
||||||
|
logger,
|
||||||
|
created_at: Time.now.utc,
|
||||||
|
text: log_text.strip,
|
||||||
|
tags: ['monsterpit.admin.log'],
|
||||||
|
visibility: :unlisted,
|
||||||
|
local_only: true,
|
||||||
|
content_type: 'text/plain',
|
||||||
|
language: 'en',
|
||||||
|
)
|
||||||
|
rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue