mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-06 03:56:56 +00:00
add missing "return reply" calls to async fastify routes
Required, according to docs: https://fastify.dev/docs/latest/Reference/Routes/#async-await
This commit is contained in:
parent
9db39d449f
commit
2c5fb36e7f
10 changed files with 90 additions and 90 deletions
|
@ -56,7 +56,7 @@ export class MastodonApiServerService {
|
|||
this.logger.exception(request, exception);
|
||||
}
|
||||
|
||||
reply.code(status).send(data);
|
||||
return reply.code(status).send(data);
|
||||
});
|
||||
|
||||
// Log error responses (including converted JSON exceptions)
|
||||
|
@ -84,7 +84,7 @@ export class MastodonApiServerService {
|
|||
fastify.get('/v1/custom_emojis', async (_request, reply) => {
|
||||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.getInstanceCustomEmojis();
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
|
||||
fastify.get('/v1/announcements', async (_request, reply) => {
|
||||
|
@ -92,7 +92,7 @@ export class MastodonApiServerService {
|
|||
const data = await client.getInstanceAnnouncements();
|
||||
const response = data.data.map((announcement) => convertAnnouncement(announcement));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Body: { id?: string } }>('/v1/announcements/:id/dismiss', async (_request, reply) => {
|
||||
|
@ -101,7 +101,7 @@ export class MastodonApiServerService {
|
|||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.dismissInstanceAnnouncement(_request.body.id);
|
||||
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
|
||||
fastify.post('/v1/media', async (_request, reply) => {
|
||||
|
@ -114,7 +114,7 @@ export class MastodonApiServerService {
|
|||
const data = await client.uploadMedia(multipartData);
|
||||
const response = convertAttachment(data.data as Entity.Attachment);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Body: { description?: string; focus?: string } }>('/v2/media', async (_request, reply) => {
|
||||
|
@ -127,36 +127,36 @@ export class MastodonApiServerService {
|
|||
const data = await client.uploadMedia(multipartData, _request.body);
|
||||
const response = convertAttachment(data.data as Entity.Attachment);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get('/v1/trends', async (_request, reply) => {
|
||||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.getInstanceTrends();
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
|
||||
fastify.get('/v1/trends/tags', async (_request, reply) => {
|
||||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.getInstanceTrends();
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
|
||||
fastify.get('/v1/trends/links', async (_request, reply) => {
|
||||
// As we do not have any system for news/links this will just return empty
|
||||
reply.send([]);
|
||||
return reply.send([]);
|
||||
});
|
||||
|
||||
fastify.get('/v1/preferences', async (_request, reply) => {
|
||||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.getPreferences();
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
|
||||
fastify.get('/v1/followed_tags', async (_request, reply) => {
|
||||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.getFollowedTags();
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
|
||||
fastify.get<{ Querystring: TimelineArgs }>('/v1/bookmarks', async (_request, reply) => {
|
||||
|
@ -165,7 +165,7 @@ export class MastodonApiServerService {
|
|||
const data = await client.getBookmarks(parseTimelineArgs(_request.query));
|
||||
const response = await Promise.all(data.data.map((status) => this.mastoConverters.convertStatus(status, me)));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Querystring: TimelineArgs }>('/v1/favourites', async (_request, reply) => {
|
||||
|
@ -187,7 +187,7 @@ export class MastodonApiServerService {
|
|||
const data = await client.getFavourites(args);
|
||||
const response = await Promise.all(data.data.map((status) => this.mastoConverters.convertStatus(status, me)));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Querystring: TimelineArgs }>('/v1/mutes', async (_request, reply) => {
|
||||
|
@ -196,7 +196,7 @@ export class MastodonApiServerService {
|
|||
const data = await client.getMutes(parseTimelineArgs(_request.query));
|
||||
const response = await Promise.all(data.data.map((account) => this.mastoConverters.convertAccount(account)));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Querystring: TimelineArgs }>('/v1/blocks', async (_request, reply) => {
|
||||
|
@ -205,7 +205,7 @@ export class MastodonApiServerService {
|
|||
const data = await client.getBlocks(parseTimelineArgs(_request.query));
|
||||
const response = await Promise.all(data.data.map((account) => this.mastoConverters.convertAccount(account)));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Querystring: { limit?: string } }>('/v1/follow_requests', async (_request, reply) => {
|
||||
|
@ -215,7 +215,7 @@ export class MastodonApiServerService {
|
|||
const data = await client.getFollowRequests(limit);
|
||||
const response = await Promise.all(data.data.map((account) => this.mastoConverters.convertAccount(account as Entity.Account)));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string } }>('/v1/follow_requests/:id/authorize', async (_request, reply) => {
|
||||
|
@ -225,7 +225,7 @@ export class MastodonApiServerService {
|
|||
const data = await client.acceptFollowRequest(_request.params.id);
|
||||
const response = convertRelationship(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string } }>('/v1/follow_requests/:id/reject', async (_request, reply) => {
|
||||
|
@ -235,7 +235,7 @@ export class MastodonApiServerService {
|
|||
const data = await client.rejectFollowRequest(_request.params.id);
|
||||
const response = convertRelationship(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
//#endregion
|
||||
|
||||
|
@ -260,7 +260,7 @@ export class MastodonApiServerService {
|
|||
const data = await client.updateMedia(_request.params.id, options);
|
||||
const response = convertAttachment(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
done();
|
||||
|
|
|
@ -47,7 +47,7 @@ export class ApiAccountMastodon {
|
|||
language: '',
|
||||
},
|
||||
});
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.patch<{
|
||||
|
@ -128,7 +128,7 @@ export class ApiAccountMastodon {
|
|||
const data = await client.updateCredentials(options);
|
||||
const response = await this.mastoConverters.convertAccount(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Querystring: { acct?: string } }>('/v1/accounts/lookup', async (_request, reply) => {
|
||||
|
@ -140,7 +140,7 @@ export class ApiAccountMastodon {
|
|||
data.data.accounts[0].fields = profile?.fields.map(f => ({ ...f, verified_at: null })) ?? [];
|
||||
const response = await this.mastoConverters.convertAccount(data.data.accounts[0]);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<ApiAccountMastodonRoute & { Querystring: { id?: string | string[] } }>('/v1/accounts/relationships', async (_request, reply) => {
|
||||
|
@ -150,7 +150,7 @@ export class ApiAccountMastodon {
|
|||
const data = await client.getRelationships(_request.query.id);
|
||||
const response = data.data.map(relationship => convertRelationship(relationship));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string } }>('/v1/accounts/:id', async (_request, reply) => {
|
||||
|
@ -160,7 +160,7 @@ export class ApiAccountMastodon {
|
|||
const data = await client.getAccount(_request.params.id);
|
||||
const account = await this.mastoConverters.convertAccount(data.data);
|
||||
|
||||
reply.send(account);
|
||||
return reply.send(account);
|
||||
});
|
||||
|
||||
fastify.get<ApiAccountMastodonRoute & { Params: { id?: string } }>('/v1/accounts/:id/statuses', async (request, reply) => {
|
||||
|
@ -172,7 +172,7 @@ export class ApiAccountMastodon {
|
|||
const response = await Promise.all(data.data.map(async (status) => await this.mastoConverters.convertStatus(status, me)));
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string } }>('/v1/accounts/:id/featured_tags', async (_request, reply) => {
|
||||
|
@ -182,7 +182,7 @@ export class ApiAccountMastodon {
|
|||
const data = await client.getFeaturedTags();
|
||||
const response = data.data.map((tag) => convertFeaturedTag(tag));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<ApiAccountMastodonRoute & { Params: { id?: string } }>('/v1/accounts/:id/followers', async (request, reply) => {
|
||||
|
@ -196,7 +196,7 @@ export class ApiAccountMastodon {
|
|||
const response = await Promise.all(data.data.map(async (account) => await this.mastoConverters.convertAccount(account)));
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<ApiAccountMastodonRoute & { Params: { id?: string } }>('/v1/accounts/:id/following', async (request, reply) => {
|
||||
|
@ -210,7 +210,7 @@ export class ApiAccountMastodon {
|
|||
const response = await Promise.all(data.data.map(async (account) => await this.mastoConverters.convertAccount(account)));
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string } }>('/v1/accounts/:id/lists', async (_request, reply) => {
|
||||
|
@ -220,7 +220,7 @@ export class ApiAccountMastodon {
|
|||
const data = await client.getAccountLists(_request.params.id);
|
||||
const response = data.data.map((list) => convertList(list));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<ApiAccountMastodonRoute & { Params: { id?: string } }>('/v1/accounts/:id/follow', async (_request, reply) => {
|
||||
|
@ -231,7 +231,7 @@ export class ApiAccountMastodon {
|
|||
const acct = convertRelationship(data.data);
|
||||
acct.following = true; // TODO this is wrong, follow may not have processed immediately
|
||||
|
||||
reply.send(acct);
|
||||
return reply.send(acct);
|
||||
});
|
||||
|
||||
fastify.post<ApiAccountMastodonRoute & { Params: { id?: string } }>('/v1/accounts/:id/unfollow', async (_request, reply) => {
|
||||
|
@ -242,7 +242,7 @@ export class ApiAccountMastodon {
|
|||
const acct = convertRelationship(data.data);
|
||||
acct.following = false;
|
||||
|
||||
reply.send(acct);
|
||||
return reply.send(acct);
|
||||
});
|
||||
|
||||
fastify.post<ApiAccountMastodonRoute & { Params: { id?: string } }>('/v1/accounts/:id/block', async (_request, reply) => {
|
||||
|
@ -252,7 +252,7 @@ export class ApiAccountMastodon {
|
|||
const data = await client.blockAccount(_request.params.id);
|
||||
const response = convertRelationship(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<ApiAccountMastodonRoute & { Params: { id?: string } }>('/v1/accounts/:id/unblock', async (_request, reply) => {
|
||||
|
@ -275,7 +275,7 @@ export class ApiAccountMastodon {
|
|||
);
|
||||
const response = convertRelationship(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<ApiAccountMastodonRoute & { Params: { id?: string } }>('/v1/accounts/:id/unmute', async (_request, reply) => {
|
||||
|
@ -285,7 +285,7 @@ export class ApiAccountMastodon {
|
|||
const data = await client.unmuteAccount(_request.params.id);
|
||||
const response = convertRelationship(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ export class ApiAppsMastodon {
|
|||
client_secret: appData.clientSecret,
|
||||
};
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ export class ApiFilterMastodon {
|
|||
const data = await client.getFilters();
|
||||
const response = data.data.map((filter) => convertFilter(filter));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<ApiFilterMastodonRoute & { Params: { id?: string } }>('/v1/filters/:id', async (_request, reply) => {
|
||||
|
@ -45,7 +45,7 @@ export class ApiFilterMastodon {
|
|||
const data = await client.getFilter(_request.params.id);
|
||||
const response = convertFilter(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<ApiFilterMastodonRoute>('/v1/filters', async (_request, reply) => {
|
||||
|
@ -64,7 +64,7 @@ export class ApiFilterMastodon {
|
|||
const data = await client.createFilter(_request.body.phrase, _request.body.context, options);
|
||||
const response = convertFilter(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<ApiFilterMastodonRoute & { Params: { id?: string } }>('/v1/filters/:id', async (_request, reply) => {
|
||||
|
@ -84,7 +84,7 @@ export class ApiFilterMastodon {
|
|||
const data = await client.updateFilter(_request.params.id, _request.body.phrase, _request.body.context, options);
|
||||
const response = convertFilter(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.delete<ApiFilterMastodonRoute & { Params: { id?: string } }>('/v1/filters/:id', async (_request, reply) => {
|
||||
|
@ -93,7 +93,7 @@ export class ApiFilterMastodon {
|
|||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.deleteFilter(_request.params.id);
|
||||
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ export class ApiInstanceMastodon {
|
|||
rules: instance.rules ?? [],
|
||||
};
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ export class ApiNotificationsMastodon {
|
|||
}
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<ApiNotifyMastodonRoute & { Params: { id?: string } }>('/v1/notification/:id', async (_request, reply) => {
|
||||
|
@ -62,7 +62,7 @@ export class ApiNotificationsMastodon {
|
|||
});
|
||||
}
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<ApiNotifyMastodonRoute & { Params: { id?: string } }>('/v1/notification/:id/dismiss', async (_request, reply) => {
|
||||
|
@ -71,14 +71,14 @@ export class ApiNotificationsMastodon {
|
|||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.dismissNotification(_request.params.id);
|
||||
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
|
||||
fastify.post<ApiNotifyMastodonRoute>('/v1/notifications/clear', async (_request, reply) => {
|
||||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.dismissNotifications();
|
||||
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ export class ApiSearchMastodon {
|
|||
attachMinMaxPagination(request, reply, response[type]);
|
||||
}
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<ApiSearchMastodonRoute>('/v2/search', async (request, reply) => {
|
||||
|
@ -103,7 +103,7 @@ export class ApiSearchMastodon {
|
|||
// Offset pagination is the only possible option
|
||||
attachOffsetPagination(request, reply, longestResult);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<ApiSearchMastodonRoute>('/v1/trends/statuses', async (request, reply) => {
|
||||
|
@ -126,7 +126,7 @@ export class ApiSearchMastodon {
|
|||
const response = await Promise.all(data.map(status => this.mastoConverters.convertStatus(status, me)));
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<ApiSearchMastodonRoute>('/v2/suggestions', async (request, reply) => {
|
||||
|
@ -158,7 +158,7 @@ export class ApiSearchMastodon {
|
|||
}));
|
||||
|
||||
attachOffsetPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ export class ApiStatusMastodon {
|
|||
response.media_attachments = [];
|
||||
}
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string } }>('/v1/statuses/:id/source', async (_request, reply) => {
|
||||
|
@ -47,7 +47,7 @@ export class ApiStatusMastodon {
|
|||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.getStatusSource(_request.params.id);
|
||||
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string }, Querystring: TimelineArgs }>('/v1/statuses/:id/context', async (_request, reply) => {
|
||||
|
@ -59,7 +59,7 @@ export class ApiStatusMastodon {
|
|||
const descendants = await Promise.all(data.descendants.map(async (status: Entity.Status) => await this.mastoConverters.convertStatus(status, me)));
|
||||
const response = { ancestors, descendants };
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string } }>('/v1/statuses/:id/history', async (_request, reply) => {
|
||||
|
@ -68,7 +68,7 @@ export class ApiStatusMastodon {
|
|||
const user = await this.clientService.getAuth(_request);
|
||||
const edits = await this.mastoConverters.getEdits(_request.params.id, user);
|
||||
|
||||
reply.send(edits);
|
||||
return reply.send(edits);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string } }>('/v1/statuses/:id/reblogged_by', async (_request, reply) => {
|
||||
|
@ -78,7 +78,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.getStatusRebloggedBy(_request.params.id);
|
||||
const response = await Promise.all(data.data.map((account: Entity.Account) => this.mastoConverters.convertAccount(account)));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string } }>('/v1/statuses/:id/favourited_by', async (_request, reply) => {
|
||||
|
@ -88,7 +88,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.getStatusFavouritedBy(_request.params.id);
|
||||
const response = await Promise.all(data.data.map((account: Entity.Account) => this.mastoConverters.convertAccount(account)));
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string } }>('/v1/media/:id', async (_request, reply) => {
|
||||
|
@ -98,7 +98,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.getMedia(_request.params.id);
|
||||
const response = convertAttachment(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string } }>('/v1/polls/:id', async (_request, reply) => {
|
||||
|
@ -108,7 +108,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.getPoll(_request.params.id);
|
||||
const response = convertPoll(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string }, Body: { choices?: number[] } }>('/v1/polls/:id/votes', async (_request, reply) => {
|
||||
|
@ -119,7 +119,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.votePoll(_request.params.id, _request.body.choices);
|
||||
const response = convertPoll(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{
|
||||
|
@ -161,14 +161,14 @@ export class ApiStatusMastodon {
|
|||
body.in_reply_to_id,
|
||||
removed,
|
||||
);
|
||||
reply.send(a.data);
|
||||
return reply.send(a.data);
|
||||
}
|
||||
if (body.in_reply_to_id && removed === '/unreact') {
|
||||
const id = body.in_reply_to_id;
|
||||
const post = await client.getStatus(id);
|
||||
const react = post.data.emoji_reactions.filter((e: Entity.Emoji) => e.me)[0].name;
|
||||
const data = await client.deleteEmojiReaction(id, react);
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
}
|
||||
if (!body.media_ids) body.media_ids = undefined;
|
||||
if (body.media_ids && !body.media_ids.length) body.media_ids = undefined;
|
||||
|
@ -194,7 +194,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.postStatus(text, options);
|
||||
const response = await this.mastoConverters.convertStatus(data.data as Entity.Status, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.put<{
|
||||
|
@ -233,7 +233,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.editStatus(_request.params.id, options);
|
||||
const response = await this.mastoConverters.convertStatus(data.data, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string } }>('/v1/statuses/:id/favourite', async (_request, reply) => {
|
||||
|
@ -243,7 +243,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.createEmojiReaction(_request.params.id, '❤');
|
||||
const response = await this.mastoConverters.convertStatus(data.data, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string } }>('/v1/statuses/:id/unfavourite', async (_request, reply) => {
|
||||
|
@ -253,7 +253,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.deleteEmojiReaction(_request.params.id, '❤');
|
||||
const response = await this.mastoConverters.convertStatus(data.data, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string } }>('/v1/statuses/:id/reblog', async (_request, reply) => {
|
||||
|
@ -263,7 +263,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.reblogStatus(_request.params.id);
|
||||
const response = await this.mastoConverters.convertStatus(data.data, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string } }>('/v1/statuses/:id/unreblog', async (_request, reply) => {
|
||||
|
@ -273,7 +273,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.unreblogStatus(_request.params.id);
|
||||
const response = await this.mastoConverters.convertStatus(data.data, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string } }>('/v1/statuses/:id/bookmark', async (_request, reply) => {
|
||||
|
@ -283,7 +283,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.bookmarkStatus(_request.params.id);
|
||||
const response = await this.mastoConverters.convertStatus(data.data, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string } }>('/v1/statuses/:id/unbookmark', async (_request, reply) => {
|
||||
|
@ -293,7 +293,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.unbookmarkStatus(_request.params.id);
|
||||
const response = await this.mastoConverters.convertStatus(data.data, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
fastify.post<{ Params: { id?: string } }>('/v1/statuses/:id/pin', async (_request, reply) => {
|
||||
if (!_request.params.id) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required parameter "id"' });
|
||||
|
@ -302,7 +302,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.pinStatus(_request.params.id);
|
||||
const response = await this.mastoConverters.convertStatus(data.data, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string } }>('/v1/statuses/:id/unpin', async (_request, reply) => {
|
||||
|
@ -312,7 +312,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.unpinStatus(_request.params.id);
|
||||
const response = await this.mastoConverters.convertStatus(data.data, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string, name?: string } }>('/v1/statuses/:id/react/:name', async (_request, reply) => {
|
||||
|
@ -323,7 +323,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.createEmojiReaction(_request.params.id, _request.params.name);
|
||||
const response = await this.mastoConverters.convertStatus(data.data, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string, name?: string } }>('/v1/statuses/:id/unreact/:name', async (_request, reply) => {
|
||||
|
@ -334,7 +334,7 @@ export class ApiStatusMastodon {
|
|||
const data = await client.deleteEmojiReaction(_request.params.id, _request.params.name);
|
||||
const response = await this.mastoConverters.convertStatus(data.data, me);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.delete<{ Params: { id?: string } }>('/v1/statuses/:id', async (_request, reply) => {
|
||||
|
@ -343,7 +343,7 @@ export class ApiStatusMastodon {
|
|||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.deleteStatus(_request.params.id);
|
||||
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ export class ApiTimelineMastodon {
|
|||
const response = await Promise.all(data.data.map((status: Entity.Status) => this.mastoConverters.convertStatus(status, me)));
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Querystring: TimelineArgs }>('/v1/timelines/home', async (request, reply) => {
|
||||
|
@ -38,7 +38,7 @@ export class ApiTimelineMastodon {
|
|||
const response = await Promise.all(data.data.map((status: Entity.Status) => this.mastoConverters.convertStatus(status, me)));
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { hashtag?: string }, Querystring: TimelineArgs }>('/v1/timelines/tag/:hashtag', async (request, reply) => {
|
||||
|
@ -50,7 +50,7 @@ export class ApiTimelineMastodon {
|
|||
const response = await Promise.all(data.data.map((status: Entity.Status) => this.mastoConverters.convertStatus(status, me)));
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string }, Querystring: TimelineArgs }>('/v1/timelines/list/:id', async (request, reply) => {
|
||||
|
@ -62,7 +62,7 @@ export class ApiTimelineMastodon {
|
|||
const response = await Promise.all(data.data.map(async (status: Entity.Status) => await this.mastoConverters.convertStatus(status, me)));
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Querystring: TimelineArgs }>('/v1/conversations', async (request, reply) => {
|
||||
|
@ -72,7 +72,7 @@ export class ApiTimelineMastodon {
|
|||
const response = await Promise.all(data.data.map((conversation: Entity.Conversation) => this.mastoConverters.convertConversation(conversation, me)));
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string } }>('/v1/lists/:id', async (_request, reply) => {
|
||||
|
@ -82,7 +82,7 @@ export class ApiTimelineMastodon {
|
|||
const data = await client.getList(_request.params.id);
|
||||
const response = convertList(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get('/v1/lists', async (request, reply) => {
|
||||
|
@ -91,7 +91,7 @@ export class ApiTimelineMastodon {
|
|||
const response = data.data.map((list: Entity.List) => convertList(list));
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string }, Querystring: TimelineArgs }>('/v1/lists/:id/accounts', async (request, reply) => {
|
||||
|
@ -102,7 +102,7 @@ export class ApiTimelineMastodon {
|
|||
const response = await Promise.all(data.data.map((account: Entity.Account) => this.mastoConverters.convertAccount(account)));
|
||||
|
||||
attachMinMaxPagination(request, reply, response);
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.post<{ Params: { id?: string }, Querystring: { accounts_id?: string[] } }>('/v1/lists/:id/accounts', async (_request, reply) => {
|
||||
|
@ -112,7 +112,7 @@ export class ApiTimelineMastodon {
|
|||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.addAccountsToList(_request.params.id, _request.query.accounts_id);
|
||||
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
|
||||
fastify.delete<{ Params: { id?: string }, Querystring: { accounts_id?: string[] } }>('/v1/lists/:id/accounts', async (_request, reply) => {
|
||||
|
@ -122,7 +122,7 @@ export class ApiTimelineMastodon {
|
|||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.deleteAccountsFromList(_request.params.id, _request.query.accounts_id);
|
||||
|
||||
reply.send(data.data);
|
||||
return reply.send(data.data);
|
||||
});
|
||||
|
||||
fastify.post<{ Body: { title?: string } }>('/v1/lists', async (_request, reply) => {
|
||||
|
@ -132,7 +132,7 @@ export class ApiTimelineMastodon {
|
|||
const data = await client.createList(_request.body.title);
|
||||
const response = convertList(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.put<{ Params: { id?: string }, Body: { title?: string } }>('/v1/lists/:id', async (_request, reply) => {
|
||||
|
@ -143,7 +143,7 @@ export class ApiTimelineMastodon {
|
|||
const data = await client.updateList(_request.params.id, _request.body.title);
|
||||
const response = convertList(data.data);
|
||||
|
||||
reply.send(response);
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.delete<{ Params: { id?: string } }>('/v1/lists/:id', async (_request, reply) => {
|
||||
|
@ -152,7 +152,7 @@ export class ApiTimelineMastodon {
|
|||
const client = this.clientService.getClient(_request);
|
||||
await client.deleteList(_request.params.id);
|
||||
|
||||
reply.send({});
|
||||
return reply.send({});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ export class OAuth2ProviderService {
|
|||
if (request.query.state) redirectUri.searchParams.set('state', String(request.query.state));
|
||||
if (request.query.redirect_uri) redirectUri.searchParams.set('redirect_uri', String(request.query.redirect_uri));
|
||||
|
||||
reply.redirect(redirectUri.toString());
|
||||
return reply.redirect(redirectUri.toString());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ export class OAuth2ProviderService {
|
|||
scope: 'read',
|
||||
created_at: Math.floor(new Date().getTime() / 1000),
|
||||
};
|
||||
reply.send(ret);
|
||||
return reply.send(ret);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -140,10 +140,10 @@ export class OAuth2ProviderService {
|
|||
scope: body.scope || 'read write follow push',
|
||||
created_at: Math.floor(new Date().getTime() / 1000),
|
||||
};
|
||||
reply.send(ret);
|
||||
return reply.send(ret);
|
||||
} catch (e: unknown) {
|
||||
const data = getErrorData(e);
|
||||
reply.code(401).send(data);
|
||||
return reply.code(401).send(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue