Files: d274b4c0b5d5a0b27a731e62ba54882cf4354efd / sbot / index.js
1817 bytesRaw
1 | var Channels = require('./channels') |
2 | var Heartbeat = require('./heartbeat') |
3 | var Subscriptions = require('./subscriptions') |
4 | var Roots = require('./roots') |
5 | var Progress = require('./progress') |
6 | var Search = require('./search') |
7 | var RecentFeeds = require('./recent-feeds') |
8 | var LiveBacklinks = require('./live-backlinks') |
9 | var pull = require('pull-stream') |
10 | |
11 | exports.name = 'patchwork' |
12 | exports.version = require('../package.json').version |
13 | exports.manifest = { |
14 | channels: 'source', |
15 | subscriptions: 'source', |
16 | roots: 'source', |
17 | latest: 'source', |
18 | linearSearch: 'source', |
19 | progress: 'source', |
20 | recentFeeds: 'source', |
21 | heartbeat: 'source', |
22 | |
23 | getSubscriptions: 'async', |
24 | getChannels: 'async', |
25 | |
26 | liveBacklinks: { |
27 | subscribe: 'sync', |
28 | unsubscribe: 'sync', |
29 | stream: 'source' |
30 | } |
31 | } |
32 | |
33 | exports.init = function (ssb, config) { |
34 | var progress = Progress(ssb, config) |
35 | var channels = Channels(ssb, config) |
36 | var subscriptions = Subscriptions(ssb, config) |
37 | var roots = Roots(ssb, config) |
38 | var search = Search(ssb, config) |
39 | var recentFeeds = RecentFeeds(ssb, config) |
40 | |
41 | // prioritize pubs that we actually follow |
42 | pull( |
43 | ssb.friends.createFriendStream({hops: 1, live: false}), |
44 | pull.collect((err, contacts) => { |
45 | if (!err) { |
46 | ssb.gossip.peers().forEach(function (peer) { |
47 | if (contacts.includes(peer.key)) { |
48 | ssb.gossip.add(peer, 'friends') |
49 | } |
50 | }) |
51 | } |
52 | }) |
53 | ) |
54 | |
55 | return { |
56 | heartbeat: Heartbeat(ssb, config), |
57 | channels: channels.stream, |
58 | subscriptions: subscriptions.stream, |
59 | roots: roots.read, |
60 | latest: roots.latest, |
61 | progress: progress.stream, |
62 | recentFeeds: recentFeeds.stream, |
63 | linearSearch: search.linear, |
64 | getSubscriptions: subscriptions.get, |
65 | getChannels: channels.get, |
66 | liveBacklinks: LiveBacklinks(ssb, config) |
67 | } |
68 | } |
69 |
Built with git-ssb-web