@@ -23,7 +23,7 @@ use crate::{
2323 util,
2424} ;
2525use async_trait:: async_trait;
26- use log:: { error, info} ;
26+ use log:: { debug , error, info} ;
2727use std:: sync:: Arc ;
2828
2929#[ async_trait]
@@ -145,6 +145,7 @@ impl CompanyService {
145145 public_key : & str ,
146146 ) -> Result < Option < File > > {
147147 if let Some ( upload_id) = upload_id {
148+ debug ! ( "processing upload file for company {id}: {upload_id:?}" ) ;
148149 let ( file_name, file_bytes) = & self
149150 . file_upload_store
150151 . read_temp_upload_file ( upload_id)
@@ -218,6 +219,7 @@ impl CompanyServiceApi for CompanyService {
218219 logo_file_upload_id : Option < String > ,
219220 timestamp : u64 ,
220221 ) -> Result < Company > {
222+ debug ! ( "creating company" ) ;
221223 let keys = BcrKeys :: new ( ) ;
222224 let private_key = keys. get_private_key_string ( ) ;
223225 let public_key = keys. get_public_key ( ) ;
@@ -287,6 +289,7 @@ impl CompanyServiceApi for CompanyService {
287289 . add_block ( & id, create_company_block)
288290 . await ?;
289291 self . identity_blockchain_store . add_block ( & new_block) . await ?;
292+ debug ! ( "company with id {id} created" ) ;
290293
291294 // TODO NOSTR: create company topic and subscribe to it
292295 // TODO NOSTR: upload files to nostr
@@ -322,7 +325,9 @@ impl CompanyServiceApi for CompanyService {
322325 proof_of_registration_file_upload_id : Option < String > ,
323326 timestamp : u64 ,
324327 ) -> Result < ( ) > {
328+ debug ! ( "editing company with id: {id}" ) ;
325329 if !self . store . exists ( id) . await {
330+ debug ! ( "company with id {id} does not exist" ) ;
326331 return Err ( super :: Error :: NotFound ) ;
327332 }
328333 let full_identity = self . identity_store . get_full ( ) . await ?;
@@ -446,6 +451,7 @@ impl CompanyServiceApi for CompanyService {
446451 self . company_blockchain_store
447452 . add_block ( id, & new_block)
448453 . await ?;
454+ debug ! ( "company with id {id} updated" ) ;
449455
450456 if let Some ( upload_id) = logo_file_upload_id {
451457 if let Err ( e) = self
@@ -466,6 +472,10 @@ impl CompanyServiceApi for CompanyService {
466472 signatory_node_id : String ,
467473 timestamp : u64 ,
468474 ) -> Result < ( ) > {
475+ debug ! (
476+ "adding signatory {} to company with id: {id}" ,
477+ & signatory_node_id
478+ ) ;
469479 if !self . store . exists ( id) . await {
470480 return Err ( super :: Error :: Validation ( format ! (
471481 "No company with id: {id} found." ,
@@ -513,7 +523,7 @@ impl CompanyServiceApi for CompanyService {
513523 company_id : id. to_owned ( ) ,
514524 block_hash : new_block. hash . clone ( ) ,
515525 block_id : new_block. id ,
516- signatory : signatory_node_id,
526+ signatory : signatory_node_id. clone ( ) ,
517527 } ,
518528 & full_identity. key_pair ,
519529 timestamp,
@@ -524,6 +534,10 @@ impl CompanyServiceApi for CompanyService {
524534 self . identity_blockchain_store
525535 . add_block ( & new_identity_block)
526536 . await ?;
537+ debug ! (
538+ "added signatory {} to company with id: {id}" ,
539+ & signatory_node_id
540+ ) ;
527541
528542 // TODO NOSTR: propagate block to company topic
529543 // TODO NOSTR: propagate company and files to new signatory
@@ -537,6 +551,10 @@ impl CompanyServiceApi for CompanyService {
537551 signatory_node_id : String ,
538552 timestamp : u64 ,
539553 ) -> Result < ( ) > {
554+ debug ! (
555+ "removing signatory {} from company with id: {id}" ,
556+ & signatory_node_id
557+ ) ;
540558 if !self . store . exists ( id) . await {
541559 return Err ( super :: Error :: Validation ( format ! (
542560 "No company with id: {id} found." ,
@@ -607,6 +625,10 @@ impl CompanyServiceApi for CompanyService {
607625 error ! ( "Could not delete local company chain for {id}: {e}" ) ;
608626 }
609627 }
628+ debug ! (
629+ "removed signatory {} to company with id: {id}" ,
630+ & signatory_node_id
631+ ) ;
610632
611633 Ok ( ( ) )
612634 }
@@ -636,6 +658,7 @@ impl CompanyServiceApi for CompanyService {
636658 file_name : & str ,
637659 private_key : & str ,
638660 ) -> Result < Vec < u8 > > {
661+ debug ! ( "getting file {file_name} for company with id: {id}" , ) ;
639662 let read_file = self
640663 . file_upload_store
641664 . open_attached_file ( id, file_name)
0 commit comments