Skip to content

Commit

Permalink
feat: support moderation v2 workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinCupela committed Nov 15, 2024
1 parent efa0736 commit c63bed9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
26 changes: 19 additions & 7 deletions src/components/Message/__tests__/MessageSimple.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,26 @@ describe('<MessageSimple />', () => {
expect(results).toHaveNoViolations();
});

describe('bounced message', () => {
const bouncedMessageOptions = {
moderation_details: {
action: 'MESSAGE_RESPONSE_ACTION_BOUNCE',
describe.each([
[
'v1',
{
moderation_details: {
action: 'MESSAGE_RESPONSE_ACTION_BOUNCE',
},
type: 'error',
},
type: 'error',
};

],
[
'v2',
{
moderation: {
action: 'bounce',
},
type: 'error',
},
],
])('bounced message %s', (_, bouncedMessageOptions) => {
it('should render error badge for bounced messages', async () => {
const message = generateAliceMessage(bouncedMessageOptions);
const { queryByTestId } = await renderMessageSimple({ message });
Expand Down
5 changes: 3 additions & 2 deletions src/components/Message/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,11 @@ export const isOnlyEmojis = (text?: string) => {
export const isMessageBounced = <
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
>(
message: Pick<StreamMessage<StreamChatGenerics>, 'type' | 'moderation_details'>,
message: Pick<StreamMessage<StreamChatGenerics>, 'type' | 'moderation' | 'moderation_details'>,
) =>
message.type === 'error' &&
message.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_BOUNCE';
(message.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_BOUNCE' ||
message.moderation?.action === 'bounce');

export const isMessageEdited = <
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
Expand Down

0 comments on commit c63bed9

Please sign in to comment.