Check if Create object is Note to prevent panic
This commit is contained in:
parent
359be39430
commit
508a848616
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Reference in New Issue