diff options
49 files changed, 5 insertions, 810 deletions
diff --git a/app/controllers/severed_relationships_controller.rb b/app/controllers/severed_relationships_controller.rb deleted file mode 100644 index 168e85e3fe4..00000000000 --- a/app/controllers/severed_relationships_controller.rb +++ /dev/null @@ -1,61 +0,0 @@ -# frozen_string_literal: true - -class SeveredRelationshipsController < ApplicationController - layout 'admin' - - before_action :authenticate_user! - before_action :set_body_classes - before_action :set_cache_headers - - before_action :set_event, only: [:following, :followers] - - def index - @events = AccountRelationshipSeveranceEvent.where(account: current_account) - end - - def following - respond_to do |format| - format.csv { send_data following_data, filename: "following-#{@event.target_name}-#{@event.created_at.to_date.iso8601}.csv" } - end - end - - def followers - respond_to do |format| - format.csv { send_data followers_data, filename: "followers-#{@event.target_name}-#{@event.created_at.to_date.iso8601}.csv" } - end - end - - private - - def set_event - @event = AccountRelationshipSeveranceEvent.find(params[:id]) - end - - def following_data - CSV.generate(headers: ['Account address', 'Show boosts', 'Notify on new posts', 'Languages'], write_headers: true) do |csv| - @event.severed_relationships.active.about_local_account(current_account).includes(:remote_account).reorder(id: :desc).each do |follow| - csv << [acct(follow.target_account), follow.show_reblogs, follow.notify, follow.languages&.join(', ')] - end - end - end - - def followers_data - CSV.generate(headers: ['Account address'], write_headers: true) do |csv| - @event.severed_relationships.passive.about_local_account(current_account).includes(:remote_account).reorder(id: :desc).each do |follow| - csv << [acct(follow.account)] - end - end - end - - def acct(account) - account.local? ? account.local_username_and_domain : account.acct - end - - def set_body_classes - @body_classes = 'admin' - end - - def set_cache_headers - response.cache_control.replace(private: true, no_store: true) - end -end diff --git a/app/javascript/mastodon/features/notifications/components/notification.jsx b/app/javascript/mastodon/features/notifications/components/notification.jsx index 1e89f77d453..d7101f8384f 100644 --- a/app/javascript/mastodon/features/notifications/components/notification.jsx +++ b/app/javascript/mastodon/features/notifications/components/notification.jsx @@ -14,7 +14,6 @@ import EditIcon from '@/material-icons/400-24px/edit.svg?react'; import FlagIcon from '@/material-icons/400-24px/flag-fill.svg?react'; import HomeIcon from '@/material-icons/400-24px/home-fill.svg?react'; import InsertChartIcon from '@/material-icons/400-24px/insert_chart.svg?react'; -import LinkOffIcon from '@/material-icons/400-24px/link_off.svg?react'; import PersonIcon from '@/material-icons/400-24px/person-fill.svg?react'; import PersonAddIcon from '@/material-icons/400-24px/person_add-fill.svg?react'; import RepeatIcon from '@/material-icons/400-24px/repeat.svg?react'; @@ -27,7 +26,6 @@ import { WithRouterPropTypes } from 'mastodon/utils/react_router'; import FollowRequestContainer from '../containers/follow_request_container'; -import RelationshipsSeveranceEvent from './relationships_severance_event'; import Report from './report'; const messages = defineMessages({ @@ -360,30 +358,6 @@ class Notification extends ImmutablePureComponent { ); } - renderRelationshipsSevered (notification) { - const { intl, unread } = this.props; - - if (!notification.get('event')) { - return null; - } - - return ( - <HotKeys handlers={this.getHandlers()}> - <div className={classNames('notification notification-severed-relationships focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.adminReport, { name: notification.getIn(['event', 'target_name']) }), notification.get('created_at'))}> - <div className='notification__message'> - <Icon id='unlink' icon={LinkOffIcon} /> - - <span title={notification.get('created_at')}> - <FormattedMessage id='notification.severed_relationships' defaultMessage='Relationships with {name} severed' values={{ name: notification.getIn(['event', 'target_name']) }} /> - </span> - </div> - - <RelationshipsSeveranceEvent event={notification.get('event')} /> - </div> - </HotKeys> - ); - } - renderAdminSignUp (notification, account, link) { const { intl, unread } = this.props; @@ -455,8 +429,6 @@ class Notification extends ImmutablePureComponent { return this.renderUpdate(notification, link); case 'poll': return this.renderPoll(notification, account); - case 'severed_relationships': - return this.renderRelationshipsSevered(notification); case 'admin.sign_up': return this.renderAdminSignUp(notification, account, link); case 'admin.report': diff --git a/app/javascript/mastodon/features/notifications/components/relationships_severance_event.jsx b/app/javascript/mastodon/features/notifications/components/relationships_severance_event.jsx deleted file mode 100644 index 12bc5f130d0..00000000000 --- a/app/javascript/mastodon/features/notifications/components/relationships_severance_event.jsx +++ /dev/null @@ -1,61 +0,0 @@ -import PropTypes from 'prop-types'; - -import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; - -import ImmutablePropTypes from 'react-immutable-proptypes'; - -import { RelativeTimestamp } from 'mastodon/components/relative_timestamp'; - -// This needs to be kept in sync with app/models/relationship_severance_event.rb -const messages = defineMessages({ - account_suspension: { id: 'relationship_severance_notification.types.account_suspension', defaultMessage: 'Account has been suspended' }, - domain_block: { id: 'relationship_severance_notification.types.domain_block', defaultMessage: 'Domain has been suspended' }, - user_domain_block: { id: 'relationship_severance_notification.types.user_domain_block', defaultMessage: 'You blocked this domain' }, -}); - -const RelationshipsSeveranceEvent = ({ event, hidden }) => { - const intl = useIntl(); - - if (hidden || !event) { - return null; - } - - return ( - <div className='notification__report'> - <div className='notification__report__details'> - <div> - <RelativeTimestamp timestamp={event.get('created_at')} short={false} /> - {' · '} - { event.get('purged') ? ( - <FormattedMessage - id='relationship_severance_notification.purged_data' - defaultMessage='purged by administrators' - /> - ) : ( - <FormattedMessage - id='relationship_severance_notification.relationships' - defaultMessage='{count, plural, one {# relationship} other {# relationships}}' - values={{ count: event.get('relationships_count', 0) }} - /> - )} - <br /> - <strong>{intl.formatMessage(messages[event.get('type')])}</strong> - </div> - - <div className='notification__report__actions'> - <a href='/severed_relationships' className='button' target='_blank' rel='noopener noreferrer'> - <FormattedMessage id='relationship_severance_notification.view' defaultMessage='View' /> - </a> - </div> - </div> - </div> - ); - -}; - -RelationshipsSeveranceEvent.propTypes = { - event: ImmutablePropTypes.map.isRequired, - hidden: PropTypes.bool, -}; - -export default RelationshipsSeveranceEvent; diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index efda92d2132..376dfb7e4b6 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -471,7 +471,6 @@ "notification.own_poll": "Your poll has ended", "notification.poll": "A poll you have voted in has ended", "notification.reblog": "{name} boosted your post", - "notification.severed_relationships": "Relationships with {name} severed", "notification.status": "{name} just posted", "notification.update": "{name} edited a post", "notification_requests.accept": "Accept", @@ -588,12 +587,6 @@ "refresh": "Refresh", "regeneration_indicator.label": "Loading…", "regeneration_indicator.sublabel": "Your home feed is being prepared!", - "relationship_severance_notification.purged_data": "purged by administrators", - "relationship_severance_notification.relationships": "{count, plural, one {# relationship} other {# relationships}}", - "relationship_severance_notification.types.account_suspension": "Account has been suspended", - "relationship_severance_notification.types.domain_block": "Domain has been suspended", - "relationship_severance_notification.types.user_domain_block": "You blocked this domain", - "relationship_severance_notification.view": "View", "relative_time.days": "{number}d", "relative_time.full.days": "{number, plural, one {# day} other {# days}} ago", "relative_time.full.hours": "{number, plural, one {# hour} other {# hours}} ago", diff --git a/app/models/account_relationship_severance_event.rb b/app/models/account_relationship_severance_event.rb deleted file mode 100644 index 20b15e28399..00000000000 --- a/app/models/account_relationship_severance_event.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -# -# == Schema Information -# -# Table name: account_relationship_severance_events -# -# id :bigint(8) not null, primary key -# account_id :bigint(8) not null -# relationship_severance_event_id :bigint(8) not null -# relationships_count :integer default(0), not null -# created_at :datetime not null -# updated_at :datetime not null -# -class AccountRelationshipSeveranceEvent < ApplicationRecord - belongs_to :account - belongs_to :relationship_severance_event - - delegate :severed_relationships, - :type, - :target_name, - :purged, - :purged?, - to: :relationship_severance_event, - prefix: false - - before_create :set_relationships_count! - - private - - def set_relationships_count! - self.relationships_count = severed_relationships.about_local_account(account).count - end -end diff --git a/app/models/concerns/account/interactions.rb b/app/models/concerns/account/interactions.rb index a32697b66eb..85363febfb2 100644 --- a/app/models/concerns/account/interactions.rb +++ b/app/models/concerns/account/interactions.rb @@ -83,11 +83,6 @@ module Account::Interactions has_many :following, -> { order('follows.id desc') }, through: :active_relationships, source: :target_account has_many :followers, -> { order('follows.id desc') }, through: :passive_relationships, source: :account - with_options class_name: 'SeveredRelationship', dependent: :destroy do - has_many :severed_relationships, foreign_key: 'local_account_id', inverse_of: :local_account - has_many :remote_severed_relationships, foreign_key: 'remote_account_id', inverse_of: :remote_account - end - # Account notes has_many :account_notes, dependent: :destroy diff --git a/app/models/concerns/account/merging.rb b/app/models/concerns/account/merging.rb index e6b147482cc..960ee1819f8 100644 --- a/app/models/concerns/account/merging.rb +++ b/app/models/concerns/account/merging.rb @@ -48,18 +48,6 @@ module Account::Merging record.update_attribute(:account_warning_id, id) end - SeveredRelationship.about_local_account(other_account).reorder(nil).find_each do |record| - record.update_attribute(:local_account_id, id) - rescue ActiveRecord::RecordNotUnique - next - end - - SeveredRelationship.about_remote_account(other_account).reorder(nil).find_each do |record| - record.update_attribute(:remote_account_id, id) - rescue ActiveRecord::RecordNotUnique - next - end - # Some follow relationships have moved, so the cache is stale Rails.cache.delete_matched("followers_hash:#{id}:*") Rails.cache.delete_matched("relationships:#{id}:*") diff --git a/app/models/notification.rb b/app/models/notification.rb index b2376c78a3d..861a1543696 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -54,9 +54,6 @@ class Notification < ApplicationRecord update: { filterable: false, }.freeze, - severed_relationships: { - filterable: false, - }.freeze, 'admin.sign_up': { filterable: false, }.freeze, @@ -89,7 +86,6 @@ class Notification < ApplicationRecord belongs_to :favourite, inverse_of: :notification belongs_to :poll, inverse_of: false belongs_to :report, inverse_of: false - belongs_to :account_relationship_severance_event, inverse_of: false end validates :type, inclusion: { in: TYPES } @@ -186,11 +182,6 @@ class Notification < ApplicationRecord self.from_account_id = activity&.status&.account_id when 'Account' self.from_account_id = activity&.id - when 'AccountRelationshipSeveranceEvent' - # These do not really have an originating account, but this is mandatory - # in the data model, and the recipient's account will by definition - # always exist - self.from_account_id = account_id end end diff --git a/app/models/relationship_severance_event.rb b/app/models/relationship_severance_event.rb deleted file mode 100644 index 30ada257671..00000000000 --- a/app/models/relationship_severance_event.rb +++ /dev/null @@ -1,56 +0,0 @@ -# frozen_string_literal: true - -# == Schema Information -# -# Table name: relationship_severance_events -# -# id :bigint(8) not null, primary key -# type :integer not null -# target_name :string not null -# purged :boolean default(FALSE), not null -# created_at :datetime not null -# updated_at :datetime not null -# -class RelationshipSeveranceEvent < ApplicationRecord - self.inheritance_column = nil - - has_many :severed_relationships, inverse_of: :relationship_severance_event, dependent: :delete_all - - enum :type, { - domain_block: 0, - user_domain_block: 1, - account_suspension: 2, - } - - scope :about_local_account, ->(account) { where(id: SeveredRelationship.about_local_account(account).select(:relationship_severance_event_id)) } - - def import_from_active_follows!(follows) - import_from_follows!(follows, true) - end - - def import_from_passive_follows!(follows) - import_from_follows!(follows, false) - end - - def affected_local_accounts - Account.where(id: severed_relationships.select(:local_account_id)) - end - - private - - def import_from_follows!(follows, active) - SeveredRelationship.insert_all( - follows.pluck(:account_id, :target_account_id, :show_reblogs, :notify, :languages).map do |account_id, target_account_id, show_reblogs, notify, languages| - { - local_account_id: active ? account_id : target_account_id, - remote_account_id: active ? target_account_id : account_id, - show_reblogs: show_reblogs, - notify: notify, - languages: languages, - relationship_severance_event_id: id, - direction: active ? :active : :passive, - } - end - ) - end -end diff --git a/app/models/severed_relationship.rb b/app/models/severed_relationship.rb deleted file mode 100644 index 64b5b0001b7..00000000000 --- a/app/models/severed_relationship.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -# == Schema Information -# -# Table name: severed_relationships -# -# id :bigint(8) not null, primary key -# relationship_severance_event_id :bigint(8) not null -# local_account_id :bigint(8) not null -# remote_account_id :bigint(8) not null -# direction :integer not null -# show_reblogs :boolean -# notify :boolean -# languages :string is an Array -# created_at :datetime not null -# updated_at :datetime not null -# -class SeveredRelationship < ApplicationRecord - belongs_to :relationship_severance_event - belongs_to :local_account, class_name: 'Account' - belongs_to :remote_account, class_name: 'Account' - - enum :direction, { - passive: 0, # analogous to `local_account.passive_relationships` - active: 1, # analogous to `local_account.active_relationships` - } - - scope :about_local_account, ->(account) { where(local_account: account) } - scope :about_remote_account, ->(account) { where(remote_account: account) } - - scope :active, -> { where(direction: :active) } - scope :passive, -> { where(direction: :passive) } - - def account - active? ? local_account : remote_account - end - - def target_account - active? ? remote_account : local_account - end -end diff --git a/app/serializers/rest/account_relationship_severance_event_serializer.rb b/app/serializers/rest/account_relationship_severance_event_serializer.rb deleted file mode 100644 index 2578e3a20fc..00000000000 --- a/app/serializers/rest/account_relationship_severance_event_serializer.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class REST::AccountRelationshipSeveranceEventSerializer < ActiveModel::Serializer - attributes :id, :type, :purged, :target_name, :created_at - - def id - object.id.to_s - end -end diff --git a/app/serializers/rest/notification_serializer.rb b/app/serializers/rest/notification_serializer.rb index 36a0adfec46..137fc53ddab 100644 --- a/app/serializers/rest/notification_serializer.rb +++ b/app/serializers/rest/notification_serializer.rb @@ -6,7 +6,6 @@ class REST::NotificationSerializer < ActiveModel::Serializer belongs_to :from_account, key: :account, serializer: REST::AccountSerializer belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer belongs_to :report, if: :report_type?, serializer: REST::ReportSerializer - belongs_to :account_relationship_severance_event, key: :event, if: :relationship_severance_event?, serializer: REST::AccountRelationshipSeveranceEventSerializer def id object.id.to_s @@ -19,8 +18,4 @@ class REST::NotificationSerializer < ActiveModel::Serializer def report_type? object.type == :'admin.report' end |