@@ -35,7 +35,9 @@ pub trait IdentityServiceApi: ServiceTraitBounds {
35
35
city_of_birth : Option < String > ,
36
36
identification_number : Option < String > ,
37
37
profile_picture_file_upload_id : Option < String > ,
38
+ ignore_profile_picture_file_upload_id : bool ,
38
39
identity_document_file_upload_id : Option < String > ,
40
+ ignore_identity_document_file_upload_id : bool ,
39
41
timestamp : u64 ,
40
42
) -> Result < ( ) > ;
41
43
/// Gets the full local identity, including the key pair and node id
@@ -198,7 +200,9 @@ impl IdentityServiceApi for IdentityService {
198
200
city_of_birth : Option < String > ,
199
201
identification_number : Option < String > ,
200
202
profile_picture_file_upload_id : Option < String > ,
203
+ ignore_profile_picture_file_upload_id : bool ,
201
204
identity_document_file_upload_id : Option < String > ,
205
+ ignore_identity_document_file_upload_id : bool ,
202
206
timestamp : u64 ,
203
207
) -> Result < ( ) > {
204
208
debug ! ( "updating identity" ) ;
@@ -279,37 +283,53 @@ impl IdentityServiceApi for IdentityService {
279
283
& mut changed,
280
284
) ;
281
285
282
- if !changed
283
- && profile_picture_file_upload_id. is_none ( )
286
+ // remove the profile picture
287
+ if !ignore_profile_picture_file_upload_id && profile_picture_file_upload_id. is_none ( ) {
288
+ identity. profile_picture_file = None ;
289
+ changed = true ;
290
+ }
291
+
292
+ // remove the identity document
293
+ if !ignore_identity_document_file_upload_id
284
294
&& identity_document_file_upload_id. is_none ( )
285
295
{
296
+ identity. identity_document_file = None ;
297
+ changed = true ;
298
+ }
299
+
300
+ if !changed {
286
301
return Ok ( ( ) ) ;
287
302
}
288
303
289
304
if let Some ( nostr_relay) = nostr_relays. first ( ) {
290
- profile_picture_file = self
291
- . process_upload_file (
292
- & profile_picture_file_upload_id,
293
- & identity. node_id ,
294
- & keys. pub_key ( ) ,
295
- nostr_relay,
296
- )
297
- . await ?;
298
- // only override the picture, if there is a new one
299
- if profile_picture_file. is_some ( ) {
300
- identity. profile_picture_file = profile_picture_file. clone ( ) ;
305
+ if !ignore_profile_picture_file_upload_id {
306
+ profile_picture_file = self
307
+ . process_upload_file (
308
+ & profile_picture_file_upload_id,
309
+ & identity. node_id ,
310
+ & keys. pub_key ( ) ,
311
+ nostr_relay,
312
+ )
313
+ . await ?;
314
+ // only override the picture, if there is a new one
315
+ if profile_picture_file. is_some ( ) {
316
+ identity. profile_picture_file = profile_picture_file. clone ( ) ;
317
+ }
301
318
}
302
- identity_document_file = self
303
- . process_upload_file (
304
- & identity_document_file_upload_id,
305
- & identity. node_id ,
306
- & keys. pub_key ( ) ,
307
- nostr_relay,
308
- )
309
- . await ?;
310
- // only override the document, if there is a new one
311
- if identity_document_file. is_some ( ) {
312
- identity. identity_document_file = identity_document_file. clone ( ) ;
319
+
320
+ if !ignore_identity_document_file_upload_id {
321
+ identity_document_file = self
322
+ . process_upload_file (
323
+ & identity_document_file_upload_id,
324
+ & identity. node_id ,
325
+ & keys. pub_key ( ) ,
326
+ nostr_relay,
327
+ )
328
+ . await ?;
329
+ // only override the document, if there is a new one
330
+ if identity_document_file. is_some ( ) {
331
+ identity. identity_document_file = identity_document_file. clone ( ) ;
332
+ }
313
333
}
314
334
} ;
315
335
}
@@ -939,7 +959,9 @@ mod tests {
939
959
None ,
940
960
None ,
941
961
None ,
962
+ true ,
942
963
None ,
964
+ true ,
943
965
1731593928 ,
944
966
)
945
967
. await ;
@@ -971,7 +993,9 @@ mod tests {
971
993
None ,
972
994
None ,
973
995
None ,
996
+ true ,
974
997
None ,
998
+ true ,
975
999
1731593928 ,
976
1000
)
977
1001
. await ;
@@ -1022,7 +1046,9 @@ mod tests {
1022
1046
None ,
1023
1047
None ,
1024
1048
None ,
1049
+ true ,
1025
1050
None ,
1051
+ true ,
1026
1052
1731593928 ,
1027
1053
)
1028
1054
. await ;
0 commit comments