Browse Source

Fix notifications about deleted reports not being also deleted (#19475)

* Fix notifications about deleted reports not being also deleted

* Fix notification with empty report crashing web UI

Fix #18909
closed-social-glitch-2
Eugen Rochko 2 years ago
committed by GitHub
parent
commit
d2eb726962
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions
  1. +4
    -0
      app/javascript/mastodon/features/notifications/components/notification.js
  2. +1
    -0
      app/models/report.rb

+ 4
- 0
app/javascript/mastodon/features/notifications/components/notification.js View File

@ -372,6 +372,10 @@ class Notification extends ImmutablePureComponent {
renderAdminReport (notification, account, link) { renderAdminReport (notification, account, link) {
const { intl, unread, report } = this.props; const { intl, unread, report } = this.props;
if (!report) {
return null;
}
const targetAccount = report.get('target_account'); const targetAccount = report.get('target_account');
const targetDisplayNameHtml = { __html: targetAccount.get('display_name_html') }; const targetDisplayNameHtml = { __html: targetAccount.get('display_name_html') };
const targetLink = <bdi><Permalink className='notification__display-name' href={targetAccount.get('url')} title={targetAccount.get('acct')} to={`/@${targetAccount.get('acct')}`} dangerouslySetInnerHTML={targetDisplayNameHtml} /></bdi>; const targetLink = <bdi><Permalink className='notification__display-name' href={targetAccount.get('url')} title={targetAccount.get('acct')} to={`/@${targetAccount.get('acct')}`} dangerouslySetInnerHTML={targetDisplayNameHtml} /></bdi>;

+ 1
- 0
app/models/report.rb View File

@ -33,6 +33,7 @@ class Report < ApplicationRecord
belongs_to :assigned_account, class_name: 'Account', optional: true belongs_to :assigned_account, class_name: 'Account', optional: true
has_many :notes, class_name: 'ReportNote', foreign_key: :report_id, inverse_of: :report, dependent: :destroy has_many :notes, class_name: 'ReportNote', foreign_key: :report_id, inverse_of: :report, dependent: :destroy
has_many :notifications, as: :activity, dependent: :destroy
scope :unresolved, -> { where(action_taken_at: nil) } scope :unresolved, -> { where(action_taken_at: nil) }
scope :resolved, -> { where.not(action_taken_at: nil) } scope :resolved, -> { where.not(action_taken_at: nil) }

Loading…
Cancel
Save