Added debug log for missing post id in embedded permalink (#23790)

* Added stricter checks for accessing other post embed data

* Added debug log

* Removed unused import

* lint fix
This commit is contained in:
Harshil Sharma 2023-06-22 11:36:12 +05:30 committed by GitHub
parent 2788c883b0
commit 178dbb9f95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -218,6 +218,13 @@ export function handlePosts(state: RelationOneToOne<Post, Post> = {}, action: Ge
const newEmbeds: PostEmbed[] = [];
for (const embed of otherPost.metadata.embeds) {
if (embed.type === 'permalink' && embed.data && !('post_id' in embed.data)) {
// eslint-disable-next-line no-console
console.error('post_id missing in post embed data for permalink.');
// eslint-disable-next-line no-console
console.error(embed.data);
}
if (embed.type === 'permalink' && (embed.data as PostPreviewMetadata).post_id === post.id) {
// skip if the embed is the deleted post
continue;