Skip to content

Commit

Permalink
add anonymous field in creation and data fetch (backend)
Browse files Browse the repository at this point in the history
  • Loading branch information
Driftedboat committed Sep 23, 2024
1 parent efdde03 commit 70a529f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 27 deletions.
67 changes: 46 additions & 21 deletions node_modules/nodebb-plugin-composer-default/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/posts/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = function (Posts) {
tid: tid,
content: content,
timestamp: timestamp,
anonymous: data.anonymous ? 1 : 0, // Added anonymous status
};

if (data.toPid) {
Expand Down
16 changes: 14 additions & 2 deletions src/posts/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,25 @@ module.exports = function (Posts) {
posts: postData,
fields: fields,
});
result.posts.forEach(post => modifyPost(post, fields));
result.posts.forEach(post => {
modifyPost(post, fields);
if (post.anonymous ==1){
post.uid = null;
}
});
return result.posts;
};

Posts.getPostData = async function (pid) {
const posts = await Posts.getPostsFields([pid], []);
return posts && posts.length ? posts[0] : null;
if (posts && posts.length) {
const post = posts[0];
if (post.anonymous == 1) {
post.uid = null;
}
return post;
}
return null;
};

Posts.getPostsData = async function (pids) {
Expand Down

0 comments on commit 70a529f

Please sign in to comment.