Commit 32067246 authored by Benjamin Neff's avatar Benjamin Neff

Delete people with invalid diaspora IDs (friendica with path)

closes #7630
parent fd36517d
......@@ -26,6 +26,7 @@
* Fix local migration run without old private key [#7558](https://github.com/diaspora/diaspora/pull/7558)
* Fix export not downloadable because the filename was resetted on access [#7622](https://github.com/diaspora/diaspora/pull/7622)
* Delete invalid oEmbed caches with binary titles [#7620](https://github.com/diaspora/diaspora/pull/7620)
* Delete invalid diaspora IDs from friendica [#7630](https://github.com/diaspora/diaspora/pull/7630)
## Features
* Ask for confirmation when leaving a submittable comment field [#7530](https://github.com/diaspora/diaspora/pull/7530)
......
......@@ -5,7 +5,6 @@
# the COPYRIGHT file.
class AspectMembership < ApplicationRecord
belongs_to :aspect
belongs_to :contact
has_one :user, :through => :contact
......
......@@ -5,8 +5,6 @@
# the COPYRIGHT file.
class NotificationActor < ApplicationRecord
belongs_to :notification
belongs_to :person
end
# frozen_string_literal: true
class CleanupInvalidDiasporaIds < ActiveRecord::Migration[5.1]
def up
ids = Person.where("diaspora_handle LIKE '%@%/%'").ids
return if ids.empty?
AspectMembership.joins(:contact).where(contacts: {person_id: ids}).delete_all
Person.where(id: ids).each do |person|
destroy_notifications_for_person(person)
person.destroy
end
end
def destroy_notifications_for_person(person)
Notification.joins(:notification_actors).where(notification_actors: {person_id: person.id}).each do |notification|
if notification.notification_actors.count > 1
notification.notification_actors.where(person_id: person.id).delete_all
else
notification.destroy
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment