Who Sent A Reply Developer Guide - edmozley/freeitsm GitHub Wiki
โ๏ธ Who sent a reply - Developer Guide
GitHub #452, split from #444 (raised by @medium00rare-art) ยท Tickets ยท built after 5.12.1 (#3239-#3241)
How a reply from a ticket records the analyst who sent it, and how a chat channel can sign its replies. For what an analyst sees, start at Tickets โ Who sent each reply.
What was missing
A reply was stored as the mailbox (email) or the channel (chat), and nothing recorded which analyst pressed Send - for email as much as for chat. The thread, the audit and a handover could say that a reply went, but not who wrote it.
What is recorded
| Where | What |
|---|---|
emails.sent_by_analyst_id |
The analyst who sent this outbound message from a ticket. NULL for inbound mail, and for anything FreeITSM sends by itself (acknowledgements, CSAT, workflows, closing messages) |
ticket_audit |
A Reply sent line by that analyst, naming the mailbox or channel |
| The thread | api/tickets/get_ticket_thread.php returns sent_by_name; the reading pane shows by Jane beside an outbound message |
Set by every path an analyst replies through:
| Path | File |
|---|---|
| Email reply / reply all / forward | api/tickets/send_email.php (saveSentEmail() returns the row id) |
| Chat text reply | api/messaging/send_message.php |
| Chat attachment | api/messaging/send_attachment.php |
| WhatsApp template | api/messaging/send_template.php |
// includes/reply_sender.php - after the message has gone. Best-effort: a failure here
// must never report a reply that was sent as failed.
replySenderRecord($conn, $emailId, $ticketId, $analystId, $channelOrMailboxName);
The column is in the analyst lifecycle registry as history: it is kept, like an audit line, when an analyst is deactivated or deleted.
Signing a chat reply
messaging_channels.reply_signature - Settings โ Messaging โ a channel โ Replies say who sent them:
| Value | The reply reads |
|---|---|
none (default) |
Thanks, we are on it. - the channel speaks for the team, as before |
name |
Jane Smith: Thanks, we are on it. |
name_team |
Jane Smith (Service Desk): Thanks, we are on it. - the ticket's team; with none, just the name |
$body = replySignaturePrefix($conn, $channel, $analystId, $ticketId) . $body;
$providerMsgId = $provider->sendMessage($recipient, $body);
- What is stored is exactly what was sent, prefix included, so the thread shows what the person in the chat read.
- Text replies and attachment captions get it. A file sent with no caption gets none: a caption that is only a name reads oddly.
- A WhatsApp template is never changed - it is pre-approved word for word - but its sender is still recorded.
- An unknown value reads as
none. The setting is saved in its ownUPDATE, only once Database Verification has added the column, so a channel still saves on an install part-way through an upgrade.
๐ Files
| File | Change |
|---|---|
๐ข includes/reply_sender.php |
replySenderReady(), replySenderRecord(), replySignaturePrefix() |
๐ก api/messaging/send_message.php, send_attachment.php, send_template.php |
Prefix and record |
๐ก api/tickets/send_email.php |
Record |
๐ก api/tickets/get_ticket_thread.php, assets/js/inbox.js, assets/css/inbox.css |
by Jane in the thread |
๐ก api/messaging/save_channel.php, get_channels.php, tickets/settings/index.php |
The channel setting |
๐ฃ database/freeitsm.sql, includes/db_verify_schema.php, includes/analyst_lifecycle.php |
emails.sent_by_analyst_id, messaging_channels.reply_signature |
๐ข tests/reply-sender.php |
12 checks |
How it was proved
tests/reply-sender.php sends real replies through send_message.php on a web chat channel, which sends nothing outside the install. It checks:
- the sender, both on the message and in the audit;
- the thread's
sent_by_name; - each signature mode, against the unsigned control and on a ticket with no team;
- that an inbound message has no sender;
- the lifecycle entry and the channel list.
The reading pane was also checked in a browser.