pubky-app-specs 0.4.3

Pubky.app Data Model Specifications
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
use crate::{
    common::sanitize_url,
    limits::VALIDATION_LIMITS,
    traits::{HasPath, Validatable},
    APP_PATH, PUBLIC_PATH,
};
use serde::{Deserialize, Serialize};
use url::Url;

#[cfg(target_arch = "wasm32")]
use crate::traits::Json;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;

#[cfg(feature = "openapi")]
use utoipa::ToSchema;

/// URI: /pub/pubky.app/profile.json
#[cfg_attr(target_arch = "wasm32", wasm_bindgen)]
#[derive(Deserialize, Serialize, Debug, Clone)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub struct PubkyAppUser {
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(skip))]
    // Avoid wasm-pack automatically generating getter/setters for the pub fields.
    pub name: String,
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(skip))]
    pub bio: Option<String>,
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(skip))]
    pub image: Option<String>,
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(skip))]
    pub links: Option<Vec<PubkyAppUserLink>>,
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(skip))]
    pub status: Option<String>,
}

impl Default for PubkyAppUser {
    fn default() -> Self {
        PubkyAppUser {
            name: "anonymous".to_string(),
            bio: None,
            image: None,
            links: None,
            status: None,
        }
        .sanitize()
    }
}

#[cfg(target_arch = "wasm32")]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen)]
impl PubkyAppUser {
    // Getters clone the data out because String/JsValue is not Copy.
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(getter))]
    pub fn name(&self) -> String {
        self.name.clone()
    }
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(getter))]
    pub fn bio(&self) -> Option<String> {
        self.bio.clone()
    }
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(getter))]
    pub fn image(&self) -> Option<String> {
        self.image.clone()
    }
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(getter))]
    pub fn links(&self) -> Option<Vec<PubkyAppUserLink>> {
        self.links.clone()
    }
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(getter))]
    pub fn status(&self) -> Option<String> {
        self.status.clone()
    }

    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = fromJson))]
    pub fn from_json(js_value: &JsValue) -> Result<Self, String> {
        Self::import_json(js_value)
    }

    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = toJson))]
    pub fn to_json(&self) -> Result<JsValue, String> {
        self.export_json()
    }
}

#[cfg(target_arch = "wasm32")]
impl Json for PubkyAppUser {}

/// Represents a user's single link with a title and URL.
#[cfg_attr(target_arch = "wasm32", wasm_bindgen)]
#[derive(Serialize, Deserialize, Default, Clone, Debug)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub struct PubkyAppUserLink {
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(skip))]
    pub title: String,
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(skip))]
    pub url: String,
}

#[cfg(target_arch = "wasm32")]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen)]
impl PubkyAppUserLink {
    // Getters clone the data out because String/JsValue is not Copy.
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(getter))]
    pub fn title(&self) -> String {
        self.title.clone()
    }
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(getter))]
    pub fn url(&self) -> String {
        self.url.clone()
    }
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen)]
impl PubkyAppUser {
    /// Creates a new `PubkyAppUser` instance and sanitizes it.
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(constructor))]
    pub fn new(
        name: String,
        bio: Option<String>,
        image: Option<String>,
        links: Option<Vec<PubkyAppUserLink>>,
        status: Option<String>,
    ) -> Self {
        Self {
            name,
            bio,
            image,
            links,
            status,
        }
        .sanitize()
    }
}

impl HasPath for PubkyAppUser {
    const PATH_SEGMENT: &'static str = "profile.json";

    fn create_path() -> String {
        [PUBLIC_PATH, APP_PATH, Self::PATH_SEGMENT].concat()
    }
}

impl Validatable for PubkyAppUser {
    fn sanitize(self) -> Self {
        // Sanitize name: trim whitespace only
        let mut name = self.name.trim().to_string();

        // We use username keyword `[DELETED]` for a user whose `profile.json` has been deleted
        // Therefore this is not a valid username.
        if name == *"[DELETED]" {
            name = "anonymous".to_string(); // default username
        }

        // Sanitize bio: trim whitespace only
        let bio = self.bio.map(|b| b.trim().to_string());

        // Sanitize image URL
        let image = self.image.map(|i| sanitize_url(&i));

        // Sanitize status: trim whitespace only
        let status = self.status.map(|s| s.trim().to_string());

        // Sanitize links: sanitize each link, validation handles format
        let links = self
            .links
            .map(|links_vec| links_vec.into_iter().map(|link| link.sanitize()).collect());

        PubkyAppUser {
            name,
            bio,
            image,
            links,
            status,
        }
    }

