Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
35 changes: 33 additions & 2 deletions __tests__/workers/cdc/primary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3347,6 +3347,7 @@ describe('post content updated', () => {
visible: true,
yggdrasilId: 'f30cdfd4-80cd-4955-bed1-0442dc5511bf',
deleted: false,
translation: {},
},
]);
});
Expand Down Expand Up @@ -3434,6 +3435,7 @@ describe('post content updated', () => {
visible: true,
yggdrasilId: 'f30cdfd4-80cd-4955-bed1-0442dc5511bf',
deleted: false,
translation: {},
},
]);
});
Expand Down Expand Up @@ -3563,6 +3565,7 @@ describe('post content updated', () => {
visible: true,
yggdrasilId: 'f30cdfd4-80cd-4955-bed1-0442dc5511bf',
deleted: false,
translation: {},
},
]);
});
Expand Down Expand Up @@ -3649,6 +3652,7 @@ describe('post content updated', () => {
visible: true,
yggdrasilId: 'f30cdfd4-80cd-4955-bed1-0442dc5511bf',
deleted: false,
translation: {},
},
]);
});
Expand All @@ -3664,8 +3668,21 @@ describe('post content updated', () => {
canonicalUrl: 'http://p4c.com',
contentMeta:
'{"cleaned":[{"provider":"test","resource_location":"gs://path.xml"}]}',
contentQuality:
'{"is_ai_probability":0.9}' as ArticlePost['contentQuality'],
contentQuality: '{"is_ai_probability":0.9}',
translation: JSON.stringify({
hr: {
title: 'translated title hr',
smartTitle: 'translated smart title hr',
titleHtml: '<p>translated title hr</p>',
summary: 'translated summary hr',
},
en: {
title: 'translated title',
smartTitle: 'translated smart title',
titleHtml: '<p>translated title</p>',
summary: 'translated summary',
},
}),
};
await expectSuccessfulBackground(
worker,
Expand All @@ -3687,6 +3704,20 @@ describe('post content updated', () => {
contentQuality: {
isAiProbability: 0.9,
},
translation: {
hr: {
title: 'translated title hr',
smartTitle: 'translated smart title hr',
titleHtml: '<p>translated title hr</p>',
summary: 'translated summary hr',
},
en: {
title: 'translated title',
smartTitle: 'translated smart title',
titleHtml: '<p>translated title</p>',
summary: 'translated summary',
},
},
},
],
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@connectrpc/connect-fastify": "^1.6.1",
"@connectrpc/connect-node": "^1.6.1",
"@dailydotdev/graphql-redis-subscriptions": "^2.4.3",
"@dailydotdev/schema": "0.2.61",
"@dailydotdev/schema": "0.2.62",
"@dailydotdev/ts-ioredis-pool": "^1.0.2",
"@fastify/cookie": "^11.0.2",
"@fastify/cors": "^11.1.0",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/workers/cdc/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
ContentMeta,
ContentQuality,
ContentUpdatedMessage,
Translation,
} from '@dailydotdev/schema';
import { DataSource, ObjectLiteral } from 'typeorm';
import { EntityTarget } from 'typeorm/common/EntityTarget';
Expand Down Expand Up @@ -138,6 +139,23 @@ export const notifyPostContentUpdated = async ({
}),
deleted: articlePost.deleted,
sharedPostId: sharePost.sharedPostId || undefined,
translation: post.translation
? Object.entries(
typeof post.translation === 'string'
? JSON.parse(post.translation)
: post.translation,
).reduce(
(acc, [key, value]) => {
acc[key] = decodeJsonField({
value: value as JsonValue,
decoder: new Translation(),
});

return acc;
},
{} as { [key: string]: Translation },
)
: undefined,
});

await triggerTypedEvent(
Expand Down
Loading