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, 12 insertions, 7 deletions
diff --git a/server/lib/user.ts b/server/lib/user.ts
index a39ef6c3d..7badb3e72 100644
--- a/server/lib/user.ts
+++ b/server/lib/user.ts
@@ -1,18 +1,19 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as uuidv4 from 'uuid/v4' 2import * as uuidv4 from 'uuid/v4'
3import { ActivityPubActorType } from '../../shared/models/activitypub' 3import { ActivityPubActorType } from '../../shared/models/activitypub'
4import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../initializers' 4import { SERVER_ACTOR_NAME } from '../initializers/constants'
5import { AccountModel } from '../models/account/account' 5import { AccountModel } from '../models/account/account'
6import { UserModel } from '../models/account/user' 6import { UserModel } from '../models/account/user'
7import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub' 7import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub'
8import { createVideoChannel } from './video-channel' 8import { createVideoChannel } from './video-channel'
9import { VideoChannelModel } from '../models/video/video-channel' 9import { VideoChannelModel } from '../models/video/video-channel'
10import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
11import { ActorModel } from '../models/activitypub/actor' 10import { ActorModel } from '../models/activitypub/actor'
12import { UserNotificationSettingModel } from '../models/account/user-notification-setting' 11import { UserNotificationSettingModel } from '../models/account/user-notification-setting'
13import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users' 12import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users'
13import { createWatchLaterPlaylist } from './video-playlist'
14import { sequelizeTypescript } from '../initializers/database'
14 15
15async function createUserAccountAndChannel (userToCreate: UserModel, validateUser = true) { 16async function createUserAccountAndChannelAndPlaylist (userToCreate: UserModel, validateUser = true) {
16 const { user, account, videoChannel } = await sequelizeTypescript.transaction(async t => { 17 const { user, account, videoChannel } = await sequelizeTypescript.transaction(async t => {
17 const userOptions = { 18 const userOptions = {
18 transaction: t, 19 transaction: t,
@@ -38,7 +39,9 @@ async function createUserAccountAndChannel (userToCreate: UserModel, validateUse
38 } 39 }
39 const videoChannel = await createVideoChannel(videoChannelInfo, accountCreated, t) 40 const videoChannel = await createVideoChannel(videoChannelInfo, accountCreated, t)
40 41
41 return { user: userCreated, account: accountCreated, videoChannel } 42 const videoPlaylist = await createWatchLaterPlaylist(accountCreated, t)
43
44 return { user: userCreated, account: accountCreated, videoChannel, videoPlaylist }
42 }) 45 })
43 46
44 const [ accountKeys, channelKeys ] = await Promise.all([ 47 const [ accountKeys, channelKeys ] = await Promise.all([
@@ -69,7 +72,7 @@ async function createLocalAccountWithoutKeys (
69 userId, 72 userId,
70 applicationId, 73 applicationId,
71 actorId: actorInstanceCreated.id 74 actorId: actorInstanceCreated.id
72 } as FilteredModelAttributes<AccountModel>) 75 })
73 76
74 const accountInstanceCreated = await accountInstance.save({ transaction: t }) 77 const accountInstanceCreated = await accountInstance.save({ transaction: t })
75 accountInstanceCreated.Actor = actorInstanceCreated 78 accountInstanceCreated.Actor = actorInstanceCreated
@@ -89,7 +92,7 @@ async function createApplicationActor (applicationId: number) {
89 92
90export { 93export {
91 createApplicationActor, 94 createApplicationActor,
92 createUserAccountAndChannel, 95 createUserAccountAndChannelAndPlaylist,
93 createLocalAccountWithoutKeys 96 createLocalAccountWithoutKeys
94} 97}
95 98
@@ -103,10 +106,12 @@ function createDefaultUserNotificationSettings (user: UserModel, t: Sequelize.Tr
103 myVideoImportFinished: UserNotificationSettingValue.WEB, 106 myVideoImportFinished: UserNotificationSettingValue.WEB,
104 myVideoPublished: UserNotificationSettingValue.WEB, 107 myVideoPublished: UserNotificationSettingValue.WEB,
105 videoAbuseAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, 108 videoAbuseAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
109 videoAutoBlacklistAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
106 blacklistOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, 110 blacklistOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
107 newUserRegistration: UserNotificationSettingValue.WEB, 111 newUserRegistration: UserNotificationSettingValue.WEB,
108 commentMention: UserNotificationSettingValue.WEB, 112 commentMention: UserNotificationSettingValue.WEB,
109 newFollow: UserNotificationSettingValue.WEB 113 newFollow: UserNotificationSettingValue.WEB,
114 newInstanceFollower: UserNotificationSettingValue.WEB
110 } 115 }
111 116
112 return UserNotificationSettingModel.create(values, { transaction: t }) 117 return UserNotificationSettingModel.create(values, { transaction: t })