summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/mastodon/endpoints
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-03-22 18:18:54 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-03-27 19:51:43 -0400
commit3c5468086047a29cc56c90ab6547484364c22326 (patch)
treed2e619b5b744c02ffc7fd352d1d3d7d701d79722 /packages/backend/src/server/api/mastodon/endpoints
parentremove unused async from toMastoApiHtml / fromMastoApiHtml (diff)
downloadsharkey-3c5468086047a29cc56c90ab6547484364c22326.tar.gz
sharkey-3c5468086047a29cc56c90ab6547484364c22326.tar.bz2
sharkey-3c5468086047a29cc56c90ab6547484364c22326.zip
support reactions in mastodon API
Diffstat (limited to 'packages/backend/src/server/api/mastodon/endpoints')
-rw-r--r--packages/backend/src/server/api/mastodon/endpoints/notifications.ts23
1 files changed, 12 insertions, 11 deletions
diff --git a/packages/backend/src/server/api/mastodon/endpoints/notifications.ts b/packages/backend/src/server/api/mastodon/endpoints/notifications.ts
index 6acb9edd6b..120b9ba7f9 100644
--- a/packages/backend/src/server/api/mastodon/endpoints/notifications.ts
+++ b/packages/backend/src/server/api/mastodon/endpoints/notifications.ts
@@ -29,13 +29,17 @@ export class ApiNotificationsMastodon {
fastify.get<ApiNotifyMastodonRoute>('/v1/notifications', async (request, reply) => {
const { client, me } = await this.clientService.getAuthClient(request);
const data = await client.getNotifications(parseTimelineArgs(request.query));
- const response = await Promise.all(data.data.map(async n => {
- const converted = await this.mastoConverters.convertNotification(n, me);
- if (converted.type === 'reaction') {
- converted.type = 'favourite';
+ const notifications = await Promise.all(data.data.map(n => this.mastoConverters.convertNotification(n, me)));
+ const response: MastodonEntity.Notification[] = [];
+ for (const notification of notifications) {
+ response.push(notification);
+ if (notification.type === 'reaction') {
+ response.push({
+ ...notification,
+ type: 'favourite',
+ });
}
- return converted;
- }));
+ }
attachMinMaxPagination(request, reply, response);
reply.send(response);
@@ -46,12 +50,9 @@ export class ApiNotificationsMastodon {
const { client, me } = await this.clientService.getAuthClient(_request);
const data = await client.getNotification(_request.params.id);
- const converted = await this.mastoConverters.convertNotification(data.data, me);
- if (converted.type === 'reaction') {
- converted.type = 'favourite';
- }
+ const response = await this.mastoConverters.convertNotification(data.data, me);
- reply.send(converted);
+ reply.send(response);
});
fastify.post<ApiNotifyMastodonRoute & { Params: { id?: string } }>('/v1/notification/:id/dismiss', { preHandler: upload.single('none') }, async (_request, reply) => {