From 1392d064a1942a2690063f4237f290948a6127bf Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 26 Oct 2020 21:52:21 -0400 Subject: [PATCH] fix(writeapi): normalizing data --- src/posts/edit.js | 4 ++++ src/topics/create.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/posts/edit.js b/src/posts/edit.js index 91dcd8de26..df3fdbcad7 100644 --- a/src/posts/edit.js +++ b/src/posts/edit.js @@ -63,6 +63,10 @@ module.exports = function (Posts) { }); } await Posts.uploads.sync(data.pid); + + // Normalize data prior to constructing returnPostData (match types with getPostSummaryByPids) + postData.deleted = !!postData.deleted; + const returnPostData = { ...postData, ...editPostData }; returnPostData.cid = topic.cid; returnPostData.topic = topic; diff --git a/src/topics/create.js b/src/topics/create.js index 2aed3268cb..afa8498b72 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -118,8 +118,9 @@ module.exports = function (Topics) { await Topics.follow(postData.tid, uid); } const topicData = topics[0]; - topicData.unreplied = 1; + topicData.unreplied = true; topicData.mainPost = postData; + topicData.index = 0; postData.index = 0; analytics.increment(['topics', 'topics:byCid:' + topicData.cid]);