fix(templateengine): audit projected template/script summaries instead of the tracked graph and script bodies (review 2026-10-21 08/G1)
This commit is contained in:
@@ -84,7 +84,7 @@ public class TemplateService
|
||||
// to the row it described.
|
||||
await _repository.AddTemplateAsync(template, cancellationToken);
|
||||
await _repository.SaveChangesAsync(cancellationToken);
|
||||
await _auditService.LogAsync(user, "Create", "Template", template.Id.ToString(), name, template, cancellationToken);
|
||||
await _auditService.LogAsync(user, "Create", "Template", template.Id.ToString(), name, TemplateAuditShapes.Template(template), cancellationToken);
|
||||
await _repository.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return Result<Template>.Success(template);
|
||||
@@ -130,6 +130,12 @@ public class TemplateService
|
||||
"Parent template cannot be changed after creation.");
|
||||
}
|
||||
|
||||
var changedFields = new List<string>();
|
||||
if (!string.Equals(template.Name, name, StringComparison.Ordinal))
|
||||
changedFields.Add(nameof(Template.Name));
|
||||
if (description != null && !string.Equals(template.Description, description, StringComparison.Ordinal))
|
||||
changedFields.Add(nameof(Template.Description));
|
||||
|
||||
template.Name = name;
|
||||
// Leave-unchanged semantics: only overwrite the description when a value is
|
||||
// supplied. null = not provided (keep existing); "" = explicit clear.
|
||||
@@ -142,7 +148,10 @@ public class TemplateService
|
||||
return Result<Template>.Failure(collisionResult);
|
||||
|
||||
await _repository.UpdateTemplateAsync(template, cancellationToken);
|
||||
await _auditService.LogAsync(user, "Update", "Template", templateId.ToString(), name, template, cancellationToken);
|
||||
// Audit a projected summary, never the tracked graph with every script body
|
||||
// (review 2026-10-21 08/G1).
|
||||
await _auditService.LogAsync(user, "Update", "Template", templateId.ToString(), name,
|
||||
TemplateAuditShapes.Template(template, changedFields), cancellationToken);
|
||||
await _repository.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return Result<Template>.Success(template);
|
||||
@@ -234,7 +243,8 @@ public class TemplateService
|
||||
|
||||
template.FolderId = newFolderId;
|
||||
await _repository.UpdateTemplateAsync(template, cancellationToken);
|
||||
await _auditService.LogAsync(user, "Move", "Template", template.Id.ToString(), template.Name, template, cancellationToken);
|
||||
await _auditService.LogAsync(user, "Move", "Template", template.Id.ToString(), template.Name,
|
||||
TemplateAuditShapes.Template(template, [nameof(Template.FolderId)]), cancellationToken);
|
||||
await _repository.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return Result<Template>.Success(template);
|
||||
@@ -723,7 +733,7 @@ public class TemplateService
|
||||
// real script Id rather than a literal "0".
|
||||
await _repository.AddTemplateScriptAsync(script, cancellationToken);
|
||||
await _repository.SaveChangesAsync(cancellationToken);
|
||||
await _auditService.LogAsync(user, "Create", "TemplateScript", script.Id.ToString(), script.Name, script, cancellationToken);
|
||||
await _auditService.LogAsync(user, "Create", "TemplateScript", script.Id.ToString(), script.Name, TemplateAuditShapes.Script(script), cancellationToken);
|
||||
await _repository.SaveChangesAsync(cancellationToken);
|
||||
|
||||
// Propagate the new member to derived descendants.
|
||||
@@ -809,7 +819,7 @@ public class TemplateService
|
||||
// Name is NOT updated (fixed)
|
||||
|
||||
await _repository.UpdateTemplateScriptAsync(existing, cancellationToken);
|
||||
await _auditService.LogAsync(user, "Update", "TemplateScript", scriptId.ToString(), existing.Name, existing, cancellationToken);
|
||||
await _auditService.LogAsync(user, "Update", "TemplateScript", scriptId.ToString(), existing.Name, TemplateAuditShapes.Script(existing), cancellationToken);
|
||||
await _repository.SaveChangesAsync(cancellationToken);
|
||||
|
||||
// Propagate the changed effective value to derived descendants.
|
||||
|
||||
Reference in New Issue
Block a user