chiark / gitweb /
Filled in account flags.
authorSimon Tatham <anakin@pobox.com>
Mon, 1 Jan 2024 12:05:24 +0000 (12:05 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 1 Jan 2024 12:05:24 +0000 (12:05 +0000)
I think that's Examine User all done now!

src/text.rs

index 1833dbd4465c48dbc17a3046771841dea47ae0a5..fefb89dcd1a9f5142df7847411e2185a19befcef 100644 (file)
@@ -1492,6 +1492,7 @@ pub struct ExamineUserDisplay {
     post_count: Paragraph,
     followers_count: Paragraph,
     following_count: Paragraph,
+    flags: Vec<Paragraph>,
     relationships: Vec<Paragraph>,
     blank: BlankLine,
 }
@@ -1545,6 +1546,42 @@ impl ExamineUserDisplay {
             .add(&ColouredString::plain(
                 &format!("Number of users followed: {}", ac.following_count)));
 
+        let mut flags = Vec::new();
+        if ac.locked {
+            flags.push(Paragraph::new()
+                       .add(&ColouredString::plain("This account is "))
+                       .add(&ColouredString::uniform("locked", 'r'))
+                       .add(&ColouredString::plain(
+                           " (you can't follow it without its permission).")));
+        }
+        if ac.suspended.unwrap_or(false) {
+            flags.push(Paragraph::new().add(
+                &ColouredString::uniform(
+                    "This account is suspended.", 'r')));
+        }
+        if ac.limited.unwrap_or(false) {
+            flags.push(Paragraph::new().add(
+                &ColouredString::uniform(
+                    "This account is silenced.", 'r')));
+        }
+        if ac.bot {
+            flags.push(Paragraph::new().add(
+                &ColouredString::plain(
+                    "This account identifies as a bot.")));
+        }
+        if ac.group {
+            flags.push(Paragraph::new().add(
+                &ColouredString::plain(
+                    "This account identifies as a group.")));
+        }
+        if let Some(moved_to) = ac.moved {
+            flags.push(Paragraph::new()
+                       .add(&ColouredString::uniform(
+                           "This account has moved to:", 'r'))
+                       .add(&ColouredString::plain(
+                           &format!(" {}", client.fq(&moved_to.acct)))));
+        }
+
         let mut relationships = Vec::new();
         if ac.id == client.our_account_id() {
             relationships.push(Paragraph::new().set_indent(2, 2).add(
@@ -1630,6 +1667,7 @@ impl ExamineUserDisplay {
             post_count,
             followers_count,
             following_count,
+            flags,
             relationships,
             blank: BlankLine::new(),
         })
@@ -1669,7 +1707,12 @@ impl TextFragment for ExamineUserDisplay {
             push_fragment(&mut lines, self.blank.render(width));
         }
 
-        // FIXME: flags
+        if !self.flags.is_empty() {
+            for para in &self.flags {
+                push_fragment(&mut lines, para.render(width));
+            }
+            push_fragment(&mut lines, self.blank.render(width));
+        }
 
         if !self.relationships.is_empty() {
             for para in &self.relationships {