ucap-doc/documents/업무/2월/2째주/묵음파일백업/bundle-image.event-json.ts

37 lines
970 B
TypeScript
Raw Normal View History

2020-02-14 07:00:15 +00:00
import { StatusCode, JsonAnalization } from '@ucap-webmessenger/api';
import { FileType } from '@ucap-webmessenger/protocol-file';
import { EventJsonDecoder } from './event-json';
export interface BundleImageEventJson {
statusCode?: StatusCode;
errorMessage?: string;
roomSeq?: number;
attachmentSeq?: number;
fileCount?: number;
baseUrl?: string;
thumbUrls?: string[];
fileType?: FileType;
}
export const decodeBundleImageEventJson: EventJsonDecoder<BundleImageEventJson> = (
message: string
) => {
try {
const json = JsonAnalization.receiveAnalization(message);
return {
statusCode: json.StatusCode,
errorMessage: json.ErrorMessage,
roomSeq: json.RoomID,
attachmentSeq: json.AttSEQ,
fileCount: json.FileCount,
thumbUrls: json.ThumbURL
} as BundleImageEventJson;
} catch (e) {
return {
statusCode: StatusCode.Fail,
errorMessage: e.toString()
} as BundleImageEventJson;
}
};