diff options
author | Starfall <us@starfall.systems> | 2022-08-26 18:09:33 -0500 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2022-08-26 18:09:33 -0500 |
commit | b581e6b6d4a5ba9ed4ae17427b7f2d5d158be4e5 (patch) | |
tree | 06c3f6859d5cee4794d678a0aa57d15c31036ce4 /lib | |
parent | 3871928aa4f660cdf1a0c451ac3396052b59ddea (diff) | |
parent | 978dd7e73c911441503ff803ffdce544ce50a33d (diff) |
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mastodon/accounts_cli.rb | 4 | ||||
-rw-r--r-- | lib/mastodon/media_cli.rb | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/mastodon/accounts_cli.rb b/lib/mastodon/accounts_cli.rb index 29c934453..558f4d3c4 100644 --- a/lib/mastodon/accounts_cli.rb +++ b/lib/mastodon/accounts_cli.rb @@ -57,7 +57,7 @@ module Mastodon option :role option :reattach, type: :boolean option :force, type: :boolean - desc 'create USERNAME', 'Create a new user' + desc 'create USERNAME', 'Create a new user account' long_desc <<-LONG_DESC Create a new user account with a given USERNAME and an e-mail address provided with --email. @@ -133,7 +133,7 @@ module Mastodon option :disable_2fa, type: :boolean option :approve, type: :boolean option :reset_password, type: :boolean - desc 'modify USERNAME', 'Modify a user' + desc 'modify USERNAME', 'Modify a user account' long_desc <<-LONG_DESC Modify a user account. diff --git a/lib/mastodon/media_cli.rb b/lib/mastodon/media_cli.rb index 36ca71844..4904cc5eb 100644 --- a/lib/mastodon/media_cli.rb +++ b/lib/mastodon/media_cli.rb @@ -187,6 +187,7 @@ module Mastodon option :account, type: :string option :domain, type: :string option :status, type: :numeric + option :days, type: :numeric option :concurrency, type: :numeric, default: 5, aliases: [:c] option :verbose, type: :boolean, default: false, aliases: [:v] option :dry_run, type: :boolean, default: false @@ -204,6 +205,8 @@ module Mastodon Use the --domain option to download attachments from a specific domain. + Use the --days option to limit attachments created within days. + By default, attachments that are believed to be already downloaded will not be re-downloaded. To force re-download of every URL, use --force. DESC @@ -224,10 +227,16 @@ module Mastodon scope = MediaAttachment.where(account_id: account.id) elsif options[:domain] scope = MediaAttachment.joins(:account).merge(Account.by_domain_and_subdomains(options[:domain])) + elsif options[:days].present? + scope = MediaAttachment.remote else exit(1) end + if options[:days].present? + scope = scope.where('id > ?', Mastodon::Snowflake.id_at(options[:days].days.ago, with_random: false)) + end + processed, aggregate = parallelize_with_progress(scope) do |media_attachment| next if media_attachment.remote_url.blank? || (!options[:force] && media_attachment.file_file_name.present?) next if DomainBlock.reject_media?(media_attachment.account.domain) |