Add IRI to local resources (#1046)

* initial commit

* add remote trail/list

* fix errors

* update to use new IRIs

* use origin in migration instead

* use UnsafeWithoutHooks

* fix trail/list order of operations

* fix remote trail/list fetch

* fixes list document update

* fix errors

---------

Co-authored-by: Christian Beutel <>
This commit is contained in:
Flomp
2026-06-07 12:20:13 +02:00
committed by GitHub
parent f912a186a6
commit fc735130cc
19 changed files with 273 additions and 131 deletions

View File

@@ -1,6 +1,8 @@
package hooks
import (
"fmt"
"os"
"pocketbase/federation"
"pocketbase/util"
@@ -12,7 +14,23 @@ import (
func CreateCommentHandler() func(e *core.RecordRequestEvent) error {
return func(e *core.RecordRequestEvent) error {
e.Next()
err := e.Next()
if err != nil {
return err
}
// add local iri
origin := os.Getenv("ORIGIN")
if origin == "" {
return fmt.Errorf("ORIGIN not set")
}
if e.Record.GetString("iri") == "" {
e.Record.Set("iri", fmt.Sprintf("%s/api/v1/comment/%s", origin, e.Record.Id))
}
err = e.App.UnsafeWithoutHooks().Save(e.Record)
if err != nil {
return err
}
userActor, err := e.App.FindFirstRecordByData("activitypub_actors", "user", e.Auth.Id)
if err != nil {