mirror of
https://github.com/jahruz67/wisp-open.git
synced 2026-08-08 18:14:08 +00:00
Refactor portalExtractIDs: simplify ID extraction logic and remove redundant handling for dbus.Struct
This commit is contained in:
@@ -400,8 +400,8 @@ func portalExtractIDs(bodyArg interface{}) []string {
|
||||
// Each element is a (id, state) struct serialized as []interface{}.
|
||||
var ids []string
|
||||
for _, tuple := range v {
|
||||
if arr, ok := tuple.([]interface{}); ok && len(arr) > 0 {
|
||||
if id, ok := unwrapVariant(arr[0]).(string); ok {
|
||||
if len(tuple) > 0 {
|
||||
if id, ok := unwrapVariant(tuple[0]).(string); ok {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
}
|
||||
@@ -420,15 +420,6 @@ func portalExtractIDs(bodyArg interface{}) []string {
|
||||
return []string{s}
|
||||
}
|
||||
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:
|
||||
return []string{v}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user