Compare commits

...

40 Commits

Author SHA1 Message Date
Thor 21e49841c3 Fixed error in media gallery 11 months ago
Thor bedb91a2bd Merge remote-tracking branch 'upstream/main' into main 11 months ago
Thor 0687ef7d13 Merge remote-tracking branch 'upstream/main' into main 1 year ago
Thor d9618e12c5 Explicit Chewy imports for statuses 1 year ago
Thor cdf30cf5db Allow full-text search on federated content 1 year ago
Thor ac10ef5e52 Merge remote-tracking branch 'upstream/main' into main 1 year ago
Thor 6b224840bc Merge remote-tracking branch 'upstream/main' into main 1 year ago
Thor abfbb2d3f2 Make 'tootctl media remove-orphans' retry file listings 1 year ago
Thor 100b278a99 Merge remote-tracking branch 'upstream/main' into main 1 year ago
Thor 22e9559aa2 Merge remote-tracking branch 'upstream/main' into main 2 years ago
Thor 8be9ee756a Merge remote-tracking branch 'upstream/main' into main 2 years ago
Thor b4853ea584 Merge remote-tracking branch 'upstream/main' into main 2 years ago
root ecc8e19071 Merge branch 'main' of https://github.com/glitch-soc/mastodon into main 2 years ago
Thor f196a3d4d9 Merge remote-tracking branch 'upstream/main' into main 2 years ago
Thor d8da65025d Correct strings file for new automated status deletion thresholds 2 years ago
Thor 0d2e4b6294 Weeded out another locally modified strings file 2 years ago
Thor 244a5e21ea Merge branch 'dev' into main 2 years ago
Thor 22f653c17b Merge branch 'main' of https://github.com/glitch-soc/mastodon into dev 2 years ago
Thor 36e533eaab Merge branch 'main' of https://github.com/glitch-soc/mastodon into dev 2 years ago
Thor eb8fa57261 Add more automated post deletion age thresholds 2 years ago
Thor affab99b47 Revert to upstream translations (keep on local branch instead) 2 years ago
Thor 6b0dc8407e Enable edit support 2 years ago
Thor 7f3114e4cb Merge branch 'main' of https://github.com/glitch-soc/mastodon into main 2 years ago
Thor 74bb52bd7e Fix sticker alignment bug 2 years ago
Thor 6a50920252 Remove margin on emojis in detailed statuses 2 years ago
Thor 7a325063af Fix big emoji sizes for detailed statuses 2 years ago
Thor e9272004de Revert more vanilla features to upstream 2 years ago
Thor 2271f10292 Revert vanilla components.scss to upstream 2 years ago
Thor 96c9b527f6 Revert vanilla compose.js to upstream 2 years ago
Thor ca90a99560 Revert redundant vanilla patches to upstream 2 years ago
Thor 775e4c4be9 Add sticker support 2 years ago
Thor ad6397f1bb Bigger emojis 2 years ago
Thor 89a476f0bc Remove duplicate JS code for media gallery 2 years ago
Thor bc8d4d0c78 Merge branch 'main' of github.com:berserker-town/glitch-soc into main 2 years ago
Thor e998b1e630 Increase media attachment limit to 20 2 years ago
Thor c4bb82b49e Add support for 20 media attachments 2 years ago
Thor 655573f9c5 Merge branch 'main' of https://github.com/glitch-soc/mastodon into main 2 years ago
Thor d4219bd203 HiDPI image patch 2 years ago
Thor f487fe0951 Merge branch 'main' of https://github.com/glitch-soc/mastodon into main 2 years ago
Mastodon 65e9b5c2e6 Rename the local timeline to the Tavern 2 years ago
  1. 12
      app/chewy/statuses_index.rb
  2. 4
      app/javascript/flavours/glitch/actions/compose.js
  3. 52
      app/javascript/flavours/glitch/components/media_gallery.jsx
  4. 2
      app/javascript/flavours/glitch/features/compose/containers/options_container.js
  5. 2
      app/javascript/flavours/glitch/features/ui/index.jsx
  6. 19
      app/javascript/flavours/glitch/styles/components/status.scss
  7. 3
      app/javascript/flavours/glitch/utils/resize_image.js
  8. 6
      app/lib/activitypub/activity/create.rb
  9. 29
      app/lib/importer/statuses_index_importer.rb
  10. 4
      app/models/account_statuses_cleanup_policy.rb
  11. 3
      app/models/media_attachment.rb
  12. 22
      app/models/status.rb
  13. 2
      app/services/activitypub/process_account_service.rb
  14. 4
      app/services/activitypub/process_status_update_service.rb
  15. 4
      app/services/post_status_service.rb
  16. 2
      app/services/search_service.rb
  17. 4
      app/services/update_status_service.rb
  18. 5
      config/locales/en.yml
  19. 14
      lib/mastodon/cli/media.rb

