1
1
// SPDX-FileCopyrightText: © 2022 Svix Authors
2
2
// SPDX-License-Identifier: MIT
3
3
4
+ use aide:: axum:: {
5
+ routing:: { delete_with, get_with, post_with} ,
6
+ ApiRouter ,
7
+ } ;
8
+ use axum:: {
9
+ extract:: { Path , State } ,
10
+ Json ,
11
+ } ;
12
+ use chrono:: { DateTime , Duration , Utc } ;
13
+ use futures:: FutureExt ;
14
+ use hyper:: StatusCode ;
15
+ use schemars:: JsonSchema ;
16
+ use sea_orm:: { entity:: prelude:: * , ActiveValue :: Set , IntoActiveModel , TransactionTrait } ;
17
+ use serde:: { Deserialize , Serialize } ;
18
+ use serde_json:: value:: RawValue ;
19
+ use svix_server_derive:: { aide_annotate, ModelIn , ModelOut } ;
20
+ use validator:: { Validate , ValidationError } ;
21
+
4
22
use crate :: {
5
23
core:: {
6
24
cache:: Cache ,
@@ -11,8 +29,8 @@ use crate::{
11
29
MessageAttemptTriggerType , MessageId , MessageUid ,
12
30
} ,
13
31
} ,
14
- db:: models:: { application, messagecontent} ,
15
- error:: { HttpError , Result } ,
32
+ db:: models:: { application, message , messagecontent} ,
33
+ error:: { Error , HttpError , Result } ,
16
34
queue:: { MessageTaskBatch , TaskQueueProducer } ,
17
35
v1:: utils:: {
18
36
apply_pagination_desc, iterator_from_before_or_after, openapi_tag, validation_error,
@@ -21,29 +39,6 @@ use crate::{
21
39
} ,
22
40
AppState ,
23
41
} ;
24
- use aide:: axum:: {
25
- routing:: { delete_with, get_with, post_with} ,
26
- ApiRouter ,
27
- } ;
28
- use axum:: {
29
- extract:: { Path , State } ,
30
- Json ,
31
- } ;
32
- use chrono:: { DateTime , Duration , Utc } ;
33
- use futures:: FutureExt ;
34
- use hyper:: StatusCode ;
35
- use schemars:: JsonSchema ;
36
- use sea_orm:: { entity:: prelude:: * , IntoActiveModel } ;
37
- use sea_orm:: { sea_query:: Expr , ActiveValue :: Set } ;
38
- use sea_orm:: { ActiveModelTrait , TransactionTrait } ;
39
- use serde:: { Deserialize , Serialize } ;
40
-
41
- use serde_json:: value:: RawValue ;
42
- use svix_server_derive:: { aide_annotate, ModelIn , ModelOut } ;
43
- use validator:: { Validate , ValidationError } ;
44
-
45
- use crate :: db:: models:: message;
46
- use crate :: error:: Error ;
47
42
48
43
pub fn validate_channels_msg ( channels : & EventChannelSet ) -> Result < ( ) , ValidationError > {
49
44
let len = channels. 0 . len ( ) ;
@@ -473,12 +468,13 @@ pub fn router() -> ApiRouter<AppState> {
473
468
474
469
#[ cfg( test) ]
475
470
mod tests {
471
+ use serde_json:: json;
472
+ use validator:: Validate ;
473
+
476
474
use super :: {
477
475
default_true, CreateMessageQueryParams , GetMessageQueryParams , ListMessagesQueryParams ,
478
476
MessageIn ,
479
477
} ;
480
- use serde_json:: json;
481
- use validator:: Validate ;
482
478
483
479
const CHANNEL_INVALID : & str = "$$invalid-channel" ;
484
480
const CHANNEL_VALID : & str = "valid-channel" ;
0 commit comments