From 932d4a4be40587fa6d489eca16a1ef6d6f2936d1 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 23 Jul 2026 12:24:52 +0200 Subject: Witness asset uploads and out-of-band attaches in the action log --- app/models/node.rb | 8 ++++++++ app/models/node_action.rb | 11 +++++++++++ 2 files changed, 19 insertions(+) (limited to 'app/models') diff --git a/app/models/node.rb b/app/models/node.rb index 7a93e799..0a9cd2d1 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -501,6 +501,14 @@ class Node < ApplicationRecord to_attach.each do |row| row.related_assets.create!(:asset => asset, :headline => headline_state == :set) end + + if to_attach.any? + metadata = { :asset_name => asset.name, + :path => asset.upload.url.sub(/\?\d+$/, "") } + metadata[:headline] = true if headline_state == :set + NodeAction.record!(:node => self, :participants => [self, asset], + :user => user, :action => "asset_attach", **metadata) + end end { :attached => to_attach.size, diff --git a/app/models/node_action.rb b/app/models/node_action.rb index 9ed0b628..aa52f489 100644 --- a/app/models/node_action.rb +++ b/app/models/node_action.rb @@ -69,6 +69,17 @@ class NodeAction < ApplicationRecord # "path" -- final path, flat string (create-symmetric) # "destroyed_descendants" -- integer, only when positive; one entry # at the root, per the subtree rule. + # + # "asset_create" (witnessed upload; participants: the asset alone): + # "asset_name", "content_type", "path" -- flat strings + # + # "asset_attach" (out-of-band attach via Node#attach_asset!; written + # only when at least one new join was created, per the tandem rule -- + # in-editor curation stays draft-scoped and surfaces at publish. + # participants: the node (primary) and the asset): + # "asset_name", "path" -- flat strings + # "headline" -- boolean, only when set by this attach + # # "asset_destroy" (witnessed asset deletion; always written, even for # unattached assets -- the files were publicly reachable; node column # nil, subjects via participants: the asset plus every then-attached -- cgit v1.3