diff --git a/src/lib/bskyHelpers.ts b/src/lib/bskyHelpers.ts index 679087f..1b1cd23 100644 --- a/src/lib/bskyHelpers.ts +++ b/src/lib/bskyHelpers.ts @@ -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 { isSimilar: true, type: BSKY_USER_MATCH_TYPE.DESCRIPTION, diff --git a/src/lib/searchAndInsertBskyUsers.ts b/src/lib/searchAndInsertBskyUsers.ts index 7784236..dbc6ece 100644 --- a/src/lib/searchAndInsertBskyUsers.ts +++ b/src/lib/searchAndInsertBskyUsers.ts @@ -61,27 +61,29 @@ export const searchAndInsertBskyUsers = async ( let matchType = null // 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 if (!term || isOneSymbol(term)) { continue } try { - const [searchResult] = await agent.searchUser({ + const searchResults = await agent.searchUser({ term: term, - limit: 1, + limit: 3, }) - const { isSimilar: isUserFound, type } = isSimilarUser({ - accountName: twAccountName, - accountNameRemoveUnderscore: twAccountNameRemoveUnderscore, - displayName: twDisplayName, - }, searchResult) + for (const searchResult of searchResults) { + const { isSimilar: isUserFound, type } = isSimilarUser({ + accountName: twAccountName, + accountNameRemoveUnderscore: twAccountNameRemoveUnderscore, + displayName: twDisplayName, + }, searchResult) - if (isUserFound) { - targetAccount = searchResult - matchType = type - break; // Stop searching when a user is found + if (isUserFound) { + targetAccount = searchResult + matchType = type + break searchLoop; // Stop searching when a user is found + } } } catch (e) { console.error(e)