2019-07-24 23:35:49 -07:00
module LogHelper
2019-08-03 13:07:19 -07:00
def user_friendly_action_log ( source , action , target , reason = nil )
2019-07-24 23:35:49 -07:00
source = source . username if source . is_a? ( Account )
2019-08-08 08:49:49 -07:00
web_domain = Rails . configuration . x . web_domain || Rails . configuration . x . local_domain
2019-07-24 23:35:49 -07:00
case action
when :create
if target . is_a? DomainBlock
2019-08-09 17:02:30 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x9a \xab < #{ source } > applied a #{ target . severity } #{ target . force_sensitive? ? " and force sensitive media " : '' } #{ target . reject_media? ? " and reject media " : '' } #{ target . reject_unknown? ? " and reject unknown accounts " : '' } policy on ' #{ target . domain } ' \ u200b. \n \n Review (moderators only): https:// #{ web_domain } /admin/instances/ #{ target . domain } \n \n #{ target . reason? ? " Comment: #{ target . reason } " : '' } " )
2019-07-24 23:35:49 -07:00
elsif target . is_a? EmailDomainBlock
2019-08-08 08:49:49 -07:00
LogWorker . perform_async ( " \ u26d4 < #{ source } > added a registration block on email domain ' #{ target . domain } '. \n \n Review (moderators only): https:// #{ web_domain } /admin/email_domain_blocks " )
2019-07-24 23:35:49 -07:00
elsif target . is_a? CustomEmoji
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x98 \xba < #{ source } > added the ' #{ target . shortcode } ' emoji. : #{ target . shortcode } : " )
2019-07-24 23:35:49 -07:00
elsif target . is_a? AccountWarning
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xe2 \x9a \xa0 \xef \xb8 \x8f < #{ source } > sent someone an admin notice. " )
2019-07-24 23:35:49 -07:00
end
when :destroy
if target . is_a? DomainBlock
2019-08-09 17:02:30 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x86 \x97 < #{ source } > reset the policy on #{ target . domain } \ u200b. \n \n Review (moderators only): https:// #{ web_domain } /admin/instances/ #{ target . domain } " )
2019-07-24 23:35:49 -07:00
elsif target . is_a? EmailDomainBlock
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x86 \x97 < #{ source } > removed the registration block on email domain ' #{ target . domain } '. " )
2019-07-24 23:35:49 -07:00
elsif target . is_a? CustomEmoji
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x97 \x91 \xef \xb8 \x8f < #{ source } > removed the ' #{ target . shortcode } ' emoji. " )
2019-07-24 23:35:49 -07:00
elsif target . is_a? Status
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x97 \x91 \xef \xb8 \x8f < #{ source } > removed post #{ TagManager . instance . url_for ( target ) } \ u200b. " )
2019-07-24 23:35:49 -07:00
end
when :update
2019-07-30 23:25:10 -07:00
if target . is_a? DomainBlock
2019-08-09 17:02:30 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x9a \xab < #{ source } > changed the policy on ' #{ target . domain } ' to #{ target . severity } #{ target . force_sensitive? ? " and force sensitive media " : '' } #{ target . reject_media? ? " and reject media " : '' } #{ target . reject_unknown? ? " and reject unknown accounts " : '' } . \n \n Review (moderators only): https:// #{ web_domain } /admin/instances/ #{ target . domain } \n \n #{ target . reason? ? " Comment: #{ target . reason } " : '' } " )
2019-07-30 23:25:10 -07:00
elsif target . is_a? Status
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x91 \x81 \xef \xb8 \x8f < #{ source } > changed visibility flags of post #{ TagManager . instance . url_for ( target ) } \ u200b. " )
2019-07-24 23:35:49 -07:00
elsif target . is_a? CustomEmoji
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x94 \x81 < #{ source } > replaced the ' #{ target . shortcode } ' emoji. : #{ target . shortcode } : " )
2019-07-24 23:35:49 -07:00
end
when :enable
if target . is_a? User
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x92 \xa7 < #{ source } > unfroze the account of < #{ target . username } >. " )
2019-07-24 23:35:49 -07:00
elsif target . is_a? CustomEmoji
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x86 \x97 < #{ source } > enabled the ' #{ target . shortcode } ' emoji. : #{ target . shortcode } : " )
2019-07-24 23:35:49 -07:00
end
when :disable
if target . is_a? User
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xe2 \x9d \x84 \xef \xb8 \x8f < #{ source } > froze the account of < #{ target . username } >. " )
2019-07-24 23:35:49 -07:00
elsif target . is_a? CustomEmoji
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \ u26d4 < #{ source } > disabled the ' #{ target . shortcode } ' emoji. " )
2019-07-24 23:35:49 -07:00
end
2019-08-08 07:59:14 -07:00
when :mark_unknown
2019-08-08 08:49:49 -07:00
if source . nil?
2019-08-09 17:02:30 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x86 \x95 Federating with a new server at ' #{ target } '. Automatic reject unknown policy set. \n \n Review (moderators only): https:// #{ web_domain } /admin/instances/ #{ target } " )
2019-08-08 08:49:49 -07:00
else
LogWorker . perform_async ( " \ u2753 < #{ source } > marked < #{ target . acct } > as an unknown account. \n \n #{ reason ? " Comment: #{ reason } " : '' } " )
end
2019-07-24 23:35:49 -07:00
when :force_sensitive
2019-08-03 19:01:16 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x94 \x9e < #{ source } > forced the media of < #{ target . acct } > to be marked sensitive. \n \n #{ reason ? " Comment: #{ reason } " : '' } " )
2019-07-24 23:35:49 -07:00
when :force_unlisted
2019-08-03 19:01:16 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x94 \x89 < #{ source } > forced the posts of < #{ target . acct } > to be unlisted. \n \n #{ reason ? " Comment: #{ reason } " : '' } " )
2019-07-24 23:35:49 -07:00
when :silence
2019-08-08 07:59:14 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x94 \x87 < #{ source } > silenced < #{ target . acct } >. \n \n #{ reason ? " Comment: #{ reason } " : '' } " )
2019-07-24 23:35:49 -07:00
when :suspend
2019-08-03 19:01:16 -07:00
LogWorker . perform_async ( " \ u26d4 < #{ source } > suspended < #{ target . acct } >. \n \n #{ reason ? " Comment: #{ reason } " : '' } " )
2019-07-24 23:35:49 -07:00
2019-08-08 07:59:14 -07:00
when :mark_known
LogWorker . perform_async ( " \ u2705 < #{ source } > marked < #{ target . acct } > as a known account. \n \n #{ reason ? " Comment: #{ reason } " : '' } " )
2019-07-24 23:35:49 -07:00
when :allow_nonsensitive
2019-08-08 07:59:14 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x86 \x97 < #{ source } > allowed < #{ target . acct } > to post media without a sensitive flag. \n \n #{ reason ? " Comment: #{ reason } " : '' } " )
2019-07-24 23:35:49 -07:00
when :allow_public
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x86 \x8a < #{ source } > allowed < #{ target . acct } > to post with public visibility. " )
2019-07-24 23:35:49 -07:00
when :unsilence
2019-08-03 19:01:16 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x94 \x8a < #{ source } > unsilenced < #{ target . acct } >. \n \n #{ reason ? " Comment: #{ reason } " : '' } " )
2019-07-24 23:35:49 -07:00
when :unsuspend
2019-08-03 19:01:16 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x86 \x97 < #{ source } > unsuspended < #{ target . acct } >. \n \n #{ reason ? " Comment: #{ reason } " : '' } " )
2019-07-24 23:35:49 -07:00
when :remove_avatar
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x97 \x91 \xef \xb8 \x8f < #{ source } > removed the avatar of < #{ target . acct } >. " )
2019-07-24 23:35:49 -07:00
when :remove_header
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x97 \x91 \xef \xb8 \x8f < #{ source } > removed the profile header of < #{ target . acct } >. " )
2019-07-24 23:35:49 -07:00
when :resolve
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \ u2705 < #{ source } > resolved report #{ target . id } . " )
2019-07-24 23:35:49 -07:00
when :reopen
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \ u2757 < #{ source } > reopened report #{ target . id } . " )
2019-07-24 23:35:49 -07:00
when :assigned_to_self
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x91 \x80 < #{ source } > is resolving report #{ target . id } . " )
2019-07-24 23:35:49 -07:00
when :unassigned
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \ u274c < #{ source } > is no longer assigned to report #{ target . id } . " )
2019-07-24 23:35:49 -07:00
when :promote
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x94 \xba < #{ source } > upgraded a local account from #{ target . role } . " )
2019-07-24 23:35:49 -07:00
when :demote
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x94 \xbb < #{ source } > downgraded a local account from #{ target . role } . " )
2019-07-24 23:35:49 -07:00
when :confirm
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \ u2705 < #{ source } > manually confirmed a local account. " )
2019-07-24 23:35:49 -07:00
when :reset_password
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x94 \x81 < #{ source } > manually reset a local account's password. " )
2019-07-24 23:35:49 -07:00
when :disable_2fa
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x94 \x81 < #{ source } > manually reset a local account's 2-factor auth. " )
2019-07-24 23:35:49 -07:00
when :change_email
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x93 \x9d < #{ source } > manually changed a local account's email address. " )
2019-07-24 23:35:49 -07:00
when :memorialize
2019-07-31 10:17:08 -07:00
LogWorker . perform_async ( " \xf0 \x9f \x8f \x85 < #{ source } > memorialized an account. " )
2019-07-24 23:35:49 -07:00
end
end
end