@ -38,27 +38,27 @@ class StatusesIndex < Chewy::Index
index_scope ::Status.unscoped.kept.without_reblogs.includes(:media_attachments, :preloadable_poll)
crutch :mentions do |collection|
data = ::Mention.where(status_id: collection.map(&:id)).where(account: Account.local, silent: false).pluck(:status_id, :account_id)
data = ::Mention.where(status_id: collection.map(&:id)).where(silent: false).pluck(:status_id, :account_id)
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
end
crutch :favourites do |collection|
data = ::Favourite.where(status_id: collection.map(&:id)).where(account: Account.local).pluck(:status_id, :account_id)
data = ::Favourite.where(status_id: collection.map(&:id)).pluck(:status_id, :account_id)
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
end
crutch :reblogs do |collection|
data = ::Status.where(reblog_of_id: collection.map(&:id)).where(account: Account.local).pluck(:reblog_of_id, :account_id)
data = ::Status.where(reblog_of_id: collection.map(&:id)).pluck(:reblog_of_id, :account_id)
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
end
crutch :bookmarks do |collection|
data = ::Bookmark.where(status_id: collection.map(&:id)).where(account: Account.local).pluck(:status_id, :account_id)
data = ::Bookmark.where(status_id: collection.map(&:id)).pluck(:status_id, :account_id)
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
end
crutch :votes do |collection|
data = ::PollVote.joins(:poll).where(poll: { status_id: collection.map(&:id) }).where(account: Account.local).pluck(:status_id, :account_id)
data = ::PollVote.joins(:poll).where(poll: { status_id: collection.map(&:id) }).pluck(:status_id, :account_id)
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
end
@ -69,7 +69,5 @@ class StatusesIndex < Chewy::Index
field :text, type: 'text', value: ->(status) { status.searchable_text } do
field :stemmed, type: 'text', analyzer: 'content'
end
field :searchable_by, type: 'long', value: ->(status, crutches) { status.searchable_by(crutches) }
end
end

