Commit 2db91b2a authored by nanahira's avatar nanahira

fix search

parent b4340f6c
Pipeline #22258 passed with stages
in 4 minutes and 40 seconds
......@@ -11,9 +11,9 @@ export class HamiFetcherService extends ConsoleLogger {
private readonly twintUrl: string = this.config.get('twintUrl');
private readonly twintToken: string = this.config.get('twintToken');
private readonly hamiUsername: string = this.config.get('hamiUsername');
private readonly hamiBlacklistSearches: string[] = this.config
.get('hamiBlacklistSearch')
?.split(' ');
private readonly hamiBlacklistSearch: string = this.config.get(
'hamiBlacklistSearch',
);
constructor(private http: HttpService, private config: ConfigService) {
super('HamiFetcherService');
}
......@@ -28,17 +28,13 @@ export class HamiFetcherService extends ConsoleLogger {
};
}
async fetchBlacklistSingle(
Search: string,
Since?: string,
): Promise<TwintData[]> {
async fetchBlacklistSingle(Since?: string): Promise<TwintData[]> {
try {
const { data } = await lastValueFrom(
this.http.post<TwintReturn>(
`${this.twintUrl}/Search`,
`${this.twintUrl}/Profile`,
{
Username: this.hamiUsername,
Search,
Since,
},
this.axiosConfig(),
......@@ -52,14 +48,9 @@ export class HamiFetcherService extends ConsoleLogger {
}
async fetchBlacklist(Since?: string): Promise<TwintData[]> {
const result = await this.fetchBlacklistSingle(Since);
return _.uniqBy(
_.flatten(
await Promise.all(
this.hamiBlacklistSearches.map((search) =>
this.fetchBlacklistSingle(search, Since),
),
),
),
result.filter((t) => t.tweet?.includes(this.hamiBlacklistSearch)),
(tweet) => tweet.id_str,
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment