@@ -8,7 +8,9 @@ pub const MAX_PROFILE_FOLLOWING: usize = 2048;
8
8
pub const MAX_PROFILE_BIO_SIZE : usize = 2048 ; // 2KB
9
9
pub const MAX_PROFILE_LINKS : usize = 100 ;
10
10
pub const MAX_PROFILE_TOKENS : usize = 100 ;
11
-
11
+ pub const MAX_PROFILE_CHANNEL_ALIAS_LEN : usize = 20 ;
12
+ pub const MAX_PROFILE_CHANNEL_TAGS_LEN : usize = 5 ;
13
+ pub const MAX_PROFILE_CHANNEL_TAG_LEN : usize = 20 ;
12
14
#[ derive( CandidType , Clone , Debug , Deserialize , Serialize ) ]
13
15
pub struct UserInfo {
14
16
pub id : Principal ,
@@ -57,6 +59,30 @@ impl UpdateProfileInput {
57
59
return Err ( format ! ( "bio size limit exceeded: {}" , bio. len( ) ) ) ;
58
60
}
59
61
}
62
+ // Check for conflicts in follow and unfollow
63
+ if !self . follow . is_disjoint ( & self . unfollow ) {
64
+ return Err ( "conflicting principals in follow and unfollow" . to_string ( ) ) ;
65
+ }
66
+
67
+ for ( channel, setting) in self . upsert_channels . iter ( ) {
68
+ if self . remove_channels . contains ( channel) {
69
+ return Err ( format ! (
70
+ "channel {:?} exists in both upsert and remove" ,
71
+ channel
72
+ ) ) ;
73
+ }
74
+ if setting. alias . len ( ) > MAX_PROFILE_CHANNEL_ALIAS_LEN {
75
+ return Err ( format ! ( "channel alias too long: {}" , setting. alias. len( ) ) ) ;
76
+ }
77
+ if setting. tags . len ( ) > MAX_PROFILE_CHANNEL_TAGS_LEN {
78
+ return Err ( format ! ( "too many tags: {}" , setting. tags. len( ) ) ) ;
79
+ }
80
+ for tag in & setting. tags {
81
+ if tag. len ( ) > MAX_PROFILE_CHANNEL_TAG_LEN {
82
+ return Err ( format ! ( "tag too long: {}" , tag. len( ) ) ) ;
83
+ }
84
+ }
85
+ }
60
86
Ok ( ( ) )
61
87
}
62
88
}
@@ -98,7 +124,7 @@ impl Link {
98
124
#[ derive( CandidType , Clone , Debug , Default , Deserialize , Serialize ) ]
99
125
pub struct UploadImageInput {
100
126
pub size : u64 , // should <= 256KB
101
- pub content_type : String , // image/webp or image/svg+xml
127
+ pub content_type : String , // " image/webp" | " image/png" | "image/jpeg" | "image/ svg+xml"
102
128
}
103
129
104
130
impl UploadImageInput {
0 commit comments