Skip to content

Commit 7bbcdec

Browse files
authored
Remove email for anon identity and contact (#733)
1 parent 97871ec commit 7bbcdec

File tree

10 files changed

+11
-27
lines changed

10 files changed

+11
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Remove file-based `FileUpload` - we use surreal/nostr-based everywhere
1313
* Refactoring & Restructuring, removing cross-crate exports (breaking for Library dependents)
1414
* Properly separate `protocol` parts from `application` in `bcr-ebill-core` (breaking for Library dependents, breaking DB change)
15+
* Remove email from anon identities and contacts
1516

1617
# 0.4.12
1718

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,11 @@ impl BillService {
153153
.await,
154154
),
155155
BillParticipantBlockData::Anon(data) => {
156-
let (email, nostr_relays) = self
156+
let (_, nostr_relays) = self
157157
.get_email_and_nostr_relay(&data.node_id, ContactType::Anon, identity, contacts)
158158
.await;
159159
BillParticipant::Anon(BillAnonParticipant {
160160
node_id: data.node_id,
161-
email,
162161
nostr_relays,
163162
})
164163
}
@@ -685,7 +684,6 @@ impl BillService {
685684
};
686685
BillParticipant::Anon(BillAnonParticipant {
687686
node_id: mint_node_id.to_owned(),
688-
email: None,
689687
nostr_relays: relays,
690688
})
691689
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,8 @@ impl ContactServiceApi for ContactService {
337337

338338
let identity = self.identity_store.get_full().await?;
339339

340-
// for anonymous contact, we only consider email and name
341-
if contact.t == ContactType::Anon {
342-
util::update_optional_field(&mut contact.email, &email, &mut changed);
343-
} else {
340+
// for anonymous contact, we only consider name
341+
if contact.t != ContactType::Anon {
344342
if let Some(ref email_to_set) = email {
345343
contact.email = Some(email_to_set.clone());
346344
changed = true;
@@ -533,7 +531,7 @@ impl ContactServiceApi for ContactService {
533531
node_id: node_id.clone(),
534532
t: t.clone(),
535533
name,
536-
email,
534+
email: None,
537535
postal_address: None,
538536
date_of_birth_or_registration: None,
539537
country_of_birth_or_registration: None,
@@ -1146,6 +1144,8 @@ pub mod tests {
11461144
)
11471145
.await;
11481146
assert!(result.is_ok());
1147+
// email is not set, even if it's provided
1148+
assert!(result.as_ref().unwrap().email.is_none());
11491149
}
11501150

11511151
#[tokio::test]

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,8 @@ impl IdentityServiceApi for IdentityService {
278278
changed = true;
279279
}
280280

281-
// for anonymous identity, we only consider email and name
282-
if identity.t == IdentityType::Anon {
283-
util::update_optional_field(&mut identity.email, &email, &mut changed);
284-
} else {
281+
// for anonymous identity, we only consider name
282+
if identity.t == IdentityType::Ident {
285283
if let Some(ref email_to_set) = email
286284
&& identity.email.as_ref() != Some(email_to_set)
287285
{
@@ -488,7 +486,7 @@ impl IdentityServiceApi for IdentityService {
488486
t: t.clone(),
489487
node_id: node_id.clone(),
490488
name,
491-
email,
489+
email: None,
492490
postal_address: OptionalPostalAddress::empty(),
493491
date_of_birth: None,
494492
country_of_birth: None,

crates/bcr-ebill-core/src/application/contact/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ impl TryFrom<Contact> for BillParticipant {
189189
}
190190
ContactType::Anon => Ok(BillParticipant::Anon(BillAnonParticipant {
191191
node_id: value.node_id.clone(),
192-
email: value.email,
193192
nostr_relays: value.nostr_relays,
194193
})),
195194
}
@@ -232,7 +231,6 @@ impl BillAnonParticipant {
232231
pub fn new(identity: Identity) -> Self {
233232
Self {
234233
node_id: identity.node_id,
235-
email: identity.email,
236234
nostr_relays: identity.nostr_relays,
237235
}
238236
}

crates/bcr-ebill-core/src/protocol/blockchain/bill/participant.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl BillParticipant {
3939
pub fn email(&self) -> Option<Email> {
4040
match self {
4141
BillParticipant::Ident(data) => data.email.to_owned(),
42-
BillParticipant::Anon(data) => data.email.to_owned(),
42+
BillParticipant::Anon(_) => None,
4343
}
4444
}
4545

@@ -66,8 +66,6 @@ impl BillParticipant {
6666
pub struct BillAnonParticipant {
6767
/// The node id of the participant
6868
pub node_id: NodeId,
69-
/// email address of the participant
70-
pub email: Option<Email>,
7169
/// The preferred Nostr relay to deliver Nostr messages to
7270
pub nostr_relays: Vec<url::Url>,
7371
}
@@ -76,7 +74,6 @@ impl From<BillIdentParticipant> for BillAnonParticipant {
7674
fn from(value: BillIdentParticipant) -> Self {
7775
Self {
7876
node_id: value.node_id,
79-
email: value.email,
8077
nostr_relays: value.nostr_relays,
8178
}
8279
}
@@ -170,7 +167,6 @@ impl From<BillParticipantBlockData> for BillParticipant {
170167
}),
171168
BillParticipantBlockData::Anon(data) => Self::Anon(BillAnonParticipant {
172169
node_id: data.node_id,
173-
email: None,
174170
nostr_relays: vec![],
175171
}),
176172
}

crates/bcr-ebill-persistence/src/db/bill.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,6 @@ impl From<BillAnonParticipantDb> for BillAnonParticipant {
11491149
fn from(value: BillAnonParticipantDb) -> Self {
11501150
Self {
11511151
node_id: value.node_id,
1152-
email: None,
11531152
nostr_relays: vec![],
11541153
}
11551154
}

crates/bcr-ebill-transport/src/nostr_transport.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ impl NostrTransportService {
121121
// we have no contact but a nostr contact of a participant
122122
Some(BillParticipant::Anon(BillAnonParticipant {
123123
node_id: node_id.to_owned(),
124-
email: None,
125124
nostr_relays: nostr.relays,
126125
}))
127126
} else {
@@ -216,7 +215,6 @@ impl NostrTransportService {
216215
if let Some(transport) = self.get_node_transport(sender).await {
217216
let recipient = BillParticipant::Anon(BillAnonParticipant {
218217
node_id: recipient.to_owned(),
219-
email: None,
220218
nostr_relays: relays.to_vec(),
221219
});
222220
transport.send_private_event(&recipient, message).await?;

crates/bcr-ebill-wasm/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ async function start(create_identity) {
133133
fail_on_error(await identityApi.create({
134134
t: 1,
135135
name: "Cypherpunk",
136-
137136
postal_address: {},
138137
}));
139138

crates/bcr-ebill-wasm/src/data/bill.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -963,8 +963,6 @@ impl From<BillParticipant> for BillParticipantWeb {
963963
pub struct BillAnonParticipantWeb {
964964
#[tsify(type = "string")]
965965
pub node_id: NodeId,
966-
#[tsify(type = "string | undefined")]
967-
pub email: Option<Email>,
968966
#[tsify(type = "string[]")]
969967
pub nostr_relays: Vec<url::Url>,
970968
}
@@ -973,7 +971,6 @@ impl From<BillAnonParticipant> for BillAnonParticipantWeb {
973971
fn from(val: BillAnonParticipant) -> Self {
974972
BillAnonParticipantWeb {
975973
node_id: val.node_id,
976-
email: val.email,
977974
nostr_relays: val.nostr_relays,
978975
}
979976
}

0 commit comments

Comments
 (0)