@ -299,7 +299,7 @@ export function doodleSet(options) {
export function uploadCompose(files) {
return function (dispatch, getState) {
const uploadLimit = 4;
const uploadLimit = 20;
const media = getState().getIn(['compose', 'media_attachments']);
const pending = getState().getIn(['compose', 'pending_media_attachments']);
const progress = new Array(files.length).fill(0);
@ -318,7 +318,7 @@ export function uploadCompose(files) {
dispatch(uploadComposeRequest());
for (const [i, f] of Array.from(files).entries()) {
if (media.size + i > 3) break;
if (media.size + i > 19) break;
resizeImage(f).then(file => {
const data = new FormData();

@ -108,16 +108,48 @@ class Item extends PureComponent {
const { attachment, lang, index, size, standalone, letterbox, displayWidth, visible } = this.props;
let badges = [], thumbnail;
let width = 50;
let width = 100;
let height = 100;
if (size === 1) {
width = 100;
let top = 'auto';
let left = 'auto';
let bottom = 'auto';
let right = 'auto';
let root = Math.sqrt(size);
let numCols = Math.ceil(root);
let numRows = Math.ceil(size / numCols);
let col = index % numCols;
let row = Math.floor(index / numCols);
if(row === numRows - 1) {
width = 100 / (1 + ((size - 1) % numCols));
} else {
width = 100 / numCols;
}
height = 100 / numRows;
if(numCols > 1) {
if(col === 0) {
right = '2px';
} else if(col === numCols - 1) {
left = '2px';;
} else {
left = '2px';
right = '2px';
}
}
if (size === 4 || (size === 3 && index > 0)) {
height = 50;
if(numRows > 1) {
if(row === 0) {
bottom = '2px';
} else if(row === numRows - 1) {
top = '2px';
} else {
top = '2px';
bottom = '2px';
}
}
if (attachment.get('description')?.length > 0) {
@ -203,7 +235,7 @@ class Item extends PureComponent {
}
return (
<div className={classNames('media-gallery__item', { standalone, letterbox, 'media-gallery__item--tall': height === 100, 'media-gallery__item--wide': width === 100 })} key={attachment.get('id')}>
<div className={classNames('media-gallery__item', { standalone, letterbox, 'media-gallery__item--tall': height === 100, 'media-gallery__item--wide': width === 100 })} key={attachment.get('id')} style={{ 'padding-left': left, 'padding-top': top, 'padding-right': right, 'padding-bottom': bottom, width: `${width}%`, height: `${height}%` }}>
<Blurhash
hash={attachment.get('blurhash')}
dummy={!useBlurhash}
@ -328,7 +360,7 @@ class MediaGallery extends PureComponent {
render () {
const { media, lang, intl, sensitive, letterbox, fullwidth, defaultWidth, autoplay } = this.props;
const { visible } = this.state;
const size = media.take(4).size;
const size = media.take(20).size; // Attachment limit patch
const uncached = media.every(attachment => attachment.get('type') === 'unknown');
const width = this.state.width || defaultWidth;
@ -348,7 +380,7 @@ class MediaGallery extends PureComponent {
if (this.isStandaloneEligible()) {
children = <Item standalone autoplay={autoplay} onClick={this.handleClick} attachment={media.get(0)} lang={lang} displayWidth={width} visible={visible} />;
} else {
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} autoplay={autoplay} onClick={this.handleClick} attachment={attachment} index={i} lang={lang} size={size} letterbox={letterbox} displayWidth={width} visible={visible || uncached} />);
children = media.take(20).map((attachment, i) => <Item key={attachment.get('id')} autoplay={autoplay} onClick={this.handleClick} attachment={attachment} index={i} lang={lang} size={size} letterbox={letterbox} displayWidth={width} visible={visible || uncached} />); // Attachment limit patch
}
if (uncached) {

@ -18,7 +18,7 @@ function mapStateToProps (state) {
acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']).toArray().join(','),
resetFileKey: state.getIn(['compose', 'resetFileKey']),
hasPoll: !!poll,
allowMedia: !poll && (media ? media.size + pending_media < 4 && !media.some(item => ['video', 'audio'].includes(item.get('type'))) : pending_media < 4),
allowMedia: !poll && (media ? media.size + pending_media < 20 && !media.some(item => ['video', 'audio'].includes(item.get('type'))) : pending_media < 20),
allowPoll: !(media && !!media.size),
showContentTypeChoice: state.getIn(['local_settings', 'show_content_type_choice']),
contentType: state.getIn(['compose', 'content_type']),

@ -78,7 +78,7 @@ const mapStateToProps = state => ({
layout: state.getIn(['meta', 'layout']),
hasComposingText: state.getIn(['compose', 'text']).trim().length !== 0,
hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0,
canUploadMore: !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < 4,
canUploadMore: !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < 20,
layout_local_setting: state.getIn(['local_settings', 'layout']),
isWide: state.getIn(['local_settings', 'stretch']),
dropdownMenuIsOpen: state.getIn(['dropdown_menu', 'openId']) !== null,

@ -62,9 +62,16 @@
}
.emojione {
width: 20px;
height: 20px;
margin: -3px 0 0;
width: 32px;
height: 32px;
margin: 0;
}
img.emojione[alt^=":sticker_"] {
width: 128px;
height: 128px;
display: block;
margin: 0 auto;
}
p,
@ -573,9 +580,9 @@
line-height: 24px;
.emojione {
width: 24px;
height: 24px;
margin: -1px 0 0;
width: 32px;
height: 32px;
margin: 0;
}
}

@ -1,6 +1,7 @@
import EXIF from 'exif-js';
const MAX_IMAGE_PIXELS = 2073600; // 1920x1080px
//const MAX_IMAGE_PIXELS = 2073600; // 1920x1080px
const MAX_IMAGE_PIXELS = 8294400; // 3840x2160px (HiDPI patch)
const _browser_quirks = {};

@ -85,6 +85,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
attach_tags(@status)
end
StatusesIndex.import! @status if Chewy.enabled?
resolve_thread(@status)
fetch_replies(@status)
distribute
@ -123,7 +125,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
visibility: @status_parser.visibility,
thread: replied_to_status,
conversation: conversation_from_uri(@object['conversation']),
media_attachment_ids: process_attachments.take(4).map(&:id),
media_attachment_ids: process_attachments.take(20).map(&:id),
poll: process_poll,
}
end
@ -255,7 +257,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
as_array(@object['attachment']).each do |attachment|
media_attachment_parser = ActivityPub::Parser::MediaAttachmentParser.new(attachment)
next if media_attachment_parser.remote_url.blank? || media_attachments.size >= 4
next if media_attachment_parser.remote_url.blank? || media_attachments.size >= 20
begin
media_attachment = MediaAttachment.create(

@ -17,28 +17,9 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
Chewy::Index::Import::BulkBuilder.new(index, to_index: Status.includes(:media_attachments, :preloadable_poll).where(id: status_ids)).bulk_body
end
indexed = 0
indexed = bulk.length
deleted = 0
# We can't use the delete_if proc to do the filtering because delete_if
# is called before rendering the data and we need to filter based
# on the results of the filter, so this filtering happens here instead
bulk.map! do |entry|
new_entry = if entry[:index] && entry.dig(:index, :data, 'searchable_by').blank?
{ delete: entry[:index].except(:data) }
else
entry
end
if new_entry[:index]
indexed += 1
else
deleted += 1
end
new_entry
end
Chewy::Index::Import::BulkRequest.new(index).perform(bulk)
[indexed, deleted]
@ -66,11 +47,11 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
end
def local_mentions_scope
Mention.where(account: Account.local, silent: false).select(:id, :status_id)
Mention.where(silent: false).select(:id, :status_id)
end
def local_favourites_scope
Favourite.where(account: Account.local).select(:id, :status_id)
Favourite.select(:id, :status_id)
end
def local_bookmarks_scope
@ -78,10 +59,10 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
end
def local_votes_scope
Poll.joins(:votes).where(votes: { account: Account.local }).select('polls.id, polls.status_id')
Poll.joins(:votes).select('polls.id, polls.status_id')
end
def local_statuses_scope
Status.local.select('"statuses"."id", COALESCE("statuses"."reblog_of_id", "statuses"."id") AS status_id')
Status.select('"statuses"."id", COALESCE("statuses"."reblog_of_id", "statuses"."id") AS status_id')
end
end

@ -23,6 +23,10 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
include Redisable
ALLOWED_MIN_STATUS_AGE = [
1.day.seconds,
2.days.seconds,
3.days.seconds,
5.days.seconds,
1.week.seconds,
2.weeks.seconds,
1.month.seconds,

@ -74,7 +74,8 @@ class MediaAttachment < ApplicationRecord
}.freeze,
small: {
pixels: 230_400, # 640x360px
# pixels: 230_400, # 640x360px
pixels: 640_000, # 800x800px (HiDPI patch)
file_geometry_parser: FastGeometryParser,
blurhash: BLURHASH_OPTIONS,
}.freeze,

@ -170,28 +170,6 @@ class Status < ApplicationRecord
"v2:#{super}"
end
def searchable_by(preloaded = nil)
ids = []
ids << account_id if local?
if preloaded.nil?
ids += mentions.joins(:account).merge(Account.local).active.pluck(:account_id)
ids += favourites.joins(:account).merge(Account.local).pluck(:account_id)
ids += reblogs.joins(:account).merge(Account.local).pluck(:account_id)
ids += bookmarks.joins(:account).merge(Account.local).pluck(:account_id)
ids += poll.votes.joins(:account).merge(Account.local).pluck(:account_id) if poll.present?
else
ids += preloaded.mentions[id] || []
ids += preloaded.favourites[id] || []
ids += preloaded.reblogs[id] || []
ids += preloaded.bookmarks[id] || []
ids += preloaded.votes[id] || []
end
ids.uniq
end
def searchable_text
[
spoiler_text,

@ -90,6 +90,8 @@ class ActivityPub::ProcessAccountService < BaseService
set_fetchable_attributes! unless @options[:only_key] || @account.suspended?
@account.save_with_optional_media!
AccountsIndex.import! @account if Chewy.enabled?
end
def set_immediate_protocol_attributes!

@ -54,6 +54,8 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
broadcast_updates!
end
StatusesIndex.import! @status if Chewy.enabled?
forward_activity! if significant_changes? && @status_parser.edited_at > last_edit_date
end
@ -72,7 +74,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
as_array(@json['attachment']).each do |attachment|
media_attachment_parser = ActivityPub::Parser::MediaAttachmentParser.new(attachment)
next if media_attachment_parser.remote_url.blank? || @next_media_attachments.size > 4
next if media_attachment_parser.remote_url.blank? || @next_media_attachments.size > 20
begin
media_attachment = previous_media_attachments.find { |previous_media_attachment| previous_media_attachment.remote_url == media_attachment_parser.remote_url }

@ -146,9 +146,9 @@ class PostStatusService < BaseService
return
end
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4 || @options[:poll].present?
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 20 || @options[:poll].present? # Attachment limit patch
@media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i))
@media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(20).map(&:to_i)) # Attachment limit patch
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if @media.size > 1 && @media.find(&:audio_or_video?)
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_ready') if @media.any?(&:not_processed?)

@ -38,7 +38,7 @@ class SearchService < BaseService
end
def perform_statuses_search!
definition = parsed_query.apply(StatusesIndex.filter(term: { searchable_by: @account.id }))
definition = parsed_query.apply(StatusesIndex)
definition = definition.filter(term: { account_id: @options[:account_id] }) if @options[:account_id].present?

@ -70,9 +70,9 @@ class UpdateStatusService < BaseService
def validate_media!
return [] if @options[:media_ids].blank? || !@options[:media_ids].is_a?(Enumerable)
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4 || @options[:poll].present?
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 20 || @options[:poll].present? # Attachment limit patch
media_attachments = @status.account.media_attachments.where(status_id: [nil, @status.id]).where(scheduled_status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i)).to_a
media_attachments = @status.account.media_attachments.where(status_id: [nil, @status.id]).where(scheduled_status_id: nil).where(id: @options[:media_ids].take(20).map(&:to_i)).to_a # Attachment limit patch
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if media_attachments.size > 1 && media_attachments.find(&:audio_or_video?)
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_ready') if media_attachments.any?(&:not_processed?)

@ -1667,6 +1667,11 @@ en:
keep_self_fav: Keep posts you favorited
keep_self_fav_hint: Doesn't delete your own posts if you have favorited them
min_age:
'86400': 1 day
'172800': 2 days
'259200': 3 days
'432000': 5 days
'604800': 1 week
'1209600': 2 weeks
'15778476': 6 months
'2629746': 1 month

@ -109,11 +109,15 @@ module Mastodon::CLI
loop do
objects = begin
bucket.objects(start_after: last_key, prefix: prefix).limit(1000).map { |x| x }
rescue => e
progress.log(pastel.red("Error fetching list of files: #{e}"))
progress.log("If you want to continue from this point, add --start-after=#{last_key} to your command") if last_key
break
begin
bucket.objects(start_after: last_key, prefix: prefix).limit(1000).map { |x| x }
rescue => e
progress.log(pastel.red("Error fetching list of files: #{e}"))
progress.log("Sleeping for 5 seconds")
sleep 5
progress.log("Retrying")
retry
end
end
break if objects.empty?

Loading…
Cancel
Save