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.ts19
1 files changed, 9 insertions, 10 deletions
diff --git a/server/lib/user.ts b/server/lib/user.ts
index 266974cac..d84aff464 100644
--- a/server/lib/user.ts
+++ b/server/lib/user.ts
@@ -2,9 +2,8 @@ import * as uuidv4 from 'uuid/v4'
2import { ActivityPubActorType } from '../../shared/models/activitypub' 2import { ActivityPubActorType } from '../../shared/models/activitypub'
3import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants' 3import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants'
4import { AccountModel } from '../models/account/account' 4import { AccountModel } from '../models/account/account'
5import { UserModel } from '../models/account/user'
6import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub' 5import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub'
7import { createVideoChannel } from './video-channel' 6import { createLocalVideoChannel } from './video-channel'
8import { ActorModel } from '../models/activitypub/actor' 7import { ActorModel } from '../models/activitypub/actor'
9import { UserNotificationSettingModel } from '../models/account/user-notification-setting' 8import { UserNotificationSettingModel } from '../models/account/user-notification-setting'
10import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users' 9import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users'
@@ -13,17 +12,17 @@ import { sequelizeTypescript } from '../initializers/database'
13import { Transaction } from 'sequelize/types' 12import { Transaction } from 'sequelize/types'
14import { Redis } from './redis' 13import { Redis } from './redis'
15import { Emailer } from './emailer' 14import { Emailer } from './emailer'
16import { MAccountActor, MActor, MChannelActor } from '../typings/models' 15import { MAccountDefault, MActorDefault, MChannelActor } from '../typings/models'
17import { MUser, MUserId, MUserNotifSettingAccount } from '../typings/models/user' 16import { MUser, MUserDefault, MUserId } from '../typings/models/user'
18 17
19type ChannelNames = { name: string, displayName: string } 18type ChannelNames = { name: string, displayName: string }
20 19
21async function createUserAccountAndChannelAndPlaylist (parameters: { 20async function createUserAccountAndChannelAndPlaylist (parameters: {
22 userToCreate: UserModel, 21 userToCreate: MUser,
23 userDisplayName?: string, 22 userDisplayName?: string,
24 channelNames?: ChannelNames, 23 channelNames?: ChannelNames,
25 validateUser?: boolean 24 validateUser?: boolean
26}): Promise<{ user: MUserNotifSettingAccount, account: MAccountActor, videoChannel: MChannelActor }> { 25}): Promise<{ user: MUserDefault, account: MAccountDefault, videoChannel: MChannelActor }> {
27 const { userToCreate, userDisplayName, channelNames, validateUser = true } = parameters 26 const { userToCreate, userDisplayName, channelNames, validateUser = true } = parameters
28 27
29 const { user, account, videoChannel } = await sequelizeTypescript.transaction(async t => { 28 const { user, account, videoChannel } = await sequelizeTypescript.transaction(async t => {
@@ -32,7 +31,7 @@ async function createUserAccountAndChannelAndPlaylist (parameters: {
32 validate: validateUser 31 validate: validateUser
33 } 32 }
34 33
35 const userCreated: MUserNotifSettingAccount = await userToCreate.save(userOptions) 34 const userCreated: MUserDefault = await userToCreate.save(userOptions)
36 userCreated.NotificationSetting = await createDefaultUserNotificationSettings(userCreated, t) 35 userCreated.NotificationSetting = await createDefaultUserNotificationSettings(userCreated, t)
37 36
38 const accountCreated = await createLocalAccountWithoutKeys({ 37 const accountCreated = await createLocalAccountWithoutKeys({
@@ -45,7 +44,7 @@ async function createUserAccountAndChannelAndPlaylist (parameters: {
45 userCreated.Account = accountCreated 44 userCreated.Account = accountCreated
46 45
47 const channelAttributes = await buildChannelAttributes(userCreated, channelNames) 46 const channelAttributes = await buildChannelAttributes(userCreated, channelNames)
48 const videoChannel = await createVideoChannel(channelAttributes, accountCreated, t) 47 const videoChannel = await createLocalVideoChannel(channelAttributes, accountCreated, t)
49 48
50 const videoPlaylist = await createWatchLaterPlaylist(accountCreated, t) 49 const videoPlaylist = await createWatchLaterPlaylist(accountCreated, t)
51 50
@@ -75,7 +74,7 @@ async function createLocalAccountWithoutKeys (parameters: {
75 const url = getAccountActivityPubUrl(name) 74 const url = getAccountActivityPubUrl(name)
76 75
77 const actorInstance = buildActorInstance(type, url, name) 76 const actorInstance = buildActorInstance(type, url, name)
78 const actorInstanceCreated: MActor = await actorInstance.save({ transaction: t }) 77 const actorInstanceCreated: MActorDefault = await actorInstance.save({ transaction: t })
79 78
80 const accountInstance = new AccountModel({ 79 const accountInstance = new AccountModel({
81 name: displayName || name, 80 name: displayName || name,
@@ -84,7 +83,7 @@ async function createLocalAccountWithoutKeys (parameters: {
84 actorId: actorInstanceCreated.id 83 actorId: actorInstanceCreated.id
85 }) 84 })
86 85
87 const accountInstanceCreated: MAccountActor = await accountInstance.save({ transaction: t }) 86 const accountInstanceCreated: MAccountDefault = await accountInstance.save({ transaction: t })
88 accountInstanceCreated.Actor = actorInstanceCreated 87 accountInstanceCreated.Actor = actorInstanceCreated
89 88
90 return accountInstanceCreated 89 return accountInstanceCreated