]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/user.ts
expliciting type checks and predicates (server only)
[github/Chocobozzz/PeerTube.git] / server / lib / user.ts
index 51050de9b2a927a7fcb3f238d7f5f3f95680b71a..ac5f55260ea5b68e290b463cbcd072f13578ff30 100644 (file)
@@ -6,6 +6,7 @@ import { UserModel } from '../models/account/user'
 import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub'
 import { createVideoChannel } from './video-channel'
 import { VideoChannelModel } from '../models/video/video-channel'
+import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
 
 async function createUserAccountAndChannel (userToCreate: UserModel, validateUser = true) {
   const { user, account, videoChannel } = await sequelizeTypescript.transaction(async t => {
@@ -34,9 +35,9 @@ async function createUserAccountAndChannel (userToCreate: UserModel, validateUse
 
 async function createLocalAccountWithoutKeys (
   name: string,
-  userId: number,
-  applicationId: number,
-  t: Sequelize.Transaction,
+  userId: number | null,
+  applicationId: number | null,
+  t: Sequelize.Transaction | undefined,
   type: ActivityPubActorType= 'Person'
 ) {
   const url = getAccountActivityPubUrl(name)
@@ -49,7 +50,7 @@ async function createLocalAccountWithoutKeys (
     userId,
     applicationId,
     actorId: actorInstanceCreated.id
-  })
+  } as FilteredModelAttributes<AccountModel>)
 
   const accountInstanceCreated = await accountInstance.save({ transaction: t })
   accountInstanceCreated.Actor = actorInstanceCreated