diff --git a/CHANGELOG.md b/CHANGELOG.md index 47c1df6..7c97e7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.8.0 + +- Add support for reaction [#48](https://github.com/softwarefactory-project/matrix-client-haskell/pull/48) + ## 0.1.7.0 - Improve login response by making the home server field optional [#45](https://github.com/softwarefactory-project/matrix-client-haskell/pull/45) diff --git a/matrix-client.cabal b/matrix-client.cabal index 7e57f47..aaa081a 100644 --- a/matrix-client.cabal +++ b/matrix-client.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: matrix-client -version: 0.1.7.0 +version: 0.1.8.0 synopsis: A matrix client library description: Matrix client is a library to interface with https://matrix.org. diff --git a/src/Network/Matrix/Client.hs b/src/Network/Matrix/Client.hs index 2c944ba..c1d951b 100644 --- a/src/Network/Matrix/Client.hs +++ b/src/Network/Matrix/Client.hs @@ -1228,7 +1228,7 @@ mkReply room re mt = EventRoomMessage (RoomMessageText oldMT) -> updateText oldMT EventRoomReply _ (RoomMessageText oldMT) -> updateText oldMT EventRoomEdit _ (RoomMessageText oldMT) -> updateText oldMT - EventReaction _ _ -> error $ "Can't reply to reaction" + EventReaction _ _ -> error "Can't reply to reaction" EventUnknown x -> error $ "Can't reply to " <> show x in EventRoomReply eventID (RoomMessageText newMessage) diff --git a/src/Network/Matrix/Events.hs b/src/Network/Matrix/Events.hs index 61738a8..4fed9bc 100644 --- a/src/Network/Matrix/Events.hs +++ b/src/Network/Matrix/Events.hs @@ -64,7 +64,7 @@ messageTextAttr msg = formattedBody = omitNull "formatted_body" $ mtFormattedBody msg reactionAttr :: [Pair] -reactionAttr = [ "msg_type" .= ("m.reaction" :: Text) ] +reactionAttr = ["msg_type" .= ("m.reaction" :: Text)] instance ToJSON MessageText where toJSON = object . messageTextAttr @@ -144,8 +144,9 @@ instance FromJSON Event where parseRelated = do relateM <- content .: "m.relates_to" case relateM of - Object relate -> parseReply relate - <|> parseByRelType relate + Object relate -> + parseReply relate + <|> parseByRelType relate _ -> mzero -- rich replies is a special kind of a relationship not using rel_type -- https://spec.matrix.org/v1.17/client-server-api/#rich-replies @@ -173,7 +174,7 @@ eventType event = case event of EventRoomMessage _ -> "m.room.message" EventRoomReply _ _ -> "m.room.message" EventRoomEdit _ _ -> "m.room.message" - EventReaction _ _ -> "m.reaction" -- https://spec.matrix.org/latest/client-server-api/#mreaction + EventReaction _ _ -> "m.reaction" -- https://spec.matrix.org/latest/client-server-api/#mreaction EventUnknown _ -> error $ "Event is not implemented: " <> show event newtype Annotation = Annotation {unAnnotation :: Text} deriving (Show, Eq, Ord) diff --git a/test/Spec.hs b/test/Spec.hs index 4598df6..69e3628 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -101,7 +101,7 @@ spec = describe "unit tests" $ do case resp of Right (Right (EventReaction eventID (Annotation annText))) -> do eventID `shouldBe` EventID "$eventID" - annText `shouldBe` "\128077" -- :+1: + annText `shouldBe` "\128077" -- :+1: _ -> error $ show resp it "encode room message" $ encodePretty (RoomMessageText (MessageText "Hello" TextType Nothing Nothing))