docs: archive add-custom-html-block and add-lead-notifications
Sync their spec deltas into landing-pages and the new lead-notifications spec, and point the deployment SQL paths at the archive folders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
This commit is contained in:
1 parent
d602cca2cd
commit
5b11e90303
19 files changed
+229
-7
No files matched your search
@@ -8,7 +8,7 @@ Public landing pages per company, built by staff from blocks in the back office
|
||||
|
||||
### Requirement: A Page Is An Ordered List Of Typed Blocks
|
||||
|
||||
A page SHALL belong to one company and have a slug, a title, an optional meta description, a status (Draft or Published) and an ordered list of zero to 30 blocks. The block types SHALL be HERO, RICH_TEXT, IMAGE_TEXT, FAQ and FORM. Blocks SHALL be returned in the order they were saved, and a valid save SHALL replace all of a page's blocks.
|
||||
A page SHALL belong to one company and have a slug, a title, an optional meta description, a status (Draft or Published), a "hide header" flag that defaults to off, and an ordered list of zero to 30 blocks. The block types SHALL be HERO, RICH_TEXT, IMAGE_TEXT, FAQ, FORM and HTML. Blocks SHALL be returned in the order they were saved, and a valid save SHALL replace all of a page's blocks.
|
||||
|
||||
#### Scenario: Blocks read back in order
|
||||
|
||||
@@ -21,6 +21,11 @@ A page SHALL belong to one company and have a slug, a title, an optional meta de
|
||||
- **WHEN** it is saved with only a RICH_TEXT block
|
||||
- **THEN** the page has only that RICH_TEXT block
|
||||
|
||||
#### Scenario: An HTML block and the header flag read back
|
||||
|
||||
- **WHEN** staff save a page with "hide header" on and blocks HTML, FORM
|
||||
- **THEN** reading the page returns "hide header" on and the HTML block with its HTML unchanged
|
||||
|
||||
### Requirement: Page Fields Are Validated Server-Side
|
||||
|
||||
A page save SHALL be refused with the offending field path, writing nothing, when the slug does not match `^[a-z0-9]+(-[a-z0-9]+)*$`, is longer than 80 characters or is used by another page of the same company, ignoring case; or when the title is blank or longer than 120 characters; or when the meta description is longer than 160 characters.
|
||||
@@ -39,13 +44,18 @@ A page save SHALL be refused with the offending field path, writing nothing, whe
|
||||
|
||||
### Requirement: Block Fields Are Validated Server-Side
|
||||
|
||||
A page save SHALL be refused with the offending field path, writing nothing, when a block has an unknown type, a required field is blank, or a text exceeds its limit: heading 120, text and FAQ question 300, button label 40, FAQ answer 2000, HTML 100000 characters. A FAQ SHALL have 1 to 30 items. `imagePosition` SHALL be LEFT or RIGHT.
|
||||
A page save SHALL be refused with the offending field path, writing nothing, when a block has an unknown type, a required field is blank, or a text exceeds its limit: heading 120, text and FAQ question 300, button label 40, FAQ answer 2000, rich-text HTML 100000 characters, and an HTML block's HTML 200000 characters. An HTML block's HTML SHALL NOT be blank. A FAQ SHALL have 1 to 30 items. `imagePosition` SHALL be LEFT or RIGHT.
|
||||
|
||||
#### Scenario: Too many blocks
|
||||
|
||||
- **WHEN** a page is saved with 31 blocks
|
||||
- **THEN** the save is refused and nothing is written
|
||||
|
||||
#### Scenario: HTML block too long
|
||||
|
||||
- **WHEN** a page is saved with an HTML block of 200001 characters
|
||||
- **THEN** the save is refused on field `blocks[0].html` and nothing is written
|
||||
|
||||
### Requirement: Block References Stay Inside The Company
|
||||
|
||||
A block's image SHALL be an image of the page's company, and a FORM block's event SHALL be an event of the page's company. Otherwise the save SHALL be refused on that field.
|
||||
@@ -58,7 +68,7 @@ A block's image SHALL be an image of the page's company, and a FORM block's even
|
||||
|
||||
### Requirement: Page Content Cannot Run Scripts
|
||||
|
||||
A button SHALL have both a label and a link or neither. The link SHALL be a same-site path starting with a single `/`, an `https://` URL, a `mailto:` link or a `tel:` link. A save SHALL be refused when any HTML holds a `script` element, an `on*` attribute or a `javascript:` URL. The public page SHALL also sanitise all HTML against an allow-list before rendering it.
|
||||
A button SHALL have both a label and a link or neither. The link SHALL be a same-site path starting with a single `/`, an `https://` URL, a `mailto:` link or a `tel:` link. A save SHALL be refused when the HTML of a RICH_TEXT or IMAGE_TEXT block holds a `script` element, an `on*` attribute or a `javascript:` URL. The public page SHALL also sanitise that HTML against an allow-list before rendering it. HTML blocks are exempt, because they only ever run sealed.
|
||||
|
||||
#### Scenario: Script link on a button
|
||||
|
||||
@@ -70,6 +80,11 @@ A button SHALL have both a label and a link or neither. The link SHALL be a same
|
||||
- **WHEN** a page is saved with rich text holding `<img src=x onerror=alert(1)>`
|
||||
- **THEN** the save is refused on that block's HTML field
|
||||
|
||||
#### Scenario: Script in an HTML block
|
||||
|
||||
- **WHEN** a page is saved with an HTML block holding `<script>document.title = "x"</script>`
|
||||
- **THEN** the save succeeds
|
||||
|
||||
### Requirement: Page Images
|
||||
|
||||
Staff with `BO_PAGES` SHALL upload images for their company in PNG, JPEG or WebP, each at most 2 MB, checked by the file's content and not by its name. Anyone SHALL be able to read an image by its id, so that public pages can show it.
|
||||
@@ -189,3 +204,76 @@ Server field errors SHALL show next to their fields, keeping all entered values.
|
||||
|
||||
- **WHEN** staff save a HERO button link `javascript:alert(1)`
|
||||
- **THEN** the error shows next to that button link and every entered value stays
|
||||
|
||||
### Requirement: Custom HTML Runs Sealed
|
||||
|
||||
The public page and the staff preview SHALL show each HTML block in a sandboxed frame loaded from its own address. Each frame response SHALL carry a Content-Security-Policy whose `sandbox` directive allows scripts and pop-ups only, so the HTML runs with an opaque origin even when the address is opened directly, and whose `frame-ancestors` directive allows only the Co-Lite site. The frame element SHALL NOT grant same-origin, form submission, top-level navigation or modal dialogs.
|
||||
|
||||
#### Scenario: Public frame is sealed
|
||||
|
||||
- **GIVEN** INS page `hotel-technology` is published with an HTML block at index 0
|
||||
- **WHEN** a visitor's browser loads `/p/INS/hotel-technology/frame/0`
|
||||
- **THEN** the response is the block's HTML with a `sandbox` policy that allows scripts and pop-ups and not same-origin
|
||||
- **AND** its `frame-ancestors` allows only the Co-Lite site
|
||||
|
||||
#### Scenario: Pasted HTML cannot reach the visitor's session
|
||||
|
||||
- **GIVEN** a published HTML block whose script reads `document.cookie` and calls `/api/auth/session`
|
||||
- **WHEN** the page is shown
|
||||
- **THEN** the script sees no Co-Lite cookies and its call carries no Co-Lite session
|
||||
|
||||
### Requirement: Custom HTML Frame Addresses
|
||||
|
||||
The public frame address SHALL be `/p/<company>/<slug>/frame/<block index>` and SHALL answer only for an HTML block of a published page; every other request SHALL get the same not-found response. The preview frame address SHALL be `/pages/<id>/preview/frame/<block index>` and SHALL require a signed-in user with `BO_PAGES` who may see that page.
|
||||
|
||||
#### Scenario: No frame for a draft, a missing block or a non-HTML block
|
||||
|
||||
- **WHEN** a visitor loads the frame address of a draft page, of block 7 of a page with 3 blocks, or of a FORM block
|
||||
- **THEN** each answers with the same not-found response
|
||||
|
||||
#### Scenario: Staff preview of a draft frame
|
||||
|
||||
- **GIVEN** a draft page with an HTML block
|
||||
- **WHEN** a signed-in user with `BO_PAGES` of that page's company opens the preview
|
||||
- **THEN** the frame shows the draft HTML, sealed as on the public page
|
||||
- **AND** the same address without a session sends the browser to sign in
|
||||
|
||||
### Requirement: Custom HTML Frame Height
|
||||
|
||||
The frame SHALL grow to fit its content, between 100 and 20000 pixels, using height reports sent by that frame only. Before the first report it SHALL be 600 pixels tall.
|
||||
|
||||
#### Scenario: A tall paste grows the frame
|
||||
|
||||
- **GIVEN** a published HTML block whose content is 3000 pixels tall
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the frame is 3000 pixels tall and shows no inner scroll bar
|
||||
|
||||
#### Scenario: Another frame cannot resize it
|
||||
|
||||
- **WHEN** a different window posts a height report to the page
|
||||
- **THEN** the frame's height does not change
|
||||
|
||||
### Requirement: The Custom HTML Block In The Editor
|
||||
|
||||
The editor SHALL offer "Add Custom HTML", which adds an HTML block with a monospace text box, a 200000-character counter and a note that forms inside the pasted HTML do not send and the sign-up form block collects leads. The editor SHALL also offer a "hide page header" switch for the page.
|
||||
|
||||
#### Scenario: Adding a Custom HTML block
|
||||
|
||||
- **WHEN** staff add a Custom HTML block and paste HTML into it
|
||||
- **THEN** the block shows the pasted HTML, the character count and the note about forms
|
||||
|
||||
#### Scenario: Hiding the header
|
||||
|
||||
- **WHEN** staff turn on "hide page header" and save
|
||||
- **THEN** reading the page returns "hide header" on
|
||||
|
||||
### Requirement: Hide Page Header
|
||||
|
||||
When a page's "hide header" flag is on, its public page and its preview SHALL NOT show the company header or the page title, and SHALL still use the page title in the browser title and the page metadata.
|
||||
|
||||
#### Scenario: Header hidden
|
||||
|
||||
- **GIVEN** INS page `hotel-technology` has "hide header" on
|
||||
- **WHEN** a visitor opens it
|
||||
- **THEN** no company logo bar or page title heading shows above the first block
|
||||
- **AND** the browser title is still the page title
|
||||
@@ -0,0 +1,134 @@
|
||||
# lead-notifications Specification
|
||||
|
||||
## Purpose
|
||||
|
||||
In-app notifications for staff: a bell with unread state, and alerts when a lead is assigned, a landing-page sign-up arrives, a customer sends a WhatsApp message, or follow-ups fall due.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Requirement: Staff Notification Bell
|
||||
|
||||
The portal SHALL show every signed-in staff user a bell in the header with the count of their unread notifications, refreshed at least every 30 seconds while the page is visible. Opening the bell SHALL list their newest notifications, newest first, and mark the listed ones read. Choosing a notification SHALL open the page it links to.
|
||||
|
||||
#### Scenario: Unread count and opening the bell
|
||||
|
||||
- **GIVEN** a salesperson has 3 unread notifications
|
||||
- **WHEN** they open any portal page
|
||||
- **THEN** the bell shows 3
|
||||
- **WHEN** they open the bell
|
||||
- **THEN** the 3 notifications are listed newest first
|
||||
- **AND** after a reload the bell shows no unread count
|
||||
|
||||
#### Scenario: A notification opens its lead
|
||||
|
||||
- **GIVEN** a "lead assigned" notification for lead L
|
||||
- **WHEN** the salesperson chooses it
|
||||
- **THEN** the portal opens lead L
|
||||
|
||||
### Requirement: Notifications Page
|
||||
|
||||
The portal SHALL provide a notifications page listing the signed-in user's notifications, newest first and paged, showing which are unread, with an action to mark all of them read.
|
||||
|
||||
#### Scenario: Mark all read
|
||||
|
||||
- **GIVEN** a user with 25 notifications, 5 of them unread
|
||||
- **WHEN** they open the notifications page and choose "Mark all read"
|
||||
- **THEN** none of their notifications is unread
|
||||
- **AND** the bell shows no unread count
|
||||
|
||||
### Requirement: Notifications Are Private To Their Recipient
|
||||
|
||||
The system SHALL show and change a user's notifications only for that user, identified from their session. A request naming another user's notification SHALL be refused as not found. A notification SHALL only name a lead of the recipient's own company.
|
||||
|
||||
#### Scenario: Another user's notification
|
||||
|
||||
- **GIVEN** notification N belongs to user A
|
||||
- **WHEN** user B asks to mark N read
|
||||
- **THEN** the request is refused as not found
|
||||
- **AND** N stays unread for user A
|
||||
|
||||
#### Scenario: Two companies
|
||||
|
||||
- **GIVEN** an INS salesperson and a CV salesperson
|
||||
- **WHEN** a CV lead is assigned to the CV salesperson
|
||||
- **THEN** only the CV salesperson is notified
|
||||
|
||||
### Requirement: Notifications Follow The Reader's Language
|
||||
|
||||
A notification SHALL be stored as message codes with parameters and shown in the reader's current portal language. Its parameters SHALL NOT include phone numbers or email addresses.
|
||||
|
||||
#### Scenario: Chinese reader
|
||||
|
||||
- **GIVEN** a "lead assigned" notification
|
||||
- **WHEN** a user with the portal in Chinese opens the bell
|
||||
- **THEN** the notification text is in Chinese, with the lead's name
|
||||
|
||||
### Requirement: Lead Assigned Notification
|
||||
|
||||
When an event lead's salesperson is set or changed to a user, the system SHALL notify that user, linking to the lead. It SHALL NOT notify a user who assigned the lead to themselves, and SHALL NOT notify anyone when the salesperson is cleared.
|
||||
|
||||
#### Scenario: Manager assigns a lead
|
||||
|
||||
- **WHEN** a manager assigns event lead L to salesperson S
|
||||
- **THEN** S gets one "lead assigned" notification naming L and its event
|
||||
|
||||
#### Scenario: Self-assignment
|
||||
|
||||
- **WHEN** salesperson S assigns lead L to themselves
|
||||
- **THEN** no notification is created
|
||||
|
||||
### Requirement: Landing Page Sign-up Notification
|
||||
|
||||
When a landing-page sign-up creates or updates an event lead, the system SHALL notify the lead's salesperson if it has one, otherwise every member of the event's sales team, once each. With no salesperson and no sales team, nobody SHALL be notified.
|
||||
|
||||
#### Scenario: Unassigned sign-up
|
||||
|
||||
- **GIVEN** event E has sales team members S1 and S2
|
||||
- **WHEN** a visitor signs up on a page whose form belongs to E, and no salesperson is assigned
|
||||
- **THEN** S1 and S2 each get one "new sign-up" notification
|
||||
|
||||
#### Scenario: Assigned at capture
|
||||
|
||||
- **WHEN** a web sign-up is captured already assigned to S
|
||||
- **THEN** S gets exactly one notification, the "new sign-up" one
|
||||
|
||||
### Requirement: WhatsApp Message Notification
|
||||
|
||||
When an inbound WhatsApp message is recorded on a chat with an owner, the system SHALL notify the owner, linking to the chat. While the owner has an unread notification for that chat, a further message SHALL update it rather than add another. A chat without an owner SHALL notify nobody.
|
||||
|
||||
#### Scenario: Busy chat
|
||||
|
||||
- **GIVEN** salesperson S owns a chat
|
||||
- **WHEN** the customer sends 4 messages before S opens the bell
|
||||
- **THEN** S has one unread notification for that chat, timed at the last message
|
||||
|
||||
#### Scenario: Unowned chat
|
||||
|
||||
- **WHEN** a message arrives on a chat without an owner
|
||||
- **THEN** no notification is created
|
||||
|
||||
### Requirement: Follow-ups Due Notification
|
||||
|
||||
Every day at 08:00 Malaysia time, the system SHALL send each salesperson with open event leads whose next follow-up date is today or earlier one summary notification giving the count due today and the count overdue, linking to their event leads.
|
||||
|
||||
#### Scenario: Morning summary
|
||||
|
||||
- **GIVEN** salesperson S has 2 open leads due today and 1 open lead due yesterday
|
||||
- **WHEN** the daily run happens
|
||||
- **THEN** S gets one notification saying 2 due today and 1 overdue
|
||||
|
||||
#### Scenario: Nothing due
|
||||
|
||||
- **GIVEN** salesperson S has no open lead due today or earlier
|
||||
- **WHEN** the daily run happens
|
||||
- **THEN** S gets no notification
|
||||
|
||||
### Requirement: Notifications Never Block The Action
|
||||
|
||||
A failure to create a notification SHALL NOT fail or roll back the sign-up, assignment or inbound message that caused it. The failure SHALL be logged without names, phone numbers or email addresses.
|
||||
|
||||
#### Scenario: Notification store down
|
||||
|
||||
- **GIVEN** the notification store cannot be reached
|
||||
- **WHEN** a visitor signs up on a landing page
|
||||
- **THEN** the sign-up succeeds and the lead is saved
|
||||
Reference in new issue
Block a user