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,13 +131,15 @@ func PersonInbox(ctx *context.APIContext) {
// Unfollowing a user
err = unfollow(ctx, activity)
case ap.CreateType:
// TODO: this is kinda a hack
err = ap.OnObject(activity.Object, func(n *ap.Note) error {
noteIRI := n.InReplyTo.GetLink().String()
noteIRISplit := strings.Split(noteIRI, "/")
n.Context = ap.IRI(strings.TrimSuffix(noteIRI, "/"+noteIRISplit[len(noteIRISplit)-1]))
return createComment(ctx, n)
})
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()
noteIRISplit := strings.Split(noteIRI, "/")
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)

View File

@ -73,7 +73,7 @@ func StarRepo(ctx context.Context, userID, repoID int64, star bool) error {
}
for i := int64(0); i < count; i++ {
if followers[i].LoginType == auth.Federated {
create.To.Append(ap.IRI(followers[i].GetIRI()+"/inbox"))
create.To.Append(ap.IRI(followers[i].GetIRI() + "/inbox"))
}
}
return activitypub.Send(user, &create)