feat(mixins/Tasks): inject userId in tasks

This commit is contained in:
Julien Fontanet
2023-08-09 16:18:29 +02:00
parent 3081810450
commit 1ddbe87d0f
2 changed files with 7 additions and 2 deletions

View File

@@ -56,9 +56,13 @@ export default class Tasks extends EventEmitter {
},
})
#app
constructor(app) {
super()
this.#app = app
app.hooks
.on('clean', () => this.#gc(app.config.getOptional('tasks.gc.keep') ?? 1e3))
.on('start', async () => {
@@ -131,10 +135,10 @@ export default class Tasks extends EventEmitter {
*
* @returns {Task}
*/
create({ name, objectId, type }) {
create({ name, objectId, userId = this.#app.apiContext?.user.id, type }) {
const tasks = this.#tasks
const task = new Task({ properties: { name, objectId, type }, onProgress: this.#onProgress })
const task = new Task({ properties: { name, objectId, userId, type }, onProgress: this.#onProgress })
// Use a compact, sortable, string representation of the creation date
//

View File

@@ -33,6 +33,7 @@
<!--packages-start-->
- @xen-orchestra/backups patch
- @xen-orchestra/mixins minor
- xen-api patch
- xo-server patch
- xo-server-auth-ldap patch