1
1
use actix_web:: { get, post, put, delete, web, HttpResponse , Responder } ;
2
2
use fplus_database:: database;
3
- use fplus_lib:: core:: { allocator:: process_allocator_file, Allocator , AllocatorUpdateInfo , ChangedAllocator } ;
3
+ use fplus_lib:: core:: { allocator:: process_allocator_file, AllocatorUpdateInfo , ChangedAllocator } ;
4
4
5
5
/**
6
6
* Get all allocators
@@ -31,24 +31,24 @@ pub async fn allocators() -> impl Responder {
31
31
#[ post( "/allocator/create" ) ]
32
32
pub async fn create_from_json ( file : web:: Json < ChangedAllocator > ) -> actix_web:: Result < impl Responder > {
33
33
let file_name = & file. file_changed ;
34
- log:: info!( "File name : {}" , file_name) ;
34
+ log:: info!( "Starting allocator creation on : {}" , file_name) ;
35
35
36
36
match process_allocator_file ( file_name) . await {
37
37
Ok ( model) => {
38
- if model. address . is_empty ( ) {
38
+ if model. multisig_address . is_empty ( ) {
39
39
return Ok ( HttpResponse :: BadRequest ( ) . body ( "Missing or invalid multisig_address" ) ) ;
40
40
}
41
- let verifiers_gh_handles = if model. application . github_handles . is_empty ( ) {
41
+ let verifiers_gh_handles = if model. application . verifiers_gh_handles . is_empty ( ) {
42
42
None
43
43
} else {
44
- Some ( model. application . github_handles . join ( ", " ) ) // Join verifiers in a string if exists
44
+ Some ( model. application . verifiers_gh_handles . join ( ", " ) ) // Join verifiers in a string if exists
45
45
} ;
46
46
47
47
match database:: create_or_update_allocator (
48
- model. organization ,
49
- model. slug ,
50
- Some ( model. common_ui_install_id as i64 ) ,
51
- Some ( model. address ) ,
48
+ model. owner ,
49
+ model. repo ,
50
+ Some ( model. installation_id as i64 ) ,
51
+ Some ( model. multisig_address ) ,
52
52
verifiers_gh_handles,
53
53
) . await {
54
54
Ok ( allocator_model) => Ok ( HttpResponse :: Ok ( ) . json ( allocator_model) ) ,
@@ -60,39 +60,6 @@ pub async fn create_from_json(file: web::Json<ChangedAllocator>) -> actix_web::R
60
60
}
61
61
62
62
63
-
64
-
65
-
66
-
67
-
68
- /**
69
- * Create a new allocator
70
- *
71
- * # Arguments
72
- * @param info: web::Json<Allocator> - The allocator information
73
- *
74
- * # Returns
75
- * @return HttpResponse - The result of the operation
76
- */
77
- #[ post( "/allocator" ) ]
78
- pub async fn create_or_update ( info : web:: Json < Allocator > ) -> impl Responder {
79
- match database:: create_or_update_allocator (
80
- info. owner . clone ( ) ,
81
- info. repo . clone ( ) ,
82
- info. installation_id ,
83
- info. multisig_address . clone ( ) ,
84
- info. verifiers_gh_handles . clone ( ) ,
85
- ) . await {
86
- Ok ( allocator_model) => HttpResponse :: Ok ( ) . json ( allocator_model) ,
87
- Err ( e) => {
88
- if e. to_string ( ) . contains ( "Allocator already exists" ) {
89
- return HttpResponse :: BadRequest ( ) . body ( e. to_string ( ) ) ;
90
- }
91
- return HttpResponse :: InternalServerError ( ) . body ( e. to_string ( ) ) ;
92
- }
93
- }
94
- }
95
-
96
63
/**
97
64
* Update an allocator
98
65
*
0 commit comments