Skip to content

Commit

Permalink
テスト修正など
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Oct 1, 2023
1 parent cbd4b77 commit 3241357
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
20 changes: 11 additions & 9 deletions app/javascript/mastodon/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,15 @@ class Status extends ImmutablePureComponent {
};

render () {
const { intl, hidden, featured, unread, showThread, scrollKey, pictureInPicture, previousId, nextInReplyToId, rootId } = this.props;
const { intl, hidden, featured, unread, muted, showThread, scrollKey, pictureInPicture, previousId, nextInReplyToId, rootId } = this.props;

let { status, account, ...other } = this.props;

if (status === null) {
return null;
}

const handlers = this.props.muted ? {} : {
const handlers = muted ? {} : {
reply: this.handleHotkeyReply,
favourite: this.handleHotkeyFavourite,
boost: this.handleHotkeyBoost,
Expand All @@ -385,7 +385,7 @@ class Status extends ImmutablePureComponent {
if (hidden) {
return (
<HotKeys handlers={handlers}>
<div ref={this.handleRef} className={classNames('status__wrapper', { focusable: !this.props.muted })} tabIndex={0}>
<div ref={this.handleRef} className={classNames('status__wrapper', { focusable: !muted })} tabIndex={0}>
<span>{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])}</span>
<span>{status.get('content')}</span>
</div>
Expand Down Expand Up @@ -414,7 +414,7 @@ class Status extends ImmutablePureComponent {
let visibilityIcon = visibilityIconInfo[status.get('limited_scope') || status.get('visibility_ex')] || visibilityIconInfo[status.get('visibility')];

if (this.state.forceFilter === undefined ? matchedFilters : this.state.forceFilter) {
const minHandlers = this.props.muted ? {} : {
const minHandlers = muted ? {} : {
moveUp: this.handleHotkeyMoveUp,
moveDown: this.handleHotkeyMoveDown,
};
Expand Down Expand Up @@ -479,7 +479,7 @@ class Status extends ImmutablePureComponent {
} else if (status.get('media_attachments').size > 0) {
const language = status.getIn(['translation', 'language']) || status.get('language');

if (this.props.muted) {
if (muted) {
media = (
<AttachmentList
compact
Expand Down Expand Up @@ -557,7 +557,7 @@ class Status extends ImmutablePureComponent {
</Bundle>
);
}
} else if (status.get('card') && !this.props.muted) {
} else if (status.get('card') && !muted) {
media = (
<Card
onOpenMedia={this.handleOpenMedia}
Expand Down Expand Up @@ -592,12 +592,14 @@ class Status extends ImmutablePureComponent {
const withReference = status.get('status_references_count') > 0 ? <span className='status__visibility-icon'><Icon id='link' title='Reference' /></span> : null;
const withExpiration = status.get('expires_at') ? <span className='status__visibility-icon'><Icon id='clock-o' title='Expiration' /></span> : null;

const quote = !muted && status.get('quote_id') && <CompactedStatusContainer id={status.get('quote_id')} />

return (
<HotKeys handlers={handlers}>
<div className={classNames('status__wrapper', `status__wrapper-${status.get('visibility_ex')}`, { 'status__wrapper-reply': !!status.get('in_reply_to_id'), unread, focusable: !this.props.muted })} tabIndex={this.props.muted ? null : 0} data-featured={featured ? 'true' : null} aria-label={textForScreenReader(intl, status, rebloggedByText)} ref={this.handleRef} data-nosnippet={status.getIn(['account', 'noindex'], true) || undefined}>
<div className={classNames('status__wrapper', `status__wrapper-${status.get('visibility_ex')}`, { 'status__wrapper-reply': !!status.get('in_reply_to_id'), unread, focusable: !muted })} tabIndex={muted ? null : 0} data-featured={featured ? 'true' : null} aria-label={textForScreenReader(intl, status, rebloggedByText)} ref={this.handleRef} data-nosnippet={status.getIn(['account', 'noindex'], true) || undefined}>
{prepend}

<div className={classNames('status', `status-${status.get('visibility_ex')}`, { 'status-reply': !!status.get('in_reply_to_id'), 'status--in-thread': !!rootId, 'status--first-in-thread': previousId && (!connectUp || connectToRoot), muted: this.props.muted })} data-id={status.get('id')}>
<div className={classNames('status', `status-${status.get('visibility_ex')}`, { 'status-reply': !!status.get('in_reply_to_id'), 'status--in-thread': !!rootId, 'status--first-in-thread': previousId && (!connectUp || connectToRoot), muted: muted })} data-id={status.get('id')}>
{(connectReply || connectUp || connectToRoot) && <div className={classNames('status__line', { 'status__line--full': connectReply, 'status__line--first': !status.get('in_reply_to_id') && !connectToRoot })} />}

{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
Expand Down Expand Up @@ -630,7 +632,7 @@ class Status extends ImmutablePureComponent {
{...statusContentProps}
/>

<CompactedStatusContainer id={status.get('id')} />
{quote}

{(!isCardMediaWithSensitive || !status.get('hidden')) && media}

Expand Down
3 changes: 2 additions & 1 deletion app/models/custom_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ def self.apply_cached_filters(cached_filters, status, following = false) # ruboc
if rules[:keywords].present?
match = rules[:keywords].match(status.proper.searchable_text)
match = rules[:keywords].match(status.proper.references.pluck(:text).join("\n\n")) if match.nil? && status.proper.references.exists?
match = rules[:keywords].match(status.proper.references.pluck(:spoiler_text).join("\n\n")) if match.nil? && status.proper.references.exists?
end
keyword_matches = [match.to_s] unless match.nil?

status_matches = [status.id, status.reblog_of_id].compact & rules[:status_ids] if rules[:status_ids].present?
status_matches = [status.id, status.reblog_of_id, status.quote_id].compact & rules[:status_ids] if rules[:status_ids].present?

next if keyword_matches.blank? && status_matches.blank?

Expand Down
4 changes: 4 additions & 0 deletions app/models/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ def quote
@quote ||= reference_objects.where(quote: true).first&.target_status
end

def quote_id
reference_objects.where(quote: true).first&.target_status_id
end

def within_realtime_window?
created_at >= REAL_TIME_WINDOW.ago
end
Expand Down
3 changes: 2 additions & 1 deletion app/presenters/status_relationships_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def initialize(statuses, current_account_id = nil, **options)
@favourites_map = {}
@bookmarks_map = {}
@mutes_map = {}
@blocks_map = {}
@pins_map = {}
@filters_map = {}
@emoji_reaction_allows_map = nil
Expand All @@ -28,7 +29,7 @@ def initialize(statuses, current_account_id = nil, **options)
@favourites_map = Status.favourites_map(status_ids, current_account_id).merge(options[:favourites_map] || {})
@bookmarks_map = Status.bookmarks_map(status_ids, current_account_id).merge(options[:bookmarks_map] || {})
@mutes_map = Status.mutes_map(conversation_ids, current_account_id).merge(options[:mutes_map] || {})
@blocks_map = Status.blocks_map(conversation_ids, current_account_id).merge(options[:blocks_map] || {})
@blocks_map = Status.blocks_map(statuses.map(&:account_id), current_account_id).merge(options[:blocks_map] || {})
@pins_map = Status.pins_map(pinnable_status_ids, current_account_id).merge(options[:pins_map] || {})
@emoji_reaction_allows_map = Status.emoji_reaction_allows_map(status_ids, current_account_id).merge(options[:emoji_reaction_allows_map] || {})
@attributes_map = options[:attributes_map] || {}
Expand Down
6 changes: 3 additions & 3 deletions app/services/process_references_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def call(status, reference_parameters, urls: nil, fetch_remote: true, no_fetch_u

@status.save!
end
quote_ur

create_notifications!
end

Expand All @@ -45,14 +45,14 @@ def self.need_process?(status, reference_parameters, urls)
reference_parameters.any? || (urls || []).any? || FormattingHelper.extract_status_plain_text(status).scan(REFURL_EXP).pluck(3).uniq.any?
end

def self.perform_worker_async(status, reference_parameters, urls, quote_urls)
def self.perform_worker_async(status, reference_parameters, urls, quote_urls = [])
return unless need_process?(status, reference_parameters, urls)

Rails.cache.write("status_reference:#{status.id}", true, expires_in: 10.minutes)
ProcessReferencesWorker.perform_async(status.id, reference_parameters, urls, [], quote_urls || [])
end

def self.call_service(status, reference_parameters, urls, quote_urls)
def self.call_service(status, reference_parameters, urls, quote_urls = [])
return unless need_process?(status, reference_parameters, urls)

ProcessReferencesService.new.call(status, reference_parameters || [], urls: urls || [], fetch_remote: false, quote_urls: quote_urls)
Expand Down

0 comments on commit 3241357

Please sign in to comment.