aboutsummaryrefslogtreecommitdiff
path: root/internal/ingest/service.go
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-26 20:20:17 -0800
committerFuwn <[email protected]>2026-02-26 20:20:17 -0800
commite264ed8f36b26c5684ea653ad7299603ccffe02b (patch)
tree95bbb4ad51740d7bcc0d834bd1aaa587df22f233 /internal/ingest/service.go
parentfix: align PLC compatibility read endpoints with plc.directory schema (diff)
downloadplutia-test-e264ed8f36b26c5684ea653ad7299603ccffe02b.tar.xz
plutia-test-e264ed8f36b26c5684ea653ad7299603ccffe02b.zip
feat: Apply Iku formatting
Diffstat (limited to 'internal/ingest/service.go')
-rw-r--r--internal/ingest/service.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/ingest/service.go b/internal/ingest/service.go
index 6cb7512..a6f7cd7 100644
--- a/internal/ingest/service.go
+++ b/internal/ingest/service.go
@@ -1057,16 +1057,19 @@ func normalizePLCDataFromOperation(did string, op map[string]any, fallbackRotati
}
services := normalizeServices(op)
+
if len(services) > 0 {
data["services"] = services
}
verificationMethods := normalizeVerificationMethods(op)
+
if len(verificationMethods) > 0 {
data["verificationMethods"] = verificationMethods
}
rotationKeys := extractStringSlice(op["rotationKeys"])
+
if len(rotationKeys) == 0 {
if recovery, _ := op["recoveryKey"].(string); strings.TrimSpace(recovery) != "" {
rotationKeys = append(rotationKeys, recovery)
@@ -1100,11 +1103,13 @@ func normalizePLCDataFromDIDDocument(did string, doc map[string]any, fallbackRot
for _, rawVM := range rawVMList {
vm, ok := rawVM.(map[string]any)
+
if !ok {
continue
}
name := "atproto"
+
if id, _ := vm["id"].(string); id != "" {
if idx := strings.LastIndex(id, "#"); idx >= 0 && idx < len(id)-1 {
name = id[idx+1:]
@@ -1126,13 +1131,16 @@ func normalizePLCDataFromDIDDocument(did string, doc map[string]any, fallbackRot
for _, rawService := range rawServiceList {
service, ok := rawService.(map[string]any)
+
if !ok {
continue
}
name := "atproto_pds"
+
if id, _ := service["id"].(string); id != "" {
name = strings.TrimPrefix(id, "#")
+
if strings.TrimSpace(name) == "" {
name = "atproto_pds"
}
@@ -1140,6 +1148,7 @@ func normalizePLCDataFromDIDDocument(did string, doc map[string]any, fallbackRot
typ, _ := service["type"].(string)
endpoint, _ := service["serviceEndpoint"].(string)
+
if endpoint == "" {
endpoint, _ = service["endpoint"].(string)
}
@@ -1168,12 +1177,14 @@ func normalizeServices(op map[string]any) map[string]map[string]string {
if rawServices, ok := op["services"].(map[string]any); ok {
for name, rawEntry := range rawServices {
entry, ok := rawEntry.(map[string]any)
+
if !ok {
continue
}
typ, _ := entry["type"].(string)
endpoint, _ := entry["endpoint"].(string)
+
if endpoint == "" {
endpoint, _ = entry["serviceEndpoint"].(string)
}
@@ -1207,6 +1218,7 @@ func normalizeVerificationMethods(op map[string]any) map[string]string {
if rawVM, ok := op["verificationMethods"].(map[string]any); ok {
for name, rawValue := range rawVM {
value, _ := rawValue.(string)
+
if strings.TrimSpace(value) == "" {
continue
}
@@ -1228,6 +1240,7 @@ func normalizeVerificationMethods(op map[string]any) map[string]string {
func extractStringSlice(v any) []string {
raw, ok := v.([]any)
+
if !ok {
return nil
}
@@ -1236,6 +1249,7 @@ func extractStringSlice(v any) []string {
for _, item := range raw {
s, _ := item.(string)
+
if strings.TrimSpace(s) == "" {
continue
}
@@ -1256,6 +1270,7 @@ func dedupeStrings(input []string) []string {
for _, item := range input {
item = strings.TrimSpace(item)
+
if item == "" {
continue
}