From 098de69b5b9c717aa87dcbe96c375c3bec533e61 Mon Sep 17 00:00:00 2001 From: shum Date: Wed, 21 Oct 2026 22:25:45 +0000 Subject: [PATCH] store: dispatch name codes on the length digits --- src/Simplex/Chat/Badges/Code.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Simplex/Chat/Badges/Code.hs b/src/Simplex/Chat/Badges/Code.hs index cd23154fd2..d0b615be33 100644 --- a/src/Simplex/Chat/Badges/Code.hs +++ b/src/Simplex/Chat/Badges/Code.hs @@ -157,9 +157,11 @@ nameCodePrefix = "SN" parseNameCode :: Text -> Maybe NameCode parseNameCode t = do body <- T.stripPrefix nameCodePrefix $ T.toUpper $ T.filter isAlphaNum t - if T.length body == nameOwnerCodeLength - then NCOwner <$> parseOwnerBody body - else NCPrepaid <$> parsePrepaidBody body + case T.length body of + n + | n == nameOwnerCodeLength -> NCOwner <$> parseOwnerBody body + | n - codeLength `elem` [1 .. length (show maxPrepaidNameLength)] -> NCPrepaid <$> parsePrepaidBody body + | otherwise -> Nothing -- | The code as it is shown and printed. formatNameCode :: NameCode -> Text