add method to create timestamp and chatMessage
This commit is contained in:
@@ -1,5 +1,19 @@
|
|||||||
// this file is responsible for managing chats and chat messages. objects are delegated to objectModel.ts.
|
// this file is responsible for managing chats and chat messages. objects are delegated to objectModel.ts.
|
||||||
|
|
||||||
|
import { createTimestamp } from "../utility";
|
||||||
|
|
||||||
|
// creation methods
|
||||||
|
export function createChatMessage(channel: string, sender: string, body: string): ChatMessage {
|
||||||
|
return {
|
||||||
|
dataVersion: "v2",
|
||||||
|
|
||||||
|
channel,
|
||||||
|
sender,
|
||||||
|
body,
|
||||||
|
dateSent: createTimestamp(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// types
|
// types
|
||||||
export interface ChatMessage {
|
export interface ChatMessage {
|
||||||
dataVersion: "v2";
|
dataVersion: "v2";
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
// date
|
||||||
|
export function createTimestamp(): string {
|
||||||
|
return new Date().toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// string
|
||||||
export function stringify(data: any): string {
|
export function stringify(data: any): string {
|
||||||
return JSON.stringify(data);
|
return JSON.stringify(data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user