diff options
author | ThibG <thib@sitedethib.com> | 2019-05-05 20:53:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-05 20:53:07 +0200 |
commit | e4ca5414a37b7973247a283a364b27052c8f9d1c (patch) | |
tree | dcb7769320c5a35b229ef579a20aa2fff209ea94 /lib | |
parent | 2c2f649200ba5b742ba9d17ac5ba553c752b59aa (diff) | |
parent | eef8802325d75b2668b131a765c5555f4be8c2ce (diff) |
Merge pull request #1032 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cli.rb | 4 | ||||
-rw-r--r-- | lib/mastodon/accounts_cli.rb | 7 | ||||
-rw-r--r-- | lib/mastodon/cache_cli.rb | 19 | ||||
-rw-r--r-- | lib/mastodon/version.rb | 4 | ||||
-rw-r--r-- | lib/paperclip/blurhash_transcoder.rb | 16 |
5 files changed, 47 insertions, 3 deletions
diff --git a/lib/cli.rb b/lib/cli.rb index b56c6e76f..5780e3e87 100644 --- a/lib/cli.rb +++ b/lib/cli.rb @@ -9,6 +9,7 @@ require_relative 'mastodon/search_cli' require_relative 'mastodon/settings_cli' require_relative 'mastodon/statuses_cli' require_relative 'mastodon/domains_cli' +require_relative 'mastodon/cache_cli' require_relative 'mastodon/version' module Mastodon @@ -41,6 +42,9 @@ module Mastodon desc 'domains SUBCOMMAND ...ARGS', 'Manage account domains' subcommand 'domains', Mastodon::DomainsCLI + desc 'cache SUBCOMMAND ...ARGS', 'Manage cache' + subcommand 'cache', Mastodon::CacheCLI + option :dry_run, type: :boolean desc 'self-destruct', 'Erase the server from the federation' long_desc <<~LONG_DESC diff --git a/lib/mastodon/accounts_cli.rb b/lib/mastodon/accounts_cli.rb index 9dc84f1b5..3131647f3 100644 --- a/lib/mastodon/accounts_cli.rb +++ b/lib/mastodon/accounts_cli.rb @@ -73,7 +73,7 @@ module Mastodon def create(username) account = Account.new(username: username) password = SecureRandom.hex - user = User.new(email: options[:email], password: password, agreement: true, admin: options[:role] == 'admin', moderator: options[:role] == 'moderator', confirmed_at: options[:confirmed] ? Time.now.utc : nil) + user = User.new(email: options[:email], password: password, agreement: true, approved: true, admin: options[:role] == 'admin', moderator: options[:role] == 'moderator', confirmed_at: options[:confirmed] ? Time.now.utc : nil) if options[:reattach] account = Account.find_local(username) || Account.new(username: username) @@ -115,6 +115,7 @@ module Mastodon option :enable, type: :boolean option :disable, type: :boolean option :disable_2fa, type: :boolean + option :approve, type: :boolean desc 'modify USERNAME', 'Modify a user' long_desc <<-LONG_DESC Modify a user account. @@ -128,6 +129,9 @@ module Mastodon With the --disable option, lock the user out of their account. The --enable option is the opposite. + With the --approve option, the account will be approved, if it was + previously not due to not having open registrations. + With the --disable-2fa option, the two-factor authentication requirement for the user can be removed. LONG_DESC @@ -147,6 +151,7 @@ module Mastodon user.email = options[:email] if options[:email] user.disabled = false if options[:enable] user.disabled = true if options[:disable] + user.approved = true if options[:approve] user.otp_required_for_login = false if options[:disable_2fa] user.confirm if options[:confirm] diff --git a/lib/mastodon/cache_cli.rb b/lib/mastodon/cache_cli.rb new file mode 100644 index 000000000..e9b6667b3 --- /dev/null +++ b/lib/mastodon/cache_cli.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require_relative '../../config/boot' +require_relative '../../config/environment' +require_relative 'cli_helper' + +module Mastodon + class CacheCLI < Thor + def self.exit_on_failure? + true + end + + desc 'clear', 'Clear out the cache storage' + def clear + Rails.cache.clear + say('OK', :green) + end + end +end diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 8172aeb94..5ea569b29 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -13,7 +13,7 @@ module Mastodon end def patch - 0 + 1 end def pre @@ -46,7 +46,7 @@ module Mastodon # specify git tag or commit hash here def source_tag - nil + ENV.fetch('SOURCE_TAG') { nil } end def source_url diff --git a/lib/paperclip/blurhash_transcoder.rb b/lib/paperclip/blurhash_transcoder.rb new file mode 100644 index 000000000..08925a6dd --- /dev/null +++ b/lib/paperclip/blurhash_transcoder.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Paperclip + class BlurhashTranscoder < Paperclip::Processor + def make + return @file unless options[:style] == :small + + pixels = convert(':source RGB:-', source: File.expand_path(@file.path)).unpack('C*') + geometry = options.fetch(:file_geometry_parser).from_file(@file) + + attachment.instance.blurhash = Blurhash.encode(geometry.width, geometry.height, pixels, options[:blurhash] || {}) + + @file + end + end +end |