diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/serve.js | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/serve.js b/lib/serve.js index 46b78e7..749e075 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -1834,15 +1834,30 @@ Serve.prototype.type = function (path) { Serve.prototype.links = function (path) { var q = this.query var dest = path.substr(1) - var opts = { - dest: dest, - reverse: true, - values: true, - } - if (q.rel) opts.rel = q.rel + var sbot = this.app.sbot pull( - this.app.sbot.links(opts), + q.rel || q.author || !sbot.backlinks ? (q.type ? + pull.error(new Error('Unable to satisfy query')) : + sbot.links({ + source: q.author || undefined, + dest: dest, + reverse: true, + values: true, + rel: q.rel + })) : sbot.backlinks.read({ + reverse: true, + query: [ + {$filter: { + dest: dest, + value: q.type ? { + content: { + type: q.type + } + } : {} + }} + ] + }), this.renderThread(), this.wrapMessages(), this.wrapLinks(dest), |