UNPKG

@onereach/channel-transformer

Version:

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

20 lines (16 loc) 576 B
import { IMSTeamsMessage, IMSTeamsAttachment, IMSTeamsEvent } from "../types"; import { getMethods } from "./methods"; import { IGenericWrapper } from "../../generic/types"; export const transformGenericToMSTeams = (msg: IGenericWrapper) => { const { children = [] } = msg; const messages: Array<IMSTeamsEvent> = children.reduce((acc, child) => { const res = getMethods(child.type)(child); Array.isArray(res) ? acc.push(...res) : acc.push(res); return acc; }, []); return { messages }; };