Skip to content

Commit b16d144

Browse files
committed
Fix possible duplicates for signatories
1 parent be64b4f commit b16d144

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.5.0
2+
3+
* Stabilise Identity Proof Implementation
4+
15
# 0.4.13
26

37
* Document versioning scheme

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace.package]
2-
version = "0.4.13"
2+
version = "0.5.0"
33
edition = "2024"
44
license = "MIT"
55

crates/bcr-ebill-api/src/service/company_service.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -992,15 +992,28 @@ impl CompanyServiceApi for CompanyService {
992992
.into(),
993993
));
994994
}
995-
// Add signatory as invited
996-
company.signatories.push(CompanySignatory {
997-
node_id: signatory_node_id.clone(),
998-
t: SignatoryType::Solo,
999-
status: CompanySignatoryStatus::Invited {
995+
// If the signatory already exists - set to invited
996+
if let Some(signatory) = company
997+
.signatories
998+
.iter_mut()
999+
.find(|s| s.node_id == signatory_node_id)
1000+
{
1001+
signatory.status = CompanySignatoryStatus::Invited {
10001002
ts: timestamp,
10011003
inviter: full_identity.identity.node_id.clone(),
1002-
},
1003-
});
1004+
};
1005+
} else {
1006+
// Otherwise, add as invited
1007+
company.signatories.push(CompanySignatory {
1008+
node_id: signatory_node_id.clone(),
1009+
t: SignatoryType::Solo,
1010+
status: CompanySignatoryStatus::Invited {
1011+
ts: timestamp,
1012+
inviter: full_identity.identity.node_id.clone(),
1013+
},
1014+
});
1015+
}
1016+
10041017
self.store.update(id, &company).await?;
10051018

10061019
let mut company_chain = self.company_blockchain_store.get_chain(id).await?;

crates/bcr-ebill-core/src/application/company.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::protocol::{
55
};
66
use bcr_common::core::NodeId;
77

8+
use log::warn;
89
use serde::{Deserialize, Serialize};
910

1011
#[derive(Debug, Serialize, Deserialize, Clone)]
@@ -180,7 +181,13 @@ impl Company {
180181
inviter: payload.inviter.clone(),
181182
}
182183
}
183-
_ => (), // already invited / accepted - ignore,
184+
_ => {
185+
// already invited / accepted - ignore,
186+
warn!(
187+
"Trying to invite {}, although they're already invited/accepted",
188+
payload.invitee
189+
);
190+
}
184191
}
185192
} else {
186193
// if the signatory wasn't in the list before - add as invited

0 commit comments

Comments
 (0)