mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-04-26 03:24:31 +02:00
- Massive replacement of changing `code.gitea.io/gitea` to `forgejo.org`. - Resolves forgejo/discussions#258 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7337 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Reviewed-by: Beowulf <beowulf@beocode.eu> Reviewed-by: Panagiotis "Ivory" Vasilopoulos <git@n0toose.net> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
35 lines
861 B
Go
35 lines
861 B
Go
// Copyright 2023 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package activitypub
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"forgejo.org/modules/activitypub"
|
|
"forgejo.org/modules/forgefed"
|
|
"forgejo.org/modules/log"
|
|
"forgejo.org/services/context"
|
|
|
|
ap "github.com/go-ap/activitypub"
|
|
"github.com/go-ap/jsonld"
|
|
)
|
|
|
|
// Respond with an ActivityStreams object
|
|
func response(ctx *context.APIContext, v any) {
|
|
binary, err := jsonld.WithContext(
|
|
jsonld.IRI(ap.ActivityBaseURI),
|
|
jsonld.IRI(ap.SecurityContextURI),
|
|
jsonld.IRI(forgefed.ForgeFedNamespaceURI),
|
|
).Marshal(v)
|
|
if err != nil {
|
|
ctx.ServerError("Marshal", err)
|
|
return
|
|
}
|
|
|
|
ctx.Resp.Header().Add("Content-Type", activitypub.ActivityStreamsContentType)
|
|
ctx.Resp.WriteHeader(http.StatusOK)
|
|
if _, err = ctx.Resp.Write(binary); err != nil {
|
|
log.Error("write to resp err: %v", err)
|
|
}
|
|
}
|