Skip to content

Commit

Permalink
Merge pull request #475 from reservoirprotocol/fix/filter-search-spam
Browse files Browse the repository at this point in the history
Filter out spam search results for PN
  • Loading branch information
pedromcunha committed Feb 20, 2024
2 parents f7bb78c + 7fd946e commit e6a3ecc
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pages/api/globalSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ export const config = {
runtime: 'edge',
}

const spamCollections: Record<number, string[]> = {
1: ['0x31fe9d95dde43cf9893b76160f63521a9e3d26b0'],
}

const locallyFilterSpam = (results: any[]) => {
return results.filter((result) => {
if (
result.data.collectionId &&
result.data.chainId &&
spamCollections[result.data.chainId]
) {
return !spamCollections[result.data.chainId].includes(
result.data.collectionId,
)
? true
: false
}
})
}

export default async function handler(req: Request) {
const { searchParams } = new URL(req.url)
const query = searchParams.get('query')
Expand Down Expand Up @@ -191,6 +211,8 @@ async function searchSingleChain(chain: ReservoirChain, query: string) {
searchResults = processedSearchResults
}
}
//filter own known spam collections
searchResults = locallyFilterSpam(searchResults)
return searchResults
}

Expand Down Expand Up @@ -353,6 +375,9 @@ async function searchAllChains(query: string) {
(a, b) => b.data.allTimeUsdVolume - a.data.allTimeUsdVolume,
)
}

//filter own known spam collections
searchResults = locallyFilterSpam(searchResults)
}

return searchResults
Expand Down

0 comments on commit e6a3ecc

Please sign in to comment.