Feat add actors to meilisearch (#1048)

* initial commit

* update api docs

* adds search token versioning

* make id filterable

* isLocal -> is_local

* add iri to actor index

* update gitignore

* Merge remote-tracking branch 'origin/main' into feat-add-actors-to-meilisearch

* fix sharing for newly discovered actors

* fix ActorSearchResult type

---------

Co-authored-by: Christian Beutel <>
This commit is contained in:
Flomp
2026-06-09 21:02:05 +02:00
committed by GitHub
parent 1e2b4ea75d
commit c04a719ca6
45 changed files with 392 additions and 108 deletions

View File

@@ -0,0 +1,48 @@
package hooks
import (
"log"
"pocketbase/util"
"time"
"github.com/meilisearch/meilisearch-go"
"github.com/pocketbase/pocketbase/core"
)
func CreateActorHandler(client meilisearch.ServiceManager) func(e *core.RecordEvent) error {
return func(e *core.RecordEvent) error {
err := e.Next()
if err != nil {
return err
}
return util.IndexActors([]*core.Record{e.Record}, client)
}
}
func UpdateActorHandler(client meilisearch.ServiceManager) func(e *core.RecordEvent) error {
return func(e *core.RecordEvent) error {
err := e.Next()
if err != nil {
return err
}
return util.UpdateActor(e.Record, client)
}
}
func DeleteActorHandler(client meilisearch.ServiceManager) func(e *core.RecordEvent) error {
return func(e *core.RecordEvent) error {
task, err := client.Index("actors").DeleteDocument(e.Record.Id, nil)
if err != nil {
return err
}
interval := 500 * time.Millisecond
_, err = client.WaitForTask(task.TaskUID, interval)
if err != nil {
log.Fatalf("Error waiting for task completion: %v", err)
}
return e.Next()
}
}

View File

@@ -41,7 +41,7 @@ func CreateListHandler(client meilisearch.ServiceManager) func(e *core.RecordEve
return err
}
if !author.GetBool("isLocal") {
if !author.GetBool("is_local") {
// this happens if someone fetches a remote list
// we create a stub list record for later reference
// no need to create an activity for that
@@ -75,7 +75,7 @@ func UpdateListHandler(client meilisearch.ServiceManager) func(e *core.RecordEve
return err
}
if !author.GetBool("isLocal") {
if !author.GetBool("is_local") {
// this happens if someone fetches a remote list
// we create a stub list record for later reference
// no need to create an activity for that

View File

@@ -51,7 +51,7 @@ func CreateTrailLikeHandler(client meilisearch.ServiceManager) func(e *core.Reco
return err
}
if !actor.GetBool("isLocal") {
if !actor.GetBool("is_local") {
// this happens if someone likes a remote trail
// we create a local copy
// no need to create an activity for that
@@ -107,7 +107,7 @@ func DeleteTrailLikeHandler(client meilisearch.ServiceManager) func(e *core.Reco
return err
}
if !actor.GetBool("isLocal") {
if !actor.GetBool("is_local") {
// this happens if someone likes a remote trail
// we create a local copy
// no need to create an activity for that

View File

@@ -47,7 +47,7 @@ func CreateTrailHandler(client meilisearch.ServiceManager) func(e *core.RecordEv
return err
}
if !userActor.GetBool("isLocal") {
if !userActor.GetBool("is_local") {
// this happens if someone fetches a remote list
// we create a stub list record for later reference
// no need to create an activity for that
@@ -92,7 +92,7 @@ func UpdateTrailHandler(client meilisearch.ServiceManager) func(e *core.RecordEv
if err != nil {
return err
}
if !userActor.GetBool("isLocal") {
if !userActor.GetBool("is_local") {
// this happens if someone fetches a remote trail
// we create a stub trail record for later reference
// no need to create an activity for that