Delete people with invalid diaspora IDs (friendica with path)
closes #7630
This commit is contained in:
parent
fd36517dee
commit
32067246df
4 changed files with 26 additions and 3 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
* Fix local migration run without old private key [#7558](https://github.com/diaspora/diaspora/pull/7558)
|
* 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)
|
* 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 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
|
## Features
|
||||||
* Ask for confirmation when leaving a submittable comment field [#7530](https://github.com/diaspora/diaspora/pull/7530)
|
* Ask for confirmation when leaving a submittable comment field [#7530](https://github.com/diaspora/diaspora/pull/7530)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class AspectMembership < ApplicationRecord
|
class AspectMembership < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :aspect
|
belongs_to :aspect
|
||||||
belongs_to :contact
|
belongs_to :contact
|
||||||
has_one :user, :through => :contact
|
has_one :user, :through => :contact
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class NotificationActor < ApplicationRecord
|
class NotificationActor < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :notification
|
belongs_to :notification
|
||||||
belongs_to :person
|
belongs_to :person
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
25
db/migrate/20170928233609_cleanup_invalid_diaspora_ids.rb
Normal file
25
db/migrate/20170928233609_cleanup_invalid_diaspora_ids.rb
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# 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
|
||||||
Loading…
Reference in a new issue