Improve reading private messages performance

This commit is contained in:
Rogerio Chaves 2020-04-13 09:49:27 +02:00
parent 8211a8cb78
commit 181d9e8455
No known key found for this signature in database
GPG Key ID: E6AF5440509B1D94
1 changed files with 3 additions and 31 deletions

View File

@ -103,44 +103,16 @@ const getVanishingMessages = async (ssbServer, profile) => {
const messagesPromise = promisePull(
// @ts-ignore
cat([
ssbServer.query.read({
ssbServer.private.read({
reverse: true,
query: [
{
$filter: {
value: {
private: true,
content: {
root: profile.id,
},
},
},
},
],
limit: 100,
}),
ssbServer.query.read({
reverse: true,
query: [
{
$filter: {
value: {
private: true,
content: {
type: "post",
root: { $not: true },
},
},
},
},
],
limit: 100,
}),
]),
pull.filter(
(msg) =>
msg.value.content.type == "post" &&
(msg.value.content.root || msg.value.content.recps.includes(profile.id))
(msg.value.content.root == profile.id ||
msg.value.content.recps.includes(profile.id))
),
paramap(mapProfiles(ssbServer))
);