(optionally) announce the success of werewolf transformations
parent
592790418d
commit
47cd2611bf
2
Gemfile
2
Gemfile
|
@ -151,3 +151,5 @@ end
|
|||
gem 'concurrent-ruby', require: false
|
||||
|
||||
gem "ruby-bbcode", "~> 2.0"
|
||||
|
||||
gem "sun_calc", "~> 0.1.0"
|
||||
|
|
|
@ -596,6 +596,7 @@ GEM
|
|||
multi_json (~> 1.8)
|
||||
strong_migrations (0.3.1)
|
||||
activerecord (>= 3.2.0)
|
||||
sun_calc (0.1.0)
|
||||
temple (0.8.1)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
|
@ -767,6 +768,7 @@ DEPENDENCIES
|
|||
stoplight (~> 2.1.3)
|
||||
streamio-ffmpeg (~> 3.0)
|
||||
strong_migrations (~> 0.3)
|
||||
sun_calc (~> 0.1.0)
|
||||
thor (~> 0.20)
|
||||
tty-command (~> 0.8)
|
||||
tty-prompt (~> 0.18)
|
||||
|
|
|
@ -36,6 +36,7 @@ class Form::AdminSettings
|
|||
show_replies_in_public_timelines
|
||||
auto_reject_unknown
|
||||
auto_mark_known
|
||||
werewolf_status
|
||||
).freeze
|
||||
|
||||
BOOLEAN_KEYS = %i(
|
||||
|
@ -53,6 +54,7 @@ class Form::AdminSettings
|
|||
show_replies_in_public_timelines
|
||||
auto_reject_unknown
|
||||
auto_mark_known
|
||||
werewolf_status
|
||||
).freeze
|
||||
|
||||
UPLOAD_KEYS = %i(
|
||||
|
|
|
@ -86,6 +86,11 @@
|
|||
|
||||
%hr.spacer/
|
||||
|
||||
.fields-group
|
||||
= f.input :werewolf_status, as: :boolean, wrapper: :with_label, label: t('admin.settings.werewolf_status.title'), hint: t('admin.settings.werewolf_status.desc_html')
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
.fields-group
|
||||
= f.input :min_invite_role, wrapper: :with_label, collection: %i(disabled user moderator admin), label: t('admin.settings.registrations.min_invite_role.title'), label_method: lambda { |role| role == :disabled ? t('admin.settings.registrations.min_invite_role.disabled') : t("admin.accounts.roles.#{role}") }, include_blank: false, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Scheduler::WerewolfScheduler
|
||||
include Sidekiq::Worker
|
||||
include Redisable
|
||||
|
||||
STATUS = ENV.fetch('WEREWOLF_STATUS', 'Werewolves successful.')
|
||||
FOOTER = ENV.fetch('WEREWOLF_FOOTER', ':werewolf: werewolf-status')
|
||||
|
||||
sidekiq_options unique: :until_executed
|
||||
|
||||
def perform
|
||||
return if redis.exists('werewolf-status')
|
||||
return unless Setting.werewolf_status
|
||||
|
||||
moon_fraction = SunCalc.moon_illumination(Time.now.utc)[:fraction]
|
||||
|
||||
return unless moon_fraction >= 0.998
|
||||
|
||||
redis.setex('werewolf-status', 1.day, 1)
|
||||
|
||||
announcer = find_announcer_acct
|
||||
return if announcer.nil?
|
||||
|
||||
s = PostStatusService.new.call(
|
||||
announcer,
|
||||
visibility: :public,
|
||||
text: STATUS,
|
||||
footer: FOOTER,
|
||||
content_type: 'text/console',
|
||||
)
|
||||
|
||||
DistributionWorker.perform_async(s.id)
|
||||
ActivityPub::DistributionWorker.perform_async(s)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_announcer_acct
|
||||
announcer = ENV['ANNOUNCEMENTS_USER'].to_i
|
||||
return if announcer == 0
|
||||
Account.find_by(id: announcer)
|
||||
end
|
||||
end
|
|
@ -511,6 +511,9 @@ en:
|
|||
auto_mark_known:
|
||||
desc_html: Learn known accounts from outgoing interactions and incoming repeats from packmates.
|
||||
title: Auto-learn known accounts
|
||||
werewolf_status:
|
||||
desc_html: Enable werewolf status Easter egg (requires an announcer account)
|
||||
title: Werewolf status
|
||||
title: Site settings
|
||||
statuses:
|
||||
back_to_account: Back to account page
|
||||
|
|
|
@ -67,6 +67,7 @@ defaults: &defaults
|
|||
default_content_type: 'text/x-bbcode+markdown'
|
||||
auto_reject_unknown: true
|
||||
auto_mark_known: true
|
||||
werewolf_status: true
|
||||
|
||||
development:
|
||||
<<: *defaults
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
prune_database_scheduler:
|
||||
every: '1d'
|
||||
class: Scheduler::PruneDatabaseScheduler
|
||||
werewolf_scheduler:
|
||||
every: '1h'
|
||||
class: Scheduler::WerewolfScheduler
|
||||
media_cleanup_scheduler:
|
||||
cron: '<%= Random.rand(0..59) %> <%= Random.rand(3..5) %> * * *'
|
||||
class: Scheduler::MediaCleanupScheduler
|
||||
|
|
Loading…
Reference in New Issue