From dd137da665c46db5e58c16c83d92b3750e6bfac2 Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Wed, 22 Mar 2023 15:02:19 +0000 Subject: [PATCH] chore(apc): ensure apc ident format after discussion with Massente --- src/Utils/Print/Letters.hs | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/Utils/Print/Letters.hs b/src/Utils/Print/Letters.hs index 4b5016fe1..82212c8be 100644 --- a/src/Utils/Print/Letters.hs +++ b/src/Utils/Print/Letters.hs @@ -144,11 +144,13 @@ templateLatex = PlainLogo -> tPlain Plain -> tPlain -paperKind :: LetterKind -> Text -paperKind Din5008 = "a4logo" -paperKind PinLetter = "a4pin" -- "a4pinp" -paperKind Plain = "a4plain" -- "a4emty" -paperKind PlainLogo = "a4logo" +paperKind :: LetterKind -> Text -- Muss genau 5 Zeichen haben! +paperKind PinLetter = "a4pin" -- Pin-Brief +paperKind Plain = "a4wht" -- Ohne Logo +paperKind Din5008 = "a4log" -- Mit Logo +paperKind PlainLogo = "a4log" + + @@ -160,7 +162,7 @@ paperKind PlainLogo = "a4logo" --------------- apcIdentSeparator :: Text -apcIdentSeparator = "___" +apcIdentSeparator = Text.take 3 "___" -- must always have length 3 data PrintJobIdentification = PrintJobIdentification { pjiName :: Text @@ -173,17 +175,22 @@ data PrintJobIdentification = PrintJobIdentification } deriving (Eq, Show) --- | create an identifier for printing with apc; which must always be place in the same position for all letters, printed in white on white --- Note that all letters to the same UUID within 24h are collated in one envelope +-- | create an identifier for printing with apc; which must always be place with the same length; exept for the last part which may be of variable length +-- this is printed in white on white at the exact same position on the page +-- Note: that all letters to the same UUID within 24h are collated in one envelope +-- Example: 9ad8de3f-0a7e-ede5-bd8b-6d0ed85c1049-f___a4pin___230322-10___lms-stuvwxyz mkApcIdent :: CryptoUUIDUser -> Char -> LetterKind -> Text -> Text -> Text -mkApcIdent uuid envelope lk tnow apcAck = Text.filter apcAcceptedChars $ Text.intercalate apcIdentSeparator - [ tshow (ciphertext uuid) <> Text.cons '-' (Text.singleton envelope) - , paperKind lk - , tnow - , apcAck +mkApcIdent uuid envelope lk tnow apcAck = Text.filter apcAcceptedChars $ Text.intercalate apcIdentSeparator + [ ensureLength 38 $ tshow (ciphertext uuid) <> Text.cons '-' (Text.singleton envelope) + , ensureLength 5 $ paperKind lk + , ensureLength 9 tnow + , apcAck -- length may be arbitrary, thus far was always 12 ] - --- | Character allowed to be included in the APC identifier string printed in white in the header of all printed letters + where + ensureLength :: Int -> Text -> Text + ensureLength n = Text.take n . Text.justifyLeft n 'x' + +-- | Character allowed to be included in the APC identifier string printed in white in the header of all printed letters, must not contain ',' nor ';' apcAcceptedChars :: Char -> Bool apcAcceptedChars '-' = True apcAcceptedChars '_' = True