feat: add triggered by metadata
This commit is contained in:
parent
59841a609a
commit
b7b65a966b
1 changed files with 13 additions and 2 deletions
|
|
@ -131,7 +131,7 @@ export class BackupController extends Controller {
|
|||
@Post("create")
|
||||
@Security("keycloak")
|
||||
async runBackup(
|
||||
@Request() req: Request & { user: { sub: string } },
|
||||
@Request() req: Request & { user: { sub: string; preferred_username: string } },
|
||||
@Body() body?: { name?: string },
|
||||
) {
|
||||
const timestamp = Math.round(Date.now() / 1000);
|
||||
|
|
@ -177,6 +177,10 @@ export class BackupController extends Controller {
|
|||
db_password: DB_PASSWORD,
|
||||
db_list: DB_LIST?.replaceAll(",", " "),
|
||||
},
|
||||
metadata: {
|
||||
triggered_by: req.user.preferred_username,
|
||||
triggered_by_id: req.user.sub,
|
||||
},
|
||||
}),
|
||||
},
|
||||
).then(async (r) => jsonParseOrPlainText(await r.text()));
|
||||
|
|
@ -198,7 +202,10 @@ export class BackupController extends Controller {
|
|||
|
||||
@Post("restore")
|
||||
@Security("keycloak")
|
||||
async restoreBackup(@Body() body: { name: string }) {
|
||||
async restoreBackup(
|
||||
@Request() req: Request & { user: { sub: string; preferred_username: string } },
|
||||
@Body() body: { name: string },
|
||||
) {
|
||||
const listRunning = await this.runningRestoreStatus();
|
||||
|
||||
if (!listRunning || listRunning.length > 0) {
|
||||
|
|
@ -234,6 +241,10 @@ export class BackupController extends Controller {
|
|||
db_user: DB_USERNAME,
|
||||
db_password: DB_PASSWORD,
|
||||
},
|
||||
metadata: {
|
||||
triggered_by: req.user.preferred_username,
|
||||
triggered_by_id: req.user.sub,
|
||||
},
|
||||
}),
|
||||
},
|
||||
).then(async (r) => jsonParseOrPlainText(await r.text()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue