+
+ const [ accountActorWithKeys, channelActorWithKeys ] = await Promise.all([
+ setAsyncActorKeys(account.Actor),
+ setAsyncActorKeys(videoChannel.Actor)
+ ])
+
+ account.Actor = accountActorWithKeys
+ videoChannel.Actor = channelActorWithKeys
+
+ return { user, account, videoChannel }
+}
+
+async function createLocalAccountWithoutKeys (parameters: {
+ name: string
+ displayName?: string
+ userId: number | null
+ applicationId: number | null
+ t: Transaction | undefined
+ type?: ActivityPubActorType
+}) {
+ const { name, displayName, userId, applicationId, t, type = 'Person' } = parameters
+ const url = getAccountActivityPubUrl(name)
+
+ const actorInstance = buildActorInstance(type, url, name)
+ const actorInstanceCreated: MActorDefault = await actorInstance.save({ transaction: t })
+
+ const accountInstance = new AccountModel({
+ name: displayName || name,
+ userId,
+ applicationId,
+ actorId: actorInstanceCreated.id
+ })
+
+ const accountInstanceCreated: MAccountDefault = await accountInstance.save({ transaction: t })
+ accountInstanceCreated.Actor = actorInstanceCreated
+
+ return accountInstanceCreated
+}
+
+async function createApplicationActor (applicationId: number) {
+ const accountCreated = await createLocalAccountWithoutKeys({
+ name: SERVER_ACTOR_NAME,
+ userId: null,
+ applicationId: applicationId,
+ t: undefined,
+ type: 'Application'
+ })
+
+ accountCreated.Actor = await setAsyncActorKeys(accountCreated.Actor)
+
+ return accountCreated
+}
+
+async function sendVerifyUserEmail (user: MUser, isPendingEmail = false) {
+ const verificationString = await Redis.Instance.setVerifyEmailVerificationString(user.id)
+ let url = WEBSERVER.URL + '/verify-account/email?userId=' + user.id + '&verificationString=' + verificationString
+
+ if (isPendingEmail) url += '&isPendingEmail=true'
+
+ const email = isPendingEmail ? user.pendingEmail : user.email
+ const username = user.username
+
+ await Emailer.Instance.addVerifyEmailJob(username, email, url)