diff --git a/__tests__/workers/cdc/primary.ts b/__tests__/workers/cdc/primary.ts index ae706c95ed..7a33df9d05 100644 --- a/__tests__/workers/cdc/primary.ts +++ b/__tests__/workers/cdc/primary.ts @@ -3347,6 +3347,7 @@ describe('post content updated', () => { visible: true, yggdrasilId: 'f30cdfd4-80cd-4955-bed1-0442dc5511bf', deleted: false, + translation: {}, }, ]); }); @@ -3434,6 +3435,7 @@ describe('post content updated', () => { visible: true, yggdrasilId: 'f30cdfd4-80cd-4955-bed1-0442dc5511bf', deleted: false, + translation: {}, }, ]); }); @@ -3563,6 +3565,7 @@ describe('post content updated', () => { visible: true, yggdrasilId: 'f30cdfd4-80cd-4955-bed1-0442dc5511bf', deleted: false, + translation: {}, }, ]); }); @@ -3649,6 +3652,7 @@ describe('post content updated', () => { visible: true, yggdrasilId: 'f30cdfd4-80cd-4955-bed1-0442dc5511bf', deleted: false, + translation: {}, }, ]); }); @@ -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: '

translated title hr

', + summary: 'translated summary hr', + }, + en: { + title: 'translated title', + smartTitle: 'translated smart title', + titleHtml: '

translated title

', + summary: 'translated summary', + }, + }), }; await expectSuccessfulBackground( worker, @@ -3687,6 +3704,20 @@ describe('post content updated', () => { contentQuality: { isAiProbability: 0.9, }, + translation: { + hr: { + title: 'translated title hr', + smartTitle: 'translated smart title hr', + titleHtml: '

translated title hr

', + summary: 'translated summary hr', + }, + en: { + title: 'translated title', + smartTitle: 'translated smart title', + titleHtml: '

translated title

', + summary: 'translated summary', + }, + }, }, ], ); diff --git a/package.json b/package.json index e7ad75436d..2aea7bbfb5 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 479770cadd..882828b18a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,8 +35,8 @@ importers: specifier: ^2.4.3 version: 2.4.3(graphql-subscriptions@3.0.0(graphql@16.11.0)) '@dailydotdev/schema': - specifier: 0.2.61 - version: 0.2.61(@bufbuild/protobuf@1.10.0) + specifier: 0.2.62 + version: 0.2.62(@bufbuild/protobuf@1.10.0) '@dailydotdev/ts-ioredis-pool': specifier: ^1.0.2 version: 1.0.2 @@ -705,8 +705,8 @@ packages: peerDependencies: graphql-subscriptions: ^1.0.0 || ^2.0.0 - '@dailydotdev/schema@0.2.61': - resolution: {integrity: sha512-FR/uDtAUYGE6OttLpYbY1cR/R9n7sKCi3vNvCxbx+mFi2+nHmz8DwriExKC1LvSXJhnG0SgoXPKevcIA8D+NjA==} + '@dailydotdev/schema@0.2.62': + resolution: {integrity: sha512-tWVnzJjrpmKZTi/WCmqxMLlmEAWj9wOg/TRQ9jFW3aCxbC9R1TRxVG3I58RWUviBrwQncathv4v++DdXuHvwiA==} peerDependencies: '@bufbuild/protobuf': 1.x @@ -5187,7 +5187,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@dailydotdev/schema@0.2.61(@bufbuild/protobuf@1.10.0)': + '@dailydotdev/schema@0.2.62(@bufbuild/protobuf@1.10.0)': dependencies: '@bufbuild/protobuf': 1.10.0 diff --git a/src/workers/cdc/common.ts b/src/workers/cdc/common.ts index 7b9d66f08a..c9f22354aa 100644 --- a/src/workers/cdc/common.ts +++ b/src/workers/cdc/common.ts @@ -2,6 +2,7 @@ import { ContentMeta, ContentQuality, ContentUpdatedMessage, + Translation, } from '@dailydotdev/schema'; import { DataSource, ObjectLiteral } from 'typeorm'; import { EntityTarget } from 'typeorm/common/EntityTarget'; @@ -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(