about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-03-27 10:44:12 -0500
committerDavid Yip <yipdw@member.fsf.org>2018-03-27 10:44:12 -0500
commitd2cdc2b5a37f9c9d56242e3540ff62cccff4b1ae (patch)
tree7a18011a34ee3f2c87c826797bf0443c5765d99e /lib
parent49c957bc3bf186b7e560d09d605f24693338c5db (diff)
parent3523aa440ba3f52bf28fe1e9707506d327c4431f (diff)
Merge remote-tracking branch 'origin/master' into gs-master
Diffstat (limited to 'lib')
-rw-r--r--lib/mastodon/version.rb2
-rw-r--r--lib/tasks/mastodon.rake18
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb
index 121c5c693..a6927eec3 100644
--- a/lib/mastodon/version.rb
+++ b/lib/mastodon/version.rb
@@ -13,7 +13,7 @@ module Mastodon
     end
 
     def patch
-      2
+      3
     end
 
     def pre
diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake
index 0972e4367..cfd6a1d25 100644
--- a/lib/tasks/mastodon.rake
+++ b/lib/tasks/mastodon.rake
@@ -740,6 +740,24 @@ namespace :mastodon do
       LinkCrawlWorker.push_bulk status_ids
     end
 
+    desc 'Find case-insensitive username duplicates of local users'
+    task find_duplicate_usernames: :environment do
+      include RoutingHelper
+
+      disable_log_stdout!
+
+      duplicate_masters = Account.find_by_sql('SELECT * FROM accounts WHERE id IN (SELECT min(id) FROM accounts WHERE domain IS NULL GROUP BY lower(username) HAVING count(*) > 1)')
+      pastel = Pastel.new
+
+      duplicate_masters.each do |account|
+        puts pastel.yellow("First of their name: ") + pastel.bold(account.username) + " (#{admin_account_url(account.id)})"
+
+        Account.where('lower(username) = ?', account.username.downcase).where.not(id: account.id).each do |duplicate|
+          puts "  " + pastel.red("Duplicate: ") + admin_account_url(duplicate.id)
+        end
+      end
+    end
+
     desc 'Remove all home feed regeneration markers'
     task remove_regeneration_markers: :environment do
       keys = Redis.current.keys('account:*:regeneration')