mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-11 14:30:35 +00:00
Merge remote-tracking branch 'upstream/stable-4.3' into glitch-soc/merge-4.3
This commit is contained in:
@@ -96,11 +96,16 @@ export const ensureComposeIsVisible = (getState) => {
|
||||
};
|
||||
|
||||
export function setComposeToStatus(status, text, spoiler_text) {
|
||||
return{
|
||||
type: COMPOSE_SET_STATUS,
|
||||
status,
|
||||
text,
|
||||
spoiler_text,
|
||||
return (dispatch, getState) => {
|
||||
const maxOptions = getState().server.getIn(['server', 'configuration', 'polls', 'max_options']);
|
||||
|
||||
dispatch({
|
||||
type: COMPOSE_SET_STATUS,
|
||||
status,
|
||||
text,
|
||||
spoiler_text,
|
||||
maxOptions,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -90,10 +90,15 @@ export function fetchStatusFail(id, error, skipLoading) {
|
||||
}
|
||||
|
||||
export function redraft(status, raw_text) {
|
||||
return {
|
||||
type: REDRAFT,
|
||||
status,
|
||||
raw_text,
|
||||
return (dispatch, getState) => {
|
||||
const maxOptions = getState().server.getIn(['server', 'configuration', 'polls', 'max_options']);
|
||||
|
||||
dispatch({
|
||||
type: REDRAFT,
|
||||
status,
|
||||
raw_text,
|
||||
maxOptions,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { apiRequestPost } from 'mastodon/api';
|
||||
import type { Status, StatusVisibility } from 'mastodon/models/status';
|
||||
import type { ApiStatusJSON } from 'mastodon/api_types/statuses';
|
||||
import type { StatusVisibility } from 'mastodon/models/status';
|
||||
|
||||
export const apiReblog = (statusId: string, visibility: StatusVisibility) =>
|
||||
apiRequestPost<{ reblog: Status }>(`v1/statuses/${statusId}/reblog`, {
|
||||
apiRequestPost<{ reblog: ApiStatusJSON }>(`v1/statuses/${statusId}/reblog`, {
|
||||
visibility,
|
||||
});
|
||||
|
||||
export const apiUnreblog = (statusId: string) =>
|
||||
apiRequestPost<Status>(`v1/statuses/${statusId}/unreblog`);
|
||||
apiRequestPost<ApiStatusJSON>(`v1/statuses/${statusId}/unreblog`);
|
||||
|
||||
@@ -504,8 +504,13 @@ export default function compose(state = initialState, action) {
|
||||
}
|
||||
|
||||
if (action.status.get('poll')) {
|
||||
let options = ImmutableList(action.status.get('poll').options.map(x => x.title));
|
||||
if (options.size < action.maxOptions) {
|
||||
options = options.push('');
|
||||
}
|
||||
|
||||
map.set('poll', ImmutableMap({
|
||||
options: action.status.getIn(['poll', 'options']).map(x => x.get('title')),
|
||||
options: options,
|
||||
multiple: action.status.getIn(['poll', 'multiple']),
|
||||
expires_in: expiresInFromExpiresAt(action.status.getIn(['poll', 'expires_at'])),
|
||||
}));
|
||||
@@ -533,8 +538,13 @@ export default function compose(state = initialState, action) {
|
||||
}
|
||||
|
||||
if (action.status.get('poll')) {
|
||||
let options = ImmutableList(action.status.get('poll').options.map(x => x.title));
|
||||
if (options.size < action.maxOptions) {
|
||||
options = options.push('');
|
||||
}
|
||||
|
||||
map.set('poll', ImmutableMap({
|
||||
options: action.status.getIn(['poll', 'options']).map(x => x.get('title')),
|
||||
options: options,
|
||||
multiple: action.status.getIn(['poll', 'multiple']),
|
||||
expires_in: expiresInFromExpiresAt(action.status.getIn(['poll', 'expires_at'])),
|
||||
}));
|
||||
|
||||
@@ -100,6 +100,8 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||
@status.ordered_media_attachment_ids = @next_media_attachments.map(&:id)
|
||||
|
||||
@media_attachments_changed = true if @status.ordered_media_attachment_ids != previous_media_attachments_ids
|
||||
|
||||
@status.media_attachments.reload if @media_attachments_changed
|
||||
end
|
||||
|
||||
def download_media_files!
|
||||
|
||||
@@ -21,8 +21,9 @@ class Scheduler::SelfDestructScheduler
|
||||
|
||||
def sidekiq_overwhelmed?
|
||||
redis_mem_info = Sidekiq.redis_info
|
||||
maxmemory = [redis_mem_info['maxmemory'].to_f, redis_mem_info['total_system_memory'].to_f].filter(&:positive?).min
|
||||
|
||||
Sidekiq::Stats.new.enqueued > MAX_ENQUEUED || redis_mem_info['used_memory'].to_f > redis_mem_info['total_system_memory'].to_f * MAX_REDIS_MEM_USAGE
|
||||
Sidekiq::Stats.new.enqueued > MAX_ENQUEUED || redis_mem_info['used_memory'].to_f > maxmemory * MAX_REDIS_MEM_USAGE
|
||||
end
|
||||
|
||||
def delete_accounts!
|
||||
|
||||
@@ -343,6 +343,42 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when originally without media attachments and text is removed' do
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/foo.png').to_return(body: attachment_fixture('emojo.png'))
|
||||
end
|
||||
|
||||
let(:payload) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: 'foo',
|
||||
type: 'Note',
|
||||
content: '',
|
||||
updated: '2021-09-08T22:39:25Z',
|
||||
attachment: [
|
||||
{ type: 'Image', mediaType: 'image/png', url: 'https://example.com/foo.png' },
|
||||
],
|
||||
}
|
||||
end
|
||||
|
||||
it 'updates media attachments, fetches attachment, records media and text removal in edit' do
|
||||
subject.call(status, json, json)
|
||||
|
||||
expect(status.reload.ordered_media_attachments.first)
|
||||
.to be_present
|
||||
.and(have_attributes(remote_url: 'https://example.com/foo.png'))
|
||||
|
||||
expect(a_request(:get, 'https://example.com/foo.png'))
|
||||
.to have_been_made
|
||||
|
||||
expect(status.edits.reload.last.ordered_media_attachment_ids)
|
||||
.to_not be_empty
|
||||
|
||||
expect(status.edits.reload.last.text)
|
||||
.to_not be_present
|
||||
end
|
||||
end
|
||||
|
||||
context 'when originally with media attachments' do
|
||||
let(:media_attachments) { [Fabricate(:media_attachment, remote_url: 'https://example.com/foo.png'), Fabricate(:media_attachment, remote_url: 'https://example.com/unused.png')] }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user