🎨 Autoformat code
parent
2fae89f0e8
commit
424965f876
@ -1,14 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
*/
|
||||||
export type MIMEType = string & { _mimeTypeBrand: any };
|
export type MIMEType = string & { _mimeTypeBrand: any };
|
||||||
|
|
||||||
|
export const isJPEG = (value: MIMEType): boolean => value === 'image/jpeg';
|
||||||
|
|
||||||
export const isJPEG = (value: MIMEType): boolean =>
|
export const isImage = (value: MIMEType): boolean => value.startsWith('image/');
|
||||||
value === 'image/jpeg';
|
|
||||||
|
|
||||||
export const isImage = (value: MIMEType): boolean =>
|
export const isVideo = (value: MIMEType): boolean => value.startsWith('video/');
|
||||||
value.startsWith('image/');
|
|
||||||
|
|
||||||
export const isVideo = (value: MIMEType): boolean =>
|
export const isAudio = (value: MIMEType): boolean => value.startsWith('audio/');
|
||||||
value.startsWith('video/');
|
|
||||||
|
|
||||||
export const isAudio = (value: MIMEType): boolean =>
|
|
||||||
value.startsWith('audio/');
|
|
||||||
|
@ -1,20 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
*/
|
||||||
import { partition } from 'lodash';
|
import { partition } from 'lodash';
|
||||||
|
|
||||||
import * as Attachment from '../Attachment';
|
import * as Attachment from '../Attachment';
|
||||||
import { Message } from '../message';
|
import { Message } from '../Message';
|
||||||
|
|
||||||
|
export const initializeAttachmentMetadata = async (
|
||||||
|
message: Message
|
||||||
|
): Promise<Message> => {
|
||||||
|
const numAttachments = message.attachments.length;
|
||||||
|
const [numVisualMediaAttachments, numFileAttachments] = partition(
|
||||||
|
message.attachments,
|
||||||
|
Attachment.isVisualMedia
|
||||||
|
).map(attachments => attachments.length);
|
||||||
|
|
||||||
export const initializeAttachmentMetadata =
|
return {
|
||||||
async (message: Message): Promise<Message> => {
|
...message,
|
||||||
const numAttachments = message.attachments.length;
|
numAttachments,
|
||||||
const [numVisualMediaAttachments, numFileAttachments] =
|
numVisualMediaAttachments,
|
||||||
partition(message.attachments, Attachment.isVisualMedia)
|
numFileAttachments,
|
||||||
.map((attachments) => attachments.length);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...message,
|
|
||||||
numAttachments,
|
|
||||||
numVisualMediaAttachments,
|
|
||||||
numFileAttachments,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue