From 220631c70478f2621b0736c93323035c17d503c8 Mon Sep 17 00:00:00 2001 From: TylerSchroederWM <75996872+TylerSchroederWM@users.noreply.github.com> Date: Mon, 1 Feb 2021 11:57:12 -0500 Subject: patchfoo integration pt. 2 --- channels-lib.js | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'channels-lib.js') 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) { -- cgit v1.2.3