From 0bb55ef84e0fc75bb7af8cad9f2d42f501173df7 Mon Sep 17 00:00:00 2001 From: Flomp Date: Mon, 11 May 2026 20:03:18 +0200 Subject: [PATCH] Fix comment author rule (#984) Co-authored-by: Christian Beutel <> --- db/migrations/1778490903_updated_comments.go | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 db/migrations/1778490903_updated_comments.go diff --git a/db/migrations/1778490903_updated_comments.go b/db/migrations/1778490903_updated_comments.go new file mode 100644 index 00000000..80c7dc02 --- /dev/null +++ b/db/migrations/1778490903_updated_comments.go @@ -0,0 +1,42 @@ +package migrations + +import ( + "encoding/json" + + "github.com/pocketbase/pocketbase/core" + m "github.com/pocketbase/pocketbase/migrations" +) + +func init() { + m.Register(func(app core.App) error { + collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk") + if err != nil { + return err + } + + // update collection data + if err := json.Unmarshal([]byte(`{ + "listRule": "((@request.auth.id != \"\" && trail.author.user = @request.auth.id) || trail.public = true) || author.user = @request.auth.id || trail.trail_share_via_trail.actor.user ?= @request.auth.id", + "viewRule": "((@request.auth.id != \"\" && trail.author.user = @request.auth.id) || trail.public = true) || author.user = @request.auth.id || trail.trail_share_via_trail.actor.user ?= @request.auth.id" + }`), &collection); err != nil { + return err + } + + return app.Save(collection) + }, func(app core.App) error { + collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk") + if err != nil { + return err + } + + // update collection data + if err := json.Unmarshal([]byte(`{ + "listRule": "((@request.auth.id != \"\" && trail.author.user = @request.auth.id) || trail.public = true) || author = @request.auth.id || trail.trail_share_via_trail.actor.user ?= @request.auth.id", + "viewRule": "((@request.auth.id != \"\" && trail.author.user = @request.auth.id) || trail.public = true) || author = @request.auth.id || trail.trail_share_via_trail.actor.user ?= @request.auth.id" + }`), &collection); err != nil { + return err + } + + return app.Save(collection) + }) +}