37 lines
970 B
TypeScript
37 lines
970 B
TypeScript
|
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;
|
||
|
}
|
||
|
};
|