Better error handling
This commit is contained in:
@ -6,7 +6,7 @@ import { Users } from '../../../../models';
|
||||
|
||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||
const id = typeof activity.actor == 'string' ? activity.actor : activity.actor.id;
|
||||
if (id == null) throw 'missing id';
|
||||
if (id == null) throw new Error('missing id');
|
||||
|
||||
if (!id.startsWith(config.url + '/')) {
|
||||
return;
|
||||
|
@ -9,7 +9,7 @@ const logger = apLogger;
|
||||
|
||||
export default async (actor: IRemoteUser, activity: IBlock): Promise<void> => {
|
||||
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
|
||||
if (id == null) throw 'missing id';
|
||||
if (id == null) throw new Error('missing id');
|
||||
|
||||
const uri = activity.id || activity;
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { Users } from '../../../models';
|
||||
|
||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
|
||||
if (id == null) throw 'missing id';
|
||||
if (id == null) throw new Error('missing id');
|
||||
|
||||
if (!id.startsWith(config.url + '/')) {
|
||||
return;
|
||||
|
@ -5,7 +5,7 @@ import { Notes } from '../../../models';
|
||||
|
||||
export default async (actor: IRemoteUser, activity: ILike) => {
|
||||
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
|
||||
if (id == null) throw 'missing id';
|
||||
if (id == null) throw new Error('missing id');
|
||||
|
||||
// Transform:
|
||||
// https://misskey.ex/notes/xxxx to
|
||||
|
@ -6,7 +6,7 @@ import { Users } from '../../../../models';
|
||||
|
||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||
const id = typeof activity.actor == 'string' ? activity.actor : activity.actor.id;
|
||||
if (id == null) throw 'missing id';
|
||||
if (id == null) throw new Error('missing id');
|
||||
|
||||
if (!id.startsWith(config.url + '/')) {
|
||||
return;
|
||||
|
@ -9,7 +9,7 @@ const logger = apLogger;
|
||||
|
||||
export default async (actor: IRemoteUser, activity: IBlock): Promise<void> => {
|
||||
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
|
||||
if (id == null) throw 'missing id';
|
||||
if (id == null) throw new Error('missing id');
|
||||
|
||||
const uri = activity.id || activity;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import { Users, FollowRequests, Followings } from '../../../../models';
|
||||
|
||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
|
||||
if (id == null) throw 'missing id';
|
||||
if (id == null) throw new Error('missing id');
|
||||
|
||||
if (!id.startsWith(config.url + '/')) {
|
||||
return;
|
||||
|
@ -8,13 +8,13 @@ import { Notes } from '../../../../models';
|
||||
*/
|
||||
export default async (actor: IRemoteUser, activity: ILike): Promise<void> => {
|
||||
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
|
||||
if (id == null) throw 'missing id';
|
||||
if (id == null) throw new Error('missing id');
|
||||
|
||||
const noteId = id.split('/').pop();
|
||||
|
||||
const note = await Notes.findOne(noteId);
|
||||
if (note == null) {
|
||||
throw 'note not found';
|
||||
throw new Error('note not found');
|
||||
}
|
||||
|
||||
await deleteReaction(actor, note);
|
||||
|
Reference in New Issue
Block a user