From a61df1522ddf8a36839cf1180d3b16e354459e9a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 29 Apr 2017 14:46:45 -0400 Subject: user gpg key checking and prompting done! --- Gpg/Wot.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Gpg') diff --git a/Gpg/Wot.hs b/Gpg/Wot.hs index fc7b8a4..cdf079a 100644 --- a/Gpg/Wot.hs +++ b/Gpg/Wot.hs @@ -84,26 +84,31 @@ knownKeyInStrongSet :: GpgKeyId knownKeyInStrongSet = GpgKeyId "E85A5F63B31D24C1EBF0D81CC910D9222512E3C7" newtype StrongSetAnalysis = StrongSetAnalysis Bool + deriving (Show) isInStrongSet :: GpgKeyId -> IO StrongSetAnalysis isInStrongSet k = maybe (StrongSetAnalysis False) (const $ StrongSetAnalysis True) <$> downloadWotPath k knownKeyInStrongSet -describeWot :: WotStats -> StrongSetAnalysis -> String -describeWot ws (StrongSetAnalysis ss) +describeWot :: Maybe WotStats -> StrongSetAnalysis -> String +describeWot (Just ws) (StrongSetAnalysis ss) | ss == False = theirname ++ "'s identity cannot be verified!" | otherwise = unlines $ [ theirname ++ "'s identity has been verified by as many as " ++ show (length sigs) ++ " people, including:" - , intercalate ", " $ take 10 $ map (stripEmail . uid) bestconnectedsigs + , intercalate ", " $ take 10 $ nub $ + map (stripEmail . uid) bestconnectedsigs , "" , theirname ++ " is probably a real person." ] where theirname = stripEmail (uid (key ws)) sigs = cross_sigs ws ++ other_sigs ws - nsigs = length sigs bestconnectedsigs = sortOn rank sigs +describeWot Nothing _ = unlines + [ "" + , "Their identity cannot be verified!" + ] stripEmail :: String -> String stripEmail = unwords . takeWhile (not . ("<" `isPrefixOf`)) . words -- cgit v1.2.3