accountStatusesController: support `tagged` query param
This commit is contained in:
parent
4bcf9c171c
commit
164e7259e0
|
@ -1,5 +1,5 @@
|
||||||
import { type AppController } from '@/app.ts';
|
import { type AppController } from '@/app.ts';
|
||||||
import { findReplyTag, z } from '@/deps.ts';
|
import { type Filter, findReplyTag, z } from '@/deps.ts';
|
||||||
import { getAuthor, getFilter, getFollows, publish } from '@/client.ts';
|
import { getAuthor, getFilter, getFollows, publish } from '@/client.ts';
|
||||||
import { parseMetaContent } from '@/schema.ts';
|
import { parseMetaContent } from '@/schema.ts';
|
||||||
import { signEvent } from '@/sign.ts';
|
import { signEvent } from '@/sign.ts';
|
||||||
|
@ -93,22 +93,26 @@ const accountStatusesQuerySchema = z.object({
|
||||||
pinned: booleanParamSchema.optional(),
|
pinned: booleanParamSchema.optional(),
|
||||||
limit: z.coerce.number().positive().transform((v) => Math.min(v, 40)).catch(20),
|
limit: z.coerce.number().positive().transform((v) => Math.min(v, 40)).catch(20),
|
||||||
exclude_replies: booleanParamSchema.optional(),
|
exclude_replies: booleanParamSchema.optional(),
|
||||||
|
tagged: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const accountStatusesController: AppController = async (c) => {
|
const accountStatusesController: AppController = async (c) => {
|
||||||
const pubkey = c.req.param('pubkey');
|
const pubkey = c.req.param('pubkey');
|
||||||
const { since, until } = paginationSchema.parse(c.req.query());
|
const { since, until } = paginationSchema.parse(c.req.query());
|
||||||
const { pinned, limit, exclude_replies } = accountStatusesQuerySchema.parse(c.req.query());
|
const { pinned, limit, exclude_replies, tagged } = accountStatusesQuerySchema.parse(c.req.query());
|
||||||
|
|
||||||
// Nostr doesn't support pinned statuses.
|
// Nostr doesn't support pinned statuses.
|
||||||
if (pinned) {
|
if (pinned) {
|
||||||
return c.json([]);
|
return c.json([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let events = await getFilter({ authors: [pubkey], kinds: [1], since, until, limit });
|
const filter: Filter<1> = { authors: [pubkey], kinds: [1], since, until, limit };
|
||||||
events.sort(eventDateComparator);
|
if (tagged) {
|
||||||
|
filter['#t'] = [tagged];
|
||||||
|
}
|
||||||
|
|
||||||
console.log({ exclude_replies });
|
let events = await getFilter(filter);
|
||||||
|
events.sort(eventDateComparator);
|
||||||
|
|
||||||
if (exclude_replies) {
|
if (exclude_replies) {
|
||||||
events = events.filter((event) => !findReplyTag(event));
|
events = events.filter((event) => !findReplyTag(event));
|
||||||
|
|
Loading…
Reference in New Issue