You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

# frozen_string_literal: true
class Api::V1::Accounts::CredentialsController < Api::BaseController
before_action -> { doorkeeper_authorize! :read, :'read:accounts' }, except: [:update]
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, only: [:update]
before_action :require_user!
def show
@account = current_account
render json: @account, serializer: REST::CredentialAccountSerializer
end
def update
@account = current_account
UpdateAccountService.new.call(@account, account_params, raise_error: true)
current_user.update(user_params) if user_params
ActivityPub::UpdateDistributionWorker.perform_async(@account.id)
render json: @account, serializer: REST::CredentialAccountSerializer
end
private
def account_params
params.permit(
:display_name,
:note,
:avatar,
:header,
:locked,
:bot,
:discoverable,
:hide_collections,
fields_attributes: [:name, :value]
)
end
def user_params
return nil if params[:source].blank?
source_params = params.require(:source)
{
settings_attributes: {
default_privacy: source_params.fetch(:privacy, @account.user.setting_default_privacy),
default_sensitive: source_params.fetch(:sensitive, @account.user.setting_default_sensitive),
default_language: source_params.fetch(:language, @account.user.setting_default_language),
Merge tag 'v4.2.0-beta1' into lets-bump-hometown-to-mastodon-4.2 - cli: followed upstream - version.rb: followed upstream, since we can use environment variables for the suffix now - lib/paperclip: chose their spoof detector - lib/sanitize: merged h1-h6 into supported elements, allowed translated attribute - config/environments: follow upstream - config/initializers: follow upstream - config/application.rb: follow upstream - config/locales: translations with %{title} prefix were replaced with hardcoded "Mastodon:" prefixes, should be fixed afterwards it's inconsistent anyway right now - config/settings: removed settings that were removed in upstream - config/routes: followed upstream, due to API restructurings. Is there some hometown-specific API stuff that might be missing now? - spec/: followed upstream, might have lost hometown-specific tests, but I haven't found any on a quick check - .ruby-version, Gemfile, etc.: upstream - .github/workflows: upstream - about: followed upstream, therefore the static homepage is gone :/ - credentials: moved federation into the settings_attributes - lists: follow upstream, `:is_exclusive` -> `:exclusive` - statuses: keep local only - account_statuses_filter: still hide local only posts for anonymous users - activitypub/activity/create: - keep activity_pub_type in params - text: use hometown's way for determining the content - spoiler: use hometown's mechanism - feed_manager: use upstream exclusive list mechanism - plain_text_formatter: use upstream way with html decoding, as I'm not sure whether we still have the Nokogiri library(?) available problem: might remove tags that we want to keep? - text_formatter: follow upstream - account: use upstream MENTION_RE expression - backup: follow upstream for permission validation - list: follow upstream, is_exclusive -> exclusive !! WE MIGHT NEED A MIGRATION! - status: moved set_locality hook to the others - user: delegates for settings (federation, autoplay, etc.) were removed upstream, follow them - webhook: follow upstream - initial_state_serializer: keep max_toot_chars - list_serializer: follow rename of is_exclusive -> exclusive Use upstream version, since the translation API got upgraded to v2. Use upstream version of vote_validator. - admin/webhooks/_form: add group for template - settings/preferences/appearance/show: add new input for 'expand_usernames' check: missing translations, especially for hints - settings/preferences/other/show: added input groups for no_rss and default_privacy check: missing translations, especially for hints - settigngs/profiles: upstream removed verification banner, follow them Followed upstream changes. Incorporated upstream changes and put the local_only check back in the correct place. Ignored hometown changes, take upstream version. - actions/lists: follow exclusive list naming - components/column_back_button: follow upstream router refactoring - components/column_header: follow upstream router refactoring - components/hashtag: keep hometown behaviour, add href to links - components/media_gallery: merge alt text indicator into upstream - components/status: merge timestamp click -> original page - components/status_action_bar: upstream removed the share button, follow them - components/status_content: - still make remote usernames => check: does the new href work? - make translate button always visible like upstream - keep hometown-specific changes for Articles and other posts - features/header: keep header link - features/account_gallery/components/media_item: keep link - features/audio/index: keep no media description indicator, merge upstream styles - features/compose/components/compose_form: - merge max chars logic - merge federation dropdown - features/compose/components/navigation_bar: keep href to profile - features/compose/components/poll_form: keep "is multiple" toggle - features/compose/index: keep column header - features/follow_requests/components/account_authorize: keep external link - features/list_editor/components/edit_list_form: overwritten from upstream - features/list_timeline/index: overwritten from upstream - features/components/follow_request: keep external link - features/components/notification: keep external link - features/picture_in_picture/components/footer: keep external link - features/status/components/detailed_status: keep external link - features/ui/components/boost_modal: keep external link - features/ui/index: merge upstream changes - features/video/: keep no media description indicator - containers/status_container: overwrite with upstream - locales: best-effort merge, but I wouldn't trust it. should be normalized in some way.
2 years ago
default_federation: source_params.fetch(:federation, @account.user.setting_default_federation),
},
}
end
end