Issue 527 - feat: update DeDi registry plugin to handle new response structure
This commit is contained in:
@@ -120,7 +120,7 @@ func (c *DeDiRegistryClient) Lookup(ctx context.Context, req *model.Subscription
|
||||
return nil, fmt.Errorf("failed to read response body: %w", err)
|
||||
}
|
||||
|
||||
// Parse response using local variables
|
||||
// Parse response
|
||||
var responseData map[string]interface{}
|
||||
err = json.Unmarshal(body, &responseData)
|
||||
if err != nil {
|
||||
@@ -129,56 +129,56 @@ func (c *DeDiRegistryClient) Lookup(ctx context.Context, req *model.Subscription
|
||||
|
||||
log.Debugf(ctx, "DeDi lookup request successful")
|
||||
|
||||
// Extract data using local variables
|
||||
// Extract data field
|
||||
data, ok := responseData["data"].(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid response format: missing data field")
|
||||
}
|
||||
|
||||
// Extract details field which contains the actual participant data
|
||||
// Extract details field
|
||||
details, ok := data["details"].(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid response format: missing details field")
|
||||
}
|
||||
|
||||
// Extract values from details field
|
||||
entityName, ok := details["entity_name"].(string)
|
||||
if !ok || entityName == "" {
|
||||
return nil, fmt.Errorf("invalid or missing entity_name in response")
|
||||
// Extract required fields from details
|
||||
keyID, _ := details["key_id"].(string)
|
||||
signingPublicKey, ok := details["signing_public_key"].(string)
|
||||
if !ok || signingPublicKey == "" {
|
||||
return nil, fmt.Errorf("invalid or missing signing_public_key in response")
|
||||
}
|
||||
|
||||
entityURL, ok := details["entity_url"].(string)
|
||||
if !ok || entityURL == "" {
|
||||
return nil, fmt.Errorf("invalid or missing entity_url in response")
|
||||
encrPublicKey, _ := details["encr_public_key"].(string)
|
||||
detailsStatus, ok := details["status"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("missing status in response")
|
||||
}
|
||||
detailsCreated, _ := details["created"].(string)
|
||||
detailsUpdated, _ := details["updated"].(string)
|
||||
validFromStr, _ := details["valid_from"].(string)
|
||||
validUntilStr, _ := details["valid_until"].(string)
|
||||
|
||||
publicKey, ok := details["publicKey"].(string)
|
||||
if !ok || publicKey == "" {
|
||||
return nil, fmt.Errorf("invalid or missing publicKey in response")
|
||||
}
|
||||
|
||||
// Extract record_name as the subscriber ID (fallback to entity_name)
|
||||
// Extract record_name as subscriber ID
|
||||
recordName, _ := data["record_name"].(string)
|
||||
if recordName == "" {
|
||||
recordName = entityName
|
||||
recordName = subscriberID
|
||||
}
|
||||
|
||||
state, _ := data["state"].(string)
|
||||
createdAt, _ := data["created_at"].(string)
|
||||
updatedAt, _ := data["updated_at"].(string)
|
||||
|
||||
// Convert to Subscription format
|
||||
subscription := model.Subscription{
|
||||
Subscriber: model.Subscriber{
|
||||
SubscriberID: recordName, // Use record_name as subscriber ID
|
||||
URL: entityURL,
|
||||
SubscriberID: recordName,
|
||||
URL: req.URL,
|
||||
Domain: req.Domain,
|
||||
Type: req.Type,
|
||||
},
|
||||
SigningPublicKey: publicKey,
|
||||
Status: state,
|
||||
Created: parseTime(createdAt),
|
||||
Updated: parseTime(updatedAt),
|
||||
KeyID: keyID,
|
||||
SigningPublicKey: signingPublicKey,
|
||||
EncrPublicKey: encrPublicKey,
|
||||
ValidFrom: parseTime(validFromStr),
|
||||
ValidUntil: parseTime(validUntilStr),
|
||||
Status: detailsStatus,
|
||||
Created: parseTime(detailsCreated),
|
||||
Updated: parseTime(detailsUpdated),
|
||||
}
|
||||
|
||||
return []model.Subscription{subscription}, nil
|
||||
|
||||
Reference in New Issue
Block a user