Skip to content

Commit

Permalink
fix: encode nested jsonb fields
Browse files Browse the repository at this point in the history
  • Loading branch information
capJavert committed May 31, 2024
1 parent 16e45a7 commit 88763bf
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/workers/cdc/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ContentUpdatedMessage } from '@dailydotdev/schema';
import {
ContentMeta,
ContentQuality,
ContentUpdatedMessage,
} from '@dailydotdev/schema';
import { DataSource } from 'typeorm';
import { EntityTarget } from 'typeorm/common/EntityTarget';
import {
Expand All @@ -11,6 +15,7 @@ import { ChangeObject } from '../../types';
import { PostKeyword, Source } from '../../entity';
import { triggerTypedEvent } from '../../common';
import { logger } from '../../logger';
import { JsonValue } from '@bufbuild/protobuf';

export const isChanged = <T>(before: T, after: T, property: keyof T): boolean =>
before[property] != after[property];
Expand Down Expand Up @@ -83,15 +88,17 @@ export const notifyPostContentUpdated = async ({
summary: articlePost.summary,
content: freeformPost.content,
language: post.language,
contentMeta: post.contentMeta,
contentMeta: ContentMeta.fromJson(post.contentMeta as JsonValue, {
ignoreUnknownFields: true,
}),
relatedPosts: relatedPosts.map((item) => ({
...item,
createdAt: +item.createdAt,
})),
contentCuration: post.contentCuration,
contentQuality: {
isAiProbability: post.contentQuality?.is_ai_probability,
},
contentQuality: ContentQuality.fromJson(post.contentQuality, {
ignoreUnknownFields: true,
}),
});

await triggerTypedEvent(
Expand Down

0 comments on commit 88763bf

Please sign in to comment.