mirror of
https://github.com/snachodog/tok-to-insta-follower-bridge.git
synced 2025-04-23 20:12:22 -06:00
✨ improve search logic
This commit is contained in:
parent
f05ea60765
commit
29f51f2d52
@ -39,7 +39,7 @@ export const isSimilarUser = (names: Names, bskyProfile: ProfileView | undefined
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bskyProfile.description?.toLocaleLowerCase().includes(lowerCaseNames.accountName)) {
|
if (bskyProfile.description?.toLocaleLowerCase().includes(`@${lowerCaseNames.accountName}`)) {
|
||||||
return {
|
return {
|
||||||
isSimilar: true,
|
isSimilar: true,
|
||||||
type: BSKY_USER_MATCH_TYPE.DESCRIPTION,
|
type: BSKY_USER_MATCH_TYPE.DESCRIPTION,
|
||||||
|
@ -61,17 +61,18 @@ export const searchAndInsertBskyUsers = async (
|
|||||||
let matchType = null
|
let matchType = null
|
||||||
|
|
||||||
// Loop over search parameters and break if a user is found
|
// Loop over search parameters and break if a user is found
|
||||||
for (const term of searchTerms) {
|
searchLoop: for (const term of searchTerms) {
|
||||||
// one symbol is not a valid search term for bsky
|
// one symbol is not a valid search term for bsky
|
||||||
if (!term || isOneSymbol(term)) {
|
if (!term || isOneSymbol(term)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const [searchResult] = await agent.searchUser({
|
const searchResults = await agent.searchUser({
|
||||||
term: term,
|
term: term,
|
||||||
limit: 1,
|
limit: 3,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for (const searchResult of searchResults) {
|
||||||
const { isSimilar: isUserFound, type } = isSimilarUser({
|
const { isSimilar: isUserFound, type } = isSimilarUser({
|
||||||
accountName: twAccountName,
|
accountName: twAccountName,
|
||||||
accountNameRemoveUnderscore: twAccountNameRemoveUnderscore,
|
accountNameRemoveUnderscore: twAccountNameRemoveUnderscore,
|
||||||
@ -81,7 +82,8 @@ export const searchAndInsertBskyUsers = async (
|
|||||||
if (isUserFound) {
|
if (isUserFound) {
|
||||||
targetAccount = searchResult
|
targetAccount = searchResult
|
||||||
matchType = type
|
matchType = type
|
||||||
break; // Stop searching when a user is found
|
break searchLoop; // Stop searching when a user is found
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user