mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Compare commits
4 commits
7d73355bbe
...
a950dabbfe
Author | SHA1 | Date | |
---|---|---|---|
|
a950dabbfe | ||
|
a50c8e951f | ||
|
2c1e75727d | ||
|
3059279672 |
13 changed files with 95 additions and 81 deletions
|
@ -60,7 +60,7 @@ export interface BaseNotificationGroupJSON {
|
|||
|
||||
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
|
||||
type: NotificationWithStatusType;
|
||||
status: ApiStatusJSON;
|
||||
status_id: string;
|
||||
}
|
||||
|
||||
interface NotificationWithStatusJSON extends BaseNotificationJSON {
|
||||
|
|
|
@ -49,22 +49,15 @@ export const FilteredNotificationsBanner: React.FC = () => {
|
|||
<span>
|
||||
<FormattedMessage
|
||||
id='filtered_notifications_banner.pending_requests'
|
||||
defaultMessage='Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know'
|
||||
defaultMessage='From {count, plural, =0 {no one} one {one person} other {# people}} you may know'
|
||||
values={{ count: policy.summary.pending_requests_count }}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className='filtered-notifications-banner__badge'>
|
||||
<div className='filtered-notifications-banner__badge__badge'>
|
||||
{toCappedNumber(policy.summary.pending_notifications_count)}
|
||||
</div>
|
||||
<FormattedMessage
|
||||
id='filtered_notifications_banner.mentions'
|
||||
defaultMessage='{count, plural, one {mention} other {mentions}}'
|
||||
values={{ count: policy.summary.pending_notifications_count }}
|
||||
/>
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -300,8 +300,7 @@
|
|||
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
|
||||
"filter_modal.select_filter.title": "Filter this post",
|
||||
"filter_modal.title.status": "Filter a post",
|
||||
"filtered_notifications_banner.mentions": "{count, plural, one {mention} other {mentions}}",
|
||||
"filtered_notifications_banner.pending_requests": "Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
||||
"filtered_notifications_banner.pending_requests": "From {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
||||
"filtered_notifications_banner.title": "Filtered notifications",
|
||||
"firehose.all": "All",
|
||||
"firehose.local": "This server",
|
||||
|
|
|
@ -124,9 +124,9 @@ export function createNotificationGroupFromJSON(
|
|||
case 'mention':
|
||||
case 'poll':
|
||||
case 'update': {
|
||||
const { status, ...groupWithoutStatus } = group;
|
||||
const { status_id: statusId, ...groupWithoutStatus } = group;
|
||||
return {
|
||||
statusId: status.id,
|
||||
statusId,
|
||||
sampleAccountIds,
|
||||
...groupWithoutStatus,
|
||||
};
|
||||
|
|
|
@ -10170,27 +10170,12 @@ noscript {
|
|||
}
|
||||
}
|
||||
|
||||
&__badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 999px;
|
||||
background: var(--background-border-color);
|
||||
color: $darker-text-color;
|
||||
padding: 4px;
|
||||
padding-inline-end: 8px;
|
||||
gap: 6px;
|
||||
font-weight: 500;
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
word-break: keep-all;
|
||||
|
||||
&__badge {
|
||||
background: $ui-button-background-color;
|
||||
color: $white;
|
||||
border-radius: 100px;
|
||||
padding: 2px 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.notification-request {
|
||||
|
|
|
@ -89,6 +89,7 @@ class Account < ApplicationRecord
|
|||
include DomainMaterializable
|
||||
include DomainNormalizable
|
||||
include Paginable
|
||||
include Reviewable
|
||||
|
||||
enum :protocol, { ostatus: 0, activitypub: 1 }
|
||||
enum :suspension_origin, { local: 0, remote: 1 }, prefix: true
|
||||
|
@ -424,22 +425,6 @@ class Account < ApplicationRecord
|
|||
@synchronization_uri_prefix ||= "#{uri[URL_PREFIX_RE]}/"
|
||||
end
|
||||
|
||||
def requires_review?
|
||||
reviewed_at.nil?
|
||||
end
|
||||
|
||||
def reviewed?
|
||||
reviewed_at.present?
|
||||
end
|
||||
|
||||
def requested_review?
|
||||
requested_review_at.present?
|
||||
end
|
||||
|
||||
def requires_review_notification?
|
||||
requires_review? && !requested_review?
|
||||
end
|
||||
|
||||
class << self
|
||||
def readonly_attributes
|
||||
super - %w(statuses_count following_count followers_count)
|
||||
|
|
21
app/models/concerns/reviewable.rb
Normal file
21
app/models/concerns/reviewable.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Reviewable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def requires_review?
|
||||
reviewed_at.nil?
|
||||
end
|
||||
|
||||
def reviewed?
|
||||
reviewed_at.present?
|
||||
end
|
||||
|
||||
def requested_review?
|
||||
requested_review_at.present?
|
||||
end
|
||||
|
||||
def requires_review_notification?
|
||||
requires_review? && !requested_review?
|
||||
end
|
||||
end
|
|
@ -21,6 +21,7 @@ class PreviewCardProvider < ApplicationRecord
|
|||
include Paginable
|
||||
include DomainNormalizable
|
||||
include Attachmentable
|
||||
include Reviewable
|
||||
|
||||
ICON_MIME_TYPES = %w(image/x-icon image/vnd.microsoft.icon image/png).freeze
|
||||
LIMIT = 1.megabyte
|
||||
|
@ -36,22 +37,6 @@ class PreviewCardProvider < ApplicationRecord
|
|||
scope :reviewed, -> { where.not(reviewed_at: nil) }
|
||||
scope :pending_review, -> { where(reviewed_at: nil) }
|
||||
|
||||
def requires_review?
|
||||
reviewed_at.nil?
|
||||
end
|
||||
|
||||
def reviewed?
|
||||
reviewed_at.present?
|
||||
end
|
||||
|
||||
def requested_review?
|
||||
requested_review_at.present?
|
||||
end
|
||||
|
||||
def requires_review_notification?
|
||||
requires_review? && !requested_review?
|
||||
end
|
||||
|
||||
def self.matching_domain(domain)
|
||||
segments = domain.split('.')
|
||||
where(domain: segments.map.with_index { |_, i| segments[i..].join('.') }).by_domain_length.first
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
class Tag < ApplicationRecord
|
||||
include Paginable
|
||||
include Reviewable
|
||||
|
||||
# rubocop:disable Rails/HasAndBelongsToMany
|
||||
has_and_belongs_to_many :statuses
|
||||
has_and_belongs_to_many :accounts
|
||||
|
@ -97,22 +99,6 @@ class Tag < ApplicationRecord
|
|||
|
||||
alias trendable? trendable
|
||||
|
||||
def requires_review?
|
||||
reviewed_at.nil?
|
||||
end
|
||||
|
||||
def reviewed?
|
||||
reviewed_at.present?
|
||||
end
|
||||
|
||||
def requested_review?
|
||||
requested_review_at.present?
|
||||
end
|
||||
|
||||
def requires_review_notification?
|
||||
requires_review? && !requested_review?
|
||||
end
|
||||
|
||||
def decaying?
|
||||
max_score_at && max_score_at >= Trends.tags.options[:max_score_cooldown].ago && max_score_at < 1.day.ago
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Account do
|
||||
include_examples 'Reviewable'
|
||||
|
||||
context 'with an account record' do
|
||||
subject { Fabricate(:account) }
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe PreviewCardProvider do
|
||||
include_examples 'Reviewable'
|
||||
|
||||
describe 'scopes' do
|
||||
let(:trendable_and_reviewed) { Fabricate(:preview_card_provider, trendable: true, reviewed_at: 5.days.ago) }
|
||||
let(:not_trendable_and_not_reviewed) { Fabricate(:preview_card_provider, trendable: false, reviewed_at: nil) }
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Tag do
|
||||
include_examples 'Reviewable'
|
||||
|
||||
describe 'validations' do
|
||||
it 'invalid with #' do
|
||||
expect(described_class.new(name: '#hello_world')).to_not be_valid
|
||||
|
|
54
spec/support/examples/models/concerns/reviewable.rb
Normal file
54
spec/support/examples/models/concerns/reviewable.rb
Normal file
|
@ -0,0 +1,54 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
shared_examples 'Reviewable' do
|
||||
subject { described_class.new(reviewed_at: reviewed_at, requested_review_at: requested_review_at) }
|
||||
|
||||
let(:reviewed_at) { nil }
|
||||
let(:requested_review_at) { nil }
|
||||
|
||||
describe '#requires_review?' do
|
||||
it { is_expected.to be_requires_review }
|
||||
|
||||
context 'when reviewed_at is not null' do
|
||||
let(:reviewed_at) { 5.days.ago }
|
||||
|
||||
it { is_expected.to_not be_requires_review }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#reviewed?' do
|
||||
it { is_expected.to_not be_reviewed }
|
||||
|
||||
context 'when reviewed_at is not null' do
|
||||
let(:reviewed_at) { 5.days.ago }
|
||||
|
||||
it { is_expected.to be_reviewed }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#requested_review?' do
|
||||
it { is_expected.to_not be_requested_review }
|
||||
|
||||
context 'when requested_reviewed_at is not null' do
|
||||
let(:requested_review_at) { 5.days.ago }
|
||||
|
||||
it { is_expected.to be_requested_review }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#requires_review_notification?' do
|
||||
it { is_expected.to be_requires_review_notification }
|
||||
|
||||
context 'when reviewed_at is not null' do
|
||||
let(:reviewed_at) { 5.days.ago }
|
||||
|
||||
it { is_expected.to_not be_requires_review_notification }
|
||||
end
|
||||
|
||||
context 'when requested_reviewed_at is not null' do
|
||||
let(:requested_review_at) { 5.days.ago }
|
||||
|
||||
it { is_expected.to_not be_requires_review_notification }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue