cheogram-smtp

created pr with cheogram-smtp/ignore-empty.1 on 2026-10-21T15:32:06Z · by 9e834e0d
changed pr name to Do not send empty emails for empty messages on 2026-10-21T15:32:32Z · by 9e834e0d
cmds
checkout latest patchset:
ssh pr.pico.sh pull cheogram-smtp:ignore-empty | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-smtp:ignore-empty [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-smtp:ignore-empty
add comment to patch request:
ssh pr.pico.sh comment cheogram-smtp:ignore-empty "lgtm!"
+2 -1 IQManager.hs #
......@@ -2,6 +2,7 @@ module IQManager (iqManager, iqManager') where
22
33 import Prelude ()
44 import BasicPrelude
5+import Data.Functor (($>))
56 import Control.Concurrent.STM (
67 STM, TMVar, TVar, modifyTVar', newEmptyTMVar, newTVar, orElse,
78 readTVar, takeTMVar, tryPutTMVar, writeTVar
......@@ -38,7 +39,7 @@ iqSenderUnexceptional responseMapVar iqToSend = do
3839 atomicUIO $ modifyTVar' responseMapVar $
3940 Map.insert (XMPP.iqID iqToSend) iqResponseVar
4041 return (
41- (waitDelay timeout *> pure Nothing)
42+ (waitDelay timeout $> Nothing)
4243 `orElse`
4344 fmap Just (takeTMVar iqResponseVar)
4445 )
+3 -3 MMS.hs #
......@@ -75,12 +75,12 @@ emailToMMS ::
7575 -> Maybe (MMS, [(CID.CID, ByteString)])
7676 emailToMMS attachmentUrl ownerT email = do
7777 _ <- header "content-type"
78- mid' <- fmap decodeUtf8 $ header "x-internal-message-id"
78+ mid' <- decodeUtf8 <$> header "x-internal-message-id"
7979 time' <- parseTimeM True defaultTimeLocale rfc822DateFormat .
8080 textToString . decodeUtf8 =<<
8181 header "date"
82- from' <- addressTel =<<
83- fmap (Address . MIME.Single) (fromMailbox email)
82+ from' <- addressTel . Address . MIME.Single =<<
83+ fromMailbox email
8484 owner' <- addressTel $ AddressLax ownerT
8585 return (MMS mid' time' to' from' owner' text' media', files)
8686 where
+3 -2 Util.hs #
......@@ -6,6 +6,7 @@ import Control.Concurrent.STM (STM, atomically)
66 import Control.Applicative (many)
77 import Control.Concurrent
88 (ThreadId, forkFinally, myThreadId, throwTo)
9+import Data.Functor (($>))
910 import Data.Void (absurd)
1011 import Control.Error (exceptT)
1112 import Data.Time.Clock (UTCTime)
......@@ -46,7 +47,7 @@ escapeJid txt = mconcat result
4647 replace '@' "\\40" <|>
4748 fmap Text.singleton Atto.anyChar
4849 ) <* Atto.endOfInput) txt
49- replace c str = Atto.char c *> pure (fromString str)
50+ replace c str = Atto.char c $> fromString str
5051
5152 -- XEP-0106 says to only escape \ when absolutely necessary
5253 slashEscape :: Atto.Parser Text
......@@ -66,7 +67,7 @@ unescapeJid txt = fromString result
6667 (Atto.char '\\' *> Atto.choice unescapes) <|>
6768 Atto.anyChar
6869 ) <* Atto.endOfInput) txt
69- unescapes = map (\(str, c) -> Atto.string (fromString str) *> pure c) [
70+ unescapes = map (\(str, c) -> Atto.string (fromString str) $> c) [
7071 ("20", ' '), ("22", '"'), ("26", '&'), ("27", '\''),
7172 ("2f", '/'), ("3a", ':'), ("3c", '<'), ("3e", '>'),
7273 ("40", '@'), ("5c", '\\')
+2 -2 gateway.hs #
......@@ -60,7 +60,7 @@ iqSetHandler replyMap componentJid trustedJids iq@XMPP.IQ {
6060 } | to == componentJid && bareJid from `elem` trustedJids = do
6161 uuid <- liftIO UUID.nextRandom
6262 let Just sid =
63- (XMPP.stanzaID =<< fmap RawComponentStanza payload) <|>
63+ (XMPP.stanzaID . RawComponentStanza =<< payload) <|>
6464 Just (UUID.toText uuid)
6565 atomicUIO $ STMMap.insert iq (Just sid) replyMap
6666 mapM_ XMPP.putStanza $
......@@ -199,7 +199,7 @@ iqGetHandler iq@XMPP.IQ {
199199 \Part of the Soprani.ca project.")
200200 ]
201201 where
202- nodeAttribute = fmap (\node -> (s"node", [XML.ContentText node])) $
202+ nodeAttribute = (\node -> (s"node", [XML.ContentText node])) <$>
203203 XML.attributeText (s"node") p
204204 iqGetHandler iq = XMPP.putStanza $ iqError notImplemented iq
205205
+1 -2 test/VCardTest.hs #
......@@ -29,8 +29,7 @@ data VCardResult = VCardResult VCard XMPP.IQ deriving (Show)
2929 instance Arbitrary VCardResult where
3030 arbitrary = do
3131 vcard <- VCard <$> arbitrary <*> arbitrary <*> arbitrary
32- iq <- XMPP.IQ <$>
33- pure XMPP.IQResult <*>
32+ iq <- XMPP.IQ XMPP.IQResult <$>
3433 arbitrary <*>
3534 arbitrary <*>
3635 arbitrary <*>
Back to top