aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/user.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/user.ts')
-rw-r--r--server/lib/user.ts11
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 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as uuidv4 from 'uuid/v4'
2import { ActivityPubActorType } from '../../shared/models/activitypub' 3import { ActivityPubActorType } from '../../shared/models/activitypub'
3import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../initializers' 4import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../initializers'
4import { AccountModel } from '../models/account/account' 5import { AccountModel } from '../models/account/account'
@@ -7,6 +8,7 @@ import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from
7import { createVideoChannel } from './video-channel' 8import { createVideoChannel } from './video-channel'
8import { VideoChannelModel } from '../models/video/video-channel' 9import { VideoChannelModel } from '../models/video/video-channel'
9import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' 10import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
11import { ActorModel } from '../models/activitypub/actor'
10 12
11async function createUserAccountAndChannel (userToCreate: UserModel, validateUser = true) { 13async 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)