aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-06-18 16:30:30 -0500
committerAnthony Wang2022-06-18 16:30:30 -0500
commit4ffb6b64bc95e32027f6d59c182f3cb33416858e (patch)
treef24e72bd0ceabc0f5679c0219e17e08d9e2a3114
parent1bd8eb6ef731b3fb7bdb02fa0b2252636893b76b (diff)
Use ctx.ServerError and remove all remote interaction code from webfinger.go
-rw-r--r--FEDERATION.md25
-rw-r--r--go.work5
-rw-r--r--go.work.sum10
-rw-r--r--routers/api/v1/activitypub/person.go8
-rw-r--r--routers/web/webfinger.go1
5 files changed, 44 insertions, 5 deletions
diff --git a/FEDERATION.md b/FEDERATION.md
new file mode 100644
index 000000000..5622fdb4e
--- /dev/null
+++ b/FEDERATION.md
@@ -0,0 +1,25 @@
+# Federation
+
+Gitea is federated using [ActivityPub](https://www.w3.org/TR/activitypub/) and the [ForgeFed extension](https://forgefed.org/) so you can interact with users and repositories from other instances as if they were on your own instance. By using the standardized ActivityPub protocol, users on any fediverse software such as [Mastodon](https://joinmastodon.org/) can follow Gitea users, receive activity updates, and comment on issues.
+
+Currently, only S2S ActivityPub is supported.
+
+## Actors
+
+Following the ForgeFed specification, users (`Person` type), organizations (`Group` type), and repositories (`Repository` type) are the ActivityPub actors in Gitea.
+
+### Users
+
+Users are represented using the `Person` type and can be found at `/api/v1/activitypub/user/{username}`.
+
+### Organizations
+
+Organizations are represented using the `Group` type and can be found at `/api/v1/activitypub/user/{orgname}`.
+
+### Repositories
+
+Repositories are represented using the `Repository` type and can be found at `/api/v1/activitypub/repo/{username}/{reponame}`.
+
+## Changing your username, organization name, or repository name
+
+Do we want to support this? If so, Gitea will send out a `Move` activity.
diff --git a/go.work b/go.work
new file mode 100644
index 000000000..bf84738c0
--- /dev/null
+++ b/go.work
@@ -0,0 +1,5 @@
+go 1.18
+
+use .
+
+replace github.com/go-ap/activitypub => /home/ta180m/Code/activitypub
diff --git a/go.work.sum b/go.work.sum
new file mode 100644
index 000000000..27d33cf48
--- /dev/null
+++ b/go.work.sum
@@ -0,0 +1,10 @@
+github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
+github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
+github.com/go-ap/errors v0.0.0-20220615144307-e8bc4a40ae9f h1:kJhGo4NApJP0Lt9lkJnfmuTnRWVFbCynY0kiTxpPUR4=
+github.com/go-ap/errors v0.0.0-20220615144307-e8bc4a40ae9f/go.mod h1:KHkKFKZvc05lr79+RGoq/zG8YjWi3+FK60Bxd+mpCew=
+github.com/go-ap/jsonld v0.0.0-20220615144122-1d862b15410d h1:Z/oRXMlZHjvjIqDma1FrIGL3iE5YL7MUI0bwYEZ6qbA=
+github.com/go-ap/jsonld v0.0.0-20220615144122-1d862b15410d/go.mod h1:jyveZeGw5LaADntW+UEsMjl3IlIwk+DxlYNsbofQkGA=
+github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg=
+github.com/klauspost/cpuid v1.3.1 h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s=
+github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
+github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
diff --git a/routers/api/v1/activitypub/person.go b/routers/api/v1/activitypub/person.go
index 1cc5be8e1..7290f1cbd 100644
--- a/routers/api/v1/activitypub/person.go
+++ b/routers/api/v1/activitypub/person.go
@@ -40,14 +40,14 @@ func Person(ctx *context.APIContext) {
person.Name = ap.NaturalLanguageValuesNew()
err := person.Name.Set("en", ap.Content(ctx.ContextUser.FullName))
if err != nil {
- ctx.Error(http.StatusInternalServerError, "Set Name", err)
+ ctx.ServerError("Set Name", err)
return
}
person.PreferredUsername = ap.NaturalLanguageValuesNew()
err = person.PreferredUsername.Set("en", ap.Content(ctx.ContextUser.Name))
if err != nil {
- ctx.Error(http.StatusInternalServerError, "Set PreferredUsername", err)
+ ctx.ServerError("Set PreferredUsername", err)
return
}
@@ -67,14 +67,14 @@ func Person(ctx *context.APIContext) {
publicKeyPem, err := activitypub.GetPublicKey(ctx.ContextUser)
if err != nil {
- ctx.Error(http.StatusInternalServerError, "GetPublicKey", err)
+ ctx.ServerError("GetPublicKey", err)
return
}
person.PublicKey.PublicKeyPem = publicKeyPem
binary, err := jsonld.WithContext(jsonld.IRI(ap.ActivityBaseURI), jsonld.IRI(ap.SecurityContextURI)).Marshal(person)
if err != nil {
- ctx.Error(http.StatusInternalServerError, "MarshalJSON", err)
+ ctx.ServerError("MarshalJSON", err)
return
}
ctx.Resp.Header().Add("Content-Type", activitypub.ActivityStreamsContentType)
diff --git a/routers/web/webfinger.go b/routers/web/webfinger.go
index 49c538aaf..c4808fbfd 100644
--- a/routers/web/webfinger.go
+++ b/routers/web/webfinger.go
@@ -29,7 +29,6 @@ type webfingerLink struct {
Rel string `json:"rel,omitempty"`
Type string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
- Template string `json:"template,omitempty"`
Titles map[string]string `json:"titles,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty"`
}