Also consider wall posts the ones there are from authors with no roots, and no wall specified, comming from patchwork

This commit is contained in:
Rogerio Chaves 2020-04-05 20:23:14 +02:00
parent 3ad7ace4ea
commit 3344cb8550
No known key found for this signature in database
GPG Key ID: E6AF5440509B1D94
2 changed files with 41 additions and 19 deletions

View File

@ -1,5 +1,6 @@
const { promisify } = require("./utils");
const pull = require("pull-stream");
const cat = require("pull-cat");
const latestOwnerValue = (ssbServer) => ({ key, dest }, cb) => {
let value = null;
@ -73,19 +74,40 @@ const mapAuthorName = (ssbServer) => (data, callback) => {
const getPosts = (ssbServer, profile) =>
new Promise((resolve, reject) => {
pull(
ssbServer.query.read({
reverse: true,
query: [
{
$filter: {
value: {
content: { type: "post", wall: profile.id },
// @ts-ignore
cat([
ssbServer.query.read({
reverse: true,
query: [
{
$filter: {
value: {
content: { type: "post", wall: profile.id },
},
},
},
},
],
limit: 100,
}),
],
limit: 100,
}),
ssbServer.query.read({
reverse: true,
query: [
{
$filter: {
value: {
author: profile.id,
content: {
type: "post",
wall: { $not: true },
root: { $not: true },
},
},
},
},
],
limit: 100,
}),
]),
pull.asyncMap(mapAuthorName(ssbServer)),
pull.collect((err, msgs) => {
const entries = msgs.map((x) => x.value);

View File

@ -1,14 +1,14 @@
var pull = require("pull-stream");
var cat = require("pull-cat");
var toPull = require("stream-to-pull-stream");
var ident = require("pull-identify-filetype");
var mime = require("mime-types");
var URL = require("url");
const pull = require("pull-stream");
const cat = require("pull-cat");
const toPull = require("stream-to-pull-stream");
const ident = require("pull-identify-filetype");
const mime = require("mime-types");
const URL = require("url");
const serveBlobs = (sbot) => {
return (req, res) => {
var parsed = URL.parse(req.url, true);
var hash = decodeURIComponent(parsed.pathname.replace("/blob/", ""));
const parsed = URL.parse(req.url, true);
const hash = decodeURIComponent(parsed.pathname.replace("/blob/", ""));
waitFor(hash, function (_, has) {
if (!has) return respond(res, 404, "File not found");