Skip to content

Commit c63bed9

Browse files
committed
feat: support moderation v2 workflow
1 parent efa0736 commit c63bed9

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/components/Message/__tests__/MessageSimple.test.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -639,14 +639,26 @@ describe('<MessageSimple />', () => {
639639
expect(results).toHaveNoViolations();
640640
});
641641

642-
describe('bounced message', () => {
643-
const bouncedMessageOptions = {
644-
moderation_details: {
645-
action: 'MESSAGE_RESPONSE_ACTION_BOUNCE',
642+
describe.each([
643+
[
644+
'v1',
645+
{
646+
moderation_details: {
647+
action: 'MESSAGE_RESPONSE_ACTION_BOUNCE',
648+
},
649+
type: 'error',
646650
},
647-
type: 'error',
648-
};
649-
651+
],
652+
[
653+
'v2',
654+
{
655+
moderation: {
656+
action: 'bounce',
657+
},
658+
type: 'error',
659+
},
660+
],
661+
])('bounced message %s', (_, bouncedMessageOptions) => {
650662
it('should render error badge for bounced messages', async () => {
651663
const message = generateAliceMessage(bouncedMessageOptions);
652664
const { queryByTestId } = await renderMessageSimple({ message });

src/components/Message/utils.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,11 @@ export const isOnlyEmojis = (text?: string) => {
485485
export const isMessageBounced = <
486486
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
487487
>(
488-
message: Pick<StreamMessage<StreamChatGenerics>, 'type' | 'moderation_details'>,
488+
message: Pick<StreamMessage<StreamChatGenerics>, 'type' | 'moderation' | 'moderation_details'>,
489489
) =>
490490
message.type === 'error' &&
491-
message.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_BOUNCE';
491+
(message.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_BOUNCE' ||
492+
message.moderation?.action === 'bounce');
492493

493494
export const isMessageEdited = <
494495
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics

0 commit comments

Comments
 (0)