@@ -23,7 +23,7 @@ use crate::{
23
23
util,
24
24
} ;
25
25
use async_trait:: async_trait;
26
- use log:: { error, info} ;
26
+ use log:: { debug , error, info} ;
27
27
use std:: sync:: Arc ;
28
28
29
29
#[ async_trait]
@@ -145,6 +145,7 @@ impl CompanyService {
145
145
public_key : & str ,
146
146
) -> Result < Option < File > > {
147
147
if let Some ( upload_id) = upload_id {
148
+ debug ! ( "processing upload file for company {id}: {upload_id:?}" ) ;
148
149
let ( file_name, file_bytes) = & self
149
150
. file_upload_store
150
151
. read_temp_upload_file ( upload_id)
@@ -218,6 +219,7 @@ impl CompanyServiceApi for CompanyService {
218
219
logo_file_upload_id : Option < String > ,
219
220
timestamp : u64 ,
220
221
) -> Result < Company > {
222
+ debug ! ( "creating company" ) ;
221
223
let keys = BcrKeys :: new ( ) ;
222
224
let private_key = keys. get_private_key_string ( ) ;
223
225
let public_key = keys. get_public_key ( ) ;
@@ -287,6 +289,7 @@ impl CompanyServiceApi for CompanyService {
287
289
. add_block ( & id, create_company_block)
288
290
. await ?;
289
291
self . identity_blockchain_store . add_block ( & new_block) . await ?;
292
+ debug ! ( "company with id {id} created" ) ;
290
293
291
294
// TODO NOSTR: create company topic and subscribe to it
292
295
// TODO NOSTR: upload files to nostr
@@ -322,7 +325,9 @@ impl CompanyServiceApi for CompanyService {
322
325
proof_of_registration_file_upload_id : Option < String > ,
323
326
timestamp : u64 ,
324
327
) -> Result < ( ) > {
328
+ debug ! ( "editing company with id: {id}" ) ;
325
329
if !self . store . exists ( id) . await {
330
+ debug ! ( "company with id {id} does not exist" ) ;
326
331
return Err ( super :: Error :: NotFound ) ;
327
332
}
328
333
let full_identity = self . identity_store . get_full ( ) . await ?;
@@ -446,6 +451,7 @@ impl CompanyServiceApi for CompanyService {
446
451
self . company_blockchain_store
447
452
. add_block ( id, & new_block)
448
453
. await ?;
454
+ debug ! ( "company with id {id} updated" ) ;
449
455
450
456
if let Some ( upload_id) = logo_file_upload_id {
451
457
if let Err ( e) = self
@@ -466,6 +472,10 @@ impl CompanyServiceApi for CompanyService {
466
472
signatory_node_id : String ,
467
473
timestamp : u64 ,
468
474
) -> Result < ( ) > {
475
+ debug ! (
476
+ "adding signatory {} to company with id: {id}" ,
477
+ & signatory_node_id
478
+ ) ;
469
479
if !self . store . exists ( id) . await {
470
480
return Err ( super :: Error :: Validation ( format ! (
471
481
"No company with id: {id} found." ,
@@ -513,7 +523,7 @@ impl CompanyServiceApi for CompanyService {
513
523
company_id : id. to_owned ( ) ,
514
524
block_hash : new_block. hash . clone ( ) ,
515
525
block_id : new_block. id ,
516
- signatory : signatory_node_id,
526
+ signatory : signatory_node_id. clone ( ) ,
517
527
} ,
518
528
& full_identity. key_pair ,
519
529
timestamp,
@@ -524,6 +534,10 @@ impl CompanyServiceApi for CompanyService {
524
534
self . identity_blockchain_store
525
535
. add_block ( & new_identity_block)
526
536
. await ?;
537
+ debug ! (
538
+ "added signatory {} to company with id: {id}" ,
539
+ & signatory_node_id
540
+ ) ;
527
541
528
542
// TODO NOSTR: propagate block to company topic
529
543
// TODO NOSTR: propagate company and files to new signatory
@@ -537,6 +551,10 @@ impl CompanyServiceApi for CompanyService {
537
551
signatory_node_id : String ,
538
552
timestamp : u64 ,
539
553
) -> Result < ( ) > {
554
+ debug ! (
555
+ "removing signatory {} from company with id: {id}" ,
556
+ & signatory_node_id
557
+ ) ;
540
558
if !self . store . exists ( id) . await {
541
559
return Err ( super :: Error :: Validation ( format ! (
542
560
"No company with id: {id} found." ,
@@ -607,6 +625,10 @@ impl CompanyServiceApi for CompanyService {
607
625
error ! ( "Could not delete local company chain for {id}: {e}" ) ;
608
626
}
609
627
}
628
+ debug ! (
629
+ "removed signatory {} to company with id: {id}" ,
630
+ & signatory_node_id
631
+ ) ;
610
632
611
633
Ok ( ( ) )
612
634
}
@@ -636,6 +658,7 @@ impl CompanyServiceApi for CompanyService {
636
658
file_name : & str ,
637
659
private_key : & str ,
638
660
) -> Result < Vec < u8 > > {
661
+ debug ! ( "getting file {file_name} for company with id: {id}" , ) ;
639
662
let read_file = self
640
663
. file_upload_store
641
664
. open_attached_file ( id, file_name)
0 commit comments