mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Compare commits
6 commits
052d888244
...
3907bdd92b
Author | SHA1 | Date | |
---|---|---|---|
|
3907bdd92b | ||
|
a50c8e951f | ||
|
2c1e75727d | ||
|
7ac3053673 | ||
|
bab725fc31 | ||
|
ee58baf14e |
13 changed files with 91 additions and 51 deletions
|
@ -60,7 +60,7 @@ export interface BaseNotificationGroupJSON {
|
||||||
|
|
||||||
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
|
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
|
||||||
type: NotificationWithStatusType;
|
type: NotificationWithStatusType;
|
||||||
status: ApiStatusJSON;
|
status_id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NotificationWithStatusJSON extends BaseNotificationJSON {
|
interface NotificationWithStatusJSON extends BaseNotificationJSON {
|
||||||
|
|
|
@ -49,21 +49,14 @@ export const FilteredNotificationsBanner: React.FC = () => {
|
||||||
<span>
|
<span>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='filtered_notifications_banner.pending_requests'
|
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 }}
|
values={{ count: policy.summary.pending_requests_count }}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='filtered-notifications-banner__badge'>
|
<div className='filtered-notifications-banner__badge'>
|
||||||
<div className='filtered-notifications-banner__badge__badge'>
|
{toCappedNumber(policy.summary.pending_notifications_count)}
|
||||||
{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>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
|
|
|
@ -300,8 +300,7 @@
|
||||||
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
|
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
|
||||||
"filter_modal.select_filter.title": "Filter this post",
|
"filter_modal.select_filter.title": "Filter this post",
|
||||||
"filter_modal.title.status": "Filter a post",
|
"filter_modal.title.status": "Filter a post",
|
||||||
"filtered_notifications_banner.mentions": "{count, plural, one {mention} other {mentions}}",
|
"filtered_notifications_banner.pending_requests": "From {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
||||||
"filtered_notifications_banner.pending_requests": "Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
|
||||||
"filtered_notifications_banner.title": "Filtered notifications",
|
"filtered_notifications_banner.title": "Filtered notifications",
|
||||||
"firehose.all": "All",
|
"firehose.all": "All",
|
||||||
"firehose.local": "This server",
|
"firehose.local": "This server",
|
||||||
|
|
|
@ -124,9 +124,9 @@ export function createNotificationGroupFromJSON(
|
||||||
case 'mention':
|
case 'mention':
|
||||||
case 'poll':
|
case 'poll':
|
||||||
case 'update': {
|
case 'update': {
|
||||||
const { status, ...groupWithoutStatus } = group;
|
const { status_id: statusId, ...groupWithoutStatus } = group;
|
||||||
return {
|
return {
|
||||||
statusId: status.id,
|
statusId,
|
||||||
sampleAccountIds,
|
sampleAccountIds,
|
||||||
...groupWithoutStatus,
|
...groupWithoutStatus,
|
||||||
};
|
};
|
||||||
|
|
|
@ -10171,25 +10171,10 @@ noscript {
|
||||||
}
|
}
|
||||||
|
|
||||||
&__badge {
|
&__badge {
|
||||||
display: flex;
|
background: $ui-button-background-color;
|
||||||
align-items: center;
|
color: $white;
|
||||||
border-radius: 999px;
|
border-radius: 100px;
|
||||||
background: var(--background-border-color);
|
padding: 2px 8px;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -501,6 +501,19 @@ class Account < ApplicationRecord
|
||||||
save!
|
save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def private_key
|
||||||
|
if account_secret
|
||||||
|
account_secret.private_key
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def private_key=(value)
|
||||||
|
self.account_secret ||= AccountSecret.new
|
||||||
|
account_secret.private_key = value
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def prepare_contents
|
def prepare_contents
|
||||||
|
|
17
app/models/account_secret.rb
Normal file
17
app/models/account_secret.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: account_secrets
|
||||||
|
#
|
||||||
|
# id :bigint(8) not null, primary key
|
||||||
|
# private_key :text
|
||||||
|
# account_id :bigint(8) not null
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
class AccountSecret < ApplicationRecord
|
||||||
|
belongs_to :account
|
||||||
|
|
||||||
|
encrypts :private_key
|
||||||
|
end
|
|
@ -77,5 +77,8 @@ module Account::Associations
|
||||||
|
|
||||||
# Imports
|
# Imports
|
||||||
has_many :bulk_imports, inverse_of: :account, dependent: :delete_all
|
has_many :bulk_imports, inverse_of: :account, dependent: :delete_all
|
||||||
|
|
||||||
|
# Secrets
|
||||||
|
has_one :account_secret, inverse_of: :account, dependent: :destroy, autosave: true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
12
db/migrate/20240726143215_create_account_secrets.rb
Normal file
12
db/migrate/20240726143215_create_account_secrets.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class CreateAccountSecrets < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
create_table :account_secrets do |t|
|
||||||
|
t.text :private_key
|
||||||
|
t.references :account, null: false, foreign_key: { on_delete: :cascade }
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
11
db/schema.rb
11
db/schema.rb
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.1].define(version: 2024_07_24_181224) do
|
ActiveRecord::Schema[7.1].define(version: 2024_07_26_143215) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
|
@ -103,6 +103,14 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_24_181224) do
|
||||||
t.index ["relationship_severance_event_id"], name: "idx_on_relationship_severance_event_id_403f53e707"
|
t.index ["relationship_severance_event_id"], name: "idx_on_relationship_severance_event_id_403f53e707"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "account_secrets", force: :cascade do |t|
|
||||||
|
t.text "private_key"
|
||||||
|
t.bigint "account_id", null: false
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["account_id"], name: "index_account_secrets_on_account_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "account_stats", force: :cascade do |t|
|
create_table "account_stats", force: :cascade do |t|
|
||||||
t.bigint "account_id", null: false
|
t.bigint "account_id", null: false
|
||||||
t.bigint "statuses_count", default: 0, null: false
|
t.bigint "statuses_count", default: 0, null: false
|
||||||
|
@ -1274,6 +1282,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_24_181224) do
|
||||||
add_foreign_key "account_pins", "accounts", on_delete: :cascade
|
add_foreign_key "account_pins", "accounts", on_delete: :cascade
|
||||||
add_foreign_key "account_relationship_severance_events", "accounts", on_delete: :cascade
|
add_foreign_key "account_relationship_severance_events", "accounts", on_delete: :cascade
|
||||||
add_foreign_key "account_relationship_severance_events", "relationship_severance_events", on_delete: :cascade
|
add_foreign_key "account_relationship_severance_events", "relationship_severance_events", on_delete: :cascade
|
||||||
|
add_foreign_key "account_secrets", "accounts", on_delete: :cascade
|
||||||
add_foreign_key "account_stats", "accounts", on_delete: :cascade
|
add_foreign_key "account_stats", "accounts", on_delete: :cascade
|
||||||
add_foreign_key "account_statuses_cleanup_policies", "accounts", on_delete: :cascade
|
add_foreign_key "account_statuses_cleanup_policies", "accounts", on_delete: :cascade
|
||||||
add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
|
add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
|
||||||
|
|
|
@ -1067,4 +1067,15 @@ RSpec.describe Account do
|
||||||
expect(subject.reload.followers_count).to eq 15
|
expect(subject.reload.followers_count).to eq 15
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'private key' do
|
||||||
|
it 'encrypts and decrypts the key' do
|
||||||
|
account = Fabricate(:account)
|
||||||
|
|
||||||
|
account.private_key = 'secret'
|
||||||
|
account.save!
|
||||||
|
|
||||||
|
expect(account.reload.private_key).to eq 'secret'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,16 +46,14 @@ describe Account::Counters do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'preserves last_status_at when decrementing statuses_count' do
|
it 'preserves last_status_at when decrementing statuses_count' do
|
||||||
account_stat = Fabricate(
|
account.statuses_count = 10
|
||||||
:account_stat,
|
account.save!
|
||||||
account: account,
|
account.account_stat.last_status_at = 3.days.ago
|
||||||
last_status_at: 3.days.ago,
|
account.account_stat.save!
|
||||||
statuses_count: 10
|
|
||||||
)
|
|
||||||
|
|
||||||
expect { account.decrement_count!(:statuses_count) }
|
expect { account.decrement_count!(:statuses_count) }
|
||||||
.to change(account_stat.reload, :statuses_count).by(-1)
|
.to change(account.account_stat.reload, :statuses_count).by(-1)
|
||||||
.and not_change(account_stat.reload, :last_status_at)
|
.and not_change(account.account_stat.reload, :last_status_at)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe 'Directories API' do
|
||||||
user: Fabricate(:user, confirmed_at: nil, approved: true),
|
user: Fabricate(:user, confirmed_at: nil, approved: true),
|
||||||
username: 'local_unconfirmed'
|
username: 'local_unconfirmed'
|
||||||
)
|
)
|
||||||
local_unconfirmed_account.create_account_stat!
|
local_unconfirmed_account.account_stat.save!
|
||||||
|
|
||||||
local_unapproved_account = Fabricate(
|
local_unapproved_account = Fabricate(
|
||||||
:account,
|
:account,
|
||||||
|
@ -25,7 +25,7 @@ describe 'Directories API' do
|
||||||
user: Fabricate(:user, confirmed_at: 10.days.ago),
|
user: Fabricate(:user, confirmed_at: 10.days.ago),
|
||||||
username: 'local_unapproved'
|
username: 'local_unapproved'
|
||||||
)
|
)
|
||||||
local_unapproved_account.create_account_stat!
|
local_unapproved_account.account_stat.save!
|
||||||
local_unapproved_account.user.update(approved: false)
|
local_unapproved_account.user.update(approved: false)
|
||||||
|
|
||||||
local_undiscoverable_account = Fabricate(
|
local_undiscoverable_account = Fabricate(
|
||||||
|
@ -35,7 +35,7 @@ describe 'Directories API' do
|
||||||
discoverable: false,
|
discoverable: false,
|
||||||
username: 'local_undiscoverable'
|
username: 'local_undiscoverable'
|
||||||
)
|
)
|
||||||
local_undiscoverable_account.create_account_stat!
|
local_undiscoverable_account.account_stat.save!
|
||||||
|
|
||||||
excluded_from_timeline_account = Fabricate(
|
excluded_from_timeline_account = Fabricate(
|
||||||
:account,
|
:account,
|
||||||
|
@ -43,7 +43,7 @@ describe 'Directories API' do
|
||||||
discoverable: true,
|
discoverable: true,
|
||||||
username: 'remote_excluded_from_timeline'
|
username: 'remote_excluded_from_timeline'
|
||||||
)
|
)
|
||||||
excluded_from_timeline_account.create_account_stat!
|
excluded_from_timeline_account.account_stat.save!
|
||||||
Fabricate(:block, account: user.account, target_account: excluded_from_timeline_account)
|
Fabricate(:block, account: user.account, target_account: excluded_from_timeline_account)
|
||||||
|
|
||||||
domain_blocked_account = Fabricate(
|
domain_blocked_account = Fabricate(
|
||||||
|
@ -52,11 +52,11 @@ describe 'Directories API' do
|
||||||
discoverable: true,
|
discoverable: true,
|
||||||
username: 'remote_domain_blocked'
|
username: 'remote_domain_blocked'
|
||||||
)
|
)
|
||||||
domain_blocked_account.create_account_stat!
|
domain_blocked_account.account_stat.save!
|
||||||
Fabricate(:account_domain_block, account: user.account, domain: 'test.example')
|
Fabricate(:account_domain_block, account: user.account, domain: 'test.example')
|
||||||
|
|
||||||
local_discoverable_account.create_account_stat!
|
local_discoverable_account.account_stat.save!
|
||||||
eligible_remote_account.create_account_stat!
|
eligible_remote_account.account_stat.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:local_discoverable_account) do
|
let(:local_discoverable_account) do
|
||||||
|
@ -93,8 +93,8 @@ describe 'Directories API' do
|
||||||
let(:remote_account) { Fabricate(:account, domain: 'host.example') }
|
let(:remote_account) { Fabricate(:account, domain: 'host.example') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
local_account.create_account_stat!
|
local_account.account_stat.save!
|
||||||
remote_account.create_account_stat!
|
remote_account.account_stat.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns only the local accounts' do
|
it 'returns only the local accounts' do
|
||||||
|
|
Loading…
Reference in a new issue