Strip timeline activity diffs of target objects the role cannot read
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 role | Before | After |
|---|---|---|
Target object denied, timelineActivity readable | full diff | empty diff |
| Linked object denied | empty diff | empty diff |
| One target field restricted | that field stripped | that 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
personreads the person's timeline activities without any of the diff values.