Add API endpoints for inbox/outbox

This commit is contained in:
Anthony Wang 2022-04-06 09:05:42 -05:00
parent 7ea5e108a5
commit cb0a9de330
Signed by: a
GPG key ID: BC96B00AEC5F2D76
3 changed files with 152 additions and 8 deletions

View file

@ -94,8 +94,30 @@ func Person(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, jsonmap)
}
// PersonInbox function
func PersonInbox(ctx *context.APIContext) {
// PersonInboxGet function
func PersonInboxGet(ctx *context.APIContext) {
// swagger:operation GET /activitypub/user/{username}/outbox activitypub activitypubPersonInbox
// ---
// summary: Returns the inbox
// produces:
// - application/json
// parameters:
// - name: username
// in: path
// description: username of the user
// type: string
// required: true
// responses:
// responses:
// "200":
// "$ref": "#/responses/ActivityPub"
ctx.Status(http.StatusOK)
activitypub.GetUserActor().GetInbox(ctx, ctx.Resp, ctx.Req)
}
// PersonInboxPost function
func PersonInboxPost(ctx *context.APIContext) {
// swagger:operation POST /activitypub/user/{username}/inbox activitypub activitypubPersonInbox
// ---
// summary: Send to the inbox
@ -109,8 +131,53 @@ func PersonInbox(ctx *context.APIContext) {
// required: true
// responses:
// responses:
// "204":
// "$ref": "#/responses/empty"
// "200":
// "$ref": "#/responses/ActivityPub"
ctx.Status(http.StatusNoContent)
ctx.Status(http.StatusOK)
activitypub.GetUserActor().PostInbox(ctx, ctx.Resp, ctx.Req)
}
// PersonOutboxGet function
func PersonOutboxGet(ctx *context.APIContext) {
// swagger:operation GET /activitypub/user/{username}/outbox activitypub activitypubPersonOutbox
// ---
// summary: Returns the outbox
// produces:
// - application/json
// parameters:
// - name: username
// in: path
// description: username of the user
// type: string
// required: true
// responses:
// responses:
// "200":
// "$ref": "#/responses/ActivityPub"
ctx.Status(http.StatusOK)
activitypub.GetUserActor().GetOutbox(ctx, ctx.Resp, ctx.Req)
}
// PersonOutboxPost function
func PersonOutboxPost(ctx *context.APIContext) {
// swagger:operation POST /activitypub/user/{username}/outbox activitypub activitypubPersonOutbox
// ---
// summary: Send to the outbox
// produces:
// - application/json
// parameters:
// - name: username
// in: path
// description: username of the user
// type: string
// required: true
// responses:
// responses:
// "200":
// "$ref": "#/responses/ActivityPub"
ctx.Status(http.StatusOK)
activitypub.GetUserActor().PostOutbox(ctx, ctx.Resp, ctx.Req)
}

View file

@ -600,7 +600,10 @@ func Routes(sessioner func(http.Handler) http.Handler) *web.Route {
m.Get("/nodeinfo", misc.NodeInfo)
m.Group("/activitypub", func() {
m.Get("/user/{username}", activitypub.Person)
m.Post("/user/{username}/inbox", activitypub.ReqSignature(), activitypub.PersonInbox)
m.Get("/user/{username}/inbox", activitypub.ReqSignature(), activitypub.PersonInboxGet)
m.Post("/user/{username}/inbox", activitypub.ReqSignature(), activitypub.PersonInboxPost)
m.Get("/user/{username}/outbox", activitypub.ReqSignature(), activitypub.PersonOutboxGet)
m.Post("/user/{username}/outbox", activitypub.ReqSignature(), activitypub.PersonOutboxPost)
})
}
m.Get("/signing-key.gpg", misc.SigningKey)

View file

@ -50,6 +50,30 @@
}
},
"/activitypub/user/{username}/inbox": {
"get": {
"produces": [
"application/json"
],
"tags": [
"activitypub"
],
"summary": "Returns the inbox",
"operationId": "activitypubPersonInbox",
"parameters": [
{
"type": "string",
"description": "username of the user",
"name": "username",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"$ref": "#/responses/ActivityPub"
}
}
},
"post": {
"produces": [
"application/json"
@ -69,8 +93,58 @@
}
],
"responses": {
"204": {
"$ref": "#/responses/empty"
"200": {
"$ref": "#/responses/ActivityPub"
}
}
}
},
"/activitypub/user/{username}/outbox": {
"get": {
"produces": [
"application/json"
],
"tags": [
"activitypub"
],
"summary": "Returns the outbox",
"operationId": "activitypubPersonOutbox",
"parameters": [
{
"type": "string",
"description": "username of the user",
"name": "username",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"$ref": "#/responses/ActivityPub"
}
}
},
"post": {
"produces": [
"application/json"
],
"tags": [
"activitypub"
],
"summary": "Send to the outbox",
"operationId": "activitypubPersonOutbox",
"parameters": [
{
"type": "string",
"description": "username of the user",
"name": "username",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"$ref": "#/responses/ActivityPub"
}
}
}