    fn validate(&self, _id: Option<&str>) -> Result<(), String> {
        // Validate name length
        let name_length = self.name.chars().count();
        if !(VALIDATION_LIMITS.user_name_min_length..=VALIDATION_LIMITS.user_name_max_length)
            .contains(&name_length)
        {
            return Err("Validation Error: Invalid name length".into());
        }

        // Validate bio length
        if let Some(bio) = &self.bio {
            if bio.chars().count() > VALIDATION_LIMITS.user_bio_max_length {
                return Err("Validation Error: Bio exceeds maximum length".into());
            }
        }

        // Validate image URL format and length
        if let Some(image) = &self.image {
            if image.is_empty() {
                return Err("Validation Error: Image URI cannot be empty".into());
            }
            if image.chars().count() > VALIDATION_LIMITS.user_image_url_max_length {
                return Err("Validation Error: Image URI exceeds maximum length".into());
            }
            // Validate URL format
            Url::parse(image)
                .map_err(|_| "Validation Error: Invalid image URI format".to_string())?;
        }

        // Validate links
        if let Some(links) = &self.links {
            if links.len() > VALIDATION_LIMITS.user_links_max_count {
                return Err("Validation Error: Too many links".into());
            }

            for link in links {
                link.validate(None)?;
            }
        }

        // Validate status length
        if let Some(status) = &self.status {
            if status.chars().count() > VALIDATION_LIMITS.user_status_max_length {
                return Err("Validation Error: Status exceeds maximum length".into());
            }
        }

        Ok(())
    }
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen)]
impl PubkyAppUserLink {
    /// Creates a new `PubkyAppUserLink` instance and sanitizes it.
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen(constructor))]
    pub fn new(title: String, url: String) -> Self {
        Self { title, url }.sanitize()
    }
}

impl Validatable for PubkyAppUserLink {
    fn sanitize(self) -> Self {
        // Sanitize title: trim whitespace only
        let title = self.title.trim().to_string();

        // Sanitize URL
        let url = sanitize_url(&self.url);

        PubkyAppUserLink { title, url }
    }

