diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-03-30 13:40:10 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-03-30 13:40:10 +0200 |
commit | 51a297e1287a9b2dd3b2d2b19433820e996779db (patch) | |
tree | d1bb823de4bff3ee9676835dc3e7614ed66deb65 /app/controllers/api | |
parent | eaea849035ea407afb2d5db411dbddc1ccca6f44 (diff) | |
parent | 2cc7ba26715c9f3fcc81ee5d30b282b1493a2e0b (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/controllers/api')
-rw-r--r-- | app/controllers/api/v1/admin/accounts_controller.rb | 16 | ||||
-rw-r--r-- | app/controllers/api/v2/admin/accounts_controller.rb | 31 |
2 files changed, 46 insertions, 1 deletions
diff --git a/app/controllers/api/v1/admin/accounts_controller.rb b/app/controllers/api/v1/admin/accounts_controller.rb index 65330b8c8..4b6dab208 100644 --- a/app/controllers/api/v1/admin/accounts_controller.rb +++ b/app/controllers/api/v1/admin/accounts_controller.rb @@ -104,13 +104,27 @@ class Api::V1::Admin::AccountsController < Api::BaseController end def filtered_accounts - AccountFilter.new(filter_params).results + AccountFilter.new(translated_filter_params).results end def filter_params params.permit(*FILTER_PARAMS) end + def translated_filter_params + translated_params = { origin: 'local', status: 'active' }.merge(filter_params.slice(*AccountFilter::KEYS)) + + translated_params[:origin] = 'remote' if params[:remote].present? + + %i(active pending disabled silenced suspended).each do |status| + translated_params[:status] = status.to_s if params[status].present? + end + + translated_params[:permissions] = 'staff' if params[:staff].present? + + translated_params + end + def insert_pagination_headers set_pagination_headers(next_path, prev_path) end diff --git a/app/controllers/api/v2/admin/accounts_controller.rb b/app/controllers/api/v2/admin/accounts_controller.rb new file mode 100644 index 000000000..a89e6835e --- /dev/null +++ b/app/controllers/api/v2/admin/accounts_controller.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class Api::V2::Admin::AccountsController < Api::V1::Admin::AccountsController + FILTER_PARAMS = %i( + origin + status + permissions + username + by_domain + display_name + email + ip + invited_by + ).freeze + + PAGINATION_PARAMS = (%i(limit) + FILTER_PARAMS).freeze + + private + + def filtered_accounts + AccountFilter.new(filter_params).results + end + + def filter_params + params.permit(*FILTER_PARAMS) + end + + def pagination_params(core_params) + params.slice(*PAGINATION_PARAMS).permit(*PAGINATION_PARAMS).merge(core_params) + end +end |