✨ User actor in activitypub
This commit is contained in:
parent
b151acd6ac
commit
673e7a69f5
@ -126,3 +126,24 @@ func apUserOutbox(c *fiber.Ctx) error {
|
||||
|
||||
return c.JSON(outbox)
|
||||
}
|
||||
|
||||
func apUserActor(c *fiber.Ctx) error {
|
||||
name := c.Params("name")
|
||||
|
||||
var publisher models.Publisher
|
||||
if err := database.C.Where("name = ?", name).First(&publisher).Error; err != nil {
|
||||
return c.Status(404).JSON(fiber.Map{"error": "User not found"})
|
||||
}
|
||||
|
||||
id := services.GetActivityID("/users/" + publisher.Name)
|
||||
actor := activitypub.Actor{
|
||||
ID: id,
|
||||
Inbox: id + "/inbox",
|
||||
Outbox: id + "/outbox",
|
||||
Type: activitypub.PersonType,
|
||||
Name: activitypub.DefaultNaturalLanguageValue(publisher.Name),
|
||||
PreferredUsername: activitypub.DefaultNaturalLanguageValue(publisher.Nick),
|
||||
}
|
||||
|
||||
return c.JSON(actor)
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ func MapAPIs(app *fiber.App, baseURL string) {
|
||||
{
|
||||
activitypub.Post("/users/:name/inbox", apUserInbox)
|
||||
activitypub.Get("/users/:name/outbox", apUserOutbox)
|
||||
activitypub.Get("/users/:name", apUserActor)
|
||||
}
|
||||
|
||||
publishers := api.Group("/publishers").Name("Publisher API")
|
||||
|
Loading…
x
Reference in New Issue
Block a user