Repository navigation
Message System
Part of Communication-and-Engagement.
Models: app/models/message.rb, app/models/sent_message.rb · Controller: app/controllers/messages_controller.rb
The shared substrate underneath both Contact-System and Feedback-System replies, and a standalone internal messaging system for transcribers/coordinators. One collection, four workflows distinguished by nature/sub_nature:
nature |
sub_nature |
Meaning |
|---|---|---|
contact |
(reply) / comment / forward
|
Coordinator reply, internal comment, or forward on a Contact (source_contact_id set) |
feedback |
(reply) / comment
|
Coordinator reply or internal comment on a Feedback (source_feedback_id set) |
general / syndicate
|
— | Peer-to-peer messages between users, optionally scoped to a syndicate
|
communication |
(reply) / comment
|
Broadcast-style "Communicate Action" message to a role (e.g. county/syndicate coordinator) — also used by the FreeCEN Gazetteer "contact this coordinator" flow |
A Message can itself be replied to (source_message_id, self-referential), so replies-to-replies all live in the same collection and share the archive/keep/thread machinery.
Embedded in Message (embeds_many :sent_messages) and represents one actual delivery event: recipients, other_recipients, sender, sent_time, active, inactive_reason, open_data_status. A message can have more than one SentMessage (e.g. a syndicate broadcast sent in batches, or a resend). "Sent" is defined structurally (sent_time + recipients both present), not by any real delivery confirmation from the mailer.
create dispatches on the submit button's literal label (params[:commit]: 'Save Message', 'Save & Send', 'Reply Feedback', 'Feedback Comment', 'Reply Contact', 'Contact Comment', 'Reply Message', 'Message Comment', 'Save Communication', 'Reply Communication', 'Communication Comment'), each routing to a differently-named private method that sets nature/sub_nature and saves. This couples controller logic to exact view button text — renaming a button in a view silently breaks that flow.
Other things worth knowing before you touch this controller:
- The many
list_*actions (list_by_name,list_by_date,list_by_most_recent,list_archived,list_syndicate_messages,list_unsent_messages, …) are near-duplicates differing only in theorderstring passed toMessage.list_messages. -
select_recipients/select_individual/select_roleimplement a 3-step recipient-picking wizard for Communicate Action / Gazetteer flows. -
extract_coordinators/extract_others(model) recover recipient identity by string-parsing display labels like"Bedfordshire (USERID) [Forename Surname]"(.split('(')/.split('[')) rather than carrying id/label as separate values — fragile if the label format ever changes. -
return_after_*/return_for_createbranch onsession[:message_base](a stringy session flag like'general'/'syndicate'/'communication') to decide the redirect target — a stale session value can send you to the wrong page.
resources :messages plus ~20 custom routes (config/routes.rb:196-225) for list variants, reply/forward flows, archive/restore/keep/unkeep, recipient selection, and gazetteer_county_coordinator.
© 2025 FreeUKGen. Licensed under Apache License 2.0