UNPKG

@onereach/channel-transformer

Version:

Convert data model between different channels (Slack, Microsoft Teams, Generic...)

25 lines (20 loc) 613 B
import { IGenericSection } from "../../../generic/types"; import { IMSTeamsEvent } from "../../types"; import { getMethods } from "../methods"; export const transformMessage = ( { messageType = 'message', attachments = [], body = {}} : IMSTeamsEvent): IGenericSection => { const section: IGenericSection = { type: 'section', props: { msteams: { type: messageType, } }, children: [] }; if (attachments?.length) section.children.push(getMethods('attachments')(attachments)); section.children.push(getMethods(body?.contentType)(body)); return section; };