-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from KEKDATA/feature/Profile
Feature/profile
- Loading branch information
Showing
54 changed files
with
1,055 additions
and
200 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const checkIsLink = (link: string | undefined) => { | ||
if (!link) { | ||
return false; | ||
} | ||
|
||
const isLink = /(https?:\/\/[^\s]+)/g.test(link); | ||
return isLink; | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Queue from 'bull'; | ||
import { nanoid } from 'nanoid'; | ||
|
||
import { OPTIONS, MAX_JOBS_PER_WORKER } from './config'; | ||
import { getProfileInfo } from '../twitter/profile/profile_info'; | ||
import { setupWebdriverFx } from '../webdriver'; | ||
import { NormalizedProfileInfo, ProfileParsedInfo, Send } from '../types'; | ||
import { ProfileInfo } from '../twitter/types'; | ||
|
||
console.info('Profile connected'); | ||
|
||
const profileQueue = new Queue('profile', OPTIONS); | ||
const webQueue = new Queue('web', OPTIONS); | ||
|
||
profileQueue.process(MAX_JOBS_PER_WORKER, async job => { | ||
const { | ||
id, | ||
options, | ||
tweetsType, | ||
}: { tweetsType: ProfileInfo; id: string; options: Send } = job.data; | ||
|
||
await setupWebdriverFx({ options }); | ||
|
||
const { | ||
profileInfo, | ||
}: { profileInfo: ProfileParsedInfo } = await getProfileInfo(null); | ||
|
||
const { activityInfo, contactInfo, ...actualProfile } = profileInfo; | ||
const normalizedActivityInfo = activityInfo.map((info: string) => ({ | ||
id: nanoid(), | ||
info, | ||
})); | ||
const normalizedContactInfo = contactInfo.map((info: string) => ({ | ||
id: nanoid(), | ||
info, | ||
})); | ||
|
||
const normalizedProfileInfo: NormalizedProfileInfo = { | ||
activityInfo: normalizedActivityInfo, | ||
contactInfo: normalizedContactInfo, | ||
...actualProfile, | ||
tweetsType, | ||
}; | ||
|
||
webQueue.add({ | ||
id, | ||
result: normalizedProfileInfo, | ||
}); | ||
}); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { Likes, Media, Tweets, TweetsAndReplies } from '../types'; | ||
import { Likes, Media, ProfileInfo, Tweets, TweetsAndReplies } from '../types'; | ||
|
||
export const TWEETS_TAB: Tweets = 'Tweets'; | ||
export const TWEETS_REPLIES_TAB: TweetsAndReplies = 'TweetsAndReplies'; | ||
export const MEDIA: Media = 'Media'; | ||
export const LIKES: Likes = 'Likes'; | ||
export const TWEETS_TAB: Tweets = 'tweets'; | ||
export const TWEETS_REPLIES_TAB: TweetsAndReplies = 'tweetsAndReplies'; | ||
export const MEDIA: Media = 'media'; | ||
export const LIKES: Likes = 'likes'; | ||
export const PROFILE_INFO_TYPE: ProfileInfo = 'profile_info'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export const PROFILE_TARGET: string = 'profile'; | ||
export const SEARCH_TWEETS_TARGET: string = 'search_tweets'; | ||
import { ProfileOption, SearchTweetsOption } from '../types'; | ||
|
||
export const PROFILE_TARGET: ProfileOption = 'profile'; | ||
export const SEARCH_TWEETS_TARGET: SearchTweetsOption = 'search_tweets'; |
This file contains 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
This file contains 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
Oops, something went wrong.