Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion matrix-client.cabal
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Network/Matrix/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions src/Network/Matrix/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down