Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support moderation v2 workflow #2562

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading