diff options
Diffstat (limited to 'server/lib/user.ts')
-rw-r--r-- | server/lib/user.ts | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/server/lib/user.ts b/server/lib/user.ts index e7a45f5aa..db29469eb 100644 --- a/server/lib/user.ts +++ b/server/lib/user.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import * as uuidv4 from 'uuid/v4' | ||
2 | import { ActivityPubActorType } from '../../shared/models/activitypub' | 3 | import { ActivityPubActorType } from '../../shared/models/activitypub' |
3 | import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../initializers' | 4 | import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../initializers' |
4 | import { AccountModel } from '../models/account/account' | 5 | import { AccountModel } from '../models/account/account' |
@@ -7,6 +8,7 @@ import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from | |||
7 | import { createVideoChannel } from './video-channel' | 8 | import { createVideoChannel } from './video-channel' |
8 | import { VideoChannelModel } from '../models/video/video-channel' | 9 | import { VideoChannelModel } from '../models/video/video-channel' |
9 | import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' | 10 | import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' |
11 | import { ActorModel } from '../models/activitypub/actor' | ||
10 | 12 | ||
11 | async function createUserAccountAndChannel (userToCreate: UserModel, validateUser = true) { | 13 | async function createUserAccountAndChannel (userToCreate: UserModel, validateUser = true) { |
12 | const { user, account, videoChannel } = await sequelizeTypescript.transaction(async t => { | 14 | const { user, account, videoChannel } = await sequelizeTypescript.transaction(async t => { |
@@ -19,8 +21,15 @@ async function createUserAccountAndChannel (userToCreate: UserModel, validateUse | |||
19 | const accountCreated = await createLocalAccountWithoutKeys(userToCreate.username, userToCreate.id, null, t) | 21 | const accountCreated = await createLocalAccountWithoutKeys(userToCreate.username, userToCreate.id, null, t) |
20 | userCreated.Account = accountCreated | 22 | userCreated.Account = accountCreated |
21 | 23 | ||
22 | const videoChannelDisplayName = `Default ${userCreated.username} channel` | 24 | let channelName = userCreated.username + '_channel' |
25 | |||
26 | // Conflict, generate uuid instead | ||
27 | const actor = await ActorModel.loadLocalByName(channelName) | ||
28 | if (actor) channelName = uuidv4() | ||
29 | |||
30 | const videoChannelDisplayName = `Main ${userCreated.username} channel` | ||
23 | const videoChannelInfo = { | 31 | const videoChannelInfo = { |
32 | name: channelName, | ||
24 | displayName: videoChannelDisplayName | 33 | displayName: videoChannelDisplayName |
25 | } | 34 | } |
26 | const videoChannel = await createVideoChannel(videoChannelInfo, accountCreated, t) | 35 | const videoChannel = await createVideoChannel(videoChannelInfo, accountCreated, t) |