aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-06-18 17:18:02 -0500
committerAnthony Wang2022-06-18 17:18:02 -0500
commit002a46fed3379adf97f976dd6d4e9023e8699497 (patch)
treef64f6839ac23b74ad7d3c4c851be65dc6971f0ff
parent10e15019aad0e81b3ec4a66954cc9d96f86ed37b (diff)
Move repo endpoints to /api/v1/activitypub/repofeature-go-ap-inbox-outbox
-rw-r--r--routers/api/v1/activitypub/person.go2
-rw-r--r--routers/api/v1/activitypub/repo.go8
-rw-r--r--routers/api/v1/api.go12
-rw-r--r--templates/swagger/v1_json.tmpl122
4 files changed, 85 insertions, 59 deletions
diff --git a/routers/api/v1/activitypub/person.go b/routers/api/v1/activitypub/person.go
index 4302fe60c..32d1c2a70 100644
--- a/routers/api/v1/activitypub/person.go
+++ b/routers/api/v1/activitypub/person.go
@@ -270,7 +270,7 @@ func PersonLiked(ctx *context.APIContext) {
liked.TotalItems = uint(count)
for _, repo := range repos {
- repo := forgefed.RepositoryNew(ap.IRI(strings.TrimSuffix(setting.AppURL, "/") + "/api/v1/activitypub/user/" + repo.OwnerName + "/" + repo.Name))
+ repo := forgefed.RepositoryNew(ap.IRI(strings.TrimSuffix(setting.AppURL, "/") + "/api/v1/activitypub/repo/" + repo.OwnerName + "/" + repo.Name))
liked.OrderedItems.Append(repo)
}
diff --git a/routers/api/v1/activitypub/repo.go b/routers/api/v1/activitypub/repo.go
index 8a780683d..a766c41ef 100644
--- a/routers/api/v1/activitypub/repo.go
+++ b/routers/api/v1/activitypub/repo.go
@@ -22,7 +22,7 @@ import (
// Repo function
func Repo(ctx *context.APIContext) {
- // swagger:operation GET /activitypub/user/{username}/{reponame} activitypub activitypubRepo
+ // swagger:operation GET /activitypub/repo/{username}/{reponame} activitypub activitypubRepo
// ---
// summary: Returns the repository
// produces:
@@ -71,7 +71,7 @@ func Repo(ctx *context.APIContext) {
// RepoInbox function
func RepoInbox(ctx *context.APIContext) {
- // swagger:operation POST /activitypub/user/{username}/{reponame}/inbox activitypub activitypubRepoInbox
+ // swagger:operation POST /activitypub/repo/{username}/{reponame}/inbox activitypub activitypubRepoInbox
// ---
// summary: Send to the inbox
// produces:
@@ -109,7 +109,7 @@ func RepoInbox(ctx *context.APIContext) {
// RepoOutbox function
func RepoOutbox(ctx *context.APIContext) {
- // swagger:operation GET /activitypub/user/{username}/outbox activitypub activitypubPersonOutbox
+ // swagger:operation GET /activitypub/repo/{username}/outbox activitypub activitypubPersonOutbox
// ---
// summary: Returns the outbox
// produces:
@@ -158,7 +158,7 @@ func RepoOutbox(ctx *context.APIContext) {
// RepoFollowers function
func RepoFollowers(ctx *context.APIContext) {
- // swagger:operation GET /activitypub/user/{username}/{reponame}/followers activitypub activitypubRepoFollowers
+ // swagger:operation GET /activitypub/repo/{username}/{reponame}/followers activitypub activitypubRepoFollowers
// ---
// summary: Returns the followers collection
// produces:
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 2e976e966..59d5cd231 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -652,13 +652,13 @@ func Routes() *web.Route {
m.Get("/following", activitypub.PersonFollowing)
m.Get("/followers", activitypub.PersonFollowers)
m.Get("/liked", activitypub.PersonLiked)
- m.Group("/{reponame}", func() {
- m.Get("", activitypub.Repo)
- m.Post("/inbox", activitypub.ReqHTTPSignature(), activitypub.RepoInbox)
- m.Get("/outbox", activitypub.RepoOutbox)
- m.Get("/followers", activitypub.RepoFollowers)
- }, repoAssignment())
}, context_service.UserAssignmentAPI())
+ m.Group("/repo/{username}/{reponame}", func() {
+ m.Get("", activitypub.Repo)
+ m.Post("/inbox", activitypub.ReqHTTPSignature(), activitypub.RepoInbox)
+ m.Get("/outbox", activitypub.RepoOutbox)
+ m.Get("/followers", activitypub.RepoFollowers)
+ }, repoAssignment())
})
}
m.Get("/signing-key.gpg", misc.SigningKey)
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index 23d700ded..6ad45012e 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -23,7 +23,7 @@
},
"basePath": "{{AppSubUrl | JSEscape | Safe}}/api/v1",
"paths": {
- "/activitypub/user/{username}": {
+ "/activitypub/repo/{username}/outbox": {
"get": {
"produces": [
"application/activity+json"
@@ -31,8 +31,8 @@
"tags": [
"activitypub"
],
- "summary": "Returns the Person actor for a user",
- "operationId": "activitypubPerson",
+ "summary": "Returns the outbox",
+ "operationId": "activitypubPersonOutbox",
"parameters": [
{
"type": "string",
@@ -40,6 +40,13 @@
"name": "username",
"in": "path",
"required": true
+ },
+ {
+ "type": "string",
+ "description": "name of the repository",
+ "name": "reponame",
+ "in": "path",
+ "required": true
}
],
"responses": {
@@ -49,7 +56,7 @@
}
}
},
- "/activitypub/user/{username}/followers": {
+ "/activitypub/repo/{username}/{reponame}": {
"get": {
"produces": [
"application/activity+json"
@@ -57,8 +64,8 @@
"tags": [
"activitypub"
],
- "summary": "Returns the Liked Collection",
- "operationId": "activitypubPersonLiked",
+ "summary": "Returns the repository",
+ "operationId": "activitypubRepo",
"parameters": [
{
"type": "string",
@@ -66,6 +73,13 @@
"name": "username",
"in": "path",
"required": true
+ },
+ {
+ "type": "string",
+ "description": "name of the repository",
+ "name": "reponame",
+ "in": "path",
+ "required": true
}
],
"responses": {
@@ -75,7 +89,7 @@
}
}
},
- "/activitypub/user/{username}/following": {
+ "/activitypub/repo/{username}/{reponame}/followers": {
"get": {
"produces": [
"application/activity+json"
@@ -83,8 +97,8 @@
"tags": [
"activitypub"
],
- "summary": "Returns the Following Collection",
- "operationId": "activitypubPersonFollowing",
+ "summary": "Returns the followers collection",
+ "operationId": "activitypubRepoFollowers",
"parameters": [
{
"type": "string",
@@ -92,6 +106,13 @@
"name": "username",
"in": "path",
"required": true
+ },
+ {
+ "type": "string",
+ "description": "name of the repository",
+ "name": "reponame",
+ "in": "path",
+ "required": true
}
],
"responses": {
@@ -101,7 +122,7 @@
}
}
},
- "/activitypub/user/{username}/inbox": {
+ "/activitypub/repo/{username}/{reponame}/inbox": {
"post": {
"produces": [
"application/activity+json"
@@ -110,7 +131,7 @@
"activitypub"
],
"summary": "Send to the inbox",
- "operationId": "activitypubPersonInbox",
+ "operationId": "activitypubRepoInbox",
"parameters": [
{
"type": "string",
@@ -118,6 +139,13 @@
"name": "username",
"in": "path",
"required": true
+ },
+ {
+ "type": "string",
+ "description": "name of the repository",
+ "name": "reponame",
+ "in": "path",
+ "required": true
}
],
"responses": {
@@ -127,7 +155,7 @@
}
}
},
- "/activitypub/user/{username}/outbox": {
+ "/activitypub/user/{username}": {
"get": {
"produces": [
"application/activity+json"
@@ -135,8 +163,8 @@
"tags": [
"activitypub"
],
- "summary": "Returns the outbox",
- "operationId": "activitypubPersonOutbox",
+ "summary": "Returns the Person actor for a user",
+ "operationId": "activitypubPerson",
"parameters": [
{
"type": "string",
@@ -144,13 +172,6 @@
"name": "username",
"in": "path",
"required": true
- },
- {
- "type": "string",
- "description": "name of the repository",
- "name": "reponame",
- "in": "path",
- "required": true
}
],
"responses": {
@@ -160,7 +181,7 @@
}
}
},
- "/activitypub/user/{username}/{reponame}": {
+ "/activitypub/user/{username}/followers": {
"get": {
"produces": [
"application/activity+json"
@@ -168,8 +189,8 @@
"tags": [
"activitypub"
],
- "summary": "Returns the repository",
- "operationId": "activitypubRepo",
+ "summary": "Returns the Liked Collection",
+ "operationId": "activitypubPersonLiked",
"parameters": [
{
"type": "string",
@@ -177,13 +198,6 @@
"name": "username",
"in": "path",
"required": true
- },
- {
- "type": "string",
- "description": "name of the repository",
- "name": "reponame",
- "in": "path",
- "required": true
}
],
"responses": {
@@ -193,7 +207,7 @@
}
}
},
- "/activitypub/user/{username}/{reponame}/followers": {
+ "/activitypub/user/{username}/following": {
"get": {
"produces": [
"application/activity+json"
@@ -201,8 +215,8 @@
"tags": [
"activitypub"
],
- "summary": "Returns the followers collection",
- "operationId": "activitypubRepoFollowers",
+ "summary": "Returns the Following Collection",
+ "operationId": "activitypubPersonFollowing",
"parameters": [
{
"type": "string",
@@ -210,13 +224,6 @@
"name": "username",
"in": "path",
"required": true
- },
- {
- "type": "string",
- "description": "name of the repository",
- "name": "reponame",
- "in": "path",
- "required": true
}
],
"responses": {
@@ -226,7 +233,7 @@
}
}
},
- "/activitypub/user/{username}/{reponame}/inbox": {
+ "/activitypub/user/{username}/inbox": {
"post": {
"produces": [
"application/activity+json"
@@ -235,7 +242,7 @@
"activitypub"
],
"summary": "Send to the inbox",
- "operationId": "activitypubRepoInbox",
+ "operationId": "activitypubPersonInbox",
"parameters": [
{
"type": "string",
@@ -243,18 +250,37 @@
"name": "username",
"in": "path",
"required": true
- },
+ }
+ ],
+ "responses": {
+ "204": {
+ "$ref": "#/responses/empty"
+ }
+ }
+ }
+ },
+ "/activitypub/user/{username}/outbox": {
+ "get": {
+ "produces": [
+ "application/activity+json"
+ ],
+ "tags": [
+ "activitypub"
+ ],
+ "summary": "Returns the Outbox OrderedCollection",
+ "operationId": "activitypubPersonOutbox",
+ "parameters": [
{
"type": "string",
- "description": "name of the repository",
- "name": "reponame",
+ "description": "username of the user",
+ "name": "username",
"in": "path",
"required": true
}
],
"responses": {
- "204": {
- "$ref": "#/responses/empty"
+ "200": {
+ "$ref": "#/responses/ActivityPub"
}
}
}