Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {
InboxStream,
CommentStream,
SubmissionStream,
ModMailStream
} from "./src/main";
import Snoowrap from "snoowrap";
const creds = require("./credentials.json");
// Create snoowrap object
const r = new Snoowrap(creds);
// Modmail test
const modmail = new ModMailStream(r, {});
modmail.on("item", console.log);
// Loop until we run out of blogs
setTimeout(redditImportLoop, 1500);
state.progressNext = subscriptionListing[subscriptionListing.length - 1].name;
state.progressCurrent = state.progressCurrent + 1;
setState({progressNext: state.progressNext, progressCurrent: state.progressCurrent});
}
}).catch((err: any) => {
console.error(err);
setState({systemMessage: "Error retrieving subscriptions: " + err, progressMode: null, progressNext: null, progressCurrent: 0});
});
};
const state = getState();
if (!state.progressMode) {
reddit = new Snoowrap({
userAgent: state.config.remoteSettings.redditUserAgent,
clientId: state.config.remoteSettings.redditClientID,
clientSecret: "",
refreshToken: state.config.remoteSettings.redditRefreshToken,
});
// Show progress bar and kick off loop
state.progressMode = PR.reddit;
state.progressCurrent = 0;
setState({
systemSnack: "Your Reddit subscriptions are being imported... You will recieve an alert when the import is finished.",
progressMode: state.progressMode, progressCurrent: state.progressCurrent
});
redditImportLoop();
}
}
return new CancelablePromise((resolve) => {
const reddit = new Snoowrap({
userAgent: config.remoteSettings.redditUserAgent,
clientId: config.remoteSettings.redditClientID,
clientSecret: "",
refreshToken: config.remoteSettings.redditRefreshToken,
});
if (url.includes("/r/")) {
reddit.getSubreddit(getFileGroup(url)).getHot({after: helpers.next})
.then((submissionListing: any) => {
if (submissionListing.length > 0) {
let convertedListing = Array();
let convertedCount = 0;
for (let s of submissionListing) {
convertURL(s.url).then((urls: Array) => {
convertedListing = convertedListing.concat(urls);
convertedCount++;
if (convertedCount == submissionListing.length) {