Update ban logic in Rakefile

This commit is contained in:
Karina Kwiatek 2021-12-30 21:35:24 +01:00
parent d06e2c97b2
commit ae83353b21
1 changed files with 31 additions and 27 deletions

View File

@ -154,9 +154,11 @@ namespace :justask do
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
fail "user #{args[:screen_name]} not found" if user.nil? fail "user #{args[:screen_name]} not found" if user.nil?
user.permanently_banned = true UseCase::User::Ban.call(
user.ban_reason = args[:reason] target_user_id: user.id,
user.save! expiry: nil,
reason: args[:reason],
)
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!" puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"
end end
@ -164,10 +166,11 @@ namespace :justask do
task :ban, [:screen_name, :reason] => :environment do |t, args| task :ban, [:screen_name, :reason] => :environment do |t, args|
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
user.permanently_banned = false UseCase::User::Ban.call(
user.banned_until = DateTime.current + 1 target_user_id: user.id,
user.ban_reason = args[:reason] expiry: DateTime.current + 1,
user.save! reason: args[:reason],
)
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!" puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"
end end
@ -175,10 +178,11 @@ namespace :justask do
task :week_ban, [:screen_name, :reason] => :environment do |t, args| task :week_ban, [:screen_name, :reason] => :environment do |t, args|
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
user.permanently_banned = false UseCase::User::Ban.call(
user.banned_until = DateTime.current + 7 target_user_id: user.id,
user.ban_reason = args[:reason] expiry: DateTime.current + 7,
user.save! reason: args[:reason],
)
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!" puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"
end end
@ -186,10 +190,11 @@ namespace :justask do
task :month_ban, [:screen_name, :reason] => :environment do |t, args| task :month_ban, [:screen_name, :reason] => :environment do |t, args|
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
user.permanently_banned = false UseCase::User::Ban.call(
user.banned_until = DateTime.current + 30 target_user_id: user.id,
user.ban_reason = args[:reason] expiry: DateTime.current + 30,
user.save! reason: args[:reason],
)
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!" puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"
end end
@ -197,10 +202,11 @@ namespace :justask do
task :year_ban, [:screen_name, :reason] => :environment do |t, args| task :year_ban, [:screen_name, :reason] => :environment do |t, args|
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
user.permanently_banned = false UseCase::User::Ban.call(
user.banned_until = DateTime.current + 365 target_user_id: user.id,
user.ban_reason = args[:reason] expiry: DateTime.current + 365,
user.save! reason: args[:reason],
)
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!" puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"
end end
@ -208,10 +214,11 @@ namespace :justask do
task :aeon_ban, [:screen_name, :reason] => :environment do |t, args| task :aeon_ban, [:screen_name, :reason] => :environment do |t, args|
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
user.permanently_banned = false UseCase::User::Ban.call(
user.banned_until = DateTime.current + 365_000_000_000 target_user_id: user.id,
user.ban_reason = args[:reason] expiry: DateTime.current + 365_000_000_000,
user.save! reason: args[:reason],
)
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!" puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"
end end
@ -220,10 +227,7 @@ namespace :justask do
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
fail "user #{args[:screen_name]} not found" if user.nil? fail "user #{args[:screen_name]} not found" if user.nil?
user.permanently_banned = false UseCase::User::Unban.call(user.id)
user.banned_until = nil
user.ban_reason = nil
user.save!
puts "#{user.screen_name} is no longer banned." puts "#{user.screen_name} is no longer banned."
end end