Created
November 11, 2020 11:21
-
-
Save radzionc/d620401bbc458c2e957c06e66037b32d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Browser = require('./browser') | |
const { getNote, getOrderedUsers } = require('./business') | |
const database = require('./database') | |
const storage = require('./storage') | |
const browserWSEndpoint = process.argv[2] | |
const browser = new Browser(browserWSEndpoint) | |
const run = async () => { | |
const users = await database.getNewUsers(storage.getLastDate()) | |
if (!users.length) { | |
console.log('No new users') | |
return | |
} | |
console.log(`New users count: ${users.length}`) | |
const orderedUsers = getOrderedUsers(users) | |
await browser.openOutlook() | |
for await (const user of orderedUsers) { | |
await browser.createContact(user.email) | |
await browser.openLinkedInSection() | |
const linkedInButton = await browser.getLinkedInButton() | |
if (linkedInButton) { | |
const note = getNote(user) | |
const linkedInProfile = await browser.connectOnLinkedIn( | |
linkedInButton, | |
note | |
) | |
await database.setUserLinkedInProfile(user.id, linkedInProfile) | |
} | |
storage.setLastDate(user.registrationDate) | |
} | |
} | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment