Turns the rows of chat_messages into the ChatMessage the API sends.
Only services/chat-service.ts uses it, on the rows of its one query.
f
chatMessageRowToApi(row: ChatMessageRow): ChatMessage
Converts a row to the ChatMessage that chat-service returns, turning its timestamps into Dates and its nulls into absent fields.
f
isChatMessageRow(obj: unknown): obj is ChatMessageRow
Checks whether obj, a row read by chat-service, is a
ChatMessageRow.
I
ChatMessageRow
Returned by chat-service's query, which joins each message to its author and
to the message it replies to. reply_to_id is kept when the message it
points to is deleted, while reply_to_author and reply_to_body then read
null.
- author_avatar_mime: string | null
- author_username: string
- body: string
- created_at: string
- id: string
-
mentions_everyone: number
1 or 0.
- reply_to_author: string | null
-
reply_to_body: string | null
Cut to chat-service's
REPLY_SNIPPET_LENcharacters. - reply_to_id: string | null
- updated_at: string | null
- user_id: string
Usage
import * as mod from "api/model/chat.ts";