Make the local timeline correctly filter only local users
This commit is contained in:
parent
c37dd2c2b5
commit
b087d08306
|
@ -1,4 +1,6 @@
|
|||
import { z } from '@/deps.ts';
|
||||
import { getFeed, getPublicFeed } from '@/queries.ts';
|
||||
import { booleanParamSchema } from '@/schema.ts';
|
||||
import { toStatus } from '@/transformers/nostr-to-mastoapi.ts';
|
||||
import { buildLinkHeader, paginationSchema } from '@/utils.ts';
|
||||
|
||||
|
@ -19,10 +21,15 @@ const homeController: AppController = async (c) => {
|
|||
return c.json(statuses, 200, link ? { link } : undefined);
|
||||
};
|
||||
|
||||
const publicQuerySchema = z.object({
|
||||
local: booleanParamSchema.catch(false),
|
||||
});
|
||||
|
||||
const publicController: AppController = async (c) => {
|
||||
const params = paginationSchema.parse(c.req.query());
|
||||
const { local } = publicQuerySchema.parse(c.req.query());
|
||||
|
||||
const events = await getPublicFeed(params);
|
||||
const events = await getPublicFeed(params, local);
|
||||
if (!events.length) {
|
||||
return c.json([]);
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ async function getFeed(pubkey: string, params: PaginationParams): Promise<Event<
|
|||
}
|
||||
|
||||
/** Get a feed of all known text notes. */
|
||||
function getPublicFeed(params: PaginationParams): Promise<Event<1>[]> {
|
||||
return mixer.getFilters([{ kinds: [1], ...params }], { timeout: 5000 });
|
||||
function getPublicFeed(params: PaginationParams, local: boolean): Promise<Event<1>[]> {
|
||||
return mixer.getFilters([{ kinds: [1], local, ...params }], { timeout: 5000 });
|
||||
}
|
||||
|
||||
async function getAncestors(event: Event<1>, result = [] as Event<1>[]): Promise<Event<1>[]> {
|
||||
|
|
|
@ -42,4 +42,7 @@ const hashtagSchema = z.string().regex(/^\w{1,30}$/);
|
|||
*/
|
||||
const safeUrlSchema = z.string().max(2048).url();
|
||||
|
||||
export { decode64Schema, emojiTagSchema, filteredArray, hashtagSchema, jsonSchema, safeUrlSchema };
|
||||
/** https://github.com/colinhacks/zod/issues/1630#issuecomment-1365983831 */
|
||||
const booleanParamSchema = z.enum(['true', 'false']).transform((value) => value === 'true');
|
||||
|
||||
export { booleanParamSchema, decode64Schema, emojiTagSchema, filteredArray, hashtagSchema, jsonSchema, safeUrlSchema };
|
||||
|
|
Loading…
Reference in New Issue