Commit f99e3d7f563e4c69140b31af2e6e873e067b24b7
minimal ebt plugin for checking my known remote seq
mix irving committed on 5/16/2018, 12:26:21 AMParent: 26d61ca780b49f14cec3dc071c03f71b4b3da905
Files changed
app/html/app.js | changed |
background-process.js | changed |
package-lock.json | changed |
package.json | changed |
app/html/app.js | ||
---|---|---|
@@ -1,6 +1,6 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | -const { h, Value } = require('mutant') | |
2 | +const { h, Value, onceTrue } = require('mutant') | |
3 | 3 | |
4 | 4 | exports.gives = nest('app.html.app') |
5 | 5 | |
6 | 6 | exports.needs = nest({ |
@@ -12,15 +12,17 @@ | ||
12 | 12 | 'keys.sync.id': 'first', |
13 | 13 | 'router.sync.router': 'first', |
14 | 14 | 'settings.sync.get': 'first', |
15 | 15 | 'settings.sync.set': 'first', |
16 | - | |
17 | 16 | 'invite.async.autofollow': 'first', |
18 | 17 | 'config.sync.load': 'first', |
19 | 18 | 'sbot.async.friendsGet': 'first', |
20 | - 'sbot.async.get': 'first' | |
19 | + 'sbot.async.get': 'first', | |
20 | + 'sbot.obs.connection': 'first' // EBT | |
21 | 21 | }) |
22 | 22 | |
23 | +var count = 0 // TODO - rm | |
24 | + | |
23 | 25 | exports.create = (api) => { |
24 | 26 | var view |
25 | 27 | |
26 | 28 | return nest({ |
@@ -33,12 +35,32 @@ | ||
33 | 35 | api.history.obs.location()(loc => console.log('location:', loc)) |
34 | 36 | |
35 | 37 | startApp() |
36 | 38 | |
39 | + onceTrue(api.sbot.obs.connection, server => getMySeq(server)) // EBT | |
40 | + | |
37 | 41 | return app |
38 | 42 | } |
39 | 43 | }) |
40 | 44 | |
45 | + function getMySeq (server) { | |
46 | + server.ebt.remoteFeedSequence((err, data) => { | |
47 | + server.latestSequence(server.id, (err, seq) => { | |
48 | + console.log(`${count} mins`) | |
49 | + count = count + 1 | |
50 | + console.log('actual seq:', seq) | |
51 | + console.log(JSON.stringify(data, null, 2)) | |
52 | + console.log('ticktack pubs', [ | |
53 | + '@7xMrWP8708+LDvaJrRMRQJEixWYp4Oipa9ohqY7+NyQ=.ed25519', | |
54 | + '@MflVZCcOBOUe6BLrm/8TyirkTu9/JtdnIJALcd8v5bc=.ed25519' | |
55 | + ]) | |
56 | + console.log('------------------') | |
57 | + }) | |
58 | + }) | |
59 | + | |
60 | + setTimeout(() => getMySeq(server), 60000) | |
61 | + } | |
62 | + | |
41 | 63 | function renderLocation (loc) { |
42 | 64 | var page = api.router.sync.router(loc) |
43 | 65 | if (page) { |
44 | 66 | view.set([ |
@@ -85,19 +107,25 @@ | ||
85 | 107 | console.log('no invites') |
86 | 108 | return |
87 | 109 | } |
88 | 110 | |
89 | - var self_id = api.config.sync.load().keys.id | |
90 | - api.sbot.async.friendsGet({dest: self_id}, function (err, friends) { | |
91 | - // if you have less than 5 followers, maybe use the autoinvite | |
92 | - if (Object.keys(friends).length <= 5) { | |
93 | - invites.forEach(invite => { | |
94 | - console.log('using invite:', invite) | |
95 | - api.invite.async.autofollow(invite, (err, follows) => { | |
96 | - if (err) console.error('Autofollow error:', err) | |
97 | - else console.log('Autofollow success', follows) | |
98 | - }) | |
111 | + useInvites(invites) | |
112 | + // TODO change it so that if you already have a bunch of friends you unfollow the pubs after they follow you? | |
113 | + | |
114 | + // var myKey = api.config.sync.load().keys.id | |
115 | + // api.sbot.async.friendsGet({dest: myKey}, function (err, friends) { | |
116 | + // // if you have less than 5 followers, maybe use the autoinvite | |
117 | + // if (Object.keys(friends).length <= 5) useInvites(invites) | |
118 | + // else console.log('no autoinvite - you have friends already') | |
119 | + // }) | |
120 | + | |
121 | + function useInvites (invites) { | |
122 | + invites.forEach(invite => { | |
123 | + console.log('using invite:', invite) | |
124 | + api.invite.async.autofollow(invite, (err, follows) => { | |
125 | + if (err) console.error('Autofollow error:', err) | |
126 | + else console.log('Autofollow success', follows) | |
99 | 127 | }) |
100 | - } else { console.log('no autoinvite - you have friends already') } | |
101 | - }) | |
128 | + }) | |
129 | + } | |
102 | 130 | } |
103 | 131 | } |
background-process.js | ||
---|---|---|
@@ -18,9 +18,9 @@ | ||
18 | 18 | .use(require('scuttlebot/plugins/local')) |
19 | 19 | .use(require('scuttlebot/plugins/logging')) |
20 | 20 | .use(require('ssb-query')) |
21 | 21 | .use(require('ssb-about')) |
22 | - // .use(require('ssb-ebt')) | |
22 | + .use(require('ssb-ebt')) | |
23 | 23 | .use(require('ssb-ws')) |
24 | 24 | .use(require('ssb-server-channel')) |
25 | 25 | .use(require('./ssb-server-ticktack')) |
26 | 26 |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 283679 bytes New file size: 289783 bytes |
Built with git-ssb-web