eventlog: branding events

This commit is contained in:
Girish Ramakrishnan
2024-12-02 12:11:14 +01:00
parent 872705d58d
commit 0a4aede3a8
6 changed files with 33 additions and 6 deletions
+8 -2
View File
@@ -21,6 +21,7 @@ const apps = require('./apps.js'),
BoxError = require('./boxerror.js'),
constants = require('./constants.js'),
debug = require('debug')('box:branding'),
eventlog = require('./eventlog.js'),
paths = require('./paths.js'),
safe = require('safetydance'),
settings = require('./settings.js');
@@ -45,6 +46,7 @@ async function setCloudronName(name, auditSource) {
await safe(apps.configureApps(installedApps.filter((a) => !!a.manifest.addons?.oidc), { scheduleNow: true }, auditSource), { debug });
await settings.set(settings.CLOUDRON_NAME_KEY, name);
await eventlog.add(eventlog.ACTION_BRANDING_NAME, auditSource, { name });
}
async function getCloudronAvatar() {
@@ -58,10 +60,12 @@ async function getCloudronAvatar() {
throw new BoxError(BoxError.FS_ERROR, `Could not read avatar: ${safe.error.message}`);
}
async function setCloudronAvatar(avatar) {
async function setCloudronAvatar(avatar, auditSource) {
assert(Buffer.isBuffer(avatar));
assert(auditSource && typeof auditSource === 'object');
await settings.setBlob(settings.CLOUDRON_AVATAR_KEY, avatar);
await eventlog.add(eventlog.ACTION_BRANDING_AVATAR, auditSource, {});
}
async function getCloudronBackground() {
@@ -90,8 +94,10 @@ async function getFooter() {
return value || constants.FOOTER;
}
async function setFooter(footer) {
async function setFooter(footer, auditSource) {
assert.strictEqual(typeof footer, 'string');
assert(auditSource && typeof auditSource === 'object');
await settings.set(settings.FOOTER_KEY, footer);
await eventlog.add(eventlog.ACTION_BRANDING_FOOTER, auditSource, { footer });
}