Strip timeline activity diffs of target objects the role cannot read

Merged
CH
8d ago
+54-6

Fixes #30993.

A role that cannot read an object but can read timelineActivity got the full properties.diff of that object's records. The "object unreadable, keep no field" branch in omitRestrictedFieldsFromTimelineActivity only ran for linked activities (a note or task attached to the record), so rows targeting the record directly only had per-field restrictions applied.

The check now runs for whichever object the activity resolves to, linked or target.

flowchart LR
  A[timelineActivity row] --> B{linkedObjectMetadataId set?}
  B -- yes --> C[linked object]
  B -- no --> D[target column object]
  C --> E{object unreadable?}
  D --> E
  E -- yes --> F[keep no field]
  E -- no --> G[drop unreadable fields only]
Member's roleBeforeAfter
Target object denied, timelineActivity readablefull diffempty diff
Linked object deniedempty diffempty diff
One target field restrictedthat field strippedthat field stripped

Not in this PR

Rows on a denied record are still listed (with happensAt, name, linkedRecordCachedName), so the member can tell the record exists and when it changed. timelineActivity follows plain role access since inherited readability was dropped in #29034, which accepted that until the record permissions rewrite. Hiding the rows needs a query-level gate, not this post-read handler.

Tests

  • Unit: a direct activity on an unreadable target object keeps no field.
  • Integration: a role denied person reads the person's timeline activities without any of the diff values.