git ssb

0+

mixmix / scuttle-gathering



Commit 252470df684356284bf88ce5c1810cfa4404f0eb

add thread and heads to get

mixmix committed on 9/20/2018, 12:25:31 AM
Parent: d9884b6426f0005c716f22446dd343470ededd8c

Files changed

README.mdchanged
gathering/async/get.jschanged
README.mdView
@@ -82,9 +82,11 @@
8282 size: Integer, // *
8383 type: MimeTypeString // *
8484 },
8585 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
8789 }
8890 ```
8991
9092 Strings that haven't been set will be empty strings, sub-properties marked with `*` are optional and may not be present.
gathering/async/get.jsView
@@ -1,5 +1,6 @@
11 const { isUpdate, isAttendee } = require('ssb-gathering-schema')
2 +const { heads } = require('ssb-sort')
23 const merge = require('lodash.merge')
34 const getBacklinks = require('../../lib/get-backlinks')
45 const permittedOpts = require('../../lib/permitted-opts')
56
@@ -14,14 +15,20 @@
1415 return function getGathering (key, cb) {
1516 server.get(key, (err, value) => {
1617 if (err) return cb(err)
1718
18- getBacklinks(server)({ key, value }, (err, backlinks) => {
19 + const gathering = { key, value }
20 +
21 + getBacklinks(server)(gathering, (err, backlinks) => {
1922 if (err) return cb(err)
2023
2124 const doc = merge({},
2225 EMPTY_DOC,
23- { key },
26 + {
27 + key,
28 + thread: backlinks,
29 + heads: heads([gathering, ...backlinks])
30 + },
2431 reduceUpdates(backlinks),
2532 reduceAttendees(backlinks)
2633 )
2734 cb(null, doc)

Built with git-ssb-web