diff --git a/modules/activitypub/follow.go b/modules/activitypub/follow.go index 42d9022ce..174617149 100644 --- a/modules/activitypub/follow.go +++ b/modules/activitypub/follow.go @@ -5,8 +5,31 @@ package activitypub import ( + "github.com/go-fed/activity/streams" "github.com/go-fed/activity/streams/vocab" ) -func follow(activity vocab.ActivityStreamsActivity) { +func follow(activity vocab.ActivityStreamsFollow) { + objectIRI := activity.GetActivityStreamsObject().Begin().GetIRI() + // user_model.FollowUser() currently only works with local users + /*s := strings.Split(objectIRI.String(), ",") + user, _ := user_model.GetUserIDsByNames(s[len(s)-1]) + user_model.FollowUser()*/ + + // Send accept activity + accept := streams.NewActivityStreamsAccept() + + tp := streams.NewJSONLDTypeProperty() + tp.AppendXMLSchemaString("Accept") + accept.SetJSONLDType(tp) + + actor := streams.NewActivityStreamsActorProperty() + actor.AppendIRI(objectIRI) + accept.SetActivityStreamsActor(actor) + + object := streams.NewActivityStreamsObjectProperty() + object.AppendActivityStreamsFollow(activity) + accept.SetActivityStreamsObject(object) + + AddToOutbox(accept.(vocab.ActivityStreamsActivity)) } diff --git a/modules/activitypub/inbox.go b/modules/activitypub/inbox.go index 0dfdd2651..bc2160dcd 100644 --- a/modules/activitypub/inbox.go +++ b/modules/activitypub/inbox.go @@ -13,7 +13,8 @@ func AddToInbox(activity vocab.ActivityStreamsActivity) { databaseAddToInbox(activity) // Probably should use callbacks here + // https://github.com/owncast/owncast/blob/develop/activitypub/resolvers/resolve.go if activity.GetJSONLDType().Name() == "Follow" { - follow(activity) + follow(activity.(vocab.ActivityStreamsFollow)) } }