git ssb

2+

mixmix / ticktack



Commit f99e3d7f563e4c69140b31af2e6e873e067b24b7

minimal ebt plugin for checking my known remote seq

mix irving committed on 5/16/2018, 12:26:21 AM
Parent: 26d61ca780b49f14cec3dc071c03f71b4b3da905

Files changed

app/html/app.jschanged
background-process.jschanged
package-lock.jsonchanged
package.jsonchanged
app/html/app.jsView
@@ -1,6 +1,6 @@
11 const nest = require('depnest')
2-const { h, Value } = require('mutant')
2+const { h, Value, onceTrue } = require('mutant')
33
44 exports.gives = nest('app.html.app')
55
66 exports.needs = nest({
@@ -12,15 +12,17 @@
1212 'keys.sync.id': 'first',
1313 'router.sync.router': 'first',
1414 'settings.sync.get': 'first',
1515 'settings.sync.set': 'first',
16-
1716 'invite.async.autofollow': 'first',
1817 'config.sync.load': 'first',
1918 'sbot.async.friendsGet': 'first',
20- 'sbot.async.get': 'first'
19+ 'sbot.async.get': 'first',
20+ 'sbot.obs.connection': 'first' // EBT
2121 })
2222
23+var count = 0 // TODO - rm
24+
2325 exports.create = (api) => {
2426 var view
2527
2628 return nest({
@@ -33,12 +35,32 @@
3335 api.history.obs.location()(loc => console.log('location:', loc))
3436
3537 startApp()
3638
39+ onceTrue(api.sbot.obs.connection, server => getMySeq(server)) // EBT
40+
3741 return app
3842 }
3943 })
4044
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+
4163 function renderLocation (loc) {
4264 var page = api.router.sync.router(loc)
4365 if (page) {
4466 view.set([
@@ -85,19 +107,25 @@
85107 console.log('no invites')
86108 return
87109 }
88110
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)
99127 })
100- } else { console.log('no autoinvite - you have friends already') }
101- })
128+ })
129+ }
102130 }
103131 }
background-process.jsView
@@ -18,9 +18,9 @@
1818 .use(require('scuttlebot/plugins/local'))
1919 .use(require('scuttlebot/plugins/logging'))
2020 .use(require('ssb-query'))
2121 .use(require('ssb-about'))
22- // .use(require('ssb-ebt'))
22+ .use(require('ssb-ebt'))
2323 .use(require('ssb-ws'))
2424 .use(require('ssb-server-channel'))
2525 .use(require('./ssb-server-ticktack'))
2626
package-lock.jsonView
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
package.jsonView
@@ -64,8 +64,9 @@
6464 "ssb-backlinks": "^0.6.1",
6565 "ssb-blobs": "^1.1.4",
6666 "ssb-client": "4.5.2",
6767 "ssb-config": "^2.2.0",
68+ "ssb-ebt": "^5.1.5",
6869 "ssb-friends": "^2.3.5",
6970 "ssb-keys": "^7.0.10",
7071 "ssb-markdown": "^3.3.0",
7172 "ssb-mentions": "^0.4.0",

Built with git-ssb-web