Federation Refactoring & Architecture Improvements (#930)
* initial commit * add lists * update permissions * fix waypoint create * needs_full_sync for activitypub trails * fixes build issues * fix list get * further CSRF protection * update API docs * adds rate limiter * fix tiptap mentions * a bit more cleanup of main.go * Fix migration order * fixes reviewed notes * require context for activitpub server calls * improve hashing for identifier * fix copy paste error * fix sync trail/list issues * fix summit log/comment duplicates * adaptions after trail merge * fix dockerignore --------- Co-authored-by: Christian Beutel <> Co-authored-by: slothful-vassal <89943360+slothful-vassal@users.noreply.github.com>
This commit is contained in:
47
db/services/trailmerge/integration_merge.go
Normal file
47
db/services/trailmerge/integration_merge.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package trailmerge
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/meilisearch/meilisearch-go"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
func TryAutoMergeImportedTrail(
|
||||
app core.App,
|
||||
client meilisearch.ServiceManager,
|
||||
ctx context.Context,
|
||||
actor *core.Record,
|
||||
sourceTrailID string,
|
||||
settings IntegrationAutoMergeSettings,
|
||||
) error {
|
||||
if actor == nil || sourceTrailID == "" || !settings.Enabled {
|
||||
return nil
|
||||
}
|
||||
|
||||
response, err := Suggest(app, actor.Id, SuggestRequest{
|
||||
Mode: SuggestModeAutoDiscovery,
|
||||
SourceTrailID: sourceTrailID,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
selectableCandidates := make([]SuggestCandidate, 0, len(response.Candidates))
|
||||
for _, candidate := range response.Candidates {
|
||||
if candidate.Selectable {
|
||||
selectableCandidates = append(selectableCandidates, candidate)
|
||||
}
|
||||
}
|
||||
|
||||
if len(selectableCandidates) != 1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
targetTrailID := selectableCandidates[0].TrailID
|
||||
if targetTrailID == "" || targetTrailID == sourceTrailID {
|
||||
return nil
|
||||
}
|
||||
|
||||
return Merge(app, client, ctx, actor, sourceTrailID, targetTrailID, DefaultIntegrationAutoMergeMergeSettings())
|
||||
}
|
||||
1608
db/services/trailmerge/service.go
Normal file
1608
db/services/trailmerge/service.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user