I need the ExtractMessageContent method. I tried to port the code to typescrypt but I was unable to evolve. I believe there is little missing. Can you help me finish?
public static Message ExtractMessageContent(Message content)
{
Message extractFromTemplateMessage(Message msg)
{
if (msg.ImageMessage!=null)
return new Message() { ImageMessage = msg.ImageMessage };
else if (msg.DocumentMessage != null)
return new Message() { DocumentMessage = msg.DocumentMessage };
else if (msg.VideoMessage!=null)
return new Message() { VideoMessage = msg.VideoMessage };
else if (msg.LocationMessage!=null)
return new Message() { LocationMessage = msg.LocationMessage };
else
{
//Todo:
return new Message(){};
}
}
content = NormalizeMessageContent(content);
if (content?.ButtonsMessage!=null)
return extractFromTemplateMessage(content.ButtonsMessage);
if (content?.TemplateMessage?.HydratedFourRowTemplate != null)
return extractFromTemplateMessage(content.ButtonsMessage);
if (content?.TemplateMessage?.HydratedFourRowTemplate!=null)
return extractFromTemplateMessage(content?.TemplateMessage?.HydratedFourRowTemplate);
if (content?.TemplateMessage?.HydratedTemplate != null)
return extractFromTemplateMessage(content?.TemplateMessage?.HydratedTemplate);
if (content?.TemplateMessage?.FourRowTemplate != null)
return extractFromTemplateMessage(content?.TemplateMessage?.FourRowTemplate);
return content;
}
Message Util ExtractMessageContent
I need the ExtractMessageContent method. I tried to port the code to typescrypt but I was unable to evolve. I believe there is little missing. Can you help me finish?
public static Message ExtractMessageContent(Message content) { Message extractFromTemplateMessage(Message msg) { if (msg.ImageMessage!=null) return new Message() { ImageMessage = msg.ImageMessage }; else if (msg.DocumentMessage != null) return new Message() { DocumentMessage = msg.DocumentMessage }; else if (msg.VideoMessage!=null) return new Message() { VideoMessage = msg.VideoMessage };
else if (msg.LocationMessage!=null) return new Message() { LocationMessage = msg.LocationMessage };
else { //Todo: return new Message(){};
} } content = NormalizeMessageContent(content); if (content?.ButtonsMessage!=null) return extractFromTemplateMessage(content.ButtonsMessage); if (content?.TemplateMessage?.HydratedFourRowTemplate != null) return extractFromTemplateMessage(content.ButtonsMessage); if (content?.TemplateMessage?.HydratedFourRowTemplate!=null) return extractFromTemplateMessage(content?.TemplateMessage?.HydratedFourRowTemplate);
if (content?.TemplateMessage?.HydratedTemplate != null) return extractFromTemplateMessage(content?.TemplateMessage?.HydratedTemplate);
if (content?.TemplateMessage?.FourRowTemplate != null) return extractFromTemplateMessage(content?.TemplateMessage?.FourRowTemplate);
return content; }