Commit 4f3123cd652a5603873f1d2e87d6016552e7b4c8
Merge pull request #56 from ticktackim/autoinvite
use autoinvite on main network, but only if you have less than 5 followersmix irving authored on 12/8/2017, 12:44:24 AM
GitHub committed on 12/8/2017, 12:44:24 AM
Parent: c89775f18f4db508d01519014235d1e9419af81b
Parent: 1a9f5025e7297fb97fe0f79c34b9cb97bb96e150
Files changed
config.js | changed |
default-config.json | changed |
main.js | changed |
ssb-config.json | added |
config.js | ||
---|---|---|
@@ -3,12 +3,10 @@ | ||
3 | 3 | const ssbKeys = require('ssb-keys') |
4 | 4 | const Path = require('path') |
5 | 5 | |
6 | 6 | // const appName = process.env.ssb_appname || 'ticktack' //'ticktack' TEMP: this is for the windowsSSB installer only |
7 | -const appName = 'ssb' | |
8 | -const opts = appName == 'ssb' | |
9 | - ? null | |
10 | - : require('./default-config.json') | |
7 | +const appName = process.env.ssb_appname || 'ssb' | |
8 | +var opts = appName === 'ssb' ? require('./ssb-config.json') : require('./default-config') | |
11 | 9 | |
12 | 10 | exports.gives = nest('config.sync.load') |
13 | 11 | exports.create = (api) => { |
14 | 12 | var config |
@@ -22,4 +20,5 @@ | ||
22 | 20 | } |
23 | 21 | return config |
24 | 22 | }) |
25 | 23 | } |
24 | + |
default-config.json | ||
---|---|---|
@@ -1,9 +1,9 @@ | ||
1 | 1 | { |
2 | - "port": 43750, | |
3 | - "blobsPort": 43751, | |
4 | - "ws": { "port": 43751 }, | |
5 | - "caps": {"shs": "ErgQF85hFQpUXp69IXtLW+nXDgFIOKKDOWFX/st2aWk="}, | |
2 | + "_port": 43750, | |
3 | + "_blobsPort": 43751, | |
4 | + "_ws": { "port": 43751 }, | |
5 | + "_caps": {"shs": "ErgQF85hFQpUXp69IXtLW+nXDgFIOKKDOWFX/st2aWk="}, | |
6 | 6 | "autoinvite": "128.199.132.182:43750:@7xMrWP8708+LDvaJrRMRQJEixWYp4Oipa9ohqY7+NyQ=.ed25519~YC4ZnjHH8qzsyHe2sihW8WDlhxSUH33IthOi4EsldwQ=" |
7 | 7 | } |
8 | 8 | |
9 | 9 |
main.js | ||
---|---|---|
@@ -39,18 +39,30 @@ | ||
39 | 39 | |
40 | 40 | const api = entry(sockets, nest({ |
41 | 41 | 'app.html.app': 'first', |
42 | 42 | 'invite.async.autofollow': 'first', |
43 | - 'config.sync.load': 'first' | |
43 | + 'config.sync.load': 'first', | |
44 | + 'sbot.async.friendsGet': 'first', | |
45 | + 'sbot.async.get': 'first' | |
44 | 46 | })) |
45 | 47 | |
46 | 48 | document.body.appendChild(api.app.html.app()) |
49 | +// console.log(api.config.sync.load()) | |
47 | 50 | |
48 | 51 | var invite = api.config.sync.load().autoinvite |
49 | -if(invite) | |
50 | - api.invite.async.autofollow( | |
51 | - invite, | |
52 | - function (err, follows) { | |
53 | - console.log('autofollowed', err, follows); | |
52 | +var self_id = api.config.sync.load().keys.id | |
53 | +if(invite) { | |
54 | + api.sbot.async.friendsGet({dest: self_id}, function (err, friends) { | |
55 | + //if you have less than 5 followers, maybe use the autoinvite | |
56 | + if(Object.keys(friends).length <= 5) | |
57 | + api.invite.async.autofollow( | |
58 | + invite, | |
59 | + function (err, follows) { console.log('autofollowed', err, follows) } | |
60 | + ) | |
61 | + else | |
62 | + console.log('no autoinvite - you have friends already') | |
54 | 63 | }) |
64 | +} | |
55 | 65 | else |
56 | 66 | console.log('no invite') |
67 | + | |
68 | + |
Built with git-ssb-web