diff options
author | Anthony Wang | 2022-04-13 22:09:01 -0500 |
---|---|---|
committer | Anthony Wang | 2022-04-13 22:09:01 -0500 |
commit | 443bfac04e8d852aead7762ec9795c25c07bd0eb (patch) | |
tree | 5d119d0a1d7d16ce14e8b84e945be8ffb8584561 | |
parent | 790ea2d6ba7b09878750eed92238f84f5426eafc (diff) |
Implement inbox
-rw-r--r-- | modules/activitypub/follow.go | 25 | ||||
-rw-r--r-- | modules/activitypub/inbox.go | 3 |
2 files changed, 26 insertions, 2 deletions
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)) } } |