import { CONVERSATION_EVENT , ConversationEvent } from '@wireapp/api-client/src/event' ; import { MessageBuilder } from './message/MessageBuilder' ; import { PayloadBundle , PayloadBundleSource , PayloadBundleState , PayloadBundleType } from './message/PayloadBundle' ; export class ConversationMapper { public static mapConversationEvent ( event , source ) { return { content : event . data , conversation : event . conversation , qualifiedConversation : event . qualified_conversation , qualifiedFrom : event . qualified_from , from : event . from , id : MessageBuilder . createId ( ) , messageTimer : 0 , source , state : PayloadBundleState . INCOMING , timestamp : new Date ( event . time ) . getTime ( ) , type : this . mapConversationEventType ( event . type ) , } ; } private static mapConversationEventType ( type ) { switch ( type ) { case CONVERSATION_EVENT . MEMBER_JOIN : return PayloadBundleType . MEMBER_JOIN ; case CONVERSATION_EVENT . MESSAGE_TIMER_UPDATE : return PayloadBundleType . TIMER_UPDATE ; case CONVERSATION_EVENT . RENAME : return PayloadBundleType . CONVERSATION_RENAME ; case CONVERSATION_EVENT . TYPING : return PayloadBundleType . TYPING ; default : return PayloadBundleType . UNKNOWN ; } } }