fix: skip searching users with the "impersonation" label.

This commit is contained in:
kawamataryo 2024-11-18 11:22:30 +09:00
parent 8e233d8488
commit f2d4160db8
2 changed files with 18 additions and 2 deletions

View File

@ -100,4 +100,8 @@ export const DOCUMENT_LINK = {
"https://www.sky-follower-bridge.dev/troubleshooting.html#page-errors",
} as const;
export const BSKY_DOMAIN = process.env.PLASMO_PUBLIC_BSKY_DOMAIN || "bsky.social";
export const BSKY_DOMAIN = process.env.PLASMO_PUBLIC_BSKY_DOMAIN || "bsky.social";
export const BSKY_PROFILE_LABEL = {
IMPERSONATION: "impersonation",
} as const;

View File

@ -2,6 +2,12 @@ import { isSimilarUser } from "~lib/bskyHelpers";
import type { getAccountNameAndDisplayName } from "~lib/domHelpers";
import { isOneSymbol } from "~lib/utils";
import type { BskyServiceWorkerClient } from "./bskyServiceWorkerClient";
import { BSKY_PROFILE_LABEL } from "./constants";
import type { ProfileView } from "@atproto/api/dist/client/types/app/bsky/actor/defs";
const isImpersonationUser = (user: ProfileView) => {
return user.labels.some((label) => label.val === BSKY_PROFILE_LABEL.IMPERSONATION);
}
export const searchBskyUser = async ({
client,
@ -25,11 +31,17 @@ export const searchBskyUser = async ({
}
try {
const searchResults = await client.searchUser({
term: term,
term,
limit: 3,
});
for (const searchResult of searchResults) {
// skip impersonation users
if (isImpersonationUser(searchResult)) {
continue;
}
const { isSimilar: isUserFound, type } = isSimilarUser(
// TODO: simplify
{