wechaty-puppet-service
Version:
Puppet Service for Wechaty
43 lines • 1.8 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.packConversationIdFileBoxToPb = exports.unpackConversationIdFileBoxArgsFromPb = void 0;
const stream_1 = require("stream");
const next_data_js_1 = require("./next-data.js");
const file_box_pb_js_1 = require("./file-box-pb.js");
/**
* MessageSendFileStreamRequest to Args
* @deprecated Will be removed after Dec 31, 2022
*/
async function unpackConversationIdFileBoxArgsFromPb(stream) {
const chunk = await (0, next_data_js_1.nextData)(stream);
if (!chunk.hasConversationId()) {
throw new Error('no conversation id');
}
const conversationId = chunk.getConversationId();
// unpackFileBoxFromChunk(unpackFileBoxChunkFromPb(stream))
const fileBox = await (0, file_box_pb_js_1.unpackFileBoxFromPb)(stream);
return {
conversationId,
fileBox,
};
}
exports.unpackConversationIdFileBoxArgsFromPb = unpackConversationIdFileBoxArgsFromPb;
/**
* Args to MessageSendFileStreamRequest
* @deprecated Will be removed after Dec 31, 2022
*/
function packConversationIdFileBoxToPb(PbConstructor) {
return async (conversationId, fileBox) => {
const stream = new stream_1.PassThrough({ objectMode: true });
const first = new PbConstructor();
first.setConversationId(conversationId);
stream.write(first);
// const fileBoxChunkStream = await packFileBoxToChunk(fileBox)
// packFileBoxChunkToPb(MessageSendFileStreamRequest)(fileBoxChunkStream)
const pbStream = await (0, file_box_pb_js_1.packFileBoxToPb)(PbConstructor)(fileBox);
pbStream.pipe(stream);
return stream;
};
}
exports.packConversationIdFileBoxToPb = packConversationIdFileBoxToPb;
//# sourceMappingURL=conversation-id-file-box.js.map
;