Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Return response status after transaction success

Chocobozzzddaf994d5386
diff --git a/server/core/controllers/api/users/user-exports.ts b/server/core/controllers/api/users/user-exports.ts
index 71a000704a..05201d7e33 100644
--- a/server/core/controllers/api/users/user-exports.ts
+++ b/server/core/controllers/api/users/user-exports.ts
@@ -15,19 +15,17 @@ import { CONFIG } from '@server/initializers/config.js'
const userExportsRouter = express.Router()
-userExportsRouter.post('/:userId/exports/request',
+userExportsRouter.post(
+ '/:userId/exports/request',
authenticate,
asyncMiddleware(userExportRequestValidator),
asyncMiddleware(requestExport)
)
-userExportsRouter.get('/:userId/exports',
- authenticate,
- asyncMiddleware(userExportsListValidator),
- asyncMiddleware(listUserExports)
-)
+userExportsRouter.get('/:userId/exports', authenticate, asyncMiddleware(userExportsListValidator), asyncMiddleware(listUserExports))
-userExportsRouter.delete('/:userId/exports/:id',
+userExportsRouter.delete(
+ '/:userId/exports/:id',
authenticate,
asyncMiddleware(userExportDeleteValidator),
asyncMiddleware(deleteUserExport)
@@ -83,15 +81,19 @@ async function listUserExports (req: express.Request, res: express.Response) {
async function deleteUserExport (req: express.Request, res: express.Response) {
const userExport = res.locals.userExport
- await sequelizeTypescript.transaction(async transaction => {
+ const result = await sequelizeTypescript.transaction(async transaction => {
await userExport.reload({ transaction })
if (!userExport.canBeSafelyRemoved()) {
- return res.sendStatus(HttpStatusCode.CONFLICT_409)
+ res.sendStatus(HttpStatusCode.CONFLICT_409)
+ return false
}
await userExport.destroy({ transaction })
+
+ return true
})
+ if (!result) return
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
}
diff --git a/server/core/controllers/api/videos/ownership.ts b/server/core/controllers/api/videos/ownership.ts
index 4827fd4e83..55c2da3e18 100644
--- a/server/core/controllers/api/videos/ownership.ts
+++ b/server/core/controllers/api/videos/ownership.ts
@@ -145,8 +145,8 @@ async function listAccountVideoOwnershipChanges (req: express.Request, res: expr
return res.json(getFormattedObjects(resultList.data, resultList.total))
}
-function acceptOwnershipChange (req: express.Request, res: express.Response) {
- return sequelizeTypescript.transaction(async t => {
+async function acceptOwnershipChange (req: express.Request, res: express.Response) {
+ await sequelizeTypescript.transaction(async t => {
const changeOwnership = res.locals.changeOwnership
const channel = res.locals.videoChannel
@@ -180,13 +180,13 @@ function acceptOwnershipChange (req: express.Request, res: express.Response) {
}
Notifier.Instance.notifyOfAcceptedVideoOwnershipChange(changeOwnership)
-
- return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
})
+
+ return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
}
-function refuseOwnershipChange (req: express.Request, res: express.Response) {
- return sequelizeTypescript.transaction(async t => {
+async function refuseOwnershipChange (req: express.Request, res: express.Response) {
+ await sequelizeTypescript.transaction(async t => {
const changeOwnership = res.locals.changeOwnership
changeOwnership.state = ChangeOwnershipState.REJECTED
@@ -204,13 +204,13 @@ function refuseOwnershipChange (req: express.Request, res: express.Response) {
})
Notifier.Instance.notifyOfRejectedVideoOwnershipChange(changeOwnership)
-
- return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
})
+
+ return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
}
-function deleteOwnershipChange (req: express.Request, res: express.Response) {
- return sequelizeTypescript.transaction(async t => {
+async function deleteOwnershipChange (req: express.Request, res: express.Response) {
+ await sequelizeTypescript.transaction(async t => {
const changeOwnership = res.locals.changeOwnership
const channel = await VideoChannelModel.loadAndPopulateAccount(changeOwnership.Video.channelId, t)
@@ -226,7 +226,7 @@ function deleteOwnershipChange (req: express.Request, res: express.Response) {
})
logger.info('Video ownership change request %d deleted.', changeOwnership.id)
-
- return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
})
+
+ return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
}