1
1
use crate :: { BigNum , TargetingTag , ValidatorId , targeting:: Rule } ;
2
- use chrono:: serde:: { ts_milliseconds, ts_milliseconds_option} ;
3
2
use chrono:: { DateTime , Utc } ;
4
3
use serde:: { Deserialize , Serialize } ;
5
4
use std:: collections:: HashMap ;
@@ -22,16 +21,6 @@ pub struct AdSlot {
22
21
/// see IAB ad unit guidelines and iab_flex_{adUnitName} (see IAB's new ad portfolio and PDF)
23
22
#[ serde( rename = "type" ) ]
24
23
pub ad_type : String ,
25
- /// A URL to the resource (usually PNG)
26
- /// * must use the ipfs:// protocol, to guarantee data immutability
27
- pub media_url : String ,
28
- /// MIME type of the media.
29
- // Possible values at the moment are:
30
- /// * image/jpeg
31
- /// * image/png
32
- pub media_mime : String ,
33
- /// Advertised URL
34
- pub target_url : String ,
35
24
/// Array of TargetingTag
36
25
#[ serde( default ) ]
37
26
pub targeting : Vec < TargetingTag > ,
@@ -53,7 +42,7 @@ pub struct AdSlot {
53
42
/// User address from the session
54
43
pub owner : ValidatorId ,
55
44
/// UTC timestamp in milliseconds, used as nonce for escaping duplicated spec ipfs hashes
56
- #[ serde( with = "ts_milliseconds " ) ]
45
+ #[ serde( deserialize_with = "from_timestamp " ) ]
57
46
pub created : DateTime < Utc > ,
58
47
/// the name of the unit used in platform UI
59
48
#[ serde( default ) ]
@@ -67,6 +56,17 @@ pub struct AdSlot {
67
56
#[ serde( default ) ]
68
57
pub archived : bool ,
69
58
/// UTC timestamp in milliseconds, changed every time modifiable property is changed
70
- #[ serde( default , with = "ts_milliseconds_option " ) ]
59
+ #[ serde( deserialize_with = "from_timestamp_option " ) ]
71
60
pub modified : Option < DateTime < Utc > > ,
72
61
}
62
+
63
+ fn from_timestamp ( time : & String ) -> DateTime < Utc > {
64
+ DateTime :: parse_from_str ( time, "%Y-%m-%dT%H:%M:%S.%f" ) . unwrap ( )
65
+ }
66
+
67
+ fn from_timestamp_option ( time : & String ) -> Option < DateTime < Utc > > {
68
+ match DateTime :: parse_from_str ( time, "%Y-%m-%dT%H:%M:%S.%f" ) {
69
+ Ok ( t) => Some ( t) ,
70
+ Err ( _) => None ,
71
+ }
72
+ }
0 commit comments