[mastodon-client] Use ctx.cache for all endpoints

This commit is contained in:
Laura Hausmann 2023-10-07 02:12:26 +02:00
parent 937a8c76c8
commit c8415a5223
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 2 additions and 4 deletions

View file

@ -11,10 +11,9 @@ export function setupEndpointsNotifications(router: Router): void {
router.get("/v1/notifications",
auth(true, ['read:notifications']),
async (ctx) => {
const cache = UserHelpers.getFreshAccountCache();
const args = normalizeUrlQuery(convertPaginationArgsIds(limitToInt(ctx.query)), ['types[]', 'exclude_types[]']);
const res = await NotificationHelpers.getNotifications(ctx.user, args.max_id, args.since_id, args.min_id, args.limit, args['types[]'], args['exclude_types[]'], args.account_id);
const data = await NotificationConverter.encodeMany(res.data, ctx.user, cache);
const data = await NotificationConverter.encodeMany(res.data, ctx.user, ctx.cache);
ctx.body = data.map(n => convertNotificationIds(n));
ctx.pagination = res.pagination;

View file

@ -10,8 +10,7 @@ export function setupEndpointsSearch(router: Router): void {
auth(true, ['read:search']),
async (ctx) => {
const args = normalizeUrlQuery(convertPaginationArgsIds(argsToBools(limitToInt(ctx.query), ['resolve', 'following', 'exclude_unreviewed'])));
const cache = UserHelpers.getFreshAccountCache();
const result = await SearchHelpers.search(ctx.user, args.q, args.type, args.resolve, args.following, args.account_id, args['exclude_unreviewed'], args.max_id, args.min_id, args.limit, args.offset, cache);
const result = await SearchHelpers.search(ctx.user, args.q, args.type, args.resolve, args.following, args.account_id, args['exclude_unreviewed'], args.max_id, args.min_id, args.limit, args.offset, ctx.cache);
ctx.body = convertSearchIds(result);