farmcontrol-api/src/auditOwner.js
Tom Butcher d86dbe0261
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
Enhance email management features with new schemas and routes
This commit introduces new schemas and routes for managing email accounts, email messages, and email templates. It adds functionality for CRUD operations on these entities, including listing, searching, and retrieving properties. The email message handling is enhanced with a worker for asynchronous email delivery, and the audit log schema is updated to accommodate system actions. Additionally, utility functions are improved for better data handling and validation. These changes significantly enhance the application's email management capabilities.
2026-09-12 21:40:07 +01:00

29 lines
742 B
JavaScript

const AUDIT_OWNER_TYPES = ['user', 'printer', 'host', 'marketplace'];
export function resolveAuditOwner(actor) {
if (actor === 'system') {
return {
system: true,
};
}
const ownerType = AUDIT_OWNER_TYPES.includes(actor?._objectType) ? actor._objectType : 'user';
return {
system: false,
owner: actor?._id,
ownerType,
};
}
export function actorDisplayName(actor) {
if (actor === 'system') return 'system';
if (actor?._objectType === 'marketplace' || actor?._objectType === 'host') {
return actor.name || actor._objectType;
}
const firstName = actor?.firstName ?? 'unknown';
const lastName = actor?.lastName ?? '';
return `${firstName} ${lastName}`.trim();
}
export { AUDIT_OWNER_TYPES };