Commit a4fe9e20496ae2e80bb64e4e6d707119424ef139
Merge pull request #29 from ssbc/autofollow
autofollow: allow building in a default pubmix irving authored on 8/17/2017, 2:57:07 AM
GitHub committed on 8/17/2017, 2:57:07 AM
Parent: cfd8810edb72821b5273b552d776456b7a6d4ae0
Parent: 9469eaafc9482e2d17b32da95e903b8bf02737a4
Files changed
invite.js | changed |
invite.js | ||
---|---|---|
@@ -10,12 +10,15 @@ | ||
10 | 10 … | 'contact.async.followerOf': 'first', |
11 | 11 … | 'keys.sync.id': 'first' |
12 | 12 … | }) |
13 | 13 … | |
14 | -exports.gives = nest('invite.async.accept') | |
14 … | +exports.gives = nest({ | |
15 … | + 'invite.async.accept': true, | |
16 … | + 'invite.async.autofollow': true, | |
17 … | +}) | |
15 | 18 … | |
16 | 19 … | exports.create = function (api) { |
17 | - return nest('invite.async.accept', function (invite, cb) { | |
20 … | + function accept (invite, cb) { | |
18 | 21 … | var progress = Value('Connecting...') |
19 | 22 … | var data = ref.parseInvite(invite) |
20 | 23 … | var id = api.keys.sync.id() |
21 | 24 … | if (!data) return cb(new Error('Not a valid invite code. Please make sure you copied the entire code and try again.')) |
@@ -69,6 +72,19 @@ | ||
69 | 72 … | }) |
70 | 73 … | }) |
71 | 74 … | |
72 | 75 … | return progress |
76 … | + } | |
77 … | + return nest({ | |
78 … | + 'invite.async.accept': accept, | |
79 … | + //like invite, but check whether we already follow them first | |
80 … | + 'invite.async.autofollow': function (invite, cb) { | |
81 … | + var id = api.keys.sync.id() | |
82 … | + var data = ref.parseInvite(invite) | |
83 … | + api.contact.async.followerOf(id, data.key, function (_, follows) { | |
84 … | + if (follows) console.log('already following', cb()) | |
85 … | + else accept(invite, cb) | |
86 … | + }) | |
87 … | + } | |
73 | 88 … | }) |
74 | 89 … | } |
90 … | + |
Built with git-ssb-web