diff options
Diffstat (limited to 'server/lib/user.ts')
-rw-r--r-- | server/lib/user.ts | 19 |
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 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import * as uuidv4 from 'uuid/v4' | 2 | import * as uuidv4 from 'uuid/v4' |
3 | import { ActivityPubActorType } from '../../shared/models/activitypub' | 3 | import { ActivityPubActorType } from '../../shared/models/activitypub' |
4 | import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../initializers' | 4 | import { SERVER_ACTOR_NAME } from '../initializers/constants' |
5 | import { AccountModel } from '../models/account/account' | 5 | import { AccountModel } from '../models/account/account' |
6 | import { UserModel } from '../models/account/user' | 6 | import { UserModel } from '../models/account/user' |
7 | import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub' | 7 | import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub' |
8 | import { createVideoChannel } from './video-channel' | 8 | import { createVideoChannel } from './video-channel' |
9 | import { VideoChannelModel } from '../models/video/video-channel' | 9 | import { VideoChannelModel } from '../models/video/video-channel' |
10 | import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' | ||
11 | import { ActorModel } from '../models/activitypub/actor' | 10 | import { ActorModel } from '../models/activitypub/actor' |
12 | import { UserNotificationSettingModel } from '../models/account/user-notification-setting' | 11 | import { UserNotificationSettingModel } from '../models/account/user-notification-setting' |
13 | import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users' | 12 | import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users' |
13 | import { createWatchLaterPlaylist } from './video-playlist' | ||
14 | import { sequelizeTypescript } from '../initializers/database' | ||
14 | 15 | ||
15 | async function createUserAccountAndChannel (userToCreate: UserModel, validateUser = true) { | 16 | async 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 | ||
90 | export { | 93 | export { |
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 }) |