MessageDetailTrait
Conversation detail: header, participants and chronological message list.
NOTE: membership is not checked separately: the Api action looks threads up via participants, so a foreign id returns nothing by itself and the presenter answers 404. A 403 would reveal which ids exist.
IMPORTANT: the order in actionDetail() is intentional: messages unread at the moment of
opening are computed before markThreadRead(), which moves last_read_datetime and resets
the counter, so afterwards no message would count as unread.
Table of Contents
Properties
- $newMessageIds : array<int, true>
- $openedThread : MessageThread|null
- $participantViews : array<int, MessageParticipantView>
- $readMessageIds : array<int, true>
- $systemEvents : array<int, array{event: string, name: string}>
- $threadMessages : array<int, Message>
Methods
- actionDetail() : void
- renderDetail() : void
- buildSystemEvents() : array<int, array{event: string, name: string}>
- Builds the system messages "X joined / left the conversation". The message text in the DB is a code (see {@see MessageSystemEvent}); the sentence is composed here from the translation and the participant's current name (also a former one, the Api still returns the row).
- collectGuestContacts() : array<int, MessageParticipantView>
- Returns contacts of participants without an account: the only way to reply to an `email_only` thread.
- findMyParticipantRow() : MessageParticipant|null
- My participant row (`myList`, the caller's only); carries `last_read_datetime` and the counter.
- indexById() : array<int, MessageParticipantView>
- initConversation() : void
- Loads messages and participants (other party's name, guest contact) and counts new messages.
- loadThread() : MessageThread|null
Properties
$newMessageIds
private
array<int, true>
$newMessageIds
= []
ids of messages that were unread for me when the thread was opened
$openedThread
private
MessageThread|null
$openedThread
= null
$participantViews
private
array<int, MessageParticipantView>
$participantViews
= []
$readMessageIds
private
array<int, true>
$readMessageIds
= []
ids of MY messages the other party read (only with "message read receipts" enabled)
$systemEvents
private
array<int, array{event: string, name: string}>
$systemEvents
= []
system messages (joined / left) by message id
$threadMessages
private
array<int, Message>
$threadMessages
= []
Methods
actionDetail()
public
actionDetail(int $id) : void
Parameters
- $id : int
renderDetail()
public
renderDetail(int $id) : void
Parameters
- $id : int
buildSystemEvents()
Builds the system messages "X joined / left the conversation". The message text in the DB is a code (see {@see MessageSystemEvent}); the sentence is composed here from the translation and the participant's current name (also a former one, the Api still returns the row).
private
buildSystemEvents(array<int, Message> $messages, array<int, MessageParticipantView> $participantMap) : array<int, array{event: string, name: string}>
Parameters
- $messages : array<int, Message>
- $participantMap : array<int, MessageParticipantView>
Return values
array<int, array{event: string, name: string}>collectGuestContacts()
Returns contacts of participants without an account: the only way to reply to an `email_only` thread.
private
collectGuestContacts(array<int, MessageParticipantView> $participants) : array<int, MessageParticipantView>
Parameters
- $participants : array<int, MessageParticipantView>
Return values
array<int, MessageParticipantView>findMyParticipantRow()
My participant row (`myList`, the caller's only); carries `last_read_datetime` and the counter.
private
findMyParticipantRow(int $id) : MessageParticipant|null
Parameters
- $id : int
Return values
MessageParticipant|nullindexById()
private
indexById(array<int, MessageParticipantView> $participants) : array<int, MessageParticipantView>
Parameters
- $participants : array<int, MessageParticipantView>
Return values
array<int, MessageParticipantView>initConversation()
Loads messages and participants (other party's name, guest contact) and counts new messages.
private
initConversation(int $id) : void
Participants do not come from MessageParticipant:myList (the caller's rows only, so the
other party's messages would have no author) but from myThreadParticipants: name plus,
for a guest, the contact, nothing more.
Parameters
- $id : int
loadThread()
private
loadThread(int $id) : MessageThread|null
Parameters
- $id : int