aboutsummaryrefslogtreecommitdiff
path: root/channels-lib.js
diff options
context:
space:
mode:
authorTylerSchroederWM <75996872+TylerSchroederWM@users.noreply.github.com>2021-02-01 11:57:12 -0500
committerGitHub <noreply@github.com>2021-02-01 11:57:12 -0500
commit220631c70478f2621b0736c93323035c17d503c8 (patch)
treef7edf076fbd0c7afe652ed35bb66a6f6ebac93f7 /channels-lib.js
parente1743f3bb0bb6cb958d33b39a2670cd2b7c5b556 (diff)
downloadssb-logbook-220631c70478f2621b0736c93323035c17d503c8.tar.gz
ssb-logbook-220631c70478f2621b0736c93323035c17d503c8.zip
patchfoo integration pt. 2
Diffstat (limited to 'channels-lib.js')
-rw-r--r--channels-lib.js27
1 files changed, 4 insertions, 23 deletions
diff --git a/channels-lib.js b/channels-lib.js
index 2968e45..f2d8484 100644
--- a/channels-lib.js
+++ b/channels-lib.js
@@ -75,27 +75,8 @@ class StreamController {
}
}
-function getFriendsSync(client, hops) {
- debug("Fetching list of friends...");
- var formattedFriends;
- var intervalIterations = 1;
-
- client.friends.hops({
- dunbar: Number.MAX_SAFE_INTEGER,
- max: hops
- }, function(error, friends) {
- if(error) {
- throw "Couldn't get list of friends from scuttlebot: " + error;
- }
-
- formattedFriends = Object.keys(friends).map(id => id.toLowerCase());
- });
-
- return waitUntilDefined(formattedFriends); // since this has to be synchronous
-}
-
module.exports = {
- getMessages: function(client, channelName, cb, hops=1) {
+ getMessages: function(client, channelName, preserve, cb, hops=MAX_HOPS) {
client.friends.hops({
dunbar: Number.MAX_SAFE_INTEGER,
max: hops
@@ -105,12 +86,12 @@ module.exports = {
}
var followedIds = Object.keys(friends).map(id => id.toLowerCase());
- getMessagesFrom(client, channelName, followedIds, cb);
+ getMessagesFrom(client, channelName, followedIds, preserve, cb);
});
}
}
-function getMessagesFrom(client, channelName, followedIds, cb) {
+function getMessagesFrom(client, channelName, followedIds, preserve, cb) {
debug("Fetching messages from IDs in " + JSON.stringify(followedIds));
var channelTag = "#" + channelName;
@@ -135,7 +116,7 @@ function getMessagesFrom(client, channelName, followedIds, cb) {
streamController.finish();
}));
- cb(streamController.outputStream);
+ cb(streamController.outputStream, preserve);
}
function createHashtagStream(client, channelName) {