mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Don't use fancy getPubkeysBySearch in regular search
This commit is contained in:
parent
a85daf1e67
commit
6eda1d4a9a
1 changed files with 1 additions and 14 deletions
|
|
@ -10,8 +10,6 @@ import { extractIdentifier, lookupPubkey } from '@/utils/lookup.ts';
|
||||||
import { nip05Cache } from '@/utils/nip05.ts';
|
import { nip05Cache } from '@/utils/nip05.ts';
|
||||||
import { accountFromPubkey, renderAccount } from '@/views/mastodon/accounts.ts';
|
import { accountFromPubkey, renderAccount } from '@/views/mastodon/accounts.ts';
|
||||||
import { renderStatus } from '@/views/mastodon/statuses.ts';
|
import { renderStatus } from '@/views/mastodon/statuses.ts';
|
||||||
import { getFollowedPubkeys } from '@/queries.ts';
|
|
||||||
import { getPubkeysBySearch } from '@/utils/search.ts';
|
|
||||||
import { paginated } from '@/utils/api.ts';
|
import { paginated } from '@/utils/api.ts';
|
||||||
|
|
||||||
const searchQuerySchema = z.object({
|
const searchQuerySchema = z.object({
|
||||||
|
|
@ -82,7 +80,7 @@ const searchController: AppController = async (c) => {
|
||||||
|
|
||||||
/** Get events for the search params. */
|
/** Get events for the search params. */
|
||||||
async function searchEvents(
|
async function searchEvents(
|
||||||
{ q, type, since, until, limit, offset, account_id, viewerPubkey }: SearchQuery & { viewerPubkey?: string },
|
{ q, type, since, until, limit, account_id }: SearchQuery & { viewerPubkey?: string },
|
||||||
signal: AbortSignal,
|
signal: AbortSignal,
|
||||||
): Promise<NostrEvent[]> {
|
): Promise<NostrEvent[]> {
|
||||||
// Hashtag search is not supported.
|
// Hashtag search is not supported.
|
||||||
|
|
@ -100,17 +98,6 @@ async function searchEvents(
|
||||||
limit,
|
limit,
|
||||||
};
|
};
|
||||||
|
|
||||||
const kysely = await Storages.kysely();
|
|
||||||
|
|
||||||
// For account search, use a special index, and prioritize followed accounts.
|
|
||||||
if (type === 'accounts') {
|
|
||||||
const following = viewerPubkey ? await getFollowedPubkeys(viewerPubkey) : new Set<string>();
|
|
||||||
const searchPubkeys = await getPubkeysBySearch(kysely, { q, limit, offset, following });
|
|
||||||
|
|
||||||
filter.authors = [...searchPubkeys];
|
|
||||||
filter.search = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Results should only be shown from one author.
|
// Results should only be shown from one author.
|
||||||
if (account_id) {
|
if (account_id) {
|
||||||
filter.authors = [account_id];
|
filter.authors = [account_id];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue