1 files changed, 7 insertions(+), 4 deletions(-)
M Main.hs
M Main.hs => Main.hs +7 -4
@@ 374,12 374,15 @@ stripOtrWhitespaceOnce body =
stripOtrWhitespace = stripOtrWhitespaceOnce . stripOtrWhitespaceOnce . stripOtrWhitespaceOnce . stripOtrWhitespaceOnce . stripOtrWhitespaceOnce
-mapBody f (m@Message { messagePayloads = payloads }) =
+mapBody :: (Text -> Text) -> XMPP.Message -> XMPP.Message
+mapBody f = mapBodyMaybe (Just . f)
+
+mapBodyMaybe f (m@Message { messagePayloads = payloads }) =
m { messagePayloads =
- map (\payload ->
+ mapMaybe (\payload ->
case isNamed (s"{jabber:component:accept}body") payload of
- [] -> payload
- _ -> payload { elementNodes = [NodeContent $ ContentText $ f (concat (elementText payload))] }
+ [] -> Just payload
+ _ -> fmap (\c -> payload { elementNodes = [NodeContent $ ContentText c]}) (f (concat (elementText payload)))
) payloads
}