    fn validate(&self, _id: Option<&str>) -> Result<(), String> {
        // Validate title
        if self.title.trim().is_empty() {
            return Err("Validation Error: Link title cannot be empty".into());
        }
        if self.title.chars().count() > VALIDATION_LIMITS.user_link_title_max_length {
            return Err("Validation Error: Link title exceeds maximum length".into());
        }

        // Validate URL
        if self.url.trim().is_empty() {
            return Err("Validation Error: Link URL cannot be empty".into());
        }
        if self.url.chars().count() > VALIDATION_LIMITS.user_link_url_max_length {
            return Err("Validation Error: Link URL exceeds maximum length".into());
        }

        // Validate URL format
        Url::parse(&self.url).map_err(|_| "Validation Error: Invalid URL format".to_string())?;

        Ok(())
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::traits::Validatable;
    use crate::{APP_PATH, PUBLIC_PATH};

    #[test]
    fn test_new() {
        let user = PubkyAppUser::new(
            "Alice".to_string(),
            Some("Maximalist".to_string()),
            Some("https://example.com/image.png".to_string()),
            Some(vec![
                PubkyAppUserLink {
                    title: "GitHub".to_string(),
                    url: "https://github.com/alice".to_string(),
                },
                PubkyAppUserLink {
                    title: "Website".to_string(),
                    url: "https://alice.dev".to_string(),
                },
            ]),
            Some("Exploring the decentralized web.".to_string()),
        );

        assert_eq!(user.name, "Alice");
        assert_eq!(user.bio.as_deref(), Some("Maximalist"));
        assert_eq!(user.image.as_deref(), Some("https://example.com/image.png"));
        assert_eq!(
            user.status.as_deref(),
            Some("Exploring the decentralized web.")
        );
        assert!(user.links.is_some());
        assert_eq!(user.links.as_ref().unwrap().len(), 2);
    }

    #[test]
    fn test_create_path() {
        let path = PubkyAppUser::create_path();
        assert_eq!(path, format!("{}{}profile.json", PUBLIC_PATH, APP_PATH));
    }

    #[test]
    fn test_sanitize() {
        let user = PubkyAppUser::new(
            "   Alice   ".to_string(),
            Some("  Maximalist and developer.  ".to_string()),
            Some("  https://example.com/image.png  ".to_string()),
            Some(vec![
                PubkyAppUserLink {
                    title: " GitHub ".to_string(),
                    url: " https://github.com/alice ".to_string(),
                },
                PubkyAppUserLink {
                    title: "Website".to_string(),
                    url: "  https://example.com  ".to_string(),
                },
            ]),
            Some("  Exploring the decentralized web.  ".to_string()),
        );

        assert_eq!(user.name, "Alice");
        assert_eq!(user.bio.as_deref(), Some("Maximalist and developer."));
        // Image URL should be trimmed
        assert_eq!(user.image.as_deref(), Some("https://example.com/image.png"));
        assert_eq!(
            user.status.as_deref(),
            Some("Exploring the decentralized web.")
        );
        assert!(user.links.is_some());
        let links = user.links.unwrap();
        assert_eq!(links.len(), 2); // All links preserved, just trimmed
        assert_eq!(links[0].title, "GitHub");
        assert_eq!(links[0].url, "https://github.com/alice"); // Trimmed and normalized
        assert_eq!(links[1].title, "Website");
        assert_eq!(links[1].url, "https://example.com/"); // Trimmed and normalized
    }

    #[test]
    fn test_validate() {
        let user = PubkyAppUser::new(
            "Alice".to_string(),
            Some("Maximalist".to_string()),
            Some("https://example.com/image.png".to_string()),
            None,
            Some("Exploring the decentralized web.".to_string()),
        );

        let result = user.validate(None);
        assert!(result.is_ok());
    }

    #[test]
    fn test_validate_invalid_name() {
        // Test name too short
        let user = PubkyAppUser::new(
            "Al".to_string(), // Too short
            None,
            None,
            None,
            None,
        );

        let result = user.validate(None);
        assert!(result.is_err());
        assert_eq!(
            result.unwrap_err().to_string(),
            "Validation Error: Invalid name length"
        );

        // Test name too long - sanitization should NOT truncate
        let long_name = "a".repeat(VALIDATION_LIMITS.user_name_max_length + 1);
        let user = PubkyAppUser::new(long_name.clone(), None, None, None, None);

        // Sanitization should preserve full length
        assert_eq!(user.name.len(), VALIDATION_LIMITS.user_name_max_length + 1);

        // Validation should catch the violation
        let result = user.validate(None);
        assert!(result.is_err());
        assert!(result.unwrap_err().contains("Invalid name length"));
    }

    #[test]
    fn test_try_from_valid() {
        let user_json = r#"
        {
            "name": "Alice",
            "bio": "Maximalist",
            "image": "https://example.com/image.png",
            "links": [
                {
                    "title": "GitHub",
                    "url": "https://github.com/alice"
                },
                {
                    "title": "Website",
                    "url": "https://alice.dev"
                }
            ],
            "status": "Exploring the decentralized web."
        }
        "#;

        let blob = user_json.as_bytes();
        let user = <PubkyAppUser as Validatable>::try_from(blob, "").unwrap();

        assert_eq!(user.name, "Alice");
        assert_eq!(user.bio.as_deref(), Some("Maximalist"));
        assert_eq!(user.image.as_deref(), Some("https://example.com/image.png"));
        assert_eq!(
            user.status.as_deref(),
            Some("Exploring the decentralized web.")
        );
        assert!(user.links.is_some());
        assert_eq!(user.links.as_ref().unwrap().len(), 2);
    }

    #[test]
    fn test_try_from_invalid_link() {
        let user_json = r#"
        {
            "name": "Alice",
            "links": [
                {
                    "title": "GitHub",
                    "url": "invalid_url"
                }
            ]
        }
        "#;

        let blob = user_json.as_bytes();
        let result = <PubkyAppUser as Validatable>::try_from(blob, "");

        // Invalid link URL should cause validation to fail
        assert!(result.is_err());
        assert!(result.unwrap_err().contains("Invalid URL format"));
    }

    #[test]
    fn test_validate_invalid_image_url() {
        let user_json = r#"
        {
            "name": "Alice",
            "image": "invalid_image_url"
        }
        "#;

        let blob = user_json.as_bytes();
        let result = <PubkyAppUser as Validatable>::try_from(blob, "");

        // Invalid image URL should cause validation to fail
        assert!(result.is_err());
        assert!(result.unwrap_err().contains("Invalid image URI format"));
    }

    #[test]
    fn test_sanitize_preserves_invalid_urls() {
        // Sanitize should preserve invalid URLs (just trim), validation rejects them
        let user = PubkyAppUser {
            name: "Alice".to_string(),
            bio: None,
            image: Some("  invalid_image_url  ".to_string()),
            links: Some(vec![PubkyAppUserLink {
                title: "Test".to_string(),
                url: "  invalid_link_url  ".to_string(),
            }]),
            status: None,
        };

        let sanitized = user.sanitize();

        // Image should be trimmed but preserved
        assert_eq!(sanitized.image.as_deref(), Some("invalid_image_url"));

        // Link should be trimmed but preserved
        let links = sanitized.links.as_ref().unwrap();
        assert_eq!(links.len(), 1);
        assert_eq!(links[0].url, "invalid_link_url");

        // Validation should reject
        let result = sanitized.validate(None);
        assert!(result.is_err());
    }

    #[test]
    fn test_sanitize_preserves_length() {
        // Test that sanitization does NOT truncate, even if over limits
        let long_bio = "a".repeat(VALIDATION_LIMITS.user_bio_max_length + 10);
        let long_status = "b".repeat(VALIDATION_LIMITS.user_status_max_length + 10);
        let long_image = format!(
            "https://example.com/{}.png",
            "a".repeat(VALIDATION_LIMITS.user_image_url_max_length - 30)
        );

        let user = PubkyAppUser::new(
            "Alice".to_string(),
            Some(long_bio.clone()),
            Some(long_image.clone()),
            None,
            Some(long_status.clone()),
        );

        // Sanitization should preserve full length (only trim whitespace)
        assert_eq!(user.bio.as_deref(), Some(long_bio.as_str()));
        assert_eq!(user.status.as_deref(), Some(long_status.as_str()));
        assert_eq!(user.image.as_deref(), Some(long_image.as_str()));
    }

    #[test]
    fn test_validate_field_length_errors() {
        // Test multiple field length validation errors
        let test_cases = vec![
            (
                PubkyAppUser::new(
                    "Alice".to_string(),
                    Some("a".repeat(VALIDATION_LIMITS.user_bio_max_length + 1)),
                    None,
                    None,
                    None,
                ),
                "bio",
            ),
            (
                PubkyAppUser::new(
                    "Alice".to_string(),
                    None,
                    None,
                    None,
                    Some("a".repeat(VALIDATION_LIMITS.user_status_max_length + 1)),
                ),
                "status",
            ),
            (
                PubkyAppUser::new(
                    "Alice".to_string(),
                    None,
                    Some(format!(
                        "https://example.com/{}.png",
                        "a".repeat(VALIDATION_LIMITS.user_image_url_max_length - 20)
                    )),
                    None,
                    None,
                ),
                "image",
            ),
        ];

        for (user, field_name) in test_cases {
            let result = user.validate(None);
            assert!(
                result.is_err(),
                "Should reject {} that exceeds maximum length",
                field_name
            );
            assert!(result.unwrap_err().contains("exceeds maximum length"));
        }
    }

    #[test]
    fn test_validate_too_many_links() {
        let mut links = Vec::new();
        for i in 0..VALIDATION_LIMITS.user_links_max_count + 1 {
            links.push(PubkyAppUserLink {
                title: format!("Link {}", i),
                url: format!("https://example.com/{}", i),
            });
        }

        let user = PubkyAppUser::new("Alice".to_string(), None, None, Some(links), None);

        // Sanitization should preserve all links (not truncate)
        assert_eq!(
            user.links.as_ref().unwrap().len(),
            VALIDATION_LIMITS.user_links_max_count + 1
        );

        // Validation should catch the violation
        let result = user.validate(None);
        assert!(result.is_err());
        assert!(result.unwrap_err().contains("Too many links"));
    }

    #[test]
    fn test_validate_link_length_errors() {
        // Test link title too long
        let long_title = "a".repeat(VALIDATION_LIMITS.user_link_title_max_length + 1);
        let link = PubkyAppUserLink {
            title: long_title.clone(),
            url: "https://example.com".to_string(),
        };
        let sanitized = link.sanitize();
        assert_eq!(
            sanitized.title.len(),
            VALIDATION_LIMITS.user_link_title_max_length + 1
        );
        let result = sanitized.validate(None);
        assert!(result.is_err());
        assert!(result.unwrap_err().contains("exceeds maximum length"));

        // Test link URL too long - create URL that exceeds limit after normalization
        let very_long_path = "a".repeat(VALIDATION_LIMITS.user_link_url_max_length);
        let very_long_url = format!("https://example.com/{}", very_long_path);
        let link2 = PubkyAppUserLink {
            title: "Test".to_string(),
            url: very_long_url,
        };
        let sanitized2 = link2.sanitize();

        // Verify URL exceeds limit (accounting for potential normalization)
        if sanitized2.url.chars().count() > VALIDATION_LIMITS.user_link_url_max_length {
            let result = sanitized2.validate(None);
            assert!(
                result.is_err(),
                "Expected validation error for URL length {}, max is {}",
                sanitized2.url.chars().count(),
                VALIDATION_LIMITS.user_link_url_max_length
            );
            assert!(result.unwrap_err().contains("exceeds maximum length"));
        } else {
            // If normalization shortened it, create an even longer one
            let extremely_long_path = "a".repeat(VALIDATION_LIMITS.user_link_url_max_length + 50);
            let extremely_long_url = format!("https://example.com/{}", extremely_long_path);
            let link3 = PubkyAppUserLink {
                title: "Test".to_string(),
                url: extremely_long_url,
            };
            let sanitized3 = link3.sanitize();
            let result = sanitized3.validate(None);
            assert!(
                result.is_err(),
                "Expected validation error for URL length {}, max is {}",
                sanitized3.url.chars().count(),
                VALIDATION_LIMITS.user_link_url_max_length
            );
            assert!(result.unwrap_err().contains("exceeds maximum length"));
        }
    }

    #[test]
    fn test_unicode_character_counting() {
        // Emoji name: 3 emoji characters (each is 1 char but multiple bytes)
        // This verifies .chars().count() is used instead of .len()
        let emoji_name = "Hi👋🏻Bob"; // 7 characters: H, i, 👋, 🏻, B, o, b
        let user = PubkyAppUser::new(emoji_name.to_string(), None, None, None, None);
        assert!(
            user.validate(None).is_ok(),
            "Should accept emoji in name (counts chars, not bytes)"
        );

        // Unicode bio with various scripts
        let unicode_bio = "你好世界 🌍 مرحبا"; // Mix of Chinese, emoji, Arabic
        let user_with_bio = PubkyAppUser::new(
            "Alice".to_string(),
            Some(unicode_bio.to_string()),
            None,
            None,
            None,
        );
        assert!(
            user_with_bio.validate(None).is_ok(),
            "Should accept multi-script Unicode in bio"
        );

        // Test that emoji-heavy string at max length passes
        // VALIDATION_LIMITS.user_name_max_length is 50, so 50 emoji should pass
        let max_emoji_name: String = "🔥".repeat(VALIDATION_LIMITS.user_name_max_length);
        assert_eq!(
            max_emoji_name.chars().count(),
            VALIDATION_LIMITS.user_name_max_length
        );
        let user_max_emoji = PubkyAppUser::new(max_emoji_name, None, None, None, None);
        assert!(
            user_max_emoji.validate(None).is_ok(),
            "Should accept {} emoji characters as name",
            VALIDATION_LIMITS.user_name_max_length
        );
    }
}