Skip to content

Ticket Participants PR Review

Ed Mozley edited this page Nov 28, 2026 · 1 revision

Ticket participants and automatic replies - PR review

PR #440 by @cloudcogsio Β· Issue #432 (from discussion #389) Β· Verdict: merge + fix Β· 5.12.0

Two things in one PR, as agreed in #432:

  • Participants - other people kept in Cc on a ticket's emails without re-adding them every time.
  • Automatic replies recognised on inbound mail, so an out-of-office never reopens a ticket or pretends to be the requester.

User page: Tickets Β§ Participants and Β§ Automatic replies.

The narrowed first version - every condition checked

The issue agreed a narrower v1 than first proposed. Each condition was checked against the code, not the description:

Condition (#432) Result
The portal rule does not change - Cc was already counted; widening it would show participant-only mail to requesters βœ… No portal file touched; portalEmailInvolvesRequester() unchanged
No automatic adding from an inbound Cc βœ… TicketParticipants::add() is called only from the ticket page and the REST API - never from the importers
Every automatic-email event off by default βœ… events() is empty until the setting is saved; nothing ticked on the settings page
No participants on a confidential ticket βœ… Refused on add, removed on every route that raises a ticket to confidential, and checked again when the Cc is built
Out-of-office detection in this PR, or first βœ… In the first commits - with one open question for Microsoft 365, below

βœ… What was good - keep it this way

What Why it matters
One service, TicketParticipants, behind the page, the REST API and the automatic emails, with typed error codes the page translates The page and the API cannot drift apart (Service layer)
Confidential enforced three times - on add, on raise (ticketSensitivityRaise() covers department, mailbox, portal, split and merge), and when the Cc is built Belt and braces on the HR and leaver path
Merge decides once whether the survivor will be confidential, and keeps dropped rows in the merge record so Undo merge restores them A real ordering trap when several tickets are merged
Automatic replies touch nothing a person's reply would - no reopen, no snooze wake, no updated_datetime, no ticket.reply_received - and get no acknowledgement Real loop protection; nothing lost, the mail is still stored
auto-generated is deliberately not an automatic reply Another service desk or Jira stamps it on mail carrying what a person wrote; that must still reopen
Nothing writes before Database Verification (ready(), emailAutoReplyReady()) Mail collection never stops on an install that has not run it
The people and analyst lifecycle is complete - analystReferenceRegistry, USER_DELETE_CASCADE, person merge, trash, permanent delete, D002 Nothing is orphaned when someone leaves
Internal notes can never reach a participant - only requester-audience events copy Answers "what can a participant receive?"
184 checks across three new tests, a before-Verification sub-process, real API keys, and headless Reply / Forward The behaviour is proved end to end

πŸ”§ What was added and fixed when merging

1. A company-scoped API key could add a person from another company 🟠

resolvePerson() checked analystCanAccessUser() - the analyst's reach. A REST key can be narrowed to fewer companies than its analyst, so a key limited to company A, whose analyst also sees company B, could add a B person by id or address - and the 201 answer carried their name, email and company. Now actorSeesPerson() also applies the key's scope:

// TRAP: analystCanAccessUser() alone is the ANALYST's reach
private static function actorSeesPerson(PDO $conn, ActorContext $ctx, int $userId): bool
{
    if (!analystCanAccessUser($conn, $ctx->actorId, $userId)) return false;
    if ($ctx->companyScope === null || !isMultiTenant($conn)) return true;
    // ...the person's company must be one of the key's
}

Test: a key scoped to the Default company adding a person in another company, by id and by address - 404, nothing about them returned - with an unscoped-key control. Without the fix: 201 and 200, name and email in the answer.

2. A new person could be created out of sight 🟑

Adding by an address nobody has creates the person in the company their address belongs to - which might be one the analyst cannot reach. The person was created, added, and the next attempt answered not found. Now an unreachable company is not found before anything is created, and the preview says the same.

3. The header line 🟑

On a desktop, From, To, Cc and the date flow as one wrapping line (reading-pane.css, display: contents). The Participants row, one block, sat in the middle of it, so it pushed "To:" to the end of a line and its address onto the next. It now comes last, with the same gap as the others, and drops onto its own line when there is no room. Before / after screenshots were taken on a test ticket. (At about 1100px "To:" can still end a line on its own; that is the existing header flow and happens without participants too - a separate tidy-up.)

Smaller

  • The analyst-address check looked only at a person's main address; it now covers their linked addresses (#308) too, as the mailbox check already did.
  • No foreign key on ticket_participants.user_id. freeitsm.sql had one, but Database Verification would never add it, so only fresh installs would have it - the kind of drift that bit 5.8.0's fresh installs. Matches ticket_watchers; USER_DELETE_CASCADE removes the rows.
  • .participant-remove:hover used --danger, which does not exist in the theme; now --danger-accent.
  • A comment said analystCanAccessTicket() is a company check; it is department and company.
  • tests/ticket-participants.php passed its second process JSON on the command line; on Windows escapeshellarg() turns double quotes into spaces, so the before-Verification block never got its data. Now base64.

Left as it is - and why

  • Microsoft 365 out-of-office replies. Exchange may mark them only Auto-Submitted: auto-generated with X-Auto-Response-Suppress and X-MS-Exchange-Inbox-Rules-Loop. Treating that pair as an automatic reply was considered and not done: mail forwarded by an Exchange inbox rule carries the same pair - and can carry a person's real reply, which must still reopen the ticket. The rule should be written from a real Microsoft 365 out-of-office, so one has been asked for. Until then such a reply may still reopen a ticket - as it did before this PR.
  • An unmatched automatic reply still fires ticket.created, so a workflow that emails on ticket creation could answer it. The PR said so; marking our own emails Auto-Submitted: auto-generated is the better fix and a follow-up.
  • Automatic replies fold only when message collapsing is on.

πŸ§ͺ What was checked

Test Result
tests/ticket-participants.php (the PR's, + the scoped key) 131 passed
tests/ticket-participants-reply.php 8 passed
tests/email-auto-reply.php 56 passed
tests/analyst-lifecycle.php, ticket-merge-undo.php, ticket-watchers.php, constraint-names-unique.php all pass
css-colour-guard, font-size-guard, web-exposure-guard, get-must-not-write, openapi_check all pass

On a disposable test install with Database Verification run first.


See also: Tickets Β· Watching a ticket Β· Bugs resolved

FreeITSM

Getting Started

Modules

Multi-tenancy (planned)

Responses to feedback

Blue sky thinking

Bugs resolved

Pull requests

Links

Clone this wiki locally