From 77e0851758595de2642b405cff8960f02ced60eb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 5 Dec 2019 14:57:14 +0100 Subject: Ensure local actors preferredName don't already exist Before applying this commit, check you don't have duplicates local actors in your database: select "preferredUsername" from actor where "serverId" is null group by "preferredUsername" having count(*) > 0 If you have some results, it seems you have duplicate channels/accounts. For every entry, you'll have to change the preferredUsername of the entry you want (so they are unique). The updated actors could have some federations issues. Sorry. --- server/models/activitypub/actor.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index 42a24b583..66a13b857 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts @@ -48,6 +48,7 @@ import { MActorWithInboxes } from '../../typings/models' import * as Bluebird from 'bluebird' +import { Op } from 'sequelize' enum ScopeNames { FULL = 'FULL' @@ -115,7 +116,19 @@ export const unusedActorAttributesForAPI = [ }, { fields: [ 'preferredUsername', 'serverId' ], - unique: true + unique: true, + where: { + serverId: { + [Op.ne]: null + } + } + }, + { + fields: [ 'preferredUsername' ], + unique: true, + where: { + serverId: null + } }, { fields: [ 'inboxUrl', 'sharedInboxUrl' ] -- cgit v1.2.3