diff --git a/src/services/serper-search.ts b/src/services/serper-search.ts index 3a688bc..4a6c41c 100644 --- a/src/services/serper-search.ts +++ b/src/services/serper-search.ts @@ -2,9 +2,8 @@ import { AsyncService, AutoCastable, DownstreamServiceFailureError, Prop, RPC_CA import { singleton } from 'tsyringe'; import { GlobalLogger } from './logger'; import { SecretExposer } from '../shared/services/secrets'; -import { GEOIP_SUPPORTED_LANGUAGES, GeoIPService } from './geoip'; import { AsyncLocalContext } from './async-context'; -import { SerperBingHTTP, SerperGoogleHTTP, SerperImageSearchResponse, SerperNewsSearchResponse, SerperSearchQueryParams, SerperWebSearchResponse, WORLD_COUNTRIES } from '../shared/3rd-party/serper-search'; +import { SerperBingHTTP, SerperGoogleHTTP, SerperImageSearchResponse, SerperNewsSearchResponse, SerperSearchQueryParams, SerperWebSearchResponse } from '../shared/3rd-party/serper-search'; import { BlackHoleDetector } from './blackhole-detector'; import { Context } from './registry'; import { ServiceBadAttemptError } from '../shared'; @@ -20,7 +19,6 @@ export class SerperSearchService extends AsyncService { constructor( protected globalLogger: GlobalLogger, protected secretExposer: SecretExposer, - protected geoipControl: GeoIPService, protected threadLocal: AsyncLocalContext, protected blackHoleDetector: BlackHoleDetector, ) { @@ -49,30 +47,6 @@ export class SerperSearchService extends AsyncService { doSearch(variant: 'images', query: SerperSearchQueryParams): Promise; doSearch(variant: 'news', query: SerperSearchQueryParams): Promise; async doSearch(variant: 'web' | 'images' | 'news', query: SerperSearchQueryParams) { - const ip = this.threadLocal.get('ip'); - if (ip) { - const geoip = await this.geoipControl.lookupCity(ip, GEOIP_SUPPORTED_LANGUAGES.EN); - const locationChunks = []; - if (geoip?.city) { - locationChunks.push(geoip.city); - } - if (geoip?.subdivisions?.length) { - for (const x of geoip.subdivisions) { - locationChunks.push(x.name); - } - } - if (geoip?.country) { - const code = geoip.country.code?.toLowerCase(); - if (code && code.toUpperCase() in WORLD_COUNTRIES) { - query.gl ??= code; - } - locationChunks.push(geoip.country.name); - } - if (locationChunks.length) { - query.location ??= locationChunks.join(', '); - } - } - const clientIt = this.iterClient(); let client = clientIt.next().value; if (!client) {