Skip to content

Commit afa471d

Browse files
committed
fix: restore translation field for content updated
1 parent bb77cee commit afa471d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/workers/cdc/common.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
ContentMeta,
33
ContentQuality,
44
ContentUpdatedMessage,
5+
Translation,
56
} from '@dailydotdev/schema';
67
import { DataSource, ObjectLiteral } from 'typeorm';
78
import { EntityTarget } from 'typeorm/common/EntityTarget';
@@ -138,6 +139,23 @@ export const notifyPostContentUpdated = async ({
138139
}),
139140
deleted: articlePost.deleted,
140141
sharedPostId: sharePost.sharedPostId || undefined,
142+
translation: post.translation
143+
? Object.entries(
144+
typeof post.translation === 'string'
145+
? JSON.parse(post.translation)
146+
: post.translation,
147+
).reduce(
148+
(acc, [key, value]) => {
149+
acc[key] = decodeJsonField({
150+
value: value as JsonValue,
151+
decoder: new Translation(),
152+
});
153+
154+
return acc;
155+
},
156+
{} as { [key: string]: Translation },
157+
)
158+
: undefined,
141159
});
142160

143161
await triggerTypedEvent(

0 commit comments

Comments
 (0)