git ssb

0+

mixmix / scuttle-gathering



Commit 05e5e97a80eb654ea1c48fa695db2c863c34a3c5

reduces attendees

mixmix committed on 9/19/2018, 10:18:16 PM
Parent: 7c528349577470dee18f77f63097c8b28f7825fa

Files changed

gathering/async/get.jschanged
gathering/async/get.test.jschanged
gathering/async/get.jsView
@@ -26,9 +26,24 @@
2626
2727 return merge(acc, update)
2828 }, { images: [] })
2929
30- cb(null, merge(doc, updates))
30 + const attendees = backlinks
31 + .filter(isAttendee)
32 + .reduce((acc, msg) => {
33 + const { link, remove } = msg.value.content.attendee
34 + // only trust attendee calls from people themselves for now
35 + if (msg.value.author !== link) return acc
36 +
37 + if (remove) {
38 + return acc.filter(feedId => feedId !== link)
39 + } else {
40 + if (acc.includes(link)) return acc
41 + else return [...acc, link]
42 + }
43 + }, [])
44 +
45 + cb(null, merge(doc, updates, { attendees }))
3146 })
3247 })
3348 }
3449 }
gathering/async/get.test.jsView
@@ -41,19 +41,27 @@
4141 },
4242 { link: '&AnotherImage//z3os/qA9+YJndRmbJQXl8LYfBquz4=.sha256' }
4343 ], 'has all images added')
4444
45- done()
45 + t.deepEqual(doc.attendees, [ server.id ], 'shows me attending')
46 + scuttle.attendee.async.publish(gathering.key, false, (err, attendee) => {
47 + if (err) throw (err)
48 + scuttle.gathering.async.get(gathering.key, (err, doc) => {
49 + if (err) throw (err)
50 + t.deepEqual(doc.attendees, [], 'shows me no longer attending')
51 +
52 + done()
53 + })
54 + })
4655 })
4756 })
4857 })
4958
5059 // helper
5160 function setupGathering (cb) {
5261 var epoch = now + 5000
5362
54- // publish gathering
55- const opts = {
63 + const initialGathering = {
5664 title: 'ziva\'s birthday',
5765 startDateTime: {
5866 epoch,
5967 tz: 'Pacific/ Auckland'
@@ -64,21 +72,23 @@
6472 size: 1049416,
6573 type: 'image/jpeg'
6674 }
6775 }
68- scuttle.gathering.async.publish(opts, (err, gathering) => {
76 +
77 + const anUpdate = {
78 + startDateTime: { epoch: now + 750 },
79 + location: 'our place in mirimar',
80 + image: {
81 + 'link': '&AnotherImage//z3os/qA9+YJndRmbJQXl8LYfBquz4=.sha256'
82 + }
83 + }
84 +
85 + // publish gathering
86 + scuttle.gathering.async.publish(initialGathering, (err, gathering) => {
6987 if (err) return cb(err)
7088
7189 // make an update
72- epoch = now + 750
73- const opts = {
74- startDateTime: { epoch },
75- location: 'our place in mirimar',
76- image: {
77- 'link': '&AnotherImage//z3os/qA9+YJndRmbJQXl8LYfBquz4=.sha256'
78- }
79- }
80- scuttle.update.async.publish(gathering.key, opts, (err, update) => {
90 + scuttle.update.async.publish(gathering.key, anUpdate, (err, update) => {
8191 if (err) return cb(err)
8292
8393 // attend it
8494 scuttle.attendee.async.publish(gathering.key, (err, attendee) => {

Built with git-ssb-web