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
+6 -2
View File
@@ -56,9 +56,13 @@ export default class Tasks extends EventEmitter {
}, },
}) })
#app
constructor(app) { constructor(app) {
super() super()
this.#app = app
app.hooks app.hooks
.on('clean', () => this.#gc(app.config.getOptional('tasks.gc.keep') ?? 1e3)) .on('clean', () => this.#gc(app.config.getOptional('tasks.gc.keep') ?? 1e3))
.on('start', async () => { .on('start', async () => {
@@ -131,10 +135,10 @@ export default class Tasks extends EventEmitter {
* *
* @returns {Task} * @returns {Task}
*/ */
create({ name, objectId, type }) { create({ name, objectId, userId = this.#app.apiContext?.user.id, type }) {
const tasks = this.#tasks 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 // Use a compact, sortable, string representation of the creation date
// //
+1
View File
@@ -33,6 +33,7 @@
<!--packages-start--> <!--packages-start-->
- @xen-orchestra/backups patch - @xen-orchestra/backups patch
- @xen-orchestra/mixins minor
- xen-api patch - xen-api patch
- xo-server patch - xo-server patch
- xo-server-auth-ldap patch - xo-server-auth-ldap patch