1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Fix missing transactions

This commit is contained in:
Chocobozzz 2021-06-15 09:17:19 +02:00
parent 51f636ad0f
commit eae0365b5c
No known key found for this signature in database
GPG key ID: 583A612D890159BE
14 changed files with 65 additions and 69 deletions

View file

@ -44,11 +44,11 @@ async function createUserAccountAndChannelAndPlaylist (parameters: {
displayName: userDisplayName,
userId: userCreated.id,
applicationId: null,
t: t
t
})
userCreated.Account = accountCreated
const channelAttributes = await buildChannelAttributes(userCreated, channelNames)
const channelAttributes = await buildChannelAttributes(userCreated, t, channelNames)
const videoChannel = await createLocalVideoChannel(channelAttributes, accountCreated, t)
const videoPlaylist = await createWatchLaterPlaylist(accountCreated, t)
@ -203,13 +203,13 @@ function createDefaultUserNotificationSettings (user: MUserId, t: Transaction |
return UserNotificationSettingModel.create(values, { transaction: t })
}
async function buildChannelAttributes (user: MUser, channelNames?: ChannelNames) {
async function buildChannelAttributes (user: MUser, transaction?: Transaction, channelNames?: ChannelNames) {
if (channelNames) return channelNames
let channelName = user.username + '_channel'
// Conflict, generate uuid instead
const actor = await ActorModel.loadLocalByName(channelName)
const actor = await ActorModel.loadLocalByName(channelName, transaction)
if (actor) channelName = uuidv4()
const videoChannelDisplayName = `Main ${user.username} channel`