Only show posts on your own wall

This commit is contained in:
Rogerio Chaves 2020-04-05 14:56:51 +02:00
parent 0ebcc46e6b
commit 1da133cb06
No known key found for this signature in database
GPG Key ID: E6AF5440509B1D94
2 changed files with 9 additions and 5 deletions

View File

@ -50,14 +50,18 @@ router.get("/", async (_req, res) => {
}
const [posts, friends] = await Promise.all([
queries.getPosts(ssbServer),
queries.getPosts(ssbServer, profile.id),
queries.getFriends(profile, ssbServer),
]);
res.render("index", { profile, posts, friends });
});
router.post("/publish", async (req, res) => {
await promisify(ssbServer.publish, { type: "post", text: req.body.message });
await promisify(ssbServer.publish, {
type: "post",
text: req.body.message,
wall: profile.id,
});
res.redirect("/");
});

View File

@ -66,7 +66,7 @@ const mapAuthorName = (ssbServer) => (data, callback) => {
.catch((err) => callback(err, null));
};
const getPosts = (ssbServer) =>
const getPosts = (ssbServer, userId) =>
new Promise((resolve, reject) => {
pull(
ssbServer.query.read({
@ -75,12 +75,12 @@ const getPosts = (ssbServer) =>
{
$filter: {
value: {
content: { type: "post" },
content: { type: "post", wall: userId },
},
},
},
],
limit: 500,
limit: 100,
}),
pull.asyncMap(mapAuthorName(ssbServer)),
pull.collect((err, msgs) => {