Check if Create object is Note to prevent panic

This commit is contained in:
Anthony Wang 2023-01-20 17:25:19 +00:00
parent 359be39430
commit 508a848616
No known key found for this signature in database
GPG Key ID: 42A5B952E6DD8D38
2 changed files with 10 additions and 8 deletions

View File

@ -131,6 +131,7 @@ func PersonInbox(ctx *context.APIContext) {
// Unfollowing a user
err = unfollow(ctx, activity)
case ap.CreateType:
if activity.Object.GetType() == ap.NoteType {
// TODO: this is kinda a hack
err = ap.OnObject(activity.Object, func(n *ap.Note) error {
noteIRI := n.InReplyTo.GetLink().String()
@ -138,6 +139,7 @@ func PersonInbox(ctx *context.APIContext) {
n.Context = ap.IRI(strings.TrimSuffix(noteIRI, "/"+noteIRISplit[len(noteIRISplit)-1]))
return createComment(ctx, n)
})
}
case ap.DeleteType:
// Deleting a user
err = delete(ctx, activity)