diff options
author | Chocobozzz <me@florianbigard.com> | 2019-12-05 14:57:14 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-12-05 14:57:14 +0100 |
commit | 77e0851758595de2642b405cff8960f02ced60eb (patch) | |
tree | 6858298627b97a450eaef388ff7222e0e5a2e1c4 /server/models/activitypub | |
parent | 7b7d4e2a6adde8a8aa0b4c0048bddd448a6a0093 (diff) | |
download | PeerTube-77e0851758595de2642b405cff8960f02ced60eb.tar.gz PeerTube-77e0851758595de2642b405cff8960f02ced60eb.tar.zst PeerTube-77e0851758595de2642b405cff8960f02ced60eb.zip |
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.
Diffstat (limited to 'server/models/activitypub')
-rw-r--r-- | server/models/activitypub/actor.ts | 15 |
1 files changed, 14 insertions, 1 deletions
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 { | |||
48 | MActorWithInboxes | 48 | MActorWithInboxes |
49 | } from '../../typings/models' | 49 | } from '../../typings/models' |
50 | import * as Bluebird from 'bluebird' | 50 | import * as Bluebird from 'bluebird' |
51 | import { Op } from 'sequelize' | ||
51 | 52 | ||
52 | enum ScopeNames { | 53 | enum ScopeNames { |
53 | FULL = 'FULL' | 54 | FULL = 'FULL' |
@@ -115,7 +116,19 @@ export const unusedActorAttributesForAPI = [ | |||
115 | }, | 116 | }, |
116 | { | 117 | { |
117 | fields: [ 'preferredUsername', 'serverId' ], | 118 | fields: [ 'preferredUsername', 'serverId' ], |
118 | unique: true | 119 | unique: true, |
120 | where: { | ||
121 | serverId: { | ||
122 | [Op.ne]: null | ||
123 | } | ||
124 | } | ||
125 | }, | ||
126 | { | ||
127 | fields: [ 'preferredUsername' ], | ||
128 | unique: true, | ||
129 | where: { | ||
130 | serverId: null | ||
131 | } | ||
119 | }, | 132 | }, |
120 | { | 133 | { |
121 | fields: [ 'inboxUrl', 'sharedInboxUrl' ] | 134 | fields: [ 'inboxUrl', 'sharedInboxUrl' ] |