Refactor portalExtractIDs: simplify ID extraction logic and remove redundant handling for dbus.Struct

This commit is contained in:
John Doe
2026-07-14 16:09:05 -07:00
parent cf2f73cd98
commit 030982d355
+2 -11
View File
@@ -400,8 +400,8 @@ func portalExtractIDs(bodyArg interface{}) []string {
// Each element is a (id, state) struct serialized as []interface{}. // Each element is a (id, state) struct serialized as []interface{}.
var ids []string var ids []string
for _, tuple := range v { for _, tuple := range v {
if arr, ok := tuple.([]interface{}); ok && len(arr) > 0 { if len(tuple) > 0 {
if id, ok := unwrapVariant(arr[0]).(string); ok { if id, ok := unwrapVariant(tuple[0]).(string); ok {
ids = append(ids, id) ids = append(ids, id)
} }
} }
@@ -420,15 +420,6 @@ func portalExtractIDs(bodyArg interface{}) []string {
return []string{s} return []string{s}
} }
return nil return nil
case []dbus.Struct:
// golang.org/x/dbus may decode (su) as dbus.Struct.
var ids []string
for _, s := range v {
if id, ok := unwrapVariant(s).(string); ok {
ids = append(ids, id)
}
}
return ids
case string: case string:
return []string{v} return []string{v}
default: default: