UNPKG

wechaty-puppet-service

Version:
39 lines 1.49 kB
import { PassThrough } from 'stream'; import { nextData } from './next-data.js'; import { packFileBoxToPb, unpackFileBoxFromPb, } from './file-box-pb.js'; /** * MessageSendFileStreamRequest to Args * @deprecated Will be removed after Dec 31, 2022 */ async function unpackConversationIdFileBoxArgsFromPb(stream) { const chunk = await nextData(stream); if (!chunk.hasConversationId()) { throw new Error('no conversation id'); } const conversationId = chunk.getConversationId(); // unpackFileBoxFromChunk(unpackFileBoxChunkFromPb(stream)) const fileBox = await unpackFileBoxFromPb(stream); return { conversationId, fileBox, }; } /** * Args to MessageSendFileStreamRequest * @deprecated Will be removed after Dec 31, 2022 */ function packConversationIdFileBoxToPb(PbConstructor) { return async (conversationId, fileBox) => { const stream = new PassThrough({ objectMode: true }); const first = new PbConstructor(); first.setConversationId(conversationId); stream.write(first); // const fileBoxChunkStream = await packFileBoxToChunk(fileBox) // packFileBoxChunkToPb(MessageSendFileStreamRequest)(fileBoxChunkStream) const pbStream = await packFileBoxToPb(PbConstructor)(fileBox); pbStream.pipe(stream); return stream; }; } export { unpackConversationIdFileBoxArgsFromPb, packConversationIdFileBoxToPb, }; //# sourceMappingURL=conversation-id-file-box.js.map