@@ -34,6 +34,7 @@ import (
34
34
"github.com/nuts-foundation/nuts-node/storage/orm"
35
35
"github.com/nuts-foundation/nuts-node/vdr/log"
36
36
"gorm.io/gorm"
37
+ "strings"
37
38
"time"
38
39
)
39
40
@@ -159,13 +160,18 @@ func (r *Manager) Create(ctx context.Context, options CreationOptions) ([]did.Do
159
160
}
160
161
161
162
docs := make ([]did.Document , 0 )
163
+ var dids []string
162
164
for _ , sqlDoc := range sqlDocs {
163
165
doc , err := sqlDoc .ToDIDDocument ()
164
166
if err != nil {
165
167
return nil , subject , err
166
168
}
167
169
docs = append (docs , doc )
170
+ dids = append (dids , sqlDoc .DID .ID )
168
171
}
172
+ log .Logger ().
173
+ WithField (core .LogFieldDIDSubject , subject ).
174
+ Infof ("Created new subject (DIDs: [%s])" , strings .Join (dids , ", " ))
169
175
return docs , subject , nil
170
176
}
171
177
@@ -241,7 +247,9 @@ func (r *Manager) CreateService(ctx context.Context, subject string, service did
241
247
if err != nil {
242
248
return nil , fmt .Errorf ("could not add service to DID Documents: %w" , err )
243
249
}
244
-
250
+ log .Logger ().
251
+ WithField (core .LogFieldDIDSubject , subject ).
252
+ Infof ("Created new service for subject (type: %s, id: %s)" , service .Type , service .ID )
245
253
return services , nil
246
254
}
247
255
@@ -297,6 +305,9 @@ func (r *Manager) DeleteService(ctx context.Context, subject string, serviceID s
297
305
if err != nil {
298
306
return fmt .Errorf ("could not delete service from DID Documents: %w" , err )
299
307
}
308
+ log .Logger ().
309
+ WithField (core .LogFieldDIDSubject , subject ).
310
+ Infof ("Deleted service for subject (id: %s)" , serviceID .String ())
300
311
return nil
301
312
}
302
313
@@ -334,14 +345,17 @@ func (r *Manager) UpdateService(ctx context.Context, subject string, serviceID s
334
345
if err != nil {
335
346
return nil , fmt .Errorf ("could not update service for DID Documents: %w" , err )
336
347
}
348
+ log .Logger ().
349
+ WithField (core .LogFieldDIDSubject , subject ).
350
+ Infof ("Updated service for subject (id: %s)" , serviceID .String ())
337
351
return services , nil
338
352
}
339
353
340
354
func (r * Manager ) AddVerificationMethod (ctx context.Context , subject string , keyUsage orm.DIDKeyFlags ) ([]did.VerificationMethod , error ) {
341
355
log .Logger ().Debug ("Creating new VerificationMethods." )
342
356
343
357
verificationMethods := make ([]did.VerificationMethod , 0 )
344
-
358
+ var vmIDs [] string
345
359
err := r .applyToDIDDocuments (ctx , subject , func (tx * gorm.DB , id did.DID , current * orm.DIDDocument ) (* orm.DIDDocument , error ) {
346
360
// known limitation
347
361
if keyUsage .Is (orm .KeyAgreementUsage ) && id .Method == "web" {
@@ -365,12 +379,16 @@ func (r *Manager) AddVerificationMethod(ctx context.Context, subject string, key
365
379
Data : data ,
366
380
}
367
381
current .VerificationMethods = append (current .VerificationMethods , sqlMethod )
382
+ vmIDs = append (vmIDs , vm .ID .String ())
368
383
return current , nil
369
384
})
370
385
371
386
if err != nil {
372
387
return nil , fmt .Errorf ("could not update DID documents: %w" , err )
373
388
}
389
+ log .Logger ().
390
+ WithField (core .LogFieldDIDSubject , subject ).
391
+ Infof ("Added verification method for subject (IDs: [%s])" , strings .Join (vmIDs , ", " ))
374
392
return verificationMethods , nil
375
393
}
376
394
0 commit comments