Version
master
Describe the bug
When writing a new (attachment) middleware that render the same downstream middleware twice, it failed.
For example, the following code using concatMiddleware.js will fail to return the correct value (210). It "skipped" the next(value + 1), thus, returned 12 instead.
const combine = () => next => value => {
return next(value) + next(value + 1);
};
const oddMultiplyByTenAndEvenMultiplyByHundred = () => next => value => {
if (value % 2) {
return value * 10;
}
return value * 100;
};
const middleware = concatMiddleware(combine, oddMultiplyByTenAndEvenMultiplyByHundred);
const work = middleware()(value => value);
expect(work(1)).toEqual(210);
Steps to reproduce
- Write a new attachment middleware that call
next() twice. So it will render attachment twice.
- Open Web Chat
- Type "echo Hello, World!"
Expected behavior
It should render the attachment ("Hello, World!") twice.
Instead, the first time it render the attachment, it succeeded. The second render failed with "no renderer for this attachment" error.
Additional context
IC3 team want to render a photo upload with the thumbnail and file name. So it could looks like the following screenshot.

Once the bug is fixed, the code below should produce the screenshot above.
function createUploadMiddleware() {
return () => next => ({
activity = {},
activity: { from: { role } } = {},
attachment,
attachment: { contentType, contentUrl, thumbnailUrl } = {}
}) => {
if (role === 'user' && /^image\//u.test(contentType) && thumbnailUrl) {
const patchedAttachment = {
...attachment,
contentType: 'application/octet-stream',
thumbnailUrl: undefined
};
const patchedAttachments = activity.attachments.map(target =>
target === attachment ? patchedAttachment : target
);
return (
<React.Fragment>
{next({ activity, attachment })}
{next({ activity: { ...activity, attachments: patchedAttachments }, attachment: patchedAttachment })}
</React.Fragment>
);
}
return next({ activity, attachment });
};
}
[Bug]
Version
masterDescribe the bug
When writing a new (attachment) middleware that render the same downstream middleware twice, it failed.
For example, the following code using
concatMiddleware.jswill fail to return the correct value (210). It "skipped" thenext(value + 1), thus, returned12instead.Steps to reproduce
next()twice. So it will render attachment twice.Expected behavior
It should render the attachment ("Hello, World!") twice.
Instead, the first time it render the attachment, it succeeded. The second render failed with "no renderer for this attachment" error.
Additional context
IC3 team want to render a photo upload with the thumbnail and file name. So it could looks like the following screenshot.
Once the bug is fixed, the code below should produce the screenshot above.
[Bug]