Skip to content

Commit

Permalink
feat: support moderation v2 workflow (#2562)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinCupela authored Nov 15, 2024
1 parent 414745d commit 18afa22
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
"emoji-mart": "^5.4.0",
"react": "^18.0.0 || ^17.0.0 || ^16.8.0",
"react-dom": "^18.0.0 || ^17.0.0 || ^16.8.0",
"stream-chat": "^8.44.0"
"stream-chat": "^8.45.0"
},
"peerDependenciesMeta": {
"@breezystack/lamejs": {
Expand Down Expand Up @@ -255,7 +255,7 @@
"react-dom": "^18.1.0",
"react-test-renderer": "^18.1.0",
"semantic-release": "^19.0.5",
"stream-chat": "^8.44.0",
"stream-chat": "^8.45.0",
"ts-jest": "^29.1.4",
"typescript": "^5.4.5"
},
Expand Down
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
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12200,10 +12200,10 @@ statuses@2.0.1:
resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63"
integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==

stream-chat@^8.44.0:
version "8.44.0"
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0"
integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA==
stream-chat@^8.45.0:
version "8.45.0"
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.0.tgz#bbb18ea897138dabb5ccd045a40958ec7242923c"
integrity sha512-re6GPh4F50ksB5/5GG5FtNAji+ZFTmIcLBIUhkGlnCwNaM8Ub59jcoI21Rtf/51+Nwrcitld2MzzlY49RlkwOA==
dependencies:
"@babel/runtime" "^7.16.3"
"@types/jsonwebtoken" "~9.0.0"
Expand Down

0 comments on commit 18afa22

Please sign in to comment.