Commit 252470df684356284bf88ce5c1810cfa4404f0eb
add thread and heads to get
mixmix committed on 9/20/2018, 12:25:31 AMParent: d9884b6426f0005c716f22446dd343470ededd8c
Files changed
README.md | changed |
gathering/async/get.js | changed |
README.md | ||
---|---|---|
@@ -82,9 +82,11 @@ | ||
82 | 82 … | size: Integer, // * |
83 | 83 … | type: MimeTypeString // * |
84 | 84 … | }, |
85 | 85 … | images: [ Image, Image, ... ] // Objects of same form as image property |
86 | - attendees: [ FeedId, FeedId, ... ] | |
86 … | + attendees: [ FeedId, FeedId, ... ], | |
87 … | + heads: [ MessageId, .... ], // most recent message(s) in the document/ thread | |
88 … | + threads: [ MessageId, ... ] // all backlinks in causal order | |
87 | 89 … | } |
88 | 90 … | ``` |
89 | 91 … | |
90 | 92 … | Strings that haven't been set will be empty strings, sub-properties marked with `*` are optional and may not be present. |
gathering/async/get.js | |||
---|---|---|---|
@@ -1,5 +1,6 @@ | |||
1 | 1 … | const { isUpdate, isAttendee } = require('ssb-gathering-schema') | |
2 … | +const { heads } = require('ssb-sort') | ||
2 | 3 … | const merge = require('lodash.merge') | |
3 | 4 … | const getBacklinks = require('../../lib/get-backlinks') | |
4 | 5 … | const permittedOpts = require('../../lib/permitted-opts') | |
5 | 6 … | ||
@@ -14,14 +15,20 @@ | |||
14 | 15 … | return function getGathering (key, cb) { | |
15 | 16 … | server.get(key, (err, value) => { | |
16 | 17 … | if (err) return cb(err) | |
17 | 18 … | ||
18 | - getBacklinks(server)({ key, value }, (err, backlinks) => { | ||
19 … | + const gathering = { key, value } | ||
20 … | + | ||
21 … | + getBacklinks(server)(gathering, (err, backlinks) => { | ||
19 | 22 … | if (err) return cb(err) | |
20 | 23 … | ||
21 | 24 … | const doc = merge({}, | |
22 | 25 … | EMPTY_DOC, | |
23 | - { key }, | ||
26 … | + { | ||
27 … | + key, | ||
28 … | + thread: backlinks, | ||
29 … | + heads: heads([gathering, ...backlinks]) | ||
30 … | + }, | ||
24 | 31 … | reduceUpdates(backlinks), | |
25 | 32 … | reduceAttendees(backlinks) | |
26 | 33 … | ) | |
27 | 34 … | cb(null, doc) |
Built with git-ssb-web