Merge tag 'v3.1.2' into hometown-dev
This commit is contained in:
@ -9,7 +9,7 @@ class AccountsController < ApplicationController
|
||||
before_action :set_cache_headers
|
||||
before_action :set_body_classes
|
||||
|
||||
skip_around_action :set_locale, if: -> { [:json, :rss].include?(request.format) }
|
||||
skip_around_action :set_locale, if: -> { [:json, :rss].include?(request.format&.to_sym) }
|
||||
skip_before_action :require_functional!
|
||||
|
||||
def show
|
||||
|
@ -11,7 +11,7 @@ class Api::V1::AnnouncementsController < Api::BaseController
|
||||
end
|
||||
|
||||
def dismiss
|
||||
AnnouncementMute.create!(account: current_account, announcement: @announcement)
|
||||
AnnouncementMute.find_or_create_by!(account: current_account, announcement: @announcement)
|
||||
render_empty
|
||||
end
|
||||
|
||||
|
@ -5,35 +5,28 @@ class Api::V1::Statuses::BookmarksController < Api::BaseController
|
||||
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:bookmarks' }
|
||||
before_action :require_user!
|
||||
before_action :set_status
|
||||
|
||||
respond_to :json
|
||||
|
||||
def create
|
||||
@status = bookmarked_status
|
||||
current_account.bookmarks.find_or_create_by!(account: current_account, status: @status)
|
||||
render json: @status, serializer: REST::StatusSerializer
|
||||
end
|
||||
|
||||
def destroy
|
||||
@status = requested_status
|
||||
@bookmarks_map = { @status.id => false }
|
||||
bookmark = current_account.bookmarks.find_by(status: @status)
|
||||
bookmark&.destroy!
|
||||
|
||||
bookmark = Bookmark.find_by!(account: current_user.account, status: @status)
|
||||
bookmark.destroy!
|
||||
|
||||
render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, bookmarks_map: @bookmarks_map)
|
||||
render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_account.id, bookmarks_map: { @status.id => false })
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def bookmarked_status
|
||||
authorize_with current_user.account, requested_status, :show?
|
||||
|
||||
bookmark = Bookmark.find_or_create_by!(account: current_user.account, status: requested_status)
|
||||
|
||||
bookmark.status.reload
|
||||
end
|
||||
|
||||
def requested_status
|
||||
Status.find(params[:status_id])
|
||||
def set_status
|
||||
@status = Status.find(params[:status_id])
|
||||
authorize @status, :show?
|
||||
rescue Mastodon::NotPermittedError
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
@ -69,8 +69,7 @@ class Api::V1::Statuses::FavouritedByAccountsController < Api::BaseController
|
||||
@status = Status.find(params[:status_id])
|
||||
authorize @status, :show?
|
||||
rescue Mastodon::NotPermittedError
|
||||
# Reraise in order to get a 404 instead of a 403 error code
|
||||
raise ActiveRecord::RecordNotFound
|
||||
not_found
|
||||
end
|
||||
|
||||
def pagination_params(core_params)
|
||||
|
@ -5,34 +5,26 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController
|
||||
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:favourites' }
|
||||
before_action :require_user!
|
||||
before_action :set_status
|
||||
|
||||
respond_to :json
|
||||
|
||||
def create
|
||||
@status = favourited_status
|
||||
FavouriteService.new.call(current_account, @status)
|
||||
render json: @status, serializer: REST::StatusSerializer
|
||||
end
|
||||
|
||||
def destroy
|
||||
@status = requested_status
|
||||
@favourites_map = { @status.id => false }
|
||||
|
||||
UnfavouriteWorker.perform_async(current_user.account_id, @status.id)
|
||||
|
||||
render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, favourites_map: @favourites_map)
|
||||
UnfavouriteWorker.perform_async(current_account.id, @status.id)
|
||||
render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_account.id, favourites_map: { @status.id => false })
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def favourited_status
|
||||
service_result.status.reload
|
||||
end
|
||||
|
||||
def service_result
|
||||
FavouriteService.new.call(current_user.account, requested_status)
|
||||
end
|
||||
|
||||
def requested_status
|
||||
Status.find(params[:status_id])
|
||||
def set_status
|
||||
@status = Status.find(params[:status_id])
|
||||
authorize @status, :show?
|
||||
rescue Mastodon::NotPermittedError
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
@ -66,8 +66,7 @@ class Api::V1::Statuses::RebloggedByAccountsController < Api::BaseController
|
||||
@status = Status.find(params[:status_id])
|
||||
authorize @status, :show?
|
||||
rescue Mastodon::NotPermittedError
|
||||
# Reraise in order to get a 404 instead of a 403 error code
|
||||
raise ActiveRecord::RecordNotFound
|
||||
not_found
|
||||
end
|
||||
|
||||
def pagination_params(core_params)
|
||||
|
@ -5,33 +5,34 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController
|
||||
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:statuses' }
|
||||
before_action :require_user!
|
||||
before_action :set_reblog
|
||||
|
||||
respond_to :json
|
||||
|
||||
def create
|
||||
@status = ReblogService.new.call(current_user.account, status_for_reblog, reblog_params)
|
||||
@status = ReblogService.new.call(current_account, @reblog, reblog_params)
|
||||
render json: @status, serializer: REST::StatusSerializer
|
||||
end
|
||||
|
||||
def destroy
|
||||
@status = status_for_destroy.reblog
|
||||
@reblogs_map = { @status.id => false }
|
||||
@status = current_account.statuses.find_by(reblog_of_id: @reblog.id)
|
||||
|
||||
authorize status_for_destroy, :unreblog?
|
||||
status_for_destroy.discard
|
||||
RemovalWorker.perform_async(status_for_destroy.id)
|
||||
if @status
|
||||
authorize @status, :unreblog?
|
||||
@status.discard
|
||||
RemovalWorker.perform_async(@status.id)
|
||||
end
|
||||
|
||||
render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, reblogs_map: @reblogs_map)
|
||||
render json: @reblog, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_account.id, reblogs_map: { @reblog.id => false })
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def status_for_reblog
|
||||
Status.find params[:status_id]
|
||||
end
|
||||
|
||||
def status_for_destroy
|
||||
@status_for_destroy ||= current_user.account.statuses.where(reblog_of_id: params[:status_id]).first!
|
||||
def set_reblog
|
||||
@reblog = Status.find(params[:status_id])
|
||||
authorize @reblog, :show?
|
||||
rescue Mastodon::NotPermittedError
|
||||
not_found
|
||||
end
|
||||
|
||||
def reblog_params
|
||||
|
@ -41,7 +41,6 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
||||
|
||||
resource.locale = I18n.locale
|
||||
resource.invite_code = params[:invite_code] if resource.invite_code.blank?
|
||||
resource.agreement = true
|
||||
resource.current_sign_in_ip = request.remote_ip
|
||||
|
||||
resource.build_account if resource.account.nil?
|
||||
@ -49,7 +48,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
||||
|
||||
def configure_sign_up_params
|
||||
devise_parameter_sanitizer.permit(:sign_up) do |u|
|
||||
u.permit({ account_attributes: [:username], invite_request_attributes: [:text] }, :email, :password, :password_confirmation, :invite_code)
|
||||
u.permit({ account_attributes: [:username], invite_request_attributes: [:text] }, :email, :password, :password_confirmation, :invite_code, :agreement)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -6,6 +6,7 @@ import assign from 'object-assign';
|
||||
import values from 'object.values';
|
||||
import isNaN from 'is-nan';
|
||||
import { decode as decodeBase64 } from './utils/base64';
|
||||
import promiseFinally from 'promise.prototype.finally';
|
||||
|
||||
if (!Array.prototype.includes) {
|
||||
includes.shim();
|
||||
@ -23,6 +24,8 @@ if (!Number.isNaN) {
|
||||
Number.isNaN = isNaN;
|
||||
}
|
||||
|
||||
promiseFinally.shim();
|
||||
|
||||
if (!HTMLCanvasElement.prototype.toBlob) {
|
||||
const BASE64_MARKER = ';base64,';
|
||||
|
||||
|
@ -2,6 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { version, source_url } from 'mastodon/initial_state';
|
||||
import StackTrace from 'stacktrace-js';
|
||||
|
||||
export default class ErrorBoundary extends React.PureComponent {
|
||||
|
||||
@ -11,24 +12,42 @@ export default class ErrorBoundary extends React.PureComponent {
|
||||
|
||||
state = {
|
||||
hasError: false,
|
||||
errorMessage: undefined,
|
||||
stackTrace: undefined,
|
||||
mappedStackTrace: undefined,
|
||||
componentStack: undefined,
|
||||
};
|
||||
|
||||
componentDidCatch (error, info) {
|
||||
this.setState({
|
||||
hasError: true,
|
||||
errorMessage: error.toString(),
|
||||
stackTrace: error.stack,
|
||||
componentStack: info && info.componentStack,
|
||||
copied: false,
|
||||
mappedStackTrace: undefined,
|
||||
});
|
||||
|
||||
StackTrace.fromError(error).then((stackframes) => {
|
||||
this.setState({
|
||||
mappedStackTrace: stackframes.map((sf) => sf.toString()).join('\n'),
|
||||
});
|
||||
}).catch(() => {
|
||||
this.setState({
|
||||
mappedStackTrace: undefined,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
handleCopyStackTrace = () => {
|
||||
const { stackTrace } = this.state;
|
||||
const { errorMessage, stackTrace, mappedStackTrace } = this.state;
|
||||
const textarea = document.createElement('textarea');
|
||||
|
||||
textarea.textContent = stackTrace;
|
||||
let contents = [errorMessage, stackTrace];
|
||||
if (mappedStackTrace) {
|
||||
contents.push(mappedStackTrace);
|
||||
}
|
||||
|
||||
textarea.textContent = contents.join('\n\n\n');
|
||||
textarea.style.position = 'fixed';
|
||||
|
||||
document.body.appendChild(textarea);
|
||||
|
@ -18,7 +18,8 @@ function loadPolyfills() {
|
||||
Number.isNaN &&
|
||||
Object.assign &&
|
||||
Object.values &&
|
||||
window.Symbol
|
||||
window.Symbol &&
|
||||
Promise.prototype.finally
|
||||
);
|
||||
|
||||
// Latest version of Firefox and Safari do not have IntersectionObserver.
|
||||
|
@ -12,7 +12,7 @@ function main() {
|
||||
if (window.history && history.replaceState) {
|
||||
const { pathname, search, hash } = window.location;
|
||||
const path = pathname + search + hash;
|
||||
if (!(/^\/web[$/]/).test(path)) {
|
||||
if (!(/^\/web($|\/)/).test(path)) {
|
||||
history.replaceState(null, document.title, `/web${path}`);
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,10 @@ class ActivityPub::ProcessAccountService < BaseService
|
||||
|
||||
RedisLock.acquire(lock_options) do |lock|
|
||||
if lock.acquired?
|
||||
@account = Account.find_remote(@username, @domain)
|
||||
@old_public_key = @account&.public_key
|
||||
@old_protocol = @account&.protocol
|
||||
@account = Account.remote.find_by(uri: @uri) if @options[:only_key]
|
||||
@account ||= Account.find_remote(@username, @domain)
|
||||
@old_public_key = @account&.public_key
|
||||
@old_protocol = @account&.protocol
|
||||
|
||||
create_account if @account.nil?
|
||||
update_account
|
||||
|
@ -66,6 +66,8 @@ class BackupService < BaseService
|
||||
def dump_media_attachments!(tar)
|
||||
MediaAttachment.attached.where(account: account).reorder(nil).find_in_batches do |media_attachments|
|
||||
media_attachments.each do |m|
|
||||
next unless m.file&.path
|
||||
|
||||
download_to_tar(tar, m.file, m.file.path)
|
||||
end
|
||||
|
||||
|
@ -18,14 +18,13 @@ class FollowService < BaseService
|
||||
if source_account.following?(target_account)
|
||||
# We're already following this account, but we'll call follow! again to
|
||||
# make sure the reblogs status is set correctly.
|
||||
source_account.follow!(target_account, reblogs: reblogs)
|
||||
return
|
||||
return source_account.follow!(target_account, reblogs: reblogs)
|
||||
elsif source_account.requested?(target_account)
|
||||
# This isn't managed by a method in AccountInteractions, so we modify it
|
||||
# ourselves if necessary.
|
||||
req = source_account.follow_requests.find_by(target_account: target_account)
|
||||
req.update!(show_reblogs: reblogs)
|
||||
return
|
||||
return req
|
||||
end
|
||||
|
||||
ActivityTracker.increment('activity:interactions')
|
||||
|
@ -99,7 +99,7 @@ class ResolveAccountService < BaseService
|
||||
if lock.acquired?
|
||||
@account = Account.find_remote(@username, @domain)
|
||||
|
||||
next if (@account.present? && !@account.activitypub?) || actor_json.nil?
|
||||
next if actor_json.nil?
|
||||
|
||||
@account = ActivityPub::ProcessAccountService.new.call(@username, @domain, actor_json)
|
||||
else
|
||||
|
@ -27,9 +27,9 @@
|
||||
= fa_icon 'check'
|
||||
= Formatter.instance.format_field(account, field.value, custom_emojify: true)
|
||||
|
||||
- if account.note.present?
|
||||
%div
|
||||
.account__header__content.emojify= Formatter.instance.simplified_format(account, custom_emojify: true)
|
||||
- if account.note.present?
|
||||
%div
|
||||
.account__header__content.emojify= Formatter.instance.simplified_format(account, custom_emojify: true)
|
||||
|
||||
.dashboard__counters{ style: 'margin-top: 10px' }
|
||||
%div
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
- if approved_registrations? && !@invite.present?
|
||||
.fields-group
|
||||
= f.simple_fields_for :invite_request do |invite_request_fields|
|
||||
= f.simple_fields_for :invite_request, resource.invite_request || resource.build_invite_request do |invite_request_fields|
|
||||
= invite_request_fields.input :text, as: :text, wrapper: :with_block_label, required: false
|
||||
|
||||
= f.input :invite_code, as: :hidden
|
||||
|
@ -10,6 +10,12 @@
|
||||
%strong
|
||||
= t('authorize_follow.already_following')
|
||||
|
||||
= render 'post_follow_actions'
|
||||
- elsif current_account.requested?(@resource)
|
||||
.flash-message
|
||||
%strong
|
||||
= t('authorize_follow.already_requested')
|
||||
|
||||
= render 'post_follow_actions'
|
||||
- else
|
||||
= form_tag authorize_interaction_path, method: :post, class: 'simple_form' do
|
||||
|
Reference in New Issue
Block a user