Merge commit '1cdcd9dc08c91321f80ffe4822f6a3da15abeb2c' into glitch-soc/merge-upstream
Conflicts: - `app/javascript/packs/public.jsx`: Upstream updated code that we actually moved to `app/javascript/core/settings.js`. Applied the changes there.
This commit is contained in:
29
app/controllers/api/v1/profiles_controller.rb
Normal file
29
app/controllers/api/v1/profiles_controller.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::ProfilesController < Api::BaseController
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }
|
||||
before_action :require_user!
|
||||
before_action :set_image
|
||||
before_action :validate_image_param
|
||||
|
||||
def destroy
|
||||
@account = current_account
|
||||
UpdateAccountService.new.call(@account, { @image => nil }, raise_error: true)
|
||||
ActivityPub::UpdateDistributionWorker.perform_async(@account.id)
|
||||
render json: @account, serializer: REST::CredentialAccountSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_image
|
||||
@image = params[:image]
|
||||
end
|
||||
|
||||
def validate_image_param
|
||||
raise(Mastodon::InvalidParameterError, 'Image must be either "avatar" or "header"') unless valid_image?
|
||||
end
|
||||
|
||||
def valid_image?
|
||||
%w(avatar header).include?(@image)
|
||||
end
|
||||
end
|
@@ -18,22 +18,14 @@ delegate(document, '#account_display_name', 'input', ({ target }) => {
|
||||
}
|
||||
});
|
||||
|
||||
delegate(document, '#account_avatar', 'change', ({ target }) => {
|
||||
const avatar = document.querySelector('.card .avatar img');
|
||||
delegate(document, '#edit_profile input[type=file]', 'change', ({ target }) => {
|
||||
const avatar = document.getElementById(target.id + '-preview');
|
||||
const [file] = target.files || [];
|
||||
const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc;
|
||||
|
||||
avatar.src = url;
|
||||
});
|
||||
|
||||
delegate(document, '#account_header', 'change', ({ target }) => {
|
||||
const header = document.querySelector('.card .card__img img');
|
||||
const [file] = target.files || [];
|
||||
const url = file ? URL.createObjectURL(file) : header.dataset.originalSrc;
|
||||
|
||||
header.src = url;
|
||||
});
|
||||
|
||||
delegate(document, '#account_locked', 'change', ({ target }) => {
|
||||
const lock = document.querySelector('.card .display-name i');
|
||||
|
||||
|
@@ -309,9 +309,19 @@ code {
|
||||
border-radius: 4px;
|
||||
background: url('images/void.png');
|
||||
|
||||
&[src$='missing.png'] {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&#account_avatar-preview {
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -35,10 +35,10 @@
|
||||
.fields-group
|
||||
= f.input :avatar, wrapper: :with_block_label, input_html: { accept: AccountAvatar::IMAGE_MIME_TYPES.join(',') }, hint: t('simple_form.hints.defaults.avatar', dimensions: '400x400', size: number_to_human_size(AccountAvatar::LIMIT))
|
||||
|
||||
- if @account.avatar.present?
|
||||
.fields-row__column.fields-row__column-6
|
||||
.fields-group
|
||||
= image_tag @account.avatar.url, class: 'fields-group__thumbnail', width: 90, height: 90
|
||||
.fields-row__column.fields-row__column-6
|
||||
.fields-group
|
||||
= image_tag @account.avatar.url, class: 'fields-group__thumbnail', id: 'account_avatar-preview'
|
||||
- if @account.avatar.present?
|
||||
= link_to settings_profile_picture_path('avatar'), data: { method: :delete }, class: 'link-button link-button--destructive' do
|
||||
= fa_icon 'trash fw'
|
||||
= t('generic.delete')
|
||||
@@ -48,10 +48,10 @@
|
||||
.fields-group
|
||||
= f.input :header, wrapper: :with_block_label, input_html: { accept: AccountHeader::IMAGE_MIME_TYPES.join(',') }, hint: t('simple_form.hints.defaults.header', dimensions: '1500x500', size: number_to_human_size(AccountHeader::LIMIT))
|
||||
|
||||
- if @account.header.present?
|
||||
.fields-row__column.fields-row__column-6
|
||||
.fields-group
|
||||
= image_tag @account.header.url, class: 'fields-group__thumbnail'
|
||||
.fields-row__column.fields-row__column-6
|
||||
.fields-group
|
||||
= image_tag @account.header.url, class: 'fields-group__thumbnail', id: 'account_header-preview'
|
||||
- if @account.header.present?
|
||||
= link_to settings_profile_picture_path('header'), data: { method: :delete }, class: 'link-button link-button--destructive' do
|
||||
= fa_icon 'trash fw'
|
||||
= t('generic.delete')
|
||||
|
Reference in New Issue
Block a user