@@ -8,7 +8,9 @@ pub const MAX_PROFILE_FOLLOWING: usize = 2048;
88pub const MAX_PROFILE_BIO_SIZE : usize = 2048 ; // 2KB
99pub const MAX_PROFILE_LINKS : usize = 100 ;
1010pub 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 ;
1214#[ derive( CandidType , Clone , Debug , Deserialize , Serialize ) ]
1315pub struct UserInfo {
1416 pub id : Principal ,
@@ -57,6 +59,30 @@ impl UpdateProfileInput {
5759 return Err ( format ! ( "bio size limit exceeded: {}" , bio. len( ) ) ) ;
5860 }
5961 }
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+ }
6086 Ok ( ( ) )
6187 }
6288}
@@ -98,7 +124,7 @@ impl Link {
98124#[ derive( CandidType , Clone , Debug , Default , Deserialize , Serialize ) ]
99125pub struct UploadImageInput {
100126 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"
102128}
103129
104130impl UploadImageInput {
0 commit comments