Merge branch 'tag-timeline' into 'develop'
Add hashtag timeline See merge request soapbox-pub/ditto!25
This commit is contained in:
commit
b6da5a0339
|
@ -38,7 +38,7 @@ import {
|
||||||
statusController,
|
statusController,
|
||||||
} from './controllers/api/statuses.ts';
|
} from './controllers/api/statuses.ts';
|
||||||
import { streamingController } from './controllers/api/streaming.ts';
|
import { streamingController } from './controllers/api/streaming.ts';
|
||||||
import { homeController, publicController } from './controllers/api/timelines.ts';
|
import { hashtagTimelineController, homeController, publicController } from './controllers/api/timelines.ts';
|
||||||
import { trendingTagsController } from './controllers/api/trends.ts';
|
import { trendingTagsController } from './controllers/api/trends.ts';
|
||||||
import { indexController } from './controllers/site.ts';
|
import { indexController } from './controllers/site.ts';
|
||||||
import { hostMetaController } from './controllers/well-known/host-meta.ts';
|
import { hostMetaController } from './controllers/well-known/host-meta.ts';
|
||||||
|
@ -109,6 +109,7 @@ app.post('/api/v1/statuses', requirePubkey, createStatusController);
|
||||||
|
|
||||||
app.get('/api/v1/timelines/home', requirePubkey, homeController);
|
app.get('/api/v1/timelines/home', requirePubkey, homeController);
|
||||||
app.get('/api/v1/timelines/public', publicController);
|
app.get('/api/v1/timelines/public', publicController);
|
||||||
|
app.get('/api/v1/timelines/tag/:hashtag', hashtagTimelineController);
|
||||||
|
|
||||||
app.get('/api/v1/preferences', preferencesController);
|
app.get('/api/v1/preferences', preferencesController);
|
||||||
app.get('/api/v1/search', searchController);
|
app.get('/api/v1/search', searchController);
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { z } from '@/deps.ts';
|
import { z } from '@/deps.ts';
|
||||||
|
import * as mixer from '@/mixer.ts';
|
||||||
import { getFeed, getPublicFeed } from '@/queries.ts';
|
import { getFeed, getPublicFeed } from '@/queries.ts';
|
||||||
import { booleanParamSchema } from '@/schema.ts';
|
import { booleanParamSchema } from '@/schema.ts';
|
||||||
import { toStatus } from '@/transformers/nostr-to-mastoapi.ts';
|
import { toStatus } from '@/transformers/nostr-to-mastoapi.ts';
|
||||||
import { buildLinkHeader, paginationSchema } from '@/utils/web.ts';
|
import { buildLinkHeader, paginationSchema } from '@/utils/web.ts';
|
||||||
|
import { Time } from '@/utils.ts';
|
||||||
|
|
||||||
import type { AppController } from '@/app.ts';
|
import type { AppController } from '@/app.ts';
|
||||||
|
|
||||||
|
@ -40,4 +42,23 @@ const publicController: AppController = async (c) => {
|
||||||
return c.json(statuses, 200, link ? { link } : undefined);
|
return c.json(statuses, 200, link ? { link } : undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { homeController, publicController };
|
const hashtagTimelineController: AppController = async (c) => {
|
||||||
|
const hashtag = c.req.param('hashtag')!;
|
||||||
|
const params = paginationSchema.parse(c.req.query());
|
||||||
|
|
||||||
|
const events = await mixer.getFilters(
|
||||||
|
[{ kinds: [1], '#t': [hashtag], ...params }],
|
||||||
|
{ timeout: Time.seconds(3) },
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!events.length) {
|
||||||
|
return c.json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const statuses = (await Promise.all(events.map(toStatus))).filter(Boolean);
|
||||||
|
|
||||||
|
const link = buildLinkHeader(c.req.url, events);
|
||||||
|
return c.json(statuses, 200, link ? { link } : undefined);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { hashtagTimelineController, homeController, publicController };
|
||||||
|
|
Loading…
Reference in New Issue