Skip to content

Commit

Permalink
Change automatic post deletion configuration to be accessible to redi…
Browse files Browse the repository at this point in the history
…rected users (mastodon#20774)

Fixes mastodon#20550
  • Loading branch information
ClearlyClaire authored Nov 17, 2022
1 parent 7955d4b commit 00b2720
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/controllers/statuses_cleanup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def update
# Do nothing
end

def require_functional!
redirect_to edit_user_registration_path unless current_user.functional_or_moved?
end

private

def set_policy
Expand Down
6 changes: 5 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ def active_for_authentication?
end

def functional?
confirmed? && approved? && !disabled? && !account.suspended? && !account.memorial? && account.moved_to_account_id.nil?
functional_or_moved? && account.moved_to_account_id.nil?
end

def functional_or_moved?
confirmed? && approved? && !disabled? && !account.suspended? && !account.memorial?
end

def unconfirmed?
Expand Down
2 changes: 1 addition & 1 deletion config/navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

n.item :relationships, safe_join([fa_icon('users fw'), t('settings.relationships')]), relationships_path, if: -> { current_user.functional? }
n.item :filters, safe_join([fa_icon('filter fw'), t('filters.index.title')]), filters_path, highlights_on: %r{/filters}, if: -> { current_user.functional? }
n.item :statuses_cleanup, safe_join([fa_icon('history fw'), t('settings.statuses_cleanup')]), statuses_cleanup_path, if: -> { current_user.functional? }
n.item :statuses_cleanup, safe_join([fa_icon('history fw'), t('settings.statuses_cleanup')]), statuses_cleanup_path, if: -> { current_user.functional_or_moved? }

n.item :security, safe_join([fa_icon('lock fw'), t('settings.account')]), edit_user_registration_path do |s|
s.item :password, safe_join([fa_icon('lock fw'), t('settings.account_settings')]), edit_user_registration_path, highlights_on: %r{/auth/edit|/settings/delete|/settings/migration|/settings/aliases|/settings/login_activities|^/disputes}
Expand Down

0 comments on commit 00b2720

Please sign in